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

Side by Side Diff: components/signin/core/browser/account_tracker_service_unittest.cc

Issue 473153002: Inline sign in extracts gaia id from HTTP header and seeds account tracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "components/signin/core/browser/account_tracker_service.h" 12 #include "components/signin/core/browser/account_tracker_service.h"
13 #include "components/signin/core/common/signin_pref_names.h"
13 #include "google_apis/gaia/fake_oauth2_token_service.h" 14 #include "google_apis/gaia/fake_oauth2_token_service.h"
14 #include "google_apis/gaia/gaia_oauth_client.h" 15 #include "google_apis/gaia/gaia_oauth_client.h"
15 #include "net/http/http_status_code.h" 16 #include "net/http/http_status_code.h"
16 #include "net/url_request/test_url_fetcher_factory.h" 17 #include "net/url_request/test_url_fetcher_factory.h"
17 #include "net/url_request/url_fetcher_delegate.h" 18 #include "net/url_request/url_fetcher_delegate.h"
18 #include "net/url_request/url_request_test_util.h" 19 #include "net/url_request/url_request_test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace { 22 namespace {
22 23
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 public: 192 public:
192 AccountTrackerServiceTest() {} 193 AccountTrackerServiceTest() {}
193 194
194 virtual ~AccountTrackerServiceTest() {} 195 virtual ~AccountTrackerServiceTest() {}
195 196
196 virtual void SetUp() override { 197 virtual void SetUp() override {
197 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); 198 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService());
198 199
199 pref_service_.registry()->RegisterListPref( 200 pref_service_.registry()->RegisterListPref(
200 AccountTrackerService::kAccountInfoPref); 201 AccountTrackerService::kAccountInfoPref);
202 pref_service_.registry()->RegisterIntegerPref(
203 prefs::kAccountIdMigrationState,
204 AccountTrackerService::MIGRATION_NOT_STARTED);
201 205
202 account_tracker_.reset(new AccountTrackerService()); 206 account_tracker_.reset(new AccountTrackerService());
203 account_tracker_->Initialize(fake_oauth2_token_service_.get(), 207 account_tracker_->Initialize(fake_oauth2_token_service_.get(),
204 &pref_service_, 208 &pref_service_,
205 new net::TestURLRequestContextGetter( 209 new net::TestURLRequestContextGetter(
206 message_loop_.message_loop_proxy())); 210 message_loop_.message_loop_proxy()));
207 account_tracker_->AddObserver(&observer_); 211 account_tracker_->AddObserver(&observer_);
208 } 212 }
209 213
210 virtual void TearDown() override { 214 virtual void TearDown() override {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 502
499 std::vector<AccountTrackerService::AccountInfo> infos = 503 std::vector<AccountTrackerService::AccountInfo> infos =
500 tracker.GetAccounts(); 504 tracker.GetAccounts();
501 ASSERT_EQ(1u, infos.size()); 505 ASSERT_EQ(1u, infos.size());
502 EXPECT_EQ("beta", infos[0].account_id); 506 EXPECT_EQ("beta", infos[0].account_id);
503 EXPECT_EQ(AccountIdToGaiaId("beta"), infos[0].gaia); 507 EXPECT_EQ(AccountIdToGaiaId("beta"), infos[0].gaia);
504 EXPECT_EQ(AccountIdToEmail("beta"), infos[0].email); 508 EXPECT_EQ(AccountIdToEmail("beta"), infos[0].email);
505 tracker.Shutdown(); 509 tracker.Shutdown();
506 } 510 }
507 } 511 }
512
513 TEST_F(AccountTrackerServiceTest, SeedAccountInfo) {
514 std::vector<AccountTrackerService::AccountInfo> infos =
515 account_tracker()->GetAccounts();
516 EXPECT_EQ(0u, infos.size());
517
518 const std::string gaia_id = AccountIdToGaiaId("alpha");
519 const std::string email = AccountIdToEmail("alpha");
520 const std::string account_id =
521 account_tracker()->PickAccountIdForAccount(gaia_id, email);
522 account_tracker()->SeedAccountInfo(gaia_id, email);
523
524 infos = account_tracker()->GetAccounts();
525 EXPECT_EQ(1u, infos.size());
526 EXPECT_EQ(account_id, infos[0].account_id);
527 EXPECT_EQ(gaia_id, infos[0].gaia);
528 EXPECT_EQ(email, infos[0].email);
529 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698