/***************************************************************
    Description: Conference of 5 PS calls and 1 MT CS call

    1. Make a conference of 2 PS calls
    2. Create new PS call and add it to the conference
    3. Repeat step 2 until there are 5 calls in conference
    4. Create new MT CS call
    5. Answer call
       Expected: Conference is put automatically on Hold
    6. Hangup call
    7. Disconnect conference
***************************************************************/

[StifSettings]
CheckHeapBalance= on
[EndStifSettings]

[Test]
title 9.9.4 Conference Call, PS Conference and MT CS call
timeout 20000
create ccetester test
test Delay 1000

// Step 1
print Step_1

// Calls 1 and 2
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

// Call 3
test OpenNewCall 3 0 ConfcallThree 2 ECCECallTypePS ECCELineTypePrimary
test Dial 3 0 SubAddress Bearer
// Conference autohold, plugin changes states to match conference
test WaitEvents 1 Hold, 2 Hold, ConferenceHold, 3 Dialling, 3 Connecting, 3 Connected, ConferenceCallSwapped

test AddToConference 3 0
// Plugin changes added call's state to match conference
// Conference autoresume, plugin changes states to match conference
test WaitEvents ConferenceCallAdded 3, 3 Hold, 1 Connected, 2 Connected, 3 Connected, ConferenceActive, ConferenceCallSwapped

// Call [4]
test OpenNewCall 4 0 ConfcallFour 2 ECCECallTypePS ECCELineTypePrimary
test Dial 4 0 SubAddress Bearer
// Conference autohold, plugin changes states to match conference
test WaitEvents 1 Hold, 2 Hold, 3 Hold, ConferenceHold, 4 Dialling, 4 Connecting, 4 Connected, ConferenceCallSwapped

test AddToConference 4 0
// Plugin changes added call's state to match conference
// Conference autoresume, plugin changes states to match conference
test WaitEvents ConferenceCallAdded 4, 4 Hold, 1 Connected, 2 Connected, 3 Connected, 4 Connected, ConferenceActive, ConferenceCallSwapped

// Call 5
test OpenNewCall 5 0 ConfCallFive 2 ECCECallTypePS ECCELineTypePrimary
test Dial 5 0 SubAddress Bearer
// Conference autohold, plugin changes states to match conference
test WaitEvents 1 Hold, 2 Hold, 3 Hold, 4 Hold, ConferenceHold, 5 Dialling, 5 Connecting, 5 Connected, ConferenceCallSwapped

test AddToConference 5 0
// Plugin changes added call's state to match conference
// Conference autoresume, plugin changes states to match conference
test WaitEvents ConferenceCallAdded 5, 5 Hold, 1 Connected, 2 Connected, 3 Connected, 4 Connected, 5 Connected, ConferenceActive, ConferenceCallSwapped

// Step 4
print Step_4

// Send plugin command, MT call with CallID 6 is created
test SendPluginRequest 2 CreateCall 1
test WaitEvent 0 IncomingCall
test WaitEvent 6 Queued

// Step 5
print Step_5

test Answer 6 0

test WaitEvents 1 Hold, 2 Hold, 3 Hold, 4 Hold, 5 Hold, ConferenceHold, 6 Answering, 6 Connected, ConferenceCallSwapped

// Step 6
print Step_6

test HangUp 6 0
test WaitEvent 6 Disconnecting
test WaitEvent 6 Idle

test Release 6 0

// Step 7
print Step_7

test HangupConference 0

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

test ReleaseConference 0

test VerifyTest
delete test
[Endtest]
