messagingfw/msgtestfw/TestActions/Base/src/CMtfTestActionFindFile.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2004-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 // FindFile
       
    17 // [Action Parameters]
       
    18 // HBufC fileName     <input>: Name of File along with the complete path.
       
    19 // [Action Description]
       
    20 // Checks for a specified file in a specified directory.
       
    21 // [APIs Used]
       
    22 // RMessagingTestUtilityServer::FileExists
       
    23 // __ACTION_INFO_END__
       
    24 // 
       
    25 //
       
    26 
       
    27 #include "messagingtestutility.h"
       
    28 #include "CMtfTestActionFindFile.h"
       
    29 #include "CMtfTestCase.h"
       
    30 #include "CMtfTestActionParameters.h"
       
    31 
       
    32 
       
    33 /**
       
    34   Function : NewL
       
    35   Description : 
       
    36   @internalTechnology
       
    37   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    38   @param : aActionParams - CMtfTestActionParameters 
       
    39   @return : CMtfTestAction* - a base class pointer to the newly created 
       
    40 							  CMtfTestActionCompareImapAccountId object
       
    41   @pre none
       
    42   @post none
       
    43 */
       
    44 CMtfTestAction* CMtfTestActionFindFile::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    45 	{
       
    46 	CMtfTestActionFindFile* self = new (ELeave) CMtfTestActionFindFile(aTestCase);
       
    47 	CleanupStack::PushL(self);
       
    48 	self->ConstructL(aActionParameters);
       
    49 	CleanupStack::Pop();
       
    50 	return self;
       
    51 	}
       
    52 	
       
    53 
       
    54 /**
       
    55   Function : CMtfTestActionCompareImapAccountId
       
    56   Description : Constructor
       
    57   @internalTechnology
       
    58   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    59   @return : N/A
       
    60   @pre none
       
    61   @post none
       
    62 */
       
    63 CMtfTestActionFindFile::CMtfTestActionFindFile(CMtfTestCase& aTestCase)
       
    64 	: CMtfSynchronousTestAction(aTestCase)
       
    65 	{
       
    66 	}
       
    67 
       
    68 
       
    69 /**
       
    70   Function : ~CMtfTestActionCompareImapAccountId
       
    71   Description : Destructor
       
    72   @internalTechnology
       
    73   @param :
       
    74   @return : 
       
    75   @pre 
       
    76   @post 
       
    77 */
       
    78 CMtfTestActionFindFile::~CMtfTestActionFindFile()
       
    79 	{
       
    80 	}
       
    81 
       
    82 
       
    83 /**
       
    84   Function : ExecuteActionL
       
    85   Description : Entry point for the this test action in the test framework
       
    86   @internalTechnology
       
    87   @param : none
       
    88   @return : void
       
    89   @pre none 
       
    90   @post none
       
    91 */
       
    92 void CMtfTestActionFindFile::ExecuteActionL()
       
    93 	{
       
    94 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionFindFile);
       
    95 	HBufC* autoSendFileName = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(0));
       
    96 	
       
    97 	TBool paramTestExistanceFlags=EFalse; 
       
    98 		// Indicates that we can test for non existance or existance of file.
       
    99 	TInt paramExistanceFlag=EFalse; 
       
   100 	
       
   101 	if( ActionParameters().Count() == 2  )
       
   102 		{		
       
   103 		paramExistanceFlag = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1) , ETrue);
       
   104 		paramTestExistanceFlags=ETrue; 
       
   105 		}
       
   106 
       
   107 	RMessagingTestUtilityServer ts;
       
   108 	ts.Connect();
       
   109 	CleanupClosePushL(ts);
       
   110 
       
   111 	TBool flagFileExists = ts.FileExists(*autoSendFileName);
       
   112 	CleanupStack::PopAndDestroy(&ts);
       
   113 
       
   114 	if (paramTestExistanceFlags==EFalse)
       
   115 		{ // Maintain old code behaviour.
       
   116 		
       
   117 		if( ! flagFileExists )
       
   118 			{
       
   119 			User::Leave(KErrNotFound);
       
   120 			//TestCase().ERR_PRINTF1(_L("File not Found !"));
       
   121 			//TestCase().SetTestStepResult(EFail);
       
   122 			}
       
   123 		}
       
   124 	else 
       
   125 		{
       
   126 			
       
   127 		if( ( paramExistanceFlag==0) && ( ! (flagFileExists) ) )
       
   128 			{ // Want to know if file does not exists, and it does not.
       
   129 			}		
       
   130 		else if( ( paramExistanceFlag==0) && (flagFileExists ) )
       
   131 			{ // Want to know if file does not exists, and it does so error.
       
   132 			TestCase().INFO_PRINTF2(_L("Test Action %S File exists but file not expected to exist."), &KTestActionFindFile);
       
   133 			User::Leave(KErrGeneral);
       
   134 			}
       
   135 		else if( ( paramExistanceFlag==1) && (flagFileExists ) )
       
   136 			{ // Want to know if file does exists, and it does so okay.
       
   137 			}
       
   138 		else if( ( paramExistanceFlag==1) && ( ! (flagFileExists) ) )
       
   139 			{ // Want to know if file does exists, and it does not.
       
   140 			TestCase().INFO_PRINTF2(_L("Test Action %S File does not exist but expected to exist."), &KTestActionFindFile);
       
   141 			User::Leave(KErrNotFound);
       
   142 			}
       
   143 		else
       
   144 			{ // Should never get here.				
       
   145 			User::Leave(KErrGeneral);
       
   146 			}
       
   147 		
       
   148 		}
       
   149 
       
   150 //	StoreParameterL<TInt>(TestCase(), flagFileExists, ActionParameters().Parameter(0) );
       
   151 
       
   152 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionFindFile);
       
   153 	TestCase().ActionCompletedL(*this);
       
   154 	}
       
   155