fix(app): the Pomodoro timer's permissions take effect as soon as they are given
All checks were successful
CI / check (push) Successful in 9m44s
CI / deploy (push) Successful in 14s

Found on the Pixel 9a with v0.2.1:

- Do Not Disturb while focusing: switching it on opens Android's list
  of apps with Do Not Disturb access; once the person allowed it there
  and came back, the switch was still off, saying the app may not, and
  had to be switched on again. The profile's sheet now looks again when
  the app comes back, and the switch goes on by itself once allowed.
- The timer's notification, posted while Android was still asking for
  leave to notify at the first start, showed nowhere until the timer
  next changed. It is now posted again as soon as notifications are
  allowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-07 14:26:05 +02:00
commit c89ef05a20
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -155,6 +155,58 @@ void main() {
expect(tester.widget<SwitchListTile>(quiet).value, isTrue);
});
testWidgets("allowed in the system's settings, keeping quiet switches on "
'by itself on coming back', (tester) async {
await showHome(tester);
await tester.tap(find.byTooltip('Pomodoro profiles'));
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Edit profile').first);
await tester.pumpAndSettle();
final quiet = find.widgetWithText(
SwitchListTile,
'Do Not Disturb while focusing',
);
await tester.ensureVisible(quiet);
await tester.pumpAndSettle();
await tester.tap(quiet);
await tester.pumpAndSettle();
expect(tester.widget<SwitchListTile>(quiet).value, isFalse);
// The person allows it in the system's settings, and comes back.
platform.allowsQuiet = true;
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
await tester.pumpAndSettle();
expect(tester.widget<SwitchListTile>(quiet).value, isTrue);
expect(find.textContaining('may not keep this device quiet'), findsNothing);
expect(platform.askedForQuiet, 1, reason: 'asked once, not again');
});
testWidgets('coming back without allowing it leaves keeping quiet off', (
tester,
) async {
await showHome(tester);
await tester.tap(find.byTooltip('Pomodoro profiles'));
await tester.pumpAndSettle();
await tester.tap(find.byTooltip('Edit profile').first);
await tester.pumpAndSettle();
final quiet = find.widgetWithText(
SwitchListTile,
'Do Not Disturb while focusing',
);
await tester.ensureVisible(quiet);
await tester.pumpAndSettle();
await tester.tap(quiet);
await tester.pumpAndSettle();
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
await tester.pumpAndSettle();
expect(tester.widget<SwitchListTile>(quiet).value, isFalse);
});
testWidgets('suggests setting up the top bar where it shows no icons, '
'until dismissed', (tester) async {
platform.suggestTopBar(suggest: true);