OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" |
| 7 #include "gin/modules/module_registry.h" |
| 8 #include "gin/test/file_runner.h" |
| 9 #include "gin/test/gtest.h" |
| 10 #include "mojo/public/bindings/js/runner_delegate.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 namespace mojo { |
| 14 namespace js { |
| 15 namespace { |
| 16 |
| 17 class TestRunnerDelegate : public RunnerDelegate { |
| 18 virtual void DidCreateContext(gin::Runner* runner) MOJO_OVERRIDE { |
| 19 RunnerDelegate::DidCreateContext(runner); |
| 20 |
| 21 v8::Handle<v8::Context> context = runner->context(); |
| 22 gin::ModuleRegistry* registry = |
| 23 gin::ModuleRegistry::From(context); |
| 24 |
| 25 registry->AddBuiltinModule(runner->isolate(), "gtest", |
| 26 gin::GetGTestTemplate(runner->isolate())); |
| 27 } |
| 28 }; |
| 29 |
| 30 void RunTest(std::string test) { |
| 31 base::FilePath path; |
| 32 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
| 33 path = path.AppendASCII("mojo") |
| 34 .AppendASCII("public") |
| 35 .AppendASCII("bindings") |
| 36 .AppendASCII("js") |
| 37 .AppendASCII(test); |
| 38 TestRunnerDelegate delegate; |
| 39 gin::RunTestFromFile(path, &delegate); |
| 40 } |
| 41 |
| 42 // TODO(abarth): Should we autogenerate these stubs from GYP? |
| 43 TEST(JSTest, core) { |
| 44 RunTest("core_unittests.js"); |
| 45 } |
| 46 |
| 47 } // namespace |
| 48 } // namespace js |
| 49 } // namespace mojo |
OLD | NEW |