| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); | 210 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); |
| 211 done.TimedWait(base::TimeDelta::FromMilliseconds( | 211 done.TimedWait(base::TimeDelta::FromMilliseconds( |
| 212 TestTimeouts::action_timeout_ms())); | 212 TestTimeouts::action_timeout_ms())); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void StartSyncService(const base::Closure& root_callback, | 215 void StartSyncService(const base::Closure& root_callback, |
| 216 const base::Closure& node_callback) { | 216 const base::Closure& node_callback) { |
| 217 if (!service_.get()) { | 217 if (!service_.get()) { |
| 218 SigninManager* signin = profile_.GetSigninManager(); | 218 SigninManager* signin = profile_.GetSigninManager(); |
| 219 signin->SetAuthenticatedUsername("test_user"); | 219 signin->SetAuthenticatedUsername("test_user"); |
| 220 ProfileSyncComponentsFactoryMock* factory = |
| 221 new ProfileSyncComponentsFactoryMock(); |
| 220 service_.reset(new PasswordTestProfileSyncService( | 222 service_.reset(new PasswordTestProfileSyncService( |
| 221 &factory_, &profile_, signin, false, | 223 factory, &profile_, signin, false, |
| 222 root_callback, node_callback)); | 224 root_callback, node_callback)); |
| 223 syncable::ModelTypeSet preferred_types = | 225 syncable::ModelTypeSet preferred_types = |
| 224 service_->GetPreferredDataTypes(); | 226 service_->GetPreferredDataTypes(); |
| 225 preferred_types.Put(syncable::PASSWORDS); | 227 preferred_types.Put(syncable::PASSWORDS); |
| 226 service_->ChangePreferredDataTypes(preferred_types); | 228 service_->ChangePreferredDataTypes(preferred_types); |
| 227 EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly( | 229 EXPECT_CALL(profile_, GetProfileSyncService()).WillRepeatedly( |
| 228 Return(service_.get())); | 230 Return(service_.get())); |
| 229 PasswordDataTypeController* data_type_controller = | 231 PasswordDataTypeController* data_type_controller = |
| 230 new PasswordDataTypeController(&factory_, | 232 new PasswordDataTypeController(factory, |
| 231 &profile_); | 233 &profile_); |
| 232 | 234 |
| 233 EXPECT_CALL(factory_, CreatePasswordSyncComponents(_, _, _)). | 235 EXPECT_CALL(*factory, CreatePasswordSyncComponents(_, _, _)). |
| 234 Times(AtLeast(1)). // Can be more if we hit NEEDS_CRYPTO. | 236 Times(AtLeast(1)). // Can be more if we hit NEEDS_CRYPTO. |
| 235 WillRepeatedly(MakePasswordSyncComponents(service_.get(), | 237 WillRepeatedly(MakePasswordSyncComponents(service_.get(), |
| 236 password_store_.get(), | 238 password_store_.get(), |
| 237 data_type_controller)); | 239 data_type_controller)); |
| 238 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 240 EXPECT_CALL(*factory, CreateDataTypeManager(_, _)). |
| 239 WillOnce(ReturnNewDataTypeManager()); | 241 WillOnce(ReturnNewDataTypeManager()); |
| 240 | 242 |
| 241 // We need tokens to get the tests going | 243 // We need tokens to get the tests going |
| 242 token_service_->IssueAuthTokenForTest( | 244 token_service_->IssueAuthTokenForTest( |
| 243 GaiaConstants::kSyncService, "token"); | 245 GaiaConstants::kSyncService, "token"); |
| 244 | 246 |
| 245 EXPECT_CALL(profile_, GetTokenService()). | 247 EXPECT_CALL(profile_, GetTokenService()). |
| 246 WillRepeatedly(Return(token_service_.get())); | 248 WillRepeatedly(Return(token_service_.get())); |
| 247 | 249 |
| 248 EXPECT_CALL(profile_, GetPasswordStore(_)). | 250 EXPECT_CALL(profile_, GetPasswordStore(_)). |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 CreateRootHelper create_root(this, syncable::PASSWORDS); | 615 CreateRootHelper create_root(this, syncable::PASSWORDS); |
| 614 StartSyncService(create_root.callback(), | 616 StartSyncService(create_root.callback(), |
| 615 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 617 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
| 616 | 618 |
| 617 std::vector<PasswordForm> new_sync_forms; | 619 std::vector<PasswordForm> new_sync_forms; |
| 618 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 620 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 619 | 621 |
| 620 EXPECT_EQ(1U, new_sync_forms.size()); | 622 EXPECT_EQ(1U, new_sync_forms.size()); |
| 621 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 623 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 622 } | 624 } |
| OLD | NEW |