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

Side by Side Diff: mojo/public/bindings/js/test/run_js_tests.cc

Issue 69843003: Implement Mojo message codec in JavaScript (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Aaron's comments Created 7 years, 1 month 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
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/module_registry.h" 7 #include "gin/modules/module_registry.h"
8 #include "gin/test/file_runner.h" 8 #include "gin/test/file_runner.h"
9 #include "gin/test/gtest.h" 9 #include "gin/test/gtest.h"
10 #include "mojo/public/bindings/js/runner_delegate.h" 10 #include "mojo/public/bindings/js/core.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 namespace js { 14 namespace js {
15 namespace { 15 namespace {
16 16
17 class TestRunnerDelegate : public RunnerDelegate { 17 class TestRunnerDelegate : public gin::FileRunnerDelegate {
18 virtual void DidCreateContext(gin::Runner* runner) MOJO_OVERRIDE { 18 public:
19 RunnerDelegate::DidCreateContext(runner); 19 TestRunnerDelegate() {
20 AddBuiltinModule(Core::kModuleName, Core::GetTemplate);
21 }
20 22
21 v8::Handle<v8::Context> context = runner->context(); 23 private:
22 gin::ModuleRegistry* registry = 24 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate);
23 gin::ModuleRegistry::From(context);
24
25 registry->AddBuiltinModule(runner->isolate(), "gtest",
26 gin::GetGTestTemplate(runner->isolate()));
27 }
28 }; 25 };
29 26
30 void RunTest(std::string test) { 27 void RunTest(std::string test) {
31 base::FilePath path; 28 base::FilePath path;
32 PathService::Get(base::DIR_SOURCE_ROOT, &path); 29 PathService::Get(base::DIR_SOURCE_ROOT, &path);
33 path = path.AppendASCII("mojo") 30 path = path.AppendASCII("mojo")
34 .AppendASCII("public") 31 .AppendASCII("public")
35 .AppendASCII("bindings") 32 .AppendASCII("bindings")
36 .AppendASCII("js") 33 .AppendASCII("js")
37 .AppendASCII(test); 34 .AppendASCII(test);
38 TestRunnerDelegate delegate; 35 TestRunnerDelegate delegate;
39 gin::RunTestFromFile(path, &delegate); 36 gin::RunTestFromFile(path, &delegate);
40 } 37 }
41 38
42 // TODO(abarth): Should we autogenerate these stubs from GYP? 39 // TODO(abarth): Should we autogenerate these stubs from GYP?
43 TEST(JSTest, core) { 40 TEST(JSTest, core) {
44 RunTest("core_unittests.js"); 41 RunTest("core_unittests.js");
45 } 42 }
46 43
44 TEST(JSTest, codec) {
45 RunTest("codec_unittests.js");
46 }
47
47 } // namespace 48 } // namespace
48 } // namespace js 49 } // namespace js
49 } // namespace mojo 50 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/bindings/js/runner_delegate.cc ('k') | mojo/public/bindings/js/test/sample_service.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698