| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 WebURLLoaderMockFactory_h | 5 #ifndef WebURLLoaderMockFactory_h |
| 6 #define WebURLLoaderMockFactory_h | 6 #define WebURLLoaderMockFactory_h |
| 7 | 7 |
| 8 #include "public/platform/WebCommon.h" | 8 #include "public/platform/WebCommon.h" |
| 9 #include "public/platform/WebData.h" | 9 #include "public/platform/WebData.h" |
| 10 #include "public/platform/WebString.h" | 10 #include "public/platform/WebString.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 virtual ~WebURLLoaderMockFactory() {} | 26 virtual ~WebURLLoaderMockFactory() {} |
| 27 | 27 |
| 28 // Create a WebURLLoader that takes care of mocked requests. | 28 // Create a WebURLLoader that takes care of mocked requests. |
| 29 // Non-mocked request are forwarded to given loader which should not | 29 // Non-mocked request are forwarded to given loader which should not |
| 30 // be nullptr. | 30 // be nullptr. |
| 31 virtual WebURLLoader* createURLLoader(WebURLLoader*) = 0; | 31 virtual WebURLLoader* createURLLoader(WebURLLoader*) = 0; |
| 32 | 32 |
| 33 // Registers a response and the file to be served when the specified URL | 33 // Registers a response and the file to be served when the specified URL |
| 34 // is loaded. If no file is specified then the response content will be empty. | 34 // is loaded. If no file is specified then the response content will be empty. |
| 35 // unregisterURL() should be called for each test entry before registering |
| 36 // another response for the same URL from another test. |
| 35 virtual void registerURL(const WebURL&, | 37 virtual void registerURL(const WebURL&, |
| 36 const WebURLResponse&, | 38 const WebURLResponse&, |
| 37 const WebString& filePath) = 0; | 39 const WebString& filePath) = 0; |
| 38 | 40 |
| 39 // Registers an error to be served when the specified URL is requested. | 41 // Registers an error to be served when the specified URL is requested. |
| 42 // unregisterURL() should be called for each test entry before registering |
| 43 // another response for the same URL from another test. |
| 40 virtual void registerErrorURL(const WebURL&, | 44 virtual void registerErrorURL(const WebURL&, |
| 41 const WebURLResponse&, | 45 const WebURLResponse&, |
| 42 const WebURLError&) = 0; | 46 const WebURLError&) = 0; |
| 43 | 47 |
| 44 // Unregisters URLs so they are no longer mocked. | 48 // Unregisters URLs so they are no longer mocked. |
| 45 virtual void unregisterURL(const WebURL&) = 0; | 49 virtual void unregisterURL(const WebURL&) = 0; |
| 46 virtual void unregisterAllURLs() = 0; | 50 virtual void unregisterAllURLs() = 0; |
| 47 | 51 |
| 48 // Causes all pending asynchronous requests to be served. When this method | 52 // Causes all pending asynchronous requests to be served. When this method |
| 49 // returns all the pending requests have been processed. | 53 // returns all the pending requests have been processed. |
| 50 // Note: this may not work as expected if more requests could be made | 54 // Note: this may not work as expected if more requests could be made |
| 51 // asynchronously from different threads (e.g. when HTML parser thread | 55 // asynchronously from different threads (e.g. when HTML parser thread |
| 52 // is being involved). | 56 // is being involved). |
| 53 // DO NOT USE THIS for Frame loading; always use methods defined in | 57 // DO NOT USE THIS for Frame loading; always use methods defined in |
| 54 // FrameTestHelpers instead. | 58 // FrameTestHelpers instead. |
| 55 virtual void serveAsynchronousRequests() = 0; | 59 virtual void serveAsynchronousRequests() = 0; |
| 56 | 60 |
| 57 // Set a delegate that allows callbacks for all WebURLLoaderClients to be | 61 // Set a delegate that allows callbacks for all WebURLLoaderClients to be |
| 58 // intercepted. | 62 // intercepted. |
| 59 virtual void setLoaderDelegate(WebURLLoaderTestDelegate*) = 0; | 63 virtual void setLoaderDelegate(WebURLLoaderTestDelegate*) = 0; |
| 60 }; | 64 }; |
| 61 | 65 |
| 62 } // namespace blink | 66 } // namespace blink |
| 63 | 67 |
| 64 #endif // WebURLLoaderMockFactory_h | 68 #endif // WebURLLoaderMockFactory_h |
| OLD | NEW |