| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/location.h" |
| 8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/single_thread_task_runner.h" |
| 11 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 13 #include "chrome/browser/sync/glue/ui_model_worker.h" | 14 #include "chrome/browser/sync/glue/ui_model_worker.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 15 #include "content/public/test/test_browser_thread.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 17 |
| 17 using browser_sync::UIModelWorker; | 18 using browser_sync::UIModelWorker; |
| 18 using syncer::SyncerError; | 19 using syncer::SyncerError; |
| 19 using content::BrowserThread; | 20 using content::BrowserThread; |
| 20 | 21 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 base::Thread faux_core_thread_; | 82 base::Thread faux_core_thread_; |
| 82 scoped_refptr<UIModelWorker> bmw_; | 83 scoped_refptr<UIModelWorker> bmw_; |
| 83 scoped_ptr<Syncer> syncer_; | 84 scoped_ptr<Syncer> syncer_; |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) { | 87 TEST_F(SyncUIModelWorkerTest, ScheduledWorkRunsOnUILoop) { |
| 87 base::WaitableEvent v_was_run(false, false); | 88 base::WaitableEvent v_was_run(false, false); |
| 88 scoped_ptr<UIModelWorkerVisitor> v( | 89 scoped_ptr<UIModelWorkerVisitor> v( |
| 89 new UIModelWorkerVisitor(&v_was_run, true)); | 90 new UIModelWorkerVisitor(&v_was_run, true)); |
| 90 | 91 |
| 91 syncer_thread()->message_loop()->PostTask(FROM_HERE, | 92 syncer_thread()->task_runner()->PostTask( |
| 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 |