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

Unified Diff: components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc

Issue 899863002: Add support in TestMockTimeTaskRunner for vending out mock Time and mock Clocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Start ticks from 0, some tests depend on this. Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc
diff --git a/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc b/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc
index 8bf44fee91dd353aad052d4f1f9bdd277f1bcde5..d67473c07bc5293110c3a0f359e69f776bbba3fb 100644
--- a/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc
+++ b/components/policy/core/common/remote_commands/remote_commands_queue_unittest.cc
@@ -56,26 +56,6 @@ class MockRemoteCommandsQueueObserver : public RemoteCommandsQueue::Observer {
DISALLOW_COPY_AND_ASSIGN(MockRemoteCommandsQueueObserver);
};
-// Clock which converts the current time represented by a base::TimeTick from
-// base::TestMockTimeTaskRunner to a base::Time.
-class TestingClock : public base::Clock {
- public:
- explicit TestingClock(scoped_refptr<base::TestMockTimeTaskRunner> task_runner)
- : task_runner_(task_runner) {}
- ~TestingClock() override {}
-
- // base::Clock:
- base::Time Now() override {
- return (task_runner_->GetCurrentMockTime() - base::TimeTicks::UnixEpoch()) +
- base::Time::UnixEpoch();
- }
-
- private:
- scoped_refptr<base::TestMockTimeTaskRunner> task_runner_;
-
- DISALLOW_COPY_AND_ASSIGN(TestingClock);
-};
-
} // namespace
using ::testing::InSequence;
@@ -122,11 +102,12 @@ class RemoteCommandsQueueTest : public testing::Test {
RemoteCommandsQueueTest::RemoteCommandsQueueTest()
: task_runner_(new base::TestMockTimeTaskRunner()),
+ clock_(nullptr),
runner_handle_(task_runner_) {
}
void RemoteCommandsQueueTest::SetUp() {
- scoped_ptr<base::Clock> clock(new TestingClock(task_runner_));
+ scoped_ptr<base::Clock> clock(task_runner_->GetMockClock());
test_start_time_ = clock->Now();
clock_ = clock.get();

Powered by Google App Engine
This is Rietveld 408576698