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

Side by Side Diff: components/sync/driver/glue/ui_model_worker_unittest.cc

Issue 2471183003: Do not observe MessageLoop destruction from ModelSafeWorker. (Closed)
Patch Set: CR maxbogue #23 Created 4 years, 1 month 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
« no previous file with comments | « components/sync/driver/glue/ui_model_worker.cc ('k') | components/sync/driver/sync_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/sync/driver/glue/ui_model_worker.h" 5 #include "components/sync/driver/glue/ui_model_worker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 18 matching lines...) Expand all
29 // Converts |work| to a WorkCallback that will verify that it's run on the 29 // Converts |work| to a WorkCallback that will verify that it's run on the
30 // thread it was constructed on. 30 // thread it was constructed on.
31 WorkCallback ClosureToWorkCallback(base::Closure work) { 31 WorkCallback ClosureToWorkCallback(base::Closure work) {
32 return base::Bind(&DoWork, base::ThreadTaskRunnerHandle::Get(), work); 32 return base::Bind(&DoWork, base::ThreadTaskRunnerHandle::Get(), work);
33 } 33 }
34 34
35 class SyncUIModelWorkerTest : public testing::Test { 35 class SyncUIModelWorkerTest : public testing::Test {
36 public: 36 public:
37 SyncUIModelWorkerTest() : sync_thread_("SyncThreadForTest") { 37 SyncUIModelWorkerTest() : sync_thread_("SyncThreadForTest") {
38 sync_thread_.Start(); 38 sync_thread_.Start();
39 worker_ = new UIModelWorker(base::ThreadTaskRunnerHandle::Get(), nullptr); 39 worker_ = new UIModelWorker(base::ThreadTaskRunnerHandle::Get());
40 } 40 }
41 41
42 void PostWorkToSyncThread(WorkCallback work) { 42 void PostWorkToSyncThread(WorkCallback work) {
43 sync_thread_.task_runner()->PostTask( 43 sync_thread_.task_runner()->PostTask(
44 FROM_HERE, 44 FROM_HERE,
45 base::Bind(base::IgnoreResult(&UIModelWorker::DoWorkAndWaitUntilDone), 45 base::Bind(base::IgnoreResult(&UIModelWorker::DoWorkAndWaitUntilDone),
46 worker_, work)); 46 worker_, work));
47 } 47 }
48 48
49 private: 49 private:
50 base::MessageLoop ui_loop_; 50 base::MessageLoop ui_loop_;
51 base::Thread sync_thread_; 51 base::Thread sync_thread_;
52 scoped_refptr<UIModelWorker> worker_; 52 scoped_refptr<UIModelWorker> worker_;
53 }; 53 };
54 54
55 TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) { 55 TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) {
56 base::RunLoop run_loop; 56 base::RunLoop run_loop;
57 PostWorkToSyncThread(ClosureToWorkCallback(run_loop.QuitClosure())); 57 PostWorkToSyncThread(ClosureToWorkCallback(run_loop.QuitClosure()));
58 // This won't quit until the QuitClosure is run. 58 // This won't quit until the QuitClosure is run.
59 run_loop.Run(); 59 run_loop.Run();
60 } 60 }
61 61
62 } // namespace 62 } // namespace
63 } // namespace syncer 63 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/glue/ui_model_worker.cc ('k') | components/sync/driver/sync_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698