1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/contentmgmt/referencedrmagent/tcaf/source/CleanupStep.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,110 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <test/testexecutelog.h>
1.23 +#include <apmstd.h>
1.24 +#include <f32file.h>
1.25 +#include <e32debug.h>
1.26 +#include <bautils.h>
1.27 +
1.28 +#include "CleanupStep.h"
1.29 +#include "cafserver.h"
1.30 +#include "manager.h"
1.31 +#include "dirstreamable.h"
1.32 +#include "virtualpathptr.h"
1.33 +#include "agent.h"
1.34 +#include "attributeset.h"
1.35 +#include "stringattributeset.h"
1.36 +#include "contentIterator.h"
1.37 +
1.38 +using namespace ContentAccess;
1.39 +
1.40 +_LIT(KDelDirTCAF,"C:\\tcaf\\");
1.41 +_LIT(KDelDirTCAFSub,"C:\\tcaf\\testdata\\");
1.42 +_LIT(KDelDirTCAFSub2,"C:\\tcaf\\testdata\\TestAgentPrivateDir\\");
1.43 +_LIT(KDelDirTCAFSub3,"C:\\tcaf\\tmtputils\\");
1.44 +
1.45 +_LIT(KDelDirTSCAF,"C:\\tcaf\\tscaf\\");
1.46 +_LIT(KDelDirTSCAFSub,"C:\\tcaf\\tscaf\\data\\");
1.47 +
1.48 +_LIT(KDelDirRTA,"C:\\rta\\");
1.49 +_LIT(KDelDirRTASub,"C:\\rta\\testdata\\");
1.50 +
1.51 +/*
1.52 + * This step deletes the test folders and files used in the CAF and RTA tests.
1.53 + */
1.54 +
1.55 +CCAFTestCleanupStep::~CCAFTestCleanupStep()
1.56 + {
1.57 + }
1.58 +
1.59 +CCAFTestCleanupStep::CCAFTestCleanupStep(CCAFServer& aParent) : iParent(aParent)
1.60 + {
1.61 + SetTestStepName(KCAFTestCleanupStep);
1.62 + }
1.63 +
1.64 +TVerdict CCAFTestCleanupStep::doTestStepL()
1.65 + {
1.66 + __UHEAP_MARK;
1.67 +
1.68 + SetTestStepResult(EPass);
1.69 + TInt err;
1.70 +
1.71 + RFs fs;
1.72 + fs.Connect();
1.73 + CFileMan* fileMan = CFileMan::NewL(fs);
1.74 + CleanupStack::PushL(fileMan);
1.75 +
1.76 + // Make the files writeable
1.77 + MakeFilesWritable(*fileMan, KDelDirTCAFSub2());
1.78 + MakeFilesWritable(*fileMan, KDelDirTCAFSub());
1.79 + MakeFilesWritable(*fileMan, KDelDirTCAFSub3());
1.80 + MakeFilesWritable(*fileMan, KDelDirTSCAFSub());
1.81 + MakeFilesWritable(*fileMan, KDelDirTSCAF());
1.82 + MakeFilesWritable(*fileMan, KDelDirTCAF());
1.83 +
1.84 + // Delete directory using CFileMan
1.85 + err = fileMan->RmDir(KDelDirTCAF);
1.86 + RDebug::Print(_L("CFileMan Delete file %S - err = %d\n"), &KDelDirTCAF, err);
1.87 + if((err!=KErrNone) && (err !=KErrPathNotFound))
1.88 + SetTestStepResult(EFail);
1.89 +
1.90 + // Make the files writeable
1.91 + MakeFilesWritable(*fileMan, KDelDirRTASub());
1.92 + MakeFilesWritable(*fileMan, KDelDirRTA());
1.93 +
1.94 + // Delete directory using CFileMan
1.95 + err = fileMan->RmDir(KDelDirRTA);
1.96 + RDebug::Print(_L("CFileMan Delete file %S - err = %d\n"), &KDelDirRTA, err);
1.97 + if((err!=KErrNone) && (err !=KErrPathNotFound))
1.98 + SetTestStepResult(EFail);
1.99 +
1.100 + CleanupStack::PopAndDestroy(fileMan);
1.101 + fs.Close();
1.102 +
1.103 + __UHEAP_MARKEND;
1.104 + return TestStepResult();
1.105 + }
1.106 +
1.107 +void CCAFTestCleanupStep::MakeFilesWritable(CFileMan& aFileMan, const TDesC& aDir)
1.108 + {
1.109 + TInt err = aFileMan.Attribs(aDir, 0, KEntryAttReadOnly, TTime(0), 0);
1.110 + if((err!=KErrNone) && (err !=KErrPathNotFound))
1.111 + SetTestStepResult(EFail);
1.112 + }
1.113 +