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.
5 #include "base/file_util.h"
6 #include "base/files/file_path.h"
7 #include "base/path_service.h"
8 #include "gin/modules/console.h"
9 #include "gin/modules/module_registry.h"
10 #include "gin/modules/timer.h"
11 #include "gin/test/file_runner.h"
12 #include "gin/test/gtest.h"
13 #include "mojo/bindings/js/core.h"
14 #include "mojo/bindings/js/unicode.h"
15 #include "mojo/common/test/test_utils.h"
16 #include "testing/gtest/include/gtest/gtest.h"
22 class TestRunnerDelegate : public gin::FileRunnerDelegate {
24 TestRunnerDelegate() {
25 AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
26 AddBuiltinModule(Core::kModuleName, Core::GetModule);
27 AddBuiltinModule(Unicode::kModuleName, Unicode::GetModule);
31 DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate);
34 void RunTest(std::string test, bool run_until_idle) {
36 PathService::Get(base::DIR_SOURCE_ROOT, &path);
37 path = path.AppendASCII("mojo")
38 .AppendASCII("bindings")
41 TestRunnerDelegate delegate;
42 gin::RunTestFromFile(path, &delegate, run_until_idle);
45 // TODO(abarth): Should we autogenerate these stubs from GYP?
47 RunTest("core_unittests.js", true);
51 // TODO(yzshen): Remove this check once isolated tests are supported on the
52 // Chromium waterfall. (http://crbug.com/351214)
53 const base::FilePath test_file_path(
54 test::GetFilePathForJSResource(
55 "mojo/public/interfaces/bindings/tests/sample_service.mojom"));
56 if (!base::PathExists(test_file_path)) {
57 LOG(WARNING) << "Mojom binding files don't exist. Skipping the test.";
61 RunTest("codec_unittests.js", true);