Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: chrome/browser/sync/profile_sync_service_password_unittest.cc

Issue 15580002: Make use of InvalidationService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Responses to Fred's comments Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "base/test/test_timeouts.h" 13 #include "base/test/test_timeouts.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/invalidation/invalidation_service_factory.h"
16 #include "chrome/browser/password_manager/mock_password_store.h" 17 #include "chrome/browser/password_manager/mock_password_store.h"
17 #include "chrome/browser/password_manager/password_store.h" 18 #include "chrome/browser/password_manager/password_store.h"
18 #include "chrome/browser/password_manager/password_store_factory.h" 19 #include "chrome/browser/password_manager/password_store_factory.h"
19 #include "chrome/browser/signin/signin_manager.h" 20 #include "chrome/browser/signin/signin_manager.h"
20 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
21 #include "chrome/browser/signin/token_service_factory.h" 22 #include "chrome/browser/signin/token_service_factory.h"
22 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" 23 #include "chrome/browser/sync/abstract_profile_sync_service_test.h"
23 #include "chrome/browser/sync/glue/password_change_processor.h" 24 #include "chrome/browser/sync/glue/password_change_processor.h"
24 #include "chrome/browser/sync/glue/password_data_type_controller.h" 25 #include "chrome/browser/sync/glue/password_data_type_controller.h"
25 #include "chrome/browser/sync/glue/password_model_associator.h" 26 #include "chrome/browser/sync/glue/password_model_associator.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); 166 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result);
166 PasswordModelAssociator::WriteToSyncNode(entry, &node); 167 PasswordModelAssociator::WriteToSyncNode(entry, &node);
167 } 168 }
168 169
169 protected: 170 protected:
170 ProfileSyncServicePasswordTest() {} 171 ProfileSyncServicePasswordTest() {}
171 172
172 virtual void SetUp() { 173 virtual void SetUp() {
173 AbstractProfileSyncServiceTest::SetUp(); 174 AbstractProfileSyncServiceTest::SetUp();
174 profile_.CreateRequestContext(); 175 profile_.CreateRequestContext();
176 invalidation::InvalidationServiceFactory::GetInstance()->
177 SetFakeInvalidationServiceForTest(&profile_);
175 password_store_ = static_cast<MockPasswordStore*>( 178 password_store_ = static_cast<MockPasswordStore*>(
176 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( 179 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
177 &profile_, MockPasswordStore::Build).get()); 180 &profile_, MockPasswordStore::Build).get());
178 } 181 }
179 182
180 virtual void TearDown() { 183 virtual void TearDown() {
181 if (password_store_) 184 if (password_store_)
182 password_store_->ShutdownOnUIThread(); 185 password_store_->ShutdownOnUIThread();
183 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( 186 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(
184 &profile_, NULL); 187 &profile_, NULL);
(...skipping 11 matching lines...) Expand all
196 BrowserThread::DB, FROM_HERE, 199 BrowserThread::DB, FROM_HERE,
197 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); 200 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done));
198 done.TimedWait(TestTimeouts::action_timeout()); 201 done.TimedWait(TestTimeouts::action_timeout());
199 } 202 }
200 203
201 void StartSyncService(const base::Closure& root_callback, 204 void StartSyncService(const base::Closure& root_callback,
202 const base::Closure& node_callback) { 205 const base::Closure& node_callback) {
203 if (!sync_service_) { 206 if (!sync_service_) {
204 SigninManagerBase* signin = 207 SigninManagerBase* signin =
205 SigninManagerFactory::GetForProfile(&profile_); 208 SigninManagerFactory::GetForProfile(&profile_);
206 signin->SetAuthenticatedUsername("test_user"); 209 signin->SetAuthenticatedUsername("test_user@gmail.com");
207 token_service_ = static_cast<TokenService*>( 210 token_service_ = static_cast<TokenService*>(
208 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( 211 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
209 &profile_, BuildTokenService)); 212 &profile_, BuildTokenService));
210 213
211 PasswordTestProfileSyncService* sync = 214 PasswordTestProfileSyncService* sync =
212 static_cast<PasswordTestProfileSyncService*>( 215 static_cast<PasswordTestProfileSyncService*>(
213 ProfileSyncServiceFactory::GetInstance()-> 216 ProfileSyncServiceFactory::GetInstance()->
214 SetTestingFactoryAndUse(&profile_, 217 SetTestingFactoryAndUse(&profile_,
215 &PasswordTestProfileSyncService::Build)); 218 &PasswordTestProfileSyncService::Build));
216 sync->set_backend_init_callback(root_callback); 219 sync->set_backend_init_callback(root_callback);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 CreateRootHelper create_root(this, syncer::PASSWORDS); 664 CreateRootHelper create_root(this, syncer::PASSWORDS);
662 StartSyncService(create_root.callback(), 665 StartSyncService(create_root.callback(),
663 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); 666 base::Bind(&AddPasswordEntriesCallback, this, sync_forms));
664 667
665 std::vector<PasswordForm> new_sync_forms; 668 std::vector<PasswordForm> new_sync_forms;
666 GetPasswordEntriesFromSyncDB(&new_sync_forms); 669 GetPasswordEntriesFromSyncDB(&new_sync_forms);
667 670
668 EXPECT_EQ(1U, new_sync_forms.size()); 671 EXPECT_EQ(1U, new_sync_forms.size());
669 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); 672 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0]));
670 } 673 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698