Enable gaia services for enterprise autotests.
[chromium-blink-merge.git] / cc / trees / blocking_task_runner_unittest.cc
blobba4f96a80d424265994783511d509052f5088488
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"
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"
12 namespace cc {
13 namespace {
15 void TestTask(bool* result) {
16 *result = true;
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);
29 TEST(BlockingTaskRunnerTest, Capture) {
30 bool did_run = false;
31 scoped_ptr<BlockingTaskRunner> runner(
32 BlockingTaskRunner::Create(base::MessageLoopProxy::current()));
34 BlockingTaskRunner::CapturePostTasks capture(runner.get());
35 runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run));
36 EXPECT_FALSE(did_run);
38 EXPECT_TRUE(did_run);
41 } // namespace
42 } // namespace cc