summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorDenis Anisimov <denis@vaadin.com>2015-05-17 12:34:32 +0300
committerVaadin Code Review <review@vaadin.com>2015-05-29 14:02:44 +0000
commit5b92ec790e3d3949992275d54ee8ac61ad94c157 (patch)
treebe337a1878d4afd3573b8e99ce0cda68f07f3e5d /uitest
parented5ad86b114ccb4d6ab08e19a734bdb8b3342399 (diff)
downloadvaadin-framework-5b92ec790e3d3949992275d54ee8ac61ad94c157.tar.gz
vaadin-framework-5b92ec790e3d3949992275d54ee8ac61ad94c157.zip
Fix for Valo notification mixins (#14872).
Change-Id: I6477557c605443419ee3fc9f3398ae5af4956aa7
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/application/CriticalNotifications.java130
-rw-r--r--uitest/src/com/vaadin/tests/application/CriticalNotificationsTestBase.java110
-rw-r--r--uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java35
3 files changed, 275 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/application/CriticalNotifications.java b/uitest/src/com/vaadin/tests/application/CriticalNotifications.java
new file mode 100644
index 0000000000..bde3fbaf6f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/CriticalNotifications.java
@@ -0,0 +1,130 @@
+/*
+ * 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.application;
+
+import java.io.IOException;
+
+import com.vaadin.server.SystemMessages;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinResponse;
+import com.vaadin.server.VaadinService;
+import com.vaadin.shared.JsonConstants;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class CriticalNotifications extends AbstractTestUI {
+
+ private SystemMessages systemMessages;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ systemMessages = VaadinService.getCurrent().getSystemMessages(
+ getLocale(), request);
+
+ Button sessionExpired = new Button("Session expired");
+ addComponent(sessionExpired);
+ sessionExpired.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ showCriticalNotification(
+ systemMessages.getSessionExpiredCaption(),
+ systemMessages.getSessionExpiredMessage(), null,
+ systemMessages.getSessionExpiredURL());
+
+ }
+ });
+
+ Button authenticationError = new Button("Authentication error");
+ addComponent(authenticationError);
+ authenticationError.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ showCriticalNotification(
+ systemMessages.getAuthenticationErrorCaption(),
+ systemMessages.getAuthenticationErrorMessage(), null,
+ systemMessages.getAuthenticationErrorURL());
+
+ }
+ });
+
+ Button communicationError = new Button("Communication error");
+ addComponent(communicationError);
+ communicationError.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ showCriticalNotification(
+ systemMessages.getCommunicationErrorCaption(),
+ systemMessages.getCommunicationErrorMessage(), null,
+ systemMessages.getCommunicationErrorURL());
+
+ }
+ });
+
+ Button internalError = new Button("Internal error");
+ addComponent(internalError);
+ internalError.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ showCriticalNotification(
+ systemMessages.getInternalErrorCaption(),
+ systemMessages.getInternalErrorMessage(), null,
+ systemMessages.getInternalErrorURL());
+
+ }
+ });
+
+ Button cookiesDisabled = new Button("Cookies disabled");
+ addComponent(cookiesDisabled);
+ cookiesDisabled.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ showCriticalNotification(
+ systemMessages.getCookiesDisabledCaption(),
+ systemMessages.getCookiesDisabledMessage(), null,
+ systemMessages.getCookiesDisabledURL());
+
+ }
+ });
+ Button custom = new Button("Custom");
+ addComponent(custom);
+ custom.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ showCriticalNotification("Custom caption", "Custom message",
+ "Custom details", "custom url");
+
+ }
+ });
+ }
+
+ protected void showCriticalNotification(String caption, String message,
+ String details, String url) {
+ VaadinService service = VaadinService.getCurrent();
+ VaadinResponse response = VaadinService.getCurrentResponse();
+
+ try {
+ service.writeStringResponse(response,
+ JsonConstants.JSON_CONTENT_TYPE, VaadinService
+ .createCriticalNotificationJSON(caption, message,
+ details, url));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/application/CriticalNotificationsTestBase.java b/uitest/src/com/vaadin/tests/application/CriticalNotificationsTestBase.java
new file mode 100644
index 0000000000..2f32fa8026
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/application/CriticalNotificationsTestBase.java
@@ -0,0 +1,110 @@
+/*
+ * 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.application;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.MultiBrowserThemeTest;
+
+public abstract class CriticalNotificationsTestBase extends
+ MultiBrowserThemeTest {
+
+ public static class ValoCriticalNotificationsTest extends
+ CriticalNotificationsTestBase {
+ @Override
+ protected String getTheme() {
+ return "valo";
+ }
+ }
+
+ public static class ReindeerCriticalNotificationsTest extends
+ CriticalNotificationsTestBase {
+ @Override
+ protected String getTheme() {
+ return "reindeer";
+ }
+ }
+
+ public static class RunoCriticalNotificationsTest extends
+ CriticalNotificationsTestBase {
+ @Override
+ protected String getTheme() {
+ return "runo";
+ }
+ }
+
+ public static class ChameleonCriticalNotificationsTest extends
+ CriticalNotificationsTestBase {
+ @Override
+ protected String getTheme() {
+ return "chameleon";
+ }
+ }
+
+ public static class BaseCriticalNotificationsTest extends
+ CriticalNotificationsTestBase {
+ @Override
+ protected String getTheme() {
+ return "base";
+ }
+ }
+
+ @Test
+ public void authenticationError() throws Exception {
+ testCriticalNotification("Authentication error");
+ }
+
+ @Test
+ public void communicationError() throws Exception {
+ testCriticalNotification("Communication error");
+ }
+
+ @Test
+ public void internalError() throws Exception {
+ testCriticalNotification("Internal error");
+ }
+
+ @Test
+ public void cookiesDisabled() throws Exception {
+ testCriticalNotification("Cookies disabled");
+ }
+
+ @Test
+ public void custom() throws Exception {
+ testCriticalNotification("Custom");
+ }
+
+ @Test
+ public void sessionExpired() throws Exception {
+ testCriticalNotification("Session expired");
+ }
+
+ private void testCriticalNotification(String buttonCaption)
+ throws Exception {
+ openTestURL(); // "theme=" + getTheme());
+ $(ButtonElement.class).caption(buttonCaption).first().click();
+ // Give the notification some time to animate
+ sleep(1000);
+ compareScreen("notification");
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return CriticalNotifications.class;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java b/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java
new file mode 100644
index 0000000000..546588947c
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tb3/MultiBrowserThemeTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.tb3;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Test which uses theme returned by {@link #getTheme()} for running the test
+ */
+public abstract class MultiBrowserThemeTest extends MultiBrowserTest {
+
+ protected abstract String getTheme();
+
+ @Override
+ protected void openTestURL(Class<?> uiClass, String... parameters) {
+ Set<String> params = new HashSet<String>(Arrays.asList(parameters));
+ params.add("theme=" + getTheme());
+ super.openTestURL(uiClass, params.toArray(new String[params.size()]));
+ }
+}