/**************************************
  1. Create MT CS call [1] (Ringing)
  2. Answer call (Connected)
  3. Create MT PS call [2] (Queued)
  4. Reject Queued call [2]
  5. Hold call [1]
  6. Create MT call [3] (Queued)
  7. Answer call [3]
     Expected: Call 3 is Connected, call 1 stays Hold
  8. Disconnect call [3]
  9. Resume call [1]
 10. Disconnect call [1]
***************************************/

[StifSettings]
CheckHeapBalance= on
[EndStifSettings]

[Test]
title 3.7 MT call, CS combined cases
timeout 20000
create ccetester test
test Delay 1000

// Step 1
print Step_1

// CS plugin is always loaded
// Send plugin command, MT call with CallID 1 is created
test SendPluginRequest 2 CreateCall 1
test WaitEvent 0 IncomingCall
test WaitEvent 1 Ringing

// Step 2
print Step_2

test Answer 1 0
test WaitEvent 1 Answering
test WaitEvent 1 Connected

// Step 3
print Step_3

// Trigger ICM and wait plugin to initialize
test InitIncomingCall
test Delay 1000

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

//  Step 4

// Reject call with Hangup
test HangUp 2 0
test WaitEvent 2 Disconnecting
test WaitEvent 2 Idle

// Call must be released
test Release 2 0

// Step 5
print Step_5

test Hold 1 0
test WaitEvents 1 Hold, 1 LocalHold

// Step 6
print Step_6

// ICM needed, plugin has been removed....
// If PS plugin is doing Release and unloads PS plug-in
// after ICM call happens (ICM does not have any effect)
// Delay added to allow unloading to complete first:
test Delay 500
test InitIncomingCall
// Wait plugin to initialize
test Delay 500

// Send plugin command, MT call with CallID 3 is created
test SendPluginRequest CreateCall 2

// NOTE
// This message is received by old observer
// if call [2] is not released in step 4
//test WaitEvent 2 Queued //event 10

test WaitEvent 0 IncomingCall
test WaitEvent 3 Queued

// Step 7
print Step_7

test Answer 3 0
test WaitEvent 3 Answering
test WaitEvent 3 Connected

// Step 8
print Step_8

test HangUp 3 0
test WaitEvent 3 Disconnecting
test WaitEvent 3 Idle

test Release 3 0

// Step 9
print Step_9

test Resume 1 0
test WaitEvents 1 Connected, 1 LocalResume

// Step 1
print Step_10

test HangUp 1 0
test WaitEvent 1 Disconnecting
test WaitEvent 1 Idle
test Release 1 0

test VerifyTest
delete test
[Endtest] 
