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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/child/scheduler_helper_unittest.cc

Issue 2540663002: Add the concept of QueueEnabledVoters to blink scheduler TaskQueue (Closed)
Patch Set: Fix test crashes and address feedback. Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "platform/scheduler/child/scheduler_helper.h" 5 #include "platform/scheduler/child/scheduler_helper.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 scheduler_helper_->SetObserver(nullptr); 209 scheduler_helper_->SetObserver(nullptr);
210 } 210 }
211 211
212 TEST_F(SchedulerHelperTest, OnTriedToExecuteBlockedTask) { 212 TEST_F(SchedulerHelperTest, OnTriedToExecuteBlockedTask) {
213 MockObserver observer; 213 MockObserver observer;
214 scheduler_helper_->SetObserver(&observer); 214 scheduler_helper_->SetObserver(&observer);
215 215
216 scoped_refptr<TaskQueue> task_queue = scheduler_helper_->NewTaskQueue( 216 scoped_refptr<TaskQueue> task_queue = scheduler_helper_->NewTaskQueue(
217 TaskQueue::Spec(TaskQueue::QueueType::TEST) 217 TaskQueue::Spec(TaskQueue::QueueType::TEST)
218 .SetShouldReportWhenExecutionBlocked(true)); 218 .SetShouldReportWhenExecutionBlocked(true));
219 task_queue->SetQueueEnabled(false); 219 std::unique_ptr<TaskQueue::QueueEnabledVoter> voter =
220 task_queue->CreateQueueEnabledVoter();
221 voter->SetQueueEnabled(false);
220 task_queue->PostTask(FROM_HERE, base::Bind(&NopTask)); 222 task_queue->PostTask(FROM_HERE, base::Bind(&NopTask));
221 223
222 // Trick |task_queue| into posting a DoWork. By default PostTask with a 224 // Trick |task_queue| into posting a DoWork. By default PostTask with a
223 // disabled queue won't post a DoWork until we enable the queue. 225 // disabled queue won't post a DoWork until we enable the queue.
224 task_queue->SetQueueEnabled(true); 226 voter->SetQueueEnabled(true);
225 task_queue->SetQueueEnabled(false); 227 voter->SetQueueEnabled(false);
226 228
227 EXPECT_CALL(observer, OnTriedToExecuteBlockedTask(_, _)).Times(1); 229 EXPECT_CALL(observer, OnTriedToExecuteBlockedTask(_, _)).Times(1);
228 RunUntilIdle(); 230 RunUntilIdle();
229 231
230 scheduler_helper_->SetObserver(nullptr); 232 scheduler_helper_->SetObserver(nullptr);
231 } 233 }
232 234
233 } // namespace scheduler 235 } // namespace scheduler
234 } // namespace blink 236 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698