Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2630)

Unified Diff: net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java

Issue 255503004: Do not attempt to download favicons with 404 status in WebView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
diff --git a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
index 1971f71009d41642e0b0e4f399e4c348534bd311..0ef13ca61631fe551f2ee35a1f10ba35db844224 100644
--- a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
+++ b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java
@@ -80,11 +80,13 @@ public class TestWebServer {
final List<Pair<String, String>> mResponseHeaders;
final boolean mIsRedirect;
final Runnable mResponseAction;
+ final boolean mIsNotFound;
- Response(byte[] resposneData, List<Pair<String, String>> responseHeaders,
- boolean isRedirect, Runnable responseAction) {
+ Response(byte[] responseData, List<Pair<String, String>> responseHeaders,
+ boolean isRedirect, boolean isNotFound, Runnable responseAction) {
mIsRedirect = isRedirect;
- mResponseData = resposneData;
+ mIsNotFound = isNotFound;
+ mResponseData = responseData;
mResponseHeaders = responseHeaders == null ?
new ArrayList<Pair<String, String>>() : responseHeaders;
mResponseAction = responseAction;
@@ -166,16 +168,18 @@ public class TestWebServer {
private static final int RESPONSE_STATUS_NORMAL = 0;
private static final int RESPONSE_STATUS_MOVED_TEMPORARILY = 1;
+ private static final int RESPONSE_STATUS_NOT_FOUND = 2;
private String setResponseInternal(
String requestPath, byte[] responseData,
List<Pair<String, String>> responseHeaders, Runnable responseAction,
int status) {
final boolean isRedirect = (status == RESPONSE_STATUS_MOVED_TEMPORARILY);
+ final boolean isNotFound = (status == RESPONSE_STATUS_NOT_FOUND);
synchronized (mLock) {
mResponseMap.put(requestPath, new Response(
- responseData, responseHeaders, isRedirect, responseAction));
+ responseData, responseHeaders, isRedirect, isNotFound, responseAction));
mResponseCountMap.put(requestPath, Integer.valueOf(0));
mLastRequestMap.put(requestPath, null);
}
@@ -195,6 +199,19 @@ public class TestWebServer {
}
/**
+ * Sets a 404 (not found) response to be returned when a particular request path is passed in.
+ *
+ * @param requestPath The path to respond to.
+ * @return The full URL including the path that should be requested to get the expected
+ * response.
+ */
+ public String setResponseWithNotFoundStatus(
+ String requestPath) {
+ return setResponseInternal(requestPath, "".getBytes(), null, null,
+ RESPONSE_STATUS_NOT_FOUND);
+ }
+
+ /**
* Sets a response to be returned when a particular request path is passed
* in (with the option to specify additional headers).
*
@@ -392,6 +409,9 @@ public class TestWebServer {
httpResponse = createResponse(HttpStatus.SC_OK);
} else if (response == null) {
httpResponse = createResponse(HttpStatus.SC_NOT_FOUND);
+ } else if (response.mIsNotFound) {
+ httpResponse = createResponse(HttpStatus.SC_NOT_FOUND);
+ servedResponseFor(path, request);
} else if (response.mIsRedirect) {
httpResponse = createResponse(HttpStatus.SC_MOVED_TEMPORARILY);
for (Pair<String, String> header : response.mResponseHeaders) {
« no previous file with comments | « android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698