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

Side by Side Diff: base/task_scheduler/sequence_unittest.cc

Issue 2859053006: Use constexpr TaskTraits constructor in base (part 2). (Closed)
Patch Set: self-review Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/task_scheduler/sequence.h" 5 #include "base/task_scheduler/sequence.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/test/gtest_util.h" 13 #include "base/test/gtest_util.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace base { 17 namespace base {
18 namespace internal { 18 namespace internal {
19 19
20 namespace { 20 namespace {
21 21
22 22
23 class TaskSchedulerSequenceTest : public testing::Test { 23 class TaskSchedulerSequenceTest : public testing::Test {
24 public: 24 public:
25 TaskSchedulerSequenceTest() 25 TaskSchedulerSequenceTest()
26 : task_a_owned_( 26 : task_a_owned_(new Task(FROM_HERE,
27 new Task(FROM_HERE, 27 Bind(&DoNothing),
28 Bind(&DoNothing), 28 {TaskPriority::BACKGROUND},
29 TaskTraits().WithPriority(TaskPriority::BACKGROUND), 29 TimeDelta())),
30 TimeDelta())), 30 task_b_owned_(new Task(FROM_HERE,
31 task_b_owned_( 31 Bind(&DoNothing),
32 new Task(FROM_HERE, 32 {TaskPriority::USER_VISIBLE},
33 Bind(&DoNothing), 33 TimeDelta())),
34 TaskTraits().WithPriority(TaskPriority::USER_VISIBLE), 34 task_c_owned_(new Task(FROM_HERE,
35 TimeDelta())), 35 Bind(&DoNothing),
36 task_c_owned_( 36 {TaskPriority::USER_BLOCKING},
37 new Task(FROM_HERE, 37 TimeDelta())),
38 Bind(&DoNothing), 38 task_d_owned_(new Task(FROM_HERE,
39 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), 39 Bind(&DoNothing),
40 TimeDelta())), 40 {TaskPriority::USER_BLOCKING},
41 task_d_owned_( 41 TimeDelta())),
42 new Task(FROM_HERE, 42 task_e_owned_(new Task(FROM_HERE,
43 Bind(&DoNothing), 43 Bind(&DoNothing),
44 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), 44 {TaskPriority::BACKGROUND},
45 TimeDelta())), 45 TimeDelta())),
46 task_e_owned_(
47 new Task(FROM_HERE,
48 Bind(&DoNothing),
49 TaskTraits().WithPriority(TaskPriority::BACKGROUND),
50 TimeDelta())),
51 task_a_(task_a_owned_.get()), 46 task_a_(task_a_owned_.get()),
52 task_b_(task_b_owned_.get()), 47 task_b_(task_b_owned_.get()),
53 task_c_(task_c_owned_.get()), 48 task_c_(task_c_owned_.get()),
54 task_d_(task_d_owned_.get()), 49 task_d_(task_d_owned_.get()),
55 task_e_(task_e_owned_.get()) {} 50 task_e_(task_e_owned_.get()) {}
56 51
57 protected: 52 protected:
58 // Tasks to be handed off to a Sequence for testing. 53 // Tasks to be handed off to a Sequence for testing.
59 std::unique_ptr<Task> task_a_owned_; 54 std::unique_ptr<Task> task_a_owned_;
60 std::unique_ptr<Task> task_b_owned_; 55 std::unique_ptr<Task> task_b_owned_;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 213 }
219 214
220 // Verify that a DCHECK fires if TakeTask() is called on an empty sequence. 215 // Verify that a DCHECK fires if TakeTask() is called on an empty sequence.
221 TEST_F(TaskSchedulerSequenceTest, TakeEmptySequence) { 216 TEST_F(TaskSchedulerSequenceTest, TakeEmptySequence) {
222 scoped_refptr<Sequence> sequence(new Sequence); 217 scoped_refptr<Sequence> sequence(new Sequence);
223 EXPECT_DCHECK_DEATH({ sequence->TakeTask(); }); 218 EXPECT_DCHECK_DEATH({ sequence->TakeTask(); });
224 } 219 }
225 220
226 } // namespace internal 221 } // namespace internal
227 } // namespace base 222 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker_unittest.cc ('k') | base/task_scheduler/task_scheduler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698