| 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/chrome/test/earl_grey/chrome_earl_grey.h" | 5 #import "ios/chrome/test/earl_grey/chrome_earl_grey.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
| 9 | 9 |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 13 #import "base/test/ios/wait_util.h" | 13 #import "base/test/ios/wait_util.h" |
| 14 #include "components/strings/grit/components_strings.h" | 14 #include "components/strings/grit/components_strings.h" |
| 15 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 15 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 16 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 16 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 17 #import "ios/chrome/browser/ui/static_content/static_html_view_controller.h" | 17 #import "ios/chrome/browser/ui/static_content/static_html_view_controller.h" |
| 18 #import "ios/chrome/test/app/chrome_test_util.h" | 18 #import "ios/chrome/test/app/chrome_test_util.h" |
| 19 #import "ios/chrome/test/app/history_test_util.h" | 19 #import "ios/chrome/test/app/history_test_util.h" |
| 20 #include "ios/chrome/test/app/navigation_test_util.h" | 20 #include "ios/chrome/test/app/navigation_test_util.h" |
| 21 #import "ios/chrome/test/app/static_html_view_test_util.h" | 21 #import "ios/chrome/test/app/static_html_view_test_util.h" |
| 22 #import "ios/testing/wait_util.h" | 22 #import "ios/testing/wait_util.h" |
| 23 #import "ios/web/public/test/earl_grey/js_test_util.h" | 23 #import "ios/web/public/test/earl_grey/js_test_util.h" |
| 24 #import "ios/web/public/test/web_view_content_test_util.h" |
| 24 #import "ios/web/public/test/web_view_interaction_test_util.h" | 25 #import "ios/web/public/test/web_view_interaction_test_util.h" |
| 25 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" | 26 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" |
| 26 #import "ios/web/public/web_state/web_state.h" | 27 #import "ios/web/public/web_state/web_state.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
| 28 | 29 |
| 29 #if !defined(__has_feature) || !__has_feature(objc_arc) | 30 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 30 #error "This file requires ARC support." | 31 #error "This file requires ARC support." |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 namespace chrome_test_util { | 34 namespace chrome_test_util { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 conditionWithName:@"Wait for absence of static HTML text." | 178 conditionWithName:@"Wait for absence of static HTML text." |
| 178 block:^BOOL { | 179 block:^BOOL { |
| 179 return !chrome_test_util::StaticHtmlViewContainingText( | 180 return !chrome_test_util::StaticHtmlViewContainingText( |
| 180 chrome_test_util::GetCurrentWebState(), | 181 chrome_test_util::GetCurrentWebState(), |
| 181 base::SysNSStringToUTF8(text)); | 182 base::SysNSStringToUTF8(text)); |
| 182 }]; | 183 }]; |
| 183 GREYAssert([condition waitWithTimeout:testing::kWaitForUIElementTimeout], | 184 GREYAssert([condition waitWithTimeout:testing::kWaitForUIElementTimeout], |
| 184 @"Failed, there was a static html view containing %@", text); | 185 @"Failed, there was a static html view containing %@", text); |
| 185 } | 186 } |
| 186 | 187 |
| 188 + (void)waitForWebViewContainingText:(std::string)text { |
| 189 GREYCondition* condition = [GREYCondition |
| 190 conditionWithName:@"Wait for web view containing text" |
| 191 block:^BOOL { |
| 192 return web::test::IsWebViewContainingText( |
| 193 chrome_test_util::GetCurrentWebState(), text); |
| 194 }]; |
| 195 GREYAssert([condition waitWithTimeout:testing::kWaitForUIElementTimeout], |
| 196 @"Failed waiting for web view containing %s", text.c_str()); |
| 197 } |
| 187 @end | 198 @end |
| OLD | NEW |