summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2014-09-20 14:22:21 +0300
committerLeif Åstrand <leif@vaadin.com>2014-09-22 05:38:10 +0000
commit222876bc4057366c63060984c577bbbfb1cc3145 (patch)
treee1637bd110c8fed28e5d764143477e80cca1074c /uitest
parent526b23cd86ccc7603e280da45d48f3f4bfcc4ecd (diff)
downloadvaadin-framework-222876bc4057366c63060984c577bbbfb1cc3145.tar.gz
vaadin-framework-222876bc4057366c63060984c577bbbfb1cc3145.zip
Add autogenerated style name for UI based on its class name (#14670)
Change-Id: Ic2ff4c29f997c33ea952a94c17aa9e70a0339337
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleName.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.java87
2 files changed, 130 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleName.java b/uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleName.java
new file mode 100644
index 0000000000..35dc4cd325
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleName.java
@@ -0,0 +1,43 @@
+/*
+ * 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.components.ui;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+
+/**
+ * Empty test ui to check auto-generated style name for UI.
+ *
+ * @author Vaadin Ltd
+ */
+public class UIAutoGeneratedStyleName extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Add UI specific autogenerated style name to ui div element"
+ + " and overlays container";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14670;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.java b/uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.java
new file mode 100644
index 0000000000..48d4c406f7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/ui/UIAutoGeneratedStyleNameTest.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.components.ui;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+
+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.phantomjs.PhantomJSDriver;
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.testbench.TestBench;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+/**
+ * Test to check auto-generated style name for UI div and overlays div.
+ *
+ * @author Vaadin Ltd
+ */
+public class UIAutoGeneratedStyleNameTest extends MultiBrowserTest {
+
+ @Test
+ public void testUiStyleName() {
+ openTestURL();
+
+ Assert.assertTrue(
+ "UI div element doesn't contain autogenerated style name",
+ containsStyle(getDriver().findElement(By.className("v-app")),
+ UIAutoGeneratedStyleName.class.getSimpleName()
+ .toLowerCase(Locale.ENGLISH)));
+
+ Assert.assertTrue(
+ "Overlays div element doesn't contain autogenerated style name",
+ containsStyle(
+ getDriver().findElement(
+ By.className("v-overlay-container")),
+ UIAutoGeneratedStyleName.class.getSimpleName()
+ .toLowerCase(Locale.ENGLISH)));
+ }
+
+ private boolean containsStyle(WebElement element, String style) {
+ return element.getAttribute("class").contains(style);
+ }
+
+ @Override
+ protected void setupDriver() throws Exception {
+ System.setProperty("phantomjs.binary.path",
+ "C:\\tmp\\phantom\\phantomjs.exe");
+ WebDriver dr = TestBench.createDriver(new PhantomJSDriver());
+ setDriver(dr);
+ }
+
+ @Override
+ protected String getScreenshotDirectory() {
+ return "C:\\tmp\\a";
+ }
+
+ @Override
+ protected void openTestURL() {
+ driver.get("http://localhost:8080/vaadin/run/UIAutoGeneratedStyleName");
+ }
+
+ @Override
+ public List<DesiredCapabilities> getBrowsersToTest() {
+ return Collections.singletonList(Browser.FIREFOX
+ .getDesiredCapabilities());
+ }
+
+}