Commit 4f44899d authored by Sébastien Séguin-Gagnon's avatar Sébastien Séguin-Gagnon Committed by Commit Bot

Reland "Reland "[Empties] Enable the IllustratedEmptyStates field trial testing config.""

This is a reland of d777f5d0

Original change's description:
> Reland "[Empties] Enable the IllustratedEmptyStates field trial testing config."
> 
> This is a reland of 74b8ec6f
> 
> Original change's description:
> > [Empties] Enable the IllustratedEmptyStates field trial testing config.
> > 
> > Change-Id: I664fa63b5b69369cb69fb4b87463ba3bb4cfc94d
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386295
> > Reviewed-by: Sergio Collazos <sczs@chromium.org>
> > Reviewed-by: Steven Holte <holte@chromium.org>
> > Commit-Queue: sebsg <sebsg@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#805136}
> 
> Change-Id: Ieb3e461efb4c55e7ef601417819cc4470e8fe4cc
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401398
> Commit-Queue: sebsg <sebsg@chromium.org>
> Reviewed-by: Sergio Collazos <sczs@chromium.org>
> Reviewed-by: Ilya Sherman <isherman@chromium.org>
> Auto-Submit: sebsg <sebsg@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#807867}

Change-Id: I0c3a85ef61dc74064e9e9d49a27a5efe1e333452
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2418891Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: sebsg <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809933}
parent 0850b5a6
...@@ -53,18 +53,35 @@ namespace { ...@@ -53,18 +53,35 @@ namespace {
// Taps on the primary sign-in button in recent tabs, and scroll first, if // Taps on the primary sign-in button in recent tabs, and scroll first, if
// necessary. // necessary.
void TapOnPrimarySignInButtonInRecentTabs() { void TapOnPrimarySignInButtonInRecentTabs() {
id<GREYMatcher> matcher = [[[EarlGrey
grey_allOf(PrimarySignInButton(), grey_sufficientlyVisible(), nil); selectElementWithMatcher:grey_allOf(PrimarySignInButton(),
const CGFloat kPixelsToScroll = 300; grey_sufficientlyVisible(), nil)]
id<GREYAction> searchAction = usingSearchAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)
grey_scrollInDirection(kGREYDirectionDown, kPixelsToScroll); onElementWithMatcher:
GREYElementInteraction* interaction = grey_allOf(grey_accessibilityID(
[[EarlGrey selectElementWithMatcher:matcher] kRecentTabsTableViewControllerAccessibilityIdentifier),
usingSearchAction:searchAction grey_sufficientlyVisible(), nil)]
onElementWithMatcher: performAction:grey_tap()];
grey_accessibilityID( }
kRecentTabsTableViewControllerAccessibilityIdentifier)];
[interaction performAction:grey_tap()]; // Collapses the recently closed tabs section if the sign in promo is
// inaccessible otherwise.
void CollapseRecentlyClosedTabsSectionIfNecessary() {
NSError* error = nil;
[[EarlGrey selectElementWithMatcher:
grey_accessibilityID(
kRecentTabsTableViewControllerAccessibilityIdentifier)]
assertWithMatcher:chrome_test_util::ContentViewSmallerThanScrollView()
error:&error];
if (error) {
[[EarlGrey selectElementWithMatcher:
grey_allOf(chrome_test_util::ButtonWithAccessibilityLabel(
l10n_util::GetNSString(
IDS_IOS_RECENT_TABS_RECENTLY_CLOSED)),
grey_sufficientlyVisible(), nil)]
performAction:grey_tap()];
}
} }
// Returns a matcher for |userEmail| in IdentityChooserViewController. // Returns a matcher for |userEmail| in IdentityChooserViewController.
...@@ -448,6 +465,10 @@ void ChooseImportOrKeepDataSepareteDialog(id<GREYMatcher> choiceButtonMatcher) { ...@@ -448,6 +465,10 @@ void ChooseImportOrKeepDataSepareteDialog(id<GREYMatcher> choiceButtonMatcher) {
[[EarlGrey selectElementWithMatcher:chrome_test_util:: [[EarlGrey selectElementWithMatcher:chrome_test_util::
TabGridOtherDevicesPanelButton()] TabGridOtherDevicesPanelButton()]
performAction:grey_tap()]; performAction:grey_tap()];
// TODO(crbug.com/1131479): Find a way to scroll the view instead.
CollapseRecentlyClosedTabsSectionIfNecessary();
TapOnPrimarySignInButtonInRecentTabs(); TapOnPrimarySignInButtonInRecentTabs();
break; break;
} }
......
...@@ -152,11 +152,15 @@ using chrome_test_util::SignOutAccountsButton; ...@@ -152,11 +152,15 @@ using chrome_test_util::SignOutAccountsButton;
+ (void)verifySigninPromoVisibleWithMode:(SigninPromoViewMode)mode + (void)verifySigninPromoVisibleWithMode:(SigninPromoViewMode)mode
closeButton:(BOOL)closeButton { closeButton:(BOOL)closeButton {
[ChromeEarlGreyUI waitForAppToIdle]; [ChromeEarlGreyUI waitForAppToIdle];
[[EarlGrey
selectElementWithMatcher:grey_allOf( // The sign-in promo is not visible when showing illustrated empty states.
grey_accessibilityID(kSigninPromoViewId), if (![ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
grey_sufficientlyVisible(), nil)] [[EarlGrey
assertWithMatcher:grey_notNil()]; selectElementWithMatcher:grey_allOf(
grey_accessibilityID(kSigninPromoViewId),
grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_notNil()];
}
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf(PrimarySignInButton(), selectElementWithMatcher:grey_allOf(PrimarySignInButton(),
grey_sufficientlyVisible(), nil)] grey_sufficientlyVisible(), nil)]
...@@ -169,10 +173,13 @@ using chrome_test_util::SignOutAccountsButton; ...@@ -169,10 +173,13 @@ using chrome_test_util::SignOutAccountsButton;
assertWithMatcher:grey_nil()]; assertWithMatcher:grey_nil()];
break; break;
case SigninPromoViewModeWarmState: case SigninPromoViewModeWarmState:
[[EarlGrey if (![ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
selectElementWithMatcher:grey_allOf(SecondarySignInButton(), [[EarlGrey
grey_sufficientlyVisible(), nil)] selectElementWithMatcher:grey_allOf(SecondarySignInButton(),
assertWithMatcher:grey_notNil()]; grey_sufficientlyVisible(),
nil)]
assertWithMatcher:grey_notNil()];
}
break; break;
} }
if (closeButton) { if (closeButton) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey_ui.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey_ui.h"
#include "base/ios/ios_util.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#include "build/build_config.h" #include "build/build_config.h"
...@@ -439,12 +440,19 @@ id<GREYMatcher> SearchIconButton() { ...@@ -439,12 +440,19 @@ id<GREYMatcher> SearchIconButton() {
} }
- (void)verifyEmptyBackgroundAppears { - (void)verifyEmptyBackgroundAppears {
id<GREYMatcher> emptyBackground = if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
grey_accessibilityID([ChromeEarlGrey isIllustratedEmptyStatesEnabled] [[EarlGrey selectElementWithMatcher:grey_accessibilityID(
? kTableViewIllustratedEmptyViewID kTableViewIllustratedEmptyViewID)]
: kBookmarkEmptyStateExplanatoryLabelIdentifier); assertWithMatcher:grey_notNil()];
[[EarlGrey selectElementWithMatcher:emptyBackground] [[EarlGrey selectElementWithMatcher:grey_text(l10n_util::GetNSString(
assertWithMatcher:grey_sufficientlyVisible()]; IDS_IOS_BOOKMARK_EMPTY_MESSAGE))]
assertWithMatcher:grey_sufficientlyVisible()];
} else {
[[EarlGrey
selectElementWithMatcher:
grey_accessibilityID(kBookmarkEmptyStateExplanatoryLabelIdentifier)]
assertWithMatcher:grey_sufficientlyVisible()];
}
} }
- (void)verifyEmptyState { - (void)verifyEmptyState {
...@@ -453,10 +461,10 @@ id<GREYMatcher> SearchIconButton() { ...@@ -453,10 +461,10 @@ id<GREYMatcher> SearchIconButton() {
id<GREYInteraction> searchBar = id<GREYInteraction> searchBar =
[EarlGrey selectElementWithMatcher:grey_accessibilityTrait( [EarlGrey selectElementWithMatcher:grey_accessibilityTrait(
UIAccessibilityTraitSearchField)]; UIAccessibilityTraitSearchField)];
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) { // TODO(crbug.com/1126982): Fix the search bar issue on iOS 12.4.
// With the illustrated empty state, the search bar should be hidden. // The search bar should not be visible when the illustrated empty state is
[searchBar assertWithMatcher:grey_nil()]; // shown.
} else { if (![ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
[searchBar assertWithMatcher:grey_notNil()]; [searchBar assertWithMatcher:grey_notNil()];
} }
} }
......
...@@ -727,7 +727,7 @@ using chrome_test_util::TappableBookmarkNodeWithLabel; ...@@ -727,7 +727,7 @@ using chrome_test_util::TappableBookmarkNodeWithLabel;
// Reopen bookmarks. // Reopen bookmarks.
[BookmarkEarlGreyUI openBookmarks]; [BookmarkEarlGreyUI openBookmarks];
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) { if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
// Ensure the root node is opened, by verifying that there isn't a Back // Ensure the root node is opened, by verifying that there isn't a Back
// button in the navigation bar. // button in the navigation bar.
[[EarlGrey selectElementWithMatcher:chrome_test_util:: [[EarlGrey selectElementWithMatcher:chrome_test_util::
...@@ -834,7 +834,7 @@ using chrome_test_util::TappableBookmarkNodeWithLabel; ...@@ -834,7 +834,7 @@ using chrome_test_util::TappableBookmarkNodeWithLabel;
- (void)testRootEmptyState { - (void)testRootEmptyState {
[BookmarkEarlGreyUI openBookmarks]; [BookmarkEarlGreyUI openBookmarks];
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) { if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
// When the user has no bookmarks, the root view should be an empty state. // When the user has no bookmarks, the root view should be an empty state.
[BookmarkEarlGreyUI verifyEmptyState]; [BookmarkEarlGreyUI verifyEmptyState];
} else { } else {
...@@ -862,7 +862,7 @@ using chrome_test_util::TappableBookmarkNodeWithLabel; ...@@ -862,7 +862,7 @@ using chrome_test_util::TappableBookmarkNodeWithLabel;
BookmarksNavigationBarBackButton()] BookmarksNavigationBarBackButton()]
performAction:grey_tap()]; performAction:grey_tap()];
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) { if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
// When the user has no bookmarks, the root view should be an empty state. // When the user has no bookmarks, the root view should be an empty state.
[BookmarkEarlGreyUI verifyEmptyState]; [BookmarkEarlGreyUI verifyEmptyState];
} else { } else {
......
...@@ -167,10 +167,7 @@ void SearchBookmarksForText(NSString* search_text) { ...@@ -167,10 +167,7 @@ void SearchBookmarksForText(NSString* search_text) {
- (void)testEmptyManagedBookmarks { - (void)testEmptyManagedBookmarks {
[BookmarkEarlGreyUI openBookmarks]; [BookmarkEarlGreyUI openBookmarks];
// Mobile bookmarks exists. [BookmarkEarlGreyUI verifyEmptyState];
[[EarlGrey selectElementWithMatcher:TappableBookmarkNodeWithLabel(
@"Mobile Bookmarks")]
assertWithMatcher:grey_notNil()];
// Managed bookmarks folder does not exist. // Managed bookmarks folder does not exist.
[[EarlGrey selectElementWithMatcher:TappableBookmarkNodeWithLabel( [[EarlGrey selectElementWithMatcher:TappableBookmarkNodeWithLabel(
......
...@@ -152,8 +152,8 @@ id<GREYMatcher> TitleOfTestPage() { ...@@ -152,8 +152,8 @@ id<GREYMatcher> TitleOfTestPage() {
IDS_HISTORY_TITLE)), IDS_HISTORY_TITLE)),
grey_accessibilityTrait( grey_accessibilityTrait(
UIAccessibilityTraitHeader), UIAccessibilityTraitHeader),
nil)] grey_sufficientlyVisible(), nil)]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_notNil()];
// Close History. // Close History.
id<GREYMatcher> exitMatcher = id<GREYMatcher> exitMatcher =
...@@ -167,6 +167,15 @@ id<GREYMatcher> TitleOfTestPage() { ...@@ -167,6 +167,15 @@ id<GREYMatcher> TitleOfTestPage() {
// Tests that the sign-in promo can be reloaded correctly. // Tests that the sign-in promo can be reloaded correctly.
- (void)testRecentTabSigninPromoReloaded { - (void)testRecentTabSigninPromoReloaded {
OpenRecentTabsPanel(); OpenRecentTabsPanel();
// Scroll to sign-in promo, if applicable.
[[EarlGrey
selectElementWithMatcher:
grey_allOf(grey_accessibilityID(
kRecentTabsTableViewControllerAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)]
performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
// Sign-in promo should be visible with cold state. // Sign-in promo should be visible with cold state.
[SigninEarlGreyUI [SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState
...@@ -185,6 +194,15 @@ id<GREYMatcher> TitleOfTestPage() { ...@@ -185,6 +194,15 @@ id<GREYMatcher> TitleOfTestPage() {
// crbug.com/776939 // crbug.com/776939
- (void)testRecentTabSigninPromoReloadedWhileHidden { - (void)testRecentTabSigninPromoReloadedWhileHidden {
OpenRecentTabsPanel(); OpenRecentTabsPanel();
// Scroll to sign-in promo, if applicable
[[EarlGrey
selectElementWithMatcher:
grey_allOf(grey_accessibilityID(
kRecentTabsTableViewControllerAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)]
performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
[SigninEarlGreyUI [SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO]; closeButton:NO];
...@@ -206,6 +224,13 @@ id<GREYMatcher> TitleOfTestPage() { ...@@ -206,6 +224,13 @@ id<GREYMatcher> TitleOfTestPage() {
// Tap on "Other Devices", to show the sign-in promo. // Tap on "Other Devices", to show the sign-in promo.
[[EarlGrey selectElementWithMatcher:otherDevicesMatcher] [[EarlGrey selectElementWithMatcher:otherDevicesMatcher]
performAction:grey_tap()]; performAction:grey_tap()];
// Scroll to sign-in promo, if applicable
[[EarlGrey
selectElementWithMatcher:
grey_allOf(grey_accessibilityID(
kRecentTabsTableViewControllerAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)]
performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
[SigninEarlGreyUI [SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState verifySigninPromoVisibleWithMode:SigninPromoViewModeWarmState
closeButton:NO]; closeButton:NO];
...@@ -290,6 +315,14 @@ id<GREYMatcher> TitleOfTestPage() { ...@@ -290,6 +315,14 @@ id<GREYMatcher> TitleOfTestPage() {
[illustratedCell assertWithMatcher:grey_nil()]; [illustratedCell assertWithMatcher:grey_nil()];
} }
// Scroll to sign-in promo, if applicable
[[EarlGrey
selectElementWithMatcher:
grey_allOf(grey_accessibilityID(
kRecentTabsTableViewControllerAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)]
performAction:grey_scrollToContentEdge(kGREYContentEdgeBottom)];
[SigninEarlGreyUI [SigninEarlGreyUI
verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState verifySigninPromoVisibleWithMode:SigninPromoViewModeColdState
closeButton:NO]; closeButton:NO];
......
...@@ -226,11 +226,17 @@ id<GREYMatcher> NoBookmarksLabel() { ...@@ -226,11 +226,17 @@ id<GREYMatcher> NoBookmarksLabel() {
// Open the Bookmarks screen on the Tools menu. // Open the Bookmarks screen on the Tools menu.
[BookmarkEarlGreyUI openBookmarks]; [BookmarkEarlGreyUI openBookmarks];
[BookmarkEarlGreyUI openMobileBookmarks];
// Assert that there are no bookmarks. // Assert that there are no bookmarks.
[[EarlGrey selectElementWithMatcher:NoBookmarksLabel()] if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
assertWithMatcher:grey_notNil()]; // The empty background appears in the root directory if the leaf folders
// are empty.
[BookmarkEarlGreyUI verifyEmptyBackgroundAppears];
} else {
[BookmarkEarlGreyUI openMobileBookmarks];
[[EarlGrey selectElementWithMatcher:NoBookmarksLabel()]
assertWithMatcher:grey_notNil()];
}
} }
// Tests that signing out from a managed user account clears the user's data. // Tests that signing out from a managed user account clears the user's data.
...@@ -249,11 +255,17 @@ id<GREYMatcher> NoBookmarksLabel() { ...@@ -249,11 +255,17 @@ id<GREYMatcher> NoBookmarksLabel() {
// Open the Bookmarks screen on the Tools menu. // Open the Bookmarks screen on the Tools menu.
[BookmarkEarlGreyUI openBookmarks]; [BookmarkEarlGreyUI openBookmarks];
[BookmarkEarlGreyUI openMobileBookmarks];
// Assert that there are no bookmarks. // Assert that there are no bookmarks.
[[EarlGrey selectElementWithMatcher:NoBookmarksLabel()] if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
assertWithMatcher:grey_notNil()]; // The empty background appears in the root directory if the leaf folders
// are empty.
[BookmarkEarlGreyUI verifyEmptyBackgroundAppears];
} else {
[BookmarkEarlGreyUI openMobileBookmarks];
[[EarlGrey selectElementWithMatcher:NoBookmarksLabel()]
assertWithMatcher:grey_notNil()];
}
} }
// Tests that given two accounts A and B that are available on the device - // Tests that given two accounts A and B that are available on the device -
......
...@@ -3595,6 +3595,21 @@ ...@@ -3595,6 +3595,21 @@
] ]
} }
], ],
"IllustratedEmptyStates": [
{
"platforms": [
"ios"
],
"experiments": [
{
"name": "Enabled",
"enable_features": [
"IllustratedEmptyStates"
]
}
]
}
],
"IncludeBetaForumMenuItem": [ "IncludeBetaForumMenuItem": [
{ {
"platforms": [ "platforms": [
......
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