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 <memory> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
7 #include "base/location.h" | 9 #include "base/location.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/sequenced_task_runner_helpers.h" | 10 #include "base/sequenced_task_runner_helpers.h" |
10 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
11 #include "content/browser/browser_thread_impl.h" | 12 #include "content/browser/browser_thread_impl.h" |
12 #include "content/public/test/test_browser_thread.h" | 13 #include "content/public/test/test_browser_thread.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 class BrowserThreadTest : public testing::Test { | 19 class BrowserThreadTest : public testing::Test { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 ~DeletedOnFile() { | 57 ~DeletedOnFile() { |
57 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 58 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
58 message_loop_->task_runner()->PostTask( | 59 message_loop_->task_runner()->PostTask( |
59 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 60 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
60 } | 61 } |
61 | 62 |
62 base::MessageLoop* message_loop_; | 63 base::MessageLoop* message_loop_; |
63 }; | 64 }; |
64 | 65 |
65 private: | 66 private: |
66 scoped_ptr<BrowserThreadImpl> ui_thread_; | 67 std::unique_ptr<BrowserThreadImpl> ui_thread_; |
67 scoped_ptr<BrowserThreadImpl> file_thread_; | 68 std::unique_ptr<BrowserThreadImpl> file_thread_; |
68 // It's kind of ugly to make this mutable - solely so we can post the Quit | 69 // It's kind of ugly to make this mutable - solely so we can post the Quit |
69 // Task from Release(). This should be fixed. | 70 // Task from Release(). This should be fixed. |
70 mutable base::MessageLoop loop_; | 71 mutable base::MessageLoop loop_; |
71 }; | 72 }; |
72 | 73 |
73 TEST_F(BrowserThreadTest, PostTask) { | 74 TEST_F(BrowserThreadTest, PostTask) { |
74 BrowserThread::PostTask( | 75 BrowserThread::PostTask( |
75 BrowserThread::FILE, | 76 BrowserThread::FILE, |
76 FROM_HERE, | 77 FROM_HERE, |
77 base::Bind(&BasicFunction, base::MessageLoop::current())); | 78 base::Bind(&BasicFunction, base::MessageLoop::current())); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // Most of the heavy testing for PostTaskAndReply() is done inside the | 111 // Most of the heavy testing for PostTaskAndReply() is done inside the |
111 // task runner test. This just makes sure we get piped through at all. | 112 // task runner test. This just makes sure we get piped through at all. |
112 ASSERT_TRUE(BrowserThread::PostTaskAndReply( | 113 ASSERT_TRUE(BrowserThread::PostTaskAndReply( |
113 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), | 114 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), |
114 base::Bind(&base::MessageLoop::QuitWhenIdle, | 115 base::Bind(&base::MessageLoop::QuitWhenIdle, |
115 base::Unretained(base::MessageLoop::current()->current())))); | 116 base::Unretained(base::MessageLoop::current()->current())))); |
116 base::MessageLoop::current()->Run(); | 117 base::MessageLoop::current()->Run(); |
117 } | 118 } |
118 | 119 |
119 } // namespace content | 120 } // namespace content |
OLD | NEW |