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

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

Issue 2737743002: Make idle tasks optional in the default platform. (Closed)
Patch Set: another fix Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/libplatform/default-platform.cc ('k') | test/unittests/run-all-unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/libplatform/default-platform.h" 5 #include "src/libplatform/default-platform.h"
6 #include "testing/gmock/include/gmock/gmock.h" 6 #include "testing/gmock/include/gmock/gmock.h"
7 7
8 using testing::InSequence; 8 using testing::InSequence;
9 using testing::StrictMock; 9 using testing::StrictMock;
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace platform { 12 namespace platform {
13 13
14 namespace { 14 namespace {
15 15
16 struct MockTask : public Task { 16 struct MockTask : public Task {
17 virtual ~MockTask() { Die(); } 17 virtual ~MockTask() { Die(); }
18 MOCK_METHOD0(Run, void()); 18 MOCK_METHOD0(Run, void());
19 MOCK_METHOD0(Die, void()); 19 MOCK_METHOD0(Die, void());
20 }; 20 };
21 21
22 struct MockIdleTask : public IdleTask { 22 struct MockIdleTask : public IdleTask {
23 virtual ~MockIdleTask() { Die(); } 23 virtual ~MockIdleTask() { Die(); }
24 MOCK_METHOD1(Run, void(double deadline_in_seconds)); 24 MOCK_METHOD1(Run, void(double deadline_in_seconds));
25 MOCK_METHOD0(Die, void()); 25 MOCK_METHOD0(Die, void());
26 }; 26 };
27 27
28 class DefaultPlatformWithMockTime : public DefaultPlatform { 28 class DefaultPlatformWithMockTime : public DefaultPlatform {
29 public: 29 public:
30 DefaultPlatformWithMockTime() : time_(0) {} 30 DefaultPlatformWithMockTime()
31 : DefaultPlatform(IdleTaskSupport::kEnabled), time_(0) {}
31 double MonotonicallyIncreasingTime() override { return time_; } 32 double MonotonicallyIncreasingTime() override { return time_; }
32 void IncreaseTime(double seconds) { time_ += seconds; } 33 void IncreaseTime(double seconds) { time_ += seconds; }
33 34
34 private: 35 private:
35 double time_; 36 double time_;
36 }; 37 };
37 38
38 } // namespace 39 } // namespace
39 40
40 41
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 { 157 {
157 DefaultPlatformWithMockTime platform; 158 DefaultPlatformWithMockTime platform;
158 StrictMock<MockIdleTask>* task = new StrictMock<MockIdleTask>; 159 StrictMock<MockIdleTask>* task = new StrictMock<MockIdleTask>;
159 platform.CallIdleOnForegroundThread(isolate, task); 160 platform.CallIdleOnForegroundThread(isolate, task);
160 EXPECT_CALL(*task, Die()); 161 EXPECT_CALL(*task, Die());
161 } 162 }
162 } 163 }
163 164
164 } // namespace platform 165 } // namespace platform
165 } // namespace v8 166 } // namespace v8
OLDNEW
« no previous file with comments | « src/libplatform/default-platform.cc ('k') | test/unittests/run-all-unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698