hfp: audio connection unit tests

This commit is contained in:
Milanka Ringwald 2015-08-21 22:31:01 +02:00
parent 08d5b4cc31
commit 99f65fee91
2 changed files with 27 additions and 0 deletions

View File

@ -696,11 +696,13 @@ void process_command(hfp_connection_t * context){
if (strncmp((char *)context->line_buffer+offset, HFP_TRIGGER_CODEC_CONNECTION_SETUP, strlen(HFP_TRIGGER_CODEC_CONNECTION_SETUP)) == 0){ if (strncmp((char *)context->line_buffer+offset, HFP_TRIGGER_CODEC_CONNECTION_SETUP, strlen(HFP_TRIGGER_CODEC_CONNECTION_SETUP)) == 0){
context->command = HFP_CMD_TRIGGER_CODEC_CONNECTION_SETUP; context->command = HFP_CMD_TRIGGER_CODEC_CONNECTION_SETUP;
context->trigger_codec_connection_setup = 1;
return; return;
} }
if (strncmp((char *)context->line_buffer+offset, HFP_CONFIRM_COMMON_CODEC, strlen(HFP_CONFIRM_COMMON_CODEC)) == 0){ if (strncmp((char *)context->line_buffer+offset, HFP_CONFIRM_COMMON_CODEC, strlen(HFP_CONFIRM_COMMON_CODEC)) == 0){
context->command = HFP_CMD_CONFIRM_COMMON_CODEC; context->command = HFP_CMD_CONFIRM_COMMON_CODEC;
return; return;
} }
@ -828,6 +830,9 @@ void hfp_parse(hfp_connection_t * context, uint8_t byte){
case HFP_PARSER_CMD_SEQUENCE: // parse comma separated sequence, ignore breacktes case HFP_PARSER_CMD_SEQUENCE: // parse comma separated sequence, ignore breacktes
switch (context->command){ switch (context->command){
case HFP_CMD_CONFIRM_COMMON_CODEC:
context->remote_codec_received = atoi((char*)context->line_buffer);
break;
case HFP_CMD_SUPPORTED_FEATURES: case HFP_CMD_SUPPORTED_FEATURES:
context->remote_supported_features = atoi((char*)context->line_buffer); context->remote_supported_features = atoi((char*)context->line_buffer);
printf("Parsed supported feature %d\n", context->remote_supported_features); printf("Parsed supported feature %d\n", context->remote_supported_features);

View File

@ -222,6 +222,28 @@ TEST(HFPParser, HFP_AG_EXTENDED_AUDIO_GATEWAY_ERROR){
CHECK_EQUAL(context.enable_extended_audio_gateway_error_report, 1); CHECK_EQUAL(context.enable_extended_audio_gateway_error_report, 1);
} }
TEST(HFPParser, HFP_AG_TRIGGER_CODEC_CONNECTION_SETUP){
sprintf(packet, "\r\nAT%s\r\n", HFP_TRIGGER_CODEC_CONNECTION_SETUP);
for (pos = 0; pos < strlen(packet); pos++){
hfp_parse(&context, packet[pos]);
}
CHECK_EQUAL(context.command, HFP_CMD_TRIGGER_CODEC_CONNECTION_SETUP);
CHECK_EQUAL(context.trigger_codec_connection_setup, 1);
}
TEST(HFPParser, HFP_AG_CONFIRM_COMMON_CODEC){
int codec = 2;
sprintf(packet, "\r\nAT%s=%d\r\n", HFP_CONFIRM_COMMON_CODEC, codec);
for (pos = 0; pos < strlen(packet); pos++){
hfp_parse(&context, packet[pos]);
}
CHECK_EQUAL(context.command, HFP_CMD_CONFIRM_COMMON_CODEC);
CHECK_EQUAL(context.remote_codec_received, codec);
}
int main (int argc, const char * argv[]){ int main (int argc, const char * argv[]){
return CommandLineTestRunner::RunAllTests(argc, argv); return CommandLineTestRunner::RunAllTests(argc, argv);