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

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

Issue 2640783005: Re-enable testContextMenuOpenInNewTabFromTallPage on device. (Closed)
Patch Set: Update function name 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 item to disappear. TODO(crbug.com/682871): Remove
61 // this once EarlGrey is synchronized with context menu.
62 void WaitForContextMenuItemDisappeared(id<GREYMatcher> contextMenuItemButton) {
63 ConditionBlock condition = ^{
64 NSError* error = nil;
65 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
66 assertWithMatcher:grey_nil()
67 error:&error];
68 return error == nil;
69 };
70 GREYAssert(testing::WaitUntilConditionOrTimeout(
71 testing::kWaitForUIElementTimeout, condition),
72 [NSString stringWithFormat:@"Waiting for matcher %@ failed.",
73 contextMenuItemButton]);
74 }
75
60 // Long press on |elementId| to trigger context menu and then tap on 76 // Long press on |elementId| to trigger context menu and then tap on
61 // |contextMenuItemButton| item. 77 // |contextMenuItemButton| item.
62 void LongPressElementAndTapOnButton(const char* elementId, 78 void LongPressElementAndTapOnButton(const char* elementId,
63 id<GREYMatcher> contextMenuItemButton) { 79 id<GREYMatcher> contextMenuItemButton) {
64 [[EarlGrey selectElementWithMatcher:chrome_test_util:: 80 [[EarlGrey selectElementWithMatcher:chrome_test_util::
65 webViewBelongingToWebController()] 81 webViewBelongingToWebController()]
66 performAction:chrome_test_util::longPressElementForContextMenu(elementId, 82 performAction:chrome_test_util::longPressElementForContextMenu(elementId,
67 true)]; 83 true)];
68 84
69 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 85 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
70 assertWithMatcher:grey_notNil()]; 86 assertWithMatcher:grey_notNil()];
71 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 87 [[EarlGrey selectElementWithMatcher:contextMenuItemButton]
72 performAction:grey_tap()]; 88 performAction:grey_tap()];
73 [[EarlGrey selectElementWithMatcher:contextMenuItemButton] 89 WaitForContextMenuItemDisappeared(contextMenuItemButton);
74 assertWithMatcher:grey_nil()];
75 } 90 }
76 91
77 // A simple wrapper that sleeps for 1s to wait for the animation, triggered from 92 // 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. 93 // 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. 94 // TODO(crbug.com/643792): Remove this function when the bug is fixed.
80 void SelectTabAtIndexInCurrentMode(NSUInteger index) { 95 void SelectTabAtIndexInCurrentMode(NSUInteger index) {
81 // Delay for 1 second. 96 // Delay for 1 second.
82 GREYCondition* myCondition = [GREYCondition conditionWithName:@"delay" 97 GREYCondition* myCondition = [GREYCondition conditionWithName:@"delay"
83 block:^BOOL { 98 block:^BOOL {
84 return NO; 99 return NO;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Verify url and tab count. 182 // Verify url and tab count.
168 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 183 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText(
169 destinationURL.GetContent())] 184 destinationURL.GetContent())]
170 assertWithMatcher:grey_notNil()]; 185 assertWithMatcher:grey_notNil()];
171 chrome_test_util::AssertMainTabCount(2U); 186 chrome_test_util::AssertMainTabCount(2U);
172 } 187 }
173 188
174 // 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
175 // 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
176 // current screen view. 191 // current screen view.
177 // TODO(crbug.com/681130): Re-enable this test on device. 192 - (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. 193 // Set up test simple http server.
187 std::map<GURL, std::string> responses; 194 std::map<GURL, std::string> responses;
188 GURL initialURL = 195 GURL initialURL =
189 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab"); 196 web::test::HttpServer::MakeUrl("http://scenarioContextMenuOpenInNewTab");
190 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination"); 197 GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
191 198
192 // 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
193 // really tall div so that scrolling is required. 200 // really tall div so that scrolling is required.
194 responses[initialURL] = 201 responses[initialURL] =
195 "<div style='height:4000px'></div>" 202 "<div style='height:4000px'></div>"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 SelectTabAtIndexInCurrentMode(1U); 246 SelectTabAtIndexInCurrentMode(1U);
240 247
241 // Verify url and tab count. 248 // Verify url and tab count.
242 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText( 249 [[EarlGrey selectElementWithMatcher:chrome_test_util::omniboxText(
243 destinationURL.GetContent())] 250 destinationURL.GetContent())]
244 assertWithMatcher:grey_notNil()]; 251 assertWithMatcher:grey_notNil()];
245 chrome_test_util::AssertMainTabCount(2U); 252 chrome_test_util::AssertMainTabCount(2U);
246 } 253 }
247 254
248 @end 255 @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