mirror of
https://github.com/kuhyx/wake-alarm.git
synced 2026-11-24 02:26:26 +01:00
The launcher "Wstrzymaj aplikację" paused WakeAlarm mid-ring on 11-20 and 11-22. WakeAlarm is now a device admin, and a pause, admin removal, revoked notifications or full-screen intent, or a killed ring on a live morning is a bypass: a miss on any weekday, the phone rings again, and the PC rings at once until a newer dismiss or 30 min. The PC rings also go to every connected monitor, since the speakers are off at the knob overnight; a one-shot silent probe checks them at A-5. DOCS-bypass.md has the layers, causes and measurements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:wake_alarm_sync/services/alarm_scheduler.dart';
|
|
import 'package:wake_alarm_sync/services/enforcement_publish.dart';
|
|
import 'package:wake_alarm_sync/services/headless_ring_start.dart';
|
|
import 'package:wake_alarm_sync/services/session_handoff.dart';
|
|
|
|
/// A bypass and a dismiss reach the PC at once, not at the next sync
|
|
/// (2026-11-22): the PC rings for a bypass until it sees a newer dismiss.
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
late List<String> calls;
|
|
|
|
setUp(() {
|
|
calls = <String>[];
|
|
SharedPreferences.setMockInitialValues(<String, Object>{});
|
|
for (final name in [headlessChannelName, AlarmScheduler.channelName]) {
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(MethodChannel(name), (call) async {
|
|
calls.add(call.method);
|
|
return null;
|
|
});
|
|
}
|
|
});
|
|
|
|
test('the headless publish pushes once, then says done', () async {
|
|
var published = 0;
|
|
await runHeadlessPublish(
|
|
publish: () async {
|
|
published++;
|
|
return true;
|
|
},
|
|
);
|
|
expect(published, 1);
|
|
expect(calls, ['done']);
|
|
});
|
|
|
|
test('done is sent even when the publish blows up', () async {
|
|
await expectLater(
|
|
runHeadlessPublish(publish: () async => throw StateError('boom')),
|
|
throwsStateError,
|
|
);
|
|
expect(calls, ['done']);
|
|
});
|
|
|
|
test('with no sync backend nothing is pushed', () async {
|
|
expect(await publishEnforcementNow(), isFalse);
|
|
});
|
|
|
|
test('a dismiss publishes at once, after telling native', () async {
|
|
final order = <String>[];
|
|
final handoff = SessionHandoff(
|
|
scheduler: AlarmScheduler(),
|
|
now: () => DateTime(2026, 11, 22, 7, 40),
|
|
publishNow: () async {
|
|
order
|
|
..addAll(calls)
|
|
..add('publish');
|
|
return true;
|
|
},
|
|
);
|
|
await handoff.afterDismiss(away: true);
|
|
expect(order, ['markRingDismissed', 'publish']);
|
|
});
|
|
}
|