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

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

Issue 2806413002: Separate the create and start phases in SchedulerSingleThreadTaskRunnerManager. (Closed)
Patch Set: self-review Created 3 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
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/scheduler_worker_stack.h" 5 #include "base/task_scheduler/scheduler_worker_stack.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/task_scheduler/scheduler_worker.h" 10 #include "base/task_scheduler/scheduler_worker.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 bool CanDetach(SchedulerWorker* worker) override { 38 bool CanDetach(SchedulerWorker* worker) override {
39 return false; 39 return false;
40 } 40 }
41 void OnDetach() override { ADD_FAILURE() << "Unexpected call to OnDetach()"; } 41 void OnDetach() override { ADD_FAILURE() << "Unexpected call to OnDetach()"; }
42 }; 42 };
43 43
44 class TaskSchedulerWorkerStackTest : public testing::Test { 44 class TaskSchedulerWorkerStackTest : public testing::Test {
45 protected: 45 protected:
46 void SetUp() override { 46 void SetUp() override {
47 worker_a_ = SchedulerWorker::Create( 47 worker_a_ = make_scoped_refptr(new SchedulerWorker(
48 ThreadPriority::NORMAL, 48 ThreadPriority::NORMAL, WrapUnique(new MockSchedulerWorkerDelegate),
49 WrapUnique(new MockSchedulerWorkerDelegate), &task_tracker_, 49 &task_tracker_));
50 SchedulerWorker::InitialState::ALIVE);
51 ASSERT_TRUE(worker_a_); 50 ASSERT_TRUE(worker_a_);
52 worker_b_ = SchedulerWorker::Create( 51 worker_b_ = make_scoped_refptr(new SchedulerWorker(
53 ThreadPriority::NORMAL, 52 ThreadPriority::NORMAL, WrapUnique(new MockSchedulerWorkerDelegate),
54 WrapUnique(new MockSchedulerWorkerDelegate), &task_tracker_, 53 &task_tracker_));
55 SchedulerWorker::InitialState::ALIVE);
56 ASSERT_TRUE(worker_b_); 54 ASSERT_TRUE(worker_b_);
57 worker_c_ = SchedulerWorker::Create( 55 worker_c_ = make_scoped_refptr(new SchedulerWorker(
58 ThreadPriority::NORMAL, 56 ThreadPriority::NORMAL, WrapUnique(new MockSchedulerWorkerDelegate),
59 WrapUnique(new MockSchedulerWorkerDelegate), &task_tracker_, 57 &task_tracker_));
60 SchedulerWorker::InitialState::ALIVE);
61 ASSERT_TRUE(worker_c_); 58 ASSERT_TRUE(worker_c_);
62 } 59 }
63 60
64 void TearDown() override { 61 void TearDown() override {
65 worker_a_->JoinForTesting(); 62 worker_a_->JoinForTesting();
66 worker_b_->JoinForTesting(); 63 worker_b_->JoinForTesting();
67 worker_c_->JoinForTesting(); 64 worker_c_->JoinForTesting();
68 } 65 }
69 66
70 scoped_refptr<SchedulerWorker> worker_a_; 67 scoped_refptr<SchedulerWorker> worker_a_;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 247
251 // Verify that Push() DCHECKs when a value is inserted twice. 248 // Verify that Push() DCHECKs when a value is inserted twice.
252 TEST_F(TaskSchedulerWorkerStackTest, PushTwice) { 249 TEST_F(TaskSchedulerWorkerStackTest, PushTwice) {
253 SchedulerWorkerStack stack; 250 SchedulerWorkerStack stack;
254 stack.Push(worker_a_.get()); 251 stack.Push(worker_a_.get());
255 EXPECT_DCHECK_DEATH({ stack.Push(worker_a_.get()); }); 252 EXPECT_DCHECK_DEATH({ stack.Push(worker_a_.get()); });
256 } 253 }
257 254
258 } // namespace internal 255 } // namespace internal
259 } // namespace base 256 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698