//
// 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:
//
//! @file

RUN_UTILS	  DeleteFile		c:\messaging.db

LOAD_SUITE 	T_MsgCommonServer 	-SharedData
LOAD_SUITE 	T_MsgImapServer 	-SharedData
LOAD_SUITE  	T_MsgSmtpServer 	-SharedData


START_TESTCASE ST-MESS-CACHEFULL-0001

//!	@SYMTestCaseID			ST-MESS-CACHEFULL-0001
//!	@SYMTestCaseDesc		Send/Receive the message when cache is full	
//!                                     	
//!	@SYMTestPriority		Critical
//!   	@SYMTestType			ST
//!  	@SYMTestStatus			Implemented
//!	@SYMPREQ 			PREQ1189   
//!	@SYMTestCaseDependencies	Requires ced -i c:\ced_default_ras.cfg to set comms.
//!	@SYMTestActions			Initialises the RAS connection
//!					Resets the message store to clean up the central repository
//!					Creates an IMAP account
//!					Connects to the IMAP server and performs a synchronisation
//!					Disconnects from the server
//!					
//!					Create the cache full situation by downloading 500 messages with
//!					the configuration of 500KB cache size in msgcache.ini file.
//!					
//!					Create a message
//!					Send the message when cache is full
//!					Connects to the IMAP server
//!					Receive the message when cache is full
//!					Disconnects from the server
//!					
//!	@SYMTestExpectedResults		Should be able to send and receive the message
//!	@SYMAuthor			Rajat Bal



PRINT ################## set cache size to 500KB ###
RUN_UTILS  CopyFile   		c:\private\1000484b\msgcache.ini c:\private\1000484b\msgcache.bak
RUN_UTILS  MakeReadWrite  	c:\private\1000484b\msgcache.ini
RUN_UTILS  CopyFile   		c:\msgtest\sys\msgcache_full.ini c:\private\1000484b\msgcache.ini
PRINT ##################

RUN_TEST_STEP 300 T_MsgCommonServer 	StartUp
RUN_TEST_STEP 300 T_MsgImapServer 	StartUp
RUN_TEST_STEP 300 T_MsgSmtpServer	StartUp

RUN_TEST_STEP 300 T_MsgCommonServer 	InitNtRas			c:\msgtest\sys\st-mess.ini 	0001-InitNtRas
RUN_TEST_STEP 300 T_MsgCommonServer 	ResetMessageStore		c:\msgtest\sys\st-mess.ini 	0001-ResetMessageStore
RUN_TEST_STEP 300 T_MsgImapServer 	CreateImapAccount		c:\msgtest\sys\st-mess.ini 	0001-CreateImapAccount

RUN_TEST_STEP 300 T_MsgImapServer	ChangeImap4SubAndSyncSettings	c:\msgtest\sys\st-mess.ini 	0001-ChangeImapSettings
RUN_TEST_STEP 300 T_MsgImapServer	ConnectAndSyncImapServer	c:\msgtest\sys\st-mess.ini 	0001-ConnectAndSyncImapServer
RUN_TEST_STEP 300 T_MsgImapServer	InitialiseImap4Account		c:\msgtest\sys\st-mess.ini 	0001-InitialiseImap4Account
RUN_TEST_STEP 300 T_MsgImapServer	DoFullImap4Synchronisation	c:\msgtest\sys\st-mess.ini 	0001-DoFullImap4Synchronisation
RUN_TEST_STEP 300 T_MsgImapServer	CheckChildrenCountImap		c:\msgtest\sys\st-mess.ini 	0001-CheckChildrenCountRemoteInbox
RUN_TEST_STEP 300 T_MsgImapServer	DisConnectImapServer		c:\msgtest\sys\st-mess.ini 	0001-DisConnectImap4Server

PRINT ################## cache full condition: by 500 messages ###
START_REPEAT	c:\msgtest\sys\st-mess.ini	0001-Section1	RepeatParam
RUN_TEST_STEP 300 T_MsgSmtpServer 	CreateSmtpMessageFromEmailFile	c:\msgtest\sys\st-mess.ini 	0001-CreateSmtpMessageFromEmailFile
END_REPEAT
RUN_TEST_STEP 3000 T_MsgSmtpServer	SendSmtpMessage			c:\msgtest\sys\st-mess.ini 	0001-SendSmtpMessage
RUN_TEST_STEP 300 T_MsgImapServer	SetImap4FullDownloadLimits	c:\msgtest\sys\st-mess.ini 	0001-SetImap4FullDownloadLimits
RUN_TEST_STEP 300 T_MsgImapServer 	ConnectImap4Server		c:\msgtest\sys\st-mess.ini 	0001-ConnectImap4Server
RUN_TEST_STEP 3000 T_MsgImapServer 	DoFullImap4Synchronisation	c:\msgtest\sys\st-mess.ini 	0001-DoFullImap4Synchronisation
RUN_TEST_STEP 3000 T_MsgImapServer 	ImapInvokeAsyncFunction		c:\msgtest\sys\st-mess.ini 	0001-ImapInvokeAsyncFunction
RUN_TEST_STEP 300 T_MsgImapServer 	DisConnectImapServer		c:\msgtest\sys\st-mess.ini 	0001-DisConnectImap4Server
PRINT ##################

PRINT ################## demo: send/recieve in cache full ###
RUN_TEST_STEP 300 T_MsgSmtpServer 	CreateSmtpMessageFromEmailFile	c:\msgtest\sys\st-mess.ini 	0001-CreateSmtpMessageFromEmailFile
RUN_TEST_STEP 300 T_MsgSmtpServer	SendSmtpMessage			c:\msgtest\sys\st-mess.ini 	0001-SendSmtpMessage
RUN_TEST_STEP 300 T_MsgImapServer	SetImap4FullDownloadLimits	c:\msgtest\sys\st-mess.ini 	0001-SetImap4FullDownloadLimits
RUN_TEST_STEP 300 T_MsgImapServer 	ConnectImap4Server		c:\msgtest\sys\st-mess.ini 	0001-ConnectImap4Server
RUN_TEST_STEP 3000 T_MsgImapServer 	DoFullImap4Synchronisation	c:\msgtest\sys\st-mess.ini 	0001-DoFullImap4Synchronisation
RUN_TEST_STEP 3000 T_MsgImapServer 	ImapInvokeAsyncFunction		c:\msgtest\sys\st-mess.ini 	0001-ImapInvokeAsyncFunction
PRINT ##################

RUN_TEST_STEP 300 T_MsgImapServer 	DisConnectImapServer		c:\msgtest\sys\st-mess.ini 	0001-DisConnectImap4Server

RUN_TEST_STEP 300 T_MsgSmtpServer	ShutDown
RUN_TEST_STEP 300 T_MsgImapServer 	ShutDown
RUN_TEST_STEP 300 T_MsgCommonServer 	ShutDown

PRINT ################## back old cahce size ###
RUN_UTILS  MakeReadWrite  	c:\private\1000484b\msgcache.ini
RUN_UTILS  CopyFile   		c:\private\1000484b\msgcache.bak c:\private\1000484b\msgcache.ini
RUN_UTILS  DeleteFile		c:\private\1000484b\msgcache.bak
PRINT ##################

PRINT Execute Completed ################################################
END_TESTCASE ST-MESS-CACHEFULL-0001


