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

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

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
« no previous file with comments | « cc/trees/blocking_task_runner.cc ('k') | cc/trees/channel_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "cc/trees/blocking_task_runner.h" 5 #include "cc/trees/blocking_task_runner.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "cc/test/ordered_simple_task_runner.h" 12 #include "cc/test/ordered_simple_task_runner.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace cc { 15 namespace cc {
16 namespace { 16 namespace {
17 17
18 void TestTask(bool* result) { 18 void TestTask(bool* result) {
19 *result = true; 19 *result = true;
20 } 20 }
21 21
22 TEST(BlockingTaskRunnerTest, NoCapture) { 22 TEST(BlockingTaskRunnerTest, NoCapture) {
23 bool did_run = false; 23 bool did_run = false;
24 scoped_ptr<BlockingTaskRunner> runner( 24 std::unique_ptr<BlockingTaskRunner> runner(
25 BlockingTaskRunner::Create(base::ThreadTaskRunnerHandle::Get())); 25 BlockingTaskRunner::Create(base::ThreadTaskRunnerHandle::Get()));
26 runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run)); 26 runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run));
27 EXPECT_FALSE(did_run); 27 EXPECT_FALSE(did_run);
28 base::RunLoop().RunUntilIdle(); 28 base::RunLoop().RunUntilIdle();
29 EXPECT_TRUE(did_run); 29 EXPECT_TRUE(did_run);
30 } 30 }
31 31
32 TEST(BlockingTaskRunnerTest, Capture) { 32 TEST(BlockingTaskRunnerTest, Capture) {
33 bool did_run = false; 33 bool did_run = false;
34 scoped_ptr<BlockingTaskRunner> runner( 34 std::unique_ptr<BlockingTaskRunner> runner(
35 BlockingTaskRunner::Create(base::ThreadTaskRunnerHandle::Get())); 35 BlockingTaskRunner::Create(base::ThreadTaskRunnerHandle::Get()));
36 { 36 {
37 BlockingTaskRunner::CapturePostTasks capture(runner.get()); 37 BlockingTaskRunner::CapturePostTasks capture(runner.get());
38 runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run)); 38 runner->PostTask(FROM_HERE, base::Bind(&TestTask, &did_run));
39 EXPECT_FALSE(did_run); 39 EXPECT_FALSE(did_run);
40 } 40 }
41 EXPECT_TRUE(did_run); 41 EXPECT_TRUE(did_run);
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 } // namespace cc 45 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/blocking_task_runner.cc ('k') | cc/trees/channel_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698