OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/files/file_path.h" | |
6 #include "base/path_service.h" | |
7 #include "gin/modules/console.h" | |
8 #include "gin/modules/module_registry.h" | |
9 #include "gin/test/file_runner.h" | |
10 #include "gin/test/gtest.h" | |
11 #include "mojo/edk/js/core.h" | |
12 #include "mojo/edk/js/support.h" | |
13 #include "mojo/public/cpp/environment/environment.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 | |
16 namespace mojo { | |
17 namespace js { | |
18 namespace { | |
19 | |
20 class TestRunnerDelegate : public gin::FileRunnerDelegate { | |
21 public: | |
22 TestRunnerDelegate() { | |
23 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); | |
24 AddBuiltinModule(Core::kModuleName, Core::GetModule); | |
25 AddBuiltinModule(Support::kModuleName, Support::GetModule); | |
26 } | |
27 | |
28 private: | |
29 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate); | |
30 }; | |
31 | |
32 void RunTest(std::string test, bool run_until_idle) { | |
33 base::FilePath path; | |
34 PathService::Get(base::DIR_SOURCE_ROOT, &path); | |
35 path = path.AppendASCII("mojo") | |
36 .AppendASCII("public") | |
37 .AppendASCII("js") | |
38 .AppendASCII(test); | |
39 TestRunnerDelegate delegate; | |
40 gin::RunTestFromFile(path, &delegate, run_until_idle); | |
41 } | |
42 | |
43 // TODO(abarth): Should we autogenerate these stubs from GYP? | |
44 TEST(JSTest, core) { | |
45 RunTest("core_unittests.js", true); | |
46 } | |
47 | |
48 TEST(JSTest, codec) { | |
49 RunTest("codec_unittests.js", true); | |
50 } | |
51 | |
52 TEST(JSTest, struct) { | |
53 RunTest("struct_unittests.js", true); | |
54 } | |
55 | |
56 TEST(JSTest, validation) { | |
57 RunTest("validation_unittests.js", true); | |
58 } | |
59 | |
60 } // namespace | |
61 } // namespace js | |
62 } // namespace mojo | |
OLD | NEW |