Commit 8d8965d2 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][MF][EG2] Migrate Fallback Coordinator tests

Add profile methods to autofill app interface.
Add GREYKeyboard dependency to earl_grey_test.h.

TBR=eugenebut@chromium.org

Bug: 1017175,1016367
Change-Id: I5bff0672282c20114677cf6500a601a9ed5c4f3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1878248
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709019}
parent c5ccae48
...@@ -173,8 +173,12 @@ source_set("test_support") { ...@@ -173,8 +173,12 @@ source_set("test_support") {
deps = [ deps = [
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/autofill/core/browser",
"//components/autofill/core/browser:test_support",
"//components/keyed_service/core", "//components/keyed_service/core",
"//components/password_manager/core/browser", "//components/password_manager/core/browser",
"//ios/chrome/browser",
"//ios/chrome/browser/autofill",
"//ios/chrome/browser/passwords", "//ios/chrome/browser/passwords",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/testing/earl_grey:earl_grey_support", "//ios/testing/earl_grey:earl_grey_support",
...@@ -195,8 +199,12 @@ source_set("eg_app_support+eg2") { ...@@ -195,8 +199,12 @@ source_set("eg_app_support+eg2") {
deps = [ deps = [
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/autofill/core/browser",
"//components/autofill/core/browser:test_support",
"//components/keyed_service/core", "//components/keyed_service/core",
"//components/password_manager/core/browser", "//components/password_manager/core/browser",
"//ios/chrome/browser",
"//ios/chrome/browser/autofill",
"//ios/chrome/browser/passwords", "//ios/chrome/browser/passwords",
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
] ]
......
...@@ -21,6 +21,15 @@ ...@@ -21,6 +21,15 @@
// Saves an example form in the store for the passed URL spec. // Saves an example form in the store for the passed URL spec.
+ (void)savePasswordFormForURLSpec:(NSString*)URLSpec; + (void)savePasswordFormForURLSpec:(NSString*)URLSpec;
// Clears the profiles (addresses) in the data manager.
+ (void)clearProfilesStore;
// Saves a sample profile (address) in the data manager.
+ (void)saveExampleProfile;
// Resturns the name of the sample profile.
+ (NSString*)exampleProfileName;
@end @end
#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_APP_INTERFACE_H_ #endif // IOS_CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_APP_INTERFACE_H_
...@@ -7,9 +7,13 @@ ...@@ -7,9 +7,13 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/keyed_service/core/service_access_type.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.h"
#include "components/password_manager/core/browser/password_store_consumer.h" #include "components/password_manager/core/browser/password_store_consumer.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.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/chrome_test_util.h"
...@@ -126,6 +130,20 @@ void ClearPasswordStore() { ...@@ -126,6 +130,20 @@ void ClearPasswordStore() {
TestStoreConsumer consumer; TestStoreConsumer consumer;
} }
// Saves an example profile in the store.
void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
autofill::AutofillProfile profile = autofill::test::GetFullProfile();
size_t profileCount = personalDataManager->GetProfiles().size();
personalDataManager->AddProfile(profile);
ConditionBlock conditionBlock = ^bool {
return profileCount < personalDataManager->GetProfiles().size();
};
base::test::ios::TimeUntilCondition(
nil, conditionBlock, false,
base::TimeDelta::FromSeconds(base::test::ios::kWaitForActionTimeout));
}
} // namespace } // namespace
@implementation AutofillAppInterface @implementation AutofillAppInterface
...@@ -142,4 +160,45 @@ void ClearPasswordStore() { ...@@ -142,4 +160,45 @@ void ClearPasswordStore() {
SaveLocalPasswordForm(GURL(base::SysNSStringToUTF8(URLSpec))); SaveLocalPasswordForm(GURL(base::SysNSStringToUTF8(URLSpec)));
} }
+ (void)clearProfilesStore {
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
autofill::PersonalDataManager* personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState(browserState);
for (const auto* profile : personalDataManager->GetProfiles()) {
personalDataManager->RemoveByGUID(profile->guid());
}
ConditionBlock conditionBlock = ^bool {
return 0 == personalDataManager->GetProfiles().size();
};
base::test::ios::TimeUntilCondition(
nil, conditionBlock, false,
base::TimeDelta::FromSeconds(base::test::ios::kWaitForActionTimeout));
}
+ (void)saveExampleProfile {
AddAutofillProfile([self personalDataManager]);
}
+ (NSString*)exampleProfileName {
autofill::AutofillProfile profile = autofill::test::GetFullProfile();
base::string16 name =
profile.GetInfo(autofill::AutofillType(autofill::NAME_FULL),
GetApplicationContext()->GetApplicationLocale());
return base::SysUTF16ToNSString(name);
}
#pragma mark - Private
// The PersonalDataManager instance for the current browser state.
+ (autofill::PersonalDataManager*)personalDataManager {
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
autofill::PersonalDataManager* personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState(browserState);
personalDataManager->SetSyncingForTest(true);
return personalDataManager;
}
@end @end
...@@ -110,10 +110,6 @@ source_set("manual_fill_ui") { ...@@ -110,10 +110,6 @@ source_set("manual_fill_ui") {
] ]
deps = [ deps = [
"//base", "//base",
"//components/autofill/core/browser",
"//components/autofill/core/common",
"//components/autofill/ios/browser",
"//components/password_manager/core/browser",
"//ios/chrome/app/strings:ios_strings_grit", "//ios/chrome/app/strings:ios_strings_grit",
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/autofill/manual_fill:manual_fill", "//ios/chrome/browser/autofill/manual_fill:manual_fill",
...@@ -240,6 +236,7 @@ source_set("eg2_tests") { ...@@ -240,6 +236,7 @@ source_set("eg2_tests") {
] ]
testonly = true testonly = true
sources = [ sources = [
"fallback_coordinator_egtest.mm",
"password_view_controller_egtest.mm", "password_view_controller_egtest.mm",
] ]
deps = [ deps = [
......
...@@ -377,6 +377,9 @@ id<GREYMatcher> SettingsPasswordSearchMatcher(); ...@@ -377,6 +377,9 @@ id<GREYMatcher> SettingsPasswordSearchMatcher();
// Returns a matcher for the profiles settings collection view. // Returns a matcher for the profiles settings collection view.
id<GREYMatcher> SettingsProfileMatcher(); id<GREYMatcher> SettingsProfileMatcher();
// Returns a matcher for an autofill suggestion view.
id<GREYMatcher> AutofillSuggestionViewMatcher();
#pragma mark - Manual Fallback #pragma mark - Manual Fallback
// Returns a matcher for the scroll view in keyboard accessory bar. // Returns a matcher for the scroll view in keyboard accessory bar.
......
...@@ -471,6 +471,10 @@ id<GREYMatcher> SettingsProfileMatcher() { ...@@ -471,6 +471,10 @@ id<GREYMatcher> SettingsProfileMatcher() {
return [ChromeMatchersAppInterface settingsProfileMatcher]; return [ChromeMatchersAppInterface settingsProfileMatcher];
} }
id<GREYMatcher> AutofillSuggestionViewMatcher() {
return [ChromeMatchersAppInterface autofillSuggestionViewMatcher];
}
#pragma mark - Manual Fallback #pragma mark - Manual Fallback
id<GREYMatcher> ManualFallbackFormSuggestionViewMatcher() { id<GREYMatcher> ManualFallbackFormSuggestionViewMatcher() {
......
...@@ -382,6 +382,9 @@ ...@@ -382,6 +382,9 @@
// Returns a matcher for the profiles settings collection view. // Returns a matcher for the profiles settings collection view.
+ (id<GREYMatcher>)settingsProfileMatcher; + (id<GREYMatcher>)settingsProfileMatcher;
// Returns a matcher for an autofill suggestion view.
+ (id<GREYMatcher>)autofillSuggestionViewMatcher;
#pragma mark - Manual Fallback #pragma mark - Manual Fallback
// Returns a matcher for the scroll view in keyboard accessory bar. // Returns a matcher for the scroll view in keyboard accessory bar.
......
...@@ -748,6 +748,10 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id, ...@@ -748,6 +748,10 @@ UIView* SubviewWithAccessibilityIdentifier(NSString* accessibility_id,
return grey_accessibilityID(kAutofillProfileTableViewID); return grey_accessibilityID(kAutofillProfileTableViewID);
} }
+ (id<GREYMatcher>)autofillSuggestionViewMatcher {
return grey_accessibilityID(kFormSuggestionLabelAccessibilityIdentifier);
}
#pragma mark - Manual Fallback #pragma mark - Manual Fallback
+ (id<GREYMatcher>)manualFallbackFormSuggestionViewMatcher { + (id<GREYMatcher>)manualFallbackFormSuggestionViewMatcher {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#if defined(CHROME_EARL_GREY_1) #if defined(CHROME_EARL_GREY_1)
#import <EarlGrey/EarlGrey.h> #import <EarlGrey/EarlGrey.h>
#import <EarlGrey/GREYAppleInternals.h>
#import <EarlGrey/GREYKeyboard.h> #import <EarlGrey/GREYKeyboard.h>
typedef DescribeToBlock GREYDescribeToBlock; typedef DescribeToBlock GREYDescribeToBlock;
......
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