blob: 36b87919e90f86a0d364c3c9a09df901bfb612e1 [file] [log] [blame]
Myles Watsona4cd53c2019-03-25 15:25:08 -07001/*
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 Watsonfc57a962019-08-22 16:11:01 -070017#define PACKET_TESTING
Hansong Zhang05c079b2019-04-04 13:24:43 -070018#include "l2cap/l2cap_packets.h"
Myles Watsona4cd53c2019-03-25 15:25:08 -070019
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
28using bluetooth::packet::BitInserter;
29using bluetooth::packet::RawBuilder;
30using std::vector;
31
Myles Watsona4cd53c2019-03-25 15:25:08 -070032namespace bluetooth {
33namespace l2cap {
34
Myles Watsonfc57a962019-08-22 16:11:01 -070035std::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 Watson9ad9dfd2019-04-16 17:05:10 -070048};
Myles Watson9ad9dfd2019-04-16 17:05:10 -070049
Myles Watsonfc57a962019-08-22 16:11:01 -070050DEFINE_AND_INSTANTIATE_ExtendedInformationStartFrameReflectionTest(extended_information_start_frame);
Myles Watson9ad9dfd2019-04-16 17:05:10 -070051
Myles Watsonfc57a962019-08-22 16:11:01 -070052std::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};
54DEFINE_AND_INSTANTIATE_StandardInformationFrameWithFcsReflectionTest(i_frame_with_fcs);
Myles Watson9ad9dfd2019-04-16 17:05:10 -070055
Myles Watsonfc57a962019-08-22 16:11:01 -070056std::vector<uint8_t> rr_frame_with_fcs = {0x04, 0x00, 0x40, 0x00, 0x01, 0x01, 0xD4, 0x14};
57DEFINE_AND_INSTANTIATE_StandardSupervisoryFrameWithFcsReflectionTest(rr_frame_with_fcs);
Hansong Zhange908ba62019-09-06 16:01:25 -070058
59std::vector<uint8_t> g_frame = {0x03, 0x00, 0x02, 0x00, 0x01, 0x02, 0x03};
60DEFINE_AND_INSTANTIATE_GroupFrameReflectionTest(g_frame);
Myles Watson2df67032019-07-11 16:17:05 -070061
62std::vector<uint8_t> config_mtu_request = {0x04, 0x05, 0x08, 0x00, 0x41, 0x00, 0x00, 0x00, 0x01, 0x02, 0xa0, 0x02};
63DEFINE_AND_INSTANTIATE_ConfigurationRequestReflectionTest(config_mtu_request);
Myles Watsona4cd53c2019-03-25 15:25:08 -070064} // namespace l2cap
65} // namespace bluetooth