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

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

Issue 1477353002: Revert of Move throttling of background timers into the renderer scheduler (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
« no previous file with comments | « components/scheduler/base/time_domain.cc ('k') | components/scheduler/base/virtual_time_domain.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/base/time_domain_unittest.cc
diff --git a/components/scheduler/base/time_domain_unittest.cc b/components/scheduler/base/time_domain_unittest.cc
index e699e189e8e8a5ac615d3845cf9005114a2c0c99..d41305ac58d372ce54dd2c2bec37735e2f1004d8 100644
--- a/components/scheduler/base/time_domain_unittest.cc
+++ b/components/scheduler/base/time_domain_unittest.cc
@@ -19,18 +19,14 @@
class MockTimeDomain : public TimeDomain {
public:
- explicit MockTimeDomain(TimeDomain::Observer* observer)
- : TimeDomain(observer),
- now_(base::TimeTicks() + base::TimeDelta::FromSeconds(1)) {}
-
- ~MockTimeDomain() override {}
+ MockTimeDomain()
+ : now_(base::TimeTicks() + base::TimeDelta::FromSeconds(1)) {}
using TimeDomain::NextScheduledRunTime;
using TimeDomain::NextScheduledTaskQueue;
using TimeDomain::ScheduleDelayedWork;
using TimeDomain::UnregisterQueue;
using TimeDomain::UpdateWorkQueues;
- using TimeDomain::RegisterAsUpdatableTaskQueue;
// TimeSource implementation:
LazyNow CreateLazyNow() override { return LazyNow(now_); }
@@ -53,23 +49,21 @@
private:
base::TimeTicks now_;
+ ~MockTimeDomain() override {}
+
DISALLOW_COPY_AND_ASSIGN(MockTimeDomain);
};
class TimeDomainTest : public testing::Test {
public:
void SetUp() final {
- time_domain_ = make_scoped_ptr(CreateMockTimeDomain());
+ time_domain_ = make_scoped_refptr(new MockTimeDomain());
task_queue_ = make_scoped_refptr(new internal::TaskQueueImpl(
- nullptr, time_domain_.get(), TaskQueue::Spec("test_queue"),
- "test.category", "test.category"));
+ nullptr, time_domain_, TaskQueue::Spec("test_queue"), "test.category",
+ "test.category"));
}
- virtual MockTimeDomain* CreateMockTimeDomain() {
- return new MockTimeDomain(nullptr);
- }
-
- scoped_ptr<MockTimeDomain> time_domain_;
+ scoped_refptr<MockTimeDomain> time_domain_;
scoped_refptr<internal::TaskQueueImpl> task_queue_;
};
@@ -121,7 +115,7 @@
TEST_F(TimeDomainTest, UnregisterQueue) {
scoped_refptr<internal::TaskQueueImpl> task_queue2_ =
make_scoped_refptr(new internal::TaskQueueImpl(
- nullptr, time_domain_.get(), TaskQueue::Spec("test_queue2"),
+ nullptr, time_domain_, TaskQueue::Spec("test_queue2"),
"test.category", "test.category"));
EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _)).Times(1);
@@ -146,7 +140,7 @@
}
TEST_F(TimeDomainTest, UpdateWorkQueues) {
- scoped_ptr<MockTimeDomain> dummy_delegate(new MockTimeDomain(nullptr));
+ scoped_refptr<MockTimeDomain> dummy_delegate(new MockTimeDomain());
base::SimpleTestTickClock dummy_time_source;
scoped_refptr<cc::OrderedSimpleTaskRunner> dummy_task_runner(
new cc::OrderedSimpleTaskRunner(&dummy_time_source, false));
@@ -182,38 +176,4 @@
EXPECT_EQ(1UL, dummy_queue->IncomingQueueSizeForTest());
}
-namespace {
-class MockObserver : public TimeDomain::Observer {
- public:
- ~MockObserver() override {}
-
- MOCK_METHOD0(OnTimeDomainHasImmediateWork, void());
- MOCK_METHOD0(OnTimeDomainHasDelayedWork, void());
-};
-} // namespace
-
-class TimeDomainWithObserverTest : public TimeDomainTest {
- public:
- MockTimeDomain* CreateMockTimeDomain() override {
- observer_.reset(new MockObserver());
- return new MockTimeDomain(observer_.get());
- }
-
- scoped_ptr<MockObserver> observer_;
-};
-
-TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasImmediateWork) {
- EXPECT_CALL(*observer_, OnTimeDomainHasImmediateWork());
- time_domain_->RegisterAsUpdatableTaskQueue(task_queue_.get());
-}
-
-TEST_F(TimeDomainWithObserverTest, OnTimeDomainHasDelayedWork) {
- EXPECT_CALL(*observer_, OnTimeDomainHasDelayedWork());
- EXPECT_CALL(*time_domain_.get(), RequestWakeup(_, _));
- LazyNow lazy_now = time_domain_->CreateLazyNow();
- time_domain_->ScheduleDelayedWork(
- task_queue_.get(),
- time_domain_->Now() + base::TimeDelta::FromMilliseconds(10), &lazy_now);
-}
-
} // namespace scheduler
« no previous file with comments | « components/scheduler/base/time_domain.cc ('k') | components/scheduler/base/virtual_time_domain.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698