aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-09-27 12:44:01 +0200
committerHenri Sara <henri.sara@gmail.com>2017-09-27 13:44:01 +0300
commit9f9efe0058397992fda43e104c90b79039d41c0f (patch)
tree6903fb464d96fb1f8f6a4e92c1308833388fd210 /uitest/src
parent94c57dea3848635e0ae42fae464e23301f9e7c2c (diff)
downloadvaadin-framework-9f9efe0058397992fda43e104c90b79039d41c0f.tar.gz
vaadin-framework-9f9efe0058397992fda43e104c90b79039d41c0f.zip
Support addCloseListener for Notification (#10027)
Converts Notification to an Extension and adds support for listening to the closing of notifications. Fixes #888
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/extensions/NotificationCloseListener.java47
-rw-r--r--uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java49
2 files changed, 96 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/extensions/NotificationCloseListener.java b/uitest/src/main/java/com/vaadin/tests/extensions/NotificationCloseListener.java
new file mode 100644
index 0000000000..2528f935b2
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/extensions/NotificationCloseListener.java
@@ -0,0 +1,47 @@
+/*
+ * 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.extensions;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Notification;
+
+/**
+ * UI used to validate Notification closes works.
+ */
+public class NotificationCloseListener extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ CheckBox checkBox = new CheckBox();
+ addComponent(checkBox);
+
+ Notification notification = Notification.show("something");
+ notification.addCloseListener(e -> checkBox.setValue(true));
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Notification Close listener is called.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10027;
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java b/uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java
new file mode 100644
index 0000000000..3b241a49d8
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/extensions/NotificationCloseListenerTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2016 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.extensions;
+
+import org.junit.Test;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class NotificationCloseListenerTest extends MultiBrowserTest {
+
+ @Test
+ public void closeListenerCalled() throws Exception {
+ openTestURL();
+
+ $(NotificationElement.class).first().close();
+
+ waitUntil(new ExpectedCondition<Boolean>() {
+
+ @Override
+ public Boolean apply(WebDriver input) {
+ try {
+ return $(CheckBoxElement.class).first().isChecked();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+ });
+ }
+}