Commit 3065e0c4 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Reland "Convert ContextMenu Franky tests to EG"

This CL adds two EarlGrey test to replace Franky tests.
Reland of: https://chromium-review.googlesource.com/c/1392091

Bug: 910345
Change-Id: I1fe9194ca2162d1418774fe90e215c33e9ad0ef0
Reviewed-on: https://chromium-review.googlesource.com/c/1392335
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarEric Noyau <noyau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619915}
parent 50ace3cf
...@@ -11,6 +11,7 @@ source_set("eg_tests") { ...@@ -11,6 +11,7 @@ source_set("eg_tests") {
deps = [ deps = [
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/strings",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui", "//ios/chrome/browser/ui",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
...@@ -71,7 +72,7 @@ const char kDestinationPageText[] = "You made it!"; ...@@ -71,7 +72,7 @@ const char kDestinationPageText[] = "You made it!";
const char kInitialPageUrl[] = "/scenarioContextMenuOpenInNewTab"; const char kInitialPageUrl[] = "/scenarioContextMenuOpenInNewTab";
// HTML content of a page with a link to the destination page. // HTML content of a page with a link to the destination page.
const char kInitialPageHtml[] = const char kInitialPageHtml[] =
"<html><body><a style='margin-left:50px' href='/destination' id='link'>" "<html><body><a style='margin-left:150px' href='/destination' id='link'>"
"link</a></body></html>"; "link</a></body></html>";
// The DOM element ID of the link to the destination page. // The DOM element ID of the link to the destination page.
const char kInitialPageDestinationLinkId[] = "link"; const char kInitialPageDestinationLinkId[] = "link";
...@@ -360,4 +361,71 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) { ...@@ -360,4 +361,71 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) {
}); });
} }
// Tests cancelling the context menu.
- (void)testDismissContextMenu {
const GURL initialURL = self.testServer->GetURL(kInitialPageUrl);
[ChromeEarlGrey loadURL:initialURL];
[ChromeEarlGrey waitForWebViewContainingText:kInitialPageDestinationLinkText];
// Display the context menu twice.
for (NSInteger i = 0; i < 2; i++) {
LongPressElement(kInitialPageDestinationLinkId);
// Make sure the context menu appeared.
[[EarlGrey selectElementWithMatcher:OpenLinkInNewTabButton()]
assertWithMatcher:grey_notNil()];
if (IsIPadIdiom()) {
// Tap the tools menu to dismiss the popover.
[[EarlGrey selectElementWithMatcher:chrome_test_util::ToolsMenuButton()]
performAction:grey_tap()];
} else {
TapOnContextMenuButton(chrome_test_util::CancelButton());
}
// Make sure the context menu disappeared.
[[EarlGrey selectElementWithMatcher:OpenLinkInNewTabButton()]
assertWithMatcher:grey_nil()];
}
// Display the context menu one last time.
LongPressElement(kInitialPageDestinationLinkId);
// Make sure the context menu appeared.
[[EarlGrey selectElementWithMatcher:OpenLinkInNewTabButton()]
assertWithMatcher:grey_notNil()];
}
// Checks that all the options are displayed in the context menu.
- (void)testAppropriateContextMenu {
const GURL initialURL = self.testServer->GetURL(kInitialPageUrl);
[ChromeEarlGrey loadURL:initialURL];
[ChromeEarlGrey waitForWebViewContainingText:kInitialPageDestinationLinkText];
LongPressElement(kInitialPageDestinationLinkId);
// Check the different buttons.
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB)]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey selectElementWithMatcher:
chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB)]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST)]
assertWithMatcher:grey_sufficientlyVisible()];
[[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
IDS_IOS_CONTENT_CONTEXT_COPY)]
assertWithMatcher:grey_sufficientlyVisible()];
if (!IsIPadIdiom()) {
[[EarlGrey selectElementWithMatcher:
chrome_test_util::ButtonWithAccessibilityLabelId(IDS_CANCEL)]
assertWithMatcher:grey_sufficientlyVisible()];
}
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment