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

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

Issue 2640783005: Re-enable testContextMenuOpenInNewTabFromTallPage on device. (Closed)
Patch Set: Addressed feedback Created 3 years, 11 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 | no next file » | 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 id<GREYMatcher> contextMenuItemButton) { 63 id<GREYMatcher> contextMenuItemButton) {
64 [[EarlGrey selectElementWithMatcher:chrome_test_util:: 64 [[EarlGrey selectElementWithMatcher:chrome_test_util::
65 webViewBelongingToWebController()] 65 webViewBelongingToWebController()]
66 performAction:chrome_test_util::longPressElementForContextMenu(elementId, 66 performAction:chrome_test_util::longPressElementForContextMenu(elementId,
67 true)]; 67 true)];
68 68
69 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 69 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
70 assertWithMatcher:grey_notNil()]; 70 assertWithMatcher:grey_notNil()];
71 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 71 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
72 performAction:grey_tap()]; 72 performAction:grey_tap()];
73 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 73
74 assertWithMatcher:grey_nil()]; 74 // Earl Grey cannot preperly synchronize with WKWebView, so adding a
Eugene But (OOO till 7-30) 2017/01/19 23:19:07 I would avoid mentioning WKWebView here. How about
liaoyuke 2017/01/19 23:46:49 Done.
75 // WaitUntilCondition to wait for the context menu to disappear.
76 ConditionBlock condition = ^{
Eugene But (OOO till 7-30) 2017/01/19 23:19:07 Could you please move this to WaitForContextMenuDi
liaoyuke 2017/01/19 23:46:49 Done.
77 NSError* error = nil;
78 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
79 assertWithMatcher:grey_nil()
80 error:&error];
81 return error == nil;
82 };
83 GREYAssert(testing::WaitUntilConditionOrTimeout(
84 testing::kWaitForUIElementTimeout, condition),
85 [NSString stringWithFormat:@"Waiting for matcher %@ failed.",
86 contextMenuItemButton]);
75 } 87 }
76 88
77 // A simple wrapper that sleeps for 1s to wait for the animation, triggered from 89 // A simple wrapper that sleeps for 1s to wait for the animation, triggered from
78 // opening a new tab through context menu, to finish before selecting tab. 90 // opening a new tab through context menu, to finish before selecting tab.
79 // TODO(crbug.com/643792): Remove this function when the bug is fixed. 91 // TODO(crbug.com/643792): Remove this function when the bug is fixed.
80 void SelectTabAtIndexInCurrentMode(NSUInteger index) { 92 void SelectTabAtIndexInCurrentMode(NSUInteger index) {
81 // Delay for 1 second. 93 // Delay for 1 second.
82 GREYCondition* myCondition = [GREYCondition conditionWithName:@"delay" 94 GREYCondition* myCondition = [GREYCondition conditionWithName:@"delay"
83 block:^BOOL { 95 block:^BOOL {
84 return NO; 96 return NO;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Verify url and tab count. 179 // Verify url and tab count.
168 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 180 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText(
169 destinationURL.GetContent())] 181 destinationURL.GetContent())]
170 assertWithMatcher:grey_notNil()]; 182 assertWithMatcher:grey_notNil()];
171 chrome_test_util::AssertMainTabCount(2U); 183 chrome_test_util::AssertMainTabCount(2U);
172 } 184 }
173 185
174 // Tests "Open in New Tab" on context menu on a link that requires scrolling 186 // Tests "Open in New Tab" on context menu on a link that requires scrolling
175 // on the page to verify that context menu can be properly triggered in the 187 // on the page to verify that context menu can be properly triggered in the
176 // current screen view. 188 // current screen view.
177 // TODO(crbug.com/681130): Re-enable this test on device. 189 - (void)testContextMenuOpenInNewTabFromTallPage {
178 #if TARGET_IPHONE_SIMULATOR
179 #define MAYBE_testContextMenuOpenInNewTabFromTallPage \
180 testContextMenuOpenInNewTabFromTallPage
181 #else
182 #define MAYBE_testContextMenuOpenInNewTabFromTallPage \
183 FLAKY_testContextMenuOpenInNewTabFromTallPage
184 #endif
185 - (void)MAYBE_testContextMenuOpenInNewTabFromTallPage {
186 // Set up test simple http server. 190 // Set up test simple http server.
187 std::map<GURL, std::string> responses; 191 std::map<GURL, std::string> responses;
188 GURL initialURL = 192 GURL initialURL =
189 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab"); 193 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab");
190 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 194 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
191 195
192 // The initial page contains a link to the destination page that is below a 196 // The initial page contains a link to the destination page that is below a
193 // really tall div so that scrolling is required. 197 // really tall div so that scrolling is required.
194 responses[initialURL] = 198 responses[initialURL] =
195 "<div style='height:4000px'></div>" 199 "<div style='height:4000px'></div>"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 SelectTabAtIndexInCurrentMode(1U); 243 SelectTabAtIndexInCurrentMode(1U);
240 244
241 // Verify url and tab count. 245 // Verify url and tab count.
242 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 246 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText(
243 destinationURL.GetContent())] 247 destinationURL.GetContent())]
244 assertWithMatcher:grey_notNil()]; 248 assertWithMatcher:grey_notNil()];
245 chrome_test_util::AssertMainTabCount(2U); 249 chrome_test_util::AssertMainTabCount(2U);
246 } 250 }
247 251
248 @end 252 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698