Commit 662e96bd authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

[ios] Fixes UI egtests when the UIRefresh flag is enabled.

KeyboardCommandsTestCase.testKeyboardCommandsNotRegistered_AddBookmarkPresented
and ToolbarTestCase.testToolbarOmniboxTyping are updated with matches for the
correct elements.

ActivityServiceControllerTestCase.testActivityServiceControllerIsDisabled and
TabSwitcherTransitionTestCase.testRotationsWhileSwitcherIsNotActive are
disabled, because these tests are exposing UIRefresh bugs.

BUG=825431,835860,835871
TEST=None

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I805e4b29ce59b88eb63016d4d2687c9043c72f5b
Reviewed-on: https://chromium-review.googlesource.com/1023718
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552790}
parent 8603ada8
......@@ -524,6 +524,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/tools_menu/public",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing:ios_test_support",
......
......@@ -123,6 +123,13 @@ id<GREYMatcher> PrintButton() {
}
- (void)testActivityServiceControllerIsDisabled {
// TODO(crbug.com/835871): There is no share button on phone when the
// UIRefreshPhase1 flag is enabled.
if (IsCompactWidth() && IsUIRefreshPhase1Enabled()) {
EARL_GREY_TEST_DISABLED(
@"Share button is not yet implemented on compact phone.");
}
// Open an un-shareable page.
GURL kURL("chrome://version");
[ChromeEarlGrey loadURL:kURL];
......
......@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/browser_view_controller.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller_constants.h"
#import "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h"
......@@ -118,6 +119,12 @@ using chrome_test_util::SettingsDoneButton;
BOOL success = chrome_test_util::ClearBookmarks();
GREYAssert(success, @"Not all bookmarks were removed.");
// Load a webpage because the NTP is not always bookmarkable.
web::test::SetUpFileBasedHttpServer();
GURL URL = web::test::HttpServer::MakeUrl(
"http://ios/testing/data/http_server_files/pony.html");
[ChromeEarlGrey loadURL:URL];
// Bookmark page
if (IsIPadIdiom()) {
id<GREYMatcher> bookmarkMatcher =
......@@ -126,7 +133,10 @@ using chrome_test_util::SettingsDoneButton;
performAction:grey_tap()];
} else {
[ChromeEarlGreyUI openToolsMenu];
id<GREYMatcher> bookmarkMatcher = grey_accessibilityLabel(@"Add Bookmark");
id<GREYMatcher> bookmarkMatcher =
IsUIRefreshPhase1Enabled()
? grey_accessibilityID(kToolsMenuAddToBookmarks)
: grey_accessibilityLabel(@"Add Bookmark");
[[EarlGrey selectElementWithMatcher:bookmarkMatcher]
performAction:grey_tap()];
}
......
......@@ -540,6 +540,12 @@ std::unique_ptr<net::test_server::HttpResponse> HandleQueryTitle(
// Tests rotating the device while the switcher is not active. This is a
// regression test case for https://crbug.com/789975.
- (void)testRotationsWhileSwitcherIsNotActive {
// TODO(crbug.com/835860): This test fails when the grid is active.
if (GetTabSwitcherMode() == TabSwitcherMode::GRID) {
EARL_GREY_TEST_DISABLED(
@"testRotationsWhileSwitcherIsNotActive fails under UIRefresh");
}
NSString* tab_title = @"NormalTabLongerStringForRotationTest";
[self setUpTestServer];
[ChromeEarlGrey loadURL:[self makeURLForTitle:tab_title]];
......
......@@ -141,6 +141,7 @@ source_set("eg_tests") {
"//ios/chrome/browser/ui/omnibox/popup",
"//ios/chrome/browser/ui/omnibox/popup:popup_internal",
"//ios/chrome/browser/ui/omnibox/popup:popup_internal",
"//ios/chrome/browser/ui/toolbar/buttons",
"//ios/chrome/browser/ui/toolbar/clean:toolbar_ui",
"//ios/chrome/browser/ui/toolbar/legacy",
"//ios/chrome/browser/ui/tools_menu/public",
......
......@@ -11,6 +11,7 @@
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
#import "ios/chrome/browser/ui/ntp/new_tab_page_controller.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_row.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_constants.h"
#import "ios/chrome/browser/ui/toolbar/clean/toolbar_view.h"
#import "ios/chrome/browser/ui/toolbar/legacy/toolbar_controller.h"
#include "ios/chrome/browser/ui/tools_menu/public/tools_menu_constants.h"
......@@ -99,8 +100,10 @@ using chrome_test_util::OmniboxText;
performAction:grey_typeText(@"foo")];
id<GREYMatcher> cancelButton =
grey_allOf(chrome_test_util::CancelButton(),
grey_not(grey_accessibilityID(@"Typing Shield")), nil);
IsUIRefreshPhase1Enabled()
? grey_accessibilityID(kToolbarCancelOmniboxEditButtonIdentifier)
: grey_allOf(chrome_test_util::CancelButton(),
grey_not(grey_accessibilityID(@"Typing Shield")), nil);
[[EarlGrey selectElementWithMatcher:cancelButton] performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
......@@ -364,8 +367,8 @@ using chrome_test_util::OmniboxText;
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
assertWithMatcher:chrome_test_util::OmniboxText("foo")];
id<GREYMatcher> CancelButton = grey_accessibilityLabel(@"Clear Text");
[[EarlGrey selectElementWithMatcher:CancelButton] performAction:grey_tap()];
id<GREYMatcher> cancelButton = grey_accessibilityLabel(@"Clear Text");
[[EarlGrey selectElementWithMatcher:cancelButton] performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
assertWithMatcher:chrome_test_util::OmniboxText("")];
......@@ -494,11 +497,22 @@ using chrome_test_util::OmniboxText;
nil)]
assertWithMatcher:grey_sufficientlyVisible()];
NSString* cancelButtonText = l10n_util::GetNSString(IDS_CANCEL);
NSString* typingShield = @"Hide keyboard";
NSString* clearText = IsIPadIdiom() ? typingShield : cancelButtonText;
id<GREYMatcher> cancelButton = nil;
if (IsUIRefreshPhase1Enabled()) {
cancelButton =
grey_accessibilityID(kToolbarCancelOmniboxEditButtonIdentifier);
} else if (IsIPadIdiom()) {
NSString* typingShield = @"Hide keyboard";
cancelButton = grey_accessibilityLabel(typingShield);
} else {
NSString* cancelText = l10n_util::GetNSString(IDS_CANCEL);
cancelButton = grey_accessibilityLabel(cancelText);
}
DCHECK(cancelButton);
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(clearText)]
[[EarlGrey
selectElementWithMatcher:grey_allOf(cancelButton,
grey_sufficientlyVisible(), nil)]
performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::Omnibox()]
assertWithMatcher:chrome_test_util::OmniboxText("")];
......
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