V8 Project
default-platform-unittest.cc
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
6 #include "testing/gmock/include/gmock/gmock.h"
7 
8 using testing::InSequence;
9 using testing::StrictMock;
10 
11 namespace v8 {
12 namespace platform {
13 
14 namespace {
15 
16 struct MockTask : public Task {
17  virtual ~MockTask() { Die(); }
18  MOCK_METHOD0(Run, void());
19  MOCK_METHOD0(Die, void());
20 };
21 
22 } // namespace
23 
24 
25 TEST(DefaultPlatformTest, PumpMessageLoop) {
26  InSequence s;
27 
28  int dummy;
29  Isolate* isolate = reinterpret_cast<Isolate*>(&dummy);
30 
31  DefaultPlatform platform;
32  EXPECT_FALSE(platform.PumpMessageLoop(isolate));
33 
34  StrictMock<MockTask>* task = new StrictMock<MockTask>;
35  platform.CallOnForegroundThread(isolate, task);
36  EXPECT_CALL(*task, Run());
37  EXPECT_CALL(*task, Die());
38  EXPECT_TRUE(platform.PumpMessageLoop(isolate));
39  EXPECT_FALSE(platform.PumpMessageLoop(isolate));
40 }
41 
42 } // namespace platform
43 } // namespace v8
Isolate represents an isolated instance of the V8 engine.
Definition: v8.h:4356
A Task represents a unit of work.
Definition: v8-platform.h:15
bool PumpMessageLoop(v8::Isolate *isolate)
virtual void CallOnForegroundThread(v8::Isolate *isolate, Task *task) OVERRIDE
Schedules a task to be invoked on a foreground thread wrt a specific |isolate|.
TEST(DefaultPlatformTest, PumpMessageLoop)
bool PumpMessageLoop(v8::Platform *platform, v8::Isolate *isolate)
Pumps the message loop for the given isolate.
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20