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

Unified Diff: mojo/public/js/bindings/codec_unittests.js

Issue 486203003: Mojo JS bindings generator doesn't generate import-qualified struct references (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resync Created 6 years, 4 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/public/js/bindings/codec_unittests.js
diff --git a/mojo/public/js/bindings/codec_unittests.js b/mojo/public/js/bindings/codec_unittests.js
index 14cd96a21f05a43f01191afceff1f2c0862760fd..80f1402eef2ac0c7df9f346f1f80ba17fe7fddbe 100644
--- a/mojo/public/js/bindings/codec_unittests.js
+++ b/mojo/public/js/bindings/codec_unittests.js
@@ -5,10 +5,13 @@
define([
"gin/test/expect",
"mojo/public/js/bindings/codec",
+ "mojo/public/interfaces/bindings/tests/rect.mojom",
"mojo/public/interfaces/bindings/tests/sample_service.mojom",
- ], function(expect, codec, sample) {
+ "mojo/public/interfaces/bindings/tests/test_structs.mojom",
+ ], function(expect, codec, rect, sample, structs) {
testBar();
testFoo();
+ testNamedRegion();
testTypes();
testAlign();
testUtf8();
@@ -143,6 +146,32 @@ define([
expect(foo2.array_of_bools).toEqual(foo.array_of_bools);
}
+ function createRect(x, y, width, height) {
+ var r = new rect.Rect();
+ r.x = x;
+ r.y = y;
+ r.width = width;
+ r.height = height;
+ return r;
+ }
+
+ // Verify that the references to the imported Rect type in test_structs.mojom
+ // are generated correctly.
+ function testNamedRegion() {
+ var r = new structs.NamedRegion();
+ r.name = "rectangle";
+ r.rects = new Array(createRect(1, 2, 3, 4), createRect(10, 20, 30, 40));
+
+ var builder = new codec.MessageBuilder(1, structs.NamedRegion.encodedSize);
+ builder.encodeStruct(structs.NamedRegion, r);
+ var reader = new codec.MessageReader(builder.finish());
+ var result = reader.decodeStruct(structs.NamedRegion);
+
+ expect(result.name).toEqual("rectangle");
+ expect(result.rects[0]).toEqual(createRect(1, 2, 3, 4));
+ expect(result.rects[1]).toEqual(createRect(10, 20, 30, 40));
+ }
+
function testTypes() {
function encodeDecode(cls, input, expectedResult, encodedSize) {
var messageName = 42;
« no previous file with comments | « mojo/public/interfaces/bindings/tests/test_structs.mojom ('k') | mojo/public/tools/bindings/generators/mojom_js_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698