aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2014-12-30 12:18:24 +0200
committerVaadin Code Review <review@vaadin.com>2015-04-17 13:19:21 +0000
commit6ce22d8ad5c9e81cc2e34a70779413fb2c7040d6 (patch)
tree800e48685a033a064f6430c9988f6c8a8700347a /uitest/src
parent3dea20b56ab4918f30e611565ac28d053b2d9cc6 (diff)
downloadvaadin-framework-6ce22d8ad5c9e81cc2e34a70779413fb2c7040d6.tar.gz
vaadin-framework-6ce22d8ad5c9e81cc2e34a70779413fb2c7040d6.zip
Update favicon when changing themes (#15481)
Change-Id: I3622d211ac5e668f7dce999605118f8f16ffae90
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/themes/ThemeChangeFavicon.java44
-rw-r--r--uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java87
2 files changed, 131 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeFavicon.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeFavicon.java
new file mode 100644
index 0000000000..8995583975
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/themes/ThemeChangeFavicon.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.themes;
+
+import java.util.Arrays;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+
+public class ThemeChangeFavicon extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ for (final String theme : Arrays.asList("valo", "reindeer")) {
+ addComponent(new Button(theme, new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ setTheme(theme);
+ }
+ }));
+ }
+ }
+
+ @Override
+ public String getDescription() {
+ return "UI for testing that the favicon changes when changing themes";
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java b/uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java
new file mode 100644
index 0000000000..e4788f93f5
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/themes/ThemeChangeFaviconTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.themes;
+
+import java.util.Collections;
+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;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class ThemeChangeFaviconTest extends SingleBrowserTest {
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ // Seems like stylesheet onload is not fired on PhantomJS
+ // https://github.com/ariya/phantomjs/issues/12332
+ return Collections.singletonList(Browser.FIREFOX
+ .getDesiredCapabilities());
+ }
+
+ @Test
+ public void changeFavicon() throws InterruptedException {
+ setDebug(true);
+ openTestURL();
+ assertFavicon("reindeer");
+
+ changeTheme("valo");
+ assertFavicon("valo");
+
+ changeTheme("reindeer");
+ assertFavicon("reindeer");
+ }
+
+ 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);
+ }
+
+ private void assertFavicon(String theme) {
+ String faviconUrl = "/VAADIN/themes/" + theme + "/favicon.ico";
+
+ List<WebElement> elements = findElements(By
+ .cssSelector("link[rel~=\"icon\"]"));
+
+ Assert.assertEquals(2, elements.size());
+
+ for (WebElement element : elements) {
+ Assert.assertTrue(element.getAttribute("href")
+ + " does not end with " + faviconUrl,
+ element.getAttribute("href").endsWith(faviconUrl));
+ }
+ }
+
+}