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 "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" | 9 #include "gin/modules/timer.h" |
10 #include "gin/test/file_runner.h" | 10 #include "gin/test/file_runner.h" |
11 #include "gin/test/gtest.h" | 11 #include "gin/test/gtest.h" |
12 #include "mojo/apps/js/bindings/monotonic_clock.h" | |
13 #include "mojo/edk/js/core.h" | 12 #include "mojo/edk/js/core.h" |
| 13 #include "mojo/edk/js/threading.h" |
| 14 #include "services/js/modules/clock/monotonic_clock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 namespace js { | 18 namespace js { |
18 namespace { | 19 namespace { |
19 | 20 |
20 class TestRunnerDelegate : public gin::FileRunnerDelegate { | 21 class TestRunnerDelegate : public gin::FileRunnerDelegate { |
21 public: | 22 public: |
22 TestRunnerDelegate() { | 23 TestRunnerDelegate() { |
23 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); | 24 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule); |
24 AddBuiltinModule(Core::kModuleName, Core::GetModule); | 25 AddBuiltinModule(Core::kModuleName, Core::GetModule); |
25 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); | 26 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule); |
26 AddBuiltinModule(apps::MonotonicClock::kModuleName, | 27 AddBuiltinModule(MonotonicClock::kModuleName, MonotonicClock::GetModule); |
27 apps::MonotonicClock::GetModule); | 28 AddBuiltinModule(Threading::kModuleName, Threading::GetModule); |
28 } | 29 } |
29 | 30 |
30 private: | 31 private: |
31 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate); | 32 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate); |
32 }; | 33 }; |
33 | 34 |
34 void RunTest(std::string test, bool run_until_idle) { | 35 void RunTest(std::string test, bool run_until_idle) { |
35 base::FilePath path; | 36 base::FilePath path; |
36 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 37 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
37 path = path.AppendASCII("mojo") | 38 path = path.AppendASCII("services") |
38 .AppendASCII("apps") | |
39 .AppendASCII("js") | 39 .AppendASCII("js") |
40 .AppendASCII("bindings") | 40 .AppendASCII("modules") |
| 41 .AppendASCII("clock") |
41 .AppendASCII(test); | 42 .AppendASCII(test); |
42 TestRunnerDelegate delegate; | 43 TestRunnerDelegate delegate; |
43 gin::RunTestFromFile(path, &delegate, run_until_idle); | 44 gin::RunTestFromFile(path, &delegate, run_until_idle); |
44 } | 45 } |
45 | 46 |
46 // TODO(abarth): Should we autogenerate these stubs from GYP? | 47 // TODO(abarth): Should we autogenerate these stubs from GYP? |
47 | 48 |
48 TEST(JSTest, monotonic_clock) { | 49 TEST(JSTest, monotonic_clock) { |
49 RunTest("monotonic_clock_unittests.js", false); | 50 RunTest("monotonic_clock_unittests.js", false); |
50 } | 51 } |
51 | 52 |
52 } // namespace | 53 } // namespace |
53 } // namespace js | 54 } // namespace js |
54 } // namespace mojo | 55 } // namespace mojo |
OLD | NEW |