| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 profile_.CreateRequestContext(); | 146 profile_.CreateRequestContext(); |
| 147 password_store_ = new MockPasswordStore(); | 147 password_store_ = new MockPasswordStore(); |
| 148 db_thread_.Start(); | 148 db_thread_.Start(); |
| 149 | 149 |
| 150 notification_service_ = new ThreadNotificationService(&db_thread_); | 150 notification_service_ = new ThreadNotificationService(&db_thread_); |
| 151 notification_service_->Init(); | 151 notification_service_->Init(); |
| 152 registrar_.Add(&observer_, | 152 registrar_.Add(&observer_, |
| 153 NotificationType::SYNC_CONFIGURE_DONE, | 153 NotificationType::SYNC_CONFIGURE_DONE, |
| 154 NotificationService::AllSources()); | 154 NotificationService::AllSources()); |
| 155 registrar_.Add(&observer_, | 155 registrar_.Add(&observer_, |
| 156 NotificationType::SYNC_PAUSED, | 156 NotificationType::SYNC_CONFIGURE_BLOCKED, |
| 157 NotificationService::AllSources()); | 157 NotificationService::AllSources()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 virtual void TearDown() { | 160 virtual void TearDown() { |
| 161 service_.reset(); | 161 service_.reset(); |
| 162 notification_service_->TearDown(); | 162 notification_service_->TearDown(); |
| 163 db_thread_.Stop(); | 163 db_thread_.Stop(); |
| 164 { | 164 { |
| 165 // The request context gets deleted on the I/O thread. To prevent a leak | 165 // The request context gets deleted on the I/O thread. To prevent a leak |
| 166 // supply one here. | 166 // supply one here. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 EXPECT_CALL(profile_, GetPasswordStore(_)). | 212 EXPECT_CALL(profile_, GetPasswordStore(_)). |
| 213 Times(AtLeast(2)). // Can be more if we hit NEEDS_CRYPTO. | 213 Times(AtLeast(2)). // Can be more if we hit NEEDS_CRYPTO. |
| 214 WillRepeatedly(Return(password_store_.get())); | 214 WillRepeatedly(Return(password_store_.get())); |
| 215 | 215 |
| 216 EXPECT_CALL(observer_, | 216 EXPECT_CALL(observer_, |
| 217 Observe( | 217 Observe( |
| 218 NotificationType(NotificationType::SYNC_CONFIGURE_DONE),_,_)); | 218 NotificationType(NotificationType::SYNC_CONFIGURE_DONE),_,_)); |
| 219 EXPECT_CALL(observer_, | 219 EXPECT_CALL(observer_, |
| 220 Observe( | 220 Observe( |
| 221 NotificationType(NotificationType::SYNC_PAUSED),_,_)) | 221 NotificationType( |
| 222 NotificationType::SYNC_CONFIGURE_BLOCKED),_,_)) |
| 222 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); | 223 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); |
| 223 | 224 |
| 224 service_->RegisterDataTypeController(data_type_controller); | 225 service_->RegisterDataTypeController(data_type_controller); |
| 225 service_->Initialize(); | 226 service_->Initialize(); |
| 226 MessageLoop::current()->Run(); | 227 MessageLoop::current()->Run(); |
| 227 FlushLastDBTask(); | 228 FlushLastDBTask(); |
| 228 | 229 |
| 229 service_->SetPassphrase("foo", false, true); | 230 service_->SetPassphrase("foo", false, true); |
| 230 MessageLoop::current()->Run(); | 231 MessageLoop::current()->Run(); |
| 231 } | 232 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 AddPasswordEntriesTask node_task(this, sync_forms); | 541 AddPasswordEntriesTask node_task(this, sync_forms); |
| 541 | 542 |
| 542 StartSyncService(&root_task, &node_task); | 543 StartSyncService(&root_task, &node_task); |
| 543 | 544 |
| 544 std::vector<PasswordForm> new_sync_forms; | 545 std::vector<PasswordForm> new_sync_forms; |
| 545 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 546 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
| 546 | 547 |
| 547 EXPECT_EQ(1U, new_sync_forms.size()); | 548 EXPECT_EQ(1U, new_sync_forms.size()); |
| 548 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 549 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
| 549 } | 550 } |
| OLD | NEW |