/***************************************************************
 	1. Make a conference of 2 calls
	2. Create 3rd call, conference autohold
	3. Add 3rd call to conference, autoresume
	4. Create 4th call, conference autohold
	5. Add 4th call to conference, autoresume
	6. Hangup and Release conference
***************************************************************/

[StifSettings]
CheckHeapBalance= on
[EndStifSettings]

[Test]
title 9.7 Conference Call, 4 Calls
timeout 30000
create ccetester test
test Delay 1000

// Step 1
print Step_1

test OpenNewCall 1 0 ConfcallOne 2 ECCECallTypePS ECCELineTypePrimary
test Dial 1 0 SubAddress Bearer
test WaitEvent 1 Dialling
test WaitEvent 1 Connecting
test WaitEvent 1 Connected

test Hold 1 0
test WaitEvents 1 Hold, 1 LocalHold

test OpenNewCall 2 0 ConfcallTwo 2 ECCECallTypePS ECCELineTypePrimary
test Dial 2 0 SubAddress Bearer
test WaitEvent 2 Dialling
test WaitEvent 2 Connecting
test WaitEvent 2 Connected

// Add calls to conference
test AddToConference 1 0
test WaitEvent ConferenceCallAdded 1

test AddToConference 2 0
// Plugin sets call to match conference state (connected)
test WaitEvents ConferenceCallAdded 2, ConferenceActive, 1 Connected

// Step 2
print Step_2

// Create third call, conference is put on hold automatically
test OpenNewCall 3 0 ConfcallThree 2 ECCECallTypePS ECCELineTypePrimary
test Dial 3 0 SubAddress Bearer

// Plugin changes call states to match conference (hold)
test WaitEvents 1 Hold, 2 Hold, ConferenceHold, 3 Dialling, 3 Connecting, 3 Connected, ConferenceCallSwapped

// Step 3
print Step_3

// Add third call to conference
test AddToConference 3 0

// Conference state is hold, so first plugin changes state of call 3 to connected
// After that conference becomes Active and plugin changes call states to Connected:
test WaitEvents ConferenceCallAdded 3, 3 Hold, 1 Connected, 2 Connected, 3 Connected, ConferenceActive, ConferenceCallSwapped

// Step 4
print Step_4

// Create 4th call, conference is put on hold automatically
test OpenNewCall 4 0 ConfcallFour 2 ECCECallTypePS ECCELineTypePrimary
test Dial 4 0 SubAddress Bearer

// Plugin changes call states to match conference (hold)
test WaitEvents 1 Hold, 2 Hold, 3 Hold, ConferenceHold, 4 Dialling, 4 Connecting, 4 Connected, ConferenceCallSwapped

// Step 5
print Step_5

// Add 4th call to conference
test AddToConference 4 0

// Conference state is hold, plugin changes call 4 state to hold
// Then conference becomes Active, plugin changes call states to Connected
test WaitEvents ConferenceCallAdded 4, 4 Hold, 1 Connected, 2 Connected, 3 Connected, 4 Connected, ConferenceActive, ConferenceCallSwapped

// Step 6
print Step_6

test HangupConference 0

test WaitEvents ConferenceCallRemoved 1, ConferenceCallRemoved 2, ConferenceCallRemoved 3, ConferenceCallRemoved 4, ConferenceIdle, 1 Disconnecting, 1 Idle, 2 Disconnecting, 2 Idle, 3 Disconnecting, 3 Idle, 4 Disconnecting, 4 Idle

test ReleaseConference 0

test VerifyTest
delete test
[Endtest]
