| 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/chrome_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/testing/wait_util.h" | |
| 14 #import "ios/web_view/test/web_view_test_util.h" | 13 #import "ios/web_view/test/web_view_test_util.h" |
| 15 #include "net/base/url_util.h" | 14 #include "net/base/url_util.h" |
| 16 #include "net/test/embedded_test_server/embedded_test_server.h" | 15 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 #include "net/test/embedded_test_server/http_request.h" | 16 #include "net/test/embedded_test_server/http_request.h" |
| 18 #include "net/test/embedded_test_server/http_response.h" | 17 #include "net/test/embedded_test_server/http_response.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| 21 #if !defined(__has_feature) || !__has_feature(objc_arc) | 20 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 22 #error "This file requires ARC support." | 21 #error "This file requires ARC support." |
| 23 #endif | 22 #endif |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // 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 |
| 127 // response later in TestRequestHandler. | 126 // response later in TestRequestHandler. |
| 128 std::string encoded_title = EncodeQueryParamValue(title); | 127 std::string encoded_title = EncodeQueryParamValue(title); |
| 129 url = net::AppendQueryParameter(url, kPageHtmlTitleParamName, encoded_title); | 128 url = net::AppendQueryParameter(url, kPageHtmlTitleParamName, encoded_title); |
| 130 std::string encoded_body = EncodeQueryParamValue(body); | 129 std::string encoded_body = EncodeQueryParamValue(body); |
| 131 url = net::AppendQueryParameter(url, kPageHtmlBodyParamName, encoded_body); | 130 url = net::AppendQueryParameter(url, kPageHtmlBodyParamName, encoded_body); |
| 132 | 131 |
| 133 return url; | 132 return url; |
| 134 } | 133 } |
| 135 | 134 |
| 136 void ChromeWebViewTest::LoadUrl(CWVWebView* web_view, NSURL* url) { | |
| 137 [web_view loadRequest:[NSURLRequest requestWithURL:url]]; | |
| 138 | |
| 139 WaitForPageLoadCompletion(web_view); | |
| 140 } | |
| 141 | |
| 142 void ChromeWebViewTest::WaitForPageLoadCompletion(CWVWebView* web_view) { | |
| 143 BOOL success = | |
| 144 testing::WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{ | |
| 145 return !web_view.isLoading; | |
| 146 }); | |
| 147 ASSERT_TRUE(success); | |
| 148 } | |
| 149 | |
| 150 } // namespace ios_web_view | 135 } // namespace ios_web_view |
| OLD | NEW |