Skip to content

Commit

Permalink
Cleanup mojo-js tests.
Browse files Browse the repository at this point in the history
1. Moves unittests to mojo/public/js where rest of the unittests
   are located. Once we make the switch to WebIDL-based core
   bindings, these tests will run as layout tests.
2. Deletes redundant mojo/edk/test directory
3. Cleanup test targets

BUG=647036

Review-Url: https://codereview.chromium.org/2645873003
Cr-Commit-Position: refs/heads/master@{#445149}
  • Loading branch information
alokp-chromium authored and Commit bot committed Jan 20, 2017
1 parent bfee22e commit 210e57b
Show file tree
Hide file tree
Showing 20 changed files with 83 additions and 194 deletions.
3 changes: 1 addition & 2 deletions mojo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ group("tests") {
deps = [
"//ipc:ipc_tests",
"//mojo/common:mojo_common_unittests",
"//mojo/edk/js/test:js_integration_tests",
"//mojo/edk/js/test:js_unittests",
"//mojo/edk/js/tests",
"//mojo/edk/system:mojo_message_pipe_perftests",
"//mojo/edk/system:mojo_system_unittests",
"//mojo/edk/test:mojo_public_bindings_perftests",
Expand Down
14 changes: 0 additions & 14 deletions mojo/edk/js/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# TODO(hansmuller): The organization of tests in this directory is weird:
# * Really, js_unittests tests public stuff, so that should live in public
# and be reworked as some sort of apptest.
# * Both js_unittests and js_integration_tests should auto-generate their
# tests somehow. The .cc files are just test runner stubs, including
# explicit lists of .js files.
group("tests") {
testonly = true
deps = [
"test:js_integration_tests",
"test:js_unittests",
]
}

component("js") {
sources = [
"core.cc",
Expand Down
46 changes: 0 additions & 46 deletions mojo/edk/js/test/BUILD.gn

This file was deleted.

34 changes: 0 additions & 34 deletions mojo/edk/js/test/hexdump.js

This file was deleted.

68 changes: 0 additions & 68 deletions mojo/edk/js/test/run_js_tests.cc

This file was deleted.

46 changes: 37 additions & 9 deletions mojo/edk/js/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,42 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("../../../../mojo/public/tools/bindings/mojom.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni")

source_set("js_to_cpp_tests") {
# TODO(hansmuller): The organization of tests in this directory is weird:
# * Really, js_unittests tests public stuff, so that should live in public
# and be reworked as some sort of apptest.
# * Both js_unittests and js_integration_tests should auto-generate their
# tests somehow. The .cc files are just test runner stubs, including
# explicit lists of .js files.

group("tests") {
testonly = true
deps = [
":mojo_js_integration_tests",
":mojo_js_unittests",
]
}

test("mojo_js_integration_tests") {
deps = [
":js_to_cpp_bindings",
"//gin:gin_test",
"//mojo/common",
"//mojo/edk/js",
"//mojo/edk/test:test_support",
"//mojo/edk/test:run_all_unittests",
"//mojo/public/cpp/bindings",
"//mojo/public/cpp/system",
"//mojo/public/interfaces/bindings/tests:test_interfaces",
"//mojo/public/interfaces/bindings/tests:test_interfaces_experimental",
"//mojo/public/js:bindings",
]

sources = [
"js_to_cpp_tests.cc",
]

data = [
"binding_tests.js",
"connection_tests.js",
"interface_ptr_tests.js",
"js_to_cpp_tests.js",
"sample_service_tests.js",
]

configs += [ "//v8:external_startup_data" ]
Expand All @@ -39,3 +48,22 @@ mojom("js_to_cpp_bindings") {
"js_to_cpp.mojom",
]
}

test("mojo_js_unittests") {
deps = [
"//base",
"//gin:gin_test",
"//mojo/edk/js",
"//mojo/edk/test:run_all_unittests",
"//mojo/edk/test:test_support",
"//mojo/public/cpp/system",
"//mojo/public/interfaces/bindings/tests:test_interfaces",
"//mojo/public/interfaces/bindings/tests:test_interfaces_experimental",
"//mojo/public/js:tests",
]

sources = [
"//mojo/edk/js/handle_unittest.cc",
"run_js_unittests.cc",
]
}
1 change: 0 additions & 1 deletion mojo/edk/js/tests/js_to_cpp_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "mojo/common/data_pipe_utils.h"
#include "mojo/edk/js/mojo_runner_delegate.h"
#include "mojo/edk/js/tests/js_to_cpp.mojom.h"
#include "mojo/edk/test/test_utils.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/system/core.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "base/path_service.h"
#include "gin/modules/console.h"
#include "gin/modules/module_registry.h"
#include "gin/modules/timer.h"
#include "gin/test/file_runner.h"
#include "gin/test/gtest.h"
#include "mojo/edk/js/core.h"
Expand All @@ -25,40 +24,61 @@ class TestRunnerDelegate : public gin::FileRunnerDelegate {
TestRunnerDelegate() {
AddBuiltinModule(gin::Console::kModuleName, gin::Console::GetModule);
AddBuiltinModule(Core::kModuleName, Core::GetModule);
AddBuiltinModule(gin::TimerModule::kName, gin::TimerModule::GetModule);
AddBuiltinModule(Threading::kModuleName, Threading::GetModule);
AddBuiltinModule(Support::kModuleName, Support::GetModule);
}

private:
DISALLOW_COPY_AND_ASSIGN(TestRunnerDelegate);
};

void RunTest(std::string test) {
void RunTest(std::string test, bool run_until_idle) {
base::FilePath path;
PathService::Get(base::DIR_SOURCE_ROOT, &path);
path = path.AppendASCII("mojo")
.AppendASCII("edk")
.AppendASCII("public")
.AppendASCII("js")
.AppendASCII("tests")
.AppendASCII(test);
TestRunnerDelegate delegate;
gin::RunTestFromFile(path, &delegate, false);
gin::RunTestFromFile(path, &delegate, run_until_idle);
}

// TODO(abarth): Should we autogenerate these stubs from GYP?
TEST(JSTest, Binding) {
RunTest("binding_unittest.js", false);
}

TEST(JSTest, Codec) {
RunTest("codec_unittest.js", true);
}

TEST(JSTest, Connection) {
RunTest("connection_tests.js");
RunTest("connection_unittest.js", false);
}

TEST(JSTest, SampleService) {
RunTest("sample_service_tests.js");
TEST(JSTest, Core) {
RunTest("core_unittest.js", true);
}

TEST(JSTest, InterfacePtr) {
RunTest("interface_ptr_tests.js");
RunTest("interface_ptr_unittest.js", false);
}

TEST(JSTest, Binding) {
RunTest("binding_tests.js");
TEST(JSTest, SampleService) {
RunTest("sample_service_unittest.js", false);
}

TEST(JSTest, Struct) {
RunTest("struct_unittest.js", true);
}

TEST(JSTest, Union) {
RunTest("union_unittest.js", true);
}

TEST(JSTest, Validation) {
RunTest("validation_unittest.js", true);
}

} // namespace
Expand Down
17 changes: 11 additions & 6 deletions mojo/public/js/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ group("tests") {
testonly = true

data = [
"codec_unittests.js",
"core_unittests.js",
"struct_unittests.js",
"test/validation_test_input_parser.js",
"union_unittests.js",
"validation_unittests.js",
"tests/binding_unittest.js",
"tests/codec_unittest.js",
"tests/connection_unittest.js",
"tests/core_unittest.js",
"tests/interface_ptr_unittest.js",
"tests/sample_service_unittest.js",
"tests/struct_unittest.js",
"tests/union_unittest.js",
"tests/validation_test_input_parser.js",
"tests/validation_unittest.js",
"//mojo/public/interfaces/bindings/tests/data/validation/",
]

public_deps = [
":bindings",
]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define([
"mojo/public/js/buffer",
"mojo/public/js/codec",
"mojo/public/js/core",
"mojo/public/js/test/validation_test_input_parser",
"mojo/public/js/tests/validation_test_input_parser",
"mojo/public/js/validator",
], function(console,
file,
Expand Down
4 changes: 2 additions & 2 deletions testing/buildbot/gn_isolate_map.pyl
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,11 @@
"type": "console_test_launcher",
},
"mojo_js_integration_tests": {
"label": "//mojo/edk/js/test:js_integration_tests",
"label": "//mojo/edk/js/tests:mojo_js_integration_tests",
"type": "console_test_launcher",
},
"mojo_js_unittests": {
"label": "//mojo/edk/js/test:js_unittests",
"label": "//mojo/edk/js/tests:mojo_js_unittests",
"type": "console_test_launcher",
},
"mojo_public_application_unittests": {
Expand Down

0 comments on commit 210e57b

Please sign in to comment.