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

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

Issue 1091363002: Change ProfileDownloader to use AccountTrackerService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up unit test. 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 11 matching lines...) Expand all
22 22
23 namespace { 23 namespace {
24 24
25 const std::string kTokenInfoResponseFormat = 25 const std::string kTokenInfoResponseFormat =
26 "{ \ 26 "{ \
27 \"id\": \"%s\", \ 27 \"id\": \"%s\", \
28 \"email\": \"%s\", \ 28 \"email\": \"%s\", \
29 \"hd\": \"\", \ 29 \"hd\": \"\", \
30 \"name\": \"%s\", \ 30 \"name\": \"%s\", \
31 \"given_name\": \"%s\", \ 31 \"given_name\": \"%s\", \
32 \"locale\": \"%s\" \ 32 \"locale\": \"%s\", \
33 \"picture\": \"%s\" \
33 }"; 34 }";
34 35
35 const std::string kTokenInfoIncompleteResponseFormat = 36 const std::string kTokenInfoIncompleteResponseFormat =
36 "{ \ 37 "{ \
37 \"id\": \"%s\", \ 38 \"id\": \"%s\", \
38 \"email\": \"%s\", \ 39 \"email\": \"%s\", \
39 \"hd\": \"\", \ 40 \"hd\": \"\", \
40 }"; 41 }";
41 42
42 enum TrackingEventType { 43 enum TrackingEventType {
(...skipping 14 matching lines...) Expand all
57 } 58 }
58 59
59 std::string AccountIdToGivenName(const std::string account_id) { 60 std::string AccountIdToGivenName(const std::string account_id) {
60 return "given-name-" + account_id; 61 return "given-name-" + account_id;
61 } 62 }
62 63
63 std::string AccountIdToLocale(const std::string account_id) { 64 std::string AccountIdToLocale(const std::string account_id) {
64 return "locale-" + account_id; 65 return "locale-" + account_id;
65 } 66 }
66 67
68 std::string AccountIdToPictureURL(const std::string account_id) {
69 return "picture_url-" + account_id;
70 }
71
67 void CheckAccountDetails(const std::string account_id, 72 void CheckAccountDetails(const std::string account_id,
68 const AccountTrackerService::AccountInfo& info) { 73 const AccountTrackerService::AccountInfo& info) {
69 EXPECT_EQ(account_id, info.account_id); 74 EXPECT_EQ(account_id, info.account_id);
70 EXPECT_EQ(AccountIdToGaiaId(account_id), info.gaia); 75 EXPECT_EQ(AccountIdToGaiaId(account_id), info.gaia);
71 EXPECT_EQ(AccountIdToEmail(account_id), info.email); 76 EXPECT_EQ(AccountIdToEmail(account_id), info.email);
72 EXPECT_EQ(AccountTrackerService::kNoHostedDomainFound, 77 EXPECT_EQ(AccountTrackerService::kNoHostedDomainFound,
73 info.hosted_domain); 78 info.hosted_domain);
74 EXPECT_EQ(AccountIdToFullName(account_id), info.full_name); 79 EXPECT_EQ(AccountIdToFullName(account_id), info.full_name);
75 EXPECT_EQ(AccountIdToGivenName(account_id), info.given_name); 80 EXPECT_EQ(AccountIdToGivenName(account_id), info.given_name);
76 EXPECT_EQ(AccountIdToLocale(account_id), info.locale); 81 EXPECT_EQ(AccountIdToLocale(account_id), info.locale);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 account_id, "access_token-" + account_id, base::Time::Max()); 280 account_id, "access_token-" + account_id, base::Time::Max());
276 } 281 }
277 282
278 std::string GenerateValidTokenInfoResponse(const std::string& account_id) { 283 std::string GenerateValidTokenInfoResponse(const std::string& account_id) {
279 return base::StringPrintf( 284 return base::StringPrintf(
280 kTokenInfoResponseFormat.c_str(), 285 kTokenInfoResponseFormat.c_str(),
281 AccountIdToGaiaId(account_id).c_str(), 286 AccountIdToGaiaId(account_id).c_str(),
282 AccountIdToEmail(account_id).c_str(), 287 AccountIdToEmail(account_id).c_str(),
283 AccountIdToFullName(account_id).c_str(), 288 AccountIdToFullName(account_id).c_str(),
284 AccountIdToGivenName(account_id).c_str(), 289 AccountIdToGivenName(account_id).c_str(),
285 AccountIdToLocale(account_id).c_str()); 290 AccountIdToLocale(account_id).c_str(),
291 AccountIdToPictureURL(account_id).c_str());
286 } 292 }
287 293
288 std::string GenerateIncompleteTokenInfoResponse( 294 std::string GenerateIncompleteTokenInfoResponse(
289 const std::string& account_id) { 295 const std::string& account_id) {
290 return base::StringPrintf( 296 return base::StringPrintf(
291 kTokenInfoIncompleteResponseFormat.c_str(), 297 kTokenInfoIncompleteResponseFormat.c_str(),
292 AccountIdToGaiaId(account_id).c_str(), 298 AccountIdToGaiaId(account_id).c_str(),
293 AccountIdToEmail(account_id).c_str()); 299 AccountIdToEmail(account_id).c_str());
294 } 300 }
295 void ReturnOAuthUrlFetchSuccess(const std::string& account_id); 301 void ReturnOAuthUrlFetchSuccess(const std::string& account_id);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 std::vector<AccountTrackerService::AccountInfo> infos = 672 std::vector<AccountTrackerService::AccountInfo> infos =
667 tracker.GetAccounts(); 673 tracker.GetAccounts();
668 ASSERT_EQ(1u, infos.size()); 674 ASSERT_EQ(1u, infos.size());
669 ASSERT_TRUE(infos[0].IsValid()); 675 ASSERT_TRUE(infos[0].IsValid());
670 // Check that no network fetches were made. 676 // Check that no network fetches were made.
671 ASSERT_TRUE(observer()->CheckEvents()); 677 ASSERT_TRUE(observer()->CheckEvents());
672 678
673 tracker.Shutdown(); 679 tracker.Shutdown();
674 } 680 }
675 } 681 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698