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

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

Issue 671183002: Revert of 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: 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
« no previous file with comments | « components/signin/core/browser/account_tracker_service.cc ('k') | google_apis/gaia/fake_gaia.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
14 #include "google_apis/gaia/fake_oauth2_token_service.h" 13 #include "google_apis/gaia/fake_oauth2_token_service.h"
15 #include "google_apis/gaia/gaia_oauth_client.h" 14 #include "google_apis/gaia/gaia_oauth_client.h"
16 #include "net/http/http_status_code.h" 15 #include "net/http/http_status_code.h"
17 #include "net/url_request/test_url_fetcher_factory.h" 16 #include "net/url_request/test_url_fetcher_factory.h"
18 #include "net/url_request/url_fetcher_delegate.h" 17 #include "net/url_request/url_fetcher_delegate.h"
19 #include "net/url_request/url_request_test_util.h" 18 #include "net/url_request/url_request_test_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 20
22 namespace { 21 namespace {
23 22
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 public: 191 public:
193 AccountTrackerServiceTest() {} 192 AccountTrackerServiceTest() {}
194 193
195 virtual ~AccountTrackerServiceTest() {} 194 virtual ~AccountTrackerServiceTest() {}
196 195
197 virtual void SetUp() override { 196 virtual void SetUp() override {
198 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); 197 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService());
199 198
200 pref_service_.registry()->RegisterListPref( 199 pref_service_.registry()->RegisterListPref(
201 AccountTrackerService::kAccountInfoPref); 200 AccountTrackerService::kAccountInfoPref);
202 pref_service_.registry()->RegisterIntegerPref(
203 prefs::kAccountIdMigrationState,
204 AccountTrackerService::MIGRATION_NOT_STARTED);
205 201
206 account_tracker_.reset(new AccountTrackerService()); 202 account_tracker_.reset(new AccountTrackerService());
207 account_tracker_->Initialize(fake_oauth2_token_service_.get(), 203 account_tracker_->Initialize(fake_oauth2_token_service_.get(),
208 &pref_service_, 204 &pref_service_,
209 new net::TestURLRequestContextGetter( 205 new net::TestURLRequestContextGetter(
210 message_loop_.message_loop_proxy())); 206 message_loop_.message_loop_proxy()));
211 account_tracker_->AddObserver(&observer_); 207 account_tracker_->AddObserver(&observer_);
212 } 208 }
213 209
214 virtual void TearDown() override { 210 virtual void TearDown() override {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 498
503 std::vector<AccountTrackerService::AccountInfo> infos = 499 std::vector<AccountTrackerService::AccountInfo> infos =
504 tracker.GetAccounts(); 500 tracker.GetAccounts();
505 ASSERT_EQ(1u, infos.size()); 501 ASSERT_EQ(1u, infos.size());
506 EXPECT_EQ("beta", infos[0].account_id); 502 EXPECT_EQ("beta", infos[0].account_id);
507 EXPECT_EQ(AccountIdToGaiaId("beta"), infos[0].gaia); 503 EXPECT_EQ(AccountIdToGaiaId("beta"), infos[0].gaia);
508 EXPECT_EQ(AccountIdToEmail("beta"), infos[0].email); 504 EXPECT_EQ(AccountIdToEmail("beta"), infos[0].email);
509 tracker.Shutdown(); 505 tracker.Shutdown();
510 } 506 }
511 } 507 }
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
« no previous file with comments | « components/signin/core/browser/account_tracker_service.cc ('k') | google_apis/gaia/fake_gaia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698