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 "console", | 6 "console", |
7 "file", | 7 "file", |
8 "gin/test/expect", | 8 "gin/test/expect", |
9 "mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom", | 9 "mojo/public/interfaces/bindings/tests/validation_test_interfaces.mojom", |
10 "mojo/public/js/buffer", | 10 "mojo/public/js/buffer", |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 if (actualResult != expectedResult) | 218 if (actualResult != expectedResult) |
219 console.log("[Test message validation failed: " + testFile + " ]"); | 219 console.log("[Test message validation failed: " + testFile + " ]"); |
220 expect(actualResult).toEqual(expectedResult); | 220 expect(actualResult).toEqual(expectedResult); |
221 } | 221 } |
222 | 222 |
223 function testMessageValidation(key, filters) { | 223 function testMessageValidation(key, filters) { |
224 var testFiles = getMessageTestFiles(key); | 224 var testFiles = getMessageTestFiles(key); |
225 expect(testFiles.length).toBeGreaterThan(0); | 225 expect(testFiles.length).toBeGreaterThan(0); |
226 | 226 |
227 for (var i = 0; i < testFiles.length; i++) { | 227 for (var i = 0; i < testFiles.length; i++) { |
228 // TODO(hansmuller, yzshen): Temporarily skipping: | 228 // TODO(hansmuller) Temporarily skipping array pointer overflow tests |
229 // - array pointer overflow tests; | 229 // because JS numbers are limited to 53 bits. |
230 // - struct versioning tests (tests with "mthd11" in the name). | 230 // TODO(yzshen) Skipping struct versioning tests (tests with "mthd11" |
231 // in the name) because ... | |
yzshen1
2015/03/13 22:55:03
... -> the feature is not supported in JS yet.
rudominer
2015/03/16 21:24:32
Done.
| |
232 // TODO(rudominer): Temporarily skipping 'no-such-method', and | |
233 // 'invalid_request_flags'until additional logic in | |
234 // *RequestValidator and *ResponseValidator is ported from cpp to js. | |
231 if (testFiles[i].indexOf("overflow") != -1 || | 235 if (testFiles[i].indexOf("overflow") != -1 || |
232 testFiles[i].indexOf("mthd11") != -1) { | 236 testFiles[i].indexOf("mthd11") != -1 || |
237 testFiles[i].indexOf("no_such_method") != -1 || | |
238 testFiles[i].indexOf("invalid_request_flags") != -1) { | |
233 console.log("[Skipping " + testFiles[i] + "]"); | 239 console.log("[Skipping " + testFiles[i] + "]"); |
234 continue; | 240 continue; |
235 } | 241 } |
236 | 242 |
237 var testMessage = readTestMessage(testFiles[i]); | 243 var testMessage = readTestMessage(testFiles[i]); |
238 var handles = new Array(testMessage.handleCount); | 244 var handles = new Array(testMessage.handleCount); |
239 var message = new codec.Message(testMessage.buffer, handles); | 245 var message = new codec.Message(testMessage.buffer, handles); |
240 var messageValidator = new validator.Validator(message); | 246 var messageValidator = new validator.Validator(message); |
241 | 247 |
242 var err = messageValidator.validateMessageHeader(); | 248 var err = messageValidator.validateMessageHeader(); |
243 for (var j = 0; err === noError && j < filters.length; ++j) | 249 for (var j = 0; err === noError && j < filters.length; ++j) |
244 err = filters[j](messageValidator); | 250 err = filters[j](messageValidator); |
245 | 251 |
246 checkValidationResult(testFiles[i], err); | 252 checkValidationResult(testFiles[i], err); |
247 } | 253 } |
248 } | 254 } |
249 | 255 |
250 function testConformanceMessageValidation() { | 256 function testConformanceMessageValidation() { |
251 testMessageValidation("conformance_", [ | 257 testMessageValidation("conformance_", [ |
252 testInterface.ConformanceTestInterface.validateRequest]); | 258 testInterface.ConformanceTestInterface.validateRequest]); |
253 } | 259 } |
254 | 260 |
255 function testIntegratedMessageValidation(testFilesPattern) { | 261 function testIntegratedMessageValidation(testFilesPattern) { |
256 var testFiles = getMessageTestFiles(testFilesPattern); | 262 var testFiles = getMessageTestFiles(testFilesPattern); |
257 expect(testFiles.length).toBeGreaterThan(0); | 263 expect(testFiles.length).toBeGreaterThan(0); |
258 | 264 |
259 for (var i = 0; i < testFiles.length; i++) { | 265 for (var i = 0; i < testFiles.length; i++) { |
260 // TODO(hansmuller): Temporarily skipping array pointer overflow tests. | |
261 if (testFiles[i].indexOf("overflow") != -1) { | |
262 console.log("[Skipping " + testFiles[i] + "]"); | |
263 continue; | |
264 } | |
265 | |
266 var testMessage = readTestMessage(testFiles[i]); | 266 var testMessage = readTestMessage(testFiles[i]); |
267 var handles = new Array(testMessage.handleCount); | 267 var handles = new Array(testMessage.handleCount); |
268 var testMessagePipe = new core.createMessagePipe(); | 268 var testMessagePipe = new core.createMessagePipe(); |
269 expect(testMessagePipe.result).toBe(core.RESULT_OK); | 269 expect(testMessagePipe.result).toBe(core.RESULT_OK); |
270 | 270 |
271 var writeMessageValue = core.writeMessage( | 271 var writeMessageValue = core.writeMessage( |
272 testMessagePipe.handle0, | 272 testMessagePipe.handle0, |
273 new Uint8Array(testMessage.buffer.arrayBuffer), | 273 new Uint8Array(testMessage.buffer.arrayBuffer), |
274 new Array(testMessage.handleCount), | 274 new Array(testMessage.handleCount), |
275 core.WRITE_MESSAGE_FLAG_NONE); | 275 core.WRITE_MESSAGE_FLAG_NONE); |
(...skipping 29 matching lines...) Expand all Loading... | |
305 testIntegratedMessageValidation("integration_intf_resp"); | 305 testIntegratedMessageValidation("integration_intf_resp"); |
306 } | 306 } |
307 | 307 |
308 expect(checkTestMessageParser()).toBeNull(); | 308 expect(checkTestMessageParser()).toBeNull(); |
309 testConformanceMessageValidation(); | 309 testConformanceMessageValidation(); |
310 testIntegratedMessageHeaderValidation(); | 310 testIntegratedMessageHeaderValidation(); |
311 testIntegratedResponseMessageValidation(); | 311 testIntegratedResponseMessageValidation(); |
312 testIntegratedRequestMessageValidation(); | 312 testIntegratedRequestMessageValidation(); |
313 this.result = "PASS"; | 313 this.result = "PASS"; |
314 }); | 314 }); |
OLD | NEW |