Commit 6dac44a6 authored by Nazerke's avatar Nazerke Committed by Commit Bot

[iOS][eg2] Convert accounts_table_egtest to EG2.

This CL
 - adds the source file to sources list,
 - adds required gn dependencies,
 - links to both eg1 and eg2 frameworks,
 _ adds helpers into SigninEarlGreyUtils used in
accounts_table_egtests.

Bug: 866147

Change-Id: I4435f82551f44a242f04e7af1dfd9d8a70583a06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903191
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Auto-Submit: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#721474}
parent 952460a7
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
// Adds |fakeIdentity| to the fake identity service. // Adds |fakeIdentity| to the fake identity service.
- (void)addFakeIdentity:(FakeChromeIdentity*)fakeIdentity; - (void)addFakeIdentity:(FakeChromeIdentity*)fakeIdentity;
// Removes |fakeIdentity| from the fake chrome identity service, to simulate
// identity removal from the device.
- (void)forgetFakeIdentity:(FakeChromeIdentity*)fakeIdentity;
// Induces a GREYAssert if |fakeIdentity| is not signed in to the active // Induces a GREYAssert if |fakeIdentity| is not signed in to the active
// profile. // profile.
- (void)checkSignedInWithFakeIdentity:(FakeChromeIdentity*)fakeIdentity; - (void)checkSignedInWithFakeIdentity:(FakeChromeIdentity*)fakeIdentity;
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
[SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity]; [SigninEarlGreyUtilsAppInterface addFakeIdentity:fakeIdentity];
} }
- (void)forgetFakeIdentity:(FakeChromeIdentity*)fakeIdentity {
[SigninEarlGreyUtilsAppInterface forgetFakeIdentity:fakeIdentity];
}
- (void)checkSignedInWithFakeIdentity:(FakeChromeIdentity*)fakeIdentity { - (void)checkSignedInWithFakeIdentity:(FakeChromeIdentity*)fakeIdentity {
BOOL fakeIdentityIsNonNil = fakeIdentity != nil; BOOL fakeIdentityIsNonNil = fakeIdentity != nil;
EG_TEST_HELPER_ASSERT_TRUE(fakeIdentityIsNonNil, @"Need to give an identity"); EG_TEST_HELPER_ASSERT_TRUE(fakeIdentityIsNonNil, @"Need to give an identity");
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
// Adds |fakeIdentity| to the fake identity service. // Adds |fakeIdentity| to the fake identity service.
+ (void)addFakeIdentity:(FakeChromeIdentity*)fakeIdentity; + (void)addFakeIdentity:(FakeChromeIdentity*)fakeIdentity;
// Removes |fakeIdentity| from the fake chrome identity service, to simulate
// identity removal from the device.
+ (void)forgetFakeIdentity:(FakeChromeIdentity*)fakeIdentity;
// Returns the gaia ID of the signed-in account. // Returns the gaia ID of the signed-in account.
+ (NSString*)primaryAccountGaiaID; + (NSString*)primaryAccountGaiaID;
......
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
fakeIdentity); fakeIdentity);
} }
+ (void)forgetFakeIdentity:(FakeChromeIdentity*)fakeIdentity {
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()
->ForgetIdentity(fakeIdentity, nil);
}
+ (NSString*)primaryAccountGaiaID { + (NSString*)primaryAccountGaiaID {
ios::ChromeBrowserState* browser_state = ios::ChromeBrowserState* browser_state =
chrome_test_util::GetOriginalBrowserState(); chrome_test_util::GetOriginalBrowserState();
......
...@@ -83,6 +83,7 @@ source_set("google_services") { ...@@ -83,6 +83,7 @@ source_set("google_services") {
} }
source_set("eg_tests") { source_set("eg_tests") {
defines = [ "CHROME_EARL_GREY_1" ]
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
testonly = true testonly = true
sources = [ sources = [
...@@ -101,6 +102,28 @@ source_set("eg_tests") { ...@@ -101,6 +102,28 @@ source_set("eg_tests") {
"//ios/chrome/test/app:test_support", "//ios/chrome/test/app:test_support",
"//ios/chrome/test/earl_grey:test_support", "//ios/chrome/test/earl_grey:test_support",
"//ios/public/provider/chrome/browser/signin:test_support", "//ios/public/provider/chrome/browser/signin:test_support",
"//ios/testing/earl_grey:earl_grey_support",
"//ui/base", "//ui/base",
] ]
} }
source_set("eg2_tests") {
defines = [ "CHROME_EARL_GREY_2" ]
configs += [
"//build/config/compiler:enable_arc",
"//build/config/ios:xctest_config",
]
testonly = true
sources = [
"accounts_table_egtest.mm",
]
deps = [
"//base",
"//ios/chrome/browser/ui/authentication:eg_test_support+eg2",
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
"//ios/public/provider/chrome/browser/signin:test_support",
"//ios/testing/earl_grey:eg_test_support+eg2",
"//ios/third_party/earl_grey2:test_lib",
]
libs = [ "UIKit.framework" ]
}
...@@ -2,15 +2,13 @@ ...@@ -2,15 +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/authentication/signin_earl_grey_ui.h" #import "ios/chrome/browser/ui/authentication/signin_earl_grey_ui.h"
#import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.h" #import "ios/chrome/browser/ui/authentication/signin_earlgrey_utils.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/public/provider/chrome/browser/signin/fake_chrome_identity.h" #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h"
#import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.h" #import "ios/testing/earl_grey/earl_grey_test.h"
#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."
...@@ -49,8 +47,7 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) { ...@@ -49,8 +47,7 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) {
// Forget |fakeIdentity|, screens should be popped back to the Main Settings. // Forget |fakeIdentity|, screens should be popped back to the Main Settings.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider() [SigninEarlGreyUtils forgetFakeIdentity:fakeIdentity];
->ForgetIdentity(fakeIdentity, nil);
[[EarlGrey selectElementWithMatcher:PrimarySignInButton()] [[EarlGrey selectElementWithMatcher:PrimarySignInButton()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
...@@ -64,8 +61,7 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) { ...@@ -64,8 +61,7 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) {
// account is removed while the "Disconnect Account" dialog is up. // account is removed while the "Disconnect Account" dialog is up.
- (void)testSignInPopUpAccountOnDisconnectAccount { - (void)testSignInPopUpAccountOnDisconnectAccount {
FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1]; FakeChromeIdentity* fakeIdentity = [SigninEarlGreyUtils fakeIdentity1];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()->AddIdentity( [SigninEarlGreyUtils addFakeIdentity:fakeIdentity];
fakeIdentity);
// Sign In |fakeIdentity|, then open the Account Settings. // Sign In |fakeIdentity|, then open the Account Settings.
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity]; [SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity];
...@@ -75,8 +71,7 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) { ...@@ -75,8 +71,7 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) {
// Forget |fakeIdentity|, screens should be popped back to the Main Settings. // Forget |fakeIdentity|, screens should be popped back to the Main Settings.
[[GREYUIThreadExecutor sharedInstance] drainUntilIdle]; [[GREYUIThreadExecutor sharedInstance] drainUntilIdle];
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider() [SigninEarlGreyUtils forgetFakeIdentity:fakeIdentity];
->ForgetIdentity(fakeIdentity, nil);
[[EarlGrey selectElementWithMatcher:PrimarySignInButton()] [[EarlGrey selectElementWithMatcher:PrimarySignInButton()]
assertWithMatcher:grey_sufficientlyVisible()]; assertWithMatcher:grey_sufficientlyVisible()];
...@@ -89,11 +84,9 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) { ...@@ -89,11 +84,9 @@ id<GREYMatcher> ButtonWithFakeIdentity(FakeChromeIdentity* fakeIdentity) {
// Tests that the Account Settings screen is correctly reloaded when one of // Tests that the Account Settings screen is correctly reloaded when one of
// the non-primary account is removed. // the non-primary account is removed.
- (void)testSignInReloadOnRemoveAccount { - (void)testSignInReloadOnRemoveAccount {
ios::FakeChromeIdentityService* identity_service =
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider();
FakeChromeIdentity* fakeIdentity1 = [SigninEarlGreyUtils fakeIdentity1]; FakeChromeIdentity* fakeIdentity1 = [SigninEarlGreyUtils fakeIdentity1];
FakeChromeIdentity* fakeIdentity2 = [SigninEarlGreyUtils fakeIdentity2]; FakeChromeIdentity* fakeIdentity2 = [SigninEarlGreyUtils fakeIdentity2];
identity_service->AddIdentity(fakeIdentity2); [SigninEarlGreyUtils addFakeIdentity:fakeIdentity2];
// Sign In |fakeIdentity|, then open the Account Settings. // Sign In |fakeIdentity|, then open the Account Settings.
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity1]; [SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity1];
......
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