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

Side by Side 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 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 // Registers from a base URL and a base file path, and returns a calculated full 56 // Registers from a base URL and a base file path, and returns a calculated full
57 // URL. 57 // URL.
58 WebURL registerMockedURLLoadFromBase( 58 WebURL registerMockedURLLoadFromBase(
59 const WebString& baseURL, 59 const WebString& baseURL,
60 const WebString& basePath, 60 const WebString& basePath,
61 const WebString& fileName, 61 const WebString& fileName,
62 const WebString& mimeType = WebString::fromUTF8("text/html")); 62 const WebString& mimeType = WebString::fromUTF8("text/html"));
63 63
64 // Registers from a full URL and a full file path. 64 // Registers from a full URL and a full file path.
65 void registerMockedURLLoad( 65 WebURL registerMockedURLLoad(
66 const WebURL& fullURL, 66 const WebURL& fullURL,
67 const WebString& filePath, 67 const WebString& filePath,
68 const WebString& mimeType = WebString::fromUTF8("text/html")); 68 const WebString& mimeType = WebString::fromUTF8("text/html"));
69 void registerMockedURLLoadWithCustomResponse(const WebURL& fullURL, 69 WebURL registerMockedURLLoadWithCustomResponse(const WebURL& fullURL,
70 const WebString& filePath, 70 const WebString& filePath,
71 WebURLResponse); 71 WebURLResponse);
72 72
73 // Registers a mock URL that returns a 404 error. 73 // Registers a mock URL that returns a 404 error.
74 void registerMockedErrorURLLoad(const WebURL& fullURL); 74 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.
75 75
76 } // namespace URLTestHelpers 76 } // namespace URLTestHelpers
77
78 // Convenience class that takes a mocked URL and unregisters it on destruction.
79 // This allows for a test to use constructs like ASSERT_TRUE() without needing
80 // to worry abount unregistering the mocked URL load to avoid putting other
81 // tests into inconsistent states in case the assertion fails.
82 class ScopedMockedURL {
83 public:
84 explicit ScopedMockedURL(const WebURL&);
85 ~ScopedMockedURL();
86
87 private:
88 WebURL m_url;
89 };
90
77 } // namespace blink 91 } // namespace blink
78 92
79 #endif 93 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698