Myles Watson | a4cd53c | 2019-03-25 15:25:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Myles Watson | fc57a96 | 2019-08-22 16:11:01 -0700 | [diff] [blame] | 17 | #define PACKET_TESTING |
Hansong Zhang | 05c079b | 2019-04-04 13:24:43 -0700 | [diff] [blame] | 18 | #include "l2cap/l2cap_packets.h" |
Myles Watson | a4cd53c | 2019-03-25 15:25:08 -0700 | [diff] [blame] | 19 | |
| 20 | #include <gtest/gtest.h> |
| 21 | #include <forward_list> |
| 22 | #include <memory> |
| 23 | |
| 24 | #include "os/log.h" |
| 25 | #include "packet/bit_inserter.h" |
| 26 | #include "packet/raw_builder.h" |
| 27 | |
| 28 | using bluetooth::packet::BitInserter; |
| 29 | using bluetooth::packet::RawBuilder; |
| 30 | using std::vector; |
| 31 | |
Myles Watson | a4cd53c | 2019-03-25 15:25:08 -0700 | [diff] [blame] | 32 | namespace bluetooth { |
| 33 | namespace l2cap { |
| 34 | |
Myles Watson | fc57a96 | 2019-08-22 16:11:01 -0700 | [diff] [blame] | 35 | std::vector<uint8_t> extended_information_start_frame = { |
| 36 | 0x0B, /* First size byte */ |
| 37 | 0x00, /* Second size byte */ |
| 38 | 0xc1, /* First ChannelId byte */ |
| 39 | 0xc2, /**/ |
| 40 | 0x4A, /* 0x12 ReqSeq, Final, IFrame */ |
| 41 | 0xD0, /* 0x13 ReqSeq */ |
| 42 | 0x89, /* 0x21 TxSeq sar = START */ |
| 43 | 0x8C, /* 0x23 TxSeq */ |
| 44 | 0x10, /* first length byte */ |
| 45 | 0x11, /**/ |
| 46 | 0x01, /* first payload byte */ |
| 47 | 0x02, 0x03, 0x04, 0x05, |
Myles Watson | 9ad9dfd | 2019-04-16 17:05:10 -0700 | [diff] [blame] | 48 | }; |
Myles Watson | 9ad9dfd | 2019-04-16 17:05:10 -0700 | [diff] [blame] | 49 | |
Myles Watson | fc57a96 | 2019-08-22 16:11:01 -0700 | [diff] [blame] | 50 | DEFINE_AND_INSTANTIATE_ExtendedInformationStartFrameReflectionTest(extended_information_start_frame); |
Myles Watson | 9ad9dfd | 2019-04-16 17:05:10 -0700 | [diff] [blame] | 51 | |
Myles Watson | fc57a96 | 2019-08-22 16:11:01 -0700 | [diff] [blame] | 52 | std::vector<uint8_t> i_frame_with_fcs = {0x0E, 0x00, 0x40, 0x00, 0x02, 0x00, 0x00, 0x01, 0x02, |
| 53 | 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x38, 0x61}; |
| 54 | DEFINE_AND_INSTANTIATE_StandardInformationFrameWithFcsReflectionTest(i_frame_with_fcs); |
Myles Watson | 9ad9dfd | 2019-04-16 17:05:10 -0700 | [diff] [blame] | 55 | |
Myles Watson | fc57a96 | 2019-08-22 16:11:01 -0700 | [diff] [blame] | 56 | std::vector<uint8_t> rr_frame_with_fcs = {0x04, 0x00, 0x40, 0x00, 0x01, 0x01, 0xD4, 0x14}; |
| 57 | DEFINE_AND_INSTANTIATE_StandardSupervisoryFrameWithFcsReflectionTest(rr_frame_with_fcs); |
Hansong Zhang | e908ba6 | 2019-09-06 16:01:25 -0700 | [diff] [blame] | 58 | |
| 59 | std::vector<uint8_t> g_frame = {0x03, 0x00, 0x02, 0x00, 0x01, 0x02, 0x03}; |
| 60 | DEFINE_AND_INSTANTIATE_GroupFrameReflectionTest(g_frame); |
Myles Watson | 2df6703 | 2019-07-11 16:17:05 -0700 | [diff] [blame] | 61 | |
| 62 | std::vector<uint8_t> config_mtu_request = {0x04, 0x05, 0x08, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x02, 0xa0, 0x02}; |
| 63 | DEFINE_AND_INSTANTIATE_ConfigurationRequestReflectionTest(config_mtu_request); |
Myles Watson | a4cd53c | 2019-03-25 15:25:08 -0700 | [diff] [blame] | 64 | } // namespace l2cap |
| 65 | } // namespace bluetooth |