Skip to content

Commit

Permalink
[web] Add few awaits in history tests (flutter#24934)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdebbar authored Mar 10, 2021
1 parent 850c7fe commit 21a484d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 0 additions & 3 deletions lib/web_ui/test/engine/history_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import 'dart:async';
import 'dart:html' as html;
import 'dart:typed_data';

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

const MethodCodec codec = JSONMethodCodec();

void emptyCallback(ByteData date) {}

void main() {
internalBootstrapBrowserTest(() => testMain);
}
Expand Down
9 changes: 4 additions & 5 deletions lib/web_ui/test/window_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import 'dart:async';
import 'dart:html' as html;
import 'dart:js_util' as js_util;
import 'dart:typed_data';

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

const MethodCodec codec = JSONMethodCodec();

void emptyCallback(ByteData data) {}

void main() {
internalBootstrapBrowserTest(() => testMain);
}
Expand Down Expand Up @@ -57,13 +54,15 @@ void testMain() {
// Reading it multiple times should return the same value.
expect(window.defaultRouteName, '/initial');
expect(window.defaultRouteName, '/initial');

Completer<void> callback = Completer<void>();
window.sendPlatformMessage(
'flutter/navigation',
JSONMethodCodec().encodeMethodCall(MethodCall(
'routeUpdated',
<String, dynamic>{'routeName': '/bar'},
)),
emptyCallback,
(_) { callback.complete(); },
);
// After a navigation platform message, [window.defaultRouteName] should
// reset to "/".
Expand Down Expand Up @@ -192,7 +191,7 @@ void testMain() {
expect(window.browserHistory.currentPath, '/');

// Perform some navigation operations.
routeInformationUpdated('/foo/bar', null);
await routeInformationUpdated('/foo/bar', null);
// Path should not be updated because URL strategy is disabled.
expect(window.browserHistory.currentPath, '/');
});
Expand Down

0 comments on commit 21a484d

Please sign in to comment.