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

Unified Diff: third_party/WebKit/Source/platform/testing/URLTestHelpers.cpp

Issue 2680723002: Generalize ScopedRegisteredURL as ScoedMockedURL* (Closed)
Patch Set: Created 3 years, 10 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
Index: third_party/WebKit/Source/platform/testing/URLTestHelpers.cpp
diff --git a/third_party/WebKit/Source/platform/testing/URLTestHelpers.cpp b/third_party/WebKit/Source/platform/testing/URLTestHelpers.cpp
index 686f769aa0730fda2d35a7e67bc2a5f061a12db0..b4b0a54137f55d4d449168dd335a561f35928691 100644
--- a/third_party/WebKit/Source/platform/testing/URLTestHelpers.cpp
+++ b/third_party/WebKit/Source/platform/testing/URLTestHelpers.cpp
@@ -62,9 +62,9 @@ WebURL registerMockedURLLoadFromBase(const WebString& baseURL,
return WebURL(url);
}
-void registerMockedURLLoad(const WebURL& fullURL,
- const WebString& filePath,
- const WebString& mimeType) {
+WebURL registerMockedURLLoad(const WebURL& fullURL,
+ const WebString& filePath,
+ const WebString& mimeType) {
WebURLLoadTiming timing;
timing.initialize();
@@ -74,9 +74,10 @@ void registerMockedURLLoad(const WebURL& fullURL,
response.setLoadTiming(timing);
registerMockedURLLoadWithCustomResponse(fullURL, filePath, response);
+ return fullURL;
}
-void registerMockedErrorURLLoad(const WebURL& fullURL) {
+WebURL registerMockedErrorURLLoad(const WebURL& fullURL) {
WebURLLoadTiming timing;
timing.initialize();
@@ -89,14 +90,23 @@ void registerMockedErrorURLLoad(const WebURL& fullURL) {
error.reason = 404;
Platform::current()->getURLLoaderMockFactory()->registerErrorURL(
fullURL, response, error);
+ return fullURL;
}
-void registerMockedURLLoadWithCustomResponse(const WebURL& fullURL,
- const WebString& filePath,
- WebURLResponse response) {
+WebURL registerMockedURLLoadWithCustomResponse(const WebURL& fullURL,
+ const WebString& filePath,
+ WebURLResponse response) {
Platform::current()->getURLLoaderMockFactory()->registerURL(fullURL, response,
filePath);
+ return fullURL;
}
} // namespace URLTestHelpers
+
+ScopedMockedURL::ScopedMockedURL(const WebURL& url) : m_url(url) {}
+
+ScopedMockedURL::~ScopedMockedURL() {
+ Platform::current()->getURLLoaderMockFactory()->unregisterURL(m_url);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698