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

Unified Diff: test/unittests/libplatform/default-platform-unittest.cc

Issue 2609833003: Add support for idle tasks to the default platform (Closed)
Patch Set: updates Created 3 years, 12 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
« no previous file with comments | « src/libplatform/default-platform.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/libplatform/default-platform-unittest.cc
diff --git a/test/unittests/libplatform/default-platform-unittest.cc b/test/unittests/libplatform/default-platform-unittest.cc
index 814b27bc518e5a147e0291e605ccae416539c4c5..473f8d39b827d5a594ddaf9f58c476b3b615416d 100644
--- a/test/unittests/libplatform/default-platform-unittest.cc
+++ b/test/unittests/libplatform/default-platform-unittest.cc
@@ -19,6 +19,11 @@ struct MockTask : public Task {
MOCK_METHOD0(Die, void());
};
+struct MockIdleTask : public IdleTask {
+ virtual ~MockIdleTask() { Die(); }
+ MOCK_METHOD1(Run, void(double deadline_in_seconds));
+ MOCK_METHOD0(Die, void());
+};
class DefaultPlatformWithMockTime : public DefaultPlatform {
public:
@@ -126,6 +131,35 @@ TEST(DefaultPlatformTest, PendingDelayedTasksAreDestroyedOnShutdown) {
}
}
+TEST(DefaultPlatformTest, RunIdleTasks) {
+ InSequence s;
+
+ int dummy;
+ Isolate* isolate = reinterpret_cast<Isolate*>(&dummy);
+
+ DefaultPlatformWithMockTime platform;
+
+ StrictMock<MockIdleTask>* task = new StrictMock<MockIdleTask>;
+ platform.CallIdleOnForegroundThread(isolate, task);
+ EXPECT_CALL(*task, Run(42.0 + 23.0));
+ EXPECT_CALL(*task, Die());
+ platform.IncreaseTime(23.0);
+ platform.RunIdleTasks(isolate, 42.0);
+}
+
+TEST(DefaultPlatformTest, PendingIdleTasksAreDestroyedOnShutdown) {
+ InSequence s;
+
+ int dummy;
+ Isolate* isolate = reinterpret_cast<Isolate*>(&dummy);
+
+ {
+ DefaultPlatformWithMockTime platform;
+ StrictMock<MockIdleTask>* task = new StrictMock<MockIdleTask>;
+ platform.CallIdleOnForegroundThread(isolate, task);
+ EXPECT_CALL(*task, Die());
+ }
+}
} // namespace platform
} // namespace v8
« no previous file with comments | « src/libplatform/default-platform.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698