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