]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make test work correctly with resynchronize
authorArtur Signell <artur@vaadin.com>
Mon, 7 Sep 2015 11:24:36 +0000 (14:24 +0300)
committerVaadin Code Review <review@vaadin.com>
Mon, 7 Sep 2015 13:41:19 +0000 (13:41 +0000)
Change-Id: I4aaf8875cbd69db525c4aaa8ac92a26b3b11b158

uitest/src/com/vaadin/tests/application/ResynchronizeUITest.java
uitest/src/com/vaadin/tests/components/embedded/EmbeddedThemeResourceTest.java
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java
uitest/src/com/vaadin/tests/themes/LegacyComponentThemeChangeTest.java
uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java
uitest/src/com/vaadin/tests/themes/ThemeChangeOnTheFlyTest.java

index 4dd8292e23ab81fa6b89b713df4153efec97ce79..726616d7b88b7b40760ee6817dd7337dd385f75b 100644 (file)
@@ -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<Boolean>() {
-            @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.");
index dc4dd341f424371a4f94e2d0fdc6e98cb81b11c9..f892775ea368fcd26e85f214990d183e3f2006cf 100644 (file)
@@ -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<Boolean>() {
             @Override
@@ -107,4 +111,5 @@ public class EmbeddedThemeResourceTest extends SingleBrowserTest {
                 embedded.findElement(By.tagName("img")).getAttribute("src"),
                 is(image.getAttribute("src")));
     }
+
 }
index a58575890edad603a03b901905ad7c87c3f1febf..5ca945c8604f1566311069d1c6bba64a2728ebe0 100644 (file)
@@ -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<Boolean>() {
+
+            @Override
+            public Boolean apply(WebDriver input) {
+                String rootClass = rootDiv.getAttribute("class").trim();
+
+                return rootClass.contains(theme);
+            }
+        }, 30);
+    }
+
 }
index 3c992f3af58c0870df454bfa6971e1ddc8bf1307..8062fdbf398071a1e250cc3ca476a39c69f3fdf5 100644 (file)
@@ -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<Boolean>() {
-
-            @Override
-            public Boolean apply(WebDriver input) {
-                String rootClass = rootDiv.getAttribute("class").trim();
-
-                return rootClass.contains(theme);
-            }
-        }, 30);
-    }
-
 }
index e4788f93f5036c17ff6f9f65742874e1da982d99..cb5e9d07c73643e9d3bc9c8f4732df4f62deb97f 100644 (file)
@@ -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<Boolean>() {
-
-            @Override
-            public Boolean apply(WebDriver input) {
-                String rootClass = rootDiv.getAttribute("class").trim();
-
-                return rootClass.contains(theme);
-            }
-        }, 30);
+        waitForThemeToChange(theme);
     }
 
     private void assertFavicon(String theme) {
index 211a908ccbe75ef245d88dd69b1ff254e5d09a2d..caf264abf1bd7443287395599599a5a7ba479460 100644 (file)
@@ -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<Boolean>() {
-
-            @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')]"));