OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/trees/blocking_task_runner.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/run_loop.h" |
| 9 #include "cc/test/ordered_simple_task_runner.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 namespace cc { |
| 13 namespace { |
| 14 |
| 15 void TestTask(bool* result) { |
| 16 *result = true; |
| 17 } |
| 18 |
| 19 TEST(BlockingTaskRunnerTest, NoCapture) { |
| 20 bool did_run = false; |
| 21 scoped_ptr<BlockingTaskRunner> runner( |
| 22 BlockingTaskRunner::Create(base::MessageLoopProxy::current())); |
| 23 runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run)); |
| 24 EXPECT_FALSE(did_run); |
| 25 base::RunLoop().RunUntilIdle(); |
| 26 EXPECT_TRUE(did_run); |
| 27 } |
| 28 |
| 29 TEST(BlockingTaskRunnerTest, Capture) { |
| 30 bool did_run = false; |
| 31 scoped_ptr<BlockingTaskRunner> runner( |
| 32 BlockingTaskRunner::Create(base::MessageLoopProxy::current())); |
| 33 { |
| 34 BlockingTaskRunner::CapturePostTasks capture(runner.get()); |
| 35 runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run)); |
| 36 EXPECT_FALSE(did_run); |
| 37 } |
| 38 EXPECT_TRUE(did_run); |
| 39 } |
| 40 |
| 41 } // namespace |
| 42 } // namespace cc |
OLD | NEW |