From: Artur Signell Date: Mon, 7 Sep 2015 11:24:36 +0000 (+0300) Subject: Make test work correctly with resynchronize X-Git-Tag: 7.6.0.alpha5~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8ffe48687ae367a765e3e54721c2821d8d773c2d;p=vaadin-framework.git Make test work correctly with resynchronize Change-Id: I4aaf8875cbd69db525c4aaa8ac92a26b3b11b158 --- diff --git a/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java b/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java index 4dd8292e23..726616d7b8 100644 --- a/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java +++ b/uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java @@ -48,13 +48,7 @@ public class ResynchronizeUITest extends SingleBrowserTest { // Click causes repaint, after this the old button element should no // longer be available // Ensure that the theme has changed - waitUntil(new ExpectedCondition() { - @Override - public Boolean apply(WebDriver input) { - WebElement app = input.findElement(By.className("v-app")); - return hasCssClass(app, "runo"); - } - }); + waitForThemeToChange("runo"); try { button.click(); Assert.fail("The old button element should have been removed by the click and replaced by a new one."); diff --git a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedThemeResourceTest.java b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedThemeResourceTest.java index dc4dd341f4..f892775ea3 100644 --- a/uitest/src/com/vaadin/tests/components/embedded/EmbeddedThemeResourceTest.java +++ b/uitest/src/com/vaadin/tests/components/embedded/EmbeddedThemeResourceTest.java @@ -80,12 +80,16 @@ public class EmbeddedThemeResourceTest extends SingleBrowserTest { @Test public void testUpdatedTheme() { - EmbeddedElement embedded = $(EmbeddedElement.class).first(); - final ImageElement image = $(ImageElement.class).first(); - final String initial = image.getAttribute("src"); + final String initial = $(ImageElement.class).first() + .getAttribute("src"); // update theme $(ButtonElement.class).first().click(); + waitForThemeToChange("reindeer"); + + EmbeddedElement embedded = $(EmbeddedElement.class).first(); + // Re fetch as theme change creates new elements + final ImageElement image = $(ImageElement.class).first(); waitUntil(new ExpectedCondition() { @Override @@ -107,4 +111,5 @@ public class EmbeddedThemeResourceTest extends SingleBrowserTest { embedded.findElement(By.tagName("img")).getAttribute("src"), is(image.getAttribute("src"))); } + } diff --git a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java index a58575890e..5ca945c860 100644 --- a/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java +++ b/uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java @@ -1208,4 +1208,20 @@ public abstract class AbstractTB3Test extends ParallelTest { return (WebElement) executeScript("return document.activeElement;"); } + + protected void waitForThemeToChange(final String theme) { + + final WebElement rootDiv = findElement(By + .xpath("//div[contains(@class,'v-app')]")); + waitUntil(new ExpectedCondition() { + + @Override + public Boolean apply(WebDriver input) { + String rootClass = rootDiv.getAttribute("class").trim(); + + return rootClass.contains(theme); + } + }, 30); + } + } diff --git a/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java b/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java index 3c992f3af5..8062fdbf39 100644 --- a/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java +++ b/uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java @@ -20,10 +20,8 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; -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.elements.ComboBoxElement; @@ -159,19 +157,4 @@ public class LegacyComponentThemeChangeTest extends MultiBrowserTest { waitForThemeToChange(theme); } - private void waitForThemeToChange(final String theme) { - - final WebElement rootDiv = findElement(By - .xpath("//div[contains(@class,'v-app')]")); - waitUntil(new ExpectedCondition() { - - @Override - public Boolean apply(WebDriver input) { - String rootClass = rootDiv.getAttribute("class").trim(); - - return rootClass.contains(theme); - } - }, 30); - } - } diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java index e4788f93f5..cb5e9d07c7 100644 --- a/uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java +++ b/uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java @@ -21,10 +21,8 @@ import java.util.List; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; -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; @@ -55,18 +53,7 @@ public class ThemeChangeFaviconTest extends SingleBrowserTest { private void changeTheme(final String theme) { $(ButtonElement.class).caption(theme).first().click(); - - final WebElement rootDiv = findElement(By - .xpath("//div[contains(@class,'v-app')]")); - waitUntil(new ExpectedCondition() { - - @Override - public Boolean apply(WebDriver input) { - String rootClass = rootDiv.getAttribute("class").trim(); - - return rootClass.contains(theme); - } - }, 30); + waitForThemeToChange(theme); } private void assertFavicon(String theme) { diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java index 211a908ccb..caf264abf1 100644 --- a/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java +++ b/uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java @@ -23,10 +23,8 @@ import java.util.List; import org.junit.Test; import org.openqa.selenium.By; -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.tests.tb3.MultiBrowserTest; @@ -91,21 +89,6 @@ public class ThemeChangeOnTheFlyTest extends MultiBrowserTest { } } - private void waitForThemeToChange(final String theme) { - - final WebElement rootDiv = findElement(By - .xpath("//div[contains(@class,'v-app')]")); - waitUntil(new ExpectedCondition() { - - @Override - public Boolean apply(WebDriver input) { - String rootClass = rootDiv.getAttribute("class").trim(); - - return rootClass.contains(theme); - } - }, 30); - } - private void assertOverlayTheme(String theme) { final WebElement overlayContainerDiv = findElement(By .xpath("//div[contains(@class,'v-overlay-container')]"));