Skip to content

Commit 21a484d

Browse files
authored
[web] Add few awaits in history tests (flutter#24934)
1 parent 850c7fe commit 21a484d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/web_ui/test/engine/history_test.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import 'dart:async';
1010
import 'dart:html' as html;
11-
import 'dart:typed_data';
1211

1312
import 'package:test/bootstrap/browser.dart';
1413
import 'package:test/test.dart';
@@ -32,8 +31,6 @@ const Map<String, bool> flutterState = <String, bool>{'flutter': true};
3231

3332
const MethodCodec codec = JSONMethodCodec();
3433

35-
void emptyCallback(ByteData date) {}
36-
3734
void main() {
3835
internalBootstrapBrowserTest(() => testMain);
3936
}

lib/web_ui/test/window_test.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import 'dart:async';
77
import 'dart:html' as html;
88
import 'dart:js_util' as js_util;
9-
import 'dart:typed_data';
109

1110
import 'package:test/bootstrap/browser.dart';
1211
import 'package:test/test.dart';
@@ -18,8 +17,6 @@ import 'matchers.dart';
1817

1918
const MethodCodec codec = JSONMethodCodec();
2019

21-
void emptyCallback(ByteData data) {}
22-
2320
void main() {
2421
internalBootstrapBrowserTest(() => testMain);
2522
}
@@ -57,13 +54,15 @@ void testMain() {
5754
// Reading it multiple times should return the same value.
5855
expect(window.defaultRouteName, '/initial');
5956
expect(window.defaultRouteName, '/initial');
57+
58+
Completer<void> callback = Completer<void>();
6059
window.sendPlatformMessage(
6160
'flutter/navigation',
6261
JSONMethodCodec().encodeMethodCall(MethodCall(
6362
'routeUpdated',
6463
<String, dynamic>{'routeName': '/bar'},
6564
)),
66-
emptyCallback,
65+
(_) { callback.complete(); },
6766
);
6867
// After a navigation platform message, [window.defaultRouteName] should
6968
// reset to "/".
@@ -192,7 +191,7 @@ void testMain() {
192191
expect(window.browserHistory.currentPath, '/');
193192

194193
// Perform some navigation operations.
195-
routeInformationUpdated('/foo/bar', null);
194+
await routeInformationUpdated('/foo/bar', null);
196195
// Path should not be updated because URL strategy is disabled.
197196
expect(window.browserHistory.currentPath, '/');
198197
});

0 commit comments

Comments
 (0)