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

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

Issue 1143343005: chrome/browser: Remove use of MessageLoopProxy and deprecated MessageLoop APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 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 "chrome/browser/sync/glue/sync_backend_registrar.h" 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
6 6
7 #include "base/location.h"
7 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h"
8 #include "chrome/browser/sync/glue/ui_model_worker.h" 10 #include "chrome/browser/sync/glue/ui_model_worker.h"
9 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
10 #include "components/sync_driver/change_processor_mock.h" 12 #include "components/sync_driver/change_processor_mock.h"
11 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "sync/internal_api/public/base/model_type.h" 15 #include "sync/internal_api/public/base/model_type.h"
14 #include "sync/internal_api/public/test/test_user_share.h" 16 #include "sync/internal_api/public/test/test_user_share.h"
15 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void SetUp() override { 72 void SetUp() override {
71 test_user_share_.SetUp(); 73 test_user_share_.SetUp();
72 registrar_.reset(new SyncBackendRegistrar("test", &profile_, 74 registrar_.reset(new SyncBackendRegistrar("test", &profile_,
73 scoped_ptr<base::Thread>())); 75 scoped_ptr<base::Thread>()));
74 sync_thread_ = registrar_->sync_thread(); 76 sync_thread_ = registrar_->sync_thread();
75 } 77 }
76 78
77 void TearDown() override { 79 void TearDown() override {
78 registrar_->RequestWorkerStopOnUIThread(); 80 registrar_->RequestWorkerStopOnUIThread();
79 test_user_share_.TearDown(); 81 test_user_share_.TearDown();
80 sync_thread_->message_loop()->PostTask( 82 sync_thread_->task_runner()->PostTask(
81 FROM_HERE, 83 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown,
82 base::Bind(&SyncBackendRegistrar::Shutdown, 84 base::Unretained(registrar_.release())));
83 base::Unretained(registrar_.release())));
84 sync_thread_->message_loop()->RunUntilIdle(); 85 sync_thread_->message_loop()->RunUntilIdle();
85 } 86 }
86 87
87 void ExpectRoutingInfo( 88 void ExpectRoutingInfo(
88 SyncBackendRegistrar* registrar, 89 SyncBackendRegistrar* registrar,
89 const syncer::ModelSafeRoutingInfo& expected_routing_info) { 90 const syncer::ModelSafeRoutingInfo& expected_routing_info) {
90 syncer::ModelSafeRoutingInfo routing_info; 91 syncer::ModelSafeRoutingInfo routing_info;
91 registrar->GetModelSafeRoutingInfo(&routing_info); 92 registrar->GetModelSafeRoutingInfo(&routing_info);
92 EXPECT_EQ(expected_routing_info, routing_info); 93 EXPECT_EQ(expected_routing_info, routing_info);
93 } 94 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // initialize the worker on the DB thread hasn't had a chance to run yet too. 325 // initialize the worker on the DB thread hasn't had a chance to run yet too.
325 // Which means ModelSafeWorker::SetWorkingLoopToCurrent hasn't been called 326 // Which means ModelSafeWorker::SetWorkingLoopToCurrent hasn't been called
326 // for the DB worker. 327 // for the DB worker.
327 db_thread_blocked_.Wait(); 328 db_thread_blocked_.Wait();
328 329
329 registrar->SetInitialTypes(ModelTypeSet()); 330 registrar->SetInitialTypes(ModelTypeSet());
330 331
331 // Start the shutdown. 332 // Start the shutdown.
332 registrar->RequestWorkerStopOnUIThread(); 333 registrar->RequestWorkerStopOnUIThread();
333 334
334 sync_thread->message_loop()->PostTask( 335 sync_thread->task_runner()->PostTask(
335 FROM_HERE, 336 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown,
336 base::Bind(&SyncBackendRegistrar::Shutdown, 337 base::Unretained(registrar.release())));
337 base::Unretained(registrar.release())));
338 338
339 // Make sure the thread starts running. 339 // Make sure the thread starts running.
340 sync_thread->WaitUntilThreadStarted(); 340 sync_thread->WaitUntilThreadStarted();
341 341
342 // The test verifies that the sync thread doesn't block because 342 // The test verifies that the sync thread doesn't block because
343 // of the blocked DB thread and can finish the shutdown. 343 // of the blocked DB thread and can finish the shutdown.
344 sync_thread->message_loop()->RunUntilIdle(); 344 sync_thread->message_loop()->RunUntilIdle();
345 345
346 db_thread_lock_.Release(); 346 db_thread_lock_.Release();
347 347
348 // Run the main thread loop until all workers have been removed and the 348 // Run the main thread loop until all workers have been removed and the
349 // registrar destroyed. 349 // registrar destroyed.
350 run_loop_.Run(); 350 run_loop_.Run();
351 } 351 }
352 352
353 } // namespace 353 } // namespace
354 354
355 } // namespace browser_sync 355 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host_impl.cc ('k') | chrome/browser/sync/glue/typed_url_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698