[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 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 | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #include "gin/runner.h" | ||||
6 | |||||
7 | #include "base/compiler_specific.h" | ||||
8 | #include "gin/converter.h" | ||||
[email protected] | f04b0e9 | 2013-11-22 14:20:55 | [diff] [blame] | 9 | #include "gin/public/isolate_holder.h" |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 10 | #include "testing/gtest/include/gtest/gtest.h" |
11 | |||||
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 12 | using v8::Isolate; |
13 | using v8::Object; | ||||
14 | using v8::Script; | ||||
15 | using v8::String; | ||||
16 | |||||
17 | namespace gin { | ||||
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 18 | |
19 | TEST(RunnerTest, Run) { | ||||
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 20 | std::string source = "this.result = 'PASS';\n"; |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 21 | |
[email protected] | f04b0e9 | 2013-11-22 14:20:55 | [diff] [blame] | 22 | gin::IsolateHolder instance; |
[email protected] | 1b93c23 | 2013-11-19 19:25:12 | [diff] [blame] | 23 | |
[email protected] | 97f21ca | 2013-11-17 17:46:07 | [diff] [blame] | 24 | RunnerDelegate delegate; |
[email protected] | 1b93c23 | 2013-11-19 19:25:12 | [diff] [blame] | 25 | Isolate* isolate = instance.isolate(); |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 26 | Runner runner(&delegate, isolate); |
27 | Runner::Scope scope(&runner); | ||||
[email protected] | 2f70342 | 2013-11-25 21:26:15 | [diff] [blame] | 28 | runner.Run(source, "test_data.js"); |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 29 | |
30 | std::string result; | ||||
[email protected] | 7618ebbb | 2013-11-27 03:38:26 | [diff] [blame] | 31 | EXPECT_TRUE(Converter<std::string>::FromV8(isolate, |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 32 | runner.global()->Get(StringToV8(isolate, "result")), |
33 | &result)); | ||||
34 | EXPECT_EQ("PASS", result); | ||||
35 | } | ||||
36 | |||||
37 | } // namespace gin |