| 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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 private: | 55 private: |
| 56 scoped_refptr<UIModelWorker> worker_; | 56 scoped_refptr<UIModelWorker> worker_; |
| 57 DISALLOW_COPY_AND_ASSIGN(Syncer); | 57 DISALLOW_COPY_AND_ASSIGN(Syncer); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 class SyncUIModelWorkerTest : public testing::Test { | 60 class SyncUIModelWorkerTest : public testing::Test { |
| 61 public: | 61 public: |
| 62 SyncUIModelWorkerTest() : faux_syncer_thread_("FauxSyncerThread"), | 62 SyncUIModelWorkerTest() : faux_syncer_thread_("FauxSyncerThread"), |
| 63 faux_core_thread_("FauxCoreThread") { } | 63 faux_core_thread_("FauxCoreThread") { } |
| 64 | 64 |
| 65 virtual void SetUp() { | 65 void SetUp() override { |
| 66 faux_syncer_thread_.Start(); | 66 faux_syncer_thread_.Start(); |
| 67 ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI, | 67 ui_thread_.reset(new content::TestBrowserThread(BrowserThread::UI, |
| 68 &faux_ui_loop_)); | 68 &faux_ui_loop_)); |
| 69 bmw_ = new UIModelWorker(NULL); | 69 bmw_ = new UIModelWorker(NULL); |
| 70 syncer_.reset(new Syncer(bmw_.get())); | 70 syncer_.reset(new Syncer(bmw_.get())); |
| 71 } | 71 } |
| 72 | 72 |
| 73 Syncer* syncer() { return syncer_.get(); } | 73 Syncer* syncer() { return syncer_.get(); } |
| 74 UIModelWorker* bmw() { return bmw_.get(); } | 74 UIModelWorker* bmw() { return bmw_.get(); } |
| 75 base::Thread* core_thread() { return &faux_core_thread_; } | 75 base::Thread* core_thread() { return &faux_core_thread_; } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 89 new UIModelWorkerVisitor(&v_was_run, true)); | 89 new UIModelWorkerVisitor(&v_was_run, true)); |
| 90 | 90 |
| 91 syncer_thread()->message_loop()->PostTask(FROM_HERE, | 91 syncer_thread()->message_loop()->PostTask(FROM_HERE, |
| 92 base::Bind(&Syncer::SyncShare, base::Unretained(syncer()), v.get())); | 92 base::Bind(&Syncer::SyncShare, base::Unretained(syncer()), v.get())); |
| 93 | 93 |
| 94 // We are on the UI thread, so run our loop to process the | 94 // We are on the UI thread, so run our loop to process the |
| 95 // (hopefully) scheduled task from a SyncShare invocation. | 95 // (hopefully) scheduled task from a SyncShare invocation. |
| 96 base::MessageLoop::current()->Run(); | 96 base::MessageLoop::current()->Run(); |
| 97 syncer_thread()->Stop(); | 97 syncer_thread()->Stop(); |
| 98 } | 98 } |
| OLD | NEW |