| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/web_test.h" | 5 #import "ios/web/test/web_test.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 WebTestWithWebController::~WebTestWithWebController() {} | 65 WebTestWithWebController::~WebTestWithWebController() {} |
| 66 | 66 |
| 67 static int s_html_load_count; | 67 static int s_html_load_count; |
| 68 | 68 |
| 69 void WebTestWithWebController::SetUp() { | 69 void WebTestWithWebController::SetUp() { |
| 70 WebTest::SetUp(); | 70 WebTest::SetUp(); |
| 71 web_state_impl_.reset(new WebStateImpl(GetBrowserState())); | 71 web_state_impl_.reset(new WebStateImpl(GetBrowserState())); |
| 72 web_state_impl_->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, | 72 web_state_impl_->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, |
| 73 0); | 73 0); |
| 74 web_state_impl_->SetWebUsageEnabled(true); |
| 74 webController_.reset(web_state_impl_->GetWebController()); | 75 webController_.reset(web_state_impl_->GetWebController()); |
| 75 | 76 |
| 76 [webController_ setWebUsageEnabled:YES]; | |
| 77 // Force generation of child views; necessary for some tests. | 77 // Force generation of child views; necessary for some tests. |
| 78 [webController_ triggerPendingLoad]; | 78 [webController_ triggerPendingLoad]; |
| 79 s_html_load_count = 0; | 79 s_html_load_count = 0; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void WebTestWithWebController::TearDown() { | 82 void WebTestWithWebController::TearDown() { |
| 83 web_state_impl_.reset(); | 83 web_state_impl_.reset(); |
| 84 WebTest::TearDown(); | 84 WebTest::TearDown(); |
| 85 } | 85 } |
| 86 | 86 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void WebTestWithWebController::DidProcessTask( | 197 void WebTestWithWebController::DidProcessTask( |
| 198 const base::PendingTask& pending_task) { | 198 const base::PendingTask& pending_task) { |
| 199 processed_a_task_ = true; | 199 processed_a_task_ = true; |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool WebTestWithWebController::ResetPageIfNavigationStalled( | 202 bool WebTestWithWebController::ResetPageIfNavigationStalled( |
| 203 NSString* load_check) { | 203 NSString* load_check) { |
| 204 NSString* inner_html = EvaluateJavaScriptAsString( | 204 NSString* inner_html = EvaluateJavaScriptAsString( |
| 205 @"(document && document.body && document.body.innerHTML) || 'undefined'"); | 205 @"(document && document.body && document.body.innerHTML) || 'undefined'"); |
| 206 if ([inner_html rangeOfString:load_check].location == NSNotFound) { | 206 if ([inner_html rangeOfString:load_check].location == NSNotFound) { |
| 207 [webController_ setWebUsageEnabled:NO]; | 207 web_state_impl_->SetWebUsageEnabled(false); |
| 208 [webController_ setWebUsageEnabled:YES]; | 208 web_state_impl_->SetWebUsageEnabled(true); |
| 209 [webController_ triggerPendingLoad]; | 209 [webController_ triggerPendingLoad]; |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 return false; | 212 return false; |
| 213 } | 213 } |
| 214 | 214 |
| 215 NSString* WebTestWithWebController::CreateLoadCheck() { | 215 NSString* WebTestWithWebController::CreateLoadCheck() { |
| 216 return [NSString stringWithFormat:@"<p style=\"display: none;\">%d</p>", | 216 return [NSString stringWithFormat:@"<p style=\"display: none;\">%d</p>", |
| 217 s_html_load_count++]; | 217 s_html_load_count++]; |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace web | 220 } // namespace web |
| OLD | NEW |