os/ossrv/genericservices/httputils/Test/Integration/TestFileUriSuite/TestDeleteFileStep.cpp
First public contribution.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include "TestDeleteFileStep.h"
25 Constructor. Sets the test step name
27 CTestDeleteFileStep::CTestDeleteFileStep()
29 //Call base class method to set human readable name for test step
30 SetTestStepName(KTestDeleteFileStep);
34 Tries to delete a file mentioned in the ini file.
37 @return EPass or EFail indicating the success or failure of file deletion.
39 TVerdict CTestDeleteFileStep::doTestStepL()
41 // Get file path and name from ini file
48 if (!GetStringFromConfig(ConfigSection(), KIniFileName, fileName))
50 ERR_PRINTF1(_L("Unable to read filename from ini file"));
51 SetTestStepResult(EFail);
55 INFO_PRINTF2(_L("File name = %S"), &fileName);
57 // check whether the filetype field exists in INI
58 if(GetStringFromConfig(ConfigSection(), KIniFileType, fileType))
60 INFO_PRINTF2(_L("File type = %S"), &fileType);
63 if(fileType == KFileTypePrivate)
64 {// The file is a private file. We require the drive too, as the path is relative
65 if (!GetStringFromConfig(ConfigSection(), KIniDrive, drive))
67 ERR_PRINTF1(_L("If file type is private, drive should be provided. Unable to read drive"));
68 SetTestStepResult(EFail);
69 return TestStepResult();
71 TFileName fullyQualifiedName(fileName);
72 // In the case of a secure vesrion of the OS
73 // As the INI file contains relative file-name for private files
74 // under the ExpectedFileName field, construct the fully-qualified
76 if((err = CTestFileUriServer::CreateFullyQualifiedName(fileName, drive, fullyQualifiedName)) != KErrNone)
78 ERR_PRINTF2(_L("Error returned by CTestFileUriServer::CreateFullyQualifiedName: %D"), err);
79 SetTestStepResult(EFail);
80 return TestStepResult();
82 fileName.Set(fullyQualifiedName);
83 INFO_PRINTF2(_L("Fully qualified name = %S"), &fileName);
89 ERR_PRINTF2(_L("Error occured while connecting to file server: %D"), err);
90 SetTestStepResult(EFail);
93 if(TestStepResult() == EPass)
95 err = fs.Delete(fileName);
98 INFO_PRINTF1(_L("File deleted successfully"));
100 else if(err == KErrNotFound || err == KErrPathNotFound)
101 {// File or path not found, this is NOT considered as fail
102 INFO_PRINTF1(_L("File and/or path does not exist"));
104 else if(err == KErrNotReady)
105 {// Drive is not ready, this is NOT considered as fail
106 INFO_PRINTF1(_L("Drive not ready"));
110 ERR_PRINTF2(_L("Error occured while deleting file: %D"), err);
111 SetTestStepResult(EFail);
116 return TestStepResult();