| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 f2: new Map([["a", [null]], ["b", [null, "d"]]]), | 151 f2: new Map([["a", [null]], ["b", [null, "d"]]]), |
| 152 // array<string,2>> | 152 // array<string,2>> |
| 153 f3: new Map([["a", ["1", "2"]], ["b", ["1", "2"]]]), | 153 f3: new Map([["a", ["1", "2"]], ["b", ["1", "2"]]]), |
| 154 // array<array<string, 1>?> | 154 // array<array<string, 1>?> |
| 155 f4: new Map([["a", [["1"]]], ["b", [null]]]), | 155 f4: new Map([["a", [["1"]]], ["b", [null]]]), |
| 156 // array<array<string, 2>, 1>> | 156 // array<array<string, 2>, 1>> |
| 157 f5: new Map([["a", [["1", "2"]]]]), | 157 f5: new Map([["a", [["1", "2"]]]]), |
| 158 // map<string, Rect?> | 158 // map<string, Rect?> |
| 159 f6: new Map([["a", null]]), | 159 f6: new Map([["a", null]]), |
| 160 // map<string, map<string, string>> | 160 // map<string, map<string, string>> |
| 161 // f7: new Map([["a", new Map([["b", "c"]])]]), | 161 f7: new Map([["a", new Map([["b", "c"]])]]), |
| 162 // map<string, array<map<string, string>>> | 162 // map<string, array<map<string, string>>> |
| 163 // f8: new Map([["a", [new Map([["b", "c"]])]]]), | 163 f8: new Map([["a", [new Map([["b", "c"]])]]]), |
| 164 }); | 164 }); |
| 165 var decodedStruct = structEncodeDecode(mapFieldsStruct); | 165 var decodedStruct = structEncodeDecode(mapFieldsStruct); |
| 166 expect(decodedStruct.f0).toEqual(mapFieldsStruct.f0); | 166 expect(decodedStruct.f0).toEqual(mapFieldsStruct.f0); |
| 167 expect(decodedStruct.f1).toEqual(mapFieldsStruct.f1); | 167 expect(decodedStruct.f1).toEqual(mapFieldsStruct.f1); |
| 168 expect(decodedStruct.f2).toEqual(mapFieldsStruct.f2); | 168 expect(decodedStruct.f2).toEqual(mapFieldsStruct.f2); |
| 169 expect(decodedStruct.f3).toEqual(mapFieldsStruct.f3); | 169 expect(decodedStruct.f3).toEqual(mapFieldsStruct.f3); |
| 170 expect(decodedStruct.f4).toEqual(mapFieldsStruct.f4); | 170 expect(decodedStruct.f4).toEqual(mapFieldsStruct.f4); |
| 171 expect(decodedStruct.f5).toEqual(mapFieldsStruct.f5); | 171 expect(decodedStruct.f5).toEqual(mapFieldsStruct.f5); |
| 172 expect(decodedStruct.f6).toEqual(mapFieldsStruct.f6); | 172 expect(decodedStruct.f6).toEqual(mapFieldsStruct.f6); |
| 173 // expect(decodedStruct.f7).toEqual(mapFieldsStruct.f7); | 173 expect(decodedStruct.f7).toEqual(mapFieldsStruct.f7); |
| 174 // expect(decodedStruct.f8).toEqual(mapFieldsStruct.f8); | 174 expect(decodedStruct.f8).toEqual(mapFieldsStruct.f8); |
| 175 } |
| 176 |
| 177 function testFloatNumberValues() { |
| 178 var decodedStruct = structEncodeDecode(new testStructs.FloatNumberValues); |
| 179 expect(decodedStruct.f0).toEqual(testStructs.FloatNumberValues.V0); |
| 180 expect(decodedStruct.f1).toEqual(testStructs.FloatNumberValues.V1); |
| 181 expect(decodedStruct.f2).toEqual(testStructs.FloatNumberValues.V2); |
| 182 expect(decodedStruct.f3).toEqual(testStructs.FloatNumberValues.V3); |
| 183 expect(decodedStruct.f4).toEqual(testStructs.FloatNumberValues.V4); |
| 184 expect(decodedStruct.f5).toEqual(testStructs.FloatNumberValues.V5); |
| 185 expect(decodedStruct.f6).toEqual(testStructs.FloatNumberValues.V6); |
| 186 expect(decodedStruct.f7).toEqual(testStructs.FloatNumberValues.V7); |
| 187 expect(decodedStruct.f8).toEqual(testStructs.FloatNumberValues.V8); |
| 188 expect(decodedStruct.f9).toEqual(testStructs.FloatNumberValues.V9); |
| 189 } |
| 190 |
| 191 function testBitArrayValues() { |
| 192 var bitArraysStruct = new testStructs.BitArrayValues({ |
| 193 // array<bool, 1> f0; |
| 194 f0: [true], |
| 195 // array<bool, 7> f1; |
| 196 f1: [true, false, true, false, true, false, true], |
| 197 // array<bool, 9> f2; |
| 198 f2: [true, false, true, false, true, false, true, false, true], |
| 199 // array<bool> f3; |
| 200 f3: [true, false, true, false, true, false, true, false], |
| 201 // array<array<bool>> f4; |
| 202 f4: [[true], [false], [true, false], [true, false, true, false]], |
| 203 // array<array<bool>?> f5; |
| 204 f5: [[true], null, null, [true, false, true, false]], |
| 205 // array<array<bool, 2>?> f6; |
| 206 f6: [[true, false], [true, false], [true, false]], |
| 207 }); |
| 208 var decodedStruct = structEncodeDecode(bitArraysStruct); |
| 209 expect(decodedStruct.f0).toEqual(bitArraysStruct.f0); |
| 210 expect(decodedStruct.f1).toEqual(bitArraysStruct.f1); |
| 211 expect(decodedStruct.f2).toEqual(bitArraysStruct.f2); |
| 212 expect(decodedStruct.f3).toEqual(bitArraysStruct.f3); |
| 213 expect(decodedStruct.f4).toEqual(bitArraysStruct.f4); |
| 214 expect(decodedStruct.f5).toEqual(bitArraysStruct.f5); |
| 215 expect(decodedStruct.f6).toEqual(bitArraysStruct.f6); |
| 175 } | 216 } |
| 176 | 217 |
| 177 testConstructors(); | 218 testConstructors(); |
| 178 testNoDefaultFieldValues(); | 219 testNoDefaultFieldValues(); |
| 179 testDefaultFieldValues(); | 220 testDefaultFieldValues(); |
| 180 testScopedConstants(); | 221 testScopedConstants(); |
| 181 testMapKeyTypes(); | 222 testMapKeyTypes(); |
| 182 testMapValueTypes(); | 223 testMapValueTypes(); |
| 224 testFloatNumberValues(); |
| 225 testBitArrayValues(); |
| 183 this.result = "PASS"; | 226 this.result = "PASS"; |
| 184 }); | 227 }); |
| OLD | NEW |