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

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

Issue 1890163003: TaskScheduler: Add delayed run time to the constructor of Task. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@7_sequenced
Patch Set: self review 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 | « no previous file | base/task_scheduler/scheduler_worker_thread_unittest.cc » ('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 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/priority_queue.h" 5 #include "base/task_scheduler/priority_queue.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 do { \ 65 do { \
66 SCOPED_TRACE(""); \ 66 SCOPED_TRACE(""); \
67 ExpectSequenceAndSortKeyEq(expected, actual); \ 67 ExpectSequenceAndSortKeyEq(expected, actual); \
68 } while (false) 68 } while (false)
69 69
70 } // namespace 70 } // namespace
71 71
72 TEST(TaskSchedulerPriorityQueueTest, PushPopPeek) { 72 TEST(TaskSchedulerPriorityQueueTest, PushPopPeek) {
73 // Create test sequences. 73 // Create test sequences.
74 scoped_refptr<Sequence> sequence_a(new Sequence); 74 scoped_refptr<Sequence> sequence_a(new Sequence);
75 sequence_a->PushTask(WrapUnique( 75 sequence_a->PushTask(WrapUnique(new Task(
76 new Task(FROM_HERE, Closure(), 76 FROM_HERE, Closure(),
77 TaskTraits().WithPriority(TaskPriority::USER_VISIBLE)))); 77 TaskTraits().WithPriority(TaskPriority::USER_VISIBLE), TimeTicks())));
78 SequenceSortKey sort_key_a = sequence_a->GetSortKey(); 78 SequenceSortKey sort_key_a = sequence_a->GetSortKey();
79 79
80 scoped_refptr<Sequence> sequence_b(new Sequence); 80 scoped_refptr<Sequence> sequence_b(new Sequence);
81 sequence_b->PushTask(WrapUnique( 81 sequence_b->PushTask(WrapUnique(new Task(
82 new Task(FROM_HERE, Closure(), 82 FROM_HERE, Closure(),
83 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING)))); 83 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), TimeTicks())));
84 SequenceSortKey sort_key_b = sequence_b->GetSortKey(); 84 SequenceSortKey sort_key_b = sequence_b->GetSortKey();
85 85
86 scoped_refptr<Sequence> sequence_c(new Sequence); 86 scoped_refptr<Sequence> sequence_c(new Sequence);
87 sequence_c->PushTask(WrapUnique( 87 sequence_c->PushTask(WrapUnique(new Task(
88 new Task(FROM_HERE, Closure(), 88 FROM_HERE, Closure(),
89 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING)))); 89 TaskTraits().WithPriority(TaskPriority::USER_BLOCKING), TimeTicks())));
90 SequenceSortKey sort_key_c = sequence_c->GetSortKey(); 90 SequenceSortKey sort_key_c = sequence_c->GetSortKey();
91 91
92 scoped_refptr<Sequence> sequence_d(new Sequence); 92 scoped_refptr<Sequence> sequence_d(new Sequence);
93 sequence_d->PushTask(WrapUnique( 93 sequence_d->PushTask(WrapUnique(new Task(
94 new Task(FROM_HERE, Closure(), 94 FROM_HERE, Closure(), TaskTraits().WithPriority(TaskPriority::BACKGROUND),
95 TaskTraits().WithPriority(TaskPriority::BACKGROUND)))); 95 TimeTicks())));
96 SequenceSortKey sort_key_d = sequence_d->GetSortKey(); 96 SequenceSortKey sort_key_d = sequence_d->GetSortKey();
97 97
98 // Create a PriorityQueue and a Transaction. 98 // Create a PriorityQueue and a Transaction.
99 PriorityQueue pq; 99 PriorityQueue pq;
100 auto transaction(pq.BeginTransaction()); 100 auto transaction(pq.BeginTransaction());
101 EXPECT_SEQUENCE_AND_SORT_KEY_EQ(PriorityQueue::SequenceAndSortKey(), 101 EXPECT_SEQUENCE_AND_SORT_KEY_EQ(PriorityQueue::SequenceAndSortKey(),
102 transaction->Peek()); 102 transaction->Peek());
103 103
104 // Push |sequence_a| in the PriorityQueue. It becomes the sequence with the 104 // Push |sequence_a| in the PriorityQueue. It becomes the sequence with the
105 // highest priority. 105 // highest priority.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 EXPECT_TRUE(PriorityQueue::SequenceAndSortKey().is_null()); 219 EXPECT_TRUE(PriorityQueue::SequenceAndSortKey().is_null());
220 220
221 const PriorityQueue::SequenceAndSortKey non_null_sequence_and_sort_key( 221 const PriorityQueue::SequenceAndSortKey non_null_sequence_and_sort_key(
222 make_scoped_refptr(new Sequence), 222 make_scoped_refptr(new Sequence),
223 SequenceSortKey(TaskPriority::USER_VISIBLE, TimeTicks())); 223 SequenceSortKey(TaskPriority::USER_VISIBLE, TimeTicks()));
224 EXPECT_FALSE(non_null_sequence_and_sort_key.is_null()); 224 EXPECT_FALSE(non_null_sequence_and_sort_key.is_null());
225 } 225 }
226 226
227 } // namespace internal 227 } // namespace internal
228 } // namespace base 228 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/scheduler_worker_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698