diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-11-09 16:24:06 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-05-11 07:41:18 +0000 |
commit | 244faff333b77dca3fadfe964b646ff7d0eceb2f (patch) | |
tree | 6554bfe9d0c7404117b2845bc9f93f5fbd624f27 /uitest/src/com/vaadin/tests/themes | |
parent | 4eb495cac3f006b9f1aa525f04025401734a3550 (diff) | |
download | vaadin-framework-244faff333b77dca3fadfe964b646ff7d0eceb2f.tar.gz vaadin-framework-244faff333b77dca3fadfe964b646ff7d0eceb2f.zip |
Notification styles should be scoped more eagerly (#14872)
Change-Id: Ifb648b8913c9999d3c0c855f05f79c8356577887
Diffstat (limited to 'uitest/src/com/vaadin/tests/themes')
-rw-r--r-- | uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java | 61 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java | 84 |
2 files changed, 145 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java new file mode 100644 index 0000000000..c7abcf9303 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java @@ -0,0 +1,61 @@ +/* + * 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.valo; + +import com.vaadin.annotations.Theme; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Notification; + +/** + * Test UI for H1 and P elements styles. + * + * @author Vaadin Ltd + */ +@Theme("valo") +public class NotificationStyle extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Button button = new Button("Show notification", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Notification notification = new Notification( + "<p>Caption</p>", + "<div style='display:inline-block;'><h1>Description</h1></div>"); + notification.setHtmlContentAllowed(true); + notification.setDelayMsec(50000); + notification.show(getPage()); + } + }); + addComponent(button); + } + + @Override + protected Integer getTicketNumber() { + return 14872; + } + + @Override + protected String getTestDescription() { + return "Notification styles should be scoped more eagerly."; + } + +} diff --git a/uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java new file mode 100644 index 0000000000..829ad27a94 --- /dev/null +++ b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java @@ -0,0 +1,84 @@ +/* + * 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.valo; + +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.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedCondition; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test for H1 and P elements styles in Notifications. + * + * @author Vaadin Ltd + */ +public class NotificationStyleTest extends MultiBrowserTest { + + @Test + public void testNotificationH1Style() { + openTestURL(); + + $(ButtonElement.class).first().click(); + + new Actions(getDriver()).moveByOffset(10, 10).perform(); + waitUntil(notificationPresentCondition(), 2); + + WebElement notification = findElement(By.className("v-Notification")); + List<WebElement> headers = notification.findElements(By.tagName("h1")); + String textAlign = headers.get(0).getCssValue("text-align"); + String textAlignInnerHeader = headers.get(1).getCssValue("text-align"); + Assert.assertNotEquals("Styles for notification defined h1 tag " + + "and custom HTML tag are the same", textAlign, + textAlignInnerHeader); + } + + @Test + public void testNotificationPStyle() { + openTestURL(); + + $(ButtonElement.class).first().click(); + + new Actions(getDriver()).moveByOffset(10, 10).perform(); + waitUntil(notificationPresentCondition(), 2); + + WebElement notification = findElement(By.className("v-Notification")); + List<WebElement> headers = notification.findElements(By.tagName("p")); + String lineHeight = headers.get(0).getCssValue("line-height"); + String lineHeightInnerHeader = headers.get(1) + .getCssValue("line-height"); + Assert.assertNotEquals("Styles for notification defined 'p' tag " + + "and custom HTML tag are the same", lineHeight, + lineHeightInnerHeader); + } + + private ExpectedCondition<Boolean> notificationPresentCondition() { + return new ExpectedCondition<Boolean>() { + + @Override + public Boolean apply(WebDriver input) { + return isElementPresent(By.className("v-Notification")); + } + }; + } +} |