Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: chrome/browser/signin/signin_tracker_unittest.cc

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: rebased Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/signin_tracker_unittest.cc
diff --git a/chrome/browser/signin/signin_tracker_unittest.cc b/chrome/browser/signin/signin_tracker_unittest.cc
index e982549ab226a720d435c09c6c97c433bbfb8bb6..34483b70b9d17ec3717be1cc4d61d2b7aea947f1 100644
--- a/chrome/browser/signin/signin_tracker_unittest.cc
+++ b/chrome/browser/signin/signin_tracker_unittest.cc
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager.h"
@@ -18,6 +19,7 @@
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
@@ -69,11 +71,22 @@ class SigninTrackerTest : public testing::Test {
tracker_ =
SigninTrackerFactory::CreateForProfile(profile_.get(), &observer_);
}
+
void TearDown() override {
tracker_.reset();
profile_.reset();
}
+ // Seed the account tracker with information from logged in user. Normally
+ // this is done by UI code before calling SigninManager. Returns the string
+ // to use as the account_id.
+ std::string AddToAccountTracker(const std::string& gaia_id,
+ const std::string& email) {
+ AccountTrackerService* service =
+ AccountTrackerServiceFactory::GetForProfile(profile_.get());
+ return service->SeedAccountInfo(gaia_id, email);
+ }
+
content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<SigninTracker> tracker_;
scoped_ptr<TestingProfile> profile_;
@@ -99,7 +112,13 @@ TEST_F(SigninTrackerTest, SignInSucceeds) {
EXPECT_CALL(observer_, SigninSuccess());
EXPECT_CALL(observer_, SigninFailed(_)).Times(0);
- mock_signin_manager_->SetAuthenticatedUsername("user@gmail.com");
- fake_oauth2_token_service_->IssueRefreshTokenForUser(
- "user@gmail.com", "refresh_token");
+ AccountTrackerService* service =
+ AccountTrackerServiceFactory::GetForProfile(profile_.get());
+ std::string gaia_id = "gaia_id";
+ std::string email = "user@gmail.com";
+ std::string account_id = service->SeedAccountInfo(gaia_id, email);
+
+ mock_signin_manager_->SetAuthenticatedAccountInfo(gaia_id, email);
+ fake_oauth2_token_service_->IssueRefreshTokenForUser(account_id,
+ "refresh_token");
}

Powered by Google App Engine
This is Rietveld 408576698