Commit f366a5a6 authored by Rohit Rao's avatar Rohit Rao Committed by Commit Bot

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

KeyboardCommandsTestCase:
- Updates the recent tabs test now that recent tabs is always presented
  and never contained.
- Updates the recent tabs test because the a11y ID of the "Done" button
  is different when the UIRefresh flag is enabled.

RecentTabsTableTestCase:
- Properly nils out the mediator after it is disconnected.  This
  prevents a crash when launching recent tabs a second time.

BUG=825431

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Ib97c1536083fae82dcc523c8ea2787c74f92469b
Reviewed-on: https://chromium-review.googlesource.com/995617Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Rohit Rao <rohitrao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548061}
parent b3f3f16b
...@@ -523,6 +523,7 @@ source_set("eg_tests") { ...@@ -523,6 +523,7 @@ source_set("eg_tests") {
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/ntp:ntp_controller", "//ios/chrome/browser/ui/ntp:ntp_controller",
"//ios/chrome/browser/ui/table_view",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/testing:ios_test_support", "//ios/testing:ios_test_support",
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/browser_view_controller.h" #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/ntp/new_tab_page_controller.h"
#import "ios/chrome/browser/ui/table_view/table_container_constants.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/ui/uikit_ui_util.h" #import "ios/chrome/browser/ui/uikit_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
...@@ -148,6 +149,7 @@ using chrome_test_util::RecentTabsMenuButton; ...@@ -148,6 +149,7 @@ using chrome_test_util::RecentTabsMenuButton;
// Open Bookmarks // Open Bookmarks
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()]; [ChromeEarlGreyUI tapToolsMenuButton:chrome_test_util::BookmarksMenuButton()];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
[self verifyNoKeyboardCommandsAreRegistered]; [self verifyNoKeyboardCommandsAreRegistered];
...@@ -156,20 +158,24 @@ using chrome_test_util::RecentTabsMenuButton; ...@@ -156,20 +158,24 @@ using chrome_test_util::RecentTabsMenuButton;
} }
// Tests that keyboard commands are not registered when the Recent Tabs UI is // Tests that keyboard commands are not registered when the Recent Tabs UI is
// shown on iPhone and registered on iPad. // shown.
- (void)testKeyboardCommands_RecentTabsPresented { - (void)testKeyboardCommands_RecentTabsPresented {
// Open Recent Tabs // Open Recent Tabs
[ChromeEarlGreyUI openToolsMenu]; [ChromeEarlGreyUI openToolsMenu];
[ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()]; [ChromeEarlGreyUI tapToolsMenuButton:RecentTabsMenuButton()];
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
if (IsIPadIdiom()) { [self verifyNoKeyboardCommandsAreRegistered];
[self verifyKeyboardCommandsAreRegistered];
} else {
[self verifyNoKeyboardCommandsAreRegistered];
id<GREYMatcher> exit = grey_accessibilityID(@"Exit"); // Clean up by dismissing the recent tabs UI before ending the test. The
[[EarlGrey selectElementWithMatcher:exit] performAction:grey_tap()]; // a11y ID for the dismiss button depends on the UIRefresh experiment.
id<GREYMatcher> exitMatcher = nil;
if (IsUIRefreshPhase1Enabled()) {
exitMatcher = grey_accessibilityID(kTableContainerDismissButtonId);
} else {
exitMatcher = grey_accessibilityID(@"Exit");
} }
[[EarlGrey selectElementWithMatcher:exitMatcher] performAction:grey_tap()];
} }
// Tests that when the app is opened on a web page and a key is pressed, the // Tests that when the app is opened on a web page and a key is pressed, the
......
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
self.recentTabsContainerViewController = nil; self.recentTabsContainerViewController = nil;
self.recentTabsTransitioningDelegate = nil; self.recentTabsTransitioningDelegate = nil;
[self.mediator disconnect]; [self.mediator disconnect];
self.mediator = nil;
} }
#pragma mark - RecentTabsHandsetViewControllerCommand #pragma mark - RecentTabsHandsetViewControllerCommand
......
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