Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: mojo/apps/js/test/run_js_tests.cc

Issue 129633005: Introduce a monotonic_clock module for Mojo.js. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blech Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/apps/js/mojo_runner_delegate.cc ('k') | mojo/mojo_apps.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "gin/modules/console.h"
7 #include "gin/modules/module_registry.h" 8 #include "gin/modules/module_registry.h"
9 #include "gin/modules/timer.h"
8 #include "gin/test/file_runner.h" 10 #include "gin/test/file_runner.h"
9 #include "gin/test/gtest.h" 11 #include "gin/test/gtest.h"
10 #include "mojo/apps/js/bindings/core.h" 12 #include "mojo/apps/js/bindings/core.h"
13 #include "mojo/apps/js/bindings/monotonic_clock.h"
14 #include "mojo/apps/js/bindings/threading.h"
11 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
12 16
13 namespace mojo { 17 namespace mojo {
14 namespace js { 18 namespace js {
15 namespace { 19 namespace {
16 20
17 class TestRunnerDelegate : public gin::FileRunnerDelegate { 21 class TestRunnerDelegate : public gin::FileRunnerDelegate {
18 public: 22 public:
19 TestRunnerDelegate() { 23 TestRunnerDelegate() {
24 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
20 AddBuiltinModule(Core::kModuleName, Core::GetModule); 25 AddBuiltinModule(Core::kModuleName, Core::GetModule);
26 AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
27 AddBuiltinModule(apps::MonotonicClock::kModuleName,
28 apps::MonotonicClock::GetModule);
29 AddBuiltinModule(apps::Threading::kModuleName, apps::Threading::GetModule);
21 } 30 }
22 31
23 private: 32 private:
24 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate); 33 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate);
25 }; 34 };
26 35
27 void RunTest(std::string test) { 36 void RunTest(std::string test, bool run_until_idle) {
28 base::FilePath path; 37 base::FilePath path;
29 PathService::Get(base::DIR_SOURCE_ROOT, &path); 38 PathService::Get(base::DIR_SOURCE_ROOT, &path);
30 path = path.AppendASCII("mojo") 39 path = path.AppendASCII("mojo")
31 .AppendASCII("apps") 40 .AppendASCII("apps")
32 .AppendASCII("js") 41 .AppendASCII("js")
33 .AppendASCII("bindings") 42 .AppendASCII("bindings")
34 .AppendASCII(test); 43 .AppendASCII(test);
35 TestRunnerDelegate delegate; 44 TestRunnerDelegate delegate;
36 gin::RunTestFromFile(path, &delegate); 45 gin::RunTestFromFile(path, &delegate, run_until_idle);
37 } 46 }
38 47
39 // TODO(abarth): Should we autogenerate these stubs from GYP? 48 // TODO(abarth): Should we autogenerate these stubs from GYP?
40 TEST(JSTest, core) { 49 TEST(JSTest, core) {
41 RunTest("core_unittests.js"); 50 RunTest("core_unittests.js", true);
42 } 51 }
43 52
44 TEST(JSTest, codec) { 53 TEST(JSTest, codec) {
45 RunTest("codec_unittests.js"); 54 RunTest("codec_unittests.js", true);
46 } 55 }
47 56
48 TEST(JSTest, sample_test) { 57 TEST(JSTest, sample_test) {
49 base::FilePath path; 58 base::FilePath path;
50 PathService::Get(base::DIR_SOURCE_ROOT, &path); 59 PathService::Get(base::DIR_SOURCE_ROOT, &path);
51 path = path.AppendASCII("mojo") 60 path = path.AppendASCII("mojo")
52 .AppendASCII("public") 61 .AppendASCII("public")
53 .AppendASCII("bindings") 62 .AppendASCII("bindings")
54 .AppendASCII("sample") 63 .AppendASCII("sample")
55 .AppendASCII("sample_service_unittests.js"); 64 .AppendASCII("sample_service_unittests.js");
56 TestRunnerDelegate delegate; 65 TestRunnerDelegate delegate;
57 gin::RunTestFromFile(path, &delegate); 66 gin::RunTestFromFile(path, &delegate);
58 } 67 }
59 68
60 TEST(JSTest, connector) { 69 TEST(JSTest, connector) {
61 RunTest("connector_unittests.js"); 70 RunTest("connector_unittests.js", true);
71 }
72
73 TEST(JSTest, monotonic_clock) {
74 RunTest("monotonic_clock_unittests.js", false);
62 } 75 }
63 76
64 } // namespace 77 } // namespace
65 } // namespace js 78 } // namespace js
66 } // namespace mojo 79 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/apps/js/mojo_runner_delegate.cc ('k') | mojo/mojo_apps.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698