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" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 | 116 |
117 + (void)reload { | 117 + (void)reload { |
118 base::scoped_nsobject<GenericChromeCommand> reloadCommand( | 118 base::scoped_nsobject<GenericChromeCommand> reloadCommand( |
119 [[GenericChromeCommand alloc] initWithTag:IDC_RELOAD]); | 119 [[GenericChromeCommand alloc] initWithTag:IDC_RELOAD]); |
120 chrome_test_util::RunCommandWithActiveViewController(reloadCommand); | 120 chrome_test_util::RunCommandWithActiveViewController(reloadCommand); |
121 [ChromeEarlGrey waitForPageToFinishLoading]; | 121 [ChromeEarlGrey waitForPageToFinishLoading]; |
122 } | 122 } |
123 | 123 |
124 + (void)goBack { | 124 + (void)goBack { |
125 base::scoped_nsobject<GenericChromeCommand> reloadCommand( | 125 [chrome_test_util::BrowserCommandDispatcherForMainBVC() goBack]; |
126 [[GenericChromeCommand alloc] initWithTag:IDC_BACK]); | 126 |
127 chrome_test_util::RunCommandWithActiveViewController(reloadCommand); | |
128 [ChromeEarlGrey waitForPageToFinishLoading]; | 127 [ChromeEarlGrey waitForPageToFinishLoading]; |
129 } | 128 } |
130 | 129 |
131 + (void)goForward { | 130 + (void)goForward { |
132 base::scoped_nsobject<GenericChromeCommand> reloadCommand( | 131 [chrome_test_util::BrowserCommandDispatcherForMainBVC() goForward]; |
133 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]); | 132 |
134 chrome_test_util::RunCommandWithActiveViewController(reloadCommand); | |
135 [ChromeEarlGrey waitForPageToFinishLoading]; | 133 [ChromeEarlGrey waitForPageToFinishLoading]; |
136 } | 134 } |
137 | 135 |
138 + (void)waitForPageToFinishLoading { | 136 + (void)waitForPageToFinishLoading { |
139 GREYCondition* condition = | 137 GREYCondition* condition = |
140 [GREYCondition conditionWithName:@"Wait for page to complete loading." | 138 [GREYCondition conditionWithName:@"Wait for page to complete loading." |
141 block:^BOOL { | 139 block:^BOOL { |
142 return !chrome_test_util::IsLoading(); | 140 return !chrome_test_util::IsLoading(); |
143 }]; | 141 }]; |
144 GREYAssert([condition waitWithTimeout:testing::kWaitForPageLoadTimeout], | 142 GREYAssert([condition waitWithTimeout:testing::kWaitForPageLoadTimeout], |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 GREYCondition* condition = [GREYCondition | 196 GREYCondition* condition = [GREYCondition |
199 conditionWithName:@"Wait for web view not containing text" | 197 conditionWithName:@"Wait for web view not containing text" |
200 block:^BOOL { | 198 block:^BOOL { |
201 return !web::test::IsWebViewContainingText( | 199 return !web::test::IsWebViewContainingText( |
202 chrome_test_util::GetCurrentWebState(), text); | 200 chrome_test_util::GetCurrentWebState(), text); |
203 }]; | 201 }]; |
204 GREYAssert([condition waitWithTimeout:testing::kWaitForUIElementTimeout], | 202 GREYAssert([condition waitWithTimeout:testing::kWaitForUIElementTimeout], |
205 @"Failed waiting for web view not containing %s", text.c_str()); | 203 @"Failed waiting for web view not containing %s", text.c_str()); |
206 } | 204 } |
207 @end | 205 @end |
OLD | NEW |