OLD | NEW |
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 <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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 base::Thread* syncer_thread() { return &faux_syncer_thread_; } | 76 base::Thread* syncer_thread() { return &faux_syncer_thread_; } |
77 private: | 77 private: |
78 base::MessageLoop faux_ui_loop_; | 78 base::MessageLoop faux_ui_loop_; |
79 base::Thread faux_syncer_thread_; | 79 base::Thread faux_syncer_thread_; |
80 base::Thread faux_core_thread_; | 80 base::Thread faux_core_thread_; |
81 scoped_refptr<UIModelWorker> bmw_; | 81 scoped_refptr<UIModelWorker> bmw_; |
82 std::unique_ptr<Syncer> syncer_; | 82 std::unique_ptr<Syncer> syncer_; |
83 }; | 83 }; |
84 | 84 |
85 TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) { | 85 TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) { |
86 base::WaitableEvent v_was_run(false, false); | 86 base::WaitableEvent v_was_run( |
| 87 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 88 base::WaitableEvent::InitialState::NOT_SIGNALED); |
87 std::unique_ptr<UIModelWorkerVisitor> v( | 89 std::unique_ptr<UIModelWorkerVisitor> v( |
88 new UIModelWorkerVisitor(&v_was_run, true)); | 90 new UIModelWorkerVisitor(&v_was_run, true)); |
89 | 91 |
90 syncer_thread()->task_runner()->PostTask( | 92 syncer_thread()->task_runner()->PostTask( |
91 FROM_HERE, | 93 FROM_HERE, |
92 base::Bind(&Syncer::SyncShare, base::Unretained(syncer()), v.get())); | 94 base::Bind(&Syncer::SyncShare, base::Unretained(syncer()), v.get())); |
93 | 95 |
94 // We are on the UI thread, so run our loop to process the | 96 // We are on the UI thread, so run our loop to process the |
95 // (hopefully) scheduled task from a SyncShare invocation. | 97 // (hopefully) scheduled task from a SyncShare invocation. |
96 base::MessageLoop::current()->Run(); | 98 base::MessageLoop::current()->Run(); |
97 syncer_thread()->Stop(); | 99 syncer_thread()->Stop(); |
98 } | 100 } |
OLD | NEW |