OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 define([ |
| 6 "console", |
| 7 "gin/test/expect", |
| 8 "mojo/public/js/bindings/codec", |
| 9 "mojo/public/js/bindings/validator", |
| 10 "mojo/bindings/js/message_file_parser" |
| 11 ], function(console, expect, codec, validator, parser) { |
| 12 |
| 13 function testValidateMessageHeader() { |
| 14 var testFiles = [ |
| 15 "conformance_msghdr_incomplete_struct", |
| 16 "conformance_msghdr_incomplete_struct_header", |
| 17 "conformance_msghdr_invalid_flags", |
| 18 "conformance_msghdr_missing_request_id", |
| 19 "conformance_msghdr_num_bytes_huge", |
| 20 //"conformance_msghdr_num_bytes_less_than_min_requirement", |
| 21 "conformance_msghdr_num_bytes_less_than_struct_header", |
| 22 "conformance_msghdr_num_bytes_num_fields_mismatch_1", |
| 23 "conformance_msghdr_num_bytes_num_fields_mismatch_2", |
| 24 "conformance_msghdr_num_bytes_num_fields_mismatch_3", |
| 25 "conformance_msghdr_num_fields_less_than_min_requirement" |
| 26 ]; |
| 27 |
| 28 for (var i = 0; i < testFiles.length; i++) { |
| 29 var filename = "mojo/public/interfaces/bindings/tests/data/validation/" + |
| 30 testFiles[i]; |
| 31 var testMessage = parser.readTestMessage(filename); |
| 32 var buffer = new codec.Buffer(testMessage.message.data.buffer); |
| 33 var message = new codec.Message(buffer); |
| 34 var actualResult = validator.validateMessageHeader(message); |
| 35 expect(actualResult).toEqual(testMessage.expected); |
| 36 } |
| 37 } |
| 38 |
| 39 parser.testMessageParser(); |
| 40 testValidateMessageHeader(); |
| 41 this.result = "PASS"; |
| 42 }); |
OLD | NEW |