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/converter.h" | 11 #include "gin/converter.h" |
11 #include "gin/modules/console.h" | 12 #include "gin/modules/console.h" |
12 #include "gin/modules/module_registry.h" | 13 #include "gin/modules/module_registry.h" |
13 #include "gin/public/context_holder.h" | 14 #include "gin/public/context_holder.h" |
14 #include "gin/public/isolate_holder.h" | 15 #include "gin/public/isolate_holder.h" |
15 #include "gin/test/file.h" | 16 #include "gin/test/file.h" |
16 #include "gin/test/gc.h" | 17 #include "gin/test/gc.h" |
17 #include "gin/test/gtest.h" | 18 #include "gin/test/gtest.h" |
18 #include "gin/try_catch.h" | 19 #include "gin/try_catch.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 30 matching lines...) Expand all Loading... |
50 } | 51 } |
51 | 52 |
52 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, | 53 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, |
53 bool run_until_idle) { | 54 bool run_until_idle) { |
54 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); | 55 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); |
55 std::string source; | 56 std::string source; |
56 ASSERT_TRUE(ReadFileToString(path, &source)); | 57 ASSERT_TRUE(ReadFileToString(path, &source)); |
57 | 58 |
58 base::MessageLoop message_loop; | 59 base::MessageLoop message_loop; |
59 | 60 |
60 gin::IsolateHolder instance(gin::IsolateHolder::kStrictMode); | 61 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, |
| 62 gin::ArrayBufferAllocator::SharedInstance()); |
| 63 gin::IsolateHolder instance; |
61 gin::ShellRunner runner(delegate, instance.isolate()); | 64 gin::ShellRunner runner(delegate, instance.isolate()); |
62 { | 65 { |
63 gin::Runner::Scope scope(&runner); | 66 gin::Runner::Scope scope(&runner); |
64 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); | 67 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
65 runner.Run(source, path.AsUTF8Unsafe()); | 68 runner.Run(source, path.AsUTF8Unsafe()); |
66 | 69 |
67 if (run_until_idle) { | 70 if (run_until_idle) { |
68 message_loop.RunUntilIdle(); | 71 message_loop.RunUntilIdle(); |
69 } else { | 72 } else { |
70 message_loop.Run(); | 73 message_loop.Run(); |
71 } | 74 } |
72 | 75 |
73 v8::Handle<v8::Value> result = runner.global()->Get( | 76 v8::Handle<v8::Value> result = runner.global()->Get( |
74 StringToSymbol(runner.GetContextHolder()->isolate(), "result")); | 77 StringToSymbol(runner.GetContextHolder()->isolate(), "result")); |
75 EXPECT_EQ("PASS", V8ToString(result)); | 78 EXPECT_EQ("PASS", V8ToString(result)); |
76 } | 79 } |
77 } | 80 } |
78 | 81 |
79 } // namespace gin | 82 } // namespace gin |
OLD | NEW |