]> source.dussan.org Git - vaadin-framework.git/commitdiff
Extract duplciated logic for checking for error notifications
authorLeif Åstrand <leif@vaadin.com>
Fri, 19 Jun 2015 11:22:19 +0000 (14:22 +0300)
committerVaadin Code Review <review@vaadin.com>
Mon, 22 Jun 2015 09:04:16 +0000 (09:04 +0000)
Change-Id: I1cc630e9c21b3e73d135129ba3d86f7b22019e0f

uitest/src/com/vaadin/tests/components/accordion/AccordionRemoveComponentTest.java
uitest/src/com/vaadin/tests/components/optiongroup/ReadOnlyOptionGroupTest.java
uitest/src/com/vaadin/tests/components/popupview/PopupViewWithExtensionTest.java
uitest/src/com/vaadin/tests/components/table/DndEmptyTableTest.java
uitest/src/com/vaadin/tests/tb3/AbstractTB3Test.java

index 84f173489710989af5ef22e4140a3faa140c4343..785acddcb7969c8e22805f7ac8593c62b963ae10 100644 (file)
@@ -15,9 +15,7 @@
  */
 package com.vaadin.tests.components.accordion;
 
-import org.junit.Assert;
 import org.junit.Test;
-import org.openqa.selenium.By;
 
 import com.vaadin.testbench.elements.ButtonElement;
 import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -36,8 +34,7 @@ public class AccordionRemoveComponentTest extends MultiBrowserTest {
 
         $(ButtonElement.class).first().click();
 
-        Assert.assertFalse(
-                "Error notification with client side exception is shown",
-                isElementPresent(By.className("v-Notification-error")));
+        assertNoErrorNotifications();
     }
+
 }
index dfafe8fb40cbfe31b37b6bd59363369b8b63ef3e..090286b1ad7cf5703b3ba92f946ed53b0eacf66a 100644 (file)
@@ -38,9 +38,7 @@ public class ReadOnlyOptionGroupTest extends MultiBrowserTest {
         WebElement checkboxInput = checkbox.findElement(By.tagName("input"));
         checkboxInput.click();
 
-        Assert.assertFalse("There is a client side exception after unset "
-                + "readonly mode for option group",
-                isElementPresent(By.className("v-Notification-error")));
+        assertNoErrorNotifications();
 
         Assert.assertFalse("Radio button in option group is still disabled "
                 + "after unset reaonly",
index 4d11190ea964d221b866de0f48b011634913bb0d..073fd321e5f42f7331588c0e79606883cfddf29d 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.vaadin.tests.components.popupview;
 
-import org.junit.Assert;
 import org.junit.Test;
 import org.openqa.selenium.WebElement;
 
@@ -38,10 +37,7 @@ public class PopupViewWithExtensionTest extends MultiBrowserTest {
         WebElement view = driver.findElement(By.className("v-popupview"));
         view.click();
 
-        Assert.assertFalse(
-                "Popup view with extension should not throw an exception. "
-                        + "(Error notification window is shown).",
-                isElementPresent(By.className("v-Notification-error")));
+        assertNoErrorNotifications();
     }
 
 }
index 4c682637b1922f4b11a20c3e3dee877ca473786d..6fb0d446d3a6ebc0bc6180684a5e82f507062c85 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.vaadin.tests.components.table;
 
-import org.junit.Assert;
 import org.junit.Test;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.interactions.Actions;
@@ -42,8 +41,7 @@ public class DndEmptyTableTest extends MultiBrowserTest {
         Actions actions = new Actions(driver);
         actions.clickAndHold(source).moveToElement(target).release();
 
-        Assert.assertFalse(isElementPresent(By
-                .className("v-Notification-error")));
+        assertNoErrorNotifications();
     }
 
 }
index 2e33cc2741bf4747ac46d905cae0c13e31e19a65..5b05d1d50ad55075d55cf8371c68e13bf80ef0dc 100644 (file)
@@ -1065,4 +1065,21 @@ public abstract class AbstractTB3Test extends ParallelTest {
         Assert.assertFalse("Element is present", isElementPresent(by));
     }
 
+    /**
+     * Asserts that no error notifications are shown. Requires the use of
+     * "?debug" as exceptions are otherwise not shown as notifications.
+     */
+    protected void assertNoErrorNotifications() {
+        Assert.assertTrue(
+                "Debug window must be open to be able to see error notifications",
+                isDebugWindowOpen());
+        Assert.assertFalse(
+                "Error notification with client side exception is shown",
+                isElementPresent(By.className("v-Notification-error")));
+    }
+
+    private boolean isDebugWindowOpen() {
+        return isElementPresent(By.className("v-debugwindow"));
+    }
+
 }