[asterisk-commits] kmoore: branch kmoore/cel_transfers r393587 - /team/kmoore/cel_transfers/tests/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 3 15:49:01 CDT 2013


Author: kmoore
Date: Wed Jul  3 15:48:59 2013
New Revision: 393587

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393587
Log:
Add first CEL attended transfer test

Modified:
    team/kmoore/cel_transfers/tests/test_cel.c

Modified: team/kmoore/cel_transfers/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_transfers/tests/test_cel.c?view=diff&rev=393587&r1=393586&r2=393587
==============================================================================
--- team/kmoore/cel_transfers/tests/test_cel.c (original)
+++ team/kmoore/cel_transfers/tests/test_cel.c Wed Jul  3 15:48:59 2013
@@ -1048,6 +1048,92 @@
 
 	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
 	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
+
+	return AST_TEST_PASS;
+}
+
+AST_TEST_DEFINE(test_cel_attended_transfer_bridges)
+{
+	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
+	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
+	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
+	RAII_VAR(struct ast_channel *, chan_alice2, NULL, safe_channel_release);
+	RAII_VAR(struct ast_bridge *, bridge1, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge2, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_str *, extra, ast_str_create(32), ast_free);
+	struct ast_party_caller alice_caller = ALICE_CALLERID;
+	struct ast_party_caller bob_caller = BOB_CALLERID;
+	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = __func__;
+		info->category = TEST_CATEGORY;
+		info->summary = "Test attended transfers between two pairs of bridged parties";
+		info->description =
+			"This test creates four channels, places each pair in"
+			" a bridge, and then attended transfers the bridges"
+			" together.\n";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+	ast_test_validate(test, extra != NULL);
+
+	/* Create first set of bridged parties */
+	bridge1 = ast_bridge_basic_new();
+	ast_test_validate(test, bridge1 != NULL);
+
+	CREATE_ALICE_CHANNEL(chan_alice, &alice_caller);
+	CREATE_BOB_CHANNEL(chan_bob, &bob_caller);
+	ANSWER_NO_APP(chan_alice);
+	ANSWER_NO_APP(chan_bob);
+
+	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_bob, NULL, NULL, 0));
+	do_sleep();
+
+	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_alice, NULL, NULL, 0));
+	do_sleep();
+	APPEND_EVENT(chan_bob, AST_CEL_BRIDGE_START, NULL, NULL, ast_channel_name(chan_alice));
+
+	/* Create second set of bridged parties */
+	bridge2 = ast_bridge_basic_new();
+	ast_test_validate(test, bridge2 != NULL);
+
+	CREATE_ALICE_CHANNEL(chan_alice2, &alice_caller);
+	CREATE_CHARLIE_CHANNEL(chan_charlie, &charlie_caller);
+	ANSWER_NO_APP(chan_alice2);
+	ANSWER_NO_APP(chan_charlie);
+
+	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_charlie, NULL, NULL, 0));
+	do_sleep();
+
+	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_alice2, NULL, NULL, 0));
+	do_sleep();
+	APPEND_EVENT(chan_charlie, AST_CEL_BRIDGE_START, NULL, NULL, ast_channel_name(chan_alice2));
+
+	/* Perform attended transfer */
+	APPEND_EVENT(chan_bob, AST_CEL_BRIDGE_END, NULL, NULL, ast_channel_name(chan_alice));
+
+	ast_bridge_transfer_attended(chan_alice, chan_alice2);
+	do_sleep();
+	APPEND_EVENT(chan_charlie, AST_CEL_BRIDGE_TO_CONF, NULL, ast_channel_name(chan_bob), ast_channel_name(chan_alice2));
+	APPEND_EVENT(chan_alice2, AST_CEL_CONF_EXIT, NULL, NULL, NULL);
+
+	ast_str_set(&extra, 0, "%s,%s,bridge:%s", bridge1->uniqueid, ast_channel_name(chan_alice2), bridge2->uniqueid);
+	APPEND_EVENT(chan_alice, AST_CEL_ATTENDEDTRANSFER, NULL, ast_str_buffer(extra), NULL);
+
+
+	ast_test_validate(test, 0 == ast_bridge_depart(chan_bob));
+	APPEND_EVENT(chan_bob, AST_CEL_CONF_EXIT, NULL, NULL, NULL);
+	ast_test_validate(test, 0 == ast_bridge_depart(chan_charlie));
+	APPEND_EVENT(chan_charlie, AST_CEL_CONF_EXIT, NULL, NULL, NULL);
+
+	do_sleep();
+	HANGUP_CHANNEL(chan_alice, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_bob, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_alice2, AST_CAUSE_NORMAL, "16,,");
+	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "16,,");
 
 	return AST_TEST_PASS;
 }
@@ -1423,6 +1509,7 @@
 	AST_TEST_UNREGISTER(test_cel_dial_answer_multiparty);
 
 	AST_TEST_UNREGISTER(test_cel_blind_transfer);
+	AST_TEST_UNREGISTER(test_cel_attended_transfer_bridges);
 
 	ast_channel_unregister(&test_cel_chan_tech);
 
@@ -1460,6 +1547,7 @@
 	cel_test_config->events |= 1<<AST_CEL_CONF_ENTER;
 	cel_test_config->events |= 1<<AST_CEL_CONF_EXIT;
 	cel_test_config->events |= 1<<AST_CEL_BLINDTRANSFER;
+	cel_test_config->events |= 1<<AST_CEL_ATTENDEDTRANSFER;
 
 	AST_TEST_REGISTER(test_cel_channel_creation);
 	AST_TEST_REGISTER(test_cel_unanswered_inbound_call);
@@ -1484,6 +1572,7 @@
 	AST_TEST_REGISTER(test_cel_dial_answer_multiparty);
 
 	AST_TEST_REGISTER(test_cel_blind_transfer);
+	AST_TEST_REGISTER(test_cel_attended_transfer_bridges);
 
 	ast_test_register_init(TEST_CATEGORY, test_cel_init_cb);
 	ast_test_register_cleanup(TEST_CATEGORY, test_cel_cleanup_cb);




More information about the asterisk-commits mailing list