OLD | NEW |
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 Loading... |
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 Loading... |
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 account_id, "access_token-" + account_id, base::Time::Max()); | 282 account_id, "access_token-" + account_id, base::Time::Max()); |
278 } | 283 } |
279 | 284 |
280 std::string GenerateValidTokenInfoResponse(const std::string& account_id) { | 285 std::string GenerateValidTokenInfoResponse(const std::string& account_id) { |
281 return base::StringPrintf( | 286 return base::StringPrintf( |
282 kTokenInfoResponseFormat.c_str(), | 287 kTokenInfoResponseFormat.c_str(), |
283 AccountIdToGaiaId(account_id).c_str(), | 288 AccountIdToGaiaId(account_id).c_str(), |
284 AccountIdToEmail(account_id).c_str(), | 289 AccountIdToEmail(account_id).c_str(), |
285 AccountIdToFullName(account_id).c_str(), | 290 AccountIdToFullName(account_id).c_str(), |
286 AccountIdToGivenName(account_id).c_str(), | 291 AccountIdToGivenName(account_id).c_str(), |
287 AccountIdToLocale(account_id).c_str()); | 292 AccountIdToLocale(account_id).c_str(), |
| 293 AccountIdToPictureURL(account_id).c_str()); |
288 } | 294 } |
289 | 295 |
290 std::string GenerateIncompleteTokenInfoResponse( | 296 std::string GenerateIncompleteTokenInfoResponse( |
291 const std::string& account_id) { | 297 const std::string& account_id) { |
292 return base::StringPrintf( | 298 return base::StringPrintf( |
293 kTokenInfoIncompleteResponseFormat.c_str(), | 299 kTokenInfoIncompleteResponseFormat.c_str(), |
294 AccountIdToGaiaId(account_id).c_str(), | 300 AccountIdToGaiaId(account_id).c_str(), |
295 AccountIdToEmail(account_id).c_str()); | 301 AccountIdToEmail(account_id).c_str()); |
296 } | 302 } |
297 void ReturnOAuthUrlFetchSuccess(const std::string& account_id); | 303 void ReturnOAuthUrlFetchSuccess(const std::string& account_id); |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 tracker.GetAccounts(); | 738 tracker.GetAccounts(); |
733 ASSERT_EQ(2u, infos.size()); | 739 ASSERT_EQ(2u, infos.size()); |
734 ASSERT_TRUE(infos[0].IsValid()); | 740 ASSERT_TRUE(infos[0].IsValid()); |
735 ASSERT_TRUE(infos[1].IsValid()); | 741 ASSERT_TRUE(infos[1].IsValid()); |
736 | 742 |
737 tracker.EnableNetworkFetches(); | 743 tracker.EnableNetworkFetches(); |
738 ASSERT_FALSE(tracker.IsAllUserInfoFetched()); | 744 ASSERT_FALSE(tracker.IsAllUserInfoFetched()); |
739 tracker.Shutdown(); | 745 tracker.Shutdown(); |
740 } | 746 } |
741 } | 747 } |
OLD | NEW |