installationservices/swi/test/tuiscriptadaptors/swifileutilitysteps.cpp
branchRCL_3
changeset 23 cd189dac02f7
parent 0 ba25891c3a9e
child 25 7333d7932ef7
equal deleted inserted replaced
21:5bddc28da627 23:cd189dac02f7
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   126 	CleanupStack::PopAndDestroy(2);
   126 	CleanupStack::PopAndDestroy(2);
   127 		
   127 		
   128 	SetTestStepResult(EPass);	
   128 	SetTestStepResult(EPass);	
   129 	return TestStepResult();
   129 	return TestStepResult();
   130 	}
   130 	}
       
   131 
       
   132 
       
   133 CSwiFileExistsStep::CSwiFileExistsStep()
       
   134     {
       
   135     SetTestStepName(KSwiFileExistsStep);
       
   136     }
       
   137 
       
   138 
       
   139 TVerdict CSwiFileExistsStep::doTestStepL()
       
   140     {
       
   141     SetTestStepResult(EFail);
       
   142     
       
   143     RTestUtilSessionSwi testUtil;
       
   144     User::LeaveIfError(testUtil.Connect());
       
   145     CleanupClosePushL(testUtil);
       
   146     
       
   147     _LIT(KNoOfFiles, "FilesCount");
       
   148     _LIT(KFile, "File");
       
   149     
       
   150     TInt filesCount(0);
       
   151     GetIntFromConfig(ConfigSection(), KNoOfFiles(), filesCount);
       
   152     
       
   153     if(filesCount == 0)
       
   154         {
       
   155         User::Leave(KErrArgument);
       
   156         }
       
   157     
       
   158     for(TInt i=0; i<filesCount; ++i)
       
   159         {
       
   160         TBuf<12> file;
       
   161         file = KFile;
       
   162         GenerateIndexedAttributeNameL(file, filesCount);
       
   163         
       
   164         TPtrC fileName;
       
   165         GetStringFromConfig(ConfigSection(), file, fileName);
       
   166         
       
   167         HBufC* fileNameBuf = fileName.AllocLC();
       
   168         TBool result= testUtil.FileExistsL(*fileNameBuf);
       
   169         
       
   170         if(!result)
       
   171             {
       
   172             INFO_PRINTF2(_L("File not found - %S ."), fileNameBuf);
       
   173             CleanupStack::PopAndDestroy(fileNameBuf);
       
   174             return TestStepResult();
       
   175             }
       
   176         else
       
   177             {
       
   178             INFO_PRINTF2(_L("File exists -  %S ."), fileNameBuf);
       
   179             CleanupStack::PopAndDestroy(fileNameBuf);
       
   180             }
       
   181         }
       
   182     
       
   183     CleanupStack::PopAndDestroy(&testUtil);
       
   184     
       
   185     SetTestStepResult(EPass);
       
   186     return TestStepResult();
       
   187     }
       
   188 
       
   189 
       
   190 void CSwiFileExistsStep::GenerateIndexedAttributeNameL(TDes& aInitialAttributeName, TInt aIndex)
       
   191     {
       
   192     const TInt MAX_INT_STR_LEN = 8;
       
   193     TBuf<MAX_INT_STR_LEN> integerAppendStr;
       
   194     integerAppendStr.Format(_L("%d"), aIndex);
       
   195     aInitialAttributeName.Append(integerAppendStr);
       
   196     }