OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/runner.h" | 5 #include "gin/runner.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/scoped_ptr.h" | |
8 #include "gin/converter.h" | 9 #include "gin/converter.h" |
10 #include "gin/gin.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 | 12 |
11 using v8::Isolate; | 13 using v8::Isolate; |
12 using v8::Object; | 14 using v8::Object; |
13 using v8::Script; | 15 using v8::Script; |
14 using v8::String; | 16 using v8::String; |
15 | 17 |
16 namespace gin { | 18 namespace gin { |
17 | 19 |
18 TEST(RunnerTest, Run) { | 20 TEST(RunnerTest, Run) { |
19 std::string source = "this.result = 'PASS';\n"; | 21 std::string source = "this.result = 'PASS';\n"; |
20 | 22 |
23 scoped_ptr<gin::Gin> instance(new gin::Gin); | |
abarth-chromium
2013/11/19 15:49:21
Why not allocate on the stack?
jochen (gone - plz use gerrit)
2013/11/19 15:57:24
Done.
| |
24 | |
21 RunnerDelegate delegate; | 25 RunnerDelegate delegate; |
22 Isolate* isolate = Isolate::GetCurrent(); | 26 Isolate* isolate = instance->isolate(); |
23 Runner runner(&delegate, isolate); | 27 Runner runner(&delegate, isolate); |
24 Runner::Scope scope(&runner); | 28 Runner::Scope scope(&runner); |
25 runner.Run(source); | 29 runner.Run(source); |
26 | 30 |
27 std::string result; | 31 std::string result; |
28 EXPECT_TRUE(Converter<std::string>::FromV8( | 32 EXPECT_TRUE(Converter<std::string>::FromV8( |
29 runner.global()->Get(StringToV8(isolate, "result")), | 33 runner.global()->Get(StringToV8(isolate, "result")), |
30 &result)); | 34 &result)); |
31 EXPECT_EQ("PASS", result); | 35 EXPECT_EQ("PASS", result); |
32 } | 36 } |
33 | 37 |
34 } // namespace gin | 38 } // namespace gin |
OLD | NEW |