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

Side by Side Diff: third_party/WebKit/Source/platform/testing/URLTestHelpers.h

Issue 2654933003: platform/testing/{URL|Unit}TestHelpers improvements (Closed)
Patch Set: header changes 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 37
37 namespace blink { 38 namespace blink {
38 39
39 class WebURL;
40 class WebURLResponse; 40 class WebURLResponse;
41 41
42 namespace URLTestHelpers { 42 namespace URLTestHelpers {
43 43
44 inline blink::KURL toKURL(const std::string& url) { 44 inline blink::KURL toKURL(const std::string& url) {
45 WTF::String wtfString(url.c_str()); 45 WTF::String wtfString(url.c_str());
46 return blink::KURL(blink::ParsedURLString, wtfString); 46 return blink::KURL(blink::ParsedURLString, wtfString);
47 } 47 }
48 48
49 // Helper functions for mock URLs. These functions set up the desired URL and 49 // Helper functions for mock URLs. These functions set up the desired URL and
50 // mimeType, with a 200 OK return status. 50 // mimeType, with a 200 OK return status.
51 // For the mock URL, fullURL == baseURL + fileName. 51 // webTestDataPath() or platformTestDataPath() in UnitTestHelpers can be used to
52 // For the actual file path: 52 // get the appropriate |basePath| and |filePath| for test data directories.
53 // <WebKit root directory> + relativeBaseDirectory + fileName, 53 // - For the mock URL, fullURL == baseURL + fileName.
54 // or, if the relative base directory is not specified: 54 // - For the file path, filePath == basePath + ("/" +) fileName.
55 // <WebKit root directory> + fileName. 55
56 // 56 // Registers from a base URL and a base file path, and returns a calculated full
57 void registerMockedURLFromBaseURL( 57 // URL.
58 WebURL registerMockedURLLoadFromBase(
58 const WebString& baseURL, 59 const WebString& baseURL,
60 const WebString& basePath,
59 const WebString& fileName, 61 const WebString& fileName,
60 const WebString& mimeType = WebString::fromUTF8("text/html")); 62 const WebString& mimeType = WebString::fromUTF8("text/html"));
63
64 // Registers from a full URL and a full file path.
61 void registerMockedURLLoad( 65 void registerMockedURLLoad(
62 const WebURL& fullURL, 66 const WebURL& fullURL,
63 const WebString& fileName, 67 const WebString& filePath,
64 const WebString& mimeType = WebString::fromUTF8("text/html")); 68 const WebString& mimeType = WebString::fromUTF8("text/html"));
65 void registerMockedURLLoad(const WebURL& fullURL, 69 void registerMockedURLLoadWithCustomResponse(const WebURL& fullURL,
66 const WebString& fileName, 70 const WebString& filePath,
67 const WebString& relativeBaseDirectory, 71 WebURLResponse);
68 const WebString& mimeType); 72
69 void registerMockedURLLoadWithCustomResponse( 73 // Registers a mock URL that returns a 404 error.
70 const WebURL& fullURL,
71 const WebString& fileName,
72 const WebString& relativeBaseDirectory,
73 WebURLResponse);
74 void registerMockedErrorURLLoad(const WebURL& fullURL); 74 void registerMockedErrorURLLoad(const WebURL& fullURL);
75 75
76 } // namespace URLTestHelpers 76 } // namespace URLTestHelpers
77 } // namespace blink 77 } // namespace blink
78 78
79 #endif 79 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698