OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "gin/shell_runner.h" | 5 #include "gin/shell_runner.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop/message_loop.h" |
8 #include "gin/array_buffer.h" | 9 #include "gin/array_buffer.h" |
9 #include "gin/converter.h" | 10 #include "gin/converter.h" |
10 #include "gin/public/isolate_holder.h" | 11 #include "gin/public/isolate_holder.h" |
11 #include "gin/v8_initializer.h" | 12 #include "gin/v8_initializer.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 15 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
15 #include "gin/public/isolate_holder.h" | 16 #include "gin/public/isolate_holder.h" |
16 #endif | 17 #endif |
17 | 18 |
18 using v8::Isolate; | 19 using v8::Isolate; |
19 using v8::Object; | 20 using v8::Object; |
20 using v8::Script; | 21 using v8::Script; |
21 using v8::String; | 22 using v8::String; |
22 | 23 |
23 namespace gin { | 24 namespace gin { |
24 | 25 |
25 TEST(RunnerTest, Run) { | 26 TEST(RunnerTest, Run) { |
| 27 base::MessageLoop message_loop; |
26 std::string source = "this.result = 'PASS';\n"; | 28 std::string source = "this.result = 'PASS';\n"; |
27 | 29 |
28 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 30 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
29 gin::V8Initializer::LoadV8Snapshot(); | 31 gin::V8Initializer::LoadV8Snapshot(); |
30 #endif | 32 #endif |
31 | 33 |
32 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | 34 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, |
33 gin::ArrayBufferAllocator::SharedInstance()); | 35 gin::ArrayBufferAllocator::SharedInstance()); |
34 gin::IsolateHolder instance; | 36 gin::IsolateHolder instance; |
35 | 37 |
36 ShellRunnerDelegate delegate; | 38 ShellRunnerDelegate delegate; |
37 Isolate* isolate = instance.isolate(); | 39 Isolate* isolate = instance.isolate(); |
38 ShellRunner runner(&delegate, isolate); | 40 ShellRunner runner(&delegate, isolate); |
39 Runner::Scope scope(&runner); | 41 Runner::Scope scope(&runner); |
40 runner.Run(source, "test_data.js"); | 42 runner.Run(source, "test_data.js"); |
41 | 43 |
42 std::string result; | 44 std::string result; |
43 EXPECT_TRUE(Converter<std::string>::FromV8(isolate, | 45 EXPECT_TRUE(Converter<std::string>::FromV8(isolate, |
44 runner.global()->Get(StringToV8(isolate, "result")), | 46 runner.global()->Get(StringToV8(isolate, "result")), |
45 &result)); | 47 &result)); |
46 EXPECT_EQ("PASS", result); | 48 EXPECT_EQ("PASS", result); |
47 } | 49 } |
48 | 50 |
49 } // namespace gin | 51 } // namespace gin |
OLD | NEW |