From 0d1bbc946c5372994ef5587438023e42ddcfa54c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pekka=20Hyv=C3=B6nen?= Date: Wed, 13 May 2015 14:56:20 +0300 Subject: [PATCH] Fixes regression in Notifications and tests (#14872) Change-Id: Ifa52508f5555c47b778cb7f80aa09f665b03b8d4 --- .../vaadin/client/ApplicationConnection.java | 10 ++++++++-- .../com/vaadin/client/ui/VNotification.java | 17 ++++++++++++++--- .../tests/themes/valo/NotificationStyle.java | 19 +++++++++++++++++-- .../themes/valo/NotificationStyleTest.java | 15 ++++++++------- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index af86818fb3..3a8d69f25a 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -1285,12 +1285,18 @@ public class ApplicationConnection implements HasHandlers { StringBuilder html = new StringBuilder(); if (caption != null) { - html.append("

"); + html.append("

"); html.append(caption); html.append("

"); } if (message != null) { - html.append("

"); + html.append("

"); html.append(message); html.append("

"); } diff --git a/client/src/com/vaadin/client/ui/VNotification.java b/client/src/com/vaadin/client/ui/VNotification.java index 2892d4e3ac..4f0c2eb625 100644 --- a/client/src/com/vaadin/client/ui/VNotification.java +++ b/client/src/com/vaadin/client/ui/VNotification.java @@ -63,8 +63,8 @@ public class VNotification extends VOverlay { private static final String STYLENAME_POSITION_CENTER = "v-position-center"; private static final String STYLENAME_POSITION_ASSISTIVE = "v-position-assistive"; - private static final String CAPTION = "caption"; - private static final String DESCRIPTION = "description"; + public static final String CAPTION = "caption"; + public static final String DESCRIPTION = "description"; /** * Position that is only accessible for assistive devices, invisible for @@ -532,7 +532,18 @@ public class VNotification extends VOverlay { html, position, style); } - private static String getDependentStyle(ApplicationConnection client, + /** + * Meant for internal usage only. + * + * @since 7.5.0 + * @param client + * application connection + * @param style + * the dependent style name + * @return the given dependent style name prefixed with current notification + * primary style + */ + public static String getDependentStyle(ApplicationConnection client, String style) { VNotification notification = createNotification(-1, client .getUIConnector().getWidget()); diff --git a/uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java index c7abcf9303..e918bb64d0 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java +++ b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyle.java @@ -32,14 +32,29 @@ public class NotificationStyle extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { - Button button = new Button("Show notification", + Button button = new Button("Show notification with h1", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Notification notification = new Notification( "

Caption

", - "

Description

"); + "

Description

" + + "

tested p

"); + notification.setHtmlContentAllowed(true); + notification.setDelayMsec(50000); + notification.show(getPage()); + } + }); + addComponent(button); + button = new Button("Show notification with p", + new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + Notification notification = new Notification( + "

Caption

", + "Description text

tested p text

"); notification.setHtmlContentAllowed(true); notification.setDelayMsec(50000); notification.show(getPage()); diff --git a/uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java index 829ad27a94..b2db29443a 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java +++ b/uitest/src/com/vaadin/tests/themes/valo/NotificationStyleTest.java @@ -57,19 +57,20 @@ public class NotificationStyleTest extends MultiBrowserTest { public void testNotificationPStyle() { openTestURL(); - $(ButtonElement.class).first().click(); + $(ButtonElement.class).get(1).click(); new Actions(getDriver()).moveByOffset(10, 10).perform(); waitUntil(notificationPresentCondition(), 2); WebElement notification = findElement(By.className("v-Notification")); - List headers = notification.findElements(By.tagName("p")); - String lineHeight = headers.get(0).getCssValue("line-height"); - String lineHeightInnerHeader = headers.get(1) - .getCssValue("line-height"); + WebElement description = notification.findElement(By + .className("v-Notification-description")); + String display = description.getCssValue("display"); + String displayP2 = notification.findElement( + By.className("tested-p")).getCssValue("display"); Assert.assertNotEquals("Styles for notification defined 'p' tag " - + "and custom HTML tag are the same", lineHeight, - lineHeightInnerHeader); + + "and custom HTML tag are the same", display, + displayP2); } private ExpectedCondition notificationPresentCondition() { -- 2.39.5