Commit 63a68852 authored by Ewann's avatar Ewann Committed by Commit Bot

[IOS] Fixes tests related to EnableCloseAllTabsConfirmation feature

This CL fixes tests impacted by the EnableCloseAllTabsConfirmation
feature before submitting the config.

Bug: 1119319
Change-Id: I32c86bcc8f6132fbd93d04578e7cbc9d4460d543
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443852
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824851}
parent 46988eba
...@@ -125,6 +125,7 @@ source_set("eg2_tests") { ...@@ -125,6 +125,7 @@ source_set("eg2_tests") {
"//components/safe_browsing/core/common:safe_browsing_prefs", "//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/strings:components_strings_grit", "//components/strings:components_strings_grit",
"//ios/chrome/browser/ui/bookmarks:eg_test_support+eg2", "//ios/chrome/browser/ui/bookmarks:eg_test_support+eg2",
"//ios/chrome/browser/ui/tab_grid:features",
"//ios/chrome/test/earl_grey:eg_test_support+eg2", "//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2", "//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib", "//ios/third_party/earl_grey2:test_lib",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey.h"
#import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey_ui.h" #import "ios/chrome/browser/ui/bookmarks/bookmark_earl_grey_ui.h"
#import "ios/chrome/browser/ui/tab_grid/features.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_app_interface.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
...@@ -98,6 +99,11 @@ std::unique_ptr<net::test_server::HttpResponse> HandleRequest( ...@@ -98,6 +99,11 @@ std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
AppLaunchConfiguration config; AppLaunchConfiguration config;
config.features_enabled.push_back(safe_browsing::kSafeBrowsingAvailableOnIOS); config.features_enabled.push_back(safe_browsing::kSafeBrowsingAvailableOnIOS);
config.features_enabled.push_back(safe_browsing::kRealTimeUrlLookupEnabled); config.features_enabled.push_back(safe_browsing::kRealTimeUrlLookupEnabled);
// EnableCloseAllTabsConfirmation feature is disabled in order to be able to
// restore session from |triggerRestoreViaTabGridRemoveAllUndo|.
// TODO(crbug.com/1146391): Remove dependency on
// kEnableCloseAllTabsConfirmation flag.
config.features_disabled.push_back(kEnableCloseAllTabsConfirmation);
// Use commandline args to insert fake unsafe URLs into the Safe Browsing // Use commandline args to insert fake unsafe URLs into the Safe Browsing
// database. // database.
......
...@@ -175,6 +175,7 @@ source_set("eg2_tests") { ...@@ -175,6 +175,7 @@ source_set("eg2_tests") {
"//components/strings", "//components/strings",
"//components/version_info", "//components/version_info",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui/tab_grid:features",
"//ios/chrome/test/earl_grey:eg_test_support+eg2", "//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2", "//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib", "//ios/third_party/earl_grey2:test_lib",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_constants.h"
#import "ios/chrome/browser/ui/tab_grid/features.h"
#include "ios/chrome/grit/ios_strings.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_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
...@@ -122,6 +123,12 @@ class UserAgentResponseProvider : public web::DataResponseProvider { ...@@ -122,6 +123,12 @@ class UserAgentResponseProvider : public web::DataResponseProvider {
@implementation RequestDesktopMobileSiteTestCase @implementation RequestDesktopMobileSiteTestCase
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
config.features_disabled.push_back(kEnableCloseAllTabsConfirmation);
return config;
}
#pragma mark - Helpers #pragma mark - Helpers
- (GREYElementInteraction*)defaultRequestButton { - (GREYElementInteraction*)defaultRequestButton {
...@@ -315,8 +322,11 @@ class UserAgentResponseProvider : public web::DataResponseProvider { ...@@ -315,8 +322,11 @@ class UserAgentResponseProvider : public web::DataResponseProvider {
[[self defaultRequestButton] performAction:grey_tap()]; [[self defaultRequestButton] performAction:grey_tap()];
[ChromeEarlGrey waitForWebStateContainingText:[self nonDefaultLabel]]; [ChromeEarlGrey waitForWebStateContainingText:[self nonDefaultLabel]];
// Go back to NTP to restore the session from there.
[ChromeEarlGrey goBack]; [ChromeEarlGrey goBack];
[[EarlGrey selectElementWithMatcher:chrome_test_util::FakeOmnibox()]
assertWithMatcher:grey_sufficientlyVisible()];
// Go back to NTP to restore the session from there.
[ChromeEarlGrey triggerRestoreViaTabGridRemoveAllUndo]; [ChromeEarlGrey triggerRestoreViaTabGridRemoveAllUndo];
// Make sure that the NTP is displayed. // Make sure that the NTP is displayed.
......
...@@ -194,6 +194,7 @@ source_set("eg2_tests") { ...@@ -194,6 +194,7 @@ source_set("eg2_tests") {
":tab_grid_ui_constants", ":tab_grid_ui_constants",
"//base", "//base",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui/tab_grid:features",
"//ios/chrome/test/earl_grey:eg_test_support+eg2", "//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2", "//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib", "//ios/third_party/earl_grey2:test_lib",
......
...@@ -10,4 +10,7 @@ ...@@ -10,4 +10,7 @@
// Feature to enable Close All Tabs confirmation. // Feature to enable Close All Tabs confirmation.
extern const base::Feature kEnableCloseAllTabsConfirmation; extern const base::Feature kEnableCloseAllTabsConfirmation;
// Whether the kCloseAllTabsConfirmation flag is enabled.
bool IsCloseAllTabsConfirmationEnabled();
#endif // IOS_CHROME_BROWSER_UI_TAB_GRID_FEATURES_H_ #endif // IOS_CHROME_BROWSER_UI_TAB_GRID_FEATURES_H_
...@@ -10,3 +10,7 @@ ...@@ -10,3 +10,7 @@
const base::Feature kEnableCloseAllTabsConfirmation{ const base::Feature kEnableCloseAllTabsConfirmation{
"EnableCloseAllTabsConfirmation", base::FEATURE_DISABLED_BY_DEFAULT}; "EnableCloseAllTabsConfirmation", base::FEATURE_DISABLED_BY_DEFAULT};
bool IsCloseAllTabsConfirmationEnabled() {
return base::FeatureList::IsEnabled(kEnableCloseAllTabsConfirmation);
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#import "ios/chrome/browser/ui/tab_grid/features.h"
#import "ios/chrome/browser/ui/tab_grid/tab_grid_constants.h" #import "ios/chrome/browser/ui/tab_grid/tab_grid_constants.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
...@@ -38,6 +39,22 @@ char kResponse3[] = "Test Page 3 content"; ...@@ -38,6 +39,22 @@ char kResponse3[] = "Test Page 3 content";
@implementation TabGridTestCase @implementation TabGridTestCase
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
// Features are enabled or disabled based on the name of the test that is
// running. This is done because it is inefficient to use
// ensureAppLaunchedWithConfiguration for each test.
if ([self isRunningTest:@selector(testCloseAllAndUndoCloseAll)] ||
[self isRunningTest:@selector
(testUndoCloseAllNotAvailableAfterNewTabCreation)]) {
config.features_disabled.push_back(kEnableCloseAllTabsConfirmation);
} else {
config.features_enabled.push_back(kEnableCloseAllTabsConfirmation);
}
return config;
}
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
...@@ -119,7 +136,6 @@ char kResponse3[] = "Test Page 3 content"; ...@@ -119,7 +136,6 @@ char kResponse3[] = "Test Page 3 content";
performAction:grey_tap()]; performAction:grey_tap()];
[[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridCloseAllButton()] [[EarlGrey selectElementWithMatcher:chrome_test_util::TabGridCloseAllButton()]
performAction:grey_tap()]; performAction:grey_tap()];
// Undo is available after close all action.
[[EarlGrey [[EarlGrey
selectElementWithMatcher:chrome_test_util::TabGridUndoCloseAllButton()] selectElementWithMatcher:chrome_test_util::TabGridUndoCloseAllButton()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
......
...@@ -869,7 +869,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -869,7 +869,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
topToolbar.leadingButton.title = topToolbar.leadingButton.title =
l10n_util::GetNSString(IDS_IOS_TAB_GRID_CLOSE_ALL_BUTTON); l10n_util::GetNSString(IDS_IOS_TAB_GRID_CLOSE_ALL_BUTTON);
topToolbar.leadingButton.target = self; topToolbar.leadingButton.target = self;
if (base::FeatureList::IsEnabled(kEnableCloseAllTabsConfirmation)) { if (IsCloseAllTabsConfirmationEnabled()) {
topToolbar.leadingButton.action = topToolbar.leadingButton.action =
@selector(closeAllButtonTappedShowConfirmation); @selector(closeAllButtonTappedShowConfirmation);
} else { } else {
...@@ -913,7 +913,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -913,7 +913,7 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
]]; ]];
bottomToolbar.leadingButton.target = self; bottomToolbar.leadingButton.target = self;
if (base::FeatureList::IsEnabled(kEnableCloseAllTabsConfirmation)) { if (IsCloseAllTabsConfirmationEnabled()) {
bottomToolbar.leadingButton.action = bottomToolbar.leadingButton.action =
@selector(closeAllButtonTappedShowConfirmation); @selector(closeAllButtonTappedShowConfirmation);
} else { } else {
......
...@@ -139,6 +139,7 @@ source_set("eg_app_support+eg2") { ...@@ -139,6 +139,7 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ui/settings/password:password_constants", "//ios/chrome/browser/ui/settings/password:password_constants",
"//ios/chrome/browser/ui/settings/privacy:privacy_ui", "//ios/chrome/browser/ui/settings/privacy:privacy_ui",
"//ios/chrome/browser/ui/settings/sync", "//ios/chrome/browser/ui/settings/sync",
"//ios/chrome/browser/ui/tab_grid:features",
"//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants", "//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants",
"//ios/chrome/browser/ui/tab_grid/grid:grid_ui_constants", "//ios/chrome/browser/ui/tab_grid/grid:grid_ui_constants",
"//ios/chrome/browser/ui/table_view:feature_flags", "//ios/chrome/browser/ui/table_view:feature_flags",
......
...@@ -534,6 +534,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error); ...@@ -534,6 +534,9 @@ id ExecuteJavaScript(NSString* javascript, NSError* __autoreleasing* out_error);
// can, open multiple windows. // can, open multiple windows.
- (BOOL)areMultipleWindowsSupported; - (BOOL)areMultipleWindowsSupported;
// Returns whether the Close All Tabs Confirmation feature is enabled.
- (BOOL)isCloseAllTabsConfirmationEnabled;
#pragma mark - Popup Blocking #pragma mark - Popup Blocking
// Gets the current value of the popup content setting preference for the // Gets the current value of the popup content setting preference for the
......
...@@ -929,6 +929,10 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface) ...@@ -929,6 +929,10 @@ GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(ChromeEarlGreyAppInterface)
return [ChromeEarlGreyAppInterface areMultipleWindowsSupported]; return [ChromeEarlGreyAppInterface areMultipleWindowsSupported];
} }
- (BOOL)isCloseAllTabsConfirmationEnabled {
return [ChromeEarlGreyAppInterface isCloseAllTabsConfirmationEnabled];
}
#pragma mark - ScopedBlockPopupsPref #pragma mark - ScopedBlockPopupsPref
- (ContentSetting)popupPrefValue { - (ContentSetting)popupPrefValue {
......
...@@ -449,6 +449,9 @@ ...@@ -449,6 +449,9 @@
// can, open multiple windows. // can, open multiple windows.
+ (BOOL)areMultipleWindowsSupported; + (BOOL)areMultipleWindowsSupported;
// Returns whether the Close All Tabs Confirmation feature is enabled.
+ (BOOL)isCloseAllTabsConfirmationEnabled;
#pragma mark - Popup Blocking #pragma mark - Popup Blocking
// Gets the current value of the popup content setting preference for the // Gets the current value of the popup content setting preference for the
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import "ios/chrome/browser/ntp/features.h" #import "ios/chrome/browser/ntp/features.h"
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/settings/autofill/features.h" #import "ios/chrome/browser/ui/settings/autofill/features.h"
#import "ios/chrome/browser/ui/tab_grid/features.h"
#import "ios/chrome/browser/ui/table_view/feature_flags.h" #import "ios/chrome/browser/ui/table_view/feature_flags.h"
#import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/menu_util.h" #import "ios/chrome/browser/ui/util/menu_util.h"
...@@ -836,6 +837,10 @@ NSString* SerializedPref(const PrefService::Preference* pref) { ...@@ -836,6 +837,10 @@ NSString* SerializedPref(const PrefService::Preference* pref) {
return IsMultipleScenesSupported(); return IsMultipleScenesSupported();
} }
+ (BOOL)isCloseAllTabsConfirmationEnabled {
return IsCloseAllTabsConfirmationEnabled();
}
#pragma mark - ScopedBlockPopupsPref #pragma mark - ScopedBlockPopupsPref
+ (ContentSetting)popupPrefValue { + (ContentSetting)popupPrefValue {
......
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