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

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

Issue 295583005: Update mojom example files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix js tests 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
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/math_calculator.mojom » ('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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 for (var i = 0; i < foo.extra_bars.length; ++i) { 79 for (var i = 0; i < foo.extra_bars.length; ++i) {
80 foo.extra_bars[i].alpha = 1 * i; 80 foo.extra_bars[i].alpha = 1 * i;
81 foo.extra_bars[i].beta = 2 * i; 81 foo.extra_bars[i].beta = 2 * i;
82 foo.extra_bars[i].gamma = 3 * i; 82 foo.extra_bars[i].gamma = 3 * i;
83 } 83 }
84 foo.name = "I am a banana"; 84 foo.name = "I am a banana";
85 // This is supposed to be a handle, but we fake it with an integer. 85 // This is supposed to be a handle, but we fake it with an integer.
86 foo.source = 23423782; 86 foo.source = 23423782;
87 87
88 var messageName = 31; 88 var messageName = 31;
89 var payloadSize = 240; 89 var payloadSize = 304;
90 90
91 var builder = new codec.MessageBuilder(messageName, payloadSize); 91 var builder = new codec.MessageBuilder(messageName, payloadSize);
92 builder.encodeStruct(sample.Foo, foo); 92 builder.encodeStruct(sample.Foo, foo);
93 93
94 var message = builder.finish(); 94 var message = builder.finish();
95 95
96 var expectedMemory = new Uint8Array([ 96 var expectedMemory = new Uint8Array([
97 /* 0: */ 16, 0, 0, 0, 2, 0, 0, 0, 97 /* 0: */ 16, 0, 0, 0, 2, 0, 0, 0,
98 /* 8: */ 31, 0, 0, 0, 0, 0, 0, 0, 98 /* 8: */ 31, 0, 0, 0, 0, 0, 0, 0,
99 /* 16: */ 80, 0, 0, 0, 13, 0, 0, 0, 99 /* 16: */ 88, 0, 0, 0, 14, 0, 0, 0,
100 /* 24: */ 0xD5, 0xB4, 0x12, 0x02, 0x93, 0x6E, 0x01, 0, 100 /* 24: */ 0xD5, 0xB4, 0x12, 0x02, 0x93, 0x6E, 0x01, 0,
101 /* 32: */ 5, 0, 0, 0, 0, 0, 0, 0, 101 /* 32: */ 5, 0, 0, 0, 0, 0, 0, 0,
102 /* 40: */ 56, 0, 0, 0, 0, 0, 0, 0, 102 /* 40: */ 64, 0, 0, 0, 0, 0, 0, 0,
103 ]); 103 ]);
104 // TODO(abarth): Test more of the message's raw memory. 104 // TODO(abarth): Test more of the message's raw memory.
105 var actualMemory = new Uint8Array(message.buffer.arrayBuffer, 105 var actualMemory = new Uint8Array(message.buffer.arrayBuffer,
106 0, expectedMemory.length); 106 0, expectedMemory.length);
107 expect(actualMemory).toEqual(expectedMemory); 107 expect(actualMemory).toEqual(expectedMemory);
108 108
109 var expectedHandles = [ 109 var expectedHandles = [
110 23423782, 110 23423782,
111 ]; 111 ];
112 112
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 expect(actualMemory.length).toEqual(expectedMemory.length); 210 expect(actualMemory.length).toEqual(expectedMemory.length);
211 expect(actualMemory).toEqual(expectedMemory); 211 expect(actualMemory).toEqual(expectedMemory);
212 212
213 var reader = new codec.MessageReader(message); 213 var reader = new codec.MessageReader(message);
214 expect(reader.payloadSize).toBe(payloadSize); 214 expect(reader.payloadSize).toBe(payloadSize);
215 expect(reader.messageName).toBe(messageName); 215 expect(reader.messageName).toBe(messageName);
216 var str2 = reader.decoder.decodeStringPointer(); 216 var str2 = reader.decoder.decodeStringPointer();
217 expect(str2).toEqual(str); 217 expect(str2).toEqual(str);
218 } 218 }
219 }); 219 });
OLDNEW
« no previous file with comments | « no previous file | mojo/public/interfaces/bindings/tests/math_calculator.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698