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 #import "ios/web_view/test/chrome_web_view_test.h" | 5 #import "ios/web_view/test/web_view_test.h" |
6 | 6 |
7 #import <ChromeWebView/ChromeWebView.h> | 7 #import <ChromeWebView/ChromeWebView.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #import "base/memory/ptr_util.h" | 11 #import "base/memory/ptr_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #import "ios/web_view/test/web_view_test_util.h" | 13 #import "ios/web_view/test/web_view_test_util.h" |
14 #include "net/base/url_util.h" | 14 #include "net/base/url_util.h" |
15 #include "net/test/embedded_test_server/embedded_test_server.h" | 15 #include "net/test/embedded_test_server/embedded_test_server.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 return CreatePageHTMLResponse(title, body); | 90 return CreatePageHTMLResponse(title, body); |
91 } | 91 } |
92 return nullptr; | 92 return nullptr; |
93 } | 93 } |
94 | 94 |
95 } // namespace | 95 } // namespace |
96 | 96 |
97 namespace ios_web_view { | 97 namespace ios_web_view { |
98 | 98 |
99 ChromeWebViewTest::ChromeWebViewTest() | 99 WebViewTest::WebViewTest() |
100 : web_view_(test::CreateWebView()), | 100 : web_view_(test::CreateWebView()), |
101 test_server_(base::MakeUnique<net::EmbeddedTestServer>( | 101 test_server_(base::MakeUnique<net::EmbeddedTestServer>( |
102 net::test_server::EmbeddedTestServer::TYPE_HTTP)) { | 102 net::test_server::EmbeddedTestServer::TYPE_HTTP)) { |
103 test_server_->RegisterRequestHandler(base::Bind(&TestRequestHandler)); | 103 test_server_->RegisterRequestHandler(base::Bind(&TestRequestHandler)); |
104 } | 104 } |
105 | 105 |
106 ChromeWebViewTest::~ChromeWebViewTest() = default; | 106 WebViewTest::~WebViewTest() = default; |
107 | 107 |
108 void ChromeWebViewTest::SetUp() { | 108 void WebViewTest::SetUp() { |
109 PlatformTest::SetUp(); | 109 PlatformTest::SetUp(); |
110 ASSERT_TRUE(test_server_->Start()); | 110 ASSERT_TRUE(test_server_->Start()); |
111 } | 111 } |
112 | 112 |
113 GURL ChromeWebViewTest::GetUrlForPageWithTitle(const std::string& title) { | 113 GURL WebViewTest::GetUrlForPageWithTitle(const std::string& title) { |
114 return GetUrlForPageWithTitleAndBody(title, std::string()); | 114 return GetUrlForPageWithTitleAndBody(title, std::string()); |
115 } | 115 } |
116 | 116 |
117 GURL ChromeWebViewTest::GetUrlForPageWithHtmlBody(const std::string& html) { | 117 GURL WebViewTest::GetUrlForPageWithHtmlBody(const std::string& html) { |
118 return GetUrlForPageWithTitleAndBody(std::string(), html); | 118 return GetUrlForPageWithTitleAndBody(std::string(), html); |
119 } | 119 } |
120 | 120 |
121 GURL ChromeWebViewTest::GetUrlForPageWithTitleAndBody(const std::string& title, | 121 GURL WebViewTest::GetUrlForPageWithTitleAndBody(const std::string& title, |
122 const std::string& body) { | 122 const std::string& body) { |
123 GURL url = test_server_->GetURL(kPageHtmlPath); | 123 GURL url = test_server_->GetURL(kPageHtmlPath); |
124 | 124 |
125 // Encode |title| and |body| in url query in order to build the server | 125 // Encode |title| and |body| in url query in order to build the server |
126 // response later in TestRequestHandler. | 126 // response later in TestRequestHandler. |
127 std::string encoded_title = EncodeQueryParamValue(title); | 127 std::string encoded_title = EncodeQueryParamValue(title); |
128 url = net::AppendQueryParameter(url, kPageHtmlTitleParamName, encoded_title); | 128 url = net::AppendQueryParameter(url, kPageHtmlTitleParamName, encoded_title); |
129 std::string encoded_body = EncodeQueryParamValue(body); | 129 std::string encoded_body = EncodeQueryParamValue(body); |
130 url = net::AppendQueryParameter(url, kPageHtmlBodyParamName, encoded_body); | 130 url = net::AppendQueryParameter(url, kPageHtmlBodyParamName, encoded_body); |
131 | 131 |
132 return url; | 132 return url; |
133 } | 133 } |
134 | 134 |
135 } // namespace ios_web_view | 135 } // namespace ios_web_view |
OLD | NEW |