sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: // User Include sl@0: #include "TestDeleteFileStep.h" sl@0: sl@0: /** sl@0: Constructor. Sets the test step name sl@0: */ sl@0: CTestDeleteFileStep::CTestDeleteFileStep() sl@0: { sl@0: //Call base class method to set human readable name for test step sl@0: SetTestStepName(KTestDeleteFileStep); sl@0: } sl@0: sl@0: /** sl@0: Tries to delete a file mentioned in the ini file. sl@0: @internalTechnology sl@0: @param None sl@0: @return EPass or EFail indicating the success or failure of file deletion. sl@0: */ sl@0: TVerdict CTestDeleteFileStep::doTestStepL() sl@0: { sl@0: // Get file path and name from ini file sl@0: TPtrC fileName; sl@0: TPtrC fileType; sl@0: TPtrC drive; sl@0: TInt err = KErrNone; sl@0: RFs fs; sl@0: sl@0: if (!GetStringFromConfig(ConfigSection(), KIniFileName, fileName)) sl@0: { sl@0: ERR_PRINTF1(_L("Unable to read filename from ini file")); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("File name = %S"), &fileName); sl@0: sl@0: // check whether the filetype field exists in INI sl@0: if(GetStringFromConfig(ConfigSection(), KIniFileType, fileType)) sl@0: { sl@0: INFO_PRINTF2(_L("File type = %S"), &fileType); sl@0: } sl@0: sl@0: if(fileType == KFileTypePrivate) sl@0: {// The file is a private file. We require the drive too, as the path is relative sl@0: if (!GetStringFromConfig(ConfigSection(), KIniDrive, drive)) sl@0: { sl@0: ERR_PRINTF1(_L("If file type is private, drive should be provided. Unable to read drive")); sl@0: SetTestStepResult(EFail); sl@0: return TestStepResult(); sl@0: } sl@0: TFileName fullyQualifiedName(fileName); sl@0: // In the case of a secure vesrion of the OS sl@0: // As the INI file contains relative file-name for private files sl@0: // under the ExpectedFileName field, construct the fully-qualified sl@0: // expected file-name sl@0: if((err = CTestFileUriServer::CreateFullyQualifiedName(fileName, drive, fullyQualifiedName)) != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Error returned by CTestFileUriServer::CreateFullyQualifiedName: %D"), err); sl@0: SetTestStepResult(EFail); sl@0: return TestStepResult(); sl@0: } sl@0: fileName.Set(fullyQualifiedName); sl@0: INFO_PRINTF2(_L("Fully qualified name = %S"), &fileName); sl@0: } sl@0: sl@0: err = fs.Connect(); sl@0: if(err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Error occured while connecting to file server: %D"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: if(TestStepResult() == EPass) sl@0: { sl@0: err = fs.Delete(fileName); sl@0: if(err == KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("File deleted successfully")); sl@0: } sl@0: else if(err == KErrNotFound || err == KErrPathNotFound) sl@0: {// File or path not found, this is NOT considered as fail sl@0: INFO_PRINTF1(_L("File and/or path does not exist")); sl@0: } sl@0: else if(err == KErrNotReady) sl@0: {// Drive is not ready, this is NOT considered as fail sl@0: INFO_PRINTF1(_L("Drive not ready")); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Error occured while deleting file: %D"), err); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: fs.Close(); sl@0: } sl@0: } sl@0: return TestStepResult(); sl@0: } // doTestStepL