os/security/contentmgmt/referencedrmagent/tcaf/source/CleanupStep.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include <test/testexecutelog.h>
    20 #include <apmstd.h>
    21 #include <f32file.h>
    22 #include <e32debug.h>
    23 #include <bautils.h>
    24 
    25 #include "CleanupStep.h"
    26 #include "cafserver.h"
    27 #include "manager.h"
    28 #include "dirstreamable.h"
    29 #include "virtualpathptr.h"
    30 #include "agent.h"
    31 #include "attributeset.h"
    32 #include "stringattributeset.h"
    33 #include "contentIterator.h"
    34 
    35 using namespace ContentAccess;
    36 
    37 _LIT(KDelDirTCAF,"C:\\tcaf\\");
    38 _LIT(KDelDirTCAFSub,"C:\\tcaf\\testdata\\");
    39 _LIT(KDelDirTCAFSub2,"C:\\tcaf\\testdata\\TestAgentPrivateDir\\");
    40 _LIT(KDelDirTCAFSub3,"C:\\tcaf\\tmtputils\\");
    41 
    42 _LIT(KDelDirTSCAF,"C:\\tcaf\\tscaf\\");
    43 _LIT(KDelDirTSCAFSub,"C:\\tcaf\\tscaf\\data\\");
    44 
    45 _LIT(KDelDirRTA,"C:\\rta\\");
    46 _LIT(KDelDirRTASub,"C:\\rta\\testdata\\");
    47 
    48 /* 
    49  * This step deletes the test folders and files used in the CAF and RTA tests.
    50  */
    51 
    52 CCAFTestCleanupStep::~CCAFTestCleanupStep()
    53 	{
    54 	}
    55 
    56 CCAFTestCleanupStep::CCAFTestCleanupStep(CCAFServer& aParent) : iParent(aParent)
    57 	{
    58 	SetTestStepName(KCAFTestCleanupStep);
    59 	}
    60 
    61 TVerdict CCAFTestCleanupStep::doTestStepL()
    62 	{
    63 	__UHEAP_MARK;
    64 	
    65 	SetTestStepResult(EPass);
    66 	TInt err;  
    67 	
    68 	RFs fs;
    69 	fs.Connect();
    70 	CFileMan* fileMan = CFileMan::NewL(fs);
    71 	CleanupStack::PushL(fileMan);
    72 
    73     // Make the files writeable 
    74 	MakeFilesWritable(*fileMan, KDelDirTCAFSub2());
    75 	MakeFilesWritable(*fileMan, KDelDirTCAFSub());
    76 	MakeFilesWritable(*fileMan, KDelDirTCAFSub3());
    77 	MakeFilesWritable(*fileMan, KDelDirTSCAFSub());
    78 	MakeFilesWritable(*fileMan, KDelDirTSCAF());
    79 	MakeFilesWritable(*fileMan, KDelDirTCAF());
    80     
    81     // Delete directory using CFileMan
    82     err = fileMan->RmDir(KDelDirTCAF);
    83     RDebug::Print(_L("CFileMan Delete file %S - err = %d\n"), &KDelDirTCAF, err);
    84     if((err!=KErrNone) && (err !=KErrPathNotFound))
    85    		SetTestStepResult(EFail);
    86 
    87     // Make the files writeable 
    88     MakeFilesWritable(*fileMan, KDelDirRTASub());
    89     MakeFilesWritable(*fileMan, KDelDirRTA());
    90     
    91     // Delete directory using CFileMan
    92    	err = fileMan->RmDir(KDelDirRTA); 
    93     RDebug::Print(_L("CFileMan Delete file %S - err = %d\n"), &KDelDirRTA, err); 
    94     if((err!=KErrNone) && (err !=KErrPathNotFound))
    95  	  	SetTestStepResult(EFail);
    96     
    97 	CleanupStack::PopAndDestroy(fileMan); 
    98     fs.Close();
    99    			
   100 	__UHEAP_MARKEND;
   101 	return TestStepResult();
   102 	}
   103 
   104 void CCAFTestCleanupStep::MakeFilesWritable(CFileMan& aFileMan, const TDesC& aDir)
   105 	{
   106 	TInt err = aFileMan.Attribs(aDir, 0, KEntryAttReadOnly, TTime(0), 0);
   107     if((err!=KErrNone) && (err !=KErrPathNotFound))
   108    		SetTestStepResult(EFail);
   109 	}
   110