| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 ACTION_P(AcquireSyncTransaction, password_test_service) { | 72 ACTION_P(AcquireSyncTransaction, password_test_service) { |
| 73 // Check to make sure we can aquire a transaction (will crash if a transaction | 73 // Check to make sure we can aquire a transaction (will crash if a transaction |
| 74 // is already held by this thread, deadlock if held by another thread). | 74 // is already held by this thread, deadlock if held by another thread). |
| 75 syncer::WriteTransaction trans( | 75 syncer::WriteTransaction trans( |
| 76 FROM_HERE, password_test_service->GetUserShare()); | 76 FROM_HERE, password_test_service->GetUserShare()); |
| 77 DVLOG(1) << "Sync transaction acquired."; | 77 DVLOG(1) << "Sync transaction acquired."; |
| 78 } | 78 } |
| 79 | 79 |
| 80 static void QuitMessageLoop() { | 80 static void QuitMessageLoop() { |
| 81 MessageLoop::current()->Quit(); | 81 base::MessageLoop::current()->Quit(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 class NullPasswordStore : public MockPasswordStore { | 84 class NullPasswordStore : public MockPasswordStore { |
| 85 public: | 85 public: |
| 86 NullPasswordStore() {} | 86 NullPasswordStore() {} |
| 87 | 87 |
| 88 static scoped_refptr<RefcountedProfileKeyedService> Build(Profile* profile) { | 88 static scoped_refptr<RefcountedProfileKeyedService> Build(Profile* profile) { |
| 89 return scoped_refptr<RefcountedProfileKeyedService>(); | 89 return scoped_refptr<RefcountedProfileKeyedService>(); |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _)). | 240 EXPECT_CALL(*components, CreateDataTypeManager(_, _, _, _, _)). |
| 241 WillOnce(ReturnNewDataTypeManager()); | 241 WillOnce(ReturnNewDataTypeManager()); |
| 242 | 242 |
| 243 // We need tokens to get the tests going | 243 // We need tokens to get the tests going |
| 244 token_service_->IssueAuthTokenForTest( | 244 token_service_->IssueAuthTokenForTest( |
| 245 GaiaConstants::kSyncService, "token"); | 245 GaiaConstants::kSyncService, "token"); |
| 246 | 246 |
| 247 sync_service_->RegisterDataTypeController(data_type_controller); | 247 sync_service_->RegisterDataTypeController(data_type_controller); |
| 248 sync_service_->Initialize(); | 248 sync_service_->Initialize(); |
| 249 MessageLoop::current()->Run(); | 249 base::MessageLoop::current()->Run(); |
| 250 FlushLastDBTask(); | 250 FlushLastDBTask(); |
| 251 | 251 |
| 252 sync_service_->SetEncryptionPassphrase("foo", | 252 sync_service_->SetEncryptionPassphrase("foo", |
| 253 ProfileSyncService::IMPLICIT); | 253 ProfileSyncService::IMPLICIT); |
| 254 MessageLoop::current()->Run(); | 254 base::MessageLoop::current()->Run(); |
| 255 } | 255 } |
| 256 } | 256 } |
| 257 | 257 |
| 258 // Helper to sort the results of GetPasswordEntriesFromSyncDB. The sorting | 258 // Helper to sort the results of GetPasswordEntriesFromSyncDB. The sorting |
| 259 // doesn't need to be particularly intelligent, it just needs to be consistent | 259 // doesn't need to be particularly intelligent, it just needs to be consistent |
| 260 // enough that we can base our tests expectations on the ordering it provides. | 260 // enough that we can base our tests expectations on the ordering it provides. |
| 261 static bool PasswordFormComparator(const PasswordForm& pf1, | 261 static bool PasswordFormComparator(const PasswordForm& pf1, |
| 262 const PasswordForm& pf2) { | 262 const PasswordForm& pf2) { |
| 263 if (pf1.submit_element < pf2.submit_element) | 263 if (pf1.submit_element < pf2.submit_element) |
| 264 return true; | 264 return true; |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 CreateRootHelper create_root(this, syncer::PASSWORDS); | 659 CreateRootHelper create_root(this, syncer::PASSWORDS); |
| 660 StartSyncService(create_root.callback(), | 660 StartSyncService(create_root.callback(), |
| 661 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 661 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
| 662 | 662 |
| 663 std::vector<PasswordForm> new_sync_forms; | 663 std::vector<PasswordForm> new_sync_forms; |
| 664 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 664 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 665 | 665 |
| 666 EXPECT_EQ(1U, new_sync_forms.size()); | 666 EXPECT_EQ(1U, new_sync_forms.size()); |
| 667 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 667 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 668 } | 668 } |
| OLD | NEW |