Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ScopedMockedURL_h | |
| 6 #define ScopedMockedURL_h | |
| 7 | |
| 8 #include "public/platform/WebString.h" | |
| 9 #include "public/platform/WebURL.h" | |
| 10 #include "public/platform/WebURLResponse.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 namespace testing { | |
| 15 | |
| 16 // Convenience classes that register a mocked URL on construction, and | |
| 17 // unregisters it on destruction. This allows for a test to use constructs like | |
|
kinuko
2017/02/08 08:21:48
nit: unregisters -> unregister
allows for a test
Takashi Toyoshima
2017/02/08 10:33:14
As discussed offline, this second sentence looks t
| |
| 18 // ASSERT_TRUE() without needing to worry abount unregistering the mocked URL | |
|
kinuko
2017/02/08 08:21:48
abount -> about
Takashi Toyoshima
2017/02/08 10:33:13
Done.
| |
| 19 // load to avoid putting other tests into inconsistent states in case the | |
| 20 // assertion fails. | |
| 21 class ScopedMockedURL { | |
| 22 public: | |
| 23 explicit ScopedMockedURL(const WebURL&); | |
|
Takashi Toyoshima
2017/02/08 06:47:20
We could have multiple constructor instead of havi
| |
| 24 virtual ~ScopedMockedURL(); | |
| 25 | |
| 26 private: | |
| 27 WebURL m_url; | |
| 28 }; | |
| 29 | |
| 30 class ScopedMockedURLLoadFromBase : ScopedMockedURL { | |
| 31 public: | |
| 32 ScopedMockedURLLoadFromBase( | |
| 33 const WebString& baseURL, | |
| 34 const WebString& basePath, | |
| 35 const WebString& fileName, | |
| 36 const WebString& mimeType = WebString::fromUTF8("text/html")); | |
| 37 ~ScopedMockedURLLoadFromBase() override = default; | |
| 38 }; | |
| 39 | |
| 40 class ScopedMockedURLLoad : ScopedMockedURL { | |
| 41 public: | |
| 42 ScopedMockedURLLoad( | |
| 43 const WebURL& fullURL, | |
| 44 const WebString& filePath, | |
| 45 const WebString& mimeType = WebString::fromUTF8("text/html")); | |
| 46 ~ScopedMockedURLLoad() override = default; | |
| 47 }; | |
| 48 | |
| 49 class ScopedMockedURLLoadWithCustomResponse : ScopedMockedURL { | |
| 50 public: | |
| 51 ScopedMockedURLLoadWithCustomResponse(const WebURL& fullURL, | |
| 52 const WebString& filePath, | |
| 53 WebURLResponse); | |
| 54 ~ScopedMockedURLLoadWithCustomResponse() override = default; | |
| 55 }; | |
| 56 | |
| 57 class ScopedMockedErrorURLLoad : ScopedMockedURL { | |
| 58 public: | |
| 59 ScopedMockedErrorURLLoad(const WebURL& fullURL); | |
| 60 ~ScopedMockedErrorURLLoad() override = default; | |
| 61 }; | |
|
kinuko
2017/02/08 08:21:48
Could we avoid defining unused classes yet? We ca
Takashi Toyoshima
2017/02/08 10:33:13
Done.
| |
| 62 | |
| 63 } // namespace testing | |
| 64 | |
| 65 } // namespace blink | |
| 66 | |
| 67 #endif | |
| OLD | NEW |