diff options
author | Johannes Dahlström <johannesd@vaadin.com> | 2012-10-17 16:29:28 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2012-10-17 16:29:28 +0300 |
commit | 90ffa9404fbb458ffbd1a26930811fcea6037d97 (patch) | |
tree | 6a4be7e87c6e0ff293a48719e64c1d898bc1a4dd /server | |
parent | 43c3f454d419c0eb7b0d094c4cf853e3ec3867ae (diff) | |
download | vaadin-framework-90ffa9404fbb458ffbd1a26930811fcea6037d97.tar.gz vaadin-framework-90ffa9404fbb458ffbd1a26930811fcea6037d97.zip |
Add Navigator.getState() returning the current navigation state (#9972)
Change-Id: Ic423252ed82ea5c991760ece76a9a0f0e5a259a4
Diffstat (limited to 'server')
-rw-r--r-- | server/src/com/vaadin/navigator/Navigator.java | 10 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java | 16 |
2 files changed, 22 insertions, 4 deletions
diff --git a/server/src/com/vaadin/navigator/Navigator.java b/server/src/com/vaadin/navigator/Navigator.java index 72d6c65fd2..4b2474a0f2 100644 --- a/server/src/com/vaadin/navigator/Navigator.java +++ b/server/src/com/vaadin/navigator/Navigator.java @@ -543,6 +543,16 @@ public class Navigator implements Serializable { } /** + * Returns the current navigation state reported by this Navigator's + * {@link NavigationStateManager}. + * + * @return The navigation state. + */ + public String getState() { + return getStateManager().getState(); + } + + /** * Return the ViewDisplay used by the navigator. Unless another display is * specified, a {@link SimpleViewDisplay} (which is a {@link Component}) is * used by default. diff --git a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java index 7e21b751dc..218791e454 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java @@ -228,21 +228,24 @@ public class NavigatorTest extends TestCase { view1.enter(eventParametersEqual("")); display.showView(view1); manager.setState("test1"); + EasyMock.expect(manager.getState()).andReturn("test1"); EasyMock.expect(provider.getViewName("test2/")).andReturn("test2"); EasyMock.expect(provider.getView("test2")).andReturn(view2); - EasyMock.expect(manager.getState()).andReturn("view1"); + EasyMock.expect(manager.getState()).andReturn("test1"); view2.enter(eventParametersEqual("")); display.showView(view2); manager.setState("test2"); + EasyMock.expect(manager.getState()).andReturn("test2"); EasyMock.expect(provider.getViewName("test1/params")) .andReturn("test1"); EasyMock.expect(provider.getView("test1")).andReturn(view1); - EasyMock.expect(manager.getState()).andReturn("view2"); + EasyMock.expect(manager.getState()).andReturn("test2"); view1.enter(eventParametersEqual("params")); display.showView(view1); manager.setState("test1/params"); + EasyMock.expect(manager.getState()).andReturn("test1/params"); control.replay(); @@ -251,8 +254,13 @@ public class NavigatorTest extends TestCase { navigator.addProvider(provider); navigator.navigateTo("test1"); + assertEquals("test1", navigator.getState()); + navigator.navigateTo("test2/"); + assertEquals("test2", navigator.getState()); + navigator.navigateTo("test1/params"); + assertEquals("test1/params", navigator.getState()); } public void testMainView() { @@ -284,7 +292,7 @@ public class NavigatorTest extends TestCase { EasyMock.expect(provider.getViewName("test1/params")) .andReturn("test1"); EasyMock.expect(provider.getView("test1")).andReturn(view1); - EasyMock.expect(manager.getState()).andReturn("view2"); + EasyMock.expect(manager.getState()).andReturn("test2"); view1.enter(eventParametersEqual("params")); display.showView(view1); manager.setState("test1/params"); @@ -330,7 +338,7 @@ public class NavigatorTest extends TestCase { ViewChangeEvent event2 = new ViewChangeEvent(navigator, view1, view2, "test2", ""); listener.addExpectedIsViewChangeAllowed(event2, true); - EasyMock.expect(manager.getState()).andReturn("view1"); + EasyMock.expect(manager.getState()).andReturn("test1"); view2.enter(eventParametersEqual("")); display.showView(view2); manager.setState("test2"); |