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

[Empties] Fix empties EG tests.

Some of the tests were not working with the new illustrated empty
states. An interface needed to be added to access the feature status
in Chrome app as opposed to the test app.

Change-Id: I1f7bf0e3d8e3e17cdbfca8948377e5086ae78059
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2378714
Commit-Queue: sebsg <sebsg@chromium.org>
Auto-Submit: sebsg <sebsg@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803149}
parent bc3738b8
......@@ -362,7 +362,7 @@ id<GREYMatcher> SearchIconButton() {
- (void)verifyEmptyBackgroundAppears {
id<GREYMatcher> emptyBackground =
grey_accessibilityID(base::FeatureList::IsEnabled(kIllustratedEmptyStates)
grey_accessibilityID([ChromeEarlGrey isIllustratedEmptyStatesEnabled]
? kTableViewIllustratedEmptyViewID
: kBookmarkEmptyStateExplanatoryLabelIdentifier);
[[EarlGrey selectElementWithMatcher:emptyBackground]
......@@ -375,7 +375,7 @@ id<GREYMatcher> SearchIconButton() {
id<GREYInteraction> searchBar =
[EarlGrey selectElementWithMatcher:grey_accessibilityTrait(
UIAccessibilityTraitSearchField)];
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) {
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
// With the illustrated empty state, the search bar should be hidden.
[searchBar assertWithMatcher:grey_nil()];
} else {
......
......@@ -583,7 +583,7 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
[ChromeEarlGreyUI openAndClearBrowsingDataFromHistory];
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) {
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
// Toolbar should only contain CBD button and the background should contain
// the Illustrated empty view
[[EarlGrey selectElementWithMatcher:chrome_test_util::
......
......@@ -196,6 +196,7 @@ source_set("eg2_tests") {
"//ios/web/public/navigation:navigation",
"//net",
"//net:test_support",
"//ui/base",
]
frameworks = [ "UIKit.framework" ]
}
......
......@@ -36,6 +36,7 @@
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/embedded_test_server/request_handler_util.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -966,16 +967,43 @@ void AssertIsShowingDistillablePage(bool online, const GURL& distillable_url) {
@"Unable to add Reading List entry.");
}
// Delete them from the Reading List view.
OpenReadingList();
[[EarlGrey selectElementWithMatcher:EmptyBackground()]
assertWithMatcher:grey_nil()];
// Make sure the Reading List view is not empty.
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kTableViewIllustratedEmptyViewID)]
assertWithMatcher:grey_nil()];
id<GREYMatcher> noReadingListMessageMatcher = grey_allOf(
grey_text(
l10n_util::GetNSString(IDS_IOS_READING_LIST_NO_ENTRIES_MESSAGE)),
grey_sufficientlyVisible(), nil);
[[EarlGrey selectElementWithMatcher:noReadingListMessageMatcher]
assertWithMatcher:grey_nil()];
} else {
[[EarlGrey selectElementWithMatcher:EmptyBackground()]
assertWithMatcher:grey_nil()];
}
// Delete them from the Reading List view.
TapToolbarButtonWithID(kReadingListToolbarEditButtonID);
TapToolbarButtonWithID(kReadingListToolbarDeleteAllReadButtonID);
// Verify the background string is displayed.
[[EarlGrey selectElementWithMatcher:EmptyBackground()]
assertWithMatcher:grey_notNil()];
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kTableViewIllustratedEmptyViewID)]
assertWithMatcher:grey_notNil()];
id<GREYMatcher> noReadingListMessageMatcher = grey_allOf(
grey_text(
l10n_util::GetNSString(IDS_IOS_READING_LIST_NO_ENTRIES_MESSAGE)),
grey_sufficientlyVisible(), nil);
[[EarlGrey selectElementWithMatcher:noReadingListMessageMatcher]
assertWithMatcher:grey_notNil()];
} else {
[[EarlGrey selectElementWithMatcher:EmptyBackground()]
assertWithMatcher:grey_notNil()];
}
}
// Tests that the VC can be dismissed by swiping down.
......
......@@ -254,7 +254,7 @@ id<GREYMatcher> TitleOfTestPage() {
grey_allOf(chrome_test_util::StaticTextWithAccessibilityLabelId(
IDS_IOS_RECENT_TABS_RECENTLY_CLOSED_EMPTY),
grey_sufficientlyVisible(), nil)];
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) {
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
[detailTextCell assertWithMatcher:grey_notNil()];
} else {
[detailTextCell assertWithMatcher:grey_nil()];
......@@ -272,7 +272,7 @@ id<GREYMatcher> TitleOfTestPage() {
grey_accessibilityID(
kRecentTabsOtherDevicesIllustratedCellAccessibilityIdentifier),
grey_sufficientlyVisible(), nil)];
if (base::FeatureList::IsEnabled(kIllustratedEmptyStates)) {
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
[illustratedCell assertWithMatcher:grey_notNil()];
} else {
[illustratedCell assertWithMatcher:grey_nil()];
......
......@@ -224,6 +224,7 @@ source_set("eg_test_support+eg2") {
"//ios/chrome/browser/ui/settings/password:eg_test_support+eg2",
"//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants",
"//ios/chrome/browser/ui/tab_grid/grid:grid_ui_constants",
"//ios/chrome/browser/ui/table_view:constants",
"//ios/chrome/browser/ui/toolbar:eg_test_support+eg2",
"//ios/testing:http_server_bundle_data",
"//ios/testing:nserror_support",
......
......@@ -523,6 +523,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// Returns whether the mobile version of the websites are requested by default.
- (BOOL)isMobileModeByDefault WARN_UNUSED_RESULT;
// Returns whether the illustrated empty stated feature is enabled.
- (BOOL)isIllustratedEmptyStatesEnabled;
#pragma mark - Popup Blocking
// Gets the current value of the popup content setting preference for the
......
......@@ -945,6 +945,10 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return [ChromeEarlGreyAppInterface isMobileModeByDefault];
}
- (BOOL)isIllustratedEmptyStatesEnabled {
return [ChromeEarlGreyAppInterface isIllustratedEmptyStatesEnabled];
}
#pragma mark - ScopedBlockPopupsPref
- (ContentSetting)popupPrefValue {
......
......@@ -433,6 +433,9 @@
// Returns whether the mobile version of the websites are requested by default.
+ (BOOL)isMobileModeByDefault WARN_UNUSED_RESULT;
// Returns whether the illustrated empty states feature is enabled.
+ (BOOL)isIllustratedEmptyStatesEnabled;
#pragma mark - Popup Blocking
// Gets the current value of the popup content setting preference for the
......
......@@ -768,6 +768,10 @@ NSString* SerializedPref(const PrefService::Preference* pref) {
return webClientUserAgent == web::UserAgentType::MOBILE;
}
+ (BOOL)isIllustratedEmptyStatesEnabled {
return base::FeatureList::IsEnabled(kIllustratedEmptyStates);
}
#pragma mark - ScopedBlockPopupsPref
+ (ContentSetting)popupPrefValue {
......
......@@ -7,7 +7,9 @@
#import "base/test/ios/wait_util.h"
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/browser/ui/table_view/table_view_constants.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -174,11 +176,23 @@ class ScopedDisableTimerTracking {
}
- (void)assertHistoryHasNoEntries {
id<GREYMatcher> noHistoryMessageMatcher =
grey_allOf(grey_text(l10n_util::GetNSString(IDS_HISTORY_NO_RESULTS)),
grey_sufficientlyVisible(), nil);
[[EarlGrey selectElementWithMatcher:noHistoryMessageMatcher]
assertWithMatcher:grey_notNil()];
if ([ChromeEarlGrey isIllustratedEmptyStatesEnabled]) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(
kTableViewIllustratedEmptyViewID)]
assertWithMatcher:grey_notNil()];
id<GREYMatcher> noHistoryMessageMatcher = grey_allOf(
grey_text(l10n_util::GetNSString(IDS_IOS_HISTORY_EMPTY_TITLE)),
grey_sufficientlyVisible(), nil);
[[EarlGrey selectElementWithMatcher:noHistoryMessageMatcher]
assertWithMatcher:grey_notNil()];
} else {
id<GREYMatcher> noHistoryMessageMatcher =
grey_allOf(grey_text(l10n_util::GetNSString(IDS_HISTORY_NO_RESULTS)),
grey_sufficientlyVisible(), nil);
[[EarlGrey selectElementWithMatcher:noHistoryMessageMatcher]
assertWithMatcher:grey_notNil()];
}
id<GREYMatcher> historyEntryMatcher =
grey_allOf(grey_kindOfClassName(@"TableViewURLCell"),
......
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