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

Side by Side Diff: ios/chrome/browser/context_menu/context_menu_egtest.mm

Issue 2752583004: Add helpers to swipe up and down on the current web view.
Patch Set: more typos! Created 3 years, 9 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
« no previous file with comments | « no previous file | ios/chrome/browser/ui/fullscreen_egtest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <EarlGrey/EarlGrey.h> 5 #import <EarlGrey/EarlGrey.h>
6 #import <UIKit/UIKit.h> 6 #import <UIKit/UIKit.h>
7 #import <XCTest/XCTest.h> 7 #import <XCTest/XCTest.h>
8 8
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "ios/chrome/browser/ui/ui_util.h" 10 #include "ios/chrome/browser/ui/ui_util.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 "<div style='height:4000px'></div>" 202 "<div style='height:4000px'></div>"
203 "<a style='margin-left:50px' href='" + 203 "<a style='margin-left:50px' href='" +
204 destinationURL.spec() + "' id='link'>link</a>"; 204 destinationURL.spec() + "' id='link'>link</a>";
205 responses[destinationURL] = kDestinationHtml; 205 responses[destinationURL] = kDestinationHtml;
206 206
207 web::test::SetUpSimpleHttpServer(responses); 207 web::test::SetUpSimpleHttpServer(responses);
208 [ChromeEarlGrey loadURL:initialURL]; 208 [ChromeEarlGrey loadURL:initialURL];
209 chrome_test_util::AssertMainTabCount(1U); 209 chrome_test_util::AssertMainTabCount(1U);
210 210
211 // Scroll down on the web view to make the link visible. 211 // Scroll down on the web view to make the link visible.
212 [[EarlGrey 212 [ChromeEarlGreyUI swipeUpOnWebView];
213 selectElementWithMatcher:WebViewScrollView(
214 chrome_test_util::GetCurrentWebState())]
215 performAction:grey_swipeFastInDirection(kGREYDirectionUp)];
216 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 213 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
217 kDestinationLinkID)] 214 kDestinationLinkID)]
218 assertWithMatcher:grey_notNil()]; 215 assertWithMatcher:grey_notNil()];
219 216
220 LongPressElementAndTapOnButton(kDestinationLinkID, OpenLinkInNewTabButton()); 217 LongPressElementAndTapOnButton(kDestinationLinkID, OpenLinkInNewTabButton());
221 218
222 // Earl Grey cannot preperly synchronize some animations, so adding a 219 // Earl Grey cannot preperly synchronize some animations, so adding a
223 // WaitUntilCondition to wait for the new tab opening animation to finish 220 // WaitUntilCondition to wait for the new tab opening animation to finish
224 // and the scroll view to become interactable. 221 // and the scroll view to become interactable.
225 ConditionBlock condition = ^{ 222 ConditionBlock condition = ^{
226 NSError* error = nil; 223 NSError* error = nil;
227 [[EarlGrey 224 [[EarlGrey
228 selectElementWithMatcher:WebViewScrollView( 225 selectElementWithMatcher:WebViewScrollView(
229 chrome_test_util::GetCurrentWebState())] 226 chrome_test_util::GetCurrentWebState())]
230 assertWithMatcher:grey_interactable() 227 assertWithMatcher:grey_interactable()
231 error:&error]; 228 error:&error];
232 return !error; 229 return !error;
233 }; 230 };
234 GREYAssert(testing::WaitUntilConditionOrTimeout( 231 GREYAssert(testing::WaitUntilConditionOrTimeout(
235 testing::kWaitForUIElementTimeout, condition), 232 testing::kWaitForUIElementTimeout, condition),
236 @"Web view did not become interactable"); 233 @"Web view did not become interactable");
237 234
238 // Make the toolbar visible by scrolling up on the web view to select the 235 // Make the toolbar visible by scrolling up on the web view to select the
239 // newly opened tab. 236 // newly opened tab.
240 [[EarlGrey 237 [ChromeEarlGreyUI swipeDownOnWebView];
241 selectElementWithMatcher:WebViewScrollView(
242 chrome_test_util::GetCurrentWebState())]
243 performAction:grey_swipeFastInDirection(kGREYDirectionDown)];
244 chrome_test_util::AssertToolbarVisible(); 238 chrome_test_util::AssertToolbarVisible();
245 239
246 SelectTabAtIndexInCurrentMode(1U); 240 SelectTabAtIndexInCurrentMode(1U);
247 241
248 // Verify url and tab count. 242 // Verify url and tab count.
249 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 243 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
250 destinationURL.GetContent())] 244 destinationURL.GetContent())]
251 assertWithMatcher:grey_notNil()]; 245 assertWithMatcher:grey_notNil()];
252 chrome_test_util::AssertMainTabCount(2U); 246 chrome_test_util::AssertMainTabCount(2U);
253 } 247 }
254 248
255 @end 249 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/fullscreen_egtest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698