| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 IOS_WEB_VIEW_TEST_CHROME_WEB_VIEW_TEST_H_ | 5 #ifndef IOS_WEB_VIEW_TEST_CHROME_WEB_VIEW_TEST_H_ |
| 6 #define IOS_WEB_VIEW_TEST_CHROME_WEB_VIEW_TEST_H_ | 6 #define IOS_WEB_VIEW_TEST_CHROME_WEB_VIEW_TEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 namespace test_server { | 14 namespace test_server { |
| 15 class EmbeddedTestServer; | 15 class EmbeddedTestServer; |
| 16 } // namespace test_server | 16 } // namespace test_server |
| 17 } // namespace net | 17 } // namespace net |
| 18 | 18 |
| 19 @class CWVWebView; | 19 @class CWVWebView; |
| 20 class GURL; | 20 class GURL; |
| 21 @class NSURL; | 21 @class NSURL; |
| 22 | 22 |
| 23 namespace ios_web_view { | 23 namespace ios_web_view { |
| 24 | 24 |
| 25 // A test fixture for testing CWVWebView. A test server is also created to | 25 // A test fixture for testing CWVWebView. A test server is also created to |
| 26 // support loading content. The server supports the urls defined by | 26 // support loading content. The server supports the urls returned by the GetUrl* |
| 27 // RegisterDefaultHandlers in net/test/embedded_test_server/default_handlers.h | 27 // methods below. |
| 28 // as well as urls returned by the GetUrl* methods below. | |
| 29 class ChromeWebViewTest : public PlatformTest { | 28 class ChromeWebViewTest : public PlatformTest { |
| 30 protected: | 29 protected: |
| 31 ChromeWebViewTest(); | 30 ChromeWebViewTest(); |
| 32 ~ChromeWebViewTest() override; | 31 ~ChromeWebViewTest() override; |
| 33 | 32 |
| 34 // Returns URL to an html page with title set to |title|. | 33 // Returns URL to an html page with title set to |title|. |
| 35 GURL GetUrlForPageWithTitle(const std::string& title); | 34 GURL GetUrlForPageWithTitle(const std::string& title); |
| 36 | 35 |
| 37 // Returns URL to an html page with |html| within page's body tags. | 36 // Returns URL to an html page with |html| within page's body tags. |
| 38 GURL GetUrlForPageWithHTMLBody(const std::string& html); | 37 GURL GetUrlForPageWithHtmlBody(const std::string& html); |
| 38 |
| 39 // Returns URL to an html page with title set to |title| and |body| within |
| 40 // the page's body tags. |
| 41 GURL GetUrlForPageWithTitleAndBody(const std::string& title, |
| 42 const std::string& body); |
| 39 | 43 |
| 40 // Loads |URL| in |web_view| and waits until the load completes. Asserts if | 44 // Loads |URL| in |web_view| and waits until the load completes. Asserts if |
| 41 // loading does not complete. | 45 // loading does not complete. |
| 42 void LoadUrl(CWVWebView* web_view, NSURL* url); | 46 void LoadUrl(CWVWebView* web_view, NSURL* url); |
| 43 | 47 |
| 44 // Waits until |web_view| stops loading. Asserts if loading does not complete. | 48 // Waits until |web_view| stops loading. Asserts if loading does not complete. |
| 45 void WaitForPageLoadCompletion(CWVWebView* web_view); | 49 void WaitForPageLoadCompletion(CWVWebView* web_view); |
| 46 | 50 |
| 47 // PlatformTest methods. | 51 // PlatformTest methods. |
| 48 void SetUp() override; | 52 void SetUp() override; |
| 49 | 53 |
| 50 // Embedded server for handling responses to urls as registered by | 54 // Embedded server for handling requests sent to the URLs returned by the |
| 51 // net/test/embedded_test_server/default_handlers.h and the GetURLForPageWith* | 55 // GetURL* methods. |
| 52 // methods. | |
| 53 std::unique_ptr<net::test_server::EmbeddedTestServer> test_server_; | 56 std::unique_ptr<net::test_server::EmbeddedTestServer> test_server_; |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 } // namespace ios_web_view | 59 } // namespace ios_web_view |
| 57 | 60 |
| 58 #endif // IOS_WEB_VIEW_TEST_CHROME_WEB_VIEW_TEST_H_ | 61 #endif // IOS_WEB_VIEW_TEST_CHROME_WEB_VIEW_TEST_H_ |
| OLD | NEW |