os/security/cryptoservices/filebasedcertificateandkeystores/test/tcertapps/t_certapps_actions.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 *
    16 */
    17 
    18 
    19 
    20 
    21 /**
    22  @file
    23 */
    24 
    25 #ifndef __T_CERTAPPS_ACTIONS_H__
    26 #define __T_CERTAPPS_ACTIONS_H__
    27 
    28 #include "t_testhandler.h"
    29 #include "t_testaction.h"
    30 #include <certificateapps.h>
    31 #include <e32cons.h>
    32 #include <badesca.h>
    33 #include <mctcertapps.h>
    34 
    35 class Output;
    36 
    37 // Base class which defines common actions
    38 class CCertAppTestAction : public CTestAction
    39 	{
    40 public:
    41 	~CCertAppTestAction();
    42 
    43 	// These methods have their default behaviour set to do nothing. May be
    44 	// overriden if required
    45 	virtual void PerformCancel();
    46 	virtual void Reset();
    47 	virtual void InitialiseL(TBool& aMemFailureFlag,
    48 							 TBool& aCancel, TInt& aHeapMark, TInt& aHeapMarkEnd);
    49 
    50 	// This method calls the abstract leaving function DoPerformActionL, and
    51 	// returns its leaving status if there is an error. Since all certapps
    52 	// calls are synchronous, PerformAction will set the finished flag to
    53 	// true always
    54 	virtual void PerformAction(TRequestStatus& aStatus);
    55 
    56 protected:
    57 	CCertAppTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
    58 
    59 	// Chained 2nd phase constructor. All this does is extract the
    60 	// expected result
    61 	void ConstructL(const TTestActionSpec& aTestActionSpec);
    62 
    63 	virtual void DoPerformActionL() = 0;
    64 	virtual void DoPerformPrerequisite(TRequestStatus& aStatus);
    65 	virtual void DoPerformPostrequisite(TRequestStatus& aStatus);
    66 	virtual void DoReportAction();
    67 	virtual void DoCheckResult(TInt aError);
    68 
    69 	// set the iExpectedResult parameter from a descriptor
    70 	virtual void SetExpectedResult(const TDesC8& aResult);
    71 
    72 	// Parses a tag with <tagname>[TAG]</tagname> - makes a call
    73 	// to Input::ParseElement
    74 	static TPtrC8 ParseTagString(const TDesC8& aBuf, const TDesC8& aTagName, TInt& aPos, TInt& aError);
    75 	static TInt32 ParseTagInt(const TDesC8& aBuf, const TDesC8& aTagName, TInt& aPos, TInt& aError);
    76 
    77 protected:
    78 	// singleton instance of the app info manager - initialised by CInitManager
    79 	// and destroyed by CDestroyManager
    80 	static CCertificateAppInfoManager* iAppManager;
    81 
    82 private:
    83 	RFs& iFs;
    84 	};
    85 
    86 // template wrapper class which implements mundane operations required by the
    87 // test framework
    88 template <class T>
    89 class CTestWrapper : public T
    90 	{
    91 public:
    92 	static CTestAction* NewL(RFs& aFs, CConsoleBase& aConsole,	Output& aOut, const TTestActionSpec& aTestActionSpec);
    93 	static CTestAction* NewLC(RFs& aFs, CConsoleBase& aConsole,	Output& aOut, const TTestActionSpec& aTestActionSpec);
    94 	~CTestWrapper() {}
    95 
    96 protected:
    97 	CTestWrapper(RFs& aFs, CConsoleBase& aConsole, Output& aOut) :
    98 		 T(aFs, aConsole, aOut) {}
    99 	};
   100 
   101 template <class T>
   102 CTestAction* CTestWrapper<T>::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
   103 	{
   104 	CTestAction* self = CTestWrapper<T>::NewLC(aFs, aConsole, aOut,	aTestActionSpec);
   105 	CleanupStack::Pop(self);
   106 	return self;
   107 	}
   108 
   109 template <class T>
   110 CTestAction* CTestWrapper<T>::NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
   111 	{
   112 	CTestWrapper<T>* self = new(ELeave) CTestWrapper<T>(aFs, aConsole, aOut);
   113 	CleanupStack::PushL(self);
   114 	self->ConstructL(aTestActionSpec);
   115 	return self;
   116 	}
   117 
   118 // Initialises the iAppManager
   119 class CInitManager : public CCertAppTestAction
   120 	{
   121 	// override the default prerequisite since this has to check that
   122 	// the manager does NOT exist
   123 	virtual void DoPerformPrerequisite(TRequestStatus& aStatus);
   124 
   125 protected:
   126 	CInitManager(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   127 	virtual void DoPerformActionL();
   128 	};
   129 
   130 // destroys the iAppManager
   131 class CDestroyManager : public CCertAppTestAction
   132 	{
   133 protected:
   134 	CDestroyManager(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   135 	virtual void DoPerformActionL();
   136 	};
   137 
   138 // Clears all the applications from the app list
   139 class CClearAllApps : public CCertAppTestAction
   140 	{
   141 protected:
   142 	CClearAllApps(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   143 	virtual void DoPerformActionL();
   144 	};
   145 
   146 // Adds a new application
   147 class CAddApp : public CCertAppTestAction
   148 	{
   149 public:
   150 	~CAddApp();
   151 
   152 protected:
   153 	CAddApp(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   154 	void ConstructL(const TTestActionSpec& aTestActionSpec);
   155 	virtual void DoPerformActionL();
   156 
   157 private:
   158 	// The CertApps to add
   159 	RArray<TCertificateAppInfo> iAppArray;
   160 	};
   161 
   162 // Removes an application
   163 class CRemoveApp : public CCertAppTestAction
   164 	{
   165 protected:
   166 	CRemoveApp(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   167 	void ConstructL(const TTestActionSpec& aTestActionSpec);
   168 	virtual void DoPerformActionL();
   169 
   170 private:
   171 	// The UID to remove
   172 	TUid iUid;
   173 	};
   174 
   175 // Gets the application count
   176 class CAppCount : public CCertAppTestAction
   177 	{
   178 protected:
   179 	CAppCount(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   180 	void ConstructL(const TTestActionSpec& aTestActionSpec);
   181 	virtual void DoPerformActionL();
   182 
   183 private:
   184 	TInt iCount; // number of apps expected
   185 	};
   186 
   187 // Gets an application
   188 class CGetApp : public CCertAppTestAction
   189 	{
   190 protected:
   191 	CGetApp(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   192 	void ConstructL(const TTestActionSpec& aTestActionSpec);
   193 	virtual void DoPerformActionL();
   194 
   195 private:
   196 	// The uid to retrieve and the name to expect
   197 	TUid iUid;
   198 	TName iName;
   199 	};
   200 
   201 // Gets the applications
   202 class CGetApplications : public CCertAppTestAction
   203 	{
   204 public:
   205 	~CGetApplications();
   206 
   207 protected:
   208 	CGetApplications(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
   209 	void ConstructL(const TTestActionSpec& aTestActionSpec);
   210 	virtual void DoPerformActionL();
   211 
   212 private:
   213 	// The CertApps expected to be received
   214 	RArray<TCertificateAppInfo> iAppArray;
   215 	};
   216 
   217 #endif	//	__T_CERTAPPS_ACTIONS_H__