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

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

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.h
diff --git a/third_party/WebKit/Source/platform/testing/URLTestHelpers.h b/third_party/WebKit/Source/platform/testing/URLTestHelpers.h
index 6cb59d353972b5338307f2817da604118c3add9a..7cb2e494d33db138ea00849d8c2d5e4a22557f98 100644
--- a/third_party/WebKit/Source/platform/testing/URLTestHelpers.h
+++ b/third_party/WebKit/Source/platform/testing/URLTestHelpers.h
@@ -62,18 +62,32 @@ WebURL registerMockedURLLoadFromBase(
const WebString& mimeType = WebString::fromUTF8("text/html"));
// Registers from a full URL and a full file path.
-void registerMockedURLLoad(
+WebURL registerMockedURLLoad(
const WebURL& fullURL,
const WebString& filePath,
const WebString& mimeType = WebString::fromUTF8("text/html"));
-void registerMockedURLLoadWithCustomResponse(const WebURL& fullURL,
- const WebString& filePath,
- WebURLResponse);
+WebURL registerMockedURLLoadWithCustomResponse(const WebURL& fullURL,
+ const WebString& filePath,
+ WebURLResponse);
// Registers a mock URL that returns a 404 error.
-void registerMockedErrorURLLoad(const WebURL& fullURL);
+WebURL registerMockedErrorURLLoad(const WebURL& fullURL);
kinuko 2017/02/07 11:17:38 To me making these methods return the given fullUR
Takashi Toyoshima 2017/02/08 06:47:20 Done.
} // namespace URLTestHelpers
+
+// Convenience class that takes a mocked URL and unregisters it on destruction.
+// This allows for a test to use constructs like ASSERT_TRUE() without needing
+// to worry abount unregistering the mocked URL load to avoid putting other
+// tests into inconsistent states in case the assertion fails.
+class ScopedMockedURL {
+ public:
+ explicit ScopedMockedURL(const WebURL&);
+ ~ScopedMockedURL();
+
+ private:
+ WebURL m_url;
+};
+
} // namespace blink
#endif

Powered by Google App Engine
This is Rietveld 408576698