Commit c145d480 authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Add unit tests for user sign-in mediator.

Due to the sign-in architecture migration that extracts sign-in logic
into the mediator it is now possible to test this logic of the code.

Bug: 971989
Change-Id: I9a8279007bc219d3a7415a7b404c981073f9024d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098383
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752799}
parent eaeda580
...@@ -104,7 +104,8 @@ class SyncSetupService : public KeyedService { ...@@ -104,7 +104,8 @@ class SyncSetupService : public KeyedService {
// changes. PrepareForFirstSyncSetup() needs to be called before. This flag is // changes. PrepareForFirstSyncSetup() needs to be called before. This flag is
// not set if the user didn't turn on sync. // not set if the user didn't turn on sync.
// This method should only be used with UnifiedConsent flag. // This method should only be used with UnifiedConsent flag.
void SetFirstSetupComplete(syncer::SyncFirstSetupCompleteSource source); virtual void SetFirstSetupComplete(
syncer::SyncFirstSetupCompleteSource source);
// Returns true if the user finished the Sync setup flow. // Returns true if the user finished the Sync setup flow.
bool IsFirstSetupComplete() const; bool IsFirstSetupComplete() const;
......
...@@ -29,6 +29,9 @@ class SyncSetupServiceMock : public SyncSetupService { ...@@ -29,6 +29,9 @@ class SyncSetupServiceMock : public SyncSetupService {
MOCK_METHOD0(PrepareForFirstSyncSetup, void()); MOCK_METHOD0(PrepareForFirstSyncSetup, void());
MOCK_METHOD1(SetFirstSetupComplete,
void(syncer::SyncFirstSetupCompleteSource));
// Allow the real SyncSetupService::HasFinishedInitialSetup() to be used when // Allow the real SyncSetupService::HasFinishedInitialSetup() to be used when
// mocking HasFinishedInitialSetup(). // mocking HasFinishedInitialSetup().
bool SyncSetupServiceHasFinishedInitialSetup(); bool SyncSetupServiceHasFinishedInitialSetup();
......
...@@ -42,3 +42,36 @@ source_set("user_signin") { ...@@ -42,3 +42,36 @@ source_set("user_signin") {
public_deps = public_deps =
[ "//ios/chrome/browser/ui/authentication/signin:signin_headers" ] [ "//ios/chrome/browser/ui/authentication/signin:signin_headers" ]
} }
source_set("unit_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [ "user_signin_mediator_unittest.mm" ]
deps = [
":user_signin",
"//base/test:test_support",
"//components/consent_auditor:test_support",
"//components/prefs",
"//components/prefs:test_support",
"//components/sync/driver:test_support",
"//components/sync_preferences",
"//components/sync_preferences:test_support",
"//ios/chrome/app/strings",
"//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/main:test_support",
"//ios/chrome/browser/prefs:browser_prefs",
"//ios/chrome/browser/signin",
"//ios/chrome/browser/signin:test_support",
"//ios/chrome/browser/sync",
"//ios/chrome/browser/sync:test_support",
"//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/unified_consent",
"//ios/public/provider/chrome/browser/signin",
"//ios/public/provider/chrome/browser/signin:fake_chrome_identity",
"//ios/public/provider/chrome/browser/signin:test_support",
"//ios/web/public/test",
"//testing/gmock",
"//testing/gtest",
"//third_party/ocmock",
]
}
...@@ -76,7 +76,6 @@ ...@@ -76,7 +76,6 @@
- (void)cancelSignin { - (void)cancelSignin {
if (self.isAuthenticationInProgress) { if (self.isAuthenticationInProgress) {
[self cancelAndDismissAuthenticationFlow]; [self cancelAndDismissAuthenticationFlow];
[self.delegate userSigninMediatorNeedPrimaryButtonUpdate];
} else { } else {
[self.delegate userSigninMediatorSigninFinishedWithResult: [self.delegate userSigninMediatorSigninFinishedWithResult:
SigninCoordinatorResultCanceledByUser]; SigninCoordinatorResultCanceledByUser];
......
...@@ -228,6 +228,7 @@ test("ios_chrome_unittests") { ...@@ -228,6 +228,7 @@ test("ios_chrome_unittests") {
"//ios/chrome/browser/ui/authentication/cells:unit_tests", "//ios/chrome/browser/ui/authentication/cells:unit_tests",
"//ios/chrome/browser/ui/authentication/signin:unit_tests", "//ios/chrome/browser/ui/authentication/signin:unit_tests",
"//ios/chrome/browser/ui/authentication/signin/add_account_signin:unit_tests", "//ios/chrome/browser/ui/authentication/signin/add_account_signin:unit_tests",
"//ios/chrome/browser/ui/authentication/signin/user_signin:unit_tests",
"//ios/chrome/browser/ui/autofill/cells:unit_tests", "//ios/chrome/browser/ui/autofill/cells:unit_tests",
"//ios/chrome/browser/ui/autofill/manual_fill:unit_tests", "//ios/chrome/browser/ui/autofill/manual_fill:unit_tests",
"//ios/chrome/browser/ui/badges:unit_tests", "//ios/chrome/browser/ui/badges:unit_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