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

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: Rebase 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/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/test/test_timeouts.h" 14 #include "base/test/test_timeouts.h"
15 #include "base/time.h" 15 #include "base/time.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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 PasswordModelAssociator::WriteToSyncNode(entry, &node); 149 PasswordModelAssociator::WriteToSyncNode(entry, &node);
149 } 150 }
150 151
151 protected: 152 protected:
152 ProfileSyncServicePasswordTest() {} 153 ProfileSyncServicePasswordTest() {}
153 154
154 virtual void SetUp() { 155 virtual void SetUp() {
155 AbstractProfileSyncServiceTest::SetUp(); 156 AbstractProfileSyncServiceTest::SetUp();
156 profile_.reset(new ProfileMock); 157 profile_.reset(new ProfileMock);
157 profile_->CreateRequestContext(); 158 profile_->CreateRequestContext();
159 invalidation::InvalidationServiceFactory::GetInstance()->
160 SetBuildOnlyFakeInvalidatorsForTest(true);
158 password_store_ = static_cast<MockPasswordStore*>( 161 password_store_ = static_cast<MockPasswordStore*>(
159 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( 162 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
160 profile_.get(), MockPasswordStore::Build).get()); 163 profile_.get(), MockPasswordStore::Build).get());
161 } 164 }
162 165
163 virtual void TearDown() { 166 virtual void TearDown() {
164 if (password_store_.get()) 167 if (password_store_.get())
165 password_store_->ShutdownOnUIThread(); 168 password_store_->ShutdownOnUIThread();
166 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory( 169 ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(
167 profile_.get(), NULL); 170 profile_.get(), NULL);
(...skipping 12 matching lines...) Expand all
180 BrowserThread::DB, FROM_HERE, 183 BrowserThread::DB, FROM_HERE,
181 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done)); 184 base::Bind(&ProfileSyncServicePasswordTest::SignalEvent, &done));
182 done.TimedWait(TestTimeouts::action_timeout()); 185 done.TimedWait(TestTimeouts::action_timeout());
183 } 186 }
184 187
185 void StartSyncService(const base::Closure& root_callback, 188 void StartSyncService(const base::Closure& root_callback,
186 const base::Closure& node_callback) { 189 const base::Closure& node_callback) {
187 if (!sync_service_) { 190 if (!sync_service_) {
188 SigninManagerBase* signin = 191 SigninManagerBase* signin =
189 SigninManagerFactory::GetForProfile(profile_.get()); 192 SigninManagerFactory::GetForProfile(profile_.get());
190 signin->SetAuthenticatedUsername("test_user"); 193 signin->SetAuthenticatedUsername("test_user@gmail.com");
191 token_service_ = static_cast<TokenService*>( 194 token_service_ = static_cast<TokenService*>(
192 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse( 195 TokenServiceFactory::GetInstance()->SetTestingFactoryAndUse(
193 profile_.get(), BuildTokenService)); 196 profile_.get(), BuildTokenService));
194 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory( 197 ProfileOAuth2TokenServiceFactory::GetInstance()->SetTestingFactory(
195 profile_.get(), FakeOAuth2TokenService::BuildTokenService); 198 profile_.get(), FakeOAuth2TokenService::BuildTokenService);
196 199
197 PasswordTestProfileSyncService* sync = 200 PasswordTestProfileSyncService* sync =
198 static_cast<PasswordTestProfileSyncService*>( 201 static_cast<PasswordTestProfileSyncService*>(
199 ProfileSyncServiceFactory::GetInstance()-> 202 ProfileSyncServiceFactory::GetInstance()->
200 SetTestingFactoryAndUse(profile_.get(), 203 SetTestingFactoryAndUse(profile_.get(),
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 CreateRootHelper create_root(this, syncer::PASSWORDS); 652 CreateRootHelper create_root(this, syncer::PASSWORDS);
650 StartSyncService(create_root.callback(), 653 StartSyncService(create_root.callback(),
651 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); 654 base::Bind(&AddPasswordEntriesCallback, this, sync_forms));
652 655
653 std::vector<PasswordForm> new_sync_forms; 656 std::vector<PasswordForm> new_sync_forms;
654 GetPasswordEntriesFromSyncDB(&new_sync_forms); 657 GetPasswordEntriesFromSyncDB(&new_sync_forms);
655 658
656 EXPECT_EQ(1U, new_sync_forms.size()); 659 EXPECT_EQ(1U, new_sync_forms.size());
657 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); 660 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0]));
658 } 661 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_observer.cc ('k') | chrome/browser/sync/profile_sync_service_preference_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698