@Test public void oneToOneRelationBetweenBrowserAndUI() throws MalformedURLException { openWindow(INSTRUMENTED_UI_URI); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); int clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(1)); assertThat(InstrumentedUI.getNumberOfInstances(), is(1)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(2)); assertThat(InstrumentedUI.getNumberOfInstances(), is(1)); firstWindow.restartBrowser(); openWindow(INSTRUMENTED_UI_URI); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(1)); assertThat(InstrumentedUI.getNumberOfInstances(), is(2)); firstWindow.click(BUTTON); waitModel.waitForChange(retrieveText.locator(LABEL)); clickCount = number(firstWindow.getText(LABEL)); assertThat(clickCount, is(2)); assertThat(InstrumentedUI.getNumberOfInstances(), is(2)); assertDefaultRootNotInstantiated(); }
@Test public void browserRestartCreatesNewInstance() throws MalformedURLException { String uri = deriveMappingForUI(PlainUI.class); openWindow(uri); assertTrue("PlainUI should contain a label", firstWindow.isElementPresent(LABEL)); assertThat(PlainUI.getNumberOfInstances(), is(1)); // reset session firstWindow.restartBrowser(); openWindow(uri); assertTrue("PlainUI should contain a label", firstWindow.isElementPresent(LABEL)); assertThat(PlainUI.getNumberOfInstances(), is(2)); assertDefaultRootNotInstantiated(); }
@Before public void resetCounter() { PlainUI.resetCounter(); PlainAlternativeUI.resetCounter(); PlainColidingAlternativeUI.resetCounter(); InstrumentedUI.resetCounter(); InstrumentedView.resetCounter(); ScopedInstrumentedView.resetCounter(); ViewWithoutAnnotation.resetCounter(); WithAnnotationRegisteredView.resetCounter(); SecondUI.resetCounter(); RootUI.resetCounter(); RootWithCustomMappingUI.resetCounter(); UIWithCDIDependentListener.resetCounter(); UIWithCDISelfListener.resetCounter(); DependentCDIEventListener.resetCounter(); DependentCDIEventListener.resetEventCounter(); ParameterizedNavigationUI.reset(); NoViewProviderNavigationUI.resetCounter(); firstWindow.restartBrowser(); }