[HtmlUnit] SVN: [14752] trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ html

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HtmlUnit] SVN: [14752] trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/ html

HtmlUnit - Dev mailing list
Revision: 14752
          http://sourceforge.net/p/htmlunit/code/14752
Author:   rbri
Date:     2017-08-01 18:23:08 +0000 (Tue, 01 Aug 2017)
Log Message:
-----------
fix build

Modified Paths:
--------------
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlArea2Test.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAreaTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageTest.java

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlArea2Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlArea2Test.java 2017-08-01 18:11:03 UTC (rev 14751)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlArea2Test.java 2017-08-01 18:23:08 UTC (rev 14752)
@@ -14,10 +14,14 @@
  */
 package com.gargoylesoftware.htmlunit.html;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -26,6 +30,7 @@
 import com.gargoylesoftware.htmlunit.MockWebConnection;
 import com.gargoylesoftware.htmlunit.SimpleWebTestCase;
 import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.util.NameValuePair;
 
 /**
  * Tests for {@link HtmlArea}.
@@ -33,14 +38,24 @@
  * @author <a href="mailto:[hidden email]">Mike Bowler</a>
  * @author David K. Taylor
  * @author Ahmed Ashour
+ * @author Ronald Brill
  */
 @RunWith(BrowserRunner.class)
 public class HtmlArea2Test extends SimpleWebTestCase {
 
-    private WebClient createWebClient(final String onClick) {
+    private WebClient createWebClient(final String onClick) throws IOException {
+        final MockWebConnection webConnection = new MockWebConnection();
+
+        final URL urlImage = new URL(URL_FIRST, "img.jpg");
+        try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) {
+            final byte[] directBytes = IOUtils.toByteArray(is);
+            final List<NameValuePair> emptyList = Collections.emptyList();
+            webConnection.setResponse(urlImage, directBytes, 200, "ok", "image/jpg", emptyList);
+        }
+
         final String firstContent
             = "<html><head><title>first</title></head><body>\n"
-            + "<img src='/images/planets.gif' width='145' height='126' usemap='#planetmap'>\n"
+            + "<img src='" + urlImage + "' width='145' height='126' usemap='#planetmap'>\n"
             + "<map id='planetmap' name='planetmap'>\n"
             + "<area shape='rect' onClick=\"" + onClick + "\" coords='0,0,82,126' id='second' "
             + "href='" + URL_SECOND + "'>\n"
@@ -48,14 +63,15 @@
             + "</map></body></html>";
         final String secondContent = "<html><head><title>second</title></head><body></body></html>";
         final String thirdContent = "<html><head><title>third</title></head><body></body></html>";
+
         final WebClient client = getWebClient();
 
-        final MockWebConnection webConnection = new MockWebConnection();
         webConnection.setResponse(URL_FIRST, firstContent);
         webConnection.setResponse(URL_SECOND, secondContent);
         webConnection.setResponse(URL_THIRD, thirdContent);
 
         client.setWebConnection(webConnection);
+
         return client;
     }
 

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAreaTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAreaTest.java 2017-08-01 18:11:03 UTC (rev 14751)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAreaTest.java 2017-08-01 18:23:08 UTC (rev 14752)
@@ -43,10 +43,17 @@
 public class HtmlAreaTest extends WebDriverTestCase {
 
     private WebDriver createWebClient(final String onClick) throws Exception {
+        final URL urlImage = new URL(URL_FIRST, "img.jpg");
+        try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) {
+            final byte[] directBytes = IOUtils.toByteArray(is);
+            final List<NameValuePair> emptyList = Collections.emptyList();
+            getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", "image/jpg", emptyList);
+        }
+
         final String firstContent
             = "<html><head><title>first</title></head>\n"
             + "<body>\n"
-            + "  <img src='/images/planets.gif' width='145' height='126' usemap='#planetmap'>\n"
+            + "  <img src='" + urlImage + "' width='145' height='126' usemap='#planetmap'>\n"
             + "  <map id='planetmap' name='planetmap'>\n"
             + "    <area shape='rect' onClick=\"" + onClick + "\" coords='0,0,82,126' id='second' "
                         + "href='" + URL_SECOND + "'>\n"

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageTest.java 2017-08-01 18:11:03 UTC (rev 14751)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageTest.java 2017-08-01 18:23:08 UTC (rev 14752)
@@ -54,16 +54,23 @@
     private void isMapClick(final String imgId, final Boolean samePage,
             final String urlSuffixClick, final String urlSuffixClickXY) throws Exception {
 
+        final URL urlImage = new URL(URL_FIRST, "img.jpg");
+        try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) {
+            final byte[] directBytes = IOUtils.toByteArray(is);
+            final List<NameValuePair> emptyList = Collections.emptyList();
+            getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", "image/jpg", emptyList);
+        }
+
         final String htmlContent
             = "<html>\n"
             + "<head><title>foo</title></head>\n"
             + "<body>\n"
             + "  <a href='http://server/foo'>\n"
-            + "    <img id='img1' src='foo.png' ismap>\n"
-            + "    <img id='img2' src='foo.png'>\n"
+            + "    <img id='img1' src='" + urlImage + "' ismap>\n"
+            + "    <img id='img2' src='" + urlImage + "'>\n"
             + "  </a>\n"
-            + "  <img id='img3' src='foo.png' ismap>\n"
-            + "  <img id='img4' src='foo.png'>\n"
+            + "  <img id='img3' src='" + urlImage + "' ismap>\n"
+            + "  <img id='img4' src='" + urlImage + "'>\n"
             + "</body></html>";
         final HtmlPage page = loadPage(htmlContent);
 
@@ -98,11 +105,19 @@
      * @throws Exception if the test fails
      */
     private void useMapClick(final int x, final int y, final String urlSuffix) throws Exception {
+
+        final URL urlImage = new URL(URL_FIRST, "img.jpg");
+        try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) {
+            final byte[] directBytes = IOUtils.toByteArray(is);
+            final List<NameValuePair> emptyList = Collections.emptyList();
+            getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", "image/jpg", emptyList);
+        }
+
         final String htmlContent
             = "<html>\n"
             + "<head><title>foo</title></head>\n"
             + "<body>\n"
-            + "  <img id='myImg' src='foo.png' usemap='#map1'>\n"
+            + "  <img id='myImg' src='" + urlImage + "' usemap='#map1'>\n"
             + "  <map name='map1'>\n"
             + "    <area href='a.html' shape='rect' coords='5,5,20,20'>\n"
             + "    <area href='b.html' shape='circle' coords='25,10,10'>\n"
@@ -124,9 +139,17 @@
     @Test
     @NotYetImplemented
     public void useMapClick_CircleRadiusPercentage() throws Exception {
+
+        final URL urlImage = new URL(URL_FIRST, "img.jpg");
+        try (InputStream is = getClass().getClassLoader().getResourceAsStream("testfiles/tiny-jpg.img")) {
+            final byte[] directBytes = IOUtils.toByteArray(is);
+            final List<NameValuePair> emptyList = Collections.emptyList();
+            getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", "image/jpg", emptyList);
+        }
+
         final String htmlContent
             = "<html><head><title>foo</title></head><body>\n"
-            + "<img id='myImg' src='foo.png' usemap='#map1'>\n"
+            + "<img id='myImg' src='" + urlImage + "' usemap='#map1'>\n"
             + "<map name='map1'>\n"
             + "<area href='a.html' shape='rect' coords='5,5,20,20'>\n"
             + "<area href='b.html' shape='circle' coords='25,10,10%'>\n"


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop