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

Side by Side Diff: mojo/apps/js/test/js_to_cpp_unittest.js

Issue 268593002: Move existing Mojo JS <--> CPP tests out of webui test harness. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused header include. Created 6 years, 7 months 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 2014 The Chromium Authors. All rights reserved. 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 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 define("mojo/apps/js/test/js_to_cpp_unittest", [ 5 define("mojo/apps/js/test/js_to_cpp_unittest", [
6 'mojo/public/js/bindings/connection', 6 "mojo/public/js/bindings/connection",
7 "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom", 7 "mojo/public/interfaces/bindings/tests/js_to_cpp.mojom",
8 ], function(connector, provider) { 8 ], function(connector, jsToCpp) {
9 var connection; 9 var connection, kIterations = 100, kBadValue = 13;
10 10
11 function ProviderClientConnection(provider) { 11 function JsSideConnection(cppSide) {
12 this.provider_ = provider; 12 this.cppSide_ = cppSide;
13 provider.echoString("message"); 13 cppSide.startTest();
14 } 14 }
15 15
16 ProviderClientConnection.prototype = 16 JsSideConnection.prototype = Object.create(jsToCpp.JsSideStub.prototype);
17 Object.create(provider.ProviderClientStub.prototype); 17
18 JsSideConnection.prototype.ping = function (arg) {
19 this.cppSide_.pingResponse();
20
21 };
22
23 JsSideConnection.prototype.echo = function (arg) {
24 var i, arg2;
25
26 // Ensure negative values are negative.
27 if (arg.si64 > 0)
28 arg.si64 = kBadValue;
29
30 if (arg.si32 > 0)
31 arg.si32 = kBadValue;
32
33 if (arg.si16 > 0)
34 arg.si16 = kBadValue;
35
36 if (arg.si8 > 0)
37 arg.si8 = kBadValue;
38
39 for (i = 0; i < kIterations; ++i) {
40 arg2 = new jsToCpp.EchoArgs();
41 arg2.si64 = -1;
42 arg2.si32 = -1;
43 arg2.si16 = -1;
44 arg2.si8 = -1;
45 arg2.name = "going";
46 this.cppSide_.echoResponse(arg, arg2);
47 }
48 };
18 49
19 return function(handle) { 50 return function(handle) {
20 connection = new connector.Connection(handle, ProviderClientConnection, 51 connection = new connector.Connection(handle, JsSideConnection,
21 provider.ProviderProxy); 52 jsToCpp.CppSideProxy);
22 }; 53 };
23 }); 54 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698