| 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" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 FileRunnerDelegate::~FileRunnerDelegate() { | 38 FileRunnerDelegate::~FileRunnerDelegate() { |
| 39 } | 39 } |
| 40 | 40 |
| 41 void FileRunnerDelegate::UnhandledException(Runner* runner, | 41 void FileRunnerDelegate::UnhandledException(Runner* runner, |
| 42 TryCatch& try_catch) { | 42 TryCatch& try_catch) { |
| 43 ModuleRunnerDelegate::UnhandledException(runner, try_catch); | 43 ModuleRunnerDelegate::UnhandledException(runner, try_catch); |
| 44 FAIL() << try_catch.GetStackTrace(); | 44 FAIL() << try_catch.GetStackTrace(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate) { | 47 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, |
| 48 bool run_until_idle) { |
| 48 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); | 49 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); |
| 49 std::string source; | 50 std::string source; |
| 50 ASSERT_TRUE(ReadFileToString(path, &source)); | 51 ASSERT_TRUE(ReadFileToString(path, &source)); |
| 51 | 52 |
| 52 base::MessageLoop message_loop; | 53 base::MessageLoop message_loop; |
| 53 | 54 |
| 54 gin::IsolateHolder instance; | 55 gin::IsolateHolder instance; |
| 55 gin::Runner runner(delegate, instance.isolate()); | 56 gin::Runner runner(delegate, instance.isolate()); |
| 56 { | 57 { |
| 57 gin::Runner::Scope scope(&runner); | 58 gin::Runner::Scope scope(&runner); |
| 58 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); | 59 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
| 59 runner.Run(source, path.AsUTF8Unsafe()); | 60 runner.Run(source, path.AsUTF8Unsafe()); |
| 60 | 61 |
| 61 message_loop.RunUntilIdle(); | 62 if (run_until_idle) { |
| 63 message_loop.RunUntilIdle(); |
| 64 } else { |
| 65 message_loop.Run(); |
| 66 } |
| 62 | 67 |
| 63 v8::Handle<v8::Value> result = runner.context()->Global()->Get( | 68 v8::Handle<v8::Value> result = runner.context()->Global()->Get( |
| 64 StringToSymbol(runner.isolate(), "result")); | 69 StringToSymbol(runner.isolate(), "result")); |
| 65 EXPECT_EQ("PASS", V8ToString(result)); | 70 EXPECT_EQ("PASS", V8ToString(result)); |
| 66 } | 71 } |
| 67 } | 72 } |
| 68 | 73 |
| 69 } // namespace gin | 74 } // namespace gin |
| OLD | NEW |