diff options
author | Artur Signell <artur@vaadin.com> | 2015-09-07 14:01:18 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2015-09-07 16:22:32 +0300 |
commit | 1795314185117b3f5cce48959f6a36116fb810f9 (patch) | |
tree | c1828f9bd3ed5af093e1c8cab23761b9c0b1ff4a /uitest | |
parent | dd515195fd274a89d979402a6f981d2b8c415a48 (diff) | |
download | vaadin-framework-1795314185117b3f5cce48959f6a36116fb810f9.tar.gz vaadin-framework-1795314185117b3f5cce48959f6a36116fb810f9.zip |
Fix resynchronize/repaintAll to actually resynchronize again (#18808)
Change-Id: Ia96d89a519b1f453457461e596c51642257c61bb
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/application/ResynchronizeUI.java | 39 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java | 65 |
2 files changed, 104 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java b/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java new file mode 100644 index 0000000000..62331ec95e --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/ResynchronizeUI.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.application; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUIWithLog; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; + +public class ResynchronizeUI extends AbstractTestUIWithLog { + + @Override + protected void setup(VaadinRequest request) { + Button b = new Button("Resynchronize", new ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + // Theme change is currently the only operation which always + // does resynchronize + setTheme("runo"); + log("Set theme to runo"); + } + }); + addComponent(b); + } +} diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java b/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java new file mode 100644 index 0000000000..4dd8292e23 --- /dev/null +++ b/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.application; + +import java.util.Collections; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.StaleElementReferenceException; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.remote.DesiredCapabilities; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class ResynchronizeUITest extends SingleBrowserTest { + + @Override + public List<DesiredCapabilities> getBrowsersToTest() { + // PhantomJS does not send onload events for styles + return Collections.singletonList(Browser.FIREFOX + .getDesiredCapabilities()); + } + + @Test + public void ensureResynchronizeRecreatesDOM() { + openTestURL(); + ButtonElement button = $(ButtonElement.class).first(); + button.click(); + // Click causes repaint, after this the old button element should no + // longer be available + // Ensure that the theme has changed + waitUntil(new ExpectedCondition<Boolean>() { + @Override + public Boolean apply(WebDriver input) { + WebElement app = input.findElement(By.className("v-app")); + return hasCssClass(app, "runo"); + } + }); + try { + button.click(); + Assert.fail("The old button element should have been removed by the click and replaced by a new one."); + } catch (StaleElementReferenceException e) { + // This is what should happen + } + } +} |