]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make test more stable
authorArtur Signell <artur@vaadin.com>
Tue, 19 Aug 2014 11:54:16 +0000 (14:54 +0300)
committerVaadin Code Review <review@vaadin.com>
Tue, 19 Aug 2014 14:46:28 +0000 (14:46 +0000)
* Added tests for tabsheet variants

Change-Id: Ib8d5c88cdedf1bbac439f91346b7b8a6a6756ede

uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java
uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java

index 501b5f573bac0e8af7228a72276a5291cf4b3540..b33a6040338c7f83592ea5d0b0a9604e6acba4b0 100644 (file)
@@ -89,6 +89,16 @@ public class ValoThemeUI extends UI {
     protected void init(VaadinRequest request) {
         if (request.getParameter("test") != null) {
             testMode = true;
+
+            if (browserCantRenderFontsConsistently()) {
+                getPage().getStyles().add(
+                        ".v-app.v-app.v-app {font-family: Sans-Serif;}");
+            }
+        }
+
+        if (getPage().getWebBrowser().isIE()
+                && getPage().getWebBrowser().getBrowserMajorVersion() == 9) {
+            menu.setWidth("320px");
         }
         // Show .v-app-loading valo-menu-badge
         // try {
@@ -97,7 +107,9 @@ public class ValoThemeUI extends UI {
         // e.printStackTrace();
         // }
 
-        Responsive.makeResponsive(this);
+        if (!testMode) {
+            Responsive.makeResponsive(this);
+        }
 
         getPage().setTitle("Valo Theme Test");
         setContent(root);
@@ -167,6 +179,19 @@ public class ValoThemeUI extends UI {
 
     }
 
+    private boolean browserCantRenderFontsConsistently() {
+        // PhantomJS renders font correctly about 50% of the time, so
+        // disable it to have consistent screenshots
+        // https://github.com/ariya/phantomjs/issues/10592
+
+        // IE8 also has randomness in its font rendering...
+
+        return getPage().getWebBrowser().getBrowserApplication()
+                .contains("PhantomJS")
+                || (getPage().getWebBrowser().isIE() && getPage()
+                        .getWebBrowser().getBrowserMajorVersion() <= 9);
+    }
+
     static boolean isTestMode() {
         return ((ValoThemeUI) getCurrent()).testMode;
     }
@@ -440,4 +465,4 @@ public class ValoThemeUI extends UI {
         }
         return container;
     }
-}
\ No newline at end of file
+}
index fdb2eabeee8b41f07846728a92252bb4881a858d..b5b7e16b3473cb9751403e3704eb43fc0b9fd400 100644 (file)
@@ -20,6 +20,7 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.WebElement;
 
 import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.CheckBoxElement;
 import com.vaadin.testbench.elements.CssLayoutElement;
 import com.vaadin.testbench.elements.LabelElement;
 import com.vaadin.testbench.elements.TreeElement;
@@ -127,6 +128,7 @@ public class ValoThemeUITest extends MultiBrowserTest {
     public void tables() throws Exception {
         openTestURL("test");
         open("Tables");
+        check("Components in Cells");
         compareScreen("tables");
     }
 
@@ -156,6 +158,64 @@ public class ValoThemeUITest extends MultiBrowserTest {
         openTestURL("test");
         open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
         compareScreen("tabs");
+
+    }
+
+    @Test
+    public void tabsClosable() throws Exception {
+        openTestURL("test");
+        open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
+        check("Closable");
+        check("Disable tabs");
+        check("Overflow");
+        compareScreen("tabs-closable-disabled");
+    }
+
+    @Test
+    public void tabsAlignRight() throws Exception {
+        openTestURL("test");
+        open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
+        check("Right-aligned tabs");
+        compareScreen("tabs-align-right");
+    }
+
+    /**
+     * workaround for http://dev.vaadin.com/ticket/13763
+     */
+    private void check(String caption) {
+        WebElement cb = $(CheckBoxElement.class).caption(caption).first()
+                .findElement(By.xpath("input"));
+        if (BrowserUtil.isChrome(getDesiredCapabilities())) {
+            testBenchElement(cb).click(0, 0);
+        } else {
+            cb.click();
+        }
+    }
+
+    @Test
+    public void tabsAlignCenter() throws Exception {
+        openTestURL("test");
+        open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
+        check("Centered tabs");
+        compareScreen("tabs-align-center");
+    }
+
+    @Test
+    public void tabsIconsOnTop() throws Exception {
+        openTestURL("test");
+        open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
+        check("Icons on top");
+        compareScreen("tabs-icons-on-top");
+    }
+
+    @Test
+    public void tabsEqualCompactPadded() throws Exception {
+        openTestURL("test");
+        open("Tabs <span class=\"valo-menu-badge\">123</span>", "Tabs");
+        check("Equal-width tabs");
+        check("Padded tabbar");
+        check("Compact");
+        compareScreen("tabs-equal-compact-padded");
     }
 
     @Test