Commit c273c91d authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Move password settings tests to EG2

Bug: 987646
Change-Id: I9e21ec812293136797b80af8c4b189331941a111
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903363Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: David Jean <djean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715258}
parent 6b75798b
...@@ -29,6 +29,7 @@ source_set("cells") { ...@@ -29,6 +29,7 @@ source_set("cells") {
"//ios/chrome/browser/ui/settings/cells:public", "//ios/chrome/browser/ui/settings/cells:public",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
......
...@@ -90,6 +90,7 @@ source_set("history_ui") { ...@@ -90,6 +90,7 @@ source_set("history_ui") {
"//ios/chrome/browser/ui/table_view:presentation", "//ios/chrome/browser/ui/table_view:presentation",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/browser/url_loading", "//ios/chrome/browser/url_loading",
"//ios/chrome/common/favicon", "//ios/chrome/common/favicon",
......
...@@ -26,6 +26,7 @@ source_set("modals") { ...@@ -26,6 +26,7 @@ source_set("modals") {
"//ios/chrome/browser/passwords:public", "//ios/chrome/browser/passwords:public",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ui/base", "//ui/base",
] ]
......
...@@ -85,6 +85,7 @@ source_set("recent_tabs_ui") { ...@@ -85,6 +85,7 @@ source_set("recent_tabs_ui") {
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:presentation", "//ios/chrome/browser/ui/table_view:presentation",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/browser/url_loading", "//ios/chrome/browser/url_loading",
"//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list",
......
...@@ -44,6 +44,7 @@ source_set("send_tab_to_self_ui") { ...@@ -44,6 +44,7 @@ source_set("send_tab_to_self_ui") {
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ui/base", "//ui/base",
] ]
......
...@@ -15,6 +15,7 @@ source_set("settings_root") { ...@@ -15,6 +15,7 @@ source_set("settings_root") {
"settings_root_view_controlling.h", "settings_root_view_controlling.h",
] ]
deps = [ deps = [
":settings_root_constants",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui:feature_flags",
...@@ -37,6 +38,17 @@ source_set("settings_root") { ...@@ -37,6 +38,17 @@ source_set("settings_root") {
] ]
} }
source_set("settings_root_constants") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"settings_root_table_constants.h",
"settings_root_table_constants.mm",
]
deps = [
"//base",
]
}
source_set("settings") { source_set("settings") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
...@@ -169,6 +181,7 @@ source_set("settings") { ...@@ -169,6 +181,7 @@ source_set("settings") {
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/table_view/cells/resources:table_view_cell_check_mark", "//ios/chrome/browser/ui/table_view/cells/resources:table_view_cell_check_mark",
"//ios/chrome/browser/voice", "//ios/chrome/browser/voice",
"//ios/chrome/browser/web:web", "//ios/chrome/browser/web:web",
......
...@@ -53,6 +53,7 @@ source_set("autofill") { ...@@ -53,6 +53,7 @@ source_set("autofill") {
"//ios/chrome/browser/ui/settings/credit_card_scanner", "//ios/chrome/browser/ui/settings/credit_card_scanner",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ui/base", "//ui/base",
......
...@@ -10,6 +10,7 @@ source_set("cells") { ...@@ -10,6 +10,7 @@ source_set("cells") {
deps = [ deps = [
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
] ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
......
...@@ -50,6 +50,7 @@ source_set("cells") { ...@@ -50,6 +50,7 @@ source_set("cells") {
"//ios/chrome/browser/ui/icons", "//ios/chrome/browser/ui/icons",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
......
...@@ -55,6 +55,7 @@ source_set("clear_browsing_data") { ...@@ -55,6 +55,7 @@ source_set("clear_browsing_data") {
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/common", "//ios/chrome/common",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
......
...@@ -69,6 +69,7 @@ source_set("google_services") { ...@@ -69,6 +69,7 @@ source_set("google_services") {
"//ios/chrome/browser/ui/settings/utils", "//ios/chrome/browser/ui/settings/utils",
"//ios/chrome/browser/ui/signin_interaction", "//ios/chrome/browser/ui/signin_interaction",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
......
...@@ -53,6 +53,7 @@ source_set("language_ui") { ...@@ -53,6 +53,7 @@ source_set("language_ui") {
"//ios/chrome/browser/ui/settings/language/cells", "//ios/chrome/browser/ui/settings/language/cells",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
......
...@@ -17,6 +17,7 @@ source_set("password") { ...@@ -17,6 +17,7 @@ source_set("password") {
"reauthentication_protocol.h", "reauthentication_protocol.h",
] ]
deps = [ deps = [
":password_constants",
"//base", "//base",
"//components/autofill/core/common", "//components/autofill/core/common",
"//components/google/core/common", "//components/google/core/common",
...@@ -40,6 +41,7 @@ source_set("password") { ...@@ -40,6 +41,7 @@ source_set("password") {
"//ios/chrome/browser/ui/settings/utils", "//ios/chrome/browser/ui/settings/utils",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
...@@ -49,6 +51,17 @@ source_set("password") { ...@@ -49,6 +51,17 @@ source_set("password") {
] ]
} }
source_set("password_constants") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"passwords_table_view_constants.h",
"passwords_table_view_constants.mm",
]
deps = [
"//base",
]
}
source_set("test_support") { source_set("test_support") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
...@@ -87,6 +100,7 @@ source_set("unit_tests") { ...@@ -87,6 +100,7 @@ source_set("unit_tests") {
"//ios/chrome/browser/passwords", "//ios/chrome/browser/passwords",
"//ios/chrome/browser/ui/table_view:test_support", "//ios/chrome/browser/ui/table_view:test_support",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/browser/web:test_support", "//ios/chrome/browser/web:test_support",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
...@@ -102,11 +116,13 @@ source_set("unit_tests") { ...@@ -102,11 +116,13 @@ source_set("unit_tests") {
] ]
} }
source_set("eg_tests") { source_set("eg_test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
"passwords_settings_egtest.mm", "passwords_settings_app_interface.h",
"passwords_settings_app_interface.mm",
] ]
deps = [ deps = [
":password", ":password",
...@@ -117,16 +133,37 @@ source_set("eg_tests") { ...@@ -117,16 +133,37 @@ source_set("eg_tests") {
"//components/password_manager/core/browser", "//components/password_manager/core/browser",
"//components/password_manager/core/common", "//components/password_manager/core/common",
"//components/prefs", "//components/prefs",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/passwords",
"//ios/chrome/test/app:test_support",
"//ios/third_party/material_components_ios",
"//url",
]
}
source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"passwords_settings_egtest.mm",
]
deps = [
":eg_test_support",
":password_constants",
"//base",
"//base/test:test_support",
"//components/strings", "//components/strings",
"//components/ukm/ios:features", "//components/ukm/ios:features",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/passwords", "//ios/chrome/browser/passwords",
"//ios/chrome/browser/ui/settings", "//ios/chrome/browser/ui/settings:settings_root_constants",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
"//ios/web:earl_grey_test_support", "//ios/web:earl_grey_test_support",
"//ios/web/public/test:element_selector", "//ios/web/public/test:element_selector",
...@@ -136,3 +173,78 @@ source_set("eg_tests") { ...@@ -136,3 +173,78 @@ source_set("eg_tests") {
"//url", "//url",
] ]
} }
source_set("eg_app_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"passwords_settings_app_interface.h",
"passwords_settings_app_interface.mm",
]
deps = [
":password",
"//base",
"//base/test:test_support",
"//components/autofill/core/common",
"//components/keyed_service/core",
"//components/password_manager/core/browser",
"//components/password_manager/core/common",
"//components/prefs",
"//components/strings:components_strings_grit",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/browser_state",
"//ios/chrome/browser/passwords",
"//ios/chrome/test/app:test_support",
"//ios/testing/earl_grey:eg_app_support+eg2",
"//ios/third_party/material_components_ios",
"//url",
]
}
source_set("eg_test_support+eg2") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"passwords_settings_app_interface.h",
]
}
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"passwords_settings_egtest.mm",
]
deps = [
":eg_test_support+eg2",
":password_constants",
"//base:base",
"//base/test:test_support",
"//components/strings:components_strings_grit",
"//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser/ui/settings:settings_root_constants",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
"//ios/web/public/test:element_selector",
"//ios/web/public/test/http_server:http_server",
"//ui/base",
"//url",
]
libs = [ "UIKit.framework" ]
}
...@@ -12,10 +12,6 @@ namespace autofill { ...@@ -12,10 +12,6 @@ namespace autofill {
struct PasswordForm; struct PasswordForm;
} // namespace autofill } // namespace autofill
// The accessibility identifier of the password details table view.
extern NSString* _Nonnull const kPasswordDetailsTableViewId;
extern NSString* _Nonnull const kPasswordDetailsDeletionAlertViewId;
@protocol ReauthenticationProtocol; @protocol ReauthenticationProtocol;
// Displays details of a password item, including URL of the site, username and // Displays details of a password item, including URL of the site, username and
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h" #import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/reauthentication_module.h" #import "ios/chrome/browser/ui/settings/password/reauthentication_module.h"
#import "ios/chrome/browser/ui/settings/utils/settings_utils.h" #import "ios/chrome/browser/ui/settings/utils/settings_utils.h"
...@@ -34,10 +35,6 @@ ...@@ -34,10 +35,6 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
NSString* const kPasswordDetailsTableViewId = @"PasswordDetailsTableViewId";
NSString* const kPasswordDetailsDeletionAlertViewId =
@"PasswordDetailsDeletionAlertViewId";
namespace { namespace {
typedef NS_ENUM(NSInteger, SectionIdentifier) { typedef NS_ENUM(NSInteger, SectionIdentifier) {
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_PASSWORDS_SETTINGS_APP_INTERFACE_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_PASSWORDS_SETTINGS_APP_INTERFACE_H_
#import <UIKit/UIKit.h>
// EarlGreyScopedBlockSwizzlerAppInterface contains the app-side
// implementation for helpers. These helpers are compiled into
// the app binary and can be called from either app or test code.
@interface PasswordSettingsAppInterface : NSObject
// Sets a re-authentication mock (i.e. what asks user for fingerprint to
// view password) and its options for next test.
+ (void)setUpMockReauthenticationModule;
+ (void)setUpMockReauthenticationModuleForExport;
+ (void)mockReauthenticationModuleShouldSucceed:(BOOL)shouldSucceed;
+ (void)mockReauthenticationModuleCanAttempt:(BOOL)canAttempt;
// Dismisses snack bar. Used before next test.
+ (void)dismissSnackBar;
// Removes all credentials stored.
+ (BOOL)clearPasswordStore;
// Creates multiple password form with index being part of the username,
// password, origin and realm.
+ (void)saveExamplePasswordWithCount:(NSInteger)count;
// Creates password form for given fields.
+ (BOOL)saveExamplePassword:(NSString*)password
userName:(NSString*)userName
origin:(NSString*)origin;
// Creates a blacklisted password form for given origin.
+ (BOOL)saveExampleBlacklistedOrigin:(NSString*)origin;
// Creates a federated password form for given origins and user.
+ (BOOL)saveExampleFederatedOrigin:(NSString*)federatedOrigin
userName:(NSString*)userName
origin:(NSString*)origin;
// Gets number of password form stored.
+ (NSInteger)passwordStoreResultsCount;
// Returns YES is crdential service is enabled.
+ (BOOL)isCredentialsServiceEnabled;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_PASSWORDS_SETTINGS_APP_INTERFACE_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/chrome/browser/ui/settings/password/passwords_settings_app_interface.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "components/autofill/core/common/password_form.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_service.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/password_test_util.h"
#import "ios/third_party/material_components_ios/src/components/Snackbar/src/MaterialSnackbar.h"
#include "url/gurl.h"
#include "url/origin.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using autofill::PasswordForm;
using chrome_test_util::SetUpAndReturnMockReauthenticationModule;
using chrome_test_util::SetUpAndReturnMockReauthenticationModuleForExport;
namespace {
scoped_refptr<password_manager::PasswordStore> GetPasswordStore() {
// ServiceAccessType governs behaviour in Incognito: only modifications with
// EXPLICIT_ACCESS, which correspond to user's explicit gesture, succeed.
// This test does not deal with Incognito, and should not run in Incognito
// context. Therefore IMPLICIT_ACCESS is used to let the test fail if in
// Incognito context.
return IOSChromePasswordStoreFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState(),
ServiceAccessType::IMPLICIT_ACCESS);
}
// This class is used to obtain results from the PasswordStore and hence both
// check the success of store updates and ensure that store has finished
// processing.
class FakeStoreConsumer : public password_manager::PasswordStoreConsumer {
public:
void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> obtained) override {
obtained_ = std::move(obtained);
}
bool FetchStoreResults() {
results_.clear();
ResetObtained();
GetPasswordStore()->GetAllLogins(this);
bool responded = base::test::ios::WaitUntilConditionOrTimeout(2.0, ^bool {
return !AreObtainedReset();
});
if (responded) {
AppendObtainedToResults();
}
return responded;
}
const std::vector<autofill::PasswordForm>& GetStoreResults() {
return results_;
}
private:
// Puts |obtained_| in a known state not corresponding to any PasswordStore
// state.
void ResetObtained() {
obtained_.clear();
obtained_.emplace_back(nullptr);
}
// Returns true if |obtained_| are in the reset state.
bool AreObtainedReset() { return obtained_.size() == 1 && !obtained_[0]; }
void AppendObtainedToResults() {
for (const auto& source : obtained_) {
results_.emplace_back(*source);
}
ResetObtained();
}
// Temporary cache of obtained store results.
std::vector<std::unique_ptr<autofill::PasswordForm>> obtained_;
// Combination of fillable and blacklisted credentials from the store.
std::vector<autofill::PasswordForm> results_;
};
// Saves |form| to the password store and waits until the async processing is
// done.
bool SaveToPasswordStore(const PasswordForm& form) {
GetPasswordStore()->AddLogin(form);
// When we retrieve the form from the store, |from_store| should be set.
autofill::PasswordForm expected_form = form;
expected_form.from_store = autofill::PasswordForm::Store::kProfileStore;
// Check the result and ensure PasswordStore processed this.
FakeStoreConsumer consumer;
if (!consumer.FetchStoreResults()) {
return false;
}
for (const auto& result : consumer.GetStoreResults()) {
if (result == expected_form)
return true;
}
return false;
}
// Creates a PasswordForm with |index| being part of the username, password,
// origin and realm.
PasswordForm CreateSampleFormWithIndex(int index) {
PasswordForm form;
form.username_value =
base::ASCIIToUTF16(base::StringPrintf("concrete username %02d", index));
form.password_value =
base::ASCIIToUTF16(base::StringPrintf("concrete password %02d", index));
form.origin = GURL(base::StringPrintf("https://www%02d.example.com", index));
form.signon_realm = form.origin.spec();
return form;
}
bool ClearPasswordStore() {
GetPasswordStore()->RemoveLoginsCreatedBetween(base::Time(), base::Time(),
base::Closure());
FakeStoreConsumer consumer;
if (!consumer.FetchStoreResults()) {
return false;
}
return consumer.GetStoreResults().empty();
}
} // namespace
@implementation PasswordSettingsAppInterface
static MockReauthenticationModule* _mockReauthenticationModule;
+ (void)setUpMockReauthenticationModule {
_mockReauthenticationModule = SetUpAndReturnMockReauthenticationModule();
}
+ (void)setUpMockReauthenticationModuleForExport {
_mockReauthenticationModule =
SetUpAndReturnMockReauthenticationModuleForExport();
}
+ (void)mockReauthenticationModuleShouldSucceed:(BOOL)shouldSucceed {
_mockReauthenticationModule.shouldSucceed = shouldSucceed;
}
+ (void)mockReauthenticationModuleCanAttempt:(BOOL)canAttempt {
_mockReauthenticationModule.canAttempt = canAttempt;
}
+ (void)dismissSnackBar {
[MDCSnackbarManager
dismissAndCallCompletionBlocksWithCategory:@"PasswordsSnackbarCategory"];
}
+ (void)saveExamplePasswordWithCount:(NSInteger)count {
for (int i = 1; i <= count; ++i) {
GetPasswordStore()->AddLogin(CreateSampleFormWithIndex(i));
}
}
+ (BOOL)saveExamplePassword:(NSString*)password
userName:(NSString*)userName
origin:(NSString*)origin {
PasswordForm example;
example.username_value = base::SysNSStringToUTF16(userName);
example.password_value = base::SysNSStringToUTF16(password);
example.origin = GURL(base::SysNSStringToUTF16(origin));
example.signon_realm = example.origin.spec();
return SaveToPasswordStore(example);
}
+ (BOOL)saveExampleBlacklistedOrigin:(NSString*)origin {
PasswordForm example;
example.origin = GURL(base::SysNSStringToUTF16(origin));
example.blacklisted_by_user = true;
example.signon_realm = example.origin.spec();
return SaveToPasswordStore(example);
}
+ (BOOL)saveExampleFederatedOrigin:(NSString*)federatedOrigin
userName:(NSString*)userName
origin:(NSString*)origin {
PasswordForm federated;
federated.username_value = base::SysNSStringToUTF16(userName);
federated.origin = GURL(base::SysNSStringToUTF16(origin));
federated.signon_realm = federated.origin.spec();
federated.federation_origin =
url::Origin::Create(GURL(base::SysNSStringToUTF16(federatedOrigin)));
return SaveToPasswordStore(federated);
}
+ (NSInteger)passwordStoreResultsCount {
FakeStoreConsumer consumer;
if (!consumer.FetchStoreResults()) {
return -1;
}
return consumer.GetStoreResults().size();
}
+ (BOOL)clearPasswordStore {
return ClearPasswordStore();
}
+ (BOOL)isCredentialsServiceEnabled {
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
return browserState->GetPrefs()->GetBoolean(
password_manager::prefs::kCredentialsEnableService);
}
@end
...@@ -2,67 +2,56 @@ ...@@ -2,67 +2,56 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#include <TargetConditionals.h> #include <TargetConditionals.h>
#include <utility> #include <utility>
#include "base/callback.h" #include "base/callback.h"
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
#include "base/mac/foundation_util.h"
#include "base/memory/ref_counted.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#import "base/test/ios/wait_util.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/autofill/core/common/password_form.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/ui/settings/password/passwords_settings_app_interface.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h" #import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
#import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller.h" #import "ios/chrome/browser/ui/settings/settings_root_table_constants.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/reauthentication_module.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"
#include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/test/app/password_test_util.h"
#import "ios/chrome/test/earl_grey/chrome_actions.h" #import "ios/chrome/test/earl_grey/chrome_actions.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_ui.h" #import "ios/chrome/test/earl_grey/chrome_earl_grey_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.h" #import "ios/chrome/test/earl_grey/chrome_matchers.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/third_party/material_components_ios/src/components/Snackbar/src/MaterialSnackbar.h" #import "ios/testing/earl_grey/earl_grey_test.h"
#include "ios/web/public/test/earl_grey/web_view_actions.h"
#include "ios/web/public/test/earl_grey/web_view_matchers.h"
#include "ios/web/public/test/element_selector.h" #include "ios/web/public/test/element_selector.h"
#include "ios/web/public/test/http_server/http_server.h"
#include "ios/web/public/test/http_server/http_server_util.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
#include "url/origin.h" #if defined(CHROME_EARL_GREY_2)
#include "ios/third_party/earl_grey2/src/CommonLib/Matcher/GREYLayoutConstraint.h" // nogncheck
#endif // defined(CHROME_EARL_GREY_2)
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
#if defined(CHROME_EARL_GREY_2)
// TODO(crbug.com/1015113) The EG2 macro is breaking indexing for some reason
// without the trailing semicolon. For now, disable the extra semi warning
// so Xcode indexing works for the egtest.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat-extra-semi"
GREY_STUB_CLASS_IN_APP_MAIN_QUEUE(PasswordSettingsAppInterface);
#pragma clang diagnostic pop
#endif // defined(CHROME_EARL_GREY_2)
// This test complements // This test complements
// password_details_collection_view_controller_unittest.mm. Very simple // password_details_collection_view_controller_unittest.mm. Very simple
// integration tests and features which are not currently unittestable should // integration tests and features which are not currently unittestable should
// go here, the rest into the unittest. // go here, the rest into the unittest.
using autofill::PasswordForm;
using chrome_test_util::ButtonWithAccessibilityLabel; using chrome_test_util::ButtonWithAccessibilityLabel;
using chrome_test_util::NavigationBarDoneButton; using chrome_test_util::NavigationBarDoneButton;
using chrome_test_util::SettingsDoneButton; using chrome_test_util::SettingsDoneButton;
using chrome_test_util::SettingsMenuBackButton; using chrome_test_util::SettingsMenuBackButton;
using chrome_test_util::SetUpAndReturnMockReauthenticationModule;
using chrome_test_util::SetUpAndReturnMockReauthenticationModuleForExport;
using chrome_test_util::TurnSettingsSwitchOn; using chrome_test_util::TurnSettingsSwitchOn;
namespace { namespace {
...@@ -226,20 +215,50 @@ id<GREYMatcher> NavigationBarEditButton() { ...@@ -226,20 +215,50 @@ id<GREYMatcher> NavigationBarEditButton() {
grey_userInteractionEnabled(), nil); grey_userInteractionEnabled(), nil);
} }
#if defined(CHROME_EARL_GREY_2)
// Matches the pop-up (call-out) menu item with accessibility label equal to the
// translated string identified by |label|.
id<GREYMatcher> PopUpMenuItemWithLabel(int label) {
if (@available(iOS 13, *)) {
// iOS13 reworked menu button subviews to no longer be accessibility
// elements. Multiple menu button subviews no longer show up as potential
// matches, which means the matcher logic does not need to be as complex as
// the iOS 11/12 logic. Various table view cells may share the same
// accesibility label, but those can be filtered out by ignoring
// UIAccessibilityTraitButton.
return grey_allOf(
grey_accessibilityLabel(l10n_util::GetNSString(label)),
grey_not(grey_accessibilityTrait(UIAccessibilityTraitButton)), nil);
} else {
// This is a hack relying on UIKit's internal structure. There are multiple
// items with the label the test is looking for, because the menu items
// likely have the same labels as the buttons for the same function. There
// is no easy way to identify elements which are part of the pop-up, because
// the associated classes are internal to UIKit. However, the pop-up items
// are of internal classs UICalloutBarButton, which can be tested easily
// in EG2.
return grey_allOf(grey_kindOfClassName(@"UICalloutBarButton"),
grey_accessibilityLabel(l10n_util::GetNSString(label)),
nullptr);
}
}
#endif // defined(CHROME_EARL_GREY_2)
#if defined(CHROME_EARL_GREY_1)
// This is similar to grey_ancestor, but only limited to the immediate parent. // This is similar to grey_ancestor, but only limited to the immediate parent.
id<GREYMatcher> MatchParentWith(id<GREYMatcher> parentMatcher) { id<GREYMatcher> MatchParentWith(id<GREYMatcher> parentMatcher) {
MatchesBlock matches = ^BOOL(id element) { GREYMatchesBlock matches = ^BOOL(id element) {
id parent = [element isKindOfClass:[UIView class]] id parent = [element isKindOfClass:[UIView class]]
? [element superview] ? [element superview]
: [element accessibilityContainer]; : [element accessibilityContainer];
return (parent && [parentMatcher matches:parent]); return (parent && [parentMatcher matches:parent]);
}; };
DescribeToBlock describe = ^void(id<GREYDescription> description) { GREYDescribeToBlock describe = ^void(id<GREYDescription> description) {
[description appendText:[NSString stringWithFormat:@"parentThatMatches(%@)", [description appendText:[NSString stringWithFormat:@"parentThatMatches(%@)",
parentMatcher]]; parentMatcher]];
}; };
return grey_allOf( return grey_allOf(
grey_anyOf(grey_kindOfClass([UIView class]), grey_anyOf(grey_kindOfClassName(@"UIView"),
grey_respondsToSelector(@selector(accessibilityContainer)), grey_respondsToSelector(@selector(accessibilityContainer)),
nil), nil),
[[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches [[GREYElementMatcherBlock alloc] initWithMatchesBlock:matches
...@@ -275,130 +294,39 @@ id<GREYMatcher> PopUpMenuItemWithLabel(int label) { ...@@ -275,130 +294,39 @@ id<GREYMatcher> PopUpMenuItemWithLabel(int label) {
nullptr); nullptr);
} }
} }
#endif // defined(CHROME_EARL_GREY_1)
scoped_refptr<password_manager::PasswordStore> GetPasswordStore() {
// ServiceAccessType governs behaviour in Incognito: only modifications with
// EXPLICIT_ACCESS, which correspond to user's explicit gesture, succeed.
// This test does not deal with Incognito, and should not run in Incognito
// context. Therefore IMPLICIT_ACCESS is used to let the test fail if in
// Incognito context.
return IOSChromePasswordStoreFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState(),
ServiceAccessType::IMPLICIT_ACCESS);
}
// This class is used to obtain results from the PasswordStore and hence both
// check the success of store updates and ensure that store has finished
// processing.
class TestStoreConsumer : public password_manager::PasswordStoreConsumer {
public:
void OnGetPasswordStoreResults(
std::vector<std::unique_ptr<autofill::PasswordForm>> obtained) override {
obtained_ = std::move(obtained);
}
const std::vector<autofill::PasswordForm>& GetStoreResults() {
results_.clear();
ResetObtained();
GetPasswordStore()->GetAllLogins(this);
bool responded = base::test::ios::WaitUntilConditionOrTimeout(2.0, ^bool {
return !AreObtainedReset();
});
GREYAssert(responded, @"Obtaining fillable items took too long.");
AppendObtainedToResults();
return results_;
}
private:
// Puts |obtained_| in a known state not corresponding to any PasswordStore
// state.
void ResetObtained() {
obtained_.clear();
obtained_.emplace_back(nullptr);
}
// Returns true if |obtained_| are in the reset state.
bool AreObtainedReset() { return obtained_.size() == 1 && !obtained_[0]; }
void AppendObtainedToResults() {
for (const auto& source : obtained_) {
results_.emplace_back(*source);
}
ResetObtained();
}
// Temporary cache of obtained store results.
std::vector<std::unique_ptr<autofill::PasswordForm>> obtained_;
// Combination of fillable and blacklisted credentials from the store.
std::vector<autofill::PasswordForm> results_;
};
// Saves |form| to the password store and waits until the async processing is
// done.
void SaveToPasswordStore(const PasswordForm& form) {
GetPasswordStore()->AddLogin(form);
// When we retrieve the form from the store, |from_store| should be set.
autofill::PasswordForm expected_form = form;
expected_form.from_store = autofill::PasswordForm::Store::kProfileStore;
// Check the result and ensure PasswordStore processed this.
TestStoreConsumer consumer;
for (const auto& result : consumer.GetStoreResults()) {
if (result == expected_form)
return;
}
GREYFail(@"Stored form was not found in the PasswordStore results.");
}
// Saves an example form in the store. // Saves an example form in the store.
void SaveExamplePasswordForm() { void SaveExamplePasswordForm() {
PasswordForm example; GREYAssert(
example.username_value = base::ASCIIToUTF16("concrete username"); [PasswordSettingsAppInterface saveExamplePassword:@"concrete password"
example.password_value = base::ASCIIToUTF16("concrete password"); userName:@"concrete username"
example.origin = GURL("https://example.com"); origin:@"https://example.com"],
example.signon_realm = example.origin.spec(); @"Stored form was not found in the PasswordStore results.");
SaveToPasswordStore(example);
} }
// Saves two example forms in the store. // Saves two example forms in the store.
void SaveExamplePasswordForms() { void SaveExamplePasswordForms() {
PasswordForm example1; GREYAssert([PasswordSettingsAppInterface
example1.username_value = base::ASCIIToUTF16("user1"); saveExamplePassword:@"password1"
example1.password_value = base::ASCIIToUTF16("password1"); userName:@"user1"
example1.origin = GURL("https://example11.com"); origin:@"https://example11.com"],
example1.signon_realm = example1.origin.spec(); @"Stored form was not found in the PasswordStore results.");
SaveToPasswordStore(example1); GREYAssert([PasswordSettingsAppInterface
saveExamplePassword:@"password2"
PasswordForm example2; userName:@"user2"
example2.username_value = base::ASCIIToUTF16("user2"); origin:@"https://example12.com"],
example2.password_value = base::ASCIIToUTF16("password2"); @"Stored form was not found in the PasswordStore results.");
example2.origin = GURL("https://example12.com");
example2.signon_realm = example2.origin.spec();
SaveToPasswordStore(example2);
} }
// Saves two example blacklisted forms in the store. // Saves two example blacklisted forms in the store.
void SaveExampleBlacklistedForms() { void SaveExampleBlacklistedForms() {
PasswordForm blacklisted1; GREYAssert([PasswordSettingsAppInterface
blacklisted1.origin = GURL("https://exclude1.com"); saveExampleBlacklistedOrigin:@"https://exclude1.com"],
blacklisted1.signon_realm = blacklisted1.origin.spec(); @"Stored form was not found in the PasswordStore results.");
blacklisted1.blacklisted_by_user = true; GREYAssert([PasswordSettingsAppInterface
SaveToPasswordStore(blacklisted1); saveExampleBlacklistedOrigin:@"https://exclude2.com"],
@"Stored form was not found in the PasswordStore results.");
PasswordForm blacklisted2;
blacklisted2.origin = GURL("https://exclude2.com");
blacklisted2.signon_realm = blacklisted2.origin.spec();
blacklisted2.blacklisted_by_user = true;
SaveToPasswordStore(blacklisted2);
}
// Removes all credentials stored.
void ClearPasswordStore() {
GetPasswordStore()->RemoveLoginsCreatedBetween(base::Time(), base::Time(),
base::Closure());
TestStoreConsumer consumer;
GREYAssert(consumer.GetStoreResults().empty(),
@"PasswordStore was not cleared.");
} }
// Opens the passwords page from the NTP. It requires no menus to be open. // Opens the passwords page from the NTP. It requires no menus to be open.
...@@ -411,8 +339,7 @@ void OpenPasswordSettings() { ...@@ -411,8 +339,7 @@ void OpenPasswordSettings() {
// background task runner and waits until it is finished. Because the // background task runner and waits until it is finished. Because the
// background task runner is sequenced, this means that previously posted // background task runner is sequenced, this means that previously posted
// tasks are also finished when this function exits. // tasks are also finished when this function exits.
TestStoreConsumer consumer; [PasswordSettingsAppInterface passwordStoreResultsCount];
consumer.GetStoreResults();
} }
// Tap Edit in any settings view. // Tap Edit in any settings view.
...@@ -421,19 +348,6 @@ void TapEdit() { ...@@ -421,19 +348,6 @@ void TapEdit() {
performAction:grey_tap()]; performAction:grey_tap()];
} }
// Creates a PasswordForm with |index| being part of the username, password,
// origin and realm.
PasswordForm CreateSampleFormWithIndex(int index) {
PasswordForm form;
form.username_value =
base::ASCIIToUTF16(base::StringPrintf("concrete username %02d", index));
form.password_value =
base::ASCIIToUTF16(base::StringPrintf("concrete password %02d", index));
form.origin = GURL(base::StringPrintf("https://www%02d.example.com", index));
form.signon_realm = form.origin.spec();
return form;
}
} // namespace } // namespace
// Various tests for the Save Passwords section of the settings. // Various tests for the Save Passwords section of the settings.
...@@ -446,10 +360,9 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -446,10 +360,9 @@ PasswordForm CreateSampleFormWithIndex(int index) {
// Snackbars triggered by tests stay up for a limited time even if the // Snackbars triggered by tests stay up for a limited time even if the
// settings get closed. Ensure that they are closed to avoid interference with // settings get closed. Ensure that they are closed to avoid interference with
// other tests. // other tests.
[MDCSnackbarManager [PasswordSettingsAppInterface dismissSnackBar];
dismissAndCallCompletionBlocksWithCategory:@"PasswordsSnackbarCategory"]; GREYAssert([PasswordSettingsAppInterface clearPasswordStore],
@"PasswordStore was not cleared.");
ClearPasswordStore();
[super tearDown]; [super tearDown];
} }
...@@ -491,11 +404,10 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -491,11 +404,10 @@ PasswordForm CreateSampleFormWithIndex(int index) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModule];
SetUpAndReturnMockReauthenticationModule(); [PasswordSettingsAppInterface mockReauthenticationModuleShouldSucceed:YES];
// Check the snackbar in case of successful reauthentication. // Check the snackbar in case of successful reauthentication.
mock_reauthentication_module.shouldSucceed = YES;
[GetInteractionForPasswordDetailItem(CopyPasswordButton()) [GetInteractionForPasswordDetailItem(CopyPasswordButton())
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -506,7 +418,7 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -506,7 +418,7 @@ PasswordForm CreateSampleFormWithIndex(int index) {
performAction:grey_tap()]; performAction:grey_tap()];
// Check the snackbar in case of failed reauthentication. // Check the snackbar in case of failed reauthentication.
mock_reauthentication_module.shouldSucceed = NO; [PasswordSettingsAppInterface mockReauthenticationModuleShouldSucceed:NO];
[GetInteractionForPasswordDetailItem(CopyPasswordButton()) [GetInteractionForPasswordDetailItem(CopyPasswordButton())
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -535,11 +447,10 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -535,11 +447,10 @@ PasswordForm CreateSampleFormWithIndex(int index) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModule];
SetUpAndReturnMockReauthenticationModule(); [PasswordSettingsAppInterface mockReauthenticationModuleShouldSucceed:YES];
// Check the snackbar in case of successful reauthentication. // Check the snackbar in case of successful reauthentication.
mock_reauthentication_module.shouldSucceed = YES;
[GetInteractionForPasswordDetailItem(ShowPasswordButton()) [GetInteractionForPasswordDetailItem(ShowPasswordButton())
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -567,11 +478,10 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -567,11 +478,10 @@ PasswordForm CreateSampleFormWithIndex(int index) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModule];
SetUpAndReturnMockReauthenticationModule(); [PasswordSettingsAppInterface mockReauthenticationModuleShouldSucceed:NO];
// Check the snackbar in case of failed reauthentication. // Check the snackbar in case of failed reauthentication.
mock_reauthentication_module.shouldSucceed = NO;
[GetInteractionForPasswordDetailItem(ShowPasswordButton()) [GetInteractionForPasswordDetailItem(ShowPasswordButton())
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -679,9 +589,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -679,9 +589,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
nullptr)] assertWithMatcher:grey_notNil()]; nullptr)] assertWithMatcher:grey_notNil()];
// Verify that the deletion was propagated to the PasswordStore. // Verify that the deletion was propagated to the PasswordStore.
TestStoreConsumer consumer; GREYAssertEqual(0, [PasswordSettingsAppInterface passwordStoreResultsCount],
GREYAssert(consumer.GetStoreResults().empty(), @"Stored password was not removed from PasswordStore.");
@"Stored password was not removed from PasswordStore.");
// Also verify that the removed password is no longer in the list. // Also verify that the removed password is no longer in the list.
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
...@@ -713,12 +622,11 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -713,12 +622,11 @@ PasswordForm CreateSampleFormWithIndex(int index) {
// Save duplicate of the previously saved form to be deleted at the same time. // Save duplicate of the previously saved form to be deleted at the same time.
// This entry is considered duplicated because it maps to the same sort key // This entry is considered duplicated because it maps to the same sort key
// as the previous one. // as the previous one.
PasswordForm exampleDuplicate; GREYAssert([PasswordSettingsAppInterface
exampleDuplicate.username_value = base::ASCIIToUTF16("concrete username"); saveExamplePassword:@"concrete password"
exampleDuplicate.password_value = base::ASCIIToUTF16("concrete password"); userName:@"concrete username"
exampleDuplicate.origin = GURL("https://example.com/example"); origin:@"https://example.com/example"],
exampleDuplicate.signon_realm = exampleDuplicate.origin.spec(); @"Stored form was not found in the PasswordStore results.");
SaveToPasswordStore(exampleDuplicate);
OpenPasswordSettings(); OpenPasswordSettings();
...@@ -744,9 +652,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -744,9 +652,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
nullptr)] assertWithMatcher:grey_notNil()]; nullptr)] assertWithMatcher:grey_notNil()];
// Verify that the deletion was propagated to the PasswordStore. // Verify that the deletion was propagated to the PasswordStore.
TestStoreConsumer consumer; GREYAssertEqual(0, [PasswordSettingsAppInterface passwordStoreResultsCount],
GREYAssert(consumer.GetStoreResults().empty(), @"Stored password was not removed from PasswordStore.");
@"Stored password was not removed from PasswordStore.");
// Also verify that the removed password is no longer in the list. // Also verify that the removed password is no longer in the list.
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
...@@ -773,11 +680,9 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -773,11 +680,9 @@ PasswordForm CreateSampleFormWithIndex(int index) {
EARL_GREY_TEST_SKIPPED(@"Test disabled on iPad and iOS 13.2+"); EARL_GREY_TEST_SKIPPED(@"Test disabled on iPad and iOS 13.2+");
} }
// Save blacklisted form to be deleted later. // Save blacklisted form to be deleted later.
PasswordForm blacklisted; GREYAssert([PasswordSettingsAppInterface
blacklisted.origin = GURL("https://blacklisted.com"); saveExampleBlacklistedOrigin:@"https://blacklisted.com"],
blacklisted.signon_realm = blacklisted.origin.spec(); @"Stored form was not found in the PasswordStore results.");
blacklisted.blacklisted_by_user = true;
SaveToPasswordStore(blacklisted);
OpenPasswordSettings(); OpenPasswordSettings();
...@@ -802,9 +707,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -802,9 +707,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
nullptr)] assertWithMatcher:grey_notNil()]; nullptr)] assertWithMatcher:grey_notNil()];
// Verify that the deletion was propagated to the PasswordStore. // Verify that the deletion was propagated to the PasswordStore.
TestStoreConsumer consumer; GREYAssertEqual(0, [PasswordSettingsAppInterface passwordStoreResultsCount],
GREYAssert(consumer.GetStoreResults().empty(), @"Stored password was not removed from PasswordStore.");
@"Stored password was not removed from PasswordStore.");
// Also verify that the removed password is no longer in the list. // Also verify that the removed password is no longer in the list.
[GetInteractionForPasswordEntry(@"secret.com") [GetInteractionForPasswordEntry(@"secret.com")
...@@ -855,8 +759,7 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -855,8 +759,7 @@ PasswordForm CreateSampleFormWithIndex(int index) {
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
// Verify that the deletion did not happen. // Verify that the deletion did not happen.
TestStoreConsumer consumer; GREYAssertEqual(1u, [PasswordSettingsAppInterface passwordStoreResultsCount],
GREYAssertEqual(1u, consumer.GetStoreResults().size(),
@"Stored password was removed from PasswordStore."); @"Stored password was removed from PasswordStore.");
// Go back to the list view and verify that the password is still in the // Go back to the list view and verify that the password is still in the
...@@ -991,9 +894,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -991,9 +894,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
// Make sure to capture the reauthentication module in a variable until the // Make sure to capture the reauthentication module in a variable until the
// end of the test, otherwise it might get deleted too soon and break the // end of the test, otherwise it might get deleted too soon and break the
// functionality of copying and viewing passwords. // functionality of copying and viewing passwords.
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModule];
SetUpAndReturnMockReauthenticationModule(); [PasswordSettingsAppInterface mockReauthenticationModuleShouldSucceed:YES];
mock_reauthentication_module.shouldSucceed = YES;
// Tap the context menu item for copying. // Tap the context menu item for copying.
[[EarlGrey [[EarlGrey
...@@ -1034,9 +936,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1034,9 +936,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
// Make sure to capture the reauthentication module in a variable until the // Make sure to capture the reauthentication module in a variable until the
// end of the test, otherwise it might get deleted too soon and break the // end of the test, otherwise it might get deleted too soon and break the
// functionality of copying and viewing passwords. // functionality of copying and viewing passwords.
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModule];
SetUpAndReturnMockReauthenticationModule(); [PasswordSettingsAppInterface mockReauthenticationModuleShouldSucceed:YES];
mock_reauthentication_module.shouldSucceed = YES;
// Tap the context menu item for showing. // Tap the context menu item for showing.
[[EarlGrey [[EarlGrey
...@@ -1069,13 +970,11 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1069,13 +970,11 @@ PasswordForm CreateSampleFormWithIndex(int index) {
// Checks that federated credentials have no password but show the federation. // Checks that federated credentials have no password but show the federation.
- (void)testFederated { - (void)testFederated {
PasswordForm federated; GREYAssert([PasswordSettingsAppInterface
federated.username_value = base::ASCIIToUTF16("federated username"); saveExampleFederatedOrigin:@"https://famous.provider.net"
federated.origin = GURL("https://example.com"); userName:@"federated username"
federated.signon_realm = federated.origin.spec(); origin:@"https://example.com"],
federated.federation_origin = @"Stored form was not found in the PasswordStore results.");
url::Origin::Create(GURL("https://famous.provider.net"));
SaveToPasswordStore(federated);
OpenPasswordSettings(); OpenPasswordSettings();
...@@ -1136,7 +1035,7 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1136,7 +1035,7 @@ PasswordForm CreateSampleFormWithIndex(int index) {
id<GREYMatcher> passwordHeader = id<GREYMatcher> passwordHeader =
grey_allOf(PasswordHeader(), grey_allOf(PasswordHeader(),
grey_kindOfClass([UITableViewHeaderFooterView class]), nil); grey_kindOfClassName(@"UITableViewHeaderFooterView"), nil);
[GetInteractionForPasswordDetailItem(passwordHeader) [GetInteractionForPasswordDetailItem(passwordHeader)
assertWithMatcher:grey_layout(@[ Below() ], CopyUsernameButton())]; assertWithMatcher:grey_layout(@[ Below() ], CopyUsernameButton())];
id<GREYMatcher> passwordCell = grey_accessibilityLabel( id<GREYMatcher> passwordCell = grey_accessibilityLabel(
...@@ -1168,11 +1067,9 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1168,11 +1067,9 @@ PasswordForm CreateSampleFormWithIndex(int index) {
// Checks the order of the elements in the detail view layout for a blacklisted // Checks the order of the elements in the detail view layout for a blacklisted
// credential. // credential.
- (void)testLayoutBlacklisted { - (void)testLayoutBlacklisted {
PasswordForm blacklisted; GREYAssert([PasswordSettingsAppInterface
blacklisted.origin = GURL("https://example.com"); saveExampleBlacklistedOrigin:@"https://example.com"],
blacklisted.signon_realm = blacklisted.origin.spec(); @"Stored form was not found in the PasswordStore results.");
blacklisted.blacklisted_by_user = true;
SaveToPasswordStore(blacklisted);
OpenPasswordSettings(); OpenPasswordSettings();
...@@ -1210,13 +1107,11 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1210,13 +1107,11 @@ PasswordForm CreateSampleFormWithIndex(int index) {
// Checks the order of the elements in the detail view layout for a federated // Checks the order of the elements in the detail view layout for a federated
// credential. // credential.
- (void)testLayoutFederated { - (void)testLayoutFederated {
PasswordForm federated; GREYAssert([PasswordSettingsAppInterface
federated.username_value = base::ASCIIToUTF16("federated username"); saveExampleFederatedOrigin:@"https://famous.provider.net"
federated.origin = GURL("https://example.com"); userName:@"federated username"
federated.signon_realm = federated.origin.spec(); origin:@"https://example.com"],
federated.federation_origin = @"Stored form was not found in the PasswordStore results.");
url::Origin::Create(GURL("https://famous.provider.net"));
SaveToPasswordStore(federated);
OpenPasswordSettings(); OpenPasswordSettings();
...@@ -1267,11 +1162,9 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1267,11 +1162,9 @@ PasswordForm CreateSampleFormWithIndex(int index) {
- (void)testStoredEntriesAlwaysShown { - (void)testStoredEntriesAlwaysShown {
SaveExamplePasswordForm(); SaveExamplePasswordForm();
PasswordForm blacklisted; GREYAssert([PasswordSettingsAppInterface
blacklisted.origin = GURL("https://blacklisted.com"); saveExampleBlacklistedOrigin:@"https://blacklisted.com"],
blacklisted.signon_realm = blacklisted.origin.spec(); @"Stored form was not found in the PasswordStore results.");
blacklisted.blacklisted_by_user = true;
SaveToPasswordStore(blacklisted);
OpenPasswordSettings(); OpenPasswordSettings();
...@@ -1318,12 +1211,9 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1318,12 +1211,9 @@ PasswordForm CreateSampleFormWithIndex(int index) {
@"savePasswordsItem_switch", @"savePasswordsItem_switch",
expected_initial_state)] expected_initial_state)]
performAction:TurnSettingsSwitchOn(!expected_initial_state)]; performAction:TurnSettingsSwitchOn(!expected_initial_state)];
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
const bool expected_final_state = !expected_initial_state; const bool expected_final_state = !expected_initial_state;
GREYAssertEqual(expected_final_state, GREYAssertEqual(expected_final_state,
browserState->GetPrefs()->GetBoolean( [PasswordSettingsAppInterface isCredentialsServiceEnabled],
password_manager::prefs::kCredentialsEnableService),
@"State of the UI toggle differs from real preferences."); @"State of the UI toggle differs from real preferences.");
} }
...@@ -1350,9 +1240,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1350,9 +1240,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
performAction:grey_tap()]; performAction:grey_tap()];
// Verify that the deletion was propagated to the PasswordStore. // Verify that the deletion was propagated to the PasswordStore.
TestStoreConsumer consumer; GREYAssertEqual(0, [PasswordSettingsAppInterface passwordStoreResultsCount],
GREYAssert(consumer.GetStoreResults().empty(), @"Stored password was not removed from PasswordStore.");
@"Stored password was not removed from PasswordStore.");
// Verify that the removed password is no longer in the list. // Verify that the removed password is no longer in the list.
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
assertWithMatcher:grey_not(grey_sufficientlyVisible())]; assertWithMatcher:grey_not(grey_sufficientlyVisible())];
...@@ -1374,10 +1263,9 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1374,10 +1263,9 @@ PasswordForm CreateSampleFormWithIndex(int index) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModule];
SetUpAndReturnMockReauthenticationModule(); [PasswordSettingsAppInterface mockReauthenticationModuleCanAttempt:NO];
mock_reauthentication_module.canAttempt = NO;
[GetInteractionForPasswordDetailItem(CopyPasswordButton()) [GetInteractionForPasswordDetailItem(CopyPasswordButton())
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -1402,10 +1290,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1402,10 +1290,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
[GetInteractionForPasswordEntry(@"example.com, concrete username") [GetInteractionForPasswordEntry(@"example.com, concrete username")
performAction:grey_tap()]; performAction:grey_tap()];
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModule];
SetUpAndReturnMockReauthenticationModule(); [PasswordSettingsAppInterface mockReauthenticationModuleCanAttempt:NO];
mock_reauthentication_module.canAttempt = NO;
[GetInteractionForPasswordDetailItem(ShowPasswordButton()) [GetInteractionForPasswordDetailItem(ShowPasswordButton())
performAction:grey_tap()]; performAction:grey_tap()];
...@@ -1453,14 +1339,12 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1453,14 +1339,12 @@ PasswordForm CreateSampleFormWithIndex(int index) {
constexpr int kPasswordsCount = 15; constexpr int kPasswordsCount = 15;
// Send the passwords to the queue to be added to the PasswordStore. // Send the passwords to the queue to be added to the PasswordStore.
for (int i = 1; i <= kPasswordsCount; ++i) { [PasswordSettingsAppInterface saveExamplePasswordWithCount:kPasswordsCount];
GetPasswordStore()->AddLogin(CreateSampleFormWithIndex(i));
}
// Use TestStoreConsumer::GetStoreResults to wait for the background storing // Use TestStoreConsumer::GetStoreResults to wait for the background storing
// task to complete and to verify that the passwords have been stored. // task to complete and to verify that the passwords have been stored.
TestStoreConsumer consumer; GREYAssertEqual(kPasswordsCount,
GREYAssertEqual(kPasswordsCount, consumer.GetStoreResults().size(), [PasswordSettingsAppInterface passwordStoreResultsCount],
@"Unexpected PasswordStore results."); @"Unexpected PasswordStore results.");
OpenPasswordSettings(); OpenPasswordSettings();
...@@ -1533,9 +1417,8 @@ PasswordForm CreateSampleFormWithIndex(int index) { ...@@ -1533,9 +1417,8 @@ PasswordForm CreateSampleFormWithIndex(int index) {
OpenPasswordSettings(); OpenPasswordSettings();
MockReauthenticationModule* mock_reauthentication_module = [PasswordSettingsAppInterface setUpMockReauthenticationModuleForExport];
SetUpAndReturnMockReauthenticationModuleForExport(); [PasswordSettingsAppInterface mockReauthenticationModuleShouldSucceed:YES];
mock_reauthentication_module.shouldSucceed = YES;
[[EarlGrey [[EarlGrey
selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId( selectElementWithMatcher:chrome_test_util::ButtonWithAccessibilityLabelId(
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_PASSWORDS_TABLE_VIEW_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_PASSWORDS_TABLE_VIEW_CONSTANTS_H_
#import <Foundation/Foundation.h>
// The accessibility identifier of the password details table view.
extern NSString* const kPasswordsTableViewId;
extern NSString* const kPasswordsExportConfirmViewId;
extern NSString* const kPasswordsSearchBarId;
extern NSString* const kPasswordsScrimViewId;
// The accessibility identifier of the password details table view.
extern NSString* const kPasswordDetailsTableViewId;
extern NSString* const kPasswordDetailsDeletionAlertViewId;
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_PASSWORDS_TABLE_VIEW_CONSTANTS_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kPasswordsTableViewId = @"PasswordsTableViewId";
NSString* const kPasswordsExportConfirmViewId = @"PasswordsExportConfirmViewId";
NSString* const kPasswordsSearchBarId = @"PasswordsSearchBar";
NSString* const kPasswordsScrimViewId = @"PasswordsScrimViewId";
NSString* const kPasswordDetailsTableViewId = @"PasswordDetailsTableViewId";
NSString* const kPasswordDetailsDeletionAlertViewId =
@"PasswordDetailsDeletionAlertViewId";
...@@ -13,12 +13,6 @@ namespace ios { ...@@ -13,12 +13,6 @@ namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
} // namespace ios } // namespace ios
// The accessibility identifier of the password details table view.
extern NSString* const kPasswordsTableViewId;
extern NSString* const kPasswordsExportConfirmViewId;
extern NSString* const kPasswordsSearchBarId;
extern NSString* const kPasswordsScrimViewId;
@protocol ReauthenticationProtocol; @protocol ReauthenticationProtocol;
@class PasswordExporter; @class PasswordExporter;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller.h" #import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller_delegate.h" #import "ios/chrome/browser/ui/settings/password/password_details_table_view_controller_delegate.h"
#import "ios/chrome/browser/ui/settings/password/password_exporter.h" #import "ios/chrome/browser/ui/settings/password/password_exporter.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
#import "ios/chrome/browser/ui/settings/password/reauthentication_module.h" #import "ios/chrome/browser/ui/settings/password/reauthentication_module.h"
#import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h" #import "ios/chrome/browser/ui/settings/utils/pref_backed_boolean.h"
#import "ios/chrome/browser/ui/settings/utils/settings_utils.h" #import "ios/chrome/browser/ui/settings/utils/settings_utils.h"
...@@ -63,11 +64,6 @@ ...@@ -63,11 +64,6 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
NSString* const kPasswordsTableViewId = @"PasswordsTableViewId";
NSString* const kPasswordsExportConfirmViewId = @"PasswordsExportConfirmViewId";
NSString* const kPasswordsSearchBarId = @"PasswordsSearchBar";
NSString* const kPasswordsScrimViewId = @"PasswordsScrimViewId";
namespace { namespace {
typedef NS_ENUM(NSInteger, SectionIdentifier) { typedef NS_ENUM(NSInteger, SectionIdentifier) {
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_SETTINGS_ROOT_TABLE_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_SETTINGS_ROOT_TABLE_CONSTANTS_H_
#import <Foundation/Foundation.h>
extern NSString* const kSettingsToolbarDeleteButtonId;
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_SETTINGS_ROOT_TABLE_CONSTANTS_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/settings/settings_root_table_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kSettingsToolbarDeleteButtonId =
@"SettingsToolbarDeleteButtonId";
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
#import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_link_header_footer_item.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h"
extern NSString* const kSettingsToolbarDeleteButtonId;
// SettingsRootTableViewController is a base class for integrating UITableViews // SettingsRootTableViewController is a base class for integrating UITableViews
// into the Settings UI. It handles the configuration and display of the MDC // into the Settings UI. It handles the configuration and display of the MDC
// AppBar. // AppBar.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "ios/chrome/browser/ui/settings/bar_button_activity_indicator.h" #import "ios/chrome/browser/ui/settings/bar_button_activity_indicator.h"
#import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h" #import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h" #import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
#import "ios/chrome/browser/ui/settings/settings_root_table_constants.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h"
#include "ios/chrome/browser/ui/ui_feature_flags.h" #include "ios/chrome/browser/ui/ui_feature_flags.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
...@@ -41,9 +42,6 @@ const CGFloat kActivityIndicatorDimensionIPad = 64; ...@@ -41,9 +42,6 @@ const CGFloat kActivityIndicatorDimensionIPad = 64;
const CGFloat kActivityIndicatorDimensionIPhone = 56; const CGFloat kActivityIndicatorDimensionIPhone = 56;
} // namespace } // namespace
NSString* const kSettingsToolbarDeleteButtonId =
@"SettingsToolbarDeleteButtonId";
@interface SettingsRootTableViewController () @interface SettingsRootTableViewController ()
// Delete button for the toolbar. // Delete button for the toolbar.
......
...@@ -43,6 +43,7 @@ source_set("sync") { ...@@ -43,6 +43,7 @@ source_set("sync") {
"//ios/chrome/browser/ui/settings/utils", "//ios/chrome/browser/ui/settings/utils",
"//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view",
"//ios/chrome/browser/ui/table_view/cells", "//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/table_view/cells:cells_constants",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/public/provider/chrome/browser", "//ios/public/provider/chrome/browser",
......
...@@ -8,8 +8,6 @@ source_set("cells") { ...@@ -8,8 +8,6 @@ source_set("cells") {
"table_view_activity_indicator_header_footer_item.mm", "table_view_activity_indicator_header_footer_item.mm",
"table_view_cell.h", "table_view_cell.h",
"table_view_cell.mm", "table_view_cell.mm",
"table_view_cells_constants.h",
"table_view_cells_constants.mm",
"table_view_detail_icon_item.h", "table_view_detail_icon_item.h",
"table_view_detail_icon_item.mm", "table_view_detail_icon_item.mm",
"table_view_detail_text_item.h", "table_view_detail_text_item.h",
...@@ -44,6 +42,7 @@ source_set("cells") { ...@@ -44,6 +42,7 @@ source_set("cells") {
] ]
deps = [ deps = [
":cells_constants",
"resources:table_view_cell_chevron", "resources:table_view_cell_chevron",
"resources:table_view_cell_edit_icon", "resources:table_view_cell_edit_icon",
"resources:table_view_cell_error_icon", "resources:table_view_cell_error_icon",
...@@ -70,6 +69,17 @@ source_set("cells") { ...@@ -70,6 +69,17 @@ source_set("cells") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
} }
source_set("cells_constants") {
sources = [
"table_view_cells_constants.h",
"table_view_cells_constants.mm",
]
deps = [
"//base",
]
configs += [ "//build/config/compiler:enable_arc" ]
}
source_set("unit_tests") { source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
...@@ -88,6 +98,7 @@ source_set("unit_tests") { ...@@ -88,6 +98,7 @@ source_set("unit_tests") {
deps = [ deps = [
":cells", ":cells",
":cells_constants",
"//base", "//base",
"//ios/chrome/browser/ui/table_view:styler", "//ios/chrome/browser/ui/table_view:styler",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
......
...@@ -258,7 +258,7 @@ source_set("test_support") { ...@@ -258,7 +258,7 @@ source_set("test_support") {
"//ios/chrome/browser/ui/safe_mode", "//ios/chrome/browser/ui/safe_mode",
"//ios/chrome/browser/ui/safe_mode:test_support", "//ios/chrome/browser/ui/safe_mode:test_support",
"//ios/chrome/browser/ui/settings:settings", "//ios/chrome/browser/ui/settings:settings",
"//ios/chrome/browser/ui/settings:settings_root", "//ios/chrome/browser/ui/settings:settings_root_constants",
"//ios/chrome/browser/ui/settings/autofill", "//ios/chrome/browser/ui/settings/autofill",
"//ios/chrome/browser/ui/settings/autofill:constants", "//ios/chrome/browser/ui/settings/autofill:constants",
"//ios/chrome/browser/ui/settings/autofill:feature_flags", "//ios/chrome/browser/ui/settings/autofill:feature_flags",
...@@ -266,7 +266,8 @@ source_set("test_support") { ...@@ -266,7 +266,8 @@ source_set("test_support") {
"//ios/chrome/browser/ui/settings/clear_browsing_data", "//ios/chrome/browser/ui/settings/clear_browsing_data",
"//ios/chrome/browser/ui/settings/credit_card_scanner", "//ios/chrome/browser/ui/settings/credit_card_scanner",
"//ios/chrome/browser/ui/settings/google_services", "//ios/chrome/browser/ui/settings/google_services",
"//ios/chrome/browser/ui/settings/password", "//ios/chrome/browser/ui/settings/password:eg_test_support",
"//ios/chrome/browser/ui/settings/password:password_constants",
"//ios/chrome/browser/ui/settings/sync", "//ios/chrome/browser/ui/settings/sync",
"//ios/chrome/browser/ui/static_content", "//ios/chrome/browser/ui/static_content",
"//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants", "//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants",
...@@ -383,6 +384,7 @@ source_set("eg_app_support+eg2") { ...@@ -383,6 +384,7 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ui/fullscreen/test:eg_app_support+eg2", "//ios/chrome/browser/ui/fullscreen/test:eg_app_support+eg2",
"//ios/chrome/browser/ui/history:constants", "//ios/chrome/browser/ui/history:constants",
"//ios/chrome/browser/ui/location_bar:location_bar", "//ios/chrome/browser/ui/location_bar:location_bar",
"//ios/chrome/browser/ui/material_components",
"//ios/chrome/browser/ui/omnibox:omnibox_internal", "//ios/chrome/browser/ui/omnibox:omnibox_internal",
"//ios/chrome/browser/ui/payments:payments_ui", "//ios/chrome/browser/ui/payments:payments_ui",
"//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/popup_menu:constants",
...@@ -393,7 +395,7 @@ source_set("eg_app_support+eg2") { ...@@ -393,7 +395,7 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ui/safe_mode:eg_app_support+eg2", "//ios/chrome/browser/ui/safe_mode:eg_app_support+eg2",
"//ios/chrome/browser/ui/settings:eg_app_support+eg2", "//ios/chrome/browser/ui/settings:eg_app_support+eg2",
"//ios/chrome/browser/ui/settings:settings", "//ios/chrome/browser/ui/settings:settings",
"//ios/chrome/browser/ui/settings:settings_root", "//ios/chrome/browser/ui/settings:settings_root_constants",
"//ios/chrome/browser/ui/settings/autofill", "//ios/chrome/browser/ui/settings/autofill",
"//ios/chrome/browser/ui/settings/autofill:constants", "//ios/chrome/browser/ui/settings/autofill:constants",
"//ios/chrome/browser/ui/settings/autofill:feature_flags", "//ios/chrome/browser/ui/settings/autofill:feature_flags",
...@@ -401,7 +403,8 @@ source_set("eg_app_support+eg2") { ...@@ -401,7 +403,8 @@ source_set("eg_app_support+eg2") {
"//ios/chrome/browser/ui/settings/clear_browsing_data", "//ios/chrome/browser/ui/settings/clear_browsing_data",
"//ios/chrome/browser/ui/settings/credit_card_scanner", "//ios/chrome/browser/ui/settings/credit_card_scanner",
"//ios/chrome/browser/ui/settings/google_services", "//ios/chrome/browser/ui/settings/google_services",
"//ios/chrome/browser/ui/settings/password", "//ios/chrome/browser/ui/settings/password:eg_app_support+eg2",
"//ios/chrome/browser/ui/settings/password:password_constants",
"//ios/chrome/browser/ui/settings/sync", "//ios/chrome/browser/ui/settings/sync",
"//ios/chrome/browser/ui/static_content", "//ios/chrome/browser/ui/static_content",
"//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants", "//ios/chrome/browser/ui/tab_grid:tab_grid_ui_constants",
...@@ -421,6 +424,7 @@ source_set("eg_app_support+eg2") { ...@@ -421,6 +424,7 @@ source_set("eg_app_support+eg2") {
"//ios/testing/earl_grey:eg_app_support+eg2", "//ios/testing/earl_grey:eg_app_support+eg2",
"//ios/third_party/earl_grey2:app_framework+link", "//ios/third_party/earl_grey2:app_framework+link",
"//ios/third_party/gtx:gtx+link", "//ios/third_party/gtx:gtx+link",
"//ios/third_party/material_components_ios",
"//ios/web:eg_app_support+eg2", "//ios/web:eg_app_support+eg2",
"//ios/web/common", "//ios/web/common",
"//ios/web/public", "//ios/web/public",
...@@ -478,6 +482,7 @@ source_set("eg_test_support+eg2") { ...@@ -478,6 +482,7 @@ source_set("eg_test_support+eg2") {
"//ios/chrome/browser/ui/popup_menu:constants", "//ios/chrome/browser/ui/popup_menu:constants",
"//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui_constants", "//ios/chrome/browser/ui/recent_tabs:recent_tabs_ui_constants",
"//ios/chrome/browser/ui/safe_mode:eg_test_support+eg2", "//ios/chrome/browser/ui/safe_mode: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: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/toolbar:eg_test_support+eg2", "//ios/chrome/browser/ui/toolbar:eg_test_support+eg2",
......
...@@ -44,9 +44,9 @@ ...@@ -44,9 +44,9 @@
#import "ios/chrome/browser/ui/settings/google_services/accounts_table_view_controller.h" #import "ios/chrome/browser/ui/settings/google_services/accounts_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/google_services/advanced_signin_settings_coordinator.h" #import "ios/chrome/browser/ui/settings/google_services/advanced_signin_settings_coordinator.h"
#import "ios/chrome/browser/ui/settings/import_data_table_view_controller.h" #import "ios/chrome/browser/ui/settings/import_data_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h" #import "ios/chrome/browser/ui/settings/password/passwords_table_view_constants.h"
#import "ios/chrome/browser/ui/settings/privacy_table_view_controller.h" #import "ios/chrome/browser/ui/settings/privacy_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h" #import "ios/chrome/browser/ui/settings/settings_root_table_constants.h"
#import "ios/chrome/browser/ui/settings/settings_table_view_controller.h" #import "ios/chrome/browser/ui/settings/settings_table_view_controller.h"
#import "ios/chrome/browser/ui/static_content/static_html_view_controller.h" #import "ios/chrome/browser/ui/static_content/static_html_view_controller.h"
#import "ios/chrome/browser/ui/tab_grid/grid/grid_constants.h" #import "ios/chrome/browser/ui/tab_grid/grid/grid_constants.h"
...@@ -544,9 +544,16 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id, ...@@ -544,9 +544,16 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id,
SubviewWithAccessibilityIdentifier( SubviewWithAccessibilityIdentifier(
@"SettingNavigationBar", @"SettingNavigationBar",
[[UIApplication sharedApplication] keyWindow])); [[UIApplication sharedApplication] keyWindow]));
#if defined(CHROME_EARL_GREY_2)
id<GREYMatcher> buttonLabelClassMatcher = grey_anyOf(
grey_kindOfClassName(@"UIButton"),
grey_kindOfClassName(@"UIAccessibilityBackButtonElement"), nil);
#else
id<GREYMatcher> buttonLabelClassMatcher = grey_kindOfClass([UIButton class]);
#endif
return grey_allOf(grey_anyOf(grey_accessibilityLabel(navBar.backItem.title), return grey_allOf(grey_anyOf(grey_accessibilityLabel(navBar.backItem.title),
grey_accessibilityLabel(@"Back"), nil), grey_accessibilityLabel(@"Back"), nil),
grey_kindOfClass([UIButton class]), buttonLabelClassMatcher,
grey_ancestor(grey_kindOfClass([UINavigationBar class])), grey_ancestor(grey_kindOfClass([UINavigationBar class])),
nil); nil);
} }
......
...@@ -62,6 +62,7 @@ chrome_ios_eg2_test("ios_chrome_settings_eg2tests_module") { ...@@ -62,6 +62,7 @@ chrome_ios_eg2_test("ios_chrome_settings_eg2tests_module") {
deps = [ deps = [
"//ios/chrome/browser/ui/settings:eg2_tests", "//ios/chrome/browser/ui/settings:eg2_tests",
"//ios/chrome/browser/ui/settings/autofill:eg2_tests", "//ios/chrome/browser/ui/settings/autofill:eg2_tests",
"//ios/chrome/browser/ui/settings/password:eg2_tests",
] ]
} }
......
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