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

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

Issue 2752153004: Fix testContextMenuOpenInNewTabFromTallPage. (Closed)
Patch Set: remove debugging code 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 | 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // Verify url and tab count. 182 // Verify url and tab count.
183 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 183 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
184 destinationURL.GetContent())] 184 destinationURL.GetContent())]
185 assertWithMatcher:grey_notNil()]; 185 assertWithMatcher:grey_notNil()];
186 chrome_test_util::AssertMainTabCount(2U); 186 chrome_test_util::AssertMainTabCount(2U);
187 } 187 }
188 188
189 // Tests "Open in New Tab" on context menu on a link that requires scrolling 189 // Tests "Open in New Tab" on context menu on a link that requires scrolling
190 // on the page to verify that context menu can be properly triggered in the 190 // on the page to verify that context menu can be properly triggered in the
191 // current screen view. 191 // current screen view.
192 // TODO(crbug.com/701104): This test is flaky because sometimes it doesn't 192 - (void)testContextMenuOpenInNewTabFromTallPage {
193 // scroll down far enough for the link to be visible.
194 - (void)FLAKY_testContextMenuOpenInNewTabFromTallPage {
195 // Set up test simple http server. 193 // Set up test simple http server.
196 std::map<GURL, std::string> responses; 194 std::map<GURL, std::string> responses;
197 GURL initialURL = 195 GURL initialURL =
198 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab"); 196 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab");
199 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 197 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
200 198
201 // The initial page contains a link to the destination page that is below a 199 // The initial page contains a link to the destination page that is below a
202 // really tall div so that scrolling is required. 200 // really tall div so that scrolling is required.
203 responses[initialURL] = 201 responses[initialURL] =
204 "<div style='height:4000px'></div>" 202 "<div style='height:4000px'></div>"
205 "<a style='margin-left:50px' href='" + 203 "<a style='margin-left:50px' href='" +
206 destinationURL.spec() + "' id='link'>link</a>"; 204 destinationURL.spec() + "' id='link'>link</a>";
207 responses[destinationURL] = kDestinationHtml; 205 responses[destinationURL] = kDestinationHtml;
208 206
209 web::test::SetUpSimpleHttpServer(responses); 207 web::test::SetUpSimpleHttpServer(responses);
210 [ChromeEarlGrey loadURL:initialURL]; 208 [ChromeEarlGrey loadURL:initialURL];
211 chrome_test_util::AssertMainTabCount(1U); 209 chrome_test_util::AssertMainTabCount(1U);
212 210
213 // Scroll down on the web view to make the link visible. 211 // Scroll down on the web view to make the link visible.
212 // grey_swipeFastInDirecton will quickly scroll towards the bottom, and then
213 // grey_scrollToContentEdge guarantees the content edge is reached. Two
214 // methods are used because the first one is much faster, but doesn't
215 // guarantee the link becomes visible.
214 [[EarlGrey 216 [[EarlGrey
215 selectElementWithMatcher:WebViewScrollView( 217 selectElementWithMatcher:WebViewScrollView(
216 chrome_test_util::GetCurrentWebState())] 218 chrome_test_util::GetCurrentWebState())]
217 performAction:grey_swipeFastInDirection(kGREYDirectionUp)]; 219 performAction:grey_swipeFastInDirection(kGREYDirectionUp)];
220 [[EarlGrey
221 selectElementWithMatcher:WebViewScrollView(
222 chrome_test_util::GetCurrentWebState())]
223 performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
Eugene But (OOO till 7-30) 2017/03/16 16:54:52 It's pretty bad that |grey_scrollToContentEdge| is
baxley 2017/03/16 17:05:14 Done. Yeah, I agree that it's so slow. For a lot o
224
218 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText( 225 [[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewContainingText(
219 kDestinationLinkID)] 226 kDestinationLinkID)]
220 assertWithMatcher:grey_notNil()]; 227 assertWithMatcher:grey_notNil()];
221 228
222 LongPressElementAndTapOnButton(kDestinationLinkID, OpenLinkInNewTabButton()); 229 LongPressElementAndTapOnButton(kDestinationLinkID, OpenLinkInNewTabButton());
223 230
224 // Earl Grey cannot preperly synchronize some animations, so adding a 231 // Earl Grey cannot preperly synchronize some animations, so adding a
225 // WaitUntilCondition to wait for the new tab opening animation to finish 232 // WaitUntilCondition to wait for the new tab opening animation to finish
226 // and the scroll view to become interactable. 233 // and the scroll view to become interactable.
227 ConditionBlock condition = ^{ 234 ConditionBlock condition = ^{
(...skipping 20 matching lines...) Expand all
248 SelectTabAtIndexInCurrentMode(1U); 255 SelectTabAtIndexInCurrentMode(1U);
249 256
250 // Verify url and tab count. 257 // Verify url and tab count.
251 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText( 258 [[EarlGrey selectElementWithMatcher:chrome_test_util::OmniboxText(
252 destinationURL.GetContent())] 259 destinationURL.GetContent())]
253 assertWithMatcher:grey_notNil()]; 260 assertWithMatcher:grey_notNil()];
254 chrome_test_util::AssertMainTabCount(2U); 261 chrome_test_util::AssertMainTabCount(2U);
255 } 262 }
256 263
257 @end 264 @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