Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: ios/chrome/test/earl_grey/chrome_earl_grey.mm

Issue 2784943002: Remove matcher to wait for static HTML view. (Closed)
Patch Set: typo Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/sys_string_conversions.h" 11 #include "base/strings/sys_string_conversions.h"
12 #import "base/test/ios/wait_util.h"
13 #include "components/strings/grit/components_strings.h"
14 #import "ios/chrome/browser/ui/static_content/static_html_view_controller.h"
12 #import "ios/chrome/test/app/chrome_test_util.h" 15 #import "ios/chrome/test/app/chrome_test_util.h"
13 #import "ios/chrome/test/app/history_test_util.h" 16 #import "ios/chrome/test/app/history_test_util.h"
14 #include "ios/chrome/test/app/navigation_test_util.h" 17 #include "ios/chrome/test/app/navigation_test_util.h"
18 #import "ios/chrome/test/app/static_html_view_test_util.h"
15 #import "ios/testing/wait_util.h" 19 #import "ios/testing/wait_util.h"
16 #import "ios/web/public/test/earl_grey/js_test_util.h" 20 #import "ios/web/public/test/earl_grey/js_test_util.h"
17 #import "ios/web/public/test/web_view_interaction_test_util.h" 21 #import "ios/web/public/test/web_view_interaction_test_util.h"
18 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" 22 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h"
19 #import "ios/web/public/web_state/web_state.h" 23 #import "ios/web/public/web_state/web_state.h"
24 #include "ui/base/l10n/l10n_util.h"
20 25
21 #if !defined(__has_feature) || !__has_feature(objc_arc) 26 #if !defined(__has_feature) || !__has_feature(objc_arc)
22 #error "This file requires ARC support." 27 #error "This file requires ARC support."
23 #endif 28 #endif
24 29
25 namespace chrome_test_util { 30 namespace chrome_test_util {
26 31
27 id ExecuteJavaScript(NSString* javascript, 32 id ExecuteJavaScript(NSString* javascript,
28 NSError* __unsafe_unretained* out_error) { 33 NSError* __unsafe_unretained* out_error) {
29 __block bool did_complete = false; 34 __block bool did_complete = false;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 123 }
119 124
120 + (void)tapWebViewElementWithID:(NSString*)elementID { 125 + (void)tapWebViewElementWithID:(NSString*)elementID {
121 BOOL success = 126 BOOL success =
122 web::test::TapWebViewElementWithId(chrome_test_util::GetCurrentWebState(), 127 web::test::TapWebViewElementWithId(chrome_test_util::GetCurrentWebState(),
123 base::SysNSStringToUTF8(elementID)); 128 base::SysNSStringToUTF8(elementID));
124 GREYAssertTrue(success, @"Failed to tap web view element with ID: %@", 129 GREYAssertTrue(success, @"Failed to tap web view element with ID: %@",
125 elementID); 130 elementID);
126 } 131 }
127 132
133 + (void)waitForErrorPage {
134 NSString* const kInternetDisconnectedError =
lpromero 2017/04/19 11:35:10 The error is not about internet disconnection, but
baxley 2017/04/19 14:39:49 Thanks for pointing out the inconsistency. Do you
lpromero 2017/04/19 14:44:52 The variable name might be sufficient, but since t
135 l10n_util::GetNSString(IDS_ERRORPAGES_HEADING_NOT_AVAILABLE);
136 [self waitForStaticHTMLViewContainingText:kInternetDisconnectedError];
137 }
138
139 + (void)waitForStaticHTMLViewContainingText:(NSString*)text {
140 GREYCondition* condition = [GREYCondition
141 conditionWithName:@"Wait for static HTML text."
142 block:^BOOL {
143 return chrome_test_util::StaticHtmlViewContainingText(
144 chrome_test_util::GetCurrentWebState(),
145 base::SysNSStringToUTF8(text));
146 }];
147 GREYAssert([condition waitWithTimeout:testing::kWaitForUIElementTimeout],
148 @"Failed to find static html view containing %@", text);
149 }
150
151 + (void)waitForStaticHTMLViewNotContainingText:(NSString*)text {
152 GREYCondition* condition = [GREYCondition
153 conditionWithName:@"Wait for absence of static HTML text."
154 block:^BOOL {
155 return !chrome_test_util::StaticHtmlViewContainingText(
156 chrome_test_util::GetCurrentWebState(),
157 base::SysNSStringToUTF8(text));
158 }];
159 GREYAssert([condition waitWithTimeout:testing::kWaitForUIElementTimeout],
160 @"Failed, there was a static html view containing %@", text);
161 }
162
128 @end 163 @end
OLDNEW
« no previous file with comments | « ios/chrome/test/earl_grey/chrome_earl_grey.h ('k') | ios/chrome/test/earl_grey/chrome_matchers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698