//
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of the License "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
//! 	@SYMTestSuiteName		pbase-f32-sfsrv-publicapi-rem
//!	@SYMScriptTestEnvironment	This test script requires a basic ROM and a MMC card (128 MB recommended, not tested above that).
//! 	@SYMScriptAuthor 		Alvar Udras, Runno Sgirka
//! 	@SYMScriptDescription		The test script contains API tests for the following functions of RRawDisk class:
//!	TInt Open(RFs &aFs, TInt aDrive);
//!	void Close();
//!	TInt Read(TInt64 aPos, TDes8 &aDes);
//!	TInt Write(TInt64 aPos, TDesC8 &aDes);
//!					The tests are containing risk, e.g. Write() method call can corrupt the boot sector or
//!					non-writable sector of the disc, which may corrupt the whole disk forever.


LOAD_SUITE	t_sfsrv
DELAY 5000

START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-0001
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-0001
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Functions Open() and Close() test. Open a disk channel and close it.
//!				Uses API elements: Open(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Close() method to close the channel.
//!				5. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Open() method call is completed returning KErrNone. The Close() method call is completed without errors. 
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		COMMAND		rfs1	new
		COMMAND		rfs1	Connect
		COMMAND		rawdisk1	new
		COMMAND		rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-0001-001-Open_command05
		COMMAND		rawdisk1	Close
		COMMAND		rawdisk1	~
		COMMAND		rfs1	Close
		COMMAND		rfs1	~		
	END_TEST_BLOCK	
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-0001


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-0002
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-0002
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Function Write() and Read() test. Open a disk channel, write to the disc, verify it by reading and close the channel.
//!				Uses API elements: Open(), Write(), Read(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Write(TInt64 aPos, TDes8 &aDes) method passing position 1024 and string 'Hello Big World!' to write
//!				   as parameters.
//!				5. Call Read(TInt64 aPos, TDes8 &aDes) method passing position 1024 and string 'Hello Big World!' for 
//!				   verification as parameters.
//!				6. Call Close() method to close the disk.
//!				7. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Read() and Write() method calls are completed returning KErrNone.
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		COMMAND		rfs1	new
		COMMAND		rfs1	Connect
		COMMAND		rawdisk1	new
		COMMAND		rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-0002-001-Open_command05
		COMMAND		rawdisk1	Write		PBASE-F32-RawDisk-PublicApi-0002-001-Write_command06
		COMMAND		rawdisk1	Read		PBASE-F32-RawDisk-PublicApi-0002-001-Read_command07
		COMMAND		rawdisk1	Close
		COMMAND		rawdisk1	~
		COMMAND		rfs1	Close
		COMMAND		rfs1	~		
	END_TEST_BLOCK	
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-0002


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-0003
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-0003
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Function Write() and Read() test. Open a disk channel, write and read an empty string and close the channel.
//!				Uses API elements: Open(), Write(), Read(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Write(TInt64 aPos, TDes8 &aDes) method passing position 1024 and empty string to write
//!				   as parameters.
//!				5. Call Read(TInt64 aPos, TDes8 &aDes) method passing position 1024 and empty string for 
//!				   verification as parameters.
//!				6. Call Close() method to close the disk.
//!				7. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Read() and Write() method calls are completed returning KErrNone.
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		COMMAND		rfs1	new
		COMMAND		rfs1	Connect
		COMMAND		rawdisk1	new
		COMMAND		rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-0003-001-Open_command05
		COMMAND		rawdisk1	Write		PBASE-F32-RawDisk-PublicApi-0003-001-Write_command06
		COMMAND		rawdisk1	Read		PBASE-F32-RawDisk-PublicApi-0003-001-Read_command07
		COMMAND		rawdisk1	Close
		COMMAND		rawdisk1	~
		COMMAND		rfs1	Close
		COMMAND		rfs1	~		
	END_TEST_BLOCK	
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-0003


// 	************************
//	***  NEGATIVE TESTS  ***
// 	************************


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1007
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-1007
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Test that checks that no other resources can access the disk while direct access to it is in effect.
//!				Uses API elements: Open(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Create a RFile instance, passing fileserver session, EFileShareAny and {removable drive path}test03.txt as parameters.
//!				5. Close the RFile instance.
//!				6. Call Close() method to close the channel.
//!				7. Format the disk for future usage.
//!				8. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The RFormat::Open() method call returns error -14 (KErrInUse).
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		CREATE_OBJECT	RFile	file
		COMMAND			rfs1	new
		COMMAND			rfs1	Connect
		COMMAND			rawdisk1	new
		COMMAND			rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-1007-001-Open_command05
		COMMAND			file		new
		COMMAND	!Error=-14	file		Create		PBASE-F32-RawDisk-PublicApi-1007-001-Create_command07
		COMMAND			file		Close
		COMMAND			file		~	
		COMMAND			rawdisk1	Close
		COMMAND			rawdisk1	~
		COMMAND			rfs1	Close
		COMMAND			rfs1	~		
	END_TEST_BLOCK
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1007


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1008
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-1008
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Function Open() test. Call Open() after opening a resource on the disk.
//!				Uses API elements: Open(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Open an RFormat instance, passing fileserver session, removable drive and EHighDensity as parameters.
//!				4. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				5. Call Close() method to close the channel.
//!				6. Close the RFormat instance.
//!				7. Format the disk for future usage.
//!				8. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Open() method call returns error -14 (KErrInUse).
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		CREATE_OBJECT	RFormat	format1
		COMMAND			rfs1	new
		COMMAND			rfs1	Connect
		COMMAND			format1		new
		COMMAND			format1		Open		PBASE-F32-RawDisk-PublicApi-1008-001-Open_command05
		COMMAND			rawdisk1	new
		COMMAND	!Error=-14	rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-1008-001-Open_command07		
		COMMAND			format1		Close
		COMMAND			format1		~	
		COMMAND			rawdisk1	Close
		COMMAND			rawdisk1	~
		COMMAND			rfs1	Close
		COMMAND			rfs1	~		
	END_TEST_BLOCK
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1008


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1009
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-1009
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Test that checks that calling Close() allows other resources to access the disk.
//!				Uses API elements: Open(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Close() method to close the channel.
//!				5. Open an RFormat instance, passing fileserver session, removable drive and EHighDensity as parameters.
//!				6. Close the RFormat instance.
//!				7. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The RFormat instance can access the disk without errors.
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		CREATE_OBJECT	RFormat	format1
		COMMAND		rfs1	new
		COMMAND		rfs1	Connect
		COMMAND		rawdisk1	new
		COMMAND		rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-1009-001-Open_command05		
		COMMAND		rawdisk1	Close
		COMMAND		rawdisk1	~
		COMMAND		format1		new
		COMMAND		format1		Open		PBASE-F32-RawDisk-PublicApi-1009-001-Open_command09
		COMMAND		format1		Close
		COMMAND		format1		~
		COMMAND		rfs1	Close
		COMMAND		rfs1	~		
	END_TEST_BLOCK
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1009


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1010
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-1010
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Function Write() test. Open a disk channel, write to the disc, while starting writing from a negative position.
//!				Uses API elements: Open(), Write(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Write(TInt64 aPos, TDes8 &aDes) method passing -1 as position, string 'Hello World!' to write as parameters.
//!				6. Call Close() method to close the disk.
//!				7. Format the disk for future usage.
//!				8. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Write() method call returns error -6 (KErrArgument).
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		CREATE_OBJECT	RFormat	format1
		COMMAND			rfs1	new
		COMMAND			rfs1	Connect
		COMMAND			rawdisk1	new
		COMMAND			rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-1010-001-Open_command05
		COMMAND	!Error=-6	rawdisk1	Write		PBASE-F32-RawDisk-PublicApi-1010-001-Write_command06
		COMMAND			rawdisk1	Close
		COMMAND			rawdisk1	~
		COMMAND			format1		new
		COMMAND			format1		Open		PBASE-F32-RawDisk-PublicApi-1010-001-Open_command10
		COMMAND			format1		Next
		COMMAND			format1		Close
		COMMAND			format1		~
		COMMAND			rfs1	Close
		COMMAND			rfs1	~		
	END_TEST_BLOCK	
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1010


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1011
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-1011
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Function Write() test. Open a disk channel, write to the disc, while starting writing from an out of range position.
//!				Uses API elements: Open(), Write(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Write(TInt64 aPos, TDes8 &aDes) method passing 10000000 as position, string 'Hello World!' as parameters.
//!				6. Call Close() method to close the disk.
//!				7. Format the disk for future usage.
//!				8. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Write() method call returns error -20 (KErrCorrupt).
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		CREATE_OBJECT	RFormat	format1
		COMMAND			rfs1	new
		COMMAND			rfs1	Connect
		COMMAND			rawdisk1	new
		COMMAND			rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-1011-001-Open_command05
		COMMAND	!Error=-20	rawdisk1	Write		PBASE-F32-RawDisk-PublicApi-1011-001-Write_command06
		COMMAND			rawdisk1	Close
		COMMAND			rawdisk1	~
		COMMAND			format1		new
		COMMAND			format1		Open		PBASE-F32-RawDisk-PublicApi-1011-001-Open_command10
		COMMAND			format1		Next
		COMMAND			format1		Close
		COMMAND			rfs1	Close
		COMMAND			rfs1	~		
	END_TEST_BLOCK	
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1011


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1012
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-1012
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Function Read() test. Open a disk channel, read from disc, starting reading from a negative position, and close the channel.
//!				Uses API elements: Open(), Read(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Read(TInt64 aPos, TDes8 &aDes) method passing -1 as position, string 'Hello World!' as parameters.
//!				5. Call Close() method to close the disk.
//!				6. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Read() method call returns error -6 (KErrArgument).
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		COMMAND			rfs1	new
		COMMAND			rfs1	Connect
		COMMAND			rawdisk1	new
		COMMAND			rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-1012-001-Open_command05
		COMMAND	!Error=-6	rawdisk1	Read		PBASE-F32-RawDisk-PublicApi-1012-001-Read_command06
		COMMAND			rawdisk1	Close
		COMMAND			rawdisk1	~
		COMMAND			rfs1	Close
		COMMAND			rfs1	~		
	END_TEST_BLOCK	
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1012


START_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1013
//! @SYMTestCaseID		PBASE-F32-RawDisk-PublicApi-1013
//! @SYMAPI			RRawDisk
//! @SYMTestCaseDesc		Function Read() test. Open a disk channel, read from disc, starting reading from an out of range position,
//!				and close the channel.
//!				Uses API elements: Open(), Read(), Close().
//! @SYMTestActions		1. Create a RFs session.
//!				2. Connect the RFs session.
//!				3. Call Open(RFs &aFs, TInt aDrive) method to open a direct access channel to disk, passing fileserver session, removable
//!				   drive as parameters.
//!				4. Call Read(TInt64 aPos, TDes8 &aDes) method passing 10000000 as position, string 'Hello World!' as parameters.
//!				5. Call Close() method to close the disk.
//!				6. Close the RFs session.
//! @SYMTestStatus		Implemented
//! @SYMTestPriority		Critical
//! @SYMTestExpectedResults	The Read() method call returns error -20 (KErrCorrupt).
//! @SYMTestType		CIT
	START_TEST_BLOCK	100	t_sfsrv	\base\PBASE-F32-RawDisk-PublicApi.ini 
		CREATE_OBJECT	RFs	rfs1
		CREATE_OBJECT	RRawDisk	rawdisk1
		COMMAND			rfs1	new
		COMMAND			rfs1	Connect
		COMMAND			rawdisk1	new
		COMMAND			rawdisk1	Open		PBASE-F32-RawDisk-PublicApi-1013-001-Open_command05
		COMMAND	!Error=-20	rawdisk1	Read		PBASE-F32-RawDisk-PublicApi-1013-001-Read_command06
		COMMAND			rawdisk1	Close
		COMMAND			rawdisk1	~
		COMMAND			rfs1	Close
		COMMAND			rfs1	~		
	END_TEST_BLOCK	
END_TESTCASE 			PBASE-F32-RawDisk-PublicApi-1013
