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") {
sources = [
"card_view_controller_egtest.mm",
"fallback_coordinator_egtest.mm",
"fallback_view_controller_egtest.mm",
"password_view_controller_egtest.mm",
]
deps = [
......
......@@ -2,25 +2,13 @@
// 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 <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/browser/ui/autofill/autofill_app_interface.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_ui.h"
#import "ios/chrome/test/earl_grey/chrome_matchers.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 "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
......@@ -30,6 +18,7 @@
#endif
using chrome_test_util::TapWebElementWithId;
using chrome_test_util::ManualFallbackProfilesIconMatcher;
namespace {
......@@ -38,47 +27,18 @@ constexpr char kFormElementReadonly[] = "readonly_field";
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
// Integration Tests for fallback coordinator.
@interface FallbackViewControllerTestCase : ChromeTestCase {
// The PersonalDataManager instance for the current browser state.
autofill::PersonalDataManager* _personalDataManager;
}
@interface FallbackViewControllerTestCase : ChromeTestCase
@end
@implementation FallbackViewControllerTestCase
- (void)setUp {
[super setUp];
ios::ChromeBrowserState* browserState =
chrome_test_util::GetOriginalBrowserState();
_personalDataManager =
autofill::PersonalDataManagerFactory::GetForBrowserState(browserState);
_personalDataManager->SetSyncingForTest(true);
_personalDataManager->ClearAllLocalData();
AddAutofillProfile(_personalDataManager);
[AutofillAppInterface clearProfilesStore];
[AutofillAppInterface saveExampleProfile];
GREYAssertTrue(self.testServer->Start(), @"Test server failed to start.");
const GURL URL = self.testServer->GetURL(kFormHTMLFile);
......@@ -87,7 +47,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
}
- (void)tearDown {
_personalDataManager->ClearAllLocalData();
[AutofillAppInterface clearProfilesStore];
[super tearDown];
}
......@@ -98,7 +58,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementReadonly)];
// Verify the profiles icon is not visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()]
[[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_notVisible()];
}
......@@ -110,7 +70,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementNormal)];
// Verify the profiles icon is visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()]
[[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_sufficientlyVisible()];
// Tap the readonly field.
......@@ -118,7 +78,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementReadonly)];
// Verify the profiles icon is not visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()]
[[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_notVisible()];
}
......@@ -130,7 +90,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementReadonly)];
// Verify the profiles icon is not visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()]
[[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
assertWithMatcher:grey_notVisible()];
// Tap the regular field.
......@@ -138,7 +98,7 @@ void AddAutofillProfile(autofill::PersonalDataManager* personalDataManager) {
performAction:TapWebElementWithId(kFormElementNormal)];
// Verify the profiles icon is visible.
[[EarlGrey selectElementWithMatcher:ProfilesIconMatcher()]
[[EarlGrey selectElementWithMatcher:ManualFallbackProfilesIconMatcher()]
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