os/security/cryptoservices/filebasedcertificateandkeystores/test/tcertapps/t_certapps_actions.h
First public contribution.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
25 #ifndef __T_CERTAPPS_ACTIONS_H__
26 #define __T_CERTAPPS_ACTIONS_H__
28 #include "t_testhandler.h"
29 #include "t_testaction.h"
30 #include <certificateapps.h>
33 #include <mctcertapps.h>
37 // Base class which defines common actions
38 class CCertAppTestAction : public CTestAction
41 ~CCertAppTestAction();
43 // These methods have their default behaviour set to do nothing. May be
44 // overriden if required
45 virtual void PerformCancel();
47 virtual void InitialiseL(TBool& aMemFailureFlag,
48 TBool& aCancel, TInt& aHeapMark, TInt& aHeapMarkEnd);
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
54 virtual void PerformAction(TRequestStatus& aStatus);
57 CCertAppTestAction(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
59 // Chained 2nd phase constructor. All this does is extract the
61 void ConstructL(const TTestActionSpec& aTestActionSpec);
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);
69 // set the iExpectedResult parameter from a descriptor
70 virtual void SetExpectedResult(const TDesC8& aResult);
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);
78 // singleton instance of the app info manager - initialised by CInitManager
79 // and destroyed by CDestroyManager
80 static CCertificateAppInfoManager* iAppManager;
86 // template wrapper class which implements mundane operations required by the
89 class CTestWrapper : public T
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);
97 CTestWrapper(RFs& aFs, CConsoleBase& aConsole, Output& aOut) :
98 T(aFs, aConsole, aOut) {}
102 CTestAction* CTestWrapper<T>::NewL(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
104 CTestAction* self = CTestWrapper<T>::NewLC(aFs, aConsole, aOut, aTestActionSpec);
105 CleanupStack::Pop(self);
110 CTestAction* CTestWrapper<T>::NewLC(RFs& aFs, CConsoleBase& aConsole, Output& aOut, const TTestActionSpec& aTestActionSpec)
112 CTestWrapper<T>* self = new(ELeave) CTestWrapper<T>(aFs, aConsole, aOut);
113 CleanupStack::PushL(self);
114 self->ConstructL(aTestActionSpec);
118 // Initialises the iAppManager
119 class CInitManager : public CCertAppTestAction
121 // override the default prerequisite since this has to check that
122 // the manager does NOT exist
123 virtual void DoPerformPrerequisite(TRequestStatus& aStatus);
126 CInitManager(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
127 virtual void DoPerformActionL();
130 // destroys the iAppManager
131 class CDestroyManager : public CCertAppTestAction
134 CDestroyManager(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
135 virtual void DoPerformActionL();
138 // Clears all the applications from the app list
139 class CClearAllApps : public CCertAppTestAction
142 CClearAllApps(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
143 virtual void DoPerformActionL();
146 // Adds a new application
147 class CAddApp : public CCertAppTestAction
153 CAddApp(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
154 void ConstructL(const TTestActionSpec& aTestActionSpec);
155 virtual void DoPerformActionL();
158 // The CertApps to add
159 RArray<TCertificateAppInfo> iAppArray;
162 // Removes an application
163 class CRemoveApp : public CCertAppTestAction
166 CRemoveApp(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
167 void ConstructL(const TTestActionSpec& aTestActionSpec);
168 virtual void DoPerformActionL();
175 // Gets the application count
176 class CAppCount : public CCertAppTestAction
179 CAppCount(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
180 void ConstructL(const TTestActionSpec& aTestActionSpec);
181 virtual void DoPerformActionL();
184 TInt iCount; // number of apps expected
187 // Gets an application
188 class CGetApp : public CCertAppTestAction
191 CGetApp(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
192 void ConstructL(const TTestActionSpec& aTestActionSpec);
193 virtual void DoPerformActionL();
196 // The uid to retrieve and the name to expect
201 // Gets the applications
202 class CGetApplications : public CCertAppTestAction
208 CGetApplications(RFs& aFs, CConsoleBase& aConsole, Output& aOut);
209 void ConstructL(const TTestActionSpec& aTestActionSpec);
210 virtual void DoPerformActionL();
213 // The CertApps expected to be received
214 RArray<TCertificateAppInfo> iAppArray;
217 #endif // __T_CERTAPPS_ACTIONS_H__