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

Unified Diff: components/scheduler/child/virtual_time_tqm_delegate_unittest.cc

Issue 1424053002: Adds a flag to support "Virtual Time" to the blink scheduler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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/child/virtual_time_tqm_delegate_unittest.cc
diff --git a/components/scheduler/child/virtual_time_tqm_delegate_unittest.cc b/components/scheduler/child/virtual_time_tqm_delegate_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8d7e6ab3d2e91305c241200b3c0fdf302c716df2
--- /dev/null
+++ b/components/scheduler/child/virtual_time_tqm_delegate_unittest.cc
@@ -0,0 +1,54 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/scheduler/child/virtual_time_tqm_delegate.h"
+
+#include "base/bind.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace scheduler {
+
+class VirtualTimeTqmDelegateTest : public testing::Test {
+ public:
+ VirtualTimeTqmDelegateTest() {}
+
+ ~VirtualTimeTqmDelegateTest() override {}
+
+ void SetUp() override {
+ message_loop_.reset(new base::MessageLoop());
+ initial_time_ = base::TimeTicks() + base::TimeDelta::FromSeconds(100);
+ virtual_time_tqm_delegate_ =
+ VirtualTimeTqmDelegate::Create(message_loop_.get(), initial_time_);
+ }
+
+ base::TimeTicks initial_time_;
+ scoped_ptr<base::MessageLoop> message_loop_;
+
+ scoped_refptr<VirtualTimeTqmDelegate> virtual_time_tqm_delegate_;
+};
+
+namespace {
+void TestFunc(bool* run) {
+ *run = true;
+}
+}
+
+TEST_F(VirtualTimeTqmDelegateTest, OnNoMoreImmediateWork_TimersFastForward) {
+ bool was_run = false;
+ virtual_time_tqm_delegate_->PostDelayedTask(FROM_HERE,
+ base::Bind(TestFunc, &was_run),
+ base::TimeDelta::FromSeconds(1));
+
+ EXPECT_EQ(initial_time_, virtual_time_tqm_delegate_->NowTicks());
+
+ virtual_time_tqm_delegate_->OnNoMoreImmediateWork();
+
+ EXPECT_EQ(initial_time_ + base::TimeDelta::FromSeconds(1),
+ virtual_time_tqm_delegate_->NowTicks());
+
+ message_loop_->RunUntilIdle();
+ EXPECT_TRUE(was_run);
+}
+
+} // namespace scheduler

Powered by Google App Engine
This is Rietveld 408576698