@@ -13,10 +13,19 @@ import '../api/fake_api.dart';
13
13
///
14
14
/// The per-account stores will use [FakeApiConnection] .
15
15
///
16
+ /// Unlike with [LiveGlobalStore] and the associated [UpdateMachine.load] ,
17
+ /// there is no automatic event-polling loop or other automated requests.
18
+ /// For each account loaded, there is a corresponding [UpdateMachine]
19
+ /// in [updateMachines] , which tests can use for invoking that logic
20
+ /// explicitly when desired.
21
+ ///
16
22
/// See also [TestZulipBinding.globalStore] , which provides one of these.
17
23
class TestGlobalStore extends GlobalStore {
18
24
TestGlobalStore ({required super .accounts});
19
25
26
+ /// A corresponding [UpdateMachine] for each loaded account.
27
+ final Map <int , UpdateMachine > updateMachines = {};
28
+
20
29
final Map <int , InitialSnapshot > _initialSnapshots = {};
21
30
22
31
/// Add an account and corresponding server data to the test data.
@@ -50,12 +59,16 @@ class TestGlobalStore extends GlobalStore {
50
59
51
60
@override
52
61
Future <PerAccountStore > loadPerAccount (Account account) {
53
- return Future .value (PerAccountStore .fromInitialSnapshot (
62
+ final initialSnapshot = _initialSnapshots[account.id]! ;
63
+ final store = PerAccountStore .fromInitialSnapshot (
54
64
globalStore: this ,
55
65
account: account,
56
66
connection: FakeApiConnection .fromAccount (account),
57
- initialSnapshot: _initialSnapshots[account.id]! ,
58
- ));
67
+ initialSnapshot: initialSnapshot,
68
+ );
69
+ updateMachines[account.id] = UpdateMachine .fromInitialSnapshot (
70
+ store: store, initialSnapshot: initialSnapshot);
71
+ return Future .value (store);
59
72
}
60
73
}
61
74
0 commit comments