os/security/cryptomgmtlibs/securitytestfw/test/captestframework/captestutility.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-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 * Implements default base classes for captestframework
    16 *
    17 */
    18 
    19 
    20 
    21 
    22 /**
    23  @file
    24 */
    25 
    26 #ifndef CAPTESTUTILITY_H__
    27 #define CAPTESTUTILITY_H__
    28 
    29 #include <e32base.h>
    30 #include <s32file.h> 
    31 #include "captestframework.h"
    32 
    33 // CDefaultCapabilityTest
    34 class CDefaultCapabilityTest : public CBase, public MCapabilityTest
    35 	{
    36 public:
    37 	IMPORT_C const TDesC& Name() const;
    38 	IMPORT_C const TDesC& SubName() const;
    39 	
    40 	IMPORT_C TCapabilitySet CapabilitiesRequired() const;
    41 	IMPORT_C TUid VidRequired() const;
    42 	IMPORT_C TUid SidRequired() const;
    43 
    44 	IMPORT_C ~CDefaultCapabilityTest();
    45 	
    46 protected:
    47 	IMPORT_C void SetNameL(const TDesC& aName);	
    48 	void SetExpectPermissionDenied(TBool aExpectPermissionDenied = ETrue);	
    49 
    50 	IMPORT_C void SetCapabilityRequired(const TCapability& aCapability);
    51 	IMPORT_C void SetSidRequired(const TUid& aSid);
    52 	IMPORT_C void SetVidRequired(const TUid& aVid);
    53 	
    54 	IMPORT_C TInt CheckFailL(TInt aResult, const TDesC& aTestName);
    55 	IMPORT_C void RunTestL(RFile& aLogFile);
    56 
    57 	void SetFail() { iFail = ETrue;}
    58 	virtual void RunTestL() =0;
    59 private:
    60 	HBufC* iTestName;
    61 	HBufC* iTestSubName;
    62 	
    63 	RFile* iLogFile;
    64 	RFileWriteStream* iLogWriteStream;
    65 	TBool iExpectPermissionDenied;
    66 	TCapabilitySet iCapabilitySet;
    67 	TUid iVidRequired;
    68 	TUid iSidRequired;	
    69 	TBool iFail;
    70 	};
    71 
    72 // CDefaultCapabilityTestFactory
    73 class CDefaultCapabilityTestFactory : public CBase, public MCapabilityTestFactory
    74 
    75 	{
    76 public:
    77 	IMPORT_C virtual TInt NumberOfTests();
    78 	IMPORT_C virtual MCapabilityTest* Test(TInt aTestNumber);
    79 	
    80 	IMPORT_C void AddTestL(CDefaultCapabilityTest* aTest);
    81 
    82 	IMPORT_C ~CDefaultCapabilityTestFactory();
    83 	
    84 private:
    85 	RPointerArray<CDefaultCapabilityTest> iTests;
    86 	};
    87 
    88 // inline functions from CSwiCapabilityTest
    89 
    90 inline void CDefaultCapabilityTest::SetExpectPermissionDenied(TBool aExpectPermissionDenied)
    91 	{
    92 	iExpectPermissionDenied = aExpectPermissionDenied;
    93 	}
    94 
    95 #endif //#ifndef CAPTESTUTILITY_H__