[HtmlUnit] SVN: [15431] trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ javascript/host

rbri--- via HtmlUnit-develop <[email protected]>
Newsgroups gmane.comp.java.htmlunit.devel
Message-ID <[email protected]>
Revision: 15431
          http://sourceforge.net/p/htmlunit/code/15431
Author:   rbri
Date:     2018-07-05 06:23:56 +0000 (Thu, 05 Jul 2018)
Log Message:
-----------
try to make our test suite more robust (when running in real browsers)

Modified Paths:
--------------
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/History2Test.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/History2Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/History2Test.java	2018-07-05 06:23:37 UTC (rev 15430)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/History2Test.java	2018-07-05 06:23:56 UTC (rev 15431)
@@ -766,10 +766,10 @@
                 + "</body></html>";
 
         final WebDriver driver = loadPage2(html);
-        assertEquals("page1", driver.getTitle());
+        assertTitle(driver, "page1");
 
         loadPage2(html2, URL_SECOND);
-        assertEquals("page2", driver.getTitle());
+        assertTitle(driver, "page2");
     }
 
     /**

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java	2018-07-05 06:23:37 UTC (rev 15430)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java	2018-07-05 06:23:56 UTC (rev 15431)
@@ -307,9 +307,9 @@
         final String secondContent = "<html><head><title>Second</title></head><body></body></html>";
 
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
-        final WebDriver webdriver = loadPageWithAlerts2(html);
+        final WebDriver driver = loadPage2(html);
 
-        assertEquals("Second", webdriver.getTitle());
+        assertTitle(driver, "Second");
     }
 
     /**
@@ -333,14 +333,14 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
         getMockWebConnection().setResponse(URL_THIRD, thirdContent);
 
-        final WebDriver webdriver = loadPageWithAlerts2(startContent);
-        webdriver.get(URL_SECOND.toExternalForm());
+        final WebDriver driver = loadPageWithAlerts2(startContent);
+        driver.get(URL_SECOND.toExternalForm());
 
-        assertEquals("Third Page", webdriver.getTitle());
+        assertTitle(driver, "Third Page");
 
         // navigate back
-        webdriver.navigate().back();
-        assertEquals("First Page", webdriver.getTitle());
+        driver.navigate().back();
+        assertTitle(driver, "First Page");
     }
 
     /**
@@ -363,9 +363,9 @@
                 + "<body onload='alert(\"on-load\")'></body></html>";
 
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
-        final WebDriver webdriver = loadPageWithAlerts2(html);
+        final WebDriver driver = loadPageWithAlerts2(html);
 
-        assertEquals("Second", webdriver.getTitle());
+        assertTitle(driver, "Second");
         assertEquals(2, getMockWebConnection().getRequestCount());
     }
 
@@ -387,9 +387,8 @@
 
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
 
-        final WebDriver webdriver = loadPageWithAlerts2(firstContent);
-
-        assertEquals("Second Page", webdriver.getTitle());
+        final WebDriver driver = loadPageWithAlerts2(firstContent);
+        assertTitle(driver, "Second Page");
     }
 
     /**
@@ -410,7 +409,7 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
 
         final WebDriver driver = loadPage2(firstContent, URL_FIRST);
-        assertEquals("Second", driver.getTitle());
+        assertTitle(driver, "Second");
     }
 
     /**
@@ -434,7 +433,7 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
         final WebDriver driver = loadPageWithAlerts2(firstContent);
 
-        assertEquals("Second", driver.getTitle());
+        assertTitle(driver, "Second");
         assertEquals(2, getMockWebConnection().getRequestCount());
     }
 
@@ -456,7 +455,7 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
 
         final WebDriver driver = loadPage2(firstContent, URL_FIRST);
-        assertEquals("Second", driver.getTitle());
+        assertTitle(driver, "Second");
     }
 
     /**
@@ -480,7 +479,7 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
         final WebDriver driver = loadPageWithAlerts2(firstContent);
 
-        assertEquals("Second", driver.getTitle());
+        assertTitle(driver, "Second");
         assertEquals(2, getMockWebConnection().getRequestCount());
     }
 
@@ -558,7 +557,8 @@
         getMockWebConnection().setResponse(URL_SECOND, secondHtml);
 
         final WebDriver driver = loadPage2(firstHtml);
-        assertEquals(getExpectedAlerts()[0], driver.getTitle());
+
+        assertTitle(driver, getExpectedAlerts()[0]);
     }
 
     /**

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java	2018-07-05 06:23:37 UTC (rev 15430)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java	2018-07-05 06:23:56 UTC (rev 15431)
@@ -1628,7 +1628,6 @@
               + "</html>";
 
         final WebDriver driver = loadPage2(html);
-        Thread.sleep(200);
-        assertEquals(getExpectedAlerts()[0], driver.getTitle());
+        assertTitle(driver, getExpectedAlerts()[0]);
     }
 }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java	2018-07-05 06:23:37 UTC (rev 15430)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java	2018-07-05 06:23:56 UTC (rev 15431)
@@ -1927,7 +1927,7 @@
         getMockWebConnection().setResponse(URL_SECOND, iframe);
         final WebDriver driver = loadPage2(html);
 
-        assertEquals(getExpectedAlerts()[0], driver.getTitle());
+        assertTitle(driver, getExpectedAlerts()[0]);
     }
 
     /**
@@ -1988,11 +1988,11 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
 
         final WebDriver driver = loadPage2(firstContent);
-        assertEquals("First", driver.getTitle());
+        assertTitle(driver, "First");
         assertEquals(1, driver.getWindowHandles().size());
 
         driver.findElement(By.id("link")).click();
-        assertEquals("Second", driver.getTitle());
+        assertTitle(driver, "Second");
 
         assertEquals(1, driver.getWindowHandles().size());
         assertEquals(new String[] {"", "second/"}, getMockWebConnection().getRequestedUrls(URL_FIRST));
@@ -2018,11 +2018,11 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
 
         final WebDriver driver = loadPage2(firstContent);
-        assertEquals("First", driver.getTitle());
+        assertTitle(driver, "First");
         assertEquals(1, driver.getWindowHandles().size());
 
         driver.findElement(By.id("link")).click();
-        assertEquals("Second", driver.getTitle());
+        assertTitle(driver, "Second");
 
         assertEquals(1, driver.getWindowHandles().size());
         assertEquals(new String[] {"", "second/"}, getMockWebConnection().getRequestedUrls(URL_FIRST));
@@ -2048,11 +2048,11 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
 
         final WebDriver driver = loadPage2(firstContent);
-        assertEquals("First", driver.getTitle());
+        assertTitle(driver, "First");
         assertEquals(1, driver.getWindowHandles().size());
 
         driver.findElement(By.id("link")).click();
-        assertEquals("Second", driver.getTitle());
+        assertTitle(driver, "Second");
 
         assertEquals(1, driver.getWindowHandles().size());
         assertEquals(new String[] {"", "second/"}, getMockWebConnection().getRequestedUrls(URL_FIRST));

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java	2018-07-05 06:23:37 UTC (rev 15430)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java	2018-07-05 06:23:56 UTC (rev 15431)
@@ -109,7 +109,7 @@
         getMockWebConnection().setResponse(urlThird, thirdContent);
 
         final WebDriver driver = loadPageWithAlerts2(firstContent);
-        assertEquals("First", driver.getTitle());
+        assertTitle(driver, "First");
     }
 
     /**
@@ -180,7 +180,7 @@
         getMockWebConnection().setResponse(urlThird, thirdContent);
 
         final WebDriver driver = loadPageWithAlerts2(firstContent);
-        assertEquals("First", driver.getTitle());
+        assertTitle(driver, "First");
     }
 
     /**
@@ -227,7 +227,7 @@
         getMockWebConnection().setResponse(urlFourth, fourthContent);
 
         final WebDriver driver = loadPageWithAlerts2(firstContent);
-        assertEquals("first", driver.getTitle());
+        assertTitle(driver, "first");
     }
 
     /**
@@ -290,7 +290,7 @@
         setExpectedAlerts(expectedAlerts);
 
         final WebDriver driver = loadPageWithAlerts2(firstContent);
-        assertEquals("first", driver.getTitle());
+        assertTitle(driver, "first");
     }
 
     /**
@@ -1515,7 +1515,7 @@
         getMockWebConnection().setResponse(URL_SECOND, secondContent);
 
         final WebDriver driver = loadPage2(firstContent, URL_FIRST);
-        assertEquals(getExpectedAlerts()[0], driver.getTitle());
+        assertTitle(driver, getExpectedAlerts()[0]);
     }
 
     /**

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java	2018-07-05 06:23:37 UTC (rev 15430)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java	2018-07-05 06:23:56 UTC (rev 15431)
@@ -2035,7 +2035,7 @@
                 + "</html>");
 
         final WebDriver driver = loadPage2(html);
-        assertEquals(getExpectedAlerts()[0], driver.getTitle());
+        assertTitle(driver, getExpectedAlerts()[0]);
     }
 
     /**


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.