| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ios/web/web_state/web_state_impl.h" | 5 #include "ios/web/web_state/web_state_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/base64.h" | 11 #include "base/base64.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/mac/bind_objc_block.h" | 14 #include "base/mac/bind_objc_block.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/test/ios/wait_util.h" | 16 #include "base/test/ios/wait_util.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "ios/web/public/load_committed_details.h" | 18 #include "ios/web/public/load_committed_details.h" |
| 19 #include "ios/web/public/test/test_browser_state.h" | 19 #include "ios/web/public/test/test_browser_state.h" |
| 20 #include "ios/web/public/test/web_test.h" |
| 20 #include "ios/web/public/web_state/global_web_state_observer.h" | 21 #include "ios/web/public/web_state/global_web_state_observer.h" |
| 21 #include "ios/web/public/web_state/web_state_delegate.h" | 22 #include "ios/web/public/web_state/web_state_delegate.h" |
| 22 #include "ios/web/public/web_state/web_state_observer.h" | 23 #include "ios/web/public/web_state/web_state_observer.h" |
| 23 #include "ios/web/public/web_state/web_state_policy_decider.h" | 24 #include "ios/web/public/web_state/web_state_policy_decider.h" |
| 24 #import "ios/web/test/web_test.h" | |
| 25 #include "ios/web/web_state/global_web_state_event_tracker.h" | 25 #include "ios/web/web_state/global_web_state_event_tracker.h" |
| 26 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 26 #include "net/http/http_response_headers.h" | 27 #include "net/http/http_response_headers.h" |
| 27 #include "net/http/http_util.h" | 28 #include "net/http/http_util.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 #include "testing/gtest_mac.h" | 31 #include "testing/gtest_mac.h" |
| 31 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 32 | 33 |
| 33 using testing::_; | 34 using testing::_; |
| 34 using testing::Assign; | 35 using testing::Assign; |
| 35 using testing::AtMost; | 36 using testing::AtMost; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 web_state_->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); | 262 web_state_->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); |
| 262 | 263 |
| 263 // Use data: url for loading html page. | 264 // Use data: url for loading html page. |
| 264 std::string encoded_html; | 265 std::string encoded_html; |
| 265 base::Base64Encode(html, &encoded_html); | 266 base::Base64Encode(html, &encoded_html); |
| 266 GURL url("data:text/html;charset=utf8;base64," + encoded_html); | 267 GURL url("data:text/html;charset=utf8;base64," + encoded_html); |
| 267 web::NavigationManager::WebLoadParams params(url); | 268 web::NavigationManager::WebLoadParams params(url); |
| 268 web_state_->GetNavigationManager()->LoadURLWithParams(params); | 269 web_state_->GetNavigationManager()->LoadURLWithParams(params); |
| 269 | 270 |
| 270 // Trigger the load. | 271 // Trigger the load. |
| 271 web_state_->GetWebController().webUsageEnabled = YES; | 272 web_state_->SetWebUsageEnabled(true); |
| 272 web_state_->GetView(); | 273 web_state_->GetView(); |
| 273 | 274 |
| 274 // Wait until load is completed. | 275 // Wait until load is completed. |
| 275 EXPECT_TRUE(web_state_->IsLoading()); | 276 EXPECT_TRUE(web_state_->IsLoading()); |
| 276 base::test::ios::WaitUntilCondition(^bool() { | 277 base::test::ios::WaitUntilCondition(^bool() { |
| 277 return !web_state_->IsLoading(); | 278 return !web_state_->IsLoading(); |
| 278 }); | 279 }); |
| 279 } | 280 } |
| 280 | 281 |
| 281 web::TestBrowserState browser_state_; | 282 web::TestBrowserState browser_state_; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 "</script>"); | 625 "</script>"); |
| 625 | 626 |
| 626 base::test::ios::WaitUntilCondition(^{ | 627 base::test::ios::WaitUntilCondition(^{ |
| 627 return message_received; | 628 return message_received; |
| 628 }); | 629 }); |
| 629 web_state_->RemoveScriptCommandCallback("test"); | 630 web_state_->RemoveScriptCommandCallback("test"); |
| 630 } | 631 } |
| 631 | 632 |
| 632 } // namespace | 633 } // namespace |
| 633 } // namespace web | 634 } // namespace web |
| OLD | NEW |