| OLD | NEW |
| 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_thread_stack.h" | 5 #include "base/task_scheduler/scheduler_worker_thread_stack.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/task_scheduler/scheduler_worker_thread.h" | 9 #include "base/task_scheduler/scheduler_worker_thread.h" |
| 10 #include "base/task_scheduler/sequence.h" | 10 #include "base/task_scheduler/sequence.h" |
| 11 #include "base/task_scheduler/task_tracker.h" | 11 #include "base/task_scheduler/task_tracker.h" |
| 12 #include "base/task_scheduler/test_utils.h" | 12 #include "base/task_scheduler/test_utils.h" |
| 13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 namespace internal { | 17 namespace internal { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class MockSchedulerWorkerThreadDelegate | 21 class MockSchedulerWorkerThreadDelegate |
| 22 : public SchedulerWorkerThread::Delegate { | 22 : public SchedulerWorkerThread::Delegate { |
| 23 public: | 23 public: |
| 24 void OnMainEntry() override {} | 24 void OnMainEntry() override {} |
| 25 scoped_refptr<Sequence> GetWork( | 25 scoped_refptr<Sequence> GetWork( |
| 26 SchedulerWorkerThread* worker_thread) override { | 26 SchedulerWorkerThread* worker_thread) override { |
| 27 return nullptr; | 27 return nullptr; |
| 28 } | 28 } |
| 29 void EnqueueSequence(scoped_refptr<Sequence> sequence) override { | 29 void ReEnqueueSequence(scoped_refptr<Sequence> sequence) override { |
| 30 NOTREACHED(); | 30 NOTREACHED(); |
| 31 } | 31 } |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 class TaskSchedulerWorkerThreadStackTest : public testing::Test { | 34 class TaskSchedulerWorkerThreadStackTest : public testing::Test { |
| 35 protected: | 35 protected: |
| 36 void SetUp() override { | 36 void SetUp() override { |
| 37 thread_a_ = SchedulerWorkerThread::CreateSchedulerWorkerThread( | 37 thread_a_ = SchedulerWorkerThread::CreateSchedulerWorkerThread( |
| 38 ThreadPriority::NORMAL, &delegate_, &task_tracker_); | 38 ThreadPriority::NORMAL, &delegate_, &task_tracker_); |
| 39 ASSERT_TRUE(thread_a_); | 39 ASSERT_TRUE(thread_a_); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 // Verify that Push() DCHECKs when a value is inserted twice. | 154 // Verify that Push() DCHECKs when a value is inserted twice. |
| 155 TEST_F(TaskSchedulerWorkerThreadStackTest, PushTwice) { | 155 TEST_F(TaskSchedulerWorkerThreadStackTest, PushTwice) { |
| 156 SchedulerWorkerThreadStack stack; | 156 SchedulerWorkerThreadStack stack; |
| 157 stack.Push(thread_a_.get()); | 157 stack.Push(thread_a_.get()); |
| 158 EXPECT_DCHECK_DEATH({ stack.Push(thread_a_.get()); }, ""); | 158 EXPECT_DCHECK_DEATH({ stack.Push(thread_a_.get()); }, ""); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace internal | 161 } // namespace internal |
| 162 } // namespace base | 162 } // namespace base |
| OLD | NEW |