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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: mojo/apps/js/test/js_to_cpp_unittest.js
diff --git a/mojo/apps/js/test/js_to_cpp_unittest.js b/mojo/apps/js/test/js_to_cpp_unittest.js
index 45bb411a731127b747397ca655620733b1e079f4..fc0853d8a03deb5a7c87b39c98aa509c202daee8 100644
--- a/mojo/apps/js/test/js_to_cpp_unittest.js
+++ b/mojo/apps/js/test/js_to_cpp_unittest.js
@@ -3,21 +3,52 @@
// found in the LICENSE file.
define("mojo/apps/js/test/js_to_cpp_unittest", [
- 'mojo/public/js/bindings/connection',
- "mojo/public/interfaces/bindings/tests/sample_interfaces.mojom",
-], function(connector, provider) {
- var connection;
-
- function ProviderClientConnection(provider) {
- this.provider_ = provider;
- provider.echoString("message");
+ "mojo/public/js/bindings/connection",
+ "mojo/public/interfaces/bindings/tests/js_to_cpp.mojom",
+], function(connector, jsToCpp) {
+ var connection, kIterations = 100, kBadValue = 13;
+
+ function JsSideConnection(cppSide) {
+ this.cppSide_ = cppSide;
+ cppSide.startTest();
}
- ProviderClientConnection.prototype =
- Object.create(provider.ProviderClientStub.prototype);
+ JsSideConnection.prototype = Object.create(jsToCpp.JsSideStub.prototype);
+
+ JsSideConnection.prototype.ping = function (arg) {
+ this.cppSide_.pingResponse();
+
+ };
+
+ JsSideConnection.prototype.echo = function (arg) {
+ var i, arg2;
+
+ // Ensure negative values are negative.
+ if (arg.si64 > 0)
+ arg.si64 = kBadValue;
+
+ if (arg.si32 > 0)
+ arg.si32 = kBadValue;
+
+ if (arg.si16 > 0)
+ arg.si16 = kBadValue;
+
+ if (arg.si8 > 0)
+ arg.si8 = kBadValue;
+
+ for (i = 0; i < kIterations; ++i) {
+ arg2 = new jsToCpp.EchoArgs();
+ arg2.si64 = -1;
+ arg2.si32 = -1;
+ arg2.si16 = -1;
+ arg2.si8 = -1;
+ arg2.name = "going";
+ this.cppSide_.echoResponse(arg, arg2);
+ }
+ };
return function(handle) {
- connection = new connector.Connection(handle, ProviderClientConnection,
- provider.ProviderProxy);
+ connection = new connector.Connection(handle, JsSideConnection,
+ jsToCpp.CppSideProxy);
};
});

Powered by Google App Engine
This is Rietveld 408576698