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

Side by Side Diff: webkit/support/weburl_loader_mock_factory.h

Issue 10821019: Add support for mocking failed loads to WebURLLoaderMock. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « webkit/support/weburl_loader_mock.cc ('k') | webkit/support/weburl_loader_mock_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ 5 #ifndef WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_
6 #define WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ 6 #define WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 25 matching lines...) Expand all
36 // NULL. 36 // NULL.
37 virtual WebKit::WebURLLoader* CreateURLLoader( 37 virtual WebKit::WebURLLoader* CreateURLLoader(
38 WebKit::WebURLLoader* default_loader); 38 WebKit::WebURLLoader* default_loader);
39 39
40 // Registers a response and the contents to be served when the specified URL 40 // Registers a response and the contents to be served when the specified URL
41 // is loaded. 41 // is loaded.
42 void RegisterURL(const WebKit::WebURL& url, 42 void RegisterURL(const WebKit::WebURL& url,
43 const WebKit::WebURLResponse& response, 43 const WebKit::WebURLResponse& response,
44 const WebKit::WebString& filePath); 44 const WebKit::WebString& filePath);
45 45
46 // Registers an error to be served when the specified URL is requested.
47 void RegisterErrorURL(const WebKit::WebURL& url,
48 const WebKit::WebURLResponse& response,
49 const WebKit::WebURLError& error);
50
46 // Unregisters |url| so it will no longer be mocked. 51 // Unregisters |url| so it will no longer be mocked.
47 void UnregisterURL(const WebKit::WebURL& url); 52 void UnregisterURL(const WebKit::WebURL& url);
48 53
49 // Unregister all URLs so no URL will be mocked anymore. 54 // Unregister all URLs so no URL will be mocked anymore.
50 void UnregisterAllURLs(); 55 void UnregisterAllURLs();
51 56
52 // Serves all the pending asynchronous requests. 57 // Serves all the pending asynchronous requests.
53 void ServeAsynchronousRequests(); 58 void ServeAsynchronousRequests();
54 59
55 // Returns the last request handled by |ServeAsynchronousRequests()|. 60 // Returns the last request handled by |ServeAsynchronousRequests()|.
(...skipping 27 matching lines...) Expand all
83 bool IsPending(WebURLLoaderMock* loader); 88 bool IsPending(WebURLLoaderMock* loader);
84 89
85 // Reads |m_filePath| and puts its content in |data|. 90 // Reads |m_filePath| and puts its content in |data|.
86 // Returns true if it successfully read the file. 91 // Returns true if it successfully read the file.
87 static bool ReadFile(const FilePath& file_path, WebKit::WebData* data); 92 static bool ReadFile(const FilePath& file_path, WebKit::WebData* data);
88 93
89 // The loaders that have not being served data yet. 94 // The loaders that have not being served data yet.
90 typedef std::map<WebURLLoaderMock*, WebKit::WebURLRequest> LoaderToRequestMap; 95 typedef std::map<WebURLLoaderMock*, WebKit::WebURLRequest> LoaderToRequestMap;
91 LoaderToRequestMap pending_loaders_; 96 LoaderToRequestMap pending_loaders_;
92 97
98 typedef std::map<WebKit::WebURL, WebKit::WebURLError> URLToErrorMap;
99 URLToErrorMap url_to_error_info_;
100
93 // Table of the registered URLs and the responses that they should receive. 101 // Table of the registered URLs and the responses that they should receive.
94 typedef std::map<WebKit::WebURL, ResponseInfo> URLToResponseMap; 102 typedef std::map<WebKit::WebURL, ResponseInfo> URLToResponseMap;
95 URLToResponseMap url_to_reponse_info_; 103 URLToResponseMap url_to_reponse_info_;
96 104
97 WebKit::WebURLRequest last_handled_asynchronous_request_; 105 WebKit::WebURLRequest last_handled_asynchronous_request_;
98 106
99 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactory); 107 DISALLOW_COPY_AND_ASSIGN(WebURLLoaderMockFactory);
100 }; 108 };
101 109
102 #endif // WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_ 110 #endif // WEBKIT_SUPPORT_WEBURL_LOADER_MOCK_FACTORY_H_
103 111
OLDNEW
« no previous file with comments | « webkit/support/weburl_loader_mock.cc ('k') | webkit/support/weburl_loader_mock_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698