Files
sync_replay_project/apps/desktop/test/desktop_entry_test.dart
T
foxyzandClaude Opus 5.5 51c1c5ab78
ci / core (push) Successful in 31s
ci / server (push) Successful in 1m3s
ci / updater-windows (push) Successful in 6m6s
Restructure step R: the app is Starsync (dev.foxyz.starsync)
- Linux app id dev.foxyz.starsync, binary starsync; Windows starsync.exe,
  company foxyz; server starsync-server; Dart package starsync; archives
  starsync-<ver>-*.
- 1.2.x compatibility: watch_together and watch-together-server
  launchers (Linux) / copies (Windows) in the archive; the updater
  accepts both names and relaunches the new binary; update.sh/.bat use
  whichever server exists.
- First start copies (never moves) the old support folder and this
  app's Hive boxes out of ~/Documents into <support>/hive; a marker
  makes it run once; AppDirs is a port; settings schema version with
  ordered migrations.
- Launcher entry dev.foxyz.starsync.desktop; the old one removed.
- Repository name and URLs unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 20:21:20 +03:00

38 lines
1.8 KiB
Dart

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:starsync/src/platform/desktop_entry.dart';
void main() {
test('writes the Starsync entry, removes only the old id\'s files', () async {
final tmp = await Directory.systemTemp.createTemp('starsync-entry');
try {
final root = '${tmp.path}/install';
await Directory('$root/lib').create(recursive: true);
await Directory('$root/data/flutter_assets/assets/icon').create(recursive: true);
await File('$root/data/flutter_assets/assets/icon/icon_48.png').writeAsString('png');
final share = '${tmp.path}/share';
final apps = Directory('$share/applications')..createSync(recursive: true);
final oldEntry = File('${apps.path}/$legacyAppId.desktop')..writeAsStringSync('old');
final other = File('${apps.path}/other.app.desktop')..writeAsStringSync('keep');
final oldIcon = File('$share/icons/hicolor/48x48/apps/$legacyAppId.png')
..createSync(recursive: true);
final otherIcon = File('$share/icons/hicolor/48x48/apps/other.png')..createSync();
await installDesktopEntry(executable: '$root/starsync', dataHome: share, force: true);
expect(oldEntry.existsSync(), isFalse);
expect(oldIcon.existsSync(), isFalse);
expect(other.existsSync(), isTrue);
expect(otherIcon.existsSync(), isTrue);
final entry = File('${apps.path}/dev.foxyz.starsync.desktop').readAsStringSync();
expect(entry, contains('Exec="$root/starsync"'));
expect(entry, contains('StartupWMClass=dev.foxyz.starsync'));
expect(entry, contains('Icon=dev.foxyz.starsync'));
expect(File('$share/icons/hicolor/48x48/apps/dev.foxyz.starsync.png').existsSync(), isTrue);
} finally {
await tmp.delete(recursive: true);
}
}, skip: Platform.isLinux ? null : 'Linux launcher entry');
}