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

Side by Side Diff: components/search_engines/search_engine_data_type_controller_unittest.cc

Issue 2769113002: [Sync] Stop accessing BrowserContextKeyedServiceFactory on non-UI thread. (Closed)
Patch Set: Rebase and removing dependent patch set. Created 3 years, 8 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 "components/search_engines/search_engine_data_type_controller.h" 5 #include "components/search_engines/search_engine_data_type_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 27 matching lines...) Expand all
38 SyncSearchEngineDataTypeControllerTest() 38 SyncSearchEngineDataTypeControllerTest()
39 : syncer::FakeSyncClient(&profile_sync_factory_), 39 : syncer::FakeSyncClient(&profile_sync_factory_),
40 template_url_service_(nullptr, 0), 40 template_url_service_(nullptr, 0),
41 search_engine_dtc_(base::Closure(), this, &template_url_service_) { 41 search_engine_dtc_(base::Closure(), this, &template_url_service_) {
42 // Disallow the TemplateURLService from loading until 42 // Disallow the TemplateURLService from loading until
43 // PreloadTemplateURLService() is called . 43 // PreloadTemplateURLService() is called .
44 template_url_service_.set_disable_load(true); 44 template_url_service_.set_disable_load(true);
45 } 45 }
46 46
47 // FakeSyncClient overrides. 47 // FakeSyncClient overrides.
48 base::WeakPtr<syncer::SyncableService> GetSyncableServiceForType( 48 ServiceProvider GetSyncableServiceForType(syncer::ModelType type) override {
49 syncer::ModelType type) override { 49 return base::Bind(&syncer::SyncableService::AsWeakPtr,
50 return syncable_service_.AsWeakPtr(); 50 base::Unretained(&syncable_service_));
51 } 51 }
52 52
53 void TearDown() override { 53 void TearDown() override {
54 // Must be done before we pump the loop. 54 // Must be done before we pump the loop.
55 syncable_service_.StopSyncing(syncer::SEARCH_ENGINES); 55 syncable_service_.StopSyncing(syncer::SEARCH_ENGINES);
56 } 56 }
57 57
58 protected: 58 protected:
59 void PreloadTemplateURLService() { 59 void PreloadTemplateURLService() {
60 template_url_service_.set_disable_load(false); 60 template_url_service_.set_disable_load(false);
61 template_url_service_.Load(); 61 template_url_service_.Load();
62 } 62 }
63 63
64 void SetStartExpectations() { 64 void SetStartExpectations() {
65 search_engine_dtc_.SetGenericChangeProcessorFactoryForTest( 65 search_engine_dtc_.SetGenericChangeProcessorFactoryForTest(
66 base::WrapUnique<syncer::GenericChangeProcessorFactory>( 66 base::WrapUnique<syncer::GenericChangeProcessorFactory>(
67 new syncer::FakeGenericChangeProcessorFactory( 67 new syncer::FakeGenericChangeProcessorFactory(
68 base::MakeUnique<syncer::FakeGenericChangeProcessor>( 68 base::MakeUnique<syncer::FakeGenericChangeProcessor>(
69 syncer::SEARCH_ENGINES, this)))); 69 syncer::SEARCH_ENGINES))));
70 EXPECT_CALL(model_load_callback_, Run(_, _)); 70 EXPECT_CALL(model_load_callback_, Run(_, _));
71 } 71 }
72 72
73 void Start() { 73 void Start() {
74 search_engine_dtc_.LoadModels( 74 search_engine_dtc_.LoadModels(
75 base::Bind(&syncer::ModelLoadCallbackMock::Run, 75 base::Bind(&syncer::ModelLoadCallbackMock::Run,
76 base::Unretained(&model_load_callback_))); 76 base::Unretained(&model_load_callback_)));
77 search_engine_dtc_.StartAssociating(base::Bind( 77 search_engine_dtc_.StartAssociating(base::Bind(
78 &syncer::StartCallbackMock::Run, base::Unretained(&start_callback_))); 78 &syncer::StartCallbackMock::Run, base::Unretained(&start_callback_)));
79 base::RunLoop().RunUntilIdle(); 79 base::RunLoop().RunUntilIdle();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 EXPECT_FALSE(syncable_service_.syncing()); 174 EXPECT_FALSE(syncable_service_.syncing());
175 search_engine_dtc_.Stop(); 175 search_engine_dtc_.Stop();
176 EXPECT_EQ(NULL, search_engine_dtc_.GetSubscriptionForTesting()); 176 EXPECT_EQ(NULL, search_engine_dtc_.GetSubscriptionForTesting());
177 EXPECT_EQ(syncer::DataTypeController::NOT_RUNNING, 177 EXPECT_EQ(syncer::DataTypeController::NOT_RUNNING,
178 search_engine_dtc_.state()); 178 search_engine_dtc_.state());
179 EXPECT_FALSE(syncable_service_.syncing()); 179 EXPECT_FALSE(syncable_service_.syncing());
180 } 180 }
181 181
182 } // namespace 182 } // namespace
183 } // namespace browser_sync 183 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/browser_sync/profile_sync_test_util.cc ('k') | components/sync/driver/async_directory_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698