1 2 // ***************************************************************************** 3 // 4 // test rfcomm query tests 5 // 6 // ***************************************************************************** 7 8 #include "btstack_config.h" 9 10 #include <stdint.h> 11 #include <stdio.h> 12 #include <stdlib.h> 13 #include <string.h> 14 15 #include "btstack_event.h" 16 #include "btstack_memory.h" 17 #include "btstack_run_loop.h" 18 #include "hci.h" 19 #include "hci_cmd.h" 20 #include "hci_dump.h" 21 #include "l2cap.h" 22 #include "mock.h" 23 #include "classic/sdp_util.h" 24 25 #include "CppUTest/TestHarness.h" 26 #include "CppUTest/CommandLineTestRunner.h" 27 28 29 static uint8_t sdp_test_record_list[] = { 30 0x00, 0x00, 0x00, 0x00, 31 0x00, 0x00, 0x00, 0x01, 32 0x00, 0x00, 0x00, 0x02, 33 0x00, 0x00, 0x00, 0x03, 34 0x00, 0x00, 0x00, 0x04, 35 0x00, 0x00, 0x00, 0x05, 36 0x00, 0x00, 0x00, 0x06, 37 0x00, 0x00, 0x00, 0x07, 38 0x00, 0x00, 0x00, 0x08, 39 0x00, 0x00, 0x00, 0x09, 40 0x00, 0x00, 0x00, 0x0A 41 }; 42 43 static void handle_sdp_parser_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ 44 static uint32_t record_handle = sdp_test_record_list[0]; 45 switch (packet[0]){ 46 case SDP_EVENT_QUERY_SERVICE_RECORD_HANDLE: 47 CHECK_EQUAL(sdp_event_query_service_record_handle_get_record_handle(packet), record_handle); 48 record_handle++; 49 break; 50 case SDP_EVENT_QUERY_COMPLETE: 51 printf("General query done with status %d.\n", sdp_event_query_complete_get_status(packet)); 52 break; 53 } 54 } 55 56 57 TEST_GROUP(SDPClient){ 58 void setup(void){ 59 sdp_parser_init(&handle_sdp_parser_event); 60 sdp_parser_init_service_search(); 61 } 62 }; 63 64 65 TEST(SDPClient, QueryData){ 66 uint16_t test_size = sizeof(sdp_test_record_list)/4; 67 sdp_parser_handle_service_search(sdp_test_record_list, test_size, test_size); 68 } 69 70 71 int main (int argc, const char * argv[]){ 72 return CommandLineTestRunner::RunAllTests(argc, argv); 73 } 74