diff options
Diffstat (limited to 'mojo/edk/js')
-rw-r--r-- | mojo/edk/js/BUILD.gn | 24 | ||||
-rw-r--r-- | mojo/edk/js/test/BUILD.gn | 32 | ||||
-rw-r--r-- | mojo/edk/js/tests/BUILD.gn | 21 | ||||
-rw-r--r-- | mojo/edk/js/tests/connection_tests.js | 29 | ||||
-rw-r--r-- | mojo/edk/js/tests/js_to_cpp_tests.js | 15 |
5 files changed, 72 insertions, 49 deletions
diff --git a/mojo/edk/js/BUILD.gn b/mojo/edk/js/BUILD.gn index 5a7e3d5..9a066d3 100644 --- a/mojo/edk/js/BUILD.gn +++ b/mojo/edk/js/BUILD.gn @@ -2,7 +2,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -source_set("js") { +import("../mojo_edk.gni") + +mojo_edk_source_set("js") { sources = [ "core.cc", "core.h", @@ -27,22 +29,28 @@ source_set("js") { "//v8", ] - deps = [ - "//mojo/public/cpp/environment", - "//mojo/public/cpp/system", + mojo_sdk_deps = [ + "mojo/public/cpp/environment", + "mojo/public/cpp/system", ] } -source_set("js_unittests") { +mojo_edk_source_set("js_unittests") { testonly = true sources = [ "handle_unittest.cc", ] deps = [ - "//mojo/edk/js", - "//mojo/edk/test:test_support", - "//mojo/public/cpp/system", "//testing/gtest", ] + + mojo_edk_deps = [ + "mojo/edk/js", + "mojo/edk/test:test_support", + ] + + mojo_sdk_deps = [ + "mojo/public/cpp/system", + ] } diff --git a/mojo/edk/js/test/BUILD.gn b/mojo/edk/js/test/BUILD.gn index be3a641..6e9792c 100644 --- a/mojo/edk/js/test/BUILD.gn +++ b/mojo/edk/js/test/BUILD.gn @@ -4,17 +4,17 @@ test("js_unittests") { deps = [ + "../../js", + "../../js:js_unittests", + "../../test:run_all_unittests", + "../../test:test_support", + "../../../environment:chromium", + "../../../public/cpp/environment", + "../../../public/cpp/system", + "../../../public/cpp/utility", + "../../../public/interfaces/bindings/tests:test_interfaces", "//base", "//gin:gin_test", - "//mojo/edk/js", - "//mojo/edk/js:js_unittests", - "//mojo/edk/test:run_all_unittests", - "//mojo/edk/test:test_support", - "//mojo/public/cpp/environment", - "//mojo/public/cpp/system", - "//mojo/public/cpp/utility", - "//mojo/environment:chromium", - "//mojo/public/interfaces/bindings/tests:test_interfaces", ] sources = [ @@ -24,15 +24,15 @@ test("js_unittests") { test("js_integration_tests") { deps = [ + "../../js", + "../../js/tests:js_to_cpp_tests", + "../../test:run_all_unittests", + "../../test:test_support", + "../../../environment:chromium", + "../../../public/cpp/bindings", + "../../../public/interfaces/bindings/tests:test_interfaces", "//base", "//gin:gin_test", - "//mojo/edk/js", - "//mojo/edk/js/tests:js_to_cpp_tests", - "//mojo/edk/test:run_all_unittests", - "//mojo/edk/test:test_support", - "//mojo/public/cpp/bindings", - "//mojo/environment:chromium", - "//mojo/public/interfaces/bindings/tests:test_interfaces", ] sources = [ diff --git a/mojo/edk/js/tests/BUILD.gn b/mojo/edk/js/tests/BUILD.gn index c7f568b..c9711c7 100644 --- a/mojo/edk/js/tests/BUILD.gn +++ b/mojo/edk/js/tests/BUILD.gn @@ -2,19 +2,26 @@ # 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_edk.gni") +import("../../../public/tools/bindings/mojom.gni") -source_set("js_to_cpp_tests") { +mojo_edk_source_set("js_to_cpp_tests") { testonly = true deps = [ ":js_to_cpp_bindings", "//gin:gin_test", - "//mojo/edk/js", - "//mojo/edk/test:test_support", - "//mojo/public/cpp/bindings", - "//mojo/public/cpp/system", - "//mojo/public/interfaces/bindings/tests:test_interfaces", + ] + + mojo_edk_deps = [ + "mojo/edk/js", + "mojo/edk/test:test_support", + ] + + mojo_sdk_deps = [ + "mojo/public/cpp/bindings", + "mojo/public/cpp/system", + "mojo/public/interfaces/bindings/tests:test_interfaces", ] sources = [ diff --git a/mojo/edk/js/tests/connection_tests.js b/mojo/edk/js/tests/connection_tests.js index 6649dfe..17009d9 100644 --- a/mojo/edk/js/tests/connection_tests.js +++ b/mojo/edk/js/tests/connection_tests.js @@ -81,14 +81,20 @@ define([ threading.quit(); }.bind(this)); + function createPeerConnection(handle, stubClass, proxyClass) { + var c = new connection.Connection(handle, stubClass, proxyClass); + c.local.peer = c.remote; + c.remote.peer = c.local; + return c; + } + function testClientServer() { var receivedFrobinate = false; var receivedDidFrobinate = false; // ServiceImpl ------------------------------------------------------------ - function ServiceImpl(peer) { - this.peer = peer; + function ServiceImpl() { } ServiceImpl.prototype = Object.create( @@ -106,8 +112,7 @@ define([ // ServiceClientImpl ------------------------------------------------------ - function ServiceClientImpl(peer) { - this.peer = peer; + function ServiceClientImpl() { } ServiceClientImpl.prototype = @@ -123,10 +128,10 @@ define([ var anotherPipe = core.createMessagePipe(); var sourcePipe = core.createMessagePipe(); - var connection0 = new connection.Connection( + var connection0 = createPeerConnection( pipe.handle0, ServiceImpl, sample_service.ServiceClient.proxyClass); - var connection1 = new connection.Connection( + var connection1 = createPeerConnection( pipe.handle1, ServiceClientImpl, sample_service.Service.proxyClass); var foo = new sample_service.Foo(); @@ -163,7 +168,7 @@ define([ function testWriteToClosedPipe() { var pipe = core.createMessagePipe(); - var connection1 = new connection.Connection( + var connection1 = createPeerConnection( pipe.handle1, function() {}, sample_service.Service.proxyClass); // Close the other end of the pipe. @@ -192,8 +197,7 @@ define([ // ProviderImpl ------------------------------------------------------------ - function ProviderImpl(peer) { - this.peer = peer; + function ProviderImpl() { } ProviderImpl.prototype = @@ -211,8 +215,7 @@ define([ // ProviderClientImpl ------------------------------------------------------ - function ProviderClientImpl(peer) { - this.peer = peer; + function ProviderClientImpl() { } ProviderClientImpl.prototype = @@ -220,12 +223,12 @@ define([ var pipe = core.createMessagePipe(); - var connection0 = new connection.Connection( + var connection0 = createPeerConnection( pipe.handle0, ProviderImpl, sample_interfaces.ProviderClient.proxyClass); - var connection1 = new connection.Connection( + var connection1 = createPeerConnection( pipe.handle1, ProviderClientImpl, sample_interfaces.Provider.proxyClass); diff --git a/mojo/edk/js/tests/js_to_cpp_tests.js b/mojo/edk/js/tests/js_to_cpp_tests.js index c32f0af..140ad4c 100644 --- a/mojo/edk/js/tests/js_to_cpp_tests.js +++ b/mojo/edk/js/tests/js_to_cpp_tests.js @@ -19,9 +19,7 @@ define('mojo/edk/js/tests/js_to_cpp_tests', [ capacityNumBytes: 64 }; - function JsSideConnection(cppSide) { - this.cppSide_ = cppSide; - cppSide.startTest(); + function JsSideConnection() { } JsSideConnection.prototype = @@ -205,6 +203,12 @@ define('mojo/edk/js/tests/js_to_cpp_tests', [ }, null); } + function createCppSideConnection(handle, stubClass, proxyClass) { + var c = new connection.Connection(handle, stubClass, proxyClass); + c.local.cppSide_ = c.remote; + return c; + } + return function(handle) { var i; sampleData = new Uint8Array(DATA_PIPE_PARAMS.capacityNumBytes); @@ -215,7 +219,8 @@ define('mojo/edk/js/tests/js_to_cpp_tests', [ for (i = 0; i < sampleMessage.length; ++i) { sampleMessage[i] = 255 - i; } - retainedConnection = new connection.Connection(handle, JsSideConnection, - jsToCpp.CppSide.proxyClass); + retainedConnection = createCppSideConnection( + handle, JsSideConnection,jsToCpp.CppSide.proxyClass); + retainedConnection.remote.startTest(); }; }); |