Commit 18bf5948 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

[ios] Migrate recent_tabs_coordinator_unittest.mm to IdentityManager

Migrated to the IdentityManager by relying on IdentityTestEnvironment,
so that we can use MakePrimaryAccount() without needing to explicitly
pass a ProfileOAuth2TokenService and a SigninManagerBase.

Bug: 890825
Change-Id: I20e228e7d9f5d2c2154666d264e31b5154bdcff8
Reviewed-on: https://chromium-review.googlesource.com/c/1314635
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605304}
parent 75e43b13
......@@ -20,7 +20,6 @@ source_set("recent_tabs") {
"//base",
"//components/browser_sync",
"//components/sessions",
"//components/signin/core/browser",
"//components/sync",
"//ios/chrome/app/strings",
"//ios/chrome/browser/browser_state",
......@@ -100,7 +99,6 @@ source_set("unit_tests") {
"//base",
"//components/browser_sync",
"//components/browser_sync:test_support",
"//components/signin/core/browser",
"//components/sync_sessions",
"//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/signin",
......@@ -109,6 +107,8 @@ source_set("unit_tests") {
"//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/test:test_support",
"//ios/web/public/test",
"//services/identity/public/cpp",
"//services/identity/public/cpp:test_support",
"//testing/gtest",
"//third_party/ocmock",
]
......
......@@ -10,10 +10,8 @@
#include "components/browser_sync/profile_sync_service.h"
#include "components/browser_sync/profile_sync_service_mock.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_sessions/open_tabs_ui_delegate.h"
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h"
#include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sync_setup_service.h"
......@@ -23,6 +21,8 @@
#include "ios/chrome/test/block_cleanup_test.h"
#include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
#include "ios/web/public/test/test_web_thread_bundle.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "services/identity/public/cpp/identity_test_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "third_party/ocmock/OCMock/OCMock.h"
#import "third_party/ocmock/gtest_support.h"
......@@ -135,13 +135,14 @@ class RecentTabsTableCoordinatorTest : public BlockCleanupTest {
void SetupSyncState(BOOL signedIn,
BOOL syncEnabled,
BOOL hasForeignSessions) {
SigninManager* siginManager = ios::SigninManagerFactory::GetForBrowserState(
chrome_browser_state_.get());
if (signedIn)
siginManager->SetAuthenticatedAccountInfo("test", "test");
else if (siginManager->IsAuthenticated())
siginManager->SignOut(signin_metrics::SIGNOUT_TEST,
if (signedIn) {
identity_test_env()->MakePrimaryAccountAvailable("test");
} else if (identity_test_env()->identity_manager()->HasPrimaryAccount()) {
identity_test_env()->identity_manager()->ClearPrimaryAccount(
identity::IdentityManager::ClearAccountTokensAction::kDefault,
signin_metrics::SIGNOUT_TEST,
signin_metrics::SignoutDelete::IGNORE_METRIC);
}
SyncSetupServiceMock* syncSetupService = static_cast<SyncSetupServiceMock*>(
SyncSetupServiceFactory::GetForBrowserState(
......@@ -182,10 +183,15 @@ class RecentTabsTableCoordinatorTest : public BlockCleanupTest {
[coordinator_ start];
}
identity::IdentityTestEnvironment* identity_test_env() {
return &identity_test_env_;
}
protected:
web::TestWebThreadBundle thread_bundle_;
GoogleServiceAuthError no_error_;
IOSChromeScopedTestingLocalState local_state_;
identity::IdentityTestEnvironment identity_test_env_;
std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
std::unique_ptr<OpenTabsUIDelegateMock> open_tabs_ui_delegate_;
......
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