From 677427feb48b03c8857562fd8e88665a788c81d5 Mon Sep 17 00:00:00 2001 From: Milanka Ringwald Date: Fri, 23 Oct 2015 22:54:35 +0200 Subject: [PATCH] test only hfp ag --- src/hfp_ag.c | 28 +++++++++++++++++----------- test/hfp/Makefile | 9 +++++---- test/hfp/hfp_ag_client_test.c | 25 ++++++++++--------------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/hfp_ag.c b/src/hfp_ag.c index fd0028c0a..4956a7379 100644 --- a/src/hfp_ag.c +++ b/src/hfp_ag.c @@ -561,11 +561,11 @@ static int hfp_ag_run_for_context_service_level_connection_queries(hfp_connectio } -static void hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context){ - if (context->state <= HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED) return; - if (context->state > HFP_CODECS_CONNECTION_ESTABLISHED) return; - +static int hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context){ + if (context->state <= HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED || + context->state > HFP_CODECS_CONNECTION_ESTABLISHED) return 0; + int done = 0; printf(" AG run for context_codecs_connection: "); switch (context->state){ case HFP_SLE_W2_EXCHANGE_COMMON_CODEC: @@ -575,7 +575,8 @@ static void hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context) context->state = HFP_SLE_W4_EXCHANGE_COMMON_CODEC; context->suggested_codec = hfp_ag_suggest_codec(context); hfp_ag_cmd_suggest_codec(context->rfcomm_cid, context->suggested_codec); - return; + done = 1; + break; } break; case HFP_SLE_W4_EXCHANGE_COMMON_CODEC: @@ -589,7 +590,8 @@ static void hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context) context->state = HFP_SLE_W4_EXCHANGE_COMMON_CODEC; } hfp_ag_ok(context->rfcomm_cid); - return; + done = 1; + break; } break; case HFP_CMD_HF_CONFIRMED_CODEC: @@ -597,12 +599,14 @@ static void hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context) if (context->codec_confirmed != context->suggested_codec){ context->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED; hfp_ag_error(context->rfcomm_cid); - return; + done = 1; + break; } context->negotiated_codec = context->codec_confirmed; context->state = HFP_CODECS_CONNECTION_ESTABLISHED; hfp_emit_event(hfp_callback, HFP_SUBEVENT_CODECS_CONNECTION_COMPLETE, 0); hfp_ag_ok(context->rfcomm_cid); + done = 1; break; default: break; @@ -620,7 +624,8 @@ static void hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context) context->state = HFP_SLE_W4_EXCHANGE_COMMON_CODEC; } hfp_ag_ok(context->rfcomm_cid); - return; + done = 1; + break; } break; case HFP_CMD_AG_SUGGESTED_CODEC: @@ -630,6 +635,8 @@ static void hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context) context->state = HFP_SLE_W4_EXCHANGE_COMMON_CODEC; context->suggested_codec = hfp_ag_suggest_codec(context); hfp_ag_cmd_suggest_codec(context->rfcomm_cid, context->suggested_codec); + done = 1; + break; } } break; @@ -640,8 +647,7 @@ static void hfp_ag_run_for_context_codecs_connection(hfp_connection_t * context) default: break; } - - + return done; } @@ -669,7 +675,7 @@ void hfp_run_for_context(hfp_connection_t *context){ if (!rfcomm_can_send_packet_now(context->rfcomm_cid)) return; done = hfp_ag_run_for_context_service_level_connection_queries(context); if (!rfcomm_can_send_packet_now(context->rfcomm_cid) || done) return; - hfp_ag_run_for_context_codecs_connection(context); + done = hfp_ag_run_for_context_codecs_connection(context); if (context->command == HFP_CMD_NONE){ switch(context->state){ diff --git a/test/hfp/Makefile b/test/hfp/Makefile index 3671d509f..9e3036783 100644 --- a/test/hfp/Makefile +++ b/test/hfp/Makefile @@ -53,7 +53,8 @@ VPATH += ${BTSTACK_ROOT}/platforms/posix/src CFLAGS = -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include -I${BTSTACK_ROOT}/ble LDFLAGS += -lCppUTest -lCppUTestExt -EXAMPLES = hfp_ag_parser_test hfp_hf_parser_test hfp_hf_client_test hfp_ag_client_test +EXAMPLES = hfp_ag_client_test +#hfp_hf_parser_test hfp_hf_client_test hfp_ag_parser_test all: ${BTSTACK_ROOT}/include/btstack/version.h ${EXAMPLES} @@ -73,8 +74,8 @@ hfp_ag_client_test: ${MOCK_OBJ} hfp_ag.o hfp.o hfp_ag_client_test.c ${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@ test: all - ./hfp_hf_parser_test - ./hfp_ag_parser_test - ./hfp_hf_client_test + #./hfp_hf_parser_test + #./hfp_ag_parser_test + #./hfp_hf_client_test ./hfp_ag_client_test diff --git a/test/hfp/hfp_ag_client_test.c b/test/hfp/hfp_ag_client_test.c index c15406175..a8d7f9023 100644 --- a/test/hfp/hfp_ag_client_test.c +++ b/test/hfp/hfp_ag_client_test.c @@ -199,10 +199,7 @@ TEST_GROUP(HFPClient){ }; TEST(HFPClient, HFCodecsConnectionEstablished){ - - for (int i = 0; i < cc_tests_size(); i++){ - service_level_connection_established = 0; setup_hfp_service_level_connection(default_slc_setup(), default_slc_setup_size()); CHECK_EQUAL(service_level_connection_established, 1); @@ -213,23 +210,21 @@ TEST(HFPClient, HFCodecsConnectionEstablished){ } // TEST(HFPClient, HFServiceLevelConnectionCommands){ -// service_level_connection_established = 0; -// setup_hfp_service_level_connection(default_slc_setup(), default_slc_setup_size()); -// CHECK_EQUAL(service_level_connection_established, 1); - // for (int i = 0; i < slc_cmds_tests_size(); i++){ -// simulate_test_sequence(hfp_slc_cmds_tests()[i].test, hfp_slc_cmds_tests()[i].len); -// } - -// } - -// TEST(HFPClient, HFServiceLevelConnectionEstablished){ -// for (int i = 0; i < slc_tests_size(); i++){ -// setup_hfp_service_level_connection(hfp_slc_tests()[i].test, hfp_slc_tests()[i].len); +// setup_hfp_service_level_connection(default_slc_setup(), default_slc_setup_size()); // CHECK_EQUAL(service_level_connection_established, 1); +// simulate_test_sequence(hfp_slc_cmds_tests()[i].test, hfp_slc_cmds_tests()[i].len); +// teardown(); // } // } +TEST(HFPClient, HFServiceLevelConnectionEstablished){ + for (int i = 0; i < slc_tests_size(); i++){ + setup_hfp_service_level_connection(hfp_slc_tests()[i].test, hfp_slc_tests()[i].len); + CHECK_EQUAL(service_level_connection_established, 1); + } +} + int main (int argc, const char * argv[]){ hfp_ag_init(rfcomm_channel_nr, 1007, codecs, sizeof(codecs),