From 9e0c7556699dbbfe0c047730d69772eecb67dcb2 Mon Sep 17 00:00:00 2001 From: Mouad Debbar Date: Tue, 8 Oct 2019 14:10:21 -0700 Subject: [PATCH] [web] Update the url when route is replaced --- lib/web_ui/lib/src/engine/window.dart | 1 + lib/web_ui/test/engine/navigation_test.dart | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/web_ui/lib/src/engine/window.dart b/lib/web_ui/lib/src/engine/window.dart index 3897938bdf985..c37eae4e202ef 100644 --- a/lib/web_ui/lib/src/engine/window.dart +++ b/lib/web_ui/lib/src/engine/window.dart @@ -153,6 +153,7 @@ class EngineWindow extends ui.Window { final Map message = decoded.arguments; switch (decoded.method) { case 'routePushed': + case 'routeReplaced': _browserHistory.setRouteName(message['routeName']); break; case 'routePopped': diff --git a/lib/web_ui/test/engine/navigation_test.dart b/lib/web_ui/test/engine/navigation_test.dart index 7258af4ce018d..df737e8f43a9c 100644 --- a/lib/web_ui/test/engine/navigation_test.dart +++ b/lib/web_ui/test/engine/navigation_test.dart @@ -22,7 +22,7 @@ void main() { engine.window.locationStrategy = _strategy = null; }); - test('Tracks pushed and popped routes', () { + test('Tracks pushed, replaced and popped routes', () { engine.window.sendPlatformMessage( 'flutter/navigation', codec.encodeMethodCall(const engine.MethodCall( @@ -62,5 +62,18 @@ void main() { emptyCallback, ); expect(_strategy.path, '/bar/baz'); + + engine.window.sendPlatformMessage( + 'flutter/navigation', + codec.encodeMethodCall(const engine.MethodCall( + 'routeReplaced', + { + 'previousRouteName': '/bar/baz', + 'routeName': '/bar/baz2', + }, + )), + emptyCallback, + ); + expect(_strategy.path, '/bar/baz2'); }); }