messagingfw/msgtestfw/TestActions/Sms/src/CMtfTestActionSetDiskSpaceMonitorLimits.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // SetDiskSpaceMonitorLimits
       
    17 // [Action Parameters]
       
    18 // lowLimit     input 		TInt
       
    19 // highLimit    input 		TInt
       
    20 // [Action Description]
       
    21 // Setting Disk space monitor limits
       
    22 // __ACTION_INFO_END__
       
    23 // 
       
    24 //
       
    25 
       
    26 
       
    27 #include "CMtfTestCase.h"
       
    28 #include "CMtfTestActionParameters.h"
       
    29 #include "CMtfTestActionSetDiskSpaceMonitorLimits.h"
       
    30 
       
    31 // Location and name of the RSC file.
       
    32 _LIT(KSMSUResourceDir, "C:\\private\\101f7989\\sms\\");
       
    33 _LIT(KSMSUResourceFile, "C:\\private\\101f7989\\sms\\smsu.rsc");
       
    34 
       
    35 
       
    36 
       
    37 /**
       
    38   Function		: NewL
       
    39   Description	: 
       
    40   @internalTechnology
       
    41   @param		: aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    42   @param		: aActionParams - CMtfTestActionParameters 
       
    43   @return		: CMtfTestAction* - a base class pointer to the newly created CMtfTestActionSetDiskSpaceMonitorLimits object
       
    44   @pre none
       
    45   @post none
       
    46 */
       
    47 CMtfTestAction* CMtfTestActionSetDiskSpaceMonitorLimits::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    48 	{
       
    49 	CMtfTestActionSetDiskSpaceMonitorLimits* self = new (ELeave) CMtfTestActionSetDiskSpaceMonitorLimits(aTestCase);
       
    50 	CleanupStack::PushL(self);
       
    51 	self->ConstructL(aActionParameters);
       
    52 	CleanupStack::Pop(self);
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 /**
       
    57   Function		: CMtfTestActionSetDiskSpaceMonitorLimits
       
    58   Description	: Constructor
       
    59   @internalTechnology
       
    60   @param		: aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    61   @return		: N/A
       
    62   @pre none
       
    63   @post none
       
    64 */
       
    65 CMtfTestActionSetDiskSpaceMonitorLimits::CMtfTestActionSetDiskSpaceMonitorLimits(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
    66 	{
       
    67 	}
       
    68 	
       
    69 /**
       
    70   Function		: ~CMtfTestActionSetDiskSpaceMonitorLimits
       
    71   Description	: Destructor
       
    72   @internalTechnology
       
    73   @param		:
       
    74   @return		: 
       
    75   @pre 
       
    76   @post 
       
    77 */
       
    78 CMtfTestActionSetDiskSpaceMonitorLimits::~CMtfTestActionSetDiskSpaceMonitorLimits()
       
    79 	{
       
    80 	}
       
    81 
       
    82 /**
       
    83   Function		: ExecuteActionL
       
    84   Description	: Entry point for the this test action in the test framework
       
    85   @internalTechnology
       
    86   @param		: none
       
    87   @return		: void
       
    88   @pre none 
       
    89   @post none
       
    90 */
       
    91 void CMtfTestActionSetDiskSpaceMonitorLimits::ExecuteActionL()
       
    92 	{
       
    93 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetDiskSpaceMonitorLimits);
       
    94 
       
    95 	RFs fs;
       
    96 	User::LeaveIfError(fs.Connect());	
       
    97 
       
    98 	TInt lowLimit = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(0));
       
    99 	TInt highLimit = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1));
       
   100 	
       
   101 
       
   102 	TestCase().INFO_PRINTF3(_L("Setting high and low .RSC limits to %ld and %ld."), highLimit, lowLimit);
       
   103 
       
   104 	__ASSERT_ALWAYS(lowLimit  < 0x7fffffff, User::Leave(KErrArgument));
       
   105 	__ASSERT_ALWAYS(highLimit < 0x7fffffff, User::Leave(KErrArgument));
       
   106 	__ASSERT_ALWAYS(lowLimit  < highLimit, User::Leave(KErrArgument));
       
   107 
       
   108 	//
       
   109 	// Data for the SMSU resource file. The low limit is written at position
       
   110 	// 20 and the high limit at position 24.
       
   111 	//
       
   112 	const TInt  smsuRscSize = 34;
       
   113 	TChar  smsuRscData[smsuRscSize] =
       
   114 				{0x6b, 0x4a, 0x1f, 0x10, 0x00, 0x00, 0x00, 0x00,
       
   115    	 			 0x00, 0x00, 0x00, 0x00, 0x19, 0xfd, 0x48, 0xe8,
       
   116 				 0x01, 0x04, 0x00, 0x00, 0x78, 0x56, 0x34, 0x12,
       
   117 				 0x87, 0x65, 0x43, 0x21, 0x14, 0x00, 0x18, 0x00, 
       
   118    		 		 0x1c, 0x00};
       
   119     						  
       
   120 	smsuRscData[20] = (lowLimit  >>  0) & 0xff;
       
   121 	smsuRscData[21] = (lowLimit  >>  8) & 0xff;
       
   122 	smsuRscData[22] = (lowLimit  >> 16) & 0xff;
       
   123 	smsuRscData[23] = (lowLimit  >> 24) & 0xff;
       
   124 	smsuRscData[24] = (highLimit >>  0) & 0xff;
       
   125 	smsuRscData[25] = (highLimit >>  8) & 0xff;
       
   126 	smsuRscData[26] = (highLimit >> 16) & 0xff;
       
   127 	smsuRscData[27] = (highLimit >> 24) & 0xff;
       
   128 
       
   129 	TBuf8<smsuRscSize>  smsuRscBuffer;
       
   130 
       
   131 	for (TInt index = 0;  index < smsuRscSize;  index++)
       
   132 		{
       
   133 		smsuRscBuffer.Append(smsuRscData[index]);
       
   134 		}
       
   135 
       
   136 	//
       
   137 	// Ensure the target directory exists...
       
   138 	//
       
   139 	TInt  ret;
       
   140 	
       
   141 	ret = fs.MkDir(KSMSUResourceDir);
       
   142 	if (ret != KErrNone  &&  ret != KErrAlreadyExists)
       
   143 		{
       
   144 		User::Leave(ret);
       
   145 		}
       
   146 
       
   147 	//
       
   148 	// Write the RSC file to the private C:\ directory...
       
   149 	//
       
   150 	RFile  file;
       
   151 
       
   152 	User::LeaveIfError(file.Replace(fs, KSMSUResourceFile, EFileWrite));
       
   153 	CleanupClosePushL(file);
       
   154 	User::LeaveIfError(file.Write(smsuRscSize, smsuRscBuffer));
       
   155 	CleanupStack::PopAndDestroy(&file);
       
   156 
       
   157 	fs.Close();
       
   158 	
       
   159 	TestCase().INFO_PRINTF2( _L("Test Action %S completed."), &KTestActionSetDiskSpaceMonitorLimits );
       
   160 	TestCase().ActionCompletedL( *this );	
       
   161 	}
       
   162 
       
   163