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

Side by Side Diff: mojo/bindings/js/codec_unittests.js

Issue 247363003: Update mojom parser to allow array of arrays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix js unit tests 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/sample_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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([ 5 define([
6 "gin/test/expect", 6 "gin/test/expect",
7 "mojo/public/js/bindings/codec", 7 "mojo/public/js/bindings/codec",
8 "mojo/public/interfaces/bindings/tests/sample_service.mojom", 8 "mojo/public/interfaces/bindings/tests/sample_service.mojom",
9 ], function(expect, codec, sample) { 9 ], function(expect, codec, sample) {
10 testBar(); 10 testBar();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 for (var i = 0; i < foo.extra_bars.length; ++i) { 77 for (var i = 0; i < foo.extra_bars.length; ++i) {
78 foo.extra_bars[i].alpha = 1 * i; 78 foo.extra_bars[i].alpha = 1 * i;
79 foo.extra_bars[i].beta = 2 * i; 79 foo.extra_bars[i].beta = 2 * i;
80 foo.extra_bars[i].gamma = 3 * i; 80 foo.extra_bars[i].gamma = 3 * i;
81 } 81 }
82 foo.name = "I am a banana"; 82 foo.name = "I am a banana";
83 // This is supposed to be a handle, but we fake it with an integer. 83 // This is supposed to be a handle, but we fake it with an integer.
84 foo.source = 23423782; 84 foo.source = 23423782;
85 85
86 var messageName = 31; 86 var messageName = 31;
87 var payloadSize = 224; 87 var payloadSize = 240;
88 88
89 var builder = new codec.MessageBuilder(messageName, payloadSize); 89 var builder = new codec.MessageBuilder(messageName, payloadSize);
90 builder.encodeStruct(sample.Foo, foo); 90 builder.encodeStruct(sample.Foo, foo);
91 91
92 var message = builder.finish(); 92 var message = builder.finish();
93 93
94 var expectedMemory = new Uint8Array([ 94 var expectedMemory = new Uint8Array([
95 /* 0: */ 16, 0, 0, 0, 2, 0, 0, 0, 95 /* 0: */ 16, 0, 0, 0, 2, 0, 0, 0,
96 /* 8: */ 31, 0, 0, 0, 0, 0, 0, 0, 96 /* 8: */ 31, 0, 0, 0, 0, 0, 0, 0,
97 /* 16: */ 72, 0, 0, 0, 12, 0, 0, 0, 97 /* 16: */ 80, 0, 0, 0, 13, 0, 0, 0,
98 /* 24: */ 0xD5, 0xB4, 0x12, 0x02, 0x93, 0x6E, 0x01, 0, 98 /* 24: */ 0xD5, 0xB4, 0x12, 0x02, 0x93, 0x6E, 0x01, 0,
99 /* 32: */ 5, 0, 0, 0, 0, 0, 0, 0, 99 /* 32: */ 5, 0, 0, 0, 0, 0, 0, 0,
100 /* 40: */ 48, 0, 0, 0, 0, 0, 0, 0, 100 /* 40: */ 56, 0, 0, 0, 0, 0, 0, 0,
101 ]); 101 ]);
102 // TODO(abarth): Test more of the message's raw memory. 102 // TODO(abarth): Test more of the message's raw memory.
103 var actualMemory = new Uint8Array(message.memory.buffer, 103 var actualMemory = new Uint8Array(message.memory.buffer,
104 0, expectedMemory.length); 104 0, expectedMemory.length);
105 expect(actualMemory).toEqual(expectedMemory); 105 expect(actualMemory).toEqual(expectedMemory);
106 106
107 var expectedHandles = [ 107 var expectedHandles = [
108 23423782, 108 23423782,
109 ]; 109 ];
110 110
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 expect(actualMemory.length).toEqual(expectedMemory.length); 180 expect(actualMemory.length).toEqual(expectedMemory.length);
181 expect(actualMemory).toEqual(expectedMemory); 181 expect(actualMemory).toEqual(expectedMemory);
182 182
183 var reader = new codec.MessageReader(message); 183 var reader = new codec.MessageReader(message);
184 expect(reader.payloadSize).toBe(payloadSize); 184 expect(reader.payloadSize).toBe(payloadSize);
185 expect(reader.messageName).toBe(messageName); 185 expect(reader.messageName).toBe(messageName);
186 var str2 = reader.decoder.decodeStringPointer(); 186 var str2 = reader.decoder.decodeStringPointer();
187 expect(str2).toEqual(str); 187 expect(str2).toEqual(str);
188 } 188 }
189 }); 189 });
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/sample_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698