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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_registrar_unittest.cc

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 7 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 "chrome/browser/sync/glue/sync_backend_registrar.h" 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/sync/glue/ui_model_worker.h" 8 #include "chrome/browser/sync/glue/ui_model_worker.h"
9 #include "chrome/test/base/testing_profile.h" 9 #include "chrome/test/base/testing_profile.h"
10 #include "components/sync_driver/change_processor_mock.h" 10 #include "components/sync_driver/change_processor_mock.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 syncer::ModelSafeRoutingInfo expected_routing_info; 53 syncer::ModelSafeRoutingInfo expected_routing_info;
54 expected_routing_info[AUTOFILL] = syncer::GROUP_DB; 54 expected_routing_info[AUTOFILL] = syncer::GROUP_DB;
55 ExpectRoutingInfo(registrar_.get(), expected_routing_info); 55 ExpectRoutingInfo(registrar_.get(), expected_routing_info);
56 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet(AUTOFILL)); 56 ExpectHasProcessorsForTypes(*registrar_, ModelTypeSet(AUTOFILL));
57 TriggerChanges(registrar_.get(), AUTOFILL); 57 TriggerChanges(registrar_.get(), AUTOFILL);
58 done->Signal(); 58 done->Signal();
59 } 59 }
60 60
61 protected: 61 protected:
62 SyncBackendRegistrarTest() 62 SyncBackendRegistrarTest()
63 : sync_thread_(NULL), 63 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD |
64 thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD |
65 content::TestBrowserThreadBundle::REAL_FILE_THREAD | 64 content::TestBrowserThreadBundle::REAL_FILE_THREAD |
66 content::TestBrowserThreadBundle::REAL_IO_THREAD) {} 65 content::TestBrowserThreadBundle::REAL_IO_THREAD),
66 sync_thread_(NULL) {}
67 67
68 ~SyncBackendRegistrarTest() override {} 68 ~SyncBackendRegistrarTest() override {}
69 69
70 void SetUp() override { 70 void SetUp() override {
71 test_user_share_.SetUp(); 71 test_user_share_.SetUp();
72 registrar_.reset(new SyncBackendRegistrar("test", &profile_, 72 registrar_.reset(new SyncBackendRegistrar("test", &profile_,
73 scoped_ptr<base::Thread>())); 73 scoped_ptr<base::Thread>()));
74 sync_thread_ = registrar_->sync_thread(); 74 sync_thread_ = registrar_->sync_thread();
75 } 75 }
76 76
(...skipping 17 matching lines...) Expand all
94 94
95 void ExpectHasProcessorsForTypes(const SyncBackendRegistrar& registrar, 95 void ExpectHasProcessorsForTypes(const SyncBackendRegistrar& registrar,
96 ModelTypeSet types) { 96 ModelTypeSet types) {
97 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 97 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
98 ModelType model_type = ModelTypeFromInt(i); 98 ModelType model_type = ModelTypeFromInt(i);
99 EXPECT_EQ(types.Has(model_type), 99 EXPECT_EQ(types.Has(model_type),
100 registrar_->IsTypeActivatedForTest(model_type)); 100 registrar_->IsTypeActivatedForTest(model_type));
101 } 101 }
102 } 102 }
103 103
104 content::TestBrowserThreadBundle thread_bundle_;
104 syncer::TestUserShare test_user_share_; 105 syncer::TestUserShare test_user_share_;
105 TestingProfile profile_; 106 TestingProfile profile_;
106 scoped_ptr<SyncBackendRegistrar> registrar_; 107 scoped_ptr<SyncBackendRegistrar> registrar_;
107 108
108 base::Thread* sync_thread_; 109 base::Thread* sync_thread_;
109 content::TestBrowserThreadBundle thread_bundle_;
110 }; 110 };
111 111
112 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) { 112 TEST_F(SyncBackendRegistrarTest, ConstructorEmpty) {
113 registrar_->SetInitialTypes(ModelTypeSet()); 113 registrar_->SetInitialTypes(ModelTypeSet());
114 EXPECT_FALSE(registrar_->IsNigoriEnabled()); 114 EXPECT_FALSE(registrar_->IsNigoriEnabled());
115 { 115 {
116 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers; 116 std::vector<scoped_refptr<syncer::ModelSafeWorker> > workers;
117 registrar_->GetWorkers(&workers); 117 registrar_->GetWorkers(&workers);
118 EXPECT_EQ(4u, workers.size()); 118 EXPECT_EQ(4u, workers.size());
119 } 119 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 db_thread_lock_.Release(); 343 db_thread_lock_.Release();
344 344
345 // Run the main thread loop until all workers have been removed and the 345 // Run the main thread loop until all workers have been removed and the
346 // registrar destroyed. 346 // registrar destroyed.
347 run_loop_.Run(); 347 run_loop_.Run();
348 } 348 }
349 349
350 } // namespace 350 } // namespace
351 351
352 } // namespace browser_sync 352 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698