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

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: CR-robliao-45-initial-state-comment 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 {
65 worker_a_->JoinForTesting();
66 worker_b_->JoinForTesting();
67 worker_c_->JoinForTesting();
68 }
69
70 scoped_refptr<SchedulerWorker> worker_a_; 61 scoped_refptr<SchedulerWorker> worker_a_;
71 scoped_refptr<SchedulerWorker> worker_b_; 62 scoped_refptr<SchedulerWorker> worker_b_;
72 scoped_refptr<SchedulerWorker> worker_c_; 63 scoped_refptr<SchedulerWorker> worker_c_;
73 64
74 private: 65 private:
75 TaskTracker task_tracker_; 66 TaskTracker task_tracker_;
76 }; 67 };
77 68
78 } // namespace 69 } // namespace
79 70
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 241
251 // Verify that Push() DCHECKs when a value is inserted twice. 242 // Verify that Push() DCHECKs when a value is inserted twice.
252 TEST_F(TaskSchedulerWorkerStackTest, PushTwice) { 243 TEST_F(TaskSchedulerWorkerStackTest, PushTwice) {
253 SchedulerWorkerStack stack; 244 SchedulerWorkerStack stack;
254 stack.Push(worker_a_.get()); 245 stack.Push(worker_a_.get());
255 EXPECT_DCHECK_DEATH({ stack.Push(worker_a_.get()); }); 246 EXPECT_DCHECK_DEATH({ stack.Push(worker_a_.get()); });
256 } 247 }
257 248
258 } // namespace internal 249 } // namespace internal
259 } // namespace base 250 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_impl.cc ('k') | base/task_scheduler/scheduler_worker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698