mirror of
https://github.com/Ujwal223/FocusGram.git
synced 2026-05-28 17:51:28 +02:00
V2 Release
This commit is contained in:
@@ -17,7 +17,8 @@ void main() {
|
||||
test('accepts http(s) instagram-like hosts and calls launcher', () async {
|
||||
final launched = <Uri>[];
|
||||
final ok = await handleFocusGramMediaDownload(
|
||||
raw: '{"type":"video","url":"https://cdninstagram.com/v/1.mp4","filename":"x"}',
|
||||
raw:
|
||||
'{"type":"video","url":"https://cdninstagram.com/v/1.mp4","filename":"x"}',
|
||||
launch: (uri) async => launched.add(uri),
|
||||
);
|
||||
|
||||
@@ -30,7 +31,8 @@ void main() {
|
||||
test('rejects non-instagram hosts even if http(s)', () async {
|
||||
final launched = <Uri>[];
|
||||
final ok = await handleFocusGramMediaDownload(
|
||||
raw: '{"type":"video","url":"https://example.com/video.mp4","filename":"x"}',
|
||||
raw:
|
||||
'{"type":"video","url":"https://example.com/video.mp4","filename":"x"}',
|
||||
launch: (uri) async => launched.add(uri),
|
||||
);
|
||||
|
||||
|
||||
@@ -38,29 +38,32 @@ void main() {
|
||||
expect(raw, isNull);
|
||||
});
|
||||
|
||||
test('startTracking increments today seconds and stopTracking persists', () async {
|
||||
final s = ScreenTimeService();
|
||||
await s.init();
|
||||
test(
|
||||
'startTracking increments today seconds and stopTracking persists',
|
||||
() async {
|
||||
final s = ScreenTimeService();
|
||||
await s.init();
|
||||
|
||||
final beforeTodayKey = DateTime.now();
|
||||
final todayKey =
|
||||
'${beforeTodayKey.year.toString().padLeft(4, '0')}-'
|
||||
'${beforeTodayKey.month.toString().padLeft(2, '0')}-'
|
||||
'${beforeTodayKey.day.toString().padLeft(2, '0')}';
|
||||
final beforeTodayKey = DateTime.now();
|
||||
final todayKey =
|
||||
'${beforeTodayKey.year.toString().padLeft(4, '0')}-'
|
||||
'${beforeTodayKey.month.toString().padLeft(2, '0')}-'
|
||||
'${beforeTodayKey.day.toString().padLeft(2, '0')}';
|
||||
|
||||
s.startTracking();
|
||||
s.startTracking();
|
||||
|
||||
// Wait ~2 seconds (test is unit-ish; still acceptable).
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
// Wait ~2 seconds (test is unit-ish; still acceptable).
|
||||
await Future<void>.delayed(const Duration(seconds: 2));
|
||||
|
||||
s.stopTracking();
|
||||
s.stopTracking();
|
||||
|
||||
expect(s.secondsByDate[todayKey], isNotNull);
|
||||
expect(s.secondsByDate[todayKey]!, greaterThanOrEqualTo(2));
|
||||
expect(s.secondsByDate[todayKey], isNotNull);
|
||||
expect(s.secondsByDate[todayKey]!, greaterThanOrEqualTo(2));
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final stored = prefs.getString(ScreenTimeService.prefKey);
|
||||
expect(stored, isNotNull);
|
||||
expect(stored, contains(todayKey));
|
||||
});
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final stored = prefs.getString(ScreenTimeService.prefKey);
|
||||
expect(stored, isNotNull);
|
||||
expect(stored, contains(todayKey));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user