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