//
// 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-0001
//! @SYMTestCaseDesc		Receive Class 0 SMS message or partial Class 0 SMS message when in an Out of Disk 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.	Set up out of disk situation
//!				6.	Create a SMS service and then modify the settings of the specified SMS service to match the one
//!				7.	Create a Class 0 SMS message 
//!				8.	Schedule a SMS message and then send the SMS message from the  sim.tsy after a trigger
//!				9.	Check the message in the Sent Item folder and Receive Class 0 SMS message will not be there in 
//!					Inbox, only can be logged in the log file
//!				10.	Check received class 0 SMS is partial or not
//!				11.	Check for partial message if it is first, middle or last part  and log into log file
//!				12.	Check using SIMTsy that each received Class0 SMS PDU is positively acknowledged by the SMS stack 

//!
//! @SYMTestExpectedResults	Class 0 SMS message or partial Class 0 SMS message has been sent and will be received 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-0001config.txt C:\config.txt
RUN_UTILS MakeReadWrite	C:\config.txt

RUN_UTILS  DeleteFile   c:\private\101F7989\sms\smsclass0preallocated.dat
RUN_UTILS  DeleteFile   c:\private\101F7989\sms\smsclass0reast.dat

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

//RUN_TEST_STEP 60  MessagingTestServer SetDiskSpaceMonitorLimits c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini   SetDiskSpaceMonitorLimits
//WaitForAll
//RUN_TEST_STEP 120 MessagingTestServer SetDiskSpace         	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini   SetDiskSpace
//WaitForAll


PRINT ###############################################
RUN_TEST_STEP 100 MessagingTestServer InitializeSimTsy 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini Init1
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer StartWatchers 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini StartWatchers
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini Sleep10
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer GetBaseConstants 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini GetBaseConstants
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetDefaultSmsSettings 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini SetSettingsFile
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetDefaultConfiguration 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini SetSmsMessageConfigFile
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSession 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CreateSession
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateRegistry 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CreateRegistry
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSmsService 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CreateSmsService
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetSmsServiceSettings 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini SetSmsSettings
RUN_TEST_STEP 100 MessagingTestServer WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetSchSendSettings 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini SetSchSendSettings
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateMtm 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CreateMtm
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer DeleteChildren 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini EmptyOutbox
RUN_TEST_STEP 100 MessagingTestServer DeleteChildren 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini EmptySent
RUN_TEST_STEP 100 MessagingTestServer DeleteChildren 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.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-0001.ini CheckChildrenCountOutbox0
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CheckChildrenCountSent0
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CheckChildrenCountInbox0
WaitForAll
PRINT ######### just check everthing has gone.
RUN_TEST_STEP 100 MessagingTestServer GetSmsConstants 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini GetSmsConstants
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSmsMessage 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CreateMessage
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CreateSelection 		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CreateSelection
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer GetDefaultAppendToSelection c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini AppendToSelection
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CheckChildrenCountOutbox1
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CheckChildrenCountSent0
RUN_TEST_STEP 100 MessagingTestServer CheckChildrenCount 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini CheckChildrenCountInbox0
WaitForAll


PRINT ###############################################
PRINT ######### Check that we have only 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-0001.ini NetAvailable
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer SetSignalStrength 	c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini NetStrengthHigh
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer Sleep 			c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.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-0001.ini ScheduleMessage
WaitForAll

PRINT ######### We have to go through the various states to ensure that the message gets out otherwise we could have 
PRINT ######### the messaging outstanding when the test finishes. This would cause the test to fail.

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

RUN_TEST_STEP 100 MessagingTestServer CHECK_POSTCONDITIONS
PRINT ######### Let message get there.
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-0001.ini CheckClass0SMS
WaitForAll
RUN_TEST_STEP 100 MessagingTestServer UnloadPhoneModule		c:\msgtest\TestFramework\ScriptedTestCases\EmailOverSMS\MSG-SMS-Receive-Class0SMS-0001.ini UnloadPhoneModule
//RUN_TEST_STEP 120 MessagingTestServer FreeDiskSpace
//WaitForAll

//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

