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

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

Issue 2680723002: Generalize ScopedRegisteredURL as ScoedMockedURL* (Closed)
Patch Set: append missed files 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/ScopedMockedURL.h
diff --git a/third_party/WebKit/Source/platform/testing/ScopedMockedURL.h b/third_party/WebKit/Source/platform/testing/ScopedMockedURL.h
new file mode 100644
index 0000000000000000000000000000000000000000..eadcbff9af3f2d327a93d112c306fb688f07f672
--- /dev/null
+++ b/third_party/WebKit/Source/platform/testing/ScopedMockedURL.h
@@ -0,0 +1,67 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ScopedMockedURL_h
+#define ScopedMockedURL_h
+
+#include "public/platform/WebString.h"
+#include "public/platform/WebURL.h"
+#include "public/platform/WebURLResponse.h"
+
+namespace blink {
+
+namespace testing {
+
+// Convenience classes that register a mocked URL on construction, and
+// unregisters it on destruction. This allows for a test to use constructs like
kinuko 2017/02/08 08:21:48 nit: unregisters -> unregister allows for a test
Takashi Toyoshima 2017/02/08 10:33:14 As discussed offline, this second sentence looks t
+// ASSERT_TRUE() without needing to worry abount unregistering the mocked URL
kinuko 2017/02/08 08:21:48 abount -> about
Takashi Toyoshima 2017/02/08 10:33:13 Done.
+// load to avoid putting other tests into inconsistent states in case the
+// assertion fails.
+class ScopedMockedURL {
+ public:
+ explicit ScopedMockedURL(const WebURL&);
Takashi Toyoshima 2017/02/08 06:47:20 We could have multiple constructor instead of havi
+ virtual ~ScopedMockedURL();
+
+ private:
+ WebURL m_url;
+};
+
+class ScopedMockedURLLoadFromBase : ScopedMockedURL {
+ public:
+ ScopedMockedURLLoadFromBase(
+ const WebString& baseURL,
+ const WebString& basePath,
+ const WebString& fileName,
+ const WebString& mimeType = WebString::fromUTF8("text/html"));
+ ~ScopedMockedURLLoadFromBase() override = default;
+};
+
+class ScopedMockedURLLoad : ScopedMockedURL {
+ public:
+ ScopedMockedURLLoad(
+ const WebURL& fullURL,
+ const WebString& filePath,
+ const WebString& mimeType = WebString::fromUTF8("text/html"));
+ ~ScopedMockedURLLoad() override = default;
+};
+
+class ScopedMockedURLLoadWithCustomResponse : ScopedMockedURL {
+ public:
+ ScopedMockedURLLoadWithCustomResponse(const WebURL& fullURL,
+ const WebString& filePath,
+ WebURLResponse);
+ ~ScopedMockedURLLoadWithCustomResponse() override = default;
+};
+
+class ScopedMockedErrorURLLoad : ScopedMockedURL {
+ public:
+ ScopedMockedErrorURLLoad(const WebURL& fullURL);
+ ~ScopedMockedErrorURLLoad() override = default;
+};
kinuko 2017/02/08 08:21:48 Could we avoid defining unused classes yet? We ca
Takashi Toyoshima 2017/02/08 10:33:13 Done.
+
+} // namespace testing
+
+} // namespace blink
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698