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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 node.InitUniqueByCreation(syncer::PASSWORDS, password_root, tag); | 147 node.InitUniqueByCreation(syncer::PASSWORDS, password_root, tag); |
148 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); | 148 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); |
149 PasswordModelAssociator::WriteToSyncNode(entry, &node); | 149 PasswordModelAssociator::WriteToSyncNode(entry, &node); |
150 } | 150 } |
151 | 151 |
152 protected: | 152 protected: |
153 ProfileSyncServicePasswordTest() {} | 153 ProfileSyncServicePasswordTest() {} |
154 | 154 |
155 virtual void SetUp() { | 155 virtual void SetUp() { |
156 AbstractProfileSyncServiceTest::SetUp(); | 156 AbstractProfileSyncServiceTest::SetUp(); |
157 profile_.reset(new ProfileMock); | 157 profile_.reset(new ProfileMock()); |
158 profile_->CreateRequestContext(); | |
159 invalidation::InvalidationServiceFactory::GetInstance()-> | 158 invalidation::InvalidationServiceFactory::GetInstance()-> |
160 SetBuildOnlyFakeInvalidatorsForTest(true); | 159 SetBuildOnlyFakeInvalidatorsForTest(true); |
161 password_store_ = static_cast<MockPasswordStore*>( | 160 password_store_ = static_cast<MockPasswordStore*>( |
162 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 161 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
163 profile_.get(), MockPasswordStore::Build).get()); | 162 profile_.get(), MockPasswordStore::Build).get()); |
164 } | 163 } |
165 | 164 |
166 virtual void TearDown() { | 165 virtual void TearDown() { |
167 if (password_store_.get()) | 166 if (password_store_.get()) |
168 password_store_->ShutdownOnUIThread(); | 167 password_store_->ShutdownOnUIThread(); |
169 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( | 168 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( |
170 profile_.get(), NULL); | 169 profile_.get(), NULL); |
171 profile_->ResetRequestContext(); | |
172 profile_.reset(); | 170 profile_.reset(); |
173 AbstractProfileSyncServiceTest::TearDown(); | 171 AbstractProfileSyncServiceTest::TearDown(); |
174 } | 172 } |
175 | 173 |
176 static void SignalEvent(base::WaitableEvent* done) { | 174 static void SignalEvent(base::WaitableEvent* done) { |
177 done->Signal(); | 175 done->Signal(); |
178 } | 176 } |
179 | 177 |
180 void FlushLastDBTask() { | 178 void FlushLastDBTask() { |
181 base::WaitableEvent done(false, false); | 179 base::WaitableEvent done(false, false); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 CreateRootHelper create_root(this, syncer::PASSWORDS); | 650 CreateRootHelper create_root(this, syncer::PASSWORDS); |
653 StartSyncService(create_root.callback(), | 651 StartSyncService(create_root.callback(), |
654 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 652 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
655 | 653 |
656 std::vector<PasswordForm> new_sync_forms; | 654 std::vector<PasswordForm> new_sync_forms; |
657 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 655 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
658 | 656 |
659 EXPECT_EQ(1U, new_sync_forms.size()); | 657 EXPECT_EQ(1U, new_sync_forms.size()); |
660 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 658 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
661 } | 659 } |
OLD | NEW |