Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: cc/trees/blocking_task_runner_unittest.cc

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 DummyTask(bool* result) {
16 *result = true;
17 }
18
19 TEST(BlockingTaskRunnerTest, NoCapture) {
20 bool did_run = false;
21 BlockingTaskRunner::current()->PostTask(FROM_HERE,
22 base::Bind(&DummyTask, &did_run));
23 EXPECT_FALSE(did_run);
24 base::RunLoop().RunUntilIdle();
25 EXPECT_TRUE(did_run);
26 }
27
28 TEST(BlockingTaskRunnerTest, Capture) {
29 bool did_run = false;
30 {
31 BlockingTaskRunner::CapturePostTasks capture;
32 BlockingTaskRunner::current()->PostTask(FROM_HERE,
33 base::Bind(&DummyTask, &did_run));
34 EXPECT_FALSE(did_run);
35 }
36 EXPECT_TRUE(did_run);
37 }
38
39 TEST(BlockingTaskRunnerTest, SetTaskRunner) {
40 bool did_run = false;
41 scoped_refptr<OrderedSimpleTaskRunner> custom_runner(
42 new OrderedSimpleTaskRunner());
43 scoped_refptr<BlockingTaskRunner> runner(BlockingTaskRunner::current());
44 runner->SetTaskRunner(custom_runner);
45 runner->PostTask(FROM_HERE, base::Bind(&DummyTask, &did_run));
46 base::RunLoop().RunUntilIdle();
47 EXPECT_FALSE(did_run);
48 custom_runner->RunPendingTasks();
49 EXPECT_TRUE(did_run);
50 runner->SetTaskRunner(base::MessageLoopProxy::current());
51 }
52
53 } // namespace
54 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698