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

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

Issue 1130853003: Add service flags to the AccountTrackerService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback. Created 5 years, 7 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
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"
(...skipping 21 matching lines...) Expand all
32 \"locale\": \"%s\" \ 32 \"locale\": \"%s\" \
33 }"; 33 }";
34 34
35 const std::string kTokenInfoIncompleteResponseFormat = 35 const std::string kTokenInfoIncompleteResponseFormat =
36 "{ \ 36 "{ \
37 \"id\": \"%s\", \ 37 \"id\": \"%s\", \
38 \"email\": \"%s\", \ 38 \"email\": \"%s\", \
39 \"hd\": \"\", \ 39 \"hd\": \"\", \
40 }"; 40 }";
41 41
42 const std::string kLSIDResponse = "{ lsid: \"Foo\" }";
43
44 const std::string kServiceFlags = "allServices=Service1,Service2";
45
42 enum TrackingEventType { 46 enum TrackingEventType {
43 UPDATED, 47 UPDATED,
44 REMOVED, 48 REMOVED,
45 }; 49 };
46 50
47 std::string AccountIdToEmail(const std::string account_id) { 51 std::string AccountIdToEmail(const std::string account_id) {
48 return account_id + "@gmail.com"; 52 return account_id + "@gmail.com";
49 } 53 }
50 54
51 std::string AccountIdToGaiaId(const std::string account_id) { 55 std::string AccountIdToGaiaId(const std::string account_id) {
(...skipping 15 matching lines...) Expand all
67 void CheckAccountDetails(const std::string account_id, 71 void CheckAccountDetails(const std::string account_id,
68 const AccountTrackerService::AccountInfo& info) { 72 const AccountTrackerService::AccountInfo& info) {
69 EXPECT_EQ(account_id, info.account_id); 73 EXPECT_EQ(account_id, info.account_id);
70 EXPECT_EQ(AccountIdToGaiaId(account_id), info.gaia); 74 EXPECT_EQ(AccountIdToGaiaId(account_id), info.gaia);
71 EXPECT_EQ(AccountIdToEmail(account_id), info.email); 75 EXPECT_EQ(AccountIdToEmail(account_id), info.email);
72 EXPECT_EQ(AccountTrackerService::kNoHostedDomainFound, 76 EXPECT_EQ(AccountTrackerService::kNoHostedDomainFound,
73 info.hosted_domain); 77 info.hosted_domain);
74 EXPECT_EQ(AccountIdToFullName(account_id), info.full_name); 78 EXPECT_EQ(AccountIdToFullName(account_id), info.full_name);
75 EXPECT_EQ(AccountIdToGivenName(account_id), info.given_name); 79 EXPECT_EQ(AccountIdToGivenName(account_id), info.given_name);
76 EXPECT_EQ(AccountIdToLocale(account_id), info.locale); 80 EXPECT_EQ(AccountIdToLocale(account_id), info.locale);
81 EXPECT_EQ(2U, info.service_flags.size());
82 EXPECT_EQ("Service1", info.service_flags[0]);
83 EXPECT_EQ("Service2", info.service_flags[1]);
77 } 84 }
78 85
79 class TrackingEvent { 86 class TrackingEvent {
80 public: 87 public:
81 TrackingEvent(TrackingEventType type, 88 TrackingEvent(TrackingEventType type,
82 const std::string& account_id, 89 const std::string& account_id,
83 const std::string& gaia_id) 90 const std::string& gaia_id)
84 : type_(type), 91 : type_(type),
85 account_id_(account_id), 92 account_id_(account_id),
86 gaia_id_(gaia_id) {} 93 gaia_id_(gaia_id) {}
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 fetcher->SetResponseString(response_string); 340 fetcher->SetResponseString(response_string);
334 fetcher->delegate()->OnURLFetchComplete(fetcher); 341 fetcher->delegate()->OnURLFetchComplete(fetcher);
335 } 342 }
336 343
337 void AccountTrackerServiceTest::ReturnOAuthUrlFetchSuccess( 344 void AccountTrackerServiceTest::ReturnOAuthUrlFetchSuccess(
338 const std::string& account_id) { 345 const std::string& account_id) {
339 IssueAccessToken(account_id); 346 IssueAccessToken(account_id);
340 ReturnOAuthUrlFetchResults(gaia::GaiaOAuthClient::kUrlFetcherId, 347 ReturnOAuthUrlFetchResults(gaia::GaiaOAuthClient::kUrlFetcherId,
341 net::HTTP_OK, 348 net::HTTP_OK,
342 GenerateValidTokenInfoResponse(account_id)); 349 GenerateValidTokenInfoResponse(account_id));
350 ReturnOAuthUrlFetchResults(0, net::HTTP_OK, kLSIDResponse);
351 ReturnOAuthUrlFetchResults(0, net::HTTP_OK, kServiceFlags);
343 } 352 }
344 353
345 void AccountTrackerServiceTest::ReturnOAuthUrlFetchSuccessIncomplete( 354 void AccountTrackerServiceTest::ReturnOAuthUrlFetchSuccessIncomplete(
346 const std::string& account_id) { 355 const std::string& account_id) {
347 IssueAccessToken(account_id); 356 IssueAccessToken(account_id);
348 ReturnOAuthUrlFetchResults(gaia::GaiaOAuthClient::kUrlFetcherId, 357 ReturnOAuthUrlFetchResults(gaia::GaiaOAuthClient::kUrlFetcherId,
349 net::HTTP_OK, 358 net::HTTP_OK,
350 GenerateIncompleteTokenInfoResponse(account_id)); 359 GenerateIncompleteTokenInfoResponse(account_id));
351 } 360 }
352 361
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 tracker.GetAccounts(); 741 tracker.GetAccounts();
733 ASSERT_EQ(2u, infos.size()); 742 ASSERT_EQ(2u, infos.size());
734 ASSERT_TRUE(infos[0].IsValid()); 743 ASSERT_TRUE(infos[0].IsValid());
735 ASSERT_TRUE(infos[1].IsValid()); 744 ASSERT_TRUE(infos[1].IsValid());
736 745
737 tracker.EnableNetworkFetches(); 746 tracker.EnableNetworkFetches();
738 ASSERT_FALSE(tracker.IsAllUserInfoFetched()); 747 ASSERT_FALSE(tracker.IsAllUserInfoFetched());
739 tracker.Shutdown(); 748 tracker.Shutdown();
740 } 749 }
741 } 750 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698