diff -r bbd31066657e -r 8bb370ba6d1d testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSReadFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testexecfw/stf/examples/MigrationExample/FileStore/TEF_STEP/src/TestFSReadFile.cpp Fri Apr 09 10:46:28 2010 +0800 @@ -0,0 +1,126 @@ +/* +* 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: +* +*/ + +// User includes +#include "TestFSReadFile.h" + +// System includes +#include + + +// Literal constants +_LIT(KFileName, "filename"); + +CTestFSReadFile::CTestFSReadFile() +/** +Constructor + */ + { + // Call base class method to set up the human readable name for logging + SetTestStepName(KTestFSReadFile); + } + +CTestFSReadFile::~CTestFSReadFile() +/** +Destructor + */ + { + } + +TVerdict CTestFSReadFile::doTestStepL() +/** +This is implementation of the pure virtual function of CTestStep. +It reads data from a file. +@return TVerdict - the test result + */ + { + TInt err = 0; + TPtrC fileName; + + INFO_PRINTF1(_L("In test step ReadFile")); + + //Getting the file name from ini file + if(!GetStringFromConfig(ConfigSection(), KFileName ,fileName)) + { + ERR_PRINTF1(_L("File Name not specified")); + SetTestStepResult(EFail); + } + else + { + INFO_PRINTF2(_L("File to be opened is= %S "),&fileName); + } + + if(TestStepResult() == EPass) + { + RFs fileSession; + //Connecting to the file server + TRAP(err, fileSession.Connect()) + if ( err != KErrNone) + { + ERR_PRINTF1(_L("Failed to connect to the file server")); + SetTestStepError(err); + } + else + { + RFile file; + + CleanupClosePushL(fileSession); + //Opening the file + err = file.Open(fileSession,fileName,EFileRead); + if ( err != KErrNone) + { + ERR_PRINTF1(_L("Error in Opening file")); + SetTestStepError(err); + } + else + { + CleanupClosePushL(file); + TInt fileSize = 0; + err = file.Size(fileSize); + if(err == KErrNone) + { + HBufC8 *data = HBufC8::NewLC(fileSize); + TPtr8 ptr = data->Des(); + // RaiseInstrumentationEventNotificationL(MTestInstrumentation::EPointFilestoreReadFileStart); + err = file.Read(ptr); + // RaiseInstrumentationEventNotificationL(MTestInstrumentation::EPointFilestoreReadFileStop); + if(err != KErrNone) + { + ERR_PRINTF1(_L("Error in reading the file")); + SetTestStepError(err); + } + else + { + INFO_PRINTF1(_L("Read File passed with no error code")); + SetTestStepResult(EPass); + } + CleanupStack::PopAndDestroy(data); + } + else + { + ERR_PRINTF1(_L("Error in finding size of the file")); + SetTestStepError(err); + } + file.Close(); + CleanupStack::PopAndDestroy(&file); + + } + CleanupStack::PopAndDestroy(&fileSession); + } + } + return TestStepResult(); + }