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