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 "gin/array_buffer.h" |
8 #include "gin/converter.h" | 9 #include "gin/converter.h" |
9 #include "gin/public/isolate_holder.h" | 10 #include "gin/public/isolate_holder.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 using v8::Isolate; | 13 using v8::Isolate; |
13 using v8::Object; | 14 using v8::Object; |
14 using v8::Script; | 15 using v8::Script; |
15 using v8::String; | 16 using v8::String; |
16 | 17 |
17 namespace gin { | 18 namespace gin { |
18 | 19 |
19 TEST(RunnerTest, Run) { | 20 TEST(RunnerTest, Run) { |
20 std::string source = "this.result = 'PASS';\n"; | 21 std::string source = "this.result = 'PASS';\n"; |
21 | 22 |
22 gin::IsolateHolder instance(gin::IsolateHolder::kStrictMode); | 23 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, |
| 24 gin::ArrayBufferAllocator::SharedInstance()); |
| 25 gin::IsolateHolder instance; |
23 | 26 |
24 ShellRunnerDelegate delegate; | 27 ShellRunnerDelegate delegate; |
25 Isolate* isolate = instance.isolate(); | 28 Isolate* isolate = instance.isolate(); |
26 ShellRunner runner(&delegate, isolate); | 29 ShellRunner runner(&delegate, isolate); |
27 Runner::Scope scope(&runner); | 30 Runner::Scope scope(&runner); |
28 runner.Run(source, "test_data.js"); | 31 runner.Run(source, "test_data.js"); |
29 | 32 |
30 std::string result; | 33 std::string result; |
31 EXPECT_TRUE(Converter<std::string>::FromV8(isolate, | 34 EXPECT_TRUE(Converter<std::string>::FromV8(isolate, |
32 runner.global()->Get(StringToV8(isolate, "result")), | 35 runner.global()->Get(StringToV8(isolate, "result")), |
33 &result)); | 36 &result)); |
34 EXPECT_EQ("PASS", result); | 37 EXPECT_EQ("PASS", result); |
35 } | 38 } |
36 | 39 |
37 } // namespace gin | 40 } // namespace gin |
OLD | NEW |