| OLD | NEW |
| 1 // Copyright (c) 2011 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" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| (...skipping 198 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 = new SigninManager(); | 218 SigninManager* signin = new SigninManager(); |
| 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 service_.get()); | 234 service_.get()); |
| 233 | 235 |
| 234 EXPECT_CALL(factory_, CreatePasswordSyncComponents(_, _, _)). | 236 EXPECT_CALL(*factory, CreatePasswordSyncComponents(_, _, _)). |
| 235 Times(AtLeast(1)). // Can be more if we hit NEEDS_CRYPTO. | 237 Times(AtLeast(1)). // Can be more if we hit NEEDS_CRYPTO. |
| 236 WillRepeatedly(MakePasswordSyncComponents(service_.get(), | 238 WillRepeatedly(MakePasswordSyncComponents(service_.get(), |
| 237 password_store_.get(), | 239 password_store_.get(), |
| 238 data_type_controller)); | 240 data_type_controller)); |
| 239 EXPECT_CALL(factory_, CreateDataTypeManager(_, _)). | 241 EXPECT_CALL(*factory, CreateDataTypeManager(_, _)). |
| 240 WillOnce(ReturnNewDataTypeManager()); | 242 WillOnce(ReturnNewDataTypeManager()); |
| 241 | 243 |
| 242 // We need tokens to get the tests going | 244 // We need tokens to get the tests going |
| 243 token_service_->IssueAuthTokenForTest( | 245 token_service_->IssueAuthTokenForTest( |
| 244 GaiaConstants::kSyncService, "token"); | 246 GaiaConstants::kSyncService, "token"); |
| 245 | 247 |
| 246 EXPECT_CALL(profile_, GetTokenService()). | 248 EXPECT_CALL(profile_, GetTokenService()). |
| 247 WillRepeatedly(Return(token_service_.get())); | 249 WillRepeatedly(Return(token_service_.get())); |
| 248 | 250 |
| 249 EXPECT_CALL(profile_, GetPasswordStore(_)). | 251 EXPECT_CALL(profile_, GetPasswordStore(_)). |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 CreateRootHelper create_root(this, syncable::PASSWORDS); | 616 CreateRootHelper create_root(this, syncable::PASSWORDS); |
| 615 StartSyncService(create_root.callback(), | 617 StartSyncService(create_root.callback(), |
| 616 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 618 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
| 617 | 619 |
| 618 std::vector<PasswordForm> new_sync_forms; | 620 std::vector<PasswordForm> new_sync_forms; |
| 619 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 621 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 620 | 622 |
| 621 EXPECT_EQ(1U, new_sync_forms.size()); | 623 EXPECT_EQ(1U, new_sync_forms.size()); |
| 622 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 624 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 623 } | 625 } |
| OLD | NEW |