Commit 9109135d authored by Olivier Robin's avatar Olivier Robin Committed by Commit Bot

[EG2] Converts SaveProfileEGTest

Tbr: eugenebut@chromium.org
Bug: 987646
Change-Id: I10f44d136c205c6259a96cc5079b57bf720fab39
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881232
Commit-Queue: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709913}
parent 782c7776
......@@ -136,6 +136,7 @@ source_set("autofill_ui") {
}
source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
......@@ -144,6 +145,7 @@ source_set("eg_tests") {
]
deps = [
":autofill_ui",
":test_support",
"//components/autofill/core/browser",
"//components/autofill/ios/browser:autofill_test_bundle_data",
"//components/autofill/ios/browser:test_support",
......@@ -153,6 +155,7 @@ source_set("eg_tests") {
"//ios/chrome/test:eg_test_support",
"//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ios/web/public/js_messaging",
"//ios/web/public/test/http_server",
"//services/network:test_support",
......@@ -163,6 +166,29 @@ source_set("eg_tests") {
]
}
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"save_profile_egtest.mm",
]
deps = [
":eg_test_support+eg2",
"//base",
"//base/test:test_support",
"//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/http_server",
"//testing/gtest",
]
libs = [ "UIKit.framework" ]
}
source_set("test_support") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ]
......
......@@ -21,13 +21,16 @@
// Saves an example form in the store for the passed URL spec.
+ (void)savePasswordFormForURLSpec:(NSString*)URLSpec;
// Returns the number of profiles (addresses) in the data manager.
+ (NSInteger)profilesCount;
// 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.
// Returns the name of the sample profile.
+ (NSString*)exampleProfileName;
// Removes the stored credit cards.
......
......@@ -160,6 +160,12 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
SaveLocalPasswordForm(GURL(base::SysNSStringToUTF8(URLSpec)));
}
+ (NSInteger)profilesCount {
autofill::PersonalDataManager* personalDataManager =
[self personalDataManager];
return personalDataManager->GetProfiles().size();
}
+ (void)clearProfilesStore {
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
......
......@@ -2,17 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <EarlGrey/EarlGrey.h>
#include <memory>
#include "base/logging.h"
#import "base/test/ios/wait_util.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
#import "ios/chrome/test/app/chrome_test_util.h"
#import "ios/chrome/browser/ui/autofill/autofill_app_interface.h"
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
#import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/earl_grey_test.h"
#import "ios/web/public/test/http_server/http_server.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -28,27 +25,15 @@ const char kProfileForm[] =
} // namepsace
@interface SaveProfileEGTest : ChromeTestCase {
autofill::PersonalDataManager* personal_data_manager_;
}
@interface SaveProfileEGTest : ChromeTestCase
@end
@implementation SaveProfileEGTest
- (void)setUp {
[super setUp];
personal_data_manager_ =
autofill::PersonalDataManagerFactory::GetForBrowserState(
chrome_test_util::GetOriginalBrowserState());
}
- (void)tearDown {
// Clear existing profile.
for (const auto* profile : personal_data_manager_->GetProfiles()) {
personal_data_manager_->RemoveByGUID(profile->guid());
}
[AutofillAppInterface clearProfilesStore];
[super tearDown];
}
......@@ -67,13 +52,13 @@ const char kProfileForm[] =
[ChromeEarlGrey loadURL:web::test::HttpServer::MakeUrl(kProfileForm)];
// Ensure there are no saved profiles.
GREYAssertEqual(0U, personal_data_manager_->GetProfiles().size(),
GREYAssertEqual(0U, [AutofillAppInterface profilesCount],
@"There should be no saved profile.");
[self fillAndSubmitForm];
// Ensure profile is saved locally.
GREYAssertEqual(1U, personal_data_manager_->GetProfiles().size(),
GREYAssertEqual(1U, [AutofillAppInterface profilesCount],
@"Profile should have been saved.");
}
......
......@@ -64,6 +64,7 @@ chrome_ios_eg2_test("ios_chrome_ui_eg2tests_module") {
deps = [
"//ios/chrome/browser/ui/activity_services:eg2_tests",
"//ios/chrome/browser/ui/autofill:eg2_tests",
"//ios/chrome/browser/ui/autofill/manual_fill:eg2_tests",
"//ios/chrome/browser/ui/content_suggestions:eg2_tests",
"//ios/chrome/browser/ui/download: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