| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/sequenced_task_runner_helpers.h" | 10 #include "base/sequenced_task_runner_helpers.h" |
| 11 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
| 12 #include "content/public/test/test_browser_thread.h" | 12 #include "content/public/test/test_browser_thread.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 class BrowserThreadTest : public testing::Test { | 18 class BrowserThreadTest : public testing::Test { |
| 19 public: | 19 public: |
| 20 void Release() const { | 20 void Release() const { |
| 21 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 21 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 22 loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 22 loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
| 23 } | 23 } |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 virtual void SetUp() { | 26 void SetUp() override { |
| 27 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI)); | 27 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI)); |
| 28 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); | 28 file_thread_.reset(new BrowserThreadImpl(BrowserThread::FILE)); |
| 29 ui_thread_->Start(); | 29 ui_thread_->Start(); |
| 30 file_thread_->Start(); | 30 file_thread_->Start(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual void TearDown() { | 33 void TearDown() override { |
| 34 ui_thread_->Stop(); | 34 ui_thread_->Stop(); |
| 35 file_thread_->Stop(); | 35 file_thread_->Stop(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 static void BasicFunction(base::MessageLoop* message_loop) { | 38 static void BasicFunction(base::MessageLoop* message_loop) { |
| 39 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 39 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 40 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 40 message_loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 class DeletedOnFile | 43 class DeletedOnFile |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 ASSERT_TRUE(BrowserThread::PostTaskAndReply( | 109 ASSERT_TRUE(BrowserThread::PostTaskAndReply( |
| 110 BrowserThread::FILE, | 110 BrowserThread::FILE, |
| 111 FROM_HERE, | 111 FROM_HERE, |
| 112 base::Bind(&base::DoNothing), | 112 base::Bind(&base::DoNothing), |
| 113 base::Bind(&base::MessageLoop::Quit, | 113 base::Bind(&base::MessageLoop::Quit, |
| 114 base::Unretained(base::MessageLoop::current()->current())))); | 114 base::Unretained(base::MessageLoop::current()->current())))); |
| 115 base::MessageLoop::current()->Run(); | 115 base::MessageLoop::current()->Run(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace content | 118 } // namespace content |
| OLD | NEW |