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

Side by Side Diff: components/scheduler/base/task_queue_manager_unittest.cc

Issue 1178423008: Provision to start base::SimpleTestTickClock at initial ticks Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 11 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 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 "components/scheduler/base/task_queue_manager.h" 5 #include "components/scheduler/base/task_queue_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 make_scoped_ptr(new TestTimeSource(now_src_.get()))); 65 make_scoped_ptr(new TestTimeSource(now_src_.get())));
66 manager_ = make_scoped_ptr(new TaskQueueManager( 66 manager_ = make_scoped_ptr(new TaskQueueManager(
67 main_task_runner_, "test.scheduler", "test.scheduler", 67 main_task_runner_, "test.scheduler", "test.scheduler",
68 "test.scheduler.debug")); 68 "test.scheduler.debug"));
69 69
70 for (size_t i = 0; i < num_queues; i++) 70 for (size_t i = 0; i < num_queues; i++)
71 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); 71 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue")));
72 } 72 }
73 73
74 void Initialize(size_t num_queues) { 74 void Initialize(size_t num_queues) {
75 now_src_.reset(new base::SimpleTestTickClock()); 75 now_src_.reset(new base::SimpleTestTickClock(
76 now_src_->Advance(base::TimeDelta::FromMicroseconds(1000)); 76 base::TimeTicks() + base::TimeDelta::FromMicroseconds(1000)));
77 InitializeWithClock(num_queues, 77 InitializeWithClock(num_queues,
78 make_scoped_ptr(new TestTimeSource(now_src_.get()))); 78 make_scoped_ptr(new TestTimeSource(now_src_.get())));
79 } 79 }
80 80
81 void InitializeWithRealMessageLoop(size_t num_queues) { 81 void InitializeWithRealMessageLoop(size_t num_queues) {
82 now_src_.reset(new base::SimpleTestTickClock()); 82 now_src_.reset(new base::SimpleTestTickClock(base::TimeTicks()));
83 message_loop_.reset(new base::MessageLoop()); 83 message_loop_.reset(new base::MessageLoop());
84 manager_ = make_scoped_ptr(new TaskQueueManager( 84 manager_ = make_scoped_ptr(new TaskQueueManager(
85 MessageLoopTaskRunner::Create( 85 MessageLoopTaskRunner::Create(
86 make_scoped_ptr(new TestTimeSource(now_src_.get()))), 86 make_scoped_ptr(new TestTimeSource(now_src_.get()))),
87 "test.scheduler", "test.scheduler", "test.scheduler.debug")); 87 "test.scheduler", "test.scheduler", "test.scheduler.debug"));
88 88
89 for (size_t i = 0; i < num_queues; i++) 89 for (size_t i = 0; i < num_queues; i++)
90 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); 90 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue")));
91 } 91 }
92 92
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 double ratio = static_cast<double>(linear_delayed_task.count()) / 1699 double ratio = static_cast<double>(linear_delayed_task.count()) /
1700 static_cast<double>(quadratic_immediate_task.count()); 1700 static_cast<double>(quadratic_immediate_task.count());
1701 1701
1702 // This is by design, we want to enforce a strict ordering in task execution 1702 // This is by design, we want to enforce a strict ordering in task execution
1703 // where by delayed tasks can not skip ahead of non-delayed work. 1703 // where by delayed tasks can not skip ahead of non-delayed work.
1704 EXPECT_GT(ratio, 0.0); 1704 EXPECT_GT(ratio, 0.0);
1705 EXPECT_LT(ratio, 0.1); 1705 EXPECT_LT(ratio, 0.1);
1706 } 1706 }
1707 1707
1708 } // namespace scheduler 1708 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/proximity_auth/proximity_monitor_impl_unittest.cc ('k') | components/scheduler/base/time_domain_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698