1 /*
2  * Copyright 2020 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 
17 // Adapted from change_path_packet_test.cc
18 
19 #include <base/logging.h>
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
22 
23 #include "avrcp_test_packets.h"
24 #include "change_path.h"
25 #include "packet_test_helper.h"
26 
27 namespace bluetooth {
28 namespace avrcp {
29 
30 using TestChangePathReqPacket = TestPacketType<ChangePathRequest>;
31 
32 // Getter
LLVMFuzzerTestOneInput(const char * data,size_t size)33 extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) {
34   std::vector<uint8_t> change_path_request_data;
35 
36   // Minimum for this type of packet appears to be 14 bytes.
37   if (size > 14) {
38     for (size_t x = 0; x < size; x++) {
39       change_path_request_data.push_back(data[x]);
40     }
41 
42     auto test_packet = TestChangePathReqPacket::Make(change_path_request_data);
43 
44     test_packet->GetUidCounter();
45     test_packet->GetDirection();
46     test_packet->GetUid();
47     test_packet->IsValid();
48     test_packet->ToString();
49   }
50 
51   return 0;
52 }
53 
54 }  // namespace avrcp
55 }  // namespace bluetooth
56