//
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//
//! ===============================================================
//! @SYMTestCaseID		MSG-SMS-Receive-Class0SMS-0003
//! @SYMTestCaseDesc		Receive more than one Class 0 SMS message when in a normal situation
//!
//! @SYMTestActions		
//!				1.	Initializes SimTsy with the configuration file
//!				2.	Start the watcher
//!				3.	Set the default SMS setting file
//!				4.	Create a session to the messaging server
//!				5.	Create a SMS service and then modify the settings of the specified SMS service to match the one
//!				6.	Create a Class 0 SMS message 
//!				7.	Create a Class 0 SMS message
//!				8.	Create a Class 0 SMS message
//!				9.	Schedule the SMS messages and then send the SMS messages from the  sim.tsy after a trigger
//!				10.	Check the messages in the Sent Item folder and Received Class 0 SMS messages will not be there in Inbox, only can be logged in the log file
//!				11.     Check using SIMTsy that each received Class0 SMS PDU is positively acknowledged by the SMS stack 
//!
//! @SYMTestExpectedResults	More than one Class 0 SMS message has been sent and will be displayed to the user by logging to the log file
//! ===============================================================
//!
//! ===============================
//! @SYMTestPriority	Critical
//! @SYMTestType	CIT
//! @SYMTestStatus	Implemented
//!
//! @SYMREQ		REQ6522, REQ6523, REQ7012, REQ7218, REQ7219, REQ7232
//! @SYMPREQ		PREQ1736
//!
//! @SYMAuthor		Rajat Bal
//! ===============================

	
RUN_UTILS DeleteFile c:\messaging.db
LOAD_SUITE MessagingTestServer -SharedData

RUN_UTILS CopyFile	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSms\MSG-SMS-Receive-Class0SMS-0003config.txt C:\config.txt
RUN_UTILS MakeReadWrite	C:\config.txt
RUN_UTILS DeleteFile    C:\logs\testexecute\class0sms.txt

PRINT Copy esk file with MAX PDUs = 5
PRINT ###############################################
// RUN_UTILS  DeleteFile   	c:\private\101F7989\esock\smswap.sms.bak
// RUN_UTILS  copyfile  		c:\private\101F7989\esock\smswap.sms.esk c:\private\101F7989\esock\smswap.sms.bak
RUN_UTILS  MakeReadWrite  	c:\private\101F7989\esock\smswap.sms.esk
RUN_UTILS  copyfile   		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\smswap_MaxFivePDUsInOOD.esk c:\private\101F7989\esock\smswap.sms.esk
PRINT ###############################################


RUN_TEST_STEP 100 MessagingTestServer BEGIN_TEST_CASE_ASYNC
RUN_TEST_STEP 100 MessagingTestServer SETUP_TEST_CASE

PRINT ###############################################
RUN_TEST_STEP 100 MessagingTestServer InitializeSimTsy 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Init1
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer StartWatchers 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini StartWatchers
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep10
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer GetBaseConstants 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini GetBaseConstants
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetDefaultSmsSettings 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini SetSettingsFile
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetDefaultConfiguration 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini SetSmsMessageConfigFile
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSession 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateSession
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateRegistry 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateRegistry
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSmsService 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateSmsService
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetSmsServiceSettings 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini SetSmsSettings
RUN_TEST_STEP 100 MessagingTestServer WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetSchSendSettings 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini SetSchSendSettings
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateMtm 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateMtm
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer DeleteChildren 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini EmptyOutbox
RUN_TEST_STEP 100 MessagingTestServer DeleteChildren 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini EmptySent
RUN_TEST_STEP 100 MessagingTestServer DeleteChildren 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini EmptyInbox
WaitForAll

RUN_TEST_STEP 100 MessagingTestServer EXECUTE_TEST_CASE

PRINT ###############################################
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CheckChildrenCountOutbox0
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CheckChildrenCountSent0
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CheckChildrenCountInbox0
WaitForAll
PRINT ######### just check everthing has gone.
RUN_TEST_STEP 100 MessagingTestServer GetSmsConstants 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini GetSmsConstants
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSmsMessage 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateMessage
RUN_TEST_STEP 100 MessagingTestServer CreateSmsMessage 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateMessage
RUN_TEST_STEP 100 MessagingTestServer CreateSmsMessage 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateMessage
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSelection 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CreateSelection
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer GetDefaultAppendToSelection c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini AppendToSelection
WaitForAll

PRINT ###############################################
PRINT ######### Check that we have more than one message in the outbox. It is the send that will trigger the recive. 
PRINT ######### The sim.tsy waits for the send, and then sends back a message.
RUN_TEST_STEP 100 MessagingTestServer SetNetworkRegistrationStatus c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini NetAvailable
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetSignalStrength 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini NetStrengthHigh
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep3
WaitForAll

PRINT ######### Get ready for the message to be sent here from the sim.tsy but after we send out a message as trigger.
RUN_TEST_STEP 100 MessagingTestServer ExecuteMtmCommand 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini ScheduleMessage
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep10
WaitForAll

RUN_TEST_STEP 100 MessagingTestServer ForwardSystemTime		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini ForwardSystemTime
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer ForwardSystemTime		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini ForwardSystemTime
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep10
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep10
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep10
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep10
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini Sleep10
WaitForAll


PRINT ######### Let message get there.
RUN_TEST_STEP 100 MessagingTestServer CHECK_POSTCONDITIONS
PRINT ######### Check that we have one message in the sent (and removed from the outbox), and that we have one message (which we sent from the sim.tsy) in the inbox. 
RUN_TEST_STEP 100 MessagingTestServer CheckClass0SMS 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CheckClass0SMS
RUN_TEST_STEP 100 MessagingTestServer CheckClass0SMS 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CheckClass0SMS
RUN_TEST_STEP 100 MessagingTestServer CheckClass0SMS 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini CheckClass0SMS
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer UnloadPhoneModule		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0003.ini UnloadPhoneModule
PRINT ###############################################


// PRINT ###############################################
// RUN_UTILS  DeleteFile  		c:\private\101F7989\sms\smsu.rsc
// RUN_UTILS  MakeReadWrite  	c:\private\101F7989\esock\smswap.sms.esk
// RUN_UTILS  copyfile  		c:\private\101F7989\esock\smswap.sms.bak     c:\private\101F7989\esock\smswap.sms.esk
// PRINT ###############################################


RUN_TEST_STEP 100 MessagingTestServer END_TEST_CASE

