| 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 "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/test/scoped_async_task_scheduler.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "gin/array_buffer.h" | 13 #include "gin/array_buffer.h" |
| 13 #include "gin/converter.h" | 14 #include "gin/converter.h" |
| 14 #include "gin/modules/console.h" | 15 #include "gin/modules/console.h" |
| 15 #include "gin/modules/module_registry.h" | 16 #include "gin/modules/module_registry.h" |
| 16 #include "gin/public/context_holder.h" | 17 #include "gin/public/context_holder.h" |
| 17 #include "gin/public/isolate_holder.h" | 18 #include "gin/public/isolate_holder.h" |
| 18 #include "gin/test/file.h" | 19 #include "gin/test/file.h" |
| 19 #include "gin/test/gc.h" | 20 #include "gin/test/gc.h" |
| 20 #include "gin/test/gtest.h" | 21 #include "gin/test/gtest.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 FAIL() << try_catch.GetStackTrace(); | 54 FAIL() << try_catch.GetStackTrace(); |
| 54 } | 55 } |
| 55 | 56 |
| 56 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, | 57 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, |
| 57 bool run_until_idle) { | 58 bool run_until_idle) { |
| 58 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); | 59 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); |
| 59 std::string source; | 60 std::string source; |
| 60 ASSERT_TRUE(ReadFileToString(path, &source)); | 61 ASSERT_TRUE(ReadFileToString(path, &source)); |
| 61 | 62 |
| 62 base::MessageLoop message_loop; | 63 base::MessageLoop message_loop; |
| 64 base::test::ScopedAsyncTaskScheduler scoped_async_task_scheduler; |
| 63 | 65 |
| 64 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 66 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 65 gin::V8Initializer::LoadV8Snapshot(); | 67 gin::V8Initializer::LoadV8Snapshot(); |
| 66 gin::V8Initializer::LoadV8Natives(); | 68 gin::V8Initializer::LoadV8Natives(); |
| 67 #endif | 69 #endif |
| 68 | 70 |
| 69 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, | 71 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, |
| 70 gin::IsolateHolder::kStableV8Extras, | 72 gin::IsolateHolder::kStableV8Extras, |
| 71 gin::ArrayBufferAllocator::SharedInstance()); | 73 gin::ArrayBufferAllocator::SharedInstance()); |
| 72 | 74 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 83 base::RunLoop().Run(); | 85 base::RunLoop().Run(); |
| 84 } | 86 } |
| 85 | 87 |
| 86 v8::Local<v8::Value> result = runner.global()->Get( | 88 v8::Local<v8::Value> result = runner.global()->Get( |
| 87 StringToSymbol(runner.GetContextHolder()->isolate(), "result")); | 89 StringToSymbol(runner.GetContextHolder()->isolate(), "result")); |
| 88 EXPECT_EQ("PASS", V8ToString(result)); | 90 EXPECT_EQ("PASS", V8ToString(result)); |
| 89 } | 91 } |
| 90 } | 92 } |
| 91 | 93 |
| 92 } // namespace gin | 94 } // namespace gin |
| OLD | NEW |