| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/public/test/web_test_with_web_state.h" | 5 #import "ios/web/public/test/web_test_with_web_state.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #import "base/test/ios/wait_util.h" | 9 #import "base/test/ios/wait_util.h" |
| 10 #include "ios/web/public/web_state/url_verification_constants.h" | 10 #include "ios/web/public/web_state/url_verification_constants.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 processed_a_task_ = false; | 106 processed_a_task_ = false; |
| 107 base::RunLoop().RunUntilIdle(); | 107 base::RunLoop().RunUntilIdle(); |
| 108 if (processed_a_task_) // Set in TaskObserver method. | 108 if (processed_a_task_) // Set in TaskObserver method. |
| 109 activitySeen = true; | 109 activitySeen = true; |
| 110 | 110 |
| 111 } while (activitySeen); | 111 } while (activitySeen); |
| 112 messageLoop->RemoveTaskObserver(this); | 112 messageLoop->RemoveTaskObserver(this); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WebTestWithWebState::WaitForCondition(ConditionBlock condition) { | 115 void WebTestWithWebState::WaitForCondition(ConditionBlock condition) { |
| 116 base::MessageLoop* messageLoop = base::MessageLoop::current(); | 116 base::test::ios::WaitUntilCondition(condition, true, |
| 117 DCHECK(messageLoop); | |
| 118 base::test::ios::WaitUntilCondition(condition, messageLoop, | |
| 119 base::TimeDelta::FromSeconds(10)); | 117 base::TimeDelta::FromSeconds(10)); |
| 120 } | 118 } |
| 121 | 119 |
| 122 id WebTestWithWebState::ExecuteJavaScript(NSString* script) { | 120 id WebTestWithWebState::ExecuteJavaScript(NSString* script) { |
| 123 __block base::scoped_nsprotocol<id> executionResult; | 121 __block base::scoped_nsprotocol<id> executionResult; |
| 124 __block bool executionCompleted = false; | 122 __block bool executionCompleted = false; |
| 125 [GetWebController(web_state()) | 123 [GetWebController(web_state()) |
| 126 executeJavaScript:script | 124 executeJavaScript:script |
| 127 completionHandler:^(id result, NSError* error) { | 125 completionHandler:^(id result, NSError* error) { |
| 128 executionResult.reset([result copy]); | 126 executionResult.reset([result copy]); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 149 | 147 |
| 150 void WebTestWithWebState::WillProcessTask(const base::PendingTask&) { | 148 void WebTestWithWebState::WillProcessTask(const base::PendingTask&) { |
| 151 // Nothing to do. | 149 // Nothing to do. |
| 152 } | 150 } |
| 153 | 151 |
| 154 void WebTestWithWebState::DidProcessTask(const base::PendingTask&) { | 152 void WebTestWithWebState::DidProcessTask(const base::PendingTask&) { |
| 155 processed_a_task_ = true; | 153 processed_a_task_ = true; |
| 156 } | 154 } |
| 157 | 155 |
| 158 } // namespace web | 156 } // namespace web |
| OLD | NEW |