Commit 28cfaa2a authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[ios] Add EG test for translate pages settings UI

Bug: 1131052
Change-Id: I62f8a29ba1fdaefb5912ebad8a9512546f61c371
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2443692Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814747}
parent 749d2dd1
...@@ -182,6 +182,7 @@ source_set("eg2_tests") { ...@@ -182,6 +182,7 @@ source_set("eg2_tests") {
"//ios/chrome/browser/ui/settings:constants", "//ios/chrome/browser/ui/settings:constants",
"//ios/chrome/browser/ui/settings/autofill:constants", "//ios/chrome/browser/ui/settings/autofill:constants",
"//ios/chrome/browser/ui/settings/elements:constants", "//ios/chrome/browser/ui/settings/elements:constants",
"//ios/chrome/browser/ui/settings/language:language_ui_constants",
"//ios/chrome/browser/ui/settings/password:password_constants", "//ios/chrome/browser/ui/settings/password:password_constants",
"//ios/chrome/browser/ui/table_view/cells:cells_constants", "//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/test/earl_grey:eg_test_support+eg2", "//ios/chrome/test/earl_grey:eg_test_support+eg2",
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#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/settings/autofill/autofill_constants.h" #import "ios/chrome/browser/ui/settings/autofill/autofill_constants.h"
#import "ios/chrome/browser/ui/settings/elements/elements_constants.h" #import "ios/chrome/browser/ui/settings/elements/elements_constants.h"
#import "ios/chrome/browser/ui/settings/language/language_settings_ui_constants.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h" #import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
#import "ios/chrome/browser/ui/settings/settings_table_view_controller_constants.h" #import "ios/chrome/browser/ui/settings/settings_table_view_controller_constants.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
...@@ -208,7 +209,7 @@ void VerifyManagedSettingItem(NSString* accessibilityID, ...@@ -208,7 +209,7 @@ void VerifyManagedSettingItem(NSString* accessibilityID,
GREYAssertFalse( GREYAssertFalse(
[ChromeEarlGrey userBooleanPref:autofill::prefs::kAutofillProfileEnabled], [ChromeEarlGrey userBooleanPref:autofill::prefs::kAutofillProfileEnabled],
@"Preference was unexpectedly true"); @"Preference was unexpectedly true");
// Open settings menu and tap Address and More settings. // Open settings menu and tap Address and More setting.
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI [ChromeEarlGreyUI
tapSettingsMenuButton:chrome_test_util::AddressesAndMoreButton()]; tapSettingsMenuButton:chrome_test_util::AddressesAndMoreButton()];
...@@ -225,7 +226,7 @@ void VerifyManagedSettingItem(NSString* accessibilityID, ...@@ -225,7 +226,7 @@ void VerifyManagedSettingItem(NSString* accessibilityID,
[ChromeEarlGrey [ChromeEarlGrey
userBooleanPref:autofill::prefs::kAutofillCreditCardEnabled], userBooleanPref:autofill::prefs::kAutofillCreditCardEnabled],
@"Preference was unexpectedly true"); @"Preference was unexpectedly true");
// Open settings menu and tap Payment Method settings. // Open settings menu and tap Payment Method setting.
[ChromeEarlGreyUI openSettingsMenu]; [ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI [ChromeEarlGreyUI
tapSettingsMenuButton:chrome_test_util::PaymentMethodsButton()]; tapSettingsMenuButton:chrome_test_util::PaymentMethodsButton()];
...@@ -349,6 +350,18 @@ void VerifyManagedSettingItem(NSString* accessibilityID, ...@@ -349,6 +350,18 @@ void VerifyManagedSettingItem(NSString* accessibilityID,
@"block_popups_settings_view_controller"); @"block_popups_settings_view_controller");
} }
- (void)testTranslateEnabledSettingsUI {
// Disable TranslateEnabled policy.
SetPolicy(false, policy::key::kTranslateEnabled);
// Open settings menu and tap Languages setting.
[ChromeEarlGreyUI openSettingsMenu];
[ChromeEarlGreyUI tapSettingsMenuButton:chrome_test_util::LanguagesButton()];
VerifyManagedSettingItem(kTranslateManagedAccessibilityIdentifier,
kLanguageSettingsTableViewAccessibilityIdentifier);
}
// Test whether the managed item will be shown if a policy is set. // Test whether the managed item will be shown if a policy is set.
- (void)testPopupMenuItem { - (void)testPopupMenuItem {
// Setup a machine level policy. // Setup a machine level policy.
......
...@@ -188,6 +188,9 @@ id<GREYMatcher> AddressesAndMoreButton(); ...@@ -188,6 +188,9 @@ id<GREYMatcher> AddressesAndMoreButton();
// Returns matcher for the "Payment Methods" button in the settings menu. // Returns matcher for the "Payment Methods" button in the settings menu.
id<GREYMatcher> PaymentMethodsButton(); id<GREYMatcher> PaymentMethodsButton();
// Returns matcher for the "Languages" button in the settings menu.
id<GREYMatcher> LanguagesButton();
// Returns matcher for the "Add Credit Card" view in the Settings menu. // Returns matcher for the "Add Credit Card" view in the Settings menu.
id<GREYMatcher> AddCreditCardView(); id<GREYMatcher> AddCreditCardView();
......
...@@ -239,6 +239,10 @@ id<GREYMatcher> PaymentMethodsButton() { ...@@ -239,6 +239,10 @@ id<GREYMatcher> PaymentMethodsButton() {
return [ChromeMatchersAppInterface paymentMethodsButton]; return [ChromeMatchersAppInterface paymentMethodsButton];
} }
id<GREYMatcher> LanguagesButton() {
return [ChromeMatchersAppInterface languagesButton];
}
id<GREYMatcher> AddCreditCardView() { id<GREYMatcher> AddCreditCardView() {
return [ChromeMatchersAppInterface addCreditCardView]; return [ChromeMatchersAppInterface addCreditCardView];
} }
......
...@@ -192,6 +192,9 @@ ...@@ -192,6 +192,9 @@
// Returns matcher for the "Payment Methods" button in the settings menu. // Returns matcher for the "Payment Methods" button in the settings menu.
+ (id<GREYMatcher>)paymentMethodsButton; + (id<GREYMatcher>)paymentMethodsButton;
// Returns matcher for the "Languages" button in the settings menu.
+ (id<GREYMatcher>)languagesButton;
// Returns matcher for the "Add Credit Card" view in the Settings menu. // Returns matcher for the "Add Credit Card" view in the Settings menu.
+ (id<GREYMatcher>)addCreditCardView; + (id<GREYMatcher>)addCreditCardView;
......
...@@ -476,6 +476,10 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id, ...@@ -476,6 +476,10 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id,
buttonWithAccessibilityLabelID:(IDS_AUTOFILL_PAYMENT_METHODS)]; buttonWithAccessibilityLabelID:(IDS_AUTOFILL_PAYMENT_METHODS)];
} }
+ (id<GREYMatcher>)languagesButton {
return grey_accessibilityID(kSettingsLanguagesCellId);
}
+ (id<GREYMatcher>)addCreditCardView { + (id<GREYMatcher>)addCreditCardView {
return grey_accessibilityID(kAddCreditCardViewID); return grey_accessibilityID(kAddCreditCardViewID);
} }
......
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