@@ -397,117 +397,165 @@ void main () {
397397 }
398398
399399 testWidgets ('smoke' , (tester) async {
400- addTearDown (testBinding.reset);
401- testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
402- await prepare (tester);
403- await tester.pump (loadPerAccountDuration);
404- checkOnHomePage (tester, expectedAccount: eg.selfAccount);
400+ final SemanticsHandle semanticsHandle = tester.ensureSemantics ();
401+ try {
402+ addTearDown (testBinding.reset);
403+ testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
404+ await prepare (tester);
405+
406+ // While loading, the loading page should be shown and have the semantics label.
407+ checkOnLoadingPage ();
408+ expect (find.bySemanticsLabel ('Loading…' ), findsOneWidget);
409+
410+ await tester.pump (loadPerAccountDuration);
411+ checkOnHomePage (tester, expectedAccount: eg.selfAccount);
412+ } finally {
413+ semanticsHandle.dispose ();
414+ }
405415 });
406416
407- testWidgets ('"Try another account" button appears after timeout' , (tester) async {
408- addTearDown (testBinding.reset);
409- testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
410- await prepare (tester);
411- checkOnLoadingPage ();
412- check (find.text ('Try another account' ).hitTestable ()).findsNothing ();
413-
414- await tester.pump (kTryAnotherAccountWaitPeriod);
415- checkOnLoadingPage ();
416- check (find.text ('Try another account' ).hitTestable ()).findsOne ();
417417
418- await tester.pump (loadPerAccountDuration);
419- checkOnHomePage (tester, expectedAccount: eg.selfAccount);
418+ testWidgets ('"Try another account" button appears after timeout' , (tester) async {
419+ final SemanticsHandle semanticsHandle = tester.ensureSemantics ();
420+ try {
421+ addTearDown (testBinding.reset);
422+ testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
423+ await prepare (tester);
424+ checkOnLoadingPage ();
425+ // No try-another button immediately.
426+ check (find.text ('Try another account' ).hitTestable ()).findsNothing ();
427+
428+ // The loading semantics should already be present.
429+ expect (find.bySemanticsLabel ('Loading…' ), findsOneWidget);
430+
431+ await tester.pump (kTryAnotherAccountWaitPeriod);
432+ checkOnLoadingPage ();
433+ check (find.text ('Try another account' ).hitTestable ()).findsOne ();
434+
435+ await tester.pump (loadPerAccountDuration);
436+ checkOnHomePage (tester, expectedAccount: eg.selfAccount);
437+ } finally {
438+ semanticsHandle.dispose ();
439+ }
420440 });
421441
422- testWidgets ('while loading, go back from ChooseAccountPage' , (tester) async {
423- testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
424- await prepare (tester);
425- await tester.pump (kTryAnotherAccountWaitPeriod);
426- await tapTryAnotherAccount (tester);
427442
428- lastPoppedRoute = null ;
429- await tester.tap (find.byType (BackButton ));
430- await tester.pump ();
431- check (lastPoppedRoute).isA <MaterialWidgetRoute >().page.isA <ChooseAccountPage >();
432- await tester.pump (
433- (lastPoppedRoute as TransitionRoute ).reverseTransitionDuration
434- // TODO not sure why a 1ms fudge is needed; investigate.
435- + Duration (milliseconds: 1 ));
436- checkOnLoadingPage ();
437-
438- await tester.pump (loadPerAccountDuration);
439- checkOnHomePage (tester, expectedAccount: eg.selfAccount);
443+ testWidgets ('while loading, go back from ChooseAccountPage' , (tester) async {
444+ final SemanticsHandle semanticsHandle = tester.ensureSemantics ();
445+ try {
446+ testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
447+ await prepare (tester);
448+ await tester.pump (kTryAnotherAccountWaitPeriod);
449+ await tapTryAnotherAccount (tester);
450+
451+ lastPoppedRoute = null ;
452+ await tester.tap (find.byType (BackButton ));
453+ await tester.pump ();
454+ check (lastPoppedRoute).isA <MaterialWidgetRoute >().page.isA <ChooseAccountPage >();
455+ await tester.pump (
456+ (lastPoppedRoute as TransitionRoute ).reverseTransitionDuration
457+ // TODO not sure why a 1ms fudge is needed; investigate.
458+ + Duration (milliseconds: 1 ));
459+ checkOnLoadingPage ();
460+
461+ // Semantics check: loading label present
462+ expect (find.bySemanticsLabel ('Loading…' ), findsOneWidget);
463+
464+ await tester.pump (loadPerAccountDuration);
465+ checkOnHomePage (tester, expectedAccount: eg.selfAccount);
466+ } finally {
467+ semanticsHandle.dispose ();
468+ }
440469 });
441470
442- testWidgets ('while loading, choose a different account' , (tester) async {
443- testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
444- await prepare (tester);
445- await tester.pump (kTryAnotherAccountWaitPeriod);
446- await tapTryAnotherAccount (tester);
447471
448- testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration * 2 ;
449- await chooseAccountWithEmail (tester, eg.otherAccount.email);
450-
451- await tester.pump (loadPerAccountDuration);
452- // The second loadPerAccount is still pending.
453- checkOnLoadingPage ();
454-
455- await tester.pump (loadPerAccountDuration);
456- // The second loadPerAccount finished.
457- checkOnHomePage (tester, expectedAccount: eg.otherAccount);
472+ testWidgets ('while loading, choose a different account' , (tester) async {
473+ final SemanticsHandle semanticsHandle = tester.ensureSemantics ();
474+ try {
475+ testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
476+ await prepare (tester);
477+ await tester.pump (kTryAnotherAccountWaitPeriod);
478+ await tapTryAnotherAccount (tester);
479+
480+ testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration * 2 ;
481+ await chooseAccountWithEmail (tester, eg.otherAccount.email);
482+
483+ // While the second account is still loading, we should be on a loading page.
484+ await tester.pump (loadPerAccountDuration);
485+ checkOnLoadingPage ();
486+ expect (find.bySemanticsLabel ('Loading…' ), findsOneWidget);
487+
488+ await tester.pump (loadPerAccountDuration);
489+ // The second load finished.
490+ checkOnHomePage (tester, expectedAccount: eg.otherAccount);
491+ } finally {
492+ semanticsHandle.dispose ();
493+ }
458494 });
459495
460- testWidgets ('while loading, choosing an account disallows going back' , (tester) async {
461- testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
462- await prepare (tester);
463- await tester.pump (kTryAnotherAccountWaitPeriod);
464- await tapTryAnotherAccount (tester);
465-
466- // While still loading, choose a different account.
467- await chooseAccountWithEmail (tester, eg.otherAccount.email);
468496
469- // User cannot go back because the navigator stack
470- // was cleared after choosing an account.
471- check (getRouteOf (tester, find.byType (CircularProgressIndicator )))
472- .isNotNull ().isFirst.isTrue ();
473-
474- await tester.pump (loadPerAccountDuration); // wait for loadPerAccount
475- checkOnHomePage (tester, expectedAccount: eg.otherAccount);
497+ testWidgets ('while loading, choosing an account disallows going back' , (tester) async {
498+ final SemanticsHandle semanticsHandle = tester.ensureSemantics ();
499+ try {
500+ testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
501+ await prepare (tester);
502+ await tester.pump (kTryAnotherAccountWaitPeriod);
503+ await tapTryAnotherAccount (tester);
504+
505+ // While still loading, choose a different account.
506+ await chooseAccountWithEmail (tester, eg.otherAccount.email);
507+
508+ // User cannot go back because the navigator stack was cleared after choosing an account.
509+ check (getRouteOf (tester, find.byType (CircularProgressIndicator )))
510+ .isNotNull ().isFirst.isTrue ();
511+
512+ // Semantics check: ensure loading label present and first route is our account route.
513+ expect (find.bySemanticsLabel ('Loading…' ), findsOneWidget);
514+
515+ await tester.pump (loadPerAccountDuration); // wait for loadPerAccount
516+ checkOnHomePage (tester, expectedAccount: eg.otherAccount);
517+ } finally {
518+ semanticsHandle.dispose ();
519+ }
476520 });
477521
478- testWidgets ('while loading, go to nested levels of ChooseAccountPage' , (tester) async {
479- testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
480- final thirdAccount = eg.account (user: eg.thirdUser);
481- await testBinding.globalStore.add (thirdAccount, eg.initialSnapshot (
482- realmUsers: [eg.thirdUser]));
483- await prepare (tester);
484522
485- await tester.pump (kTryAnotherAccountWaitPeriod);
486- // While still loading the first account, choose a different account.
487- await tapTryAnotherAccount (tester);
488- await chooseAccountWithEmail (tester, eg.otherAccount.email);
489- // User cannot go back because the navigator stack
490- // was cleared after choosing an account.
491- check (getRouteOf (tester, find.byType (CircularProgressIndicator )))
492- .isA <MaterialAccountWidgetRoute >()
523+ testWidgets ('while loading, go to nested levels of ChooseAccountPage' , (tester) async {
524+ final SemanticsHandle semanticsHandle = tester.ensureSemantics ();
525+ try {
526+ testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
527+ final thirdAccount = eg.account (user: eg.thirdUser);
528+ await testBinding.globalStore.add (thirdAccount, eg.initialSnapshot (
529+ realmUsers: [eg.thirdUser]));
530+ await prepare (tester);
531+
532+ await tester.pump (kTryAnotherAccountWaitPeriod);
533+ await tapTryAnotherAccount (tester);
534+ await chooseAccountWithEmail (tester, eg.otherAccount.email);
535+ check (getRouteOf (tester, find.byType (CircularProgressIndicator )))
536+ .isA <MaterialAccountWidgetRoute >()
493537 ..isFirst.isTrue ()
494538 ..accountId.equals (eg.otherAccount.id);
495539
496- await tester. pump (kTryAnotherAccountWaitPeriod);
497- // While still loading the second account, choose a different account.
498- await tapTryAnotherAccount (tester);
499- await chooseAccountWithEmail ( tester, thirdAccount.email );
500- // User cannot go back because the navigator stack
501- // was cleared after choosing an account.
502- check (getRouteOf (tester, find.byType (CircularProgressIndicator )))
503- .isA <MaterialAccountWidgetRoute >()
540+ // Semantics check: loading label present
541+ expect (find. bySemanticsLabel ( 'Loading…' ), findsOneWidget);
542+
543+ await tester. pump (kTryAnotherAccountWaitPeriod );
544+ await tapTryAnotherAccount (tester);
545+ await chooseAccountWithEmail (tester, thirdAccount.email);
546+ check (getRouteOf (tester, find.byType (CircularProgressIndicator )))
547+ .isA <MaterialAccountWidgetRoute >()
504548 ..isFirst.isTrue ()
505549 ..accountId.equals (thirdAccount.id);
506550
507- await tester.pump (loadPerAccountDuration); // wait for loadPerAccount
508- checkOnHomePage (tester, expectedAccount: thirdAccount);
551+ await tester.pump (loadPerAccountDuration); // wait for loadPerAccount
552+ checkOnHomePage (tester, expectedAccount: thirdAccount);
553+ } finally {
554+ semanticsHandle.dispose ();
555+ }
509556 });
510557
558+
511559 testWidgets ('after finishing loading, go back from ChooseAccountPage' , (tester) async {
512560 testBinding.globalStore.loadPerAccountDuration = loadPerAccountDuration;
513561 await prepare (tester);
0 commit comments