| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "gin/modules/console.h" | 7 #include "gin/modules/console.h" |
| 8 #include "gin/modules/module_registry.h" | 8 #include "gin/modules/module_registry.h" |
| 9 #include "gin/modules/timer.h" | |
| 10 #include "gin/test/file_runner.h" | 9 #include "gin/test/file_runner.h" |
| 11 #include "gin/test/gtest.h" | 10 #include "gin/test/gtest.h" |
| 12 #include "mojo/edk/js/core.h" | 11 #include "mojo/edk/js/core.h" |
| 13 #include "mojo/edk/js/support.h" | 12 #include "mojo/edk/js/support.h" |
| 14 #include "mojo/public/cpp/environment/environment.h" | 13 #include "mojo/public/cpp/environment/environment.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 namespace mojo { | 16 namespace mojo { |
| 18 namespace js { | 17 namespace js { |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 class TestRunnerDelegate : public gin::FileRunnerDelegate { | 20 class TestRunnerDelegate : public gin::FileRunnerDelegate { |
| 22 public: | 21 public: |
| 23 TestRunnerDelegate() { | 22 TestRunnerDelegate() { |
| 24 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); | 23 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); |
| 25 AddBuiltinModule(Core::kModuleName, Core::GetModule); | 24 AddBuiltinModule(Core::kModuleName, Core::GetModule); |
| 26 AddBuiltinModule(Support::kModuleName, Support::GetModule); | 25 AddBuiltinModule(Support::kModuleName, Support::GetModule); |
| 27 } | 26 } |
| 28 | 27 |
| 29 private: | 28 private: |
| 30 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate); | 29 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate); |
| 31 }; | 30 }; |
| 32 | 31 |
| 33 void RunTest(std::string test, bool run_until_idle) { | 32 void RunTest(std::string test, bool run_until_idle) { |
| 34 Environment env; | |
| 35 base::FilePath path; | 33 base::FilePath path; |
| 36 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 34 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
| 37 path = path.AppendASCII("mojo") | 35 path = path.AppendASCII("mojo") |
| 38 .AppendASCII("public") | 36 .AppendASCII("public") |
| 39 .AppendASCII("js") | 37 .AppendASCII("js") |
| 40 .AppendASCII(test); | 38 .AppendASCII(test); |
| 41 TestRunnerDelegate delegate; | 39 TestRunnerDelegate delegate; |
| 42 gin::RunTestFromFile(path, &delegate, run_until_idle); | 40 gin::RunTestFromFile(path, &delegate, run_until_idle); |
| 43 } | 41 } |
| 44 | 42 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 55 RunTest("struct_unittests.js", true); | 53 RunTest("struct_unittests.js", true); |
| 56 } | 54 } |
| 57 | 55 |
| 58 TEST(JSTest, validation) { | 56 TEST(JSTest, validation) { |
| 59 RunTest("validation_unittests.js", true); | 57 RunTest("validation_unittests.js", true); |
| 60 } | 58 } |
| 61 | 59 |
| 62 } // namespace | 60 } // namespace |
| 63 } // namespace js | 61 } // namespace js |
| 64 } // namespace mojo | 62 } // namespace mojo |
| OLD | NEW |