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/test/file_runner.h" | 5 #include "gin/test/file_runner.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "gin/converter.h" | 10 #include "gin/converter.h" |
11 #include "gin/gin.h" | |
11 #include "gin/modules/module_registry.h" | 12 #include "gin/modules/module_registry.h" |
12 #include "gin/test/gtest.h" | 13 #include "gin/test/gtest.h" |
13 #include "gin/try_catch.h" | 14 #include "gin/try_catch.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace gin { | 17 namespace gin { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 base::FilePath GetModuleBase() { | 21 base::FilePath GetModuleBase() { |
(...skipping 18 matching lines...) Expand all Loading... | |
39 EXPECT_FALSE(try_catch.HasCaught()) << try_catch.GetPrettyMessage(); | 40 EXPECT_FALSE(try_catch.HasCaught()) << try_catch.GetPrettyMessage(); |
40 } | 41 } |
41 | 42 |
42 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate) { | 43 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate) { |
43 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); | 44 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); |
44 std::string source; | 45 std::string source; |
45 ASSERT_TRUE(ReadFileToString(path, &source)); | 46 ASSERT_TRUE(ReadFileToString(path, &source)); |
46 | 47 |
47 base::MessageLoop message_loop; | 48 base::MessageLoop message_loop; |
48 | 49 |
49 gin::Runner runner(delegate, v8::Isolate::GetCurrent()); | 50 scoped_ptr<gin::Gin> instance(new gin::Gin); |
abarth-chromium
2013/11/19 16:48:58
Why not on the stack?
| |
50 gin::Runner::Scope scope(&runner); | 51 gin::Runner runner(delegate, instance->isolate()); |
51 runner.Run(source); | 52 { |
53 gin::Runner::Scope scope(&runner); | |
54 runner.Run(source); | |
52 | 55 |
53 message_loop.RunUntilIdle(); | 56 message_loop.RunUntilIdle(); |
54 | 57 |
55 v8::Handle<v8::Value> result = runner.context()->Global()->Get( | 58 v8::Handle<v8::Value> result = runner.context()->Global()->Get( |
56 StringToSymbol(runner.isolate(), "result")); | 59 StringToSymbol(runner.isolate(), "result")); |
57 std::string result_string; | 60 std::string result_string; |
58 ASSERT_TRUE(ConvertFromV8(result, &result_string)); | 61 ASSERT_TRUE(ConvertFromV8(result, &result_string)); |
59 EXPECT_EQ("PASS", result_string); | 62 EXPECT_EQ("PASS", result_string); |
63 } | |
60 } | 64 } |
61 | 65 |
62 } // namespace gin | 66 } // namespace gin |
OLD | NEW |