| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 //! Tests encoding and decoding functionality in the bindings package | 5 //! Tests encoding and decoding functionality in the bindings package |
| 6 //! | 6 //! |
| 7 //! Test failure is defined as the function returning via panicking | 7 //! Test failure is defined as the function returning via panicking |
| 8 //! and the result being caught in the test! macro. If a test function | 8 //! and the result being caught in the test! macro. If a test function |
| 9 //! returns without panicking, it is assumed to pass. | 9 //! returns without panicking, it is assumed to pass. |
| 10 | 10 |
| 11 #[macro_use] | 11 #[macro_use] |
| 12 extern crate mojo; | 12 extern crate mojo; |
| 13 | 13 |
| 14 use mojo::bindings::mojom::MojomMessageOption; | 14 use mojo::bindings::mojom::MojomMessageOption; |
| 15 use mojo::system; | 15 use mojo::system; |
| 16 | 16 |
| 17 #[macro_use] | 17 #[macro_use] |
| 18 mod util; | 18 mod util; |
| 19 | 19 |
| 20 use util::mojom_validation::*; | 20 use util::mojom_validation::*; |
| 21 | 21 |
| 22 /// This macro is a wrapper for the tests! macro as it takes advantage of the | 22 /// This macro is a wrapper for the tests! macro as it takes advantage of the |
| 23 /// shared code between tests. | 23 /// shared code between tests. |
| 24 /// | 24 /// |
| 25 /// Given a test name, it will generate a test function. In this test function | 25 /// Given a test name, it will generate a test function. In this test function |
| 26 /// we perform the following steps: | 26 /// we perform the following steps: |
| 27 /// 1. Decode the header of the validation input. | 27 /// 1. Decode the header of the validation input. |
| 28 /// 3. Decode the payload of the validation input. | 28 /// 2. Decode the payload of the validation input, expecting a validation |
| 29 /// error. |
| 29 /// | 30 /// |
| 30 macro_rules! validation_tests { | 31 macro_rules! validation_tests { |
| 31 ($($name:ident => $req_type:ident;)*) => { | 32 ($($name:ident => $req_type:ident;)*) => { |
| 32 tests! { | 33 tests! { |
| 33 $( | 34 $( |
| 34 fn $name() { | 35 fn $name() { |
| 35 let data = include_str!(concat!("../../interfaces/bindings/tests
/data/validation/", | 36 let data = include_str!(concat!("../../interfaces/bindings/tests
/data/validation/", |
| 36 stringify!($name), | 37 stringify!($name), |
| 37 ".data")); | 38 ".data")); |
| 38 let expected = include_str!(concat!("../../interfaces/bindings/t
ests/data/validation/", | 39 let expected = include_str!(concat!("../../interfaces/bindings/t
ests/data/validation/", |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 conformance_msghdr_num_bytes_huge => ConformanceTestInterfaceRequestOption; | 118 conformance_msghdr_num_bytes_huge => ConformanceTestInterfaceRequestOption; |
| 118 conformance_msghdr_num_bytes_less_than_min_requirement => ConformanceTestInt
erfaceRequestOption; | 119 conformance_msghdr_num_bytes_less_than_min_requirement => ConformanceTestInt
erfaceRequestOption; |
| 119 conformance_msghdr_num_bytes_less_than_struct_header => ConformanceTestInter
faceRequestOption; | 120 conformance_msghdr_num_bytes_less_than_struct_header => ConformanceTestInter
faceRequestOption; |
| 120 conformance_msghdr_num_bytes_version_mismatch_1 => ConformanceTestInterfaceR
equestOption; | 121 conformance_msghdr_num_bytes_version_mismatch_1 => ConformanceTestInterfaceR
equestOption; |
| 121 conformance_msghdr_num_bytes_version_mismatch_2 => ConformanceTestInterfaceR
equestOption; | 122 conformance_msghdr_num_bytes_version_mismatch_2 => ConformanceTestInterfaceR
equestOption; |
| 122 conformance_msghdr_num_bytes_version_mismatch_3 => ConformanceTestInterfaceR
equestOption; | 123 conformance_msghdr_num_bytes_version_mismatch_3 => ConformanceTestInterfaceR
equestOption; |
| 123 resp_boundscheck_msghdr_no_such_method => BoundsCheckTestInterfaceResponseOp
tion; | 124 resp_boundscheck_msghdr_no_such_method => BoundsCheckTestInterfaceResponseOp
tion; |
| 124 resp_conformance_msghdr_invalid_response_flags1 => ConformanceTestInterfaceR
esponseOption; | 125 resp_conformance_msghdr_invalid_response_flags1 => ConformanceTestInterfaceR
esponseOption; |
| 125 resp_conformance_msghdr_invalid_response_flags2 => ConformanceTestInterfaceR
esponseOption; | 126 resp_conformance_msghdr_invalid_response_flags2 => ConformanceTestInterfaceR
esponseOption; |
| 126 resp_conformance_msghdr_no_such_method => ConformanceTestInterfaceResponseOp
tion; | 127 resp_conformance_msghdr_no_such_method => ConformanceTestInterfaceResponseOp
tion; |
| 128 integration_intf_resp_mthd0_unexpected_array_header => IntegrationTestInterf
aceResponseOption; |
| 129 integration_intf_rqst_mthd0_unexpected_struct_header => IntegrationTestInter
faceRequestOption; |
| 130 integration_msghdr_invalid_flags => IntegrationTestInterfaceRequestOption; |
| 127 } | 131 } |
| OLD | NEW |