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") { ...@@ -20,7 +20,6 @@ source_set("recent_tabs") {
"//base", "//base",
"//components/browser_sync", "//components/browser_sync",
"//components/sessions", "//components/sessions",
"//components/signin/core/browser",
"//components/sync", "//components/sync",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
...@@ -100,7 +99,6 @@ source_set("unit_tests") { ...@@ -100,7 +99,6 @@ source_set("unit_tests") {
"//base", "//base",
"//components/browser_sync", "//components/browser_sync",
"//components/browser_sync:test_support", "//components/browser_sync:test_support",
"//components/signin/core/browser",
"//components/sync_sessions", "//components/sync_sessions",
"//ios/chrome/browser/browser_state:test_support", "//ios/chrome/browser/browser_state:test_support",
"//ios/chrome/browser/signin", "//ios/chrome/browser/signin",
...@@ -109,6 +107,8 @@ source_set("unit_tests") { ...@@ -109,6 +107,8 @@ source_set("unit_tests") {
"//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/test:test_support", "//ios/chrome/test:test_support",
"//ios/web/public/test", "//ios/web/public/test",
"//services/identity/public/cpp",
"//services/identity/public/cpp:test_support",
"//testing/gtest", "//testing/gtest",
"//third_party/ocmock", "//third_party/ocmock",
] ]
......
...@@ -10,10 +10,8 @@ ...@@ -10,10 +10,8 @@
#include "components/browser_sync/profile_sync_service.h" #include "components/browser_sync/profile_sync_service.h"
#include "components/browser_sync/profile_sync_service_mock.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 "components/sync_sessions/open_tabs_ui_delegate.h"
#include "ios/chrome/browser/browser_state/test_chrome_browser_state.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/ios_chrome_profile_sync_test_util.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h" #include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#include "ios/chrome/browser/sync/sync_setup_service.h" #include "ios/chrome/browser/sync/sync_setup_service.h"
...@@ -23,6 +21,8 @@ ...@@ -23,6 +21,8 @@
#include "ios/chrome/test/block_cleanup_test.h" #include "ios/chrome/test/block_cleanup_test.h"
#include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h" #include "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
#include "ios/web/public/test/test_web_thread_bundle.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" #include "testing/gtest/include/gtest/gtest.h"
#import "third_party/ocmock/OCMock/OCMock.h" #import "third_party/ocmock/OCMock/OCMock.h"
#import "third_party/ocmock/gtest_support.h" #import "third_party/ocmock/gtest_support.h"
...@@ -135,13 +135,14 @@ class RecentTabsTableCoordinatorTest : public BlockCleanupTest { ...@@ -135,13 +135,14 @@ class RecentTabsTableCoordinatorTest : public BlockCleanupTest {
void SetupSyncState(BOOL signedIn, void SetupSyncState(BOOL signedIn,
BOOL syncEnabled, BOOL syncEnabled,
BOOL hasForeignSessions) { BOOL hasForeignSessions) {
SigninManager* siginManager = ios::SigninManagerFactory::GetForBrowserState( if (signedIn) {
chrome_browser_state_.get()); identity_test_env()->MakePrimaryAccountAvailable("test");
if (signedIn) } else if (identity_test_env()->identity_manager()->HasPrimaryAccount()) {
siginManager->SetAuthenticatedAccountInfo("test", "test"); identity_test_env()->identity_manager()->ClearPrimaryAccount(
else if (siginManager->IsAuthenticated()) identity::IdentityManager::ClearAccountTokensAction::kDefault,
siginManager->SignOut(signin_metrics::SIGNOUT_TEST, signin_metrics::SIGNOUT_TEST,
signin_metrics::SignoutDelete::IGNORE_METRIC); signin_metrics::SignoutDelete::IGNORE_METRIC);
}
SyncSetupServiceMock* syncSetupService = static_cast<SyncSetupServiceMock*>( SyncSetupServiceMock* syncSetupService = static_cast<SyncSetupServiceMock*>(
SyncSetupServiceFactory::GetForBrowserState( SyncSetupServiceFactory::GetForBrowserState(
...@@ -182,10 +183,15 @@ class RecentTabsTableCoordinatorTest : public BlockCleanupTest { ...@@ -182,10 +183,15 @@ class RecentTabsTableCoordinatorTest : public BlockCleanupTest {
[coordinator_ start]; [coordinator_ start];
} }
identity::IdentityTestEnvironment* identity_test_env() {
return &identity_test_env_;
}
protected: protected:
web::TestWebThreadBundle thread_bundle_; web::TestWebThreadBundle thread_bundle_;
GoogleServiceAuthError no_error_; GoogleServiceAuthError no_error_;
IOSChromeScopedTestingLocalState local_state_; IOSChromeScopedTestingLocalState local_state_;
identity::IdentityTestEnvironment identity_test_env_;
std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
std::unique_ptr<OpenTabsUIDelegateMock> open_tabs_ui_delegate_; 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