@@ -70,12 +70,12 @@ void main() {
70
70
return const SizedBox .shrink ();
71
71
})));
72
72
// First, shows a loading page instead of child.
73
- check (tester. any ( find.byType (CircularProgressIndicator ))). isTrue ();
73
+ check (find.byType (CircularProgressIndicator )). findsOne ();
74
74
check (globalStore).isNull ();
75
75
76
76
await tester.pump ();
77
77
// Then after loading, mounts child instead, with provided store.
78
- check (tester. any ( find.byType (CircularProgressIndicator ))). isFalse ();
78
+ check (find.byType (CircularProgressIndicator )). findsNothing ();
79
79
check (globalStore).identicalTo (testBinding.globalStore);
80
80
81
81
await testBinding.globalStore.add (eg.selfAccount, eg.initialSnapshot ());
@@ -84,6 +84,56 @@ void main() {
84
84
.equals ((accountId: eg.selfAccount.id, account: eg.selfAccount));
85
85
});
86
86
87
+ testWidgets ('GlobalStoreWidget awaits blockingFuture' , (tester) async {
88
+ addTearDown (testBinding.reset);
89
+
90
+ final completer = Completer <void >();
91
+ await tester.pumpWidget (Directionality (textDirection: TextDirection .ltr,
92
+ child: GlobalStoreWidget (
93
+ blockingFuture: completer.future,
94
+ child: Text ('done' ))));
95
+
96
+ await tester.pump ();
97
+ await tester.pump ();
98
+ await tester.pump ();
99
+ // Even after the store must have loaded,
100
+ // still shows loading page while blockingFuture is pending.
101
+ check (find.byType (CircularProgressIndicator )).findsOne ();
102
+ check (find.text ('done' )).findsNothing ();
103
+
104
+ // Once blockingFuture completes…
105
+ completer.complete ();
106
+ await tester.pump ();
107
+ // … mounts child instead of the loading page.
108
+ check (find.byType (CircularProgressIndicator )).findsNothing ();
109
+ check (find.text ('done' )).findsOne ();
110
+ });
111
+
112
+ testWidgets ('GlobalStoreWidget handles failed blockingFuture like success' , (tester) async {
113
+ addTearDown (testBinding.reset);
114
+
115
+ final completer = Completer <void >();
116
+ await tester.pumpWidget (Directionality (textDirection: TextDirection .ltr,
117
+ child: GlobalStoreWidget (
118
+ blockingFuture: completer.future,
119
+ child: Text ('done' ))));
120
+
121
+ await tester.pump ();
122
+ await tester.pump ();
123
+ await tester.pump ();
124
+ // Even after the store must have loaded,
125
+ // still shows loading page while blockingFuture is pending.
126
+ check (find.byType (CircularProgressIndicator )).findsOne ();
127
+ check (find.text ('done' )).findsNothing ();
128
+
129
+ // Once blockingFuture completes, even with an error…
130
+ completer.completeError (Exception ('oops' ));
131
+ await tester.pump ();
132
+ // … mounts child instead of the loading page.
133
+ check (find.byType (CircularProgressIndicator )).findsNothing ();
134
+ check (find.text ('done' )).findsOne ();
135
+ });
136
+
87
137
testWidgets ('GlobalStoreWidget.of updates dependents' , (tester) async {
88
138
addTearDown (testBinding.reset);
89
139
0 commit comments