use of com.vaadin.flow.component.page.Page in project flow by vaadin.
the class JavaScriptBootstrapUITest method should_not_notify_clientRoute_when_navigatingToTheSame.
@Test
public void should_not_notify_clientRoute_when_navigatingToTheSame() {
ui = Mockito.spy(ui);
Page page = mockPage();
UIInternals internals = mockUIInternals();
Mockito.when(internals.hasLastHandledLocation()).thenReturn(true);
Location lastLocation = new Location("clean");
Mockito.when(internals.getLastHandledLocation()).thenReturn(lastLocation);
ui.navigate("clean/");
Mockito.verify(page, Mockito.never()).executeJs(Mockito.anyString(), Mockito.anyString());
}
use of com.vaadin.flow.component.page.Page in project flow by vaadin.
the class JavaScriptBootstrapUITest method should_update_pushState_when_navigationHasBeenAlreadyStarted.
@Test
public void should_update_pushState_when_navigationHasBeenAlreadyStarted() {
ui = Mockito.spy(ui);
Page page = mockPage();
UIInternals internals = mockUIInternals();
Mockito.when(internals.hasLastHandledLocation()).thenReturn(true);
Location lastLocation = new Location("clean");
Mockito.when(internals.getLastHandledLocation()).thenReturn(lastLocation);
StateTree stateTree = Mockito.mock(StateTree.class);
Mockito.when(internals.getStateTree()).thenReturn(stateTree);
Mockito.when(internals.getTitle()).thenReturn("");
StateNode stateNode = BasicElementStateProvider.createStateNode("foo-element");
Mockito.when(stateTree.getRootNode()).thenReturn(stateNode);
ArgumentCaptor<String> execJs = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> execArg = ArgumentCaptor.forClass(String.class);
ui.navigate("clean/1");
Mockito.verify(page).executeJs(execJs.capture(), execArg.capture());
assertEquals(CLIENT_PUSHSTATE_TO, execJs.getValue());
final List<String> execValues = execArg.getAllValues();
assertEquals(2, execValues.size());
assertNull(execValues.get(0));
assertEquals("clean/1", execArg.getValue());
}
use of com.vaadin.flow.component.page.Page in project flow by vaadin.
the class PolymerTemplateTest method setUp.
@SuppressWarnings("serial")
@Before
public void setUp() throws SecurityException, IllegalArgumentException {
executionOrder.clear();
executionParams.clear();
VaadinSession session = Mockito.mock(VaadinSession.class);
ui = new UI() {
private Page page = new Page(this) {
@Override
public PendingJavaScriptResult executeJs(String expression, Serializable... parameters) {
executionOrder.add(expression);
executionParams.add(parameters);
return null;
}
};
@Override
public VaadinSession getSession() {
return session;
}
@Override
public Page getPage() {
return page;
}
};
VaadinService service = Mockito.mock(VaadinService.class);
when(session.getService()).thenReturn(service);
DefaultInstantiator instantiator = new DefaultInstantiator(service);
when(service.getInstantiator()).thenReturn(instantiator);
UI.setCurrent(ui);
}
Aggregations