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/files/file_util.h" | 7 #include "base/files/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/array_buffer.h" | 10 #include "gin/array_buffer.h" |
11 #include "gin/converter.h" | 11 #include "gin/converter.h" |
12 #include "gin/modules/console.h" | 12 #include "gin/modules/console.h" |
13 #include "gin/modules/module_registry.h" | 13 #include "gin/modules/module_registry.h" |
14 #include "gin/public/context_holder.h" | 14 #include "gin/public/context_holder.h" |
15 #include "gin/public/isolate_holder.h" | 15 #include "gin/public/isolate_holder.h" |
16 #include "gin/test/file.h" | 16 #include "gin/test/file.h" |
17 #include "gin/test/gc.h" | 17 #include "gin/test/gc.h" |
18 #include "gin/test/gtest.h" | 18 #include "gin/test/gtest.h" |
19 #include "gin/try_catch.h" | 19 #include "gin/try_catch.h" |
| 20 #include "gin/v8_initializer.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | |
23 #include "gin/public/isolate_holder.h" | |
24 #endif | |
25 | |
26 namespace gin { | 23 namespace gin { |
27 | 24 |
28 namespace { | 25 namespace { |
29 | 26 |
30 std::vector<base::FilePath> GetModuleSearchPaths() { | 27 std::vector<base::FilePath> GetModuleSearchPaths() { |
31 std::vector<base::FilePath> search_paths(2); | 28 std::vector<base::FilePath> search_paths(2); |
32 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]); | 29 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]); |
33 PathService::Get(base::DIR_EXE, &search_paths[1]); | 30 PathService::Get(base::DIR_EXE, &search_paths[1]); |
34 search_paths[1] = search_paths[1].AppendASCII("gen"); | 31 search_paths[1] = search_paths[1].AppendASCII("gen"); |
35 return search_paths; | 32 return search_paths; |
(...skipping 20 matching lines...) Expand all Loading... |
56 | 53 |
57 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, | 54 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, |
58 bool run_until_idle) { | 55 bool run_until_idle) { |
59 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); | 56 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); |
60 std::string source; | 57 std::string source; |
61 ASSERT_TRUE(ReadFileToString(path, &source)); | 58 ASSERT_TRUE(ReadFileToString(path, &source)); |
62 | 59 |
63 base::MessageLoop message_loop; | 60 base::MessageLoop message_loop; |
64 | 61 |
65 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 62 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
66 gin::IsolateHolder::LoadV8Snapshot(); | 63 gin::V8Initializer::LoadV8Snapshot(); |
67 #endif | 64 #endif |
68 | 65 |
69 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | 66 gin::V8Initializer::Initialize(gin::V8Initializer::kStrictMode, |
70 gin::ArrayBufferAllocator::SharedInstance()); | 67 gin::ArrayBufferAllocator::SharedInstance()); |
| 68 |
71 gin::IsolateHolder instance; | 69 gin::IsolateHolder instance; |
72 gin::ShellRunner runner(delegate, instance.isolate()); | 70 gin::ShellRunner runner(delegate, instance.isolate()); |
73 { | 71 { |
74 gin::Runner::Scope scope(&runner); | 72 gin::Runner::Scope scope(&runner); |
75 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); | 73 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
76 runner.Run(source, path.AsUTF8Unsafe()); | 74 runner.Run(source, path.AsUTF8Unsafe()); |
77 | 75 |
78 if (run_until_idle) { | 76 if (run_until_idle) { |
79 message_loop.RunUntilIdle(); | 77 message_loop.RunUntilIdle(); |
80 } else { | 78 } else { |
81 message_loop.Run(); | 79 message_loop.Run(); |
82 } | 80 } |
83 | 81 |
84 v8::Handle<v8::Value> result = runner.global()->Get( | 82 v8::Handle<v8::Value> result = runner.global()->Get( |
85 StringToSymbol(runner.GetContextHolder()->isolate(), "result")); | 83 StringToSymbol(runner.GetContextHolder()->isolate(), "result")); |
86 EXPECT_EQ("PASS", V8ToString(result)); | 84 EXPECT_EQ("PASS", V8ToString(result)); |
87 } | 85 } |
88 } | 86 } |
89 | 87 |
90 } // namespace gin | 88 } // namespace gin |
OLD | NEW |