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

Unified Diff: ios/web/shell/test/context_menu_egtest.mm

Issue 2674473002: Fix context menu web shell EarlGrey tests. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/shell/test/context_menu_egtest.mm
diff --git a/ios/web/shell/test/context_menu_egtest.mm b/ios/web/shell/test/context_menu_egtest.mm
index ddd789506f4802fcf50d204879332347d25b87b0..46f665ee9a630e1202c03450af4303d0ec3cd081 100644
--- a/ios/web/shell/test/context_menu_egtest.mm
+++ b/ios/web/shell/test/context_menu_egtest.mm
@@ -27,6 +27,7 @@
using testing::ContextMenuItemWithText;
using testing::ElementToDismissContextMenu;
+using web::WebViewContainingText;
// Context menu test cases for the web shell.
@interface ContextMenuTestCase : ShellBaseTestCase
@@ -36,26 +37,24 @@ using testing::ElementToDismissContextMenu;
// Tests context menu appears on a regular link.
- (void)testContextMenu {
-// TODO(crbug.com/687546): Tests disabled on devices.
-#if !TARGET_IPHONE_SIMULATOR
- EARL_GREY_TEST_DISABLED(@"Disabled for devices because it is very flaky.");
-#endif
-
// Create map of canned responses and set up the test HTML server.
std::map<GURL, std::string> responses;
GURL initialURL = web::test::HttpServer::MakeUrl("http://contextMenuOpen");
GURL destinationURL = web::test::HttpServer::MakeUrl("http://destination");
// The initial page contains a link to the destination URL.
std::string linkID = "link";
+ std::string linkText = "link for context menu";
responses[initialURL] =
"<body>"
"<a href='" +
- destinationURL.spec() + "' id='" + linkID +
- "'>link for context menu</a>"
+ destinationURL.spec() + "' id='" + linkID + "'>" + linkText +
+ "</a>"
"</span></body>";
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:initialURL];
+ [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)]
+ assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::WebView()]
performAction:web::longPressElementForContextMenu(
@@ -85,14 +84,17 @@ using testing::ElementToDismissContextMenu;
// The initial page contains a link to the destination URL that has an
// ancestor that disables the context menu via -webkit-touch-callout.
std::string linkID = "link";
+ std::string linkText = "no-callout link";
responses[initialURL] = "<body><a href='" + destinationURL.spec() +
"' style='-webkit-touch-callout: none' id='" +
- linkID +
- "'>no-callout link</a>"
+ linkID + "'>" + linkText +
+ "</a>"
"</body>";
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:initialURL];
+ [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)]
+ assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::WebView()]
performAction:web::longPressElementForContextMenu(
@@ -115,15 +117,18 @@ using testing::ElementToDismissContextMenu;
// The initial page contains a link to the destination URL that has an
// ancestor that disables the context menu via -webkit-touch-callout.
std::string linkID = "link";
+ std::string linkText = "ancestor no-callout link";
responses[initialURL] =
"<body style='-webkit-touch-callout: none'>"
"<a href='" +
- destinationURL.spec() + "' id='" + linkID +
- "'>ancestor no-callout link</a>"
+ destinationURL.spec() + "' id='" + linkID + "'>" + linkText +
+ "</a>"
"</body>";
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:initialURL];
+ [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)]
+ assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::WebView()]
performAction:web::longPressElementForContextMenu(
@@ -146,16 +151,19 @@ using testing::ElementToDismissContextMenu;
// The initial page contains a link to the destination URL that has an
// ancestor that disables the context menu via -webkit-touch-callout.
std::string linkID = "link";
+ std::string linkText = "override no-callout link";
responses[initialURL] =
"<body style='-webkit-touch-callout: none'>"
"<a href='" +
destinationURL.spec() + "' style='-webkit-touch-callout: default' id='" +
- linkID +
- "'>override no-callout link</a>"
+ linkID + "'>" + linkText +
+ "</a>"
"</body>";
web::test::SetUpSimpleHttpServer(responses);
[ShellEarlGrey loadURL:initialURL];
+ [[EarlGrey selectElementWithMatcher:WebViewContainingText(linkText)]
+ assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:web::WebView()]
performAction:web::longPressElementForContextMenu(
« 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