OLD | NEW |
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([ | 5 define([ |
6 "gin/test/expect", | 6 "gin/test/expect", |
7 "mojo/public/interfaces/bindings/tests/rect.mojom", | 7 "mojo/public/interfaces/bindings/tests/rect.mojom", |
8 "mojo/public/interfaces/bindings/tests/test_structs.mojom", | 8 "mojo/public/interfaces/bindings/tests/test_structs.mojom", |
9 "mojo/public/js/codec", | 9 "mojo/public/js/codec", |
10 "mojo/public/js/validator", | 10 "mojo/public/js/validator", |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 expect(decodedStruct.f2).toEqual(testStructs.FloatNumberValues.V2); | 181 expect(decodedStruct.f2).toEqual(testStructs.FloatNumberValues.V2); |
182 expect(decodedStruct.f3).toEqual(testStructs.FloatNumberValues.V3); | 182 expect(decodedStruct.f3).toEqual(testStructs.FloatNumberValues.V3); |
183 expect(decodedStruct.f4).toEqual(testStructs.FloatNumberValues.V4); | 183 expect(decodedStruct.f4).toEqual(testStructs.FloatNumberValues.V4); |
184 expect(decodedStruct.f5).toEqual(testStructs.FloatNumberValues.V5); | 184 expect(decodedStruct.f5).toEqual(testStructs.FloatNumberValues.V5); |
185 expect(decodedStruct.f6).toEqual(testStructs.FloatNumberValues.V6); | 185 expect(decodedStruct.f6).toEqual(testStructs.FloatNumberValues.V6); |
186 expect(decodedStruct.f7).toEqual(testStructs.FloatNumberValues.V7); | 186 expect(decodedStruct.f7).toEqual(testStructs.FloatNumberValues.V7); |
187 expect(decodedStruct.f8).toEqual(testStructs.FloatNumberValues.V8); | 187 expect(decodedStruct.f8).toEqual(testStructs.FloatNumberValues.V8); |
188 expect(decodedStruct.f9).toEqual(testStructs.FloatNumberValues.V9); | 188 expect(decodedStruct.f9).toEqual(testStructs.FloatNumberValues.V9); |
189 } | 189 } |
190 | 190 |
| 191 function testIntegerNumberValues() { |
| 192 var minInt32 = -2147483648; // See crbug.com/445618 |
| 193 var decodedStruct = structEncodeDecode( |
| 194 new testStructs.IntegerNumberValues({f10: minInt32})); |
| 195 expect(decodedStruct.f0).toEqual(testStructs.IntegerNumberValues.V0); |
| 196 expect(decodedStruct.f1).toEqual(testStructs.IntegerNumberValues.V1); |
| 197 expect(decodedStruct.f2).toEqual(testStructs.IntegerNumberValues.V2); |
| 198 expect(decodedStruct.f3).toEqual(testStructs.IntegerNumberValues.V3); |
| 199 expect(decodedStruct.f4).toEqual(testStructs.IntegerNumberValues.V4); |
| 200 expect(decodedStruct.f5).toEqual(testStructs.IntegerNumberValues.V5); |
| 201 expect(decodedStruct.f6).toEqual(testStructs.IntegerNumberValues.V6); |
| 202 expect(decodedStruct.f7).toEqual(testStructs.IntegerNumberValues.V7); |
| 203 expect(decodedStruct.f8).toEqual(testStructs.IntegerNumberValues.V8); |
| 204 expect(decodedStruct.f9).toEqual(testStructs.IntegerNumberValues.V9); |
| 205 expect(decodedStruct.f10).toEqual(minInt32); |
| 206 expect(decodedStruct.f11).toEqual(testStructs.IntegerNumberValues.V11); |
| 207 expect(decodedStruct.f12).toEqual(testStructs.IntegerNumberValues.V12); |
| 208 expect(decodedStruct.f13).toEqual(testStructs.IntegerNumberValues.V13); |
| 209 expect(decodedStruct.f14).toEqual(testStructs.IntegerNumberValues.V14); |
| 210 expect(decodedStruct.f15).toEqual(testStructs.IntegerNumberValues.V15); |
| 211 expect(decodedStruct.f16).toEqual(testStructs.IntegerNumberValues.V16); |
| 212 expect(decodedStruct.f17).toEqual(testStructs.IntegerNumberValues.V17); |
| 213 expect(decodedStruct.f18).toEqual(testStructs.IntegerNumberValues.V18); |
| 214 expect(decodedStruct.f19).toEqual(testStructs.IntegerNumberValues.V19); |
| 215 } |
| 216 |
| 217 function testUnsignedNumberValues() { |
| 218 var decodedStruct = |
| 219 structEncodeDecode(new testStructs.UnsignedNumberValues); |
| 220 expect(decodedStruct.f0).toEqual(testStructs.UnsignedNumberValues.V0); |
| 221 expect(decodedStruct.f1).toEqual(testStructs.UnsignedNumberValues.V1); |
| 222 expect(decodedStruct.f2).toEqual(testStructs.UnsignedNumberValues.V2); |
| 223 expect(decodedStruct.f3).toEqual(testStructs.UnsignedNumberValues.V3); |
| 224 expect(decodedStruct.f4).toEqual(testStructs.UnsignedNumberValues.V4); |
| 225 expect(decodedStruct.f5).toEqual(testStructs.UnsignedNumberValues.V5); |
| 226 expect(decodedStruct.f6).toEqual(testStructs.UnsignedNumberValues.V6); |
| 227 expect(decodedStruct.f7).toEqual(testStructs.UnsignedNumberValues.V7); |
| 228 expect(decodedStruct.f8).toEqual(testStructs.UnsignedNumberValues.V8); |
| 229 expect(decodedStruct.f9).toEqual(testStructs.UnsignedNumberValues.V9); |
| 230 expect(decodedStruct.f10).toEqual(testStructs.UnsignedNumberValues.V10); |
| 231 expect(decodedStruct.f11).toEqual(testStructs.UnsignedNumberValues.V11); |
| 232 } |
| 233 |
| 234 |
191 function testBitArrayValues() { | 235 function testBitArrayValues() { |
192 var bitArraysStruct = new testStructs.BitArrayValues({ | 236 var bitArraysStruct = new testStructs.BitArrayValues({ |
193 // array<bool, 1> f0; | 237 // array<bool, 1> f0; |
194 f0: [true], | 238 f0: [true], |
195 // array<bool, 7> f1; | 239 // array<bool, 7> f1; |
196 f1: [true, false, true, false, true, false, true], | 240 f1: [true, false, true, false, true, false, true], |
197 // array<bool, 9> f2; | 241 // array<bool, 9> f2; |
198 f2: [true, false, true, false, true, false, true, false, true], | 242 f2: [true, false, true, false, true, false, true, false, true], |
199 // array<bool> f3; | 243 // array<bool> f3; |
200 f3: [true, false, true, false, true, false, true, false], | 244 f3: [true, false, true, false, true, false, true, false], |
(...skipping 14 matching lines...) Expand all Loading... |
215 expect(decodedStruct.f6).toEqual(bitArraysStruct.f6); | 259 expect(decodedStruct.f6).toEqual(bitArraysStruct.f6); |
216 } | 260 } |
217 | 261 |
218 testConstructors(); | 262 testConstructors(); |
219 testNoDefaultFieldValues(); | 263 testNoDefaultFieldValues(); |
220 testDefaultFieldValues(); | 264 testDefaultFieldValues(); |
221 testScopedConstants(); | 265 testScopedConstants(); |
222 testMapKeyTypes(); | 266 testMapKeyTypes(); |
223 testMapValueTypes(); | 267 testMapValueTypes(); |
224 testFloatNumberValues(); | 268 testFloatNumberValues(); |
| 269 testIntegerNumberValues(); |
| 270 testUnsignedNumberValues(); |
225 testBitArrayValues(); | 271 testBitArrayValues(); |
226 this.result = "PASS"; | 272 this.result = "PASS"; |
227 }); | 273 }); |
OLD | NEW |