@@ -78,7 +78,7 @@ void testMain() {
78
78
myWindow.sendPlatformMessage (
79
79
'flutter/navigation' ,
80
80
const JSONMethodCodec ().encodeMethodCall (
81
- const MethodCall ('routeUpdated ' , < String , dynamic > {'routeName ' : '/bar' }),
81
+ const MethodCall ('routeInformationUpdated ' , < String , dynamic > {'location ' : '/bar' }),
82
82
),
83
83
(_) {
84
84
callback.complete ();
@@ -125,30 +125,21 @@ void testMain() {
125
125
'selectMultiEntryHistory' ,
126
126
< String , dynamic > {},
127
127
); // -> multi
128
- await check <SingleEntryBrowserHistory >('routeUpdated' , < String , dynamic > {
129
- 'routeName' : '/bar' ,
130
- }); // -> single
131
- await check <SingleEntryBrowserHistory >('routeInformationUpdated' , < String , dynamic > {
128
+ await check <MultiEntriesBrowserHistory >('routeInformationUpdated' , < String , dynamic > {
132
129
'location' : '/bar' ,
133
130
}); // does not change mode
134
- await check <MultiEntriesBrowserHistory >(
135
- 'selectMultiEntryHistory ' ,
131
+ await check <SingleEntryBrowserHistory >(
132
+ 'selectSingleEntryHistory ' ,
136
133
< String , dynamic > {},
137
- ); // -> multi
138
- await check <MultiEntriesBrowserHistory >('routeInformationUpdated' , < String , dynamic > {
134
+ ); // -> single
135
+ await check <SingleEntryBrowserHistory >('routeInformationUpdated' , < String , dynamic > {
139
136
'location' : '/bar' ,
140
137
}); // does not change mode
141
138
});
142
139
143
140
test (
144
141
'handleNavigationMessage throws for route update methods called with null arguments' ,
145
142
() async {
146
- expect (() async {
147
- await myWindow.handleNavigationMessage (
148
- const JSONMethodCodec ().encodeMethodCall (const MethodCall ('routeUpdated' )),
149
- );
150
- }, throwsAssertionError);
151
-
152
143
expect (() async {
153
144
await myWindow.handleNavigationMessage (
154
145
const JSONMethodCodec ().encodeMethodCall (const MethodCall ('routeInformationUpdated' )),
@@ -214,12 +205,21 @@ void testMain() {
214
205
);
215
206
expect (myWindow.browserHistory, isA <MultiEntriesBrowserHistory >());
216
207
217
- // routeUpdated resets the history type
208
+ // change the history type
218
209
Completer <void > callback = Completer <void >();
210
+ myWindow.sendPlatformMessage (
211
+ 'flutter/navigation' ,
212
+ const JSONMethodCodec ().encodeMethodCall (const MethodCall ('selectSingleEntryHistory' )),
213
+ (_) {
214
+ callback.complete ();
215
+ },
216
+ );
217
+ await callback.future;
218
+ callback = Completer <void >();
219
219
myWindow.sendPlatformMessage (
220
220
'flutter/navigation' ,
221
221
const JSONMethodCodec ().encodeMethodCall (
222
- const MethodCall ('routeUpdated ' , < String , dynamic > {'routeName ' : '/bar' }),
222
+ const MethodCall ('routeInformationUpdated ' , < String , dynamic > {'location ' : '/bar' }),
223
223
),
224
224
(_) {
225
225
callback.complete ();
@@ -250,7 +250,7 @@ void testMain() {
250
250
// they can be interleaved safely
251
251
await myWindow.handleNavigationMessage (
252
252
const JSONMethodCodec ().encodeMethodCall (
253
- const MethodCall ('routeUpdated ' , < String , dynamic > {'routeName ' : '/foo' }),
253
+ const MethodCall ('routeInformationUpdated ' , < String , dynamic > {'location ' : '/foo' }),
254
254
),
255
255
);
256
256
expect (myWindow.browserHistory, isA <SingleEntryBrowserHistory >());
@@ -390,32 +390,6 @@ void testMain() {
390
390
expect (myWindow.browserHistory.urlStrategy! .getState (), _tagStateWithSerialCount ('/state1' , 1 ));
391
391
});
392
392
393
- test ('initialize browser history with default url strategy (single)' , () async {
394
- // On purpose, we don't initialize history on the window. We want to let the
395
- // window to self-initialize when it receives a navigation message.
396
-
397
- // Without initializing history, the default route name should be
398
- // initialized to "/" in tests.
399
- expect (myWindow.defaultRouteName, '/' );
400
-
401
- final Completer <void > callback = Completer <void >();
402
- myWindow.sendPlatformMessage (
403
- 'flutter/navigation' ,
404
- const JSONMethodCodec ().encodeMethodCall (
405
- const MethodCall ('routeUpdated' , < String , dynamic > {'routeName' : '/bar' }),
406
- ),
407
- (_) {
408
- callback.complete ();
409
- },
410
- );
411
- await callback.future;
412
- expect (myWindow.browserHistory, isA <SingleEntryBrowserHistory >());
413
- // The url strategy should've been set to the default, and the path
414
- // should've been correctly set to "/bar".
415
- expect (myWindow.browserHistory.urlStrategy, isNot (isNull));
416
- expect (myWindow.browserHistory.urlStrategy! .getPath (), '/bar' );
417
- }, skip: isSafari); // https://github.com/flutter/flutter/issues/50836
418
-
419
393
test ('initialize browser history with default url strategy (multiple)' , () async {
420
394
// On purpose, we don't initialize history on the window. We want to let the
421
395
// window to self-initialize when it receives a navigation message.
@@ -443,7 +417,7 @@ void testMain() {
443
417
// should've been correctly set to "/baz".
444
418
expect (myWindow.browserHistory.urlStrategy, isNot (isNull));
445
419
expect (myWindow.browserHistory.urlStrategy! .getPath (), '/baz' );
446
- }, skip : isSafari); // https://github.com/flutter/flutter/issues/50836
420
+ });
447
421
448
422
test ('can disable location strategy' , () async {
449
423
// Disable URL strategy.
0 commit comments