Commit 0221b43d authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][MF][EG2] Migrate Fallback View Controller tests

Bug: 1017690
Change-Id: I68b0643a099456c41c1abd483c1ae66edc957398
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1878411
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709892}
parent af2a5eaf
...@@ -238,6 +238,7 @@ source_set("eg2_tests") { ...@@ -238,6 +238,7 @@ source_set("eg2_tests") {
sources = [ sources = [
"card_view_controller_egtest.mm", "card_view_controller_egtest.mm",
"fallback_coordinator_egtest.mm", "fallback_coordinator_egtest.mm",
"fallback_view_controller_egtest.mm",
"password_view_controller_egtest.mm", "password_view_controller_egtest.mm",
] ]
deps = [ deps = [
......
...@@ -2,25 +2,13 @@ ...@@ -2,25 +2,13 @@
// 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> #import "ios/chrome/browser/ui/autofill/autofill_app_interface.h"
#include <atomic>
#include "base/ios/ios_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/autofill/core/common/autofill_features.h"
#include "components/autofill/ios/browser/autofill_switches.h"
#include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_accessory_view_controller.h"
#import "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/test/app/chrome_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_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/web/public/test/earl_grey/web_view_matchers.h" #import "ios/testing/earl_grey/earl_grey_test.h"
#include "ios/web/public/test/element_selector.h" #include "ios/web/public/test/element_selector.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -30,6 +18,7 @@ ...@@ -30,6 +18,7 @@
#endif #endif
using chrome_test_util::TapWebElementWithId; using chrome_test_util::TapWebElementWithId;
using chrome_test_util::ManualFallbackProfilesIconMatcher;
namespace { namespace {
...@@ -38,47 +27,18 @@ constexpr char kFormElementReadonly[] = "readonly_field"; ...@@ -38,47 +27,18 @@ constexpr char kFormElementReadonly[] = "readonly_field";
constexpr char kFormHTMLFile[] = "/readonly_form.html"; constexpr char kFormHTMLFile[] = "/readonly_form.html";
// Returns a matcher for the profiles icon in the keyboard accessory bar.
id<GREYMatcher> ProfilesIconMatcher() {
return grey_accessibilityID(
manual_fill::AccessoryAddressAccessibilityIdentifier);
}
// 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);
GREYAssert(base::test::ios::WaitUntilConditionOrTimeout(
base::test::ios::kWaitForActionTimeout,
^bool() {
return profileCount <
personalDataManager->GetProfiles().size();
}),
@"Failed to add profile.");
}
} // namespace } // namespace
// Integration Tests for fallback coordinator. // Integration Tests for fallback coordinator.
@interface FallbackViewControllerTestCase : ChromeTestCase { @interface FallbackViewControllerTestCase : ChromeTestCase
// The PersonalDataManager instance for the current browser state.
autofill::PersonalDataManager* _personalDataManager;
}
@end @end
@implementation FallbackViewControllerTestCase @implementation FallbackViewControllerTestCase
- (void)setUp { - (void)setUp {
[super setUp]; [super setUp];
ios::ChromeBrowserState* browserState = [AutofillAppInterface clearProfilesStore];
chrome_test_util::GetOriginalBrowserState(); [AutofillAppInterface saveExampleProfile];
_personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState(browserState);
_personalDataManager->SetSyncingForTest(true);
_personalDataManager->ClearAllLocalData();
AddAutofillProfile(_personalDataManager);
GREYAssertTrue(self.testServer->Start(), @"Test server failed to start."); GREYAssertTrue(self.testServer->Start(), @"Test server failed to start.");
const GURL URL = self.testServer->GetURL(kFormHTMLFile); const GURL URL = self.testServer->GetURL(kFormHTMLFile);
...@@ -87,7 +47,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) { ...@@ -87,7 +47,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
} }
- (void)tearDown { - (void)tearDown {
_personalDataManager->ClearAllLocalData(); [AutofillAppInterface clearProfilesStore];
[super tearDown]; [super tearDown];
} }
...@@ -98,7 +58,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) { ...@@ -98,7 +58,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementReadonly)]; performAction:TapWebElementWithId(kFormElementReadonly)];
// Verify the profiles icon is not visible. // Verify the profiles icon is not visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()] [[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_notVisible()]; assertWithMatcher:grey_notVisible()];
} }
...@@ -110,7 +70,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) { ...@@ -110,7 +70,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementNormal)]; performAction:TapWebElementWithId(kFormElementNormal)];
// Verify the profiles icon is visible. // Verify the profiles icon is visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()] [[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
// Tap the readonly field. // Tap the readonly field.
...@@ -118,7 +78,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) { ...@@ -118,7 +78,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementReadonly)]; performAction:TapWebElementWithId(kFormElementReadonly)];
// Verify the profiles icon is not visible. // Verify the profiles icon is not visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()] [[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_notVisible()]; assertWithMatcher:grey_notVisible()];
} }
...@@ -130,7 +90,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) { ...@@ -130,7 +90,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementReadonly)]; performAction:TapWebElementWithId(kFormElementReadonly)];
// Verify the profiles icon is not visible. // Verify the profiles icon is not visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()] [[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_notVisible()]; assertWithMatcher:grey_notVisible()];
// Tap the regular field. // Tap the regular field.
...@@ -138,7 +98,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) { ...@@ -138,7 +98,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementNormal)]; performAction:TapWebElementWithId(kFormElementNormal)];
// Verify the profiles icon is visible. // Verify the profiles icon is visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()] [[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
} }
......
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