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.
5 #include "cc/trees/blocking_task_runner.h"
8 #include "base/location.h"
9 #include "base/run_loop.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "cc/test/ordered_simple_task_runner.h"
13 #include "testing/gtest/include/gtest/gtest.h"
18 void TestTask(bool* result
) {
22 TEST(BlockingTaskRunnerTest
, NoCapture
) {
24 scoped_ptr
<BlockingTaskRunner
> runner(
25 BlockingTaskRunner::Create(base::ThreadTaskRunnerHandle::Get()));
26 runner
->PostTask(FROM_HERE
, base::Bind(&TestTask
, &did_run
));
27 EXPECT_FALSE(did_run
);
28 base::RunLoop().RunUntilIdle();
32 TEST(BlockingTaskRunnerTest
, Capture
) {
34 scoped_ptr
<BlockingTaskRunner
> runner(
35 BlockingTaskRunner::Create(base::ThreadTaskRunnerHandle::Get()));
37 BlockingTaskRunner::CapturePostTasks
capture(runner
.get());
38 runner
->PostTask(FROM_HERE
, base::Bind(&TestTask
, &did_run
));
39 EXPECT_FALSE(did_run
);