diff options
Diffstat (limited to 'server/tests/src')
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java | 5 | ||||
-rw-r--r-- | server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java | 38 |
2 files changed, 31 insertions, 12 deletions
diff --git a/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java b/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java index 5db0df4280..2b9d0e533d 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/ClassBasedViewProviderTest.java @@ -20,6 +20,7 @@ import junit.framework.TestCase; import com.vaadin.navigator.Navigator.ClassBasedViewProvider; import com.vaadin.navigator.View; +import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.ui.Label; public class ClassBasedViewProviderTest extends TestCase { @@ -28,8 +29,8 @@ public class ClassBasedViewProviderTest extends TestCase { public String parameters = null; @Override - public void navigateTo(String parameters) { - this.parameters = parameters; + public void enter(ViewChangeEvent event) { + parameters = event.getParameters(); } } 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 ca060a4651..fa48e4bff6 100644 --- a/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java +++ b/server/tests/src/com/vaadin/tests/server/navigator/NavigatorTest.java @@ -21,6 +21,7 @@ import java.util.LinkedList; import junit.framework.TestCase; import org.easymock.EasyMock; +import org.easymock.IArgumentMatcher; import org.easymock.IMocksControl; import com.vaadin.navigator.NavigationStateManager; @@ -168,6 +169,23 @@ public class NavigatorTest extends TestCase { } } + public static ViewChangeEvent eventParametersEqual(final String expected) { + EasyMock.reportMatcher(new IArgumentMatcher() { + @Override + public void appendTo(StringBuffer buffer) { + buffer.append("paramsIs(\"" + expected + "\")"); + } + + @Override + public boolean matches(Object actual) { + return actual instanceof ViewChangeEvent + && expected.equals(((ViewChangeEvent) actual) + .getParameters()); + } + }); + return null; + } + public void testBasicNavigation() { IMocksControl control = EasyMock.createControl(); NavigationStateManager manager = control @@ -181,14 +199,14 @@ public class NavigatorTest extends TestCase { EasyMock.expect(provider.getViewName("test1")).andReturn("test1"); EasyMock.expect(provider.getView("test1")).andReturn(view1); EasyMock.expect(manager.getState()).andReturn(""); - view1.navigateTo(""); + view1.enter(eventParametersEqual("")); display.showView(view1); manager.setState("test1"); EasyMock.expect(provider.getViewName("test2/")).andReturn("test2"); EasyMock.expect(provider.getView("test2")).andReturn(view2); EasyMock.expect(manager.getState()).andReturn("view1"); - view2.navigateTo(""); + view2.enter(eventParametersEqual("")); display.showView(view2); manager.setState("test2"); @@ -196,7 +214,7 @@ public class NavigatorTest extends TestCase { .andReturn("test1"); EasyMock.expect(provider.getView("test1")).andReturn(view1); EasyMock.expect(manager.getState()).andReturn("view2"); - view1.navigateTo("params"); + view1.enter(eventParametersEqual("params")); display.showView(view1); manager.setState("test1/params"); @@ -224,14 +242,14 @@ public class NavigatorTest extends TestCase { EasyMock.expect(provider.getViewName("test2")).andReturn("test2"); EasyMock.expect(provider.getView("test2")).andReturn(view2); EasyMock.expect(manager.getState()).andReturn("view1"); - view2.navigateTo(""); + view2.enter(eventParametersEqual("")); display.showView(view2); manager.setState("test2"); EasyMock.expect(provider.getViewName("")).andReturn("test1"); EasyMock.expect(provider.getView("test1")).andReturn(view1); EasyMock.expect(manager.getState()).andReturn(""); - view1.navigateTo(""); + view1.enter(eventParametersEqual("")); display.showView(view1); manager.setState("test1"); @@ -239,7 +257,7 @@ public class NavigatorTest extends TestCase { .andReturn("test1"); EasyMock.expect(provider.getView("test1")).andReturn(view1); EasyMock.expect(manager.getState()).andReturn("view2"); - view1.navigateTo("params"); + view1.enter(eventParametersEqual("params")); display.showView(view1); manager.setState("test1/params"); @@ -274,7 +292,7 @@ public class NavigatorTest extends TestCase { "test1", ""); listener.addExpectedIsViewChangeAllowed(event1, true); EasyMock.expect(manager.getState()).andReturn(""); - view1.navigateTo(""); + view1.enter(eventParametersEqual("")); display.showView(view1); manager.setState("test1"); listener.addExpectedNavigatorViewChange(event1); @@ -285,7 +303,7 @@ public class NavigatorTest extends TestCase { "test2", ""); listener.addExpectedIsViewChangeAllowed(event2, true); EasyMock.expect(manager.getState()).andReturn("view1"); - view2.navigateTo(""); + view2.enter(eventParametersEqual("")); display.showView(view2); manager.setState("test2"); listener.addExpectedNavigatorViewChange(event2); @@ -343,7 +361,7 @@ public class NavigatorTest extends TestCase { "test1", "bar"); listener1.addExpectedIsViewChangeAllowed(event3, true); listener2.addExpectedIsViewChangeAllowed(event3, true); - view1.navigateTo("bar"); + view1.enter(EasyMock.isA(ViewChangeEvent.class)); display.showView(view1); manager.setState("test1/bar"); listener1.addExpectedNavigatorViewChange(event3); @@ -357,7 +375,7 @@ public class NavigatorTest extends TestCase { "test2", ""); listener1.addExpectedIsViewChangeAllowed(event4, true); listener2.addExpectedIsViewChangeAllowed(event4, true); - view2.navigateTo(""); + view2.enter(EasyMock.isA(ViewChangeEvent.class)); display.showView(view2); manager.setState("test2"); listener1.addExpectedNavigatorViewChange(event4); |