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

Side by Side Diff: third_party/WebKit/Source/platform/testing/URLTestHelpers.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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef URLTestHelpers_h 31 #ifndef URLTestHelpers_h
32 #define URLTestHelpers_h 32 #define URLTestHelpers_h
33 33
34 #include "platform/weborigin/KURL.h" 34 #include "platform/weborigin/KURL.h"
35 #include "public/platform/WebString.h" 35 #include "public/platform/WebString.h"
36 #include "public/platform/WebURL.h" 36 #include "public/platform/WebURL.h"
37 #include "public/platform/WebURLResponse.h"
37 38
38 namespace blink { 39 namespace blink {
39
40 class WebURLResponse;
41
42 namespace URLTestHelpers { 40 namespace URLTestHelpers {
43 41
44 inline blink::KURL toKURL(const std::string& url) { 42 inline blink::KURL toKURL(const std::string& url) {
45 WTF::String wtfString(url.c_str()); 43 WTF::String wtfString(url.c_str());
46 return blink::KURL(blink::ParsedURLString, wtfString); 44 return blink::KURL(blink::ParsedURLString, wtfString);
47 } 45 }
48 46
47 // Note: Please use one of ScopedMockedURL* class for new code as you can as
48 // possible.
kinuko 2017/02/08 08:21:48 I think we could say "Avoid directly using these
Takashi Toyoshima 2017/02/08 10:33:14 Done.
49 //
49 // Helper functions for mock URLs. These functions set up the desired URL and 50 // Helper functions for mock URLs. These functions set up the desired URL and
50 // mimeType, with a 200 OK return status. 51 // mimeType, with a 200 OK return status.
51 // webTestDataPath() or platformTestDataPath() in UnitTestHelpers can be used to 52 // webTestDataPath() or platformTestDataPath() in UnitTestHelpers can be used to
52 // get the appropriate |basePath| and |filePath| for test data directories. 53 // get the appropriate |basePath| and |filePath| for test data directories.
53 // - For the mock URL, fullURL == baseURL + fileName. 54 // - For the mock URL, fullURL == baseURL + fileName.
54 // - For the file path, filePath == basePath + ("/" +) fileName. 55 // - For the file path, filePath == basePath + ("/" +) fileName.
55 56
56 // Registers from a base URL and a base file path, and returns a calculated full 57 // Registers from a base URL and a base file path, and returns a calculated full
57 // URL. 58 // URL.
58 WebURL registerMockedURLLoadFromBase( 59 WebURL registerMockedURLLoadFromBase(
59 const WebString& baseURL, 60 const WebString& baseURL,
60 const WebString& basePath, 61 const WebString& basePath,
61 const WebString& fileName, 62 const WebString& fileName,
62 const WebString& mimeType = WebString::fromUTF8("text/html")); 63 const WebString& mimeType = WebString::fromUTF8("text/html"));
63 64
64 // Registers from a full URL and a full file path. 65 // Registers from a full URL and a full file path.
65 void registerMockedURLLoad( 66 void registerMockedURLLoad(
66 const WebURL& fullURL, 67 const WebURL& fullURL,
67 const WebString& filePath, 68 const WebString& filePath,
68 const WebString& mimeType = WebString::fromUTF8("text/html")); 69 const WebString& mimeType = WebString::fromUTF8("text/html"));
70
71 // Registers with a custom response.
69 void registerMockedURLLoadWithCustomResponse(const WebURL& fullURL, 72 void registerMockedURLLoadWithCustomResponse(const WebURL& fullURL,
70 const WebString& filePath, 73 const WebString& filePath,
71 WebURLResponse); 74 WebURLResponse);
72 75
73 // Registers a mock URL that returns a 404 error. 76 // Registers a mock URL that returns a 404 error.
74 void registerMockedErrorURLLoad(const WebURL& fullURL); 77 void registerMockedErrorURLLoad(const WebURL& fullURL);
75 78
76 } // namespace URLTestHelpers 79 } // namespace URLTestHelpers
77 } // namespace blink 80 } // namespace blink
78 81
79 #endif 82 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698