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> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) { | 88 TEST_F(BrowserThreadTest, ReleasedOnCorrectThread) { |
89 { | 89 { |
90 scoped_refptr<DeletedOnFile> test( | 90 scoped_refptr<DeletedOnFile> test( |
91 new DeletedOnFile(base::MessageLoop::current())); | 91 new DeletedOnFile(base::MessageLoop::current())); |
92 } | 92 } |
93 base::RunLoop().Run(); | 93 base::RunLoop().Run(); |
94 } | 94 } |
95 | 95 |
96 TEST_F(BrowserThreadTest, PostTaskViaTaskRunner) { | 96 TEST_F(BrowserThreadTest, PostTaskViaTaskRunner) { |
97 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 97 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
98 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE); | 98 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE); |
99 task_runner->PostTask( | 99 task_runner->PostTask( |
100 FROM_HERE, base::Bind(&BasicFunction, base::MessageLoop::current())); | 100 FROM_HERE, base::Bind(&BasicFunction, base::MessageLoop::current())); |
101 base::RunLoop().Run(); | 101 base::RunLoop().Run(); |
102 } | 102 } |
103 | 103 |
104 TEST_F(BrowserThreadTest, ReleaseViaTaskRunner) { | 104 TEST_F(BrowserThreadTest, ReleaseViaTaskRunner) { |
105 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 105 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
106 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | 106 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI); |
107 task_runner->ReleaseSoon(FROM_HERE, this); | 107 task_runner->ReleaseSoon(FROM_HERE, this); |
108 base::RunLoop().Run(); | 108 base::RunLoop().Run(); |
109 } | 109 } |
110 | 110 |
111 TEST_F(BrowserThreadTest, PostTaskAndReply) { | 111 TEST_F(BrowserThreadTest, PostTaskAndReply) { |
112 // Most of the heavy testing for PostTaskAndReply() is done inside the | 112 // Most of the heavy testing for PostTaskAndReply() is done inside the |
113 // task runner test. This just makes sure we get piped through at all. | 113 // task runner test. This just makes sure we get piped through at all. |
114 ASSERT_TRUE(BrowserThread::PostTaskAndReply( | 114 ASSERT_TRUE(BrowserThread::PostTaskAndReply( |
115 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), | 115 BrowserThread::FILE, FROM_HERE, base::Bind(&base::DoNothing), |
116 base::Bind(&base::MessageLoop::QuitWhenIdle, | 116 base::Bind(&base::MessageLoop::QuitWhenIdle, |
117 base::Unretained(base::MessageLoop::current()->current())))); | 117 base::Unretained(base::MessageLoop::current()->current())))); |
118 base::RunLoop().Run(); | 118 base::RunLoop().Run(); |
119 } | 119 } |
120 | 120 |
121 } // namespace content | 121 } // namespace content |
OLD | NEW |