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

Unified Diff: components/scheduler/base/task_queue_manager_unittest.cc

Issue 1461143003: Revert of Adds TimeDomains to the TaskQueueManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/scheduler/base/task_queue_manager_unittest.cc
diff --git a/components/scheduler/base/task_queue_manager_unittest.cc b/components/scheduler/base/task_queue_manager_unittest.cc
index d5ad8e5a0650bedfd21cbb5b06c59e82898be773..1c46c695d1c03522c589df2842443584079ec69c 100644
--- a/components/scheduler/base/task_queue_manager_unittest.cc
+++ b/components/scheduler/base/task_queue_manager_unittest.cc
@@ -10,14 +10,12 @@
#include "base/test/simple_test_tick_clock.h"
#include "base/threading/thread.h"
#include "cc/test/ordered_simple_task_runner.h"
-#include "components/scheduler/base/real_time_domain.h"
#include "components/scheduler/base/task_queue_impl.h"
#include "components/scheduler/base/task_queue_manager_delegate_for_test.h"
#include "components/scheduler/base/task_queue_selector.h"
#include "components/scheduler/base/task_queue_sets.h"
#include "components/scheduler/base/test_always_fail_time_source.h"
#include "components/scheduler/base/test_time_source.h"
-#include "components/scheduler/base/virtual_time_domain.h"
#include "testing/gmock/include/gmock/gmock.h"
using testing::ElementsAre;
@@ -73,7 +71,6 @@
}
void InitializeWithRealMessageLoop(size_t num_queues) {
- now_src_.reset(new base::SimpleTestTickClock());
message_loop_.reset(new base::MessageLoop());
manager_ = make_scoped_ptr(new TaskQueueManager(
MessageLoopTaskRunner::Create(
@@ -900,49 +897,47 @@
EXPECT_TRUE(runners_[0]->RunsTasksOnCurrentThread());
}
-TEST_F(TaskQueueManagerTest, TimeDomain_NextScheduledRunTime) {
+TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime) {
Initialize(2u);
now_src_->Advance(base::TimeDelta::FromMicroseconds(10000));
// With no delayed tasks.
- base::TimeTicks run_time;
- EXPECT_FALSE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
+ EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null());
// With a non-delayed task.
runners_[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
- EXPECT_FALSE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
+ EXPECT_TRUE(manager_->NextPendingDelayedTaskRunTime().is_null());
// With a delayed task.
base::TimeDelta expected_delay = base::TimeDelta::FromMilliseconds(50);
runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
- EXPECT_TRUE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
- EXPECT_EQ(now_src_->NowTicks() + expected_delay, run_time);
+ EXPECT_EQ(now_src_->NowTicks() + expected_delay,
+ manager_->NextPendingDelayedTaskRunTime());
// With another delayed task in the same queue with a longer delay.
runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask),
base::TimeDelta::FromMilliseconds(100));
- EXPECT_TRUE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
- EXPECT_EQ(now_src_->NowTicks() + expected_delay, run_time);
+ EXPECT_EQ(now_src_->NowTicks() + expected_delay,
+ manager_->NextPendingDelayedTaskRunTime());
// With another delayed task in the same queue with a shorter delay.
expected_delay = base::TimeDelta::FromMilliseconds(20);
runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
- EXPECT_TRUE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
- EXPECT_EQ(now_src_->NowTicks() + expected_delay, run_time);
+ EXPECT_EQ(now_src_->NowTicks() + expected_delay,
+ manager_->NextPendingDelayedTaskRunTime());
// With another delayed task in a different queue with a shorter delay.
expected_delay = base::TimeDelta::FromMilliseconds(10);
runners_[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), expected_delay);
- EXPECT_TRUE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
- EXPECT_EQ(now_src_->NowTicks() + expected_delay, run_time);
+ EXPECT_EQ(now_src_->NowTicks() + expected_delay,
+ manager_->NextPendingDelayedTaskRunTime());
// Test it updates as time progresses
now_src_->Advance(expected_delay);
- EXPECT_TRUE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
- EXPECT_EQ(now_src_->NowTicks(), run_time);
-}
-
-TEST_F(TaskQueueManagerTest, TimeDomain_NextScheduledRunTime_MultipleQueues) {
+ EXPECT_EQ(now_src_->NowTicks(), manager_->NextPendingDelayedTaskRunTime());
+}
+
+TEST_F(TaskQueueManagerTest, NextPendingDelayedTaskRunTime_MultipleQueues) {
Initialize(3u);
base::TimeDelta delay1 = base::TimeDelta::FromMilliseconds(50);
@@ -951,11 +946,9 @@
runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay1);
runners_[1]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay2);
runners_[2]->PostDelayedTask(FROM_HERE, base::Bind(&NopTask), delay3);
- runners_[0]->PostTask(FROM_HERE, base::Bind(&NopTask));
-
- base::TimeTicks run_time;
- EXPECT_TRUE(manager_->real_time_domain()->NextScheduledRunTime(&run_time));
- EXPECT_EQ(now_src_->NowTicks() + delay2, run_time);
+
+ EXPECT_EQ(now_src_->NowTicks() + delay2,
+ manager_->NextPendingDelayedTaskRunTime());
}
TEST_F(TaskQueueManagerTest, DeleteTaskQueueManagerInsideATask) {
@@ -1383,79 +1376,4 @@
EXPECT_THAT(log, ElementsAre(false, false, true));
}
-TEST_F(TaskQueueManagerTest, TimeDomainsAreIndependant) {
- Initialize(2u);
-
- base::TimeTicks start_time = manager_->delegate()->NowTicks();
- scoped_refptr<VirtualTimeDomain> domain_a(new VirtualTimeDomain(start_time));
- scoped_refptr<VirtualTimeDomain> domain_b(new VirtualTimeDomain(start_time));
- manager_->RegisterTimeDomain(domain_a);
- manager_->RegisterTimeDomain(domain_b);
- runners_[0]->SetTimeDomain(domain_a);
- runners_[1]->SetTimeDomain(domain_b);
-
- std::vector<int> run_order;
- runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order),
- base::TimeDelta::FromMilliseconds(10));
- runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 2, &run_order),
- base::TimeDelta::FromMilliseconds(20));
- runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 3, &run_order),
- base::TimeDelta::FromMilliseconds(30));
-
- runners_[1]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 4, &run_order),
- base::TimeDelta::FromMilliseconds(10));
- runners_[1]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 5, &run_order),
- base::TimeDelta::FromMilliseconds(20));
- runners_[1]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 6, &run_order),
- base::TimeDelta::FromMilliseconds(30));
-
- domain_b->AdvanceTo(start_time + base::TimeDelta::FromMilliseconds(50));
-
- test_task_runner_->RunUntilIdle();
- EXPECT_THAT(run_order, ElementsAre(4, 5, 6));
-
- domain_a->AdvanceTo(start_time + base::TimeDelta::FromMilliseconds(50));
-
- test_task_runner_->RunUntilIdle();
- EXPECT_THAT(run_order, ElementsAre(4, 5, 6, 1, 2, 3));
-
- manager_->UnregisterTimeDomain(domain_a);
- manager_->UnregisterTimeDomain(domain_b);
-}
-
-TEST_F(TaskQueueManagerTest, TimeDomainMigration) {
- Initialize(1u);
-
- base::TimeTicks start_time = manager_->delegate()->NowTicks();
- scoped_refptr<VirtualTimeDomain> domain_a(new VirtualTimeDomain(start_time));
- manager_->RegisterTimeDomain(domain_a);
- runners_[0]->SetTimeDomain(domain_a);
-
- std::vector<int> run_order;
- runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 1, &run_order),
- base::TimeDelta::FromMilliseconds(10));
- runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 2, &run_order),
- base::TimeDelta::FromMilliseconds(20));
- runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 3, &run_order),
- base::TimeDelta::FromMilliseconds(30));
- runners_[0]->PostDelayedTask(FROM_HERE, base::Bind(&TestTask, 4, &run_order),
- base::TimeDelta::FromMilliseconds(40));
-
- domain_a->AdvanceTo(start_time + base::TimeDelta::FromMilliseconds(20));
- test_task_runner_->RunUntilIdle();
- EXPECT_THAT(run_order, ElementsAre(1, 2));
-
- scoped_refptr<VirtualTimeDomain> domain_b(new VirtualTimeDomain(start_time));
- manager_->RegisterTimeDomain(domain_b);
- runners_[0]->SetTimeDomain(domain_b);
-
- domain_b->AdvanceTo(start_time + base::TimeDelta::FromMilliseconds(50));
-
- test_task_runner_->RunUntilIdle();
- EXPECT_THAT(run_order, ElementsAre(1, 2, 3, 4));
-
- manager_->UnregisterTimeDomain(domain_a);
- manager_->UnregisterTimeDomain(domain_b);
-}
-
} // namespace scheduler
« no previous file with comments | « components/scheduler/base/task_queue_manager.cc ('k') | components/scheduler/base/task_queue_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698