From: Artur Signell Date: Tue, 19 Aug 2014 11:54:16 +0000 (+0300) Subject: Make test more stable X-Git-Tag: 7.3.0.rc1~6^2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=403b9b5870ea643edfe7fe8a2390f0a012f69d5e;p=vaadin-framework.git Make test more stable * Added tests for tabsheet variants Change-Id: Ib8d5c88cdedf1bbac439f91346b7b8a6a6756ede --- diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java index 501b5f573b..b33a604033 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java @@ -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 +} diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java index fdb2eabeee..b5b7e16b34 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java @@ -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 123", "Tabs"); compareScreen("tabs"); + + } + + @Test + public void tabsClosable() throws Exception { + openTestURL("test"); + open("Tabs 123", "Tabs"); + check("Closable"); + check("Disable tabs"); + check("Overflow"); + compareScreen("tabs-closable-disabled"); + } + + @Test + public void tabsAlignRight() throws Exception { + openTestURL("test"); + open("Tabs 123", "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 123", "Tabs"); + check("Centered tabs"); + compareScreen("tabs-align-center"); + } + + @Test + public void tabsIconsOnTop() throws Exception { + openTestURL("test"); + open("Tabs 123", "Tabs"); + check("Icons on top"); + compareScreen("tabs-icons-on-top"); + } + + @Test + public void tabsEqualCompactPadded() throws Exception { + openTestURL("test"); + open("Tabs 123", "Tabs"); + check("Equal-width tabs"); + check("Padded tabbar"); + check("Compact"); + compareScreen("tabs-equal-compact-padded"); } @Test