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

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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 id<GREYMatcher> openImageInNewTabButton() { 50 id<GREYMatcher> openImageInNewTabButton() {
51 return buttonWithAccessibilityLabelId( 51 return buttonWithAccessibilityLabelId(
52 IDS_IOS_CONTENT_CONTEXT_OPENIMAGENEWTAB); 52 IDS_IOS_CONTENT_CONTEXT_OPENIMAGENEWTAB);
53 } 53 }
54 54
55 // Matcher for the open link in new tab button in the context menu. 55 // Matcher for the open link in new tab button in the context menu.
56 id<GREYMatcher> openLinkInNewTabButton() { 56 id<GREYMatcher> openLinkInNewTabButton() {
57 return buttonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB); 57 return buttonWithAccessibilityLabelId(IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB);
58 } 58 }
59 59
60 // Waits for the context menu to disappear. TODO(crbug.com/682871): Remove this
61 // once EarlGrey is synchronized with context menu.
Eugene But (OOO till 7-30) 2017/01/20 00:00:14 Could you please document |matcher| argument. Sorr
liaoyuke 2017/01/20 00:16:21 Done.
62 void WaitForContextMenuDisappeared(id<GREYMatcher> matcher) {
63 ConditionBlock condition = ^{
64 NSError* error = nil;
65 [[EarlGrey selectElementWithMatcher:matcher] assertWithMatcher:grey_nil()
66 error:&error];
67 return error == nil;
68 };
69 GREYAssert(
70 testing::WaitUntilConditionOrTimeout(testing::kWaitForUIElementTimeout,
71 condition),
72 [NSString stringWithFormat:@"Waiting for matcher %@ failed.", matcher]);
73 }
74
60 // Long press on |elementId| to trigger context menu and then tap on 75 // Long press on |elementId| to trigger context menu and then tap on
61 // |contextMenuItemButton| item. 76 // |contextMenuItemButton| item.
62 void LongPressElementAndTapOnButton(const char* elementId, 77 void LongPressElementAndTapOnButton(const char* elementId,
63 id<GREYMatcher> contextMenuItemButton) { 78 id<GREYMatcher> contextMenuItemButton) {
64 [[EarlGrey selectElementWithMatcher:chrome_test_util:: 79 [[EarlGrey selectElementWithMatcher:chrome_test_util::
65 webViewBelongingToWebController()] 80 webViewBelongingToWebController()]
66 performAction:chrome_test_util::longPressElementForContextMenu(elementId, 81 performAction:chrome_test_util::longPressElementForContextMenu(elementId,
67 true)]; 82 true)];
68 83
69 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 84 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
70 assertWithMatcher:grey_notNil()]; 85 assertWithMatcher:grey_notNil()];
71 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 86 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
72 performAction:grey_tap()]; 87 performAction:grey_tap()];
73 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 88 WaitForContextMenuDisappeared(contextMenuItemButton);
74 assertWithMatcher:grey_nil()];
75 } 89 }
76 90
77 // A simple wrapper that sleeps for 1s to wait for the animation, triggered from 91 // 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. 92 // 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. 93 // TODO(crbug.com/643792): Remove this function when the bug is fixed.
80 void SelectTabAtIndexInCurrentMode(NSUInteger index) { 94 void SelectTabAtIndexInCurrentMode(NSUInteger index) {
81 // Delay for 1 second. 95 // Delay for 1 second.
82 GREYCondition* myCondition = [GREYCondition conditionWithName:@"delay" 96 GREYCondition* myCondition = [GREYCondition conditionWithName:@"delay"
83 block:^BOOL { 97 block:^BOOL {
84 return NO; 98 return NO;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Verify url and tab count. 181 // Verify url and tab count.
168 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 182 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText(
169 destinationURL.GetContent())] 183 destinationURL.GetContent())]
170 assertWithMatcher:grey_notNil()]; 184 assertWithMatcher:grey_notNil()];
171 chrome_test_util::AssertMainTabCount(2U); 185 chrome_test_util::AssertMainTabCount(2U);
172 } 186 }
173 187
174 // Tests "Open in New Tab" on context menu on a link that requires scrolling 188 // 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 189 // on the page to verify that context menu can be properly triggered in the
176 // current screen view. 190 // current screen view.
177 // TODO(crbug.com/681130): Re-enable this test on device. 191 - (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. 192 // Set up test simple http server.
187 std::map<GURL, std::string> responses; 193 std::map<GURL, std::string> responses;
188 GURL initialURL = 194 GURL initialURL =
189 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab"); 195 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab");
190 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 196 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
191 197
192 // The initial page contains a link to the destination page that is below a 198 // The initial page contains a link to the destination page that is below a
193 // really tall div so that scrolling is required. 199 // really tall div so that scrolling is required.
194 responses[initialURL] = 200 responses[initialURL] =
195 "<div style='height:4000px'></div>" 201 "<div style='height:4000px'></div>"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 SelectTabAtIndexInCurrentMode(1U); 245 SelectTabAtIndexInCurrentMode(1U);
240 246
241 // Verify url and tab count. 247 // Verify url and tab count.
242 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 248 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText(
243 destinationURL.GetContent())] 249 destinationURL.GetContent())]
244 assertWithMatcher:grey_notNil()]; 250 assertWithMatcher:grey_notNil()];
245 chrome_test_util::AssertMainTabCount(2U); 251 chrome_test_util::AssertMainTabCount(2U);
246 } 252 }
247 253
248 @end 254 @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