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 {
// e.printStackTrace();
// }
- Responsive.makeResponsive(this);
+ if (!testMode) {
+ Responsive.makeResponsive(this);
+ }
getPage().setTitle("Valo Theme Test");
setContent(root);
}
+ 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;
}
}
return container;
}
-}
\ No newline at end of file
+}
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;
public void tables() throws Exception {
openTestURL("test");
open("Tables");
+ check("Components in Cells");
compareScreen("tables");
}
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