OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "chrome/browser/signin/account_reconcilor.h" | 6 #include "chrome/browser/signin/account_reconcilor.h" |
7 #include "chrome/browser/signin/account_reconcilor_factory.h" | 7 #include "chrome/browser/signin/account_reconcilor_factory.h" |
8 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 8 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
9 #include "chrome/browser/signin/fake_signin_manager.h" | 9 #include "chrome/browser/signin/fake_signin_manager.h" |
10 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #endif | 94 #endif |
95 | 95 |
96 TEST_F(AccountReconcilorTest, ProfileAlreadyConnected) { | 96 TEST_F(AccountReconcilorTest, ProfileAlreadyConnected) { |
97 signin_manager()->SetAuthenticatedUsername(kTestEmail); | 97 signin_manager()->SetAuthenticatedUsername(kTestEmail); |
98 | 98 |
99 AccountReconcilor* reconcilor = | 99 AccountReconcilor* reconcilor = |
100 AccountReconcilorFactory::GetForProfile(profile()); | 100 AccountReconcilorFactory::GetForProfile(profile()); |
101 ASSERT_TRUE(NULL != reconcilor); | 101 ASSERT_TRUE(NULL != reconcilor); |
102 ASSERT_TRUE(reconcilor->IsPeriodicReconciliationRunning()); | 102 ASSERT_TRUE(reconcilor->IsPeriodicReconciliationRunning()); |
103 } | 103 } |
| 104 |
| 105 TEST_F(AccountReconcilorTest, ParseListAccountsData) { |
| 106 std::vector<std::string> accounts; |
| 107 accounts = AccountReconcilor::ParseListAccountsData(""); |
| 108 ASSERT_EQ(0u, accounts.size()); |
| 109 |
| 110 accounts = AccountReconcilor::ParseListAccountsData("1"); |
| 111 ASSERT_EQ(0u, accounts.size()); |
| 112 |
| 113 accounts = AccountReconcilor::ParseListAccountsData("[]"); |
| 114 ASSERT_EQ(0u, accounts.size()); |
| 115 |
| 116 accounts = AccountReconcilor::ParseListAccountsData("[\"foo\", \"bar\"]"); |
| 117 ASSERT_EQ(0u, accounts.size()); |
| 118 |
| 119 accounts = AccountReconcilor::ParseListAccountsData("[\"foo\", []]"); |
| 120 ASSERT_EQ(0u, accounts.size()); |
| 121 |
| 122 accounts = AccountReconcilor::ParseListAccountsData( |
| 123 "[\"foo\", [[\"bar\", 0, \"name\", 0, \"photo\", 0, 0, 0]]]"); |
| 124 ASSERT_EQ(0u, accounts.size()); |
| 125 |
| 126 accounts = AccountReconcilor::ParseListAccountsData( |
| 127 "[\"foo\", [[\"bar\", 0, \"name\", \"email\", \"photo\", 0, 0, 0]]]"); |
| 128 ASSERT_EQ(1u, accounts.size()); |
| 129 ASSERT_EQ("email", accounts[0]); |
| 130 |
| 131 accounts = AccountReconcilor::ParseListAccountsData( |
| 132 "[\"foo\", [[\"bar1\", 0, \"name1\", \"email1\", \"photo1\", 0, 0, 0], " |
| 133 "[\"bar2\", 0, \"name2\", \"email2\", \"photo2\", 0, 0, 0]]]"); |
| 134 ASSERT_EQ(2u, accounts.size()); |
| 135 ASSERT_EQ("email1", accounts[0]); |
| 136 ASSERT_EQ("email2", accounts[1]); |
| 137 } |
OLD | NEW |