| 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 const std::string kLSIDResponse = "{ lsid: \"Foo\" }"; | 43 const std::string kLSIDResponse = "{ lsid: \"Foo\" }"; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 61 } | 62 } |
| 62 | 63 |
| 63 std::string AccountIdToGivenName(const std::string account_id) { | 64 std::string AccountIdToGivenName(const std::string account_id) { |
| 64 return "given-name-" + account_id; | 65 return "given-name-" + account_id; |
| 65 } | 66 } |
| 66 | 67 |
| 67 std::string AccountIdToLocale(const std::string account_id) { | 68 std::string AccountIdToLocale(const std::string account_id) { |
| 68 return "locale-" + account_id; | 69 return "locale-" + account_id; |
| 69 } | 70 } |
| 70 | 71 |
| 72 std::string AccountIdToPictureURL(const std::string account_id) { |
| 73 return "picture_url-" + account_id; |
| 74 } |
| 75 |
| 71 void CheckAccountDetails(const std::string account_id, | 76 void CheckAccountDetails(const std::string account_id, |
| 72 const AccountTrackerService::AccountInfo& info) { | 77 const AccountTrackerService::AccountInfo& info) { |
| 73 EXPECT_EQ(account_id, info.account_id); | 78 EXPECT_EQ(account_id, info.account_id); |
| 74 EXPECT_EQ(AccountIdToGaiaId(account_id), info.gaia); | 79 EXPECT_EQ(AccountIdToGaiaId(account_id), info.gaia); |
| 75 EXPECT_EQ(AccountIdToEmail(account_id), info.email); | 80 EXPECT_EQ(AccountIdToEmail(account_id), info.email); |
| 76 EXPECT_EQ(AccountTrackerService::kNoHostedDomainFound, | 81 EXPECT_EQ(AccountTrackerService::kNoHostedDomainFound, |
| 77 info.hosted_domain); | 82 info.hosted_domain); |
| 78 EXPECT_EQ(AccountIdToFullName(account_id), info.full_name); | 83 EXPECT_EQ(AccountIdToFullName(account_id), info.full_name); |
| 79 EXPECT_EQ(AccountIdToGivenName(account_id), info.given_name); | 84 EXPECT_EQ(AccountIdToGivenName(account_id), info.given_name); |
| 80 EXPECT_EQ(AccountIdToLocale(account_id), info.locale); | 85 EXPECT_EQ(AccountIdToLocale(account_id), info.locale); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 account_id, "access_token-" + account_id, base::Time::Max()); | 289 account_id, "access_token-" + account_id, base::Time::Max()); |
| 285 } | 290 } |
| 286 | 291 |
| 287 std::string GenerateValidTokenInfoResponse(const std::string& account_id) { | 292 std::string GenerateValidTokenInfoResponse(const std::string& account_id) { |
| 288 return base::StringPrintf( | 293 return base::StringPrintf( |
| 289 kTokenInfoResponseFormat.c_str(), | 294 kTokenInfoResponseFormat.c_str(), |
| 290 AccountIdToGaiaId(account_id).c_str(), | 295 AccountIdToGaiaId(account_id).c_str(), |
| 291 AccountIdToEmail(account_id).c_str(), | 296 AccountIdToEmail(account_id).c_str(), |
| 292 AccountIdToFullName(account_id).c_str(), | 297 AccountIdToFullName(account_id).c_str(), |
| 293 AccountIdToGivenName(account_id).c_str(), | 298 AccountIdToGivenName(account_id).c_str(), |
| 294 AccountIdToLocale(account_id).c_str()); | 299 AccountIdToLocale(account_id).c_str(), |
| 300 AccountIdToPictureURL(account_id).c_str()); |
| 295 } | 301 } |
| 296 | 302 |
| 297 std::string GenerateIncompleteTokenInfoResponse( | 303 std::string GenerateIncompleteTokenInfoResponse( |
| 298 const std::string& account_id) { | 304 const std::string& account_id) { |
| 299 return base::StringPrintf( | 305 return base::StringPrintf( |
| 300 kTokenInfoIncompleteResponseFormat.c_str(), | 306 kTokenInfoIncompleteResponseFormat.c_str(), |
| 301 AccountIdToGaiaId(account_id).c_str(), | 307 AccountIdToGaiaId(account_id).c_str(), |
| 302 AccountIdToEmail(account_id).c_str()); | 308 AccountIdToEmail(account_id).c_str()); |
| 303 } | 309 } |
| 304 void ReturnOAuthUrlFetchSuccess(const std::string& account_id); | 310 void ReturnOAuthUrlFetchSuccess(const std::string& account_id); |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 tracker.GetAccounts(); | 747 tracker.GetAccounts(); |
| 742 ASSERT_EQ(2u, infos.size()); | 748 ASSERT_EQ(2u, infos.size()); |
| 743 ASSERT_TRUE(infos[0].IsValid()); | 749 ASSERT_TRUE(infos[0].IsValid()); |
| 744 ASSERT_TRUE(infos[1].IsValid()); | 750 ASSERT_TRUE(infos[1].IsValid()); |
| 745 | 751 |
| 746 tracker.EnableNetworkFetches(); | 752 tracker.EnableNetworkFetches(); |
| 747 ASSERT_FALSE(tracker.IsAllUserInfoFetched()); | 753 ASSERT_FALSE(tracker.IsAllUserInfoFetched()); |
| 748 tracker.Shutdown(); | 754 tracker.Shutdown(); |
| 749 } | 755 } |
| 750 } | 756 } |
| OLD | NEW |