sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2001-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 <e32test.h>
|
sl@0
|
20 |
#include <ct.h>
|
sl@0
|
21 |
#include <f32file.h>
|
sl@0
|
22 |
#include "MTestInterface.h"
|
sl@0
|
23 |
#include <ecom/ecom.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
RTest test(_L("CT Framework Tests"));
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
|
sl@0
|
29 |
TBool gLogging=ETrue;
|
sl@0
|
30 |
TBool gSilent=EFalse;
|
sl@0
|
31 |
|
sl@0
|
32 |
const TInt gInterfaceA = 0x101f4e50;
|
sl@0
|
33 |
const TInt gInterfaceB = 0x101f4e51;
|
sl@0
|
34 |
const TInt gInterfaceC = 0x101f4e52;
|
sl@0
|
35 |
|
sl@0
|
36 |
const TInt gAttribute1 = 0x101f4e4a;
|
sl@0
|
37 |
const TInt gAttribute2 = 0x101f4e4b;
|
sl@0
|
38 |
|
sl@0
|
39 |
const TInt gImplementation6 = 0x101f4e4c;
|
sl@0
|
40 |
const TInt gImplementation5 = 0x101f4e4d;
|
sl@0
|
41 |
|
sl@0
|
42 |
class CTestConsole:public CConsoleBase
|
sl@0
|
43 |
|
sl@0
|
44 |
{
|
sl@0
|
45 |
public:
|
sl@0
|
46 |
static CTestConsole* NewL(CConsoleBase* aCon);
|
sl@0
|
47 |
TInt Create(const TDesC16& aTitle,TSize aSize) {return iCon->Create(aTitle,aSize);};
|
sl@0
|
48 |
void Read(TRequestStatus& aStatus) {iCon->Read(aStatus);};
|
sl@0
|
49 |
void ReadCancel(void) {iCon->ReadCancel();};
|
sl@0
|
50 |
void Write(const TDesC16& aString);
|
sl@0
|
51 |
TPoint CursorPos(void) const {return iCon->CursorPos();};
|
sl@0
|
52 |
void SetCursorPosAbs(const TPoint& aPos) {iCon->SetCursorPosAbs(aPos);};
|
sl@0
|
53 |
void SetCursorPosRel(const TPoint& aPos) {iCon->SetCursorPosRel(aPos);};
|
sl@0
|
54 |
void SetCursorHeight(TInt aHeight) {iCon->SetCursorHeight(aHeight);};
|
sl@0
|
55 |
void SetTitle(const TDesC16& aTitle) {iCon->SetTitle(aTitle);};
|
sl@0
|
56 |
void ClearScreen(void) {iCon->ClearScreen();};
|
sl@0
|
57 |
void ClearToEndOfLine(void) {iCon->ClearToEndOfLine();};
|
sl@0
|
58 |
TSize ScreenSize(void) const {return iCon->ScreenSize();};
|
sl@0
|
59 |
TKeyCode KeyCode(void) const {return iCon->KeyCode();};
|
sl@0
|
60 |
TUint KeyModifiers(void) const {return iCon->KeyModifiers();};
|
sl@0
|
61 |
~CTestConsole(void);
|
sl@0
|
62 |
void SetLogFile(RFile* aFile);
|
sl@0
|
63 |
private:
|
sl@0
|
64 |
CTestConsole(void);
|
sl@0
|
65 |
CConsoleBase* iCon;
|
sl@0
|
66 |
RFile* iFile;
|
sl@0
|
67 |
};
|
sl@0
|
68 |
|
sl@0
|
69 |
CTestConsole* CTestConsole::NewL(CConsoleBase* aCon)
|
sl@0
|
70 |
|
sl@0
|
71 |
{
|
sl@0
|
72 |
CTestConsole* self;
|
sl@0
|
73 |
self=new (ELeave) CTestConsole;
|
sl@0
|
74 |
self->iCon=aCon;
|
sl@0
|
75 |
self->iFile=NULL;
|
sl@0
|
76 |
return self;
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
CTestConsole::CTestConsole(void):CConsoleBase()
|
sl@0
|
80 |
|
sl@0
|
81 |
{
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
CTestConsole::~CTestConsole(void)
|
sl@0
|
85 |
|
sl@0
|
86 |
{
|
sl@0
|
87 |
delete iCon;
|
sl@0
|
88 |
if (iFile)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
iFile->Close();
|
sl@0
|
91 |
}
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
void CTestConsole::Write(const TDesC16& aString)
|
sl@0
|
95 |
|
sl@0
|
96 |
{
|
sl@0
|
97 |
if (gSilent)
|
sl@0
|
98 |
return;
|
sl@0
|
99 |
iCon->Write(aString);
|
sl@0
|
100 |
if ((iFile)&&(gLogging))
|
sl@0
|
101 |
{
|
sl@0
|
102 |
TUint8 space[200];
|
sl@0
|
103 |
TPtr8 ptr(space,200);
|
sl@0
|
104 |
ptr.Copy(aString);
|
sl@0
|
105 |
iFile->Write(ptr);
|
sl@0
|
106 |
}
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
void CTestConsole::SetLogFile(RFile* aFile)
|
sl@0
|
110 |
|
sl@0
|
111 |
{
|
sl@0
|
112 |
iFile=aFile;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
template <class T> class TTestArray
|
sl@0
|
116 |
{
|
sl@0
|
117 |
public:
|
sl@0
|
118 |
TTestArray(T* aArray, TInt aCount);
|
sl@0
|
119 |
TArray<T> Array();
|
sl@0
|
120 |
private:
|
sl@0
|
121 |
static TInt Count(const CBase* aThat);
|
sl@0
|
122 |
static const TAny* Get(const CBase* aThat, TInt aIndex);
|
sl@0
|
123 |
|
sl@0
|
124 |
T* iArray;
|
sl@0
|
125 |
TInt iCount;
|
sl@0
|
126 |
};
|
sl@0
|
127 |
|
sl@0
|
128 |
template <class T> TTestArray<T>::TTestArray(T* aArray, TInt aCount)
|
sl@0
|
129 |
: iArray(aArray), iCount(aCount)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
template <class T> TInt TTestArray<T>::Count(const CBase* aThat)
|
sl@0
|
134 |
{
|
sl@0
|
135 |
return reinterpret_cast<const TTestArray*>(aThat)->iCount;
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
template <class T> const TAny* TTestArray<T>::Get(const CBase* aThat, TInt aIndex)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
return &reinterpret_cast<const TTestArray*>(aThat)->iArray[aIndex];
|
sl@0
|
141 |
}
|
sl@0
|
142 |
|
sl@0
|
143 |
template <class T> TArray<T> TTestArray<T>::Array()
|
sl@0
|
144 |
{
|
sl@0
|
145 |
return TArray<T>(Count, Get, reinterpret_cast<CBase*>(this));
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|
sl@0
|
148 |
/** A filter that includes nothing (as a random easy-to-write test filter */
|
sl@0
|
149 |
class TNoTokenTypes : public MCTTokenTypeFilter
|
sl@0
|
150 |
{
|
sl@0
|
151 |
public:
|
sl@0
|
152 |
/** Always returns EFalse. */
|
sl@0
|
153 |
virtual TBool Accept(const CCTTokenTypeInfo& aTokenType) const;
|
sl@0
|
154 |
};
|
sl@0
|
155 |
|
sl@0
|
156 |
// Accept everything
|
sl@0
|
157 |
TBool TNoTokenTypes::Accept(const CCTTokenTypeInfo&) const
|
sl@0
|
158 |
{
|
sl@0
|
159 |
return EFalse;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
class CStopScheduler : public CActive
|
sl@0
|
163 |
{
|
sl@0
|
164 |
public:
|
sl@0
|
165 |
void DoCancel() {};
|
sl@0
|
166 |
void RunL();
|
sl@0
|
167 |
CStopScheduler();
|
sl@0
|
168 |
};
|
sl@0
|
169 |
|
sl@0
|
170 |
void CStopScheduler::RunL()
|
sl@0
|
171 |
{
|
sl@0
|
172 |
CActiveScheduler::Stop();
|
sl@0
|
173 |
};
|
sl@0
|
174 |
|
sl@0
|
175 |
CStopScheduler::CStopScheduler()
|
sl@0
|
176 |
: CActive(EPriorityIdle)
|
sl@0
|
177 |
{
|
sl@0
|
178 |
CActiveScheduler::Add(this);
|
sl@0
|
179 |
SetActive();
|
sl@0
|
180 |
TRequestStatus* r = &iStatus;
|
sl@0
|
181 |
User::RequestComplete(r, KErrNone);
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
TInt TokenTypeInfoListTestsL()
|
sl@0
|
185 |
{
|
sl@0
|
186 |
test.Printf(_L("1.1,Testing getting all token types,"));
|
sl@0
|
187 |
RCPointerArray<CCTTokenTypeInfo> myTokenTypes;
|
sl@0
|
188 |
CleanupClosePushL(myTokenTypes);
|
sl@0
|
189 |
|
sl@0
|
190 |
CCTTokenTypeInfo::ListL(myTokenTypes);
|
sl@0
|
191 |
|
sl@0
|
192 |
if (myTokenTypes.Count() < 6)
|
sl@0
|
193 |
{
|
sl@0
|
194 |
CleanupStack::PopAndDestroy();
|
sl@0
|
195 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
196 |
return (1);
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
myTokenTypes.ResetAndDestroy();
|
sl@0
|
200 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
201 |
|
sl@0
|
202 |
test.Printf(_L("1.2,Testing user-supplied filter,"));
|
sl@0
|
203 |
TNoTokenTypes filter;
|
sl@0
|
204 |
CCTTokenTypeInfo::ListL(myTokenTypes, filter);
|
sl@0
|
205 |
|
sl@0
|
206 |
if (myTokenTypes.Count() > 0)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
CleanupStack::PopAndDestroy();
|
sl@0
|
209 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
210 |
return (2);
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
myTokenTypes.ResetAndDestroy();
|
sl@0
|
214 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
215 |
|
sl@0
|
216 |
test.Printf(_L("1.3,Testing finding filters matching 1 interface,"));
|
sl@0
|
217 |
RArray<TUid> a;
|
sl@0
|
218 |
TUid aa = {gInterfaceA};
|
sl@0
|
219 |
User::LeaveIfError(a.Append(aa));
|
sl@0
|
220 |
CleanupClosePushL(a);
|
sl@0
|
221 |
TCTFindTokenTypesByInterface findA(a.Array());
|
sl@0
|
222 |
CCTTokenTypeInfo::ListL(myTokenTypes, findA);
|
sl@0
|
223 |
if (myTokenTypes.Count() != 4)
|
sl@0
|
224 |
{
|
sl@0
|
225 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
226 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
227 |
return (3);
|
sl@0
|
228 |
}
|
sl@0
|
229 |
TInt findAResults[] = {1,4,5,6};
|
sl@0
|
230 |
TInt flag[] = {1,1,1,1};
|
sl@0
|
231 |
for (TInt ii = 0; ii < 4; ii++)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
TInt count = 0;
|
sl@0
|
234 |
TInt iii=0;
|
sl@0
|
235 |
TBuf<20> matchString;
|
sl@0
|
236 |
_LIT(format, "Test Token Type %d");
|
sl@0
|
237 |
matchString.Format(format, findAResults[iii]);
|
sl@0
|
238 |
TBuf<20> idisplay_name= myTokenTypes[ii]->Label();
|
sl@0
|
239 |
|
sl@0
|
240 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
241 |
count++;
|
sl@0
|
242 |
else
|
sl@0
|
243 |
{
|
sl@0
|
244 |
if(flag[0]==1)
|
sl@0
|
245 |
flag[0]=0;
|
sl@0
|
246 |
else
|
sl@0
|
247 |
count++;
|
sl@0
|
248 |
}
|
sl@0
|
249 |
matchString.Format(format, findAResults[iii+1]);
|
sl@0
|
250 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
251 |
count++;
|
sl@0
|
252 |
else
|
sl@0
|
253 |
{
|
sl@0
|
254 |
if(flag[1]==1)
|
sl@0
|
255 |
flag[1]=0;
|
sl@0
|
256 |
else
|
sl@0
|
257 |
count++;
|
sl@0
|
258 |
}
|
sl@0
|
259 |
matchString.Format(format, findAResults[iii+2]);
|
sl@0
|
260 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
261 |
count++;
|
sl@0
|
262 |
else
|
sl@0
|
263 |
{
|
sl@0
|
264 |
if(flag[2]==1)
|
sl@0
|
265 |
flag[2]=0;
|
sl@0
|
266 |
else
|
sl@0
|
267 |
count++;
|
sl@0
|
268 |
}
|
sl@0
|
269 |
matchString.Format(format, findAResults[iii+3]);
|
sl@0
|
270 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
271 |
count++;
|
sl@0
|
272 |
else
|
sl@0
|
273 |
{
|
sl@0
|
274 |
if(flag[3]==1)
|
sl@0
|
275 |
flag[3]=0;
|
sl@0
|
276 |
else
|
sl@0
|
277 |
count++;
|
sl@0
|
278 |
}
|
sl@0
|
279 |
if(count==4)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
282 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
283 |
return (4);
|
sl@0
|
284 |
}
|
sl@0
|
285 |
}
|
sl@0
|
286 |
|
sl@0
|
287 |
myTokenTypes.ResetAndDestroy();
|
sl@0
|
288 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
289 |
|
sl@0
|
290 |
test.Printf(_L("1.5,Testing finding filters matching 2 interfaces,"));
|
sl@0
|
291 |
TUid aAndB[] = {{gInterfaceA}, {gInterfaceB}};
|
sl@0
|
292 |
TTestArray<TUid> aAndBArray(aAndB, 2);
|
sl@0
|
293 |
TCTFindTokenTypesByInterface findAAndB(aAndBArray.Array());
|
sl@0
|
294 |
CCTTokenTypeInfo::ListL(myTokenTypes, findAAndB);
|
sl@0
|
295 |
if (myTokenTypes.Count() != 2)
|
sl@0
|
296 |
{
|
sl@0
|
297 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
298 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
299 |
return (5);
|
sl@0
|
300 |
}
|
sl@0
|
301 |
TInt findAAndBResults[] = {4,6};
|
sl@0
|
302 |
TInt flag1[] = {1,1};
|
sl@0
|
303 |
for (TInt jj = 0; jj < 2; jj++)
|
sl@0
|
304 |
{
|
sl@0
|
305 |
TInt count = 0;
|
sl@0
|
306 |
TInt jjj=0;
|
sl@0
|
307 |
TBuf<20> matchString;
|
sl@0
|
308 |
_LIT(format, "Test Token Type %d");
|
sl@0
|
309 |
matchString.Format(format, findAAndBResults[jjj]);
|
sl@0
|
310 |
TBuf<20> idisplay_name = myTokenTypes[jj]->Label();
|
sl@0
|
311 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
312 |
count++;
|
sl@0
|
313 |
else
|
sl@0
|
314 |
{
|
sl@0
|
315 |
if(flag1[0]==1)
|
sl@0
|
316 |
flag1[0]=0;
|
sl@0
|
317 |
else
|
sl@0
|
318 |
count++;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
matchString.Format(format, findAAndBResults[jjj+1]);
|
sl@0
|
321 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
322 |
count++;
|
sl@0
|
323 |
else
|
sl@0
|
324 |
{
|
sl@0
|
325 |
if(flag1[1]==1)
|
sl@0
|
326 |
flag1[1]=0;
|
sl@0
|
327 |
else
|
sl@0
|
328 |
count++;
|
sl@0
|
329 |
}
|
sl@0
|
330 |
if(count==2)
|
sl@0
|
331 |
{
|
sl@0
|
332 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
333 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
334 |
return (6);
|
sl@0
|
335 |
}
|
sl@0
|
336 |
}
|
sl@0
|
337 |
|
sl@0
|
338 |
// NOTE No ResetAndDestroy
|
sl@0
|
339 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
340 |
|
sl@0
|
341 |
test.Printf(_L("1.6,Testing appending interface infos,"));
|
sl@0
|
342 |
CCTTokenTypeInfo::ListL(myTokenTypes, findA);
|
sl@0
|
343 |
if (myTokenTypes.Count() != 6)
|
sl@0
|
344 |
{
|
sl@0
|
345 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
346 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
347 |
return (7);
|
sl@0
|
348 |
}
|
sl@0
|
349 |
TInt flag2[] = {1,1,1,1};
|
sl@0
|
350 |
for (TInt kk = 0; kk < 4; kk++)
|
sl@0
|
351 |
{
|
sl@0
|
352 |
TInt count = 0;
|
sl@0
|
353 |
TInt kkk=0;
|
sl@0
|
354 |
TBuf<20> matchString;
|
sl@0
|
355 |
_LIT(format, "Test Token Type %d");
|
sl@0
|
356 |
matchString.Format(format, findAResults[kkk]);
|
sl@0
|
357 |
TBuf<20> idisplay_name = myTokenTypes[kk+2]->Label();
|
sl@0
|
358 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
359 |
count++;
|
sl@0
|
360 |
else
|
sl@0
|
361 |
{
|
sl@0
|
362 |
if(flag2[0]==1)
|
sl@0
|
363 |
flag2[0]=0;
|
sl@0
|
364 |
else
|
sl@0
|
365 |
count++;
|
sl@0
|
366 |
}
|
sl@0
|
367 |
matchString.Format(format, findAResults[kkk+1]);
|
sl@0
|
368 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
369 |
count++;
|
sl@0
|
370 |
else
|
sl@0
|
371 |
{
|
sl@0
|
372 |
if(flag2[1]==1)
|
sl@0
|
373 |
flag2[1]=0;
|
sl@0
|
374 |
else
|
sl@0
|
375 |
count++;
|
sl@0
|
376 |
}
|
sl@0
|
377 |
matchString.Format(format, findAResults[kkk+2]);
|
sl@0
|
378 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
379 |
count++;
|
sl@0
|
380 |
else
|
sl@0
|
381 |
{
|
sl@0
|
382 |
if(flag2[2]==1)
|
sl@0
|
383 |
flag2[2]=0;
|
sl@0
|
384 |
else
|
sl@0
|
385 |
count++;
|
sl@0
|
386 |
}
|
sl@0
|
387 |
matchString.Format(format, findAResults[kkk+3]);
|
sl@0
|
388 |
if (matchString.Compare(idisplay_name))
|
sl@0
|
389 |
count++;
|
sl@0
|
390 |
else
|
sl@0
|
391 |
{
|
sl@0
|
392 |
if(flag2[3]==1)
|
sl@0
|
393 |
flag2[3]=0;
|
sl@0
|
394 |
else
|
sl@0
|
395 |
count++;
|
sl@0
|
396 |
}
|
sl@0
|
397 |
if(count==4)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
400 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
401 |
return (8);
|
sl@0
|
402 |
}
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
406 |
|
sl@0
|
407 |
myTokenTypes.ResetAndDestroy();
|
sl@0
|
408 |
test.Printf(_L("1.7,Testing filtering by interface and attribute,"));
|
sl@0
|
409 |
TCTTokenTypeAttribute att = {{gAttribute1}, 1};
|
sl@0
|
410 |
RArray<TCTTokenTypeAttribute> attArray(sizeof(TCTTokenTypeAttribute), &att,
|
sl@0
|
411 |
1);
|
sl@0
|
412 |
TCTFindTokenTypesByInterfaceAndAttribute findAWithAtt1(a.Array(),
|
sl@0
|
413 |
attArray.Array());
|
sl@0
|
414 |
CCTTokenTypeInfo::ListL(myTokenTypes, findAWithAtt1);
|
sl@0
|
415 |
if (myTokenTypes.Count() != 1)
|
sl@0
|
416 |
{
|
sl@0
|
417 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
418 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
419 |
return (9);
|
sl@0
|
420 |
}
|
sl@0
|
421 |
_LIT(KMatch, "Test Token Type 6");
|
sl@0
|
422 |
if (myTokenTypes[0]->Label() != KMatch)
|
sl@0
|
423 |
{
|
sl@0
|
424 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
425 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
426 |
return (10);
|
sl@0
|
427 |
}
|
sl@0
|
428 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
429 |
|
sl@0
|
430 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
431 |
return KErrNone;
|
sl@0
|
432 |
};
|
sl@0
|
433 |
|
sl@0
|
434 |
TInt TokenTypeInfoTestsL()
|
sl@0
|
435 |
{
|
sl@0
|
436 |
test.Printf(_L("2.1,Testing token type for tests,"));
|
sl@0
|
437 |
RCPointerArray<CCTTokenTypeInfo> myTokenTypes;
|
sl@0
|
438 |
CleanupClosePushL(myTokenTypes);
|
sl@0
|
439 |
TUid aABndC[] = {{gInterfaceA}, {gInterfaceB}, {gInterfaceC}};
|
sl@0
|
440 |
TTestArray<TUid> aABndCArray(aABndC, 3);
|
sl@0
|
441 |
TCTFindTokenTypesByInterface findABAndC(aABndCArray.Array());
|
sl@0
|
442 |
CCTTokenTypeInfo::ListL(myTokenTypes, findABAndC);
|
sl@0
|
443 |
if (myTokenTypes.Count() != 1)
|
sl@0
|
444 |
{
|
sl@0
|
445 |
CleanupStack::PopAndDestroy();
|
sl@0
|
446 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
447 |
return (1);
|
sl@0
|
448 |
}
|
sl@0
|
449 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
450 |
|
sl@0
|
451 |
test.Printf(_L("2.2,Test UID function,"));
|
sl@0
|
452 |
CCTTokenTypeInfo* info = myTokenTypes[0];
|
sl@0
|
453 |
if (info->Type().iUid != gImplementation6)
|
sl@0
|
454 |
{
|
sl@0
|
455 |
CleanupStack::PopAndDestroy();
|
sl@0
|
456 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
457 |
return (1);
|
sl@0
|
458 |
}
|
sl@0
|
459 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
460 |
|
sl@0
|
461 |
test.Printf(_L("2.3,Test getting an array of interfaces,"));
|
sl@0
|
462 |
RArray<TUid> interfaces = info->Interfaces();
|
sl@0
|
463 |
if (interfaces.Count() != 3)
|
sl@0
|
464 |
{
|
sl@0
|
465 |
CleanupStack::PopAndDestroy();
|
sl@0
|
466 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
467 |
return (4);
|
sl@0
|
468 |
}
|
sl@0
|
469 |
TUid refInterfaces[] = {{gInterfaceA}, {gInterfaceB}, {gInterfaceC}};
|
sl@0
|
470 |
for (TInt ii = 0; ii < 3; ii++)
|
sl@0
|
471 |
{
|
sl@0
|
472 |
if (interfaces[ii] != refInterfaces[ii])
|
sl@0
|
473 |
{
|
sl@0
|
474 |
CleanupStack::PopAndDestroy();
|
sl@0
|
475 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
476 |
return (5);
|
sl@0
|
477 |
}
|
sl@0
|
478 |
}
|
sl@0
|
479 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
480 |
|
sl@0
|
481 |
test.Printf(_L("2.4,Test getting an array of attributes,"));
|
sl@0
|
482 |
RArray<TCTTokenTypeAttribute> attributes = info->Attributes();
|
sl@0
|
483 |
if (attributes.Count() != 2)
|
sl@0
|
484 |
{
|
sl@0
|
485 |
CleanupStack::PopAndDestroy();
|
sl@0
|
486 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
487 |
return (8);
|
sl@0
|
488 |
}
|
sl@0
|
489 |
TCTTokenTypeAttribute refAttributes[] =
|
sl@0
|
490 |
{{{gAttribute2}, 2}, {{gAttribute1}, 1}};
|
sl@0
|
491 |
for (TInt jj = 0; jj < 2; jj++)
|
sl@0
|
492 |
{
|
sl@0
|
493 |
if (attributes[jj].iUID != refAttributes[jj].iUID ||
|
sl@0
|
494 |
attributes[jj].iVal != refAttributes[jj].iVal)
|
sl@0
|
495 |
{
|
sl@0
|
496 |
CleanupStack::PopAndDestroy();
|
sl@0
|
497 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
498 |
return (9);
|
sl@0
|
499 |
}
|
sl@0
|
500 |
}
|
sl@0
|
501 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
502 |
|
sl@0
|
503 |
test.Printf(_L("2.5,Test getting the label,"));
|
sl@0
|
504 |
_LIT(KLabel, "Test Token Type 6");
|
sl@0
|
505 |
if (info->Label() != KLabel)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
CleanupStack::PopAndDestroy();
|
sl@0
|
508 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
509 |
return (10);
|
sl@0
|
510 |
}
|
sl@0
|
511 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
512 |
|
sl@0
|
513 |
test.Printf(_L("2.6,Test getting the type of the token type,"));
|
sl@0
|
514 |
TUid impl6 = {gImplementation6};
|
sl@0
|
515 |
if (info->Type() != impl6)
|
sl@0
|
516 |
{
|
sl@0
|
517 |
CleanupStack::PopAndDestroy();
|
sl@0
|
518 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
519 |
return (11);
|
sl@0
|
520 |
}
|
sl@0
|
521 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
522 |
|
sl@0
|
523 |
CleanupStack::PopAndDestroy();
|
sl@0
|
524 |
return KErrNone;
|
sl@0
|
525 |
}
|
sl@0
|
526 |
|
sl@0
|
527 |
|
sl@0
|
528 |
TInt TestTokenTypeL(MCTTokenType* aTokenType, TInt aNum)
|
sl@0
|
529 |
{
|
sl@0
|
530 |
test.Printf(_L("3.4.1,Getting token info,"));
|
sl@0
|
531 |
RCPointerArray<HBufC> tokenInfo;
|
sl@0
|
532 |
CleanupClosePushL(tokenInfo);
|
sl@0
|
533 |
TRequestStatus status = KRequestPending;
|
sl@0
|
534 |
aTokenType->List(tokenInfo, status);
|
sl@0
|
535 |
// Cancel call is pointelss as it does nothing in the test
|
sl@0
|
536 |
// plugin. But it won't do any harm to check it doesn't explode.
|
sl@0
|
537 |
aTokenType->CancelList();
|
sl@0
|
538 |
User::WaitForRequest(status);
|
sl@0
|
539 |
if (status.Int() != KErrNone || tokenInfo.Count() != 1)
|
sl@0
|
540 |
{
|
sl@0
|
541 |
CleanupStack::PopAndDestroy();
|
sl@0
|
542 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
543 |
return (100);
|
sl@0
|
544 |
}
|
sl@0
|
545 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
546 |
|
sl@0
|
547 |
test.Printf(_L("3.4.1,Checking token type name,"));
|
sl@0
|
548 |
TBuf<20> buf;
|
sl@0
|
549 |
_LIT(KLabelFormat, "Test Token Type %d");
|
sl@0
|
550 |
buf.Format(KLabelFormat, aNum);
|
sl@0
|
551 |
if (aTokenType->Label().Compare(buf))
|
sl@0
|
552 |
{
|
sl@0
|
553 |
CleanupStack::PopAndDestroy();
|
sl@0
|
554 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
555 |
return (105);
|
sl@0
|
556 |
}
|
sl@0
|
557 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
558 |
|
sl@0
|
559 |
test.Printf(_L("3.4.2,Checking token type Type UID,"));
|
sl@0
|
560 |
TUid uid = {gImplementation5 + 5 - aNum};
|
sl@0
|
561 |
if (aTokenType->Type() != uid)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
CleanupStack::PopAndDestroy();
|
sl@0
|
564 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
565 |
return (105);
|
sl@0
|
566 |
}
|
sl@0
|
567 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
568 |
|
sl@0
|
569 |
test.Printf(_L("3.4.3,Checking token name,"));
|
sl@0
|
570 |
_LIT(KFormat, "Test Token %d");
|
sl@0
|
571 |
buf.Format(KFormat, aNum);
|
sl@0
|
572 |
if (buf.Compare(*tokenInfo[0]))
|
sl@0
|
573 |
{
|
sl@0
|
574 |
CleanupStack::PopAndDestroy();
|
sl@0
|
575 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
576 |
return (101);
|
sl@0
|
577 |
}
|
sl@0
|
578 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
579 |
|
sl@0
|
580 |
test.Printf(_L("3.4.4,Opening token,"));
|
sl@0
|
581 |
status = KRequestPending;
|
sl@0
|
582 |
MCTToken* token;
|
sl@0
|
583 |
aTokenType->OpenToken(*tokenInfo[0], token, status);
|
sl@0
|
584 |
// Cancel call will fail as token isn't opened asynchronous. Check
|
sl@0
|
585 |
// that the reference counting still works.
|
sl@0
|
586 |
aTokenType->CancelOpenToken();
|
sl@0
|
587 |
User::WaitForRequest(status);
|
sl@0
|
588 |
if (status.Int() != KErrNone)
|
sl@0
|
589 |
{
|
sl@0
|
590 |
CleanupStack::PopAndDestroy();
|
sl@0
|
591 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
592 |
return (102);
|
sl@0
|
593 |
}
|
sl@0
|
594 |
token->Release();
|
sl@0
|
595 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
596 |
|
sl@0
|
597 |
test.Printf(_L("3.4.5,Opening token by handle,"));
|
sl@0
|
598 |
status = KRequestPending;
|
sl@0
|
599 |
TCTTokenHandle handle(aTokenType->Type(), 1);
|
sl@0
|
600 |
aTokenType->OpenToken(handle, token, status);
|
sl@0
|
601 |
User::WaitForRequest(status);
|
sl@0
|
602 |
if (status.Int() != KErrNone)
|
sl@0
|
603 |
{
|
sl@0
|
604 |
CleanupStack::PopAndDestroy();
|
sl@0
|
605 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
606 |
return (102);
|
sl@0
|
607 |
}
|
sl@0
|
608 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
609 |
|
sl@0
|
610 |
test.Printf(_L("3.4.6,Checking token's TokenType() function,"));
|
sl@0
|
611 |
if (&token->TokenType() != aTokenType)
|
sl@0
|
612 |
{
|
sl@0
|
613 |
CleanupStack::PopAndDestroy();
|
sl@0
|
614 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
615 |
return (102);
|
sl@0
|
616 |
}
|
sl@0
|
617 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
618 |
|
sl@0
|
619 |
_LIT(KVersion, "The Ultimate Version");
|
sl@0
|
620 |
_LIT(KSerial, "Serial No. 1");
|
sl@0
|
621 |
_LIT(KManufacturer, "ACME Corporation");
|
sl@0
|
622 |
|
sl@0
|
623 |
test.Printf(_L("3.4.6.1,Checking token's Information() function,"));
|
sl@0
|
624 |
if (token->Information(MCTToken::EVersion) != KVersion ||
|
sl@0
|
625 |
token->Information(MCTToken::ESerialNo) != KSerial ||
|
sl@0
|
626 |
token->Information(MCTToken::EManufacturer) != KManufacturer)
|
sl@0
|
627 |
{
|
sl@0
|
628 |
CleanupStack::PopAndDestroy();
|
sl@0
|
629 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
630 |
return (102);
|
sl@0
|
631 |
}
|
sl@0
|
632 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
633 |
|
sl@0
|
634 |
test.Printf(_L("3.4.7,Registering for removal notification,"));
|
sl@0
|
635 |
// This is another test to check that an API doesn't crash. We
|
sl@0
|
636 |
// call the base NotifyOnRemoval/CancelNotify functions and check
|
sl@0
|
637 |
// they do nothing! There's no point in creating derived versions
|
sl@0
|
638 |
// that do something as that would be testing the test plugin, not
|
sl@0
|
639 |
// the framework.
|
sl@0
|
640 |
TRequestStatus removalStatus;
|
sl@0
|
641 |
token->NotifyOnRemoval(removalStatus);
|
sl@0
|
642 |
token->CancelNotify();
|
sl@0
|
643 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
644 |
|
sl@0
|
645 |
test.Printf(_L("3.4.9,Testing cancellation of async interface opening,"));
|
sl@0
|
646 |
MTestInterface* interface;
|
sl@0
|
647 |
MCTTokenInterface* temp;
|
sl@0
|
648 |
TUid intB = {gInterfaceB};
|
sl@0
|
649 |
token->GetInterface(intB, temp, status);
|
sl@0
|
650 |
token->CancelGetInterface();
|
sl@0
|
651 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
652 |
|
sl@0
|
653 |
test.Printf(_L("3.4.10,Opening an interface,"));
|
sl@0
|
654 |
status = KRequestPending;
|
sl@0
|
655 |
TUid intC = {gInterfaceC};
|
sl@0
|
656 |
token->GetInterface(intC, temp, status);
|
sl@0
|
657 |
interface = static_cast<MTestInterface*>(temp);
|
sl@0
|
658 |
// Cancel call is pointelss as it does nothing in the test
|
sl@0
|
659 |
// plugin. But it won't do any harm to check it doesn't explode.
|
sl@0
|
660 |
token->CancelGetInterface();
|
sl@0
|
661 |
CleanupReleasePushL(*interface);
|
sl@0
|
662 |
token->Release();
|
sl@0
|
663 |
User::WaitForRequest(status);
|
sl@0
|
664 |
if (status.Int() != KErrNone)
|
sl@0
|
665 |
{
|
sl@0
|
666 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
667 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
668 |
return (103);
|
sl@0
|
669 |
}
|
sl@0
|
670 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
671 |
|
sl@0
|
672 |
test.Printf(_L("3.4.11,Checking interface name,"));
|
sl@0
|
673 |
if (buf.Compare(interface->Label()))
|
sl@0
|
674 |
{
|
sl@0
|
675 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
676 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
677 |
return (104);
|
sl@0
|
678 |
}
|
sl@0
|
679 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
680 |
|
sl@0
|
681 |
test.Printf(_L("3.4.12,Getting an object,"));
|
sl@0
|
682 |
MTestObject* object = interface->ObjectL();
|
sl@0
|
683 |
object->Release();
|
sl@0
|
684 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
685 |
|
sl@0
|
686 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
687 |
return KErrNone;
|
sl@0
|
688 |
}
|
sl@0
|
689 |
|
sl@0
|
690 |
TInt TokenTypeTestsL()
|
sl@0
|
691 |
{
|
sl@0
|
692 |
test.Printf(_L("3.1,Getting token types for tests,"));
|
sl@0
|
693 |
RFs fs;
|
sl@0
|
694 |
RCPointerArray<CCTTokenTypeInfo> myTokenTypes;
|
sl@0
|
695 |
CleanupClosePushL(myTokenTypes);
|
sl@0
|
696 |
TUid aABndC[] = {{gInterfaceA}, {gInterfaceB}, {gInterfaceC}};
|
sl@0
|
697 |
TTestArray<TUid> aABandCArray(aABndC, 3);
|
sl@0
|
698 |
TCTFindTokenTypesByInterface findABAndC(aABandCArray.Array());
|
sl@0
|
699 |
CCTTokenTypeInfo::ListL(myTokenTypes, findABAndC);
|
sl@0
|
700 |
if (myTokenTypes.Count() != 1)
|
sl@0
|
701 |
{
|
sl@0
|
702 |
CleanupStack::PopAndDestroy();
|
sl@0
|
703 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
704 |
return (1);
|
sl@0
|
705 |
}
|
sl@0
|
706 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
707 |
|
sl@0
|
708 |
test.Printf(_L("3.2,Loading token type 6,"));
|
sl@0
|
709 |
MCTTokenType* token6 = MCTTokenType::NewL(*myTokenTypes[0], fs);
|
sl@0
|
710 |
if (!token6)
|
sl@0
|
711 |
{
|
sl@0
|
712 |
CleanupStack::PopAndDestroy();
|
sl@0
|
713 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
714 |
return (1);
|
sl@0
|
715 |
}
|
sl@0
|
716 |
CleanupReleasePushL(*token6);
|
sl@0
|
717 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
718 |
|
sl@0
|
719 |
TInt ret = TestTokenTypeL(token6, 6);
|
sl@0
|
720 |
if (ret)
|
sl@0
|
721 |
{
|
sl@0
|
722 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
723 |
return ret;
|
sl@0
|
724 |
}
|
sl@0
|
725 |
|
sl@0
|
726 |
test.Printf(_L("3.3,Loading token type 5,"));
|
sl@0
|
727 |
TUid UID5 = {gImplementation5};
|
sl@0
|
728 |
MCTTokenType* token5 = MCTTokenType::NewL(UID5, fs);
|
sl@0
|
729 |
if (!token5)
|
sl@0
|
730 |
{
|
sl@0
|
731 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
732 |
test.Printf(_L("FAILED\r\n"));
|
sl@0
|
733 |
return (2);
|
sl@0
|
734 |
}
|
sl@0
|
735 |
CleanupReleasePushL(*token5);
|
sl@0
|
736 |
test.Printf(_L("PASSED\r\n"));
|
sl@0
|
737 |
|
sl@0
|
738 |
ret = TestTokenTypeL(token5, 5);
|
sl@0
|
739 |
CleanupStack::PopAndDestroy(3);
|
sl@0
|
740 |
|
sl@0
|
741 |
return ret;
|
sl@0
|
742 |
}
|
sl@0
|
743 |
|
sl@0
|
744 |
TInt MemoryTestL(TInt (*aFnToTest)())
|
sl@0
|
745 |
{
|
sl@0
|
746 |
gLogging = EFalse;
|
sl@0
|
747 |
for (TInt ii = 1; ; ii++)
|
sl@0
|
748 |
{
|
sl@0
|
749 |
if (ii % 10)
|
sl@0
|
750 |
test.Printf(_L("."));
|
sl@0
|
751 |
else
|
sl@0
|
752 |
test.Printf(_L("*"));
|
sl@0
|
753 |
if (!(ii % 50))
|
sl@0
|
754 |
test.Printf(_L("\r\n"));
|
sl@0
|
755 |
gSilent = ETrue;
|
sl@0
|
756 |
__UHEAP_MARK;
|
sl@0
|
757 |
__UHEAP_FAILNEXT(ii);
|
sl@0
|
758 |
TRAPD(err,aFnToTest());
|
sl@0
|
759 |
__UHEAP_RESET;
|
sl@0
|
760 |
REComSession::FinalClose();
|
sl@0
|
761 |
__UHEAP_MARKEND;
|
sl@0
|
762 |
User::Heap().Check();
|
sl@0
|
763 |
gSilent = EFalse;
|
sl@0
|
764 |
if (err != KErrNoMemory)
|
sl@0
|
765 |
{
|
sl@0
|
766 |
test.Printf(_L("\r\n"));
|
sl@0
|
767 |
gLogging = ETrue;
|
sl@0
|
768 |
return err;
|
sl@0
|
769 |
}
|
sl@0
|
770 |
}
|
sl@0
|
771 |
}
|
sl@0
|
772 |
|
sl@0
|
773 |
void TestsL(void)
|
sl@0
|
774 |
{
|
sl@0
|
775 |
CActiveScheduler* as = new(ELeave) CActiveScheduler;
|
sl@0
|
776 |
CActiveScheduler::Install(as);
|
sl@0
|
777 |
|
sl@0
|
778 |
TInt errors = 0;
|
sl@0
|
779 |
TInt ret;
|
sl@0
|
780 |
__UHEAP_MARK;
|
sl@0
|
781 |
ret = TokenTypeInfoListTestsL();
|
sl@0
|
782 |
REComSession::FinalClose();
|
sl@0
|
783 |
__UHEAP_MARKEND;
|
sl@0
|
784 |
if (ret)
|
sl@0
|
785 |
{
|
sl@0
|
786 |
test.Printf(_L("1.9,ERROR %d in Info List test,FAILED\r\n"),ret);
|
sl@0
|
787 |
errors++;
|
sl@0
|
788 |
}
|
sl@0
|
789 |
else
|
sl@0
|
790 |
{
|
sl@0
|
791 |
test.Printf(_L("1.9,Info List test,PASSED\r\n"),ret);
|
sl@0
|
792 |
}
|
sl@0
|
793 |
__UHEAP_MARK;
|
sl@0
|
794 |
ret = TokenTypeInfoTestsL();
|
sl@0
|
795 |
REComSession::FinalClose();
|
sl@0
|
796 |
__UHEAP_MARKEND;
|
sl@0
|
797 |
if (ret)
|
sl@0
|
798 |
{
|
sl@0
|
799 |
test.Printf(_L("2.9,ERROR %d in Info test,FAILED\r\n"),ret);
|
sl@0
|
800 |
errors++;
|
sl@0
|
801 |
}
|
sl@0
|
802 |
else
|
sl@0
|
803 |
{
|
sl@0
|
804 |
test.Printf(_L("2.9,Info test,PASSED\r\n"),ret);
|
sl@0
|
805 |
}
|
sl@0
|
806 |
|
sl@0
|
807 |
__UHEAP_MARK;
|
sl@0
|
808 |
ret = TokenTypeTestsL();
|
sl@0
|
809 |
REComSession::FinalClose();
|
sl@0
|
810 |
__UHEAP_MARKEND;
|
sl@0
|
811 |
if (ret)
|
sl@0
|
812 |
{
|
sl@0
|
813 |
test.Printf(_L("3.9,ERROR %d in token test,FAILED\r\n"),ret);
|
sl@0
|
814 |
errors++;
|
sl@0
|
815 |
}
|
sl@0
|
816 |
else
|
sl@0
|
817 |
{
|
sl@0
|
818 |
test.Printf(_L("3.9,token test,PASSED\r\n"),ret);
|
sl@0
|
819 |
}
|
sl@0
|
820 |
|
sl@0
|
821 |
ret = MemoryTestL(TokenTypeInfoListTestsL);
|
sl@0
|
822 |
if (ret)
|
sl@0
|
823 |
{
|
sl@0
|
824 |
test.Printf(_L("4.9,ERROR %d in Info List memory test,FAILED\r\n"),ret);
|
sl@0
|
825 |
errors++;
|
sl@0
|
826 |
}
|
sl@0
|
827 |
else
|
sl@0
|
828 |
{
|
sl@0
|
829 |
test.Printf(_L("4.9,Info List memory test,PASSED\r\n"),ret);
|
sl@0
|
830 |
}
|
sl@0
|
831 |
ret = MemoryTestL(TokenTypeTestsL);
|
sl@0
|
832 |
if (ret)
|
sl@0
|
833 |
{
|
sl@0
|
834 |
test.Printf(_L("5.9,ERROR %d in Token Type memory test,FAILED\r\n"),ret);
|
sl@0
|
835 |
errors++;
|
sl@0
|
836 |
}
|
sl@0
|
837 |
else
|
sl@0
|
838 |
{
|
sl@0
|
839 |
test.Printf(_L("5.9,Token Type memory test,PASSED\r\n"),ret);
|
sl@0
|
840 |
}
|
sl@0
|
841 |
|
sl@0
|
842 |
test.Printf(_L("%d tests failed out of 44 hardcoded\r\n"), errors);
|
sl@0
|
843 |
|
sl@0
|
844 |
|
sl@0
|
845 |
if (errors)
|
sl@0
|
846 |
{
|
sl@0
|
847 |
test.Printf(_L("%d TESTS FAILED\r\n"),errors);
|
sl@0
|
848 |
}
|
sl@0
|
849 |
else
|
sl@0
|
850 |
{
|
sl@0
|
851 |
test.Printf(_L("ALL TESTS PASSED\r\n"));
|
sl@0
|
852 |
}
|
sl@0
|
853 |
|
sl@0
|
854 |
delete as;
|
sl@0
|
855 |
}
|
sl@0
|
856 |
|
sl@0
|
857 |
GLDEF_C TInt E32Main(void)
|
sl@0
|
858 |
|
sl@0
|
859 |
{
|
sl@0
|
860 |
CTrapCleanup* cleanup;
|
sl@0
|
861 |
cleanup=CTrapCleanup::New();
|
sl@0
|
862 |
test.Start(_L(" @SYMTestCaseID:SEC-CRYPTOTOKENS-CTFRAMEWORK-0001 Starting token framework tests\r\n"));
|
sl@0
|
863 |
CTestConsole* con=NULL;
|
sl@0
|
864 |
TRAPD(ret,con=CTestConsole::NewL(test.Console()));
|
sl@0
|
865 |
RFs fs;
|
sl@0
|
866 |
if (gLogging)
|
sl@0
|
867 |
{
|
sl@0
|
868 |
User::LeaveIfError(fs.Connect());
|
sl@0
|
869 |
RFile* file;
|
sl@0
|
870 |
file=new (ELeave) RFile;
|
sl@0
|
871 |
TDriveUnit sysDrive (fs.GetSystemDrive());
|
sl@0
|
872 |
TDriveName driveName(sysDrive.Name());
|
sl@0
|
873 |
TBuf<64> logFile (driveName);
|
sl@0
|
874 |
logFile.Append(_L("\\T_CTFrameworkLog.txt"));
|
sl@0
|
875 |
User::LeaveIfError(file->Replace(fs, logFile, EFileShareAny|EFileWrite));
|
sl@0
|
876 |
con->SetLogFile(file);
|
sl@0
|
877 |
}
|
sl@0
|
878 |
test.SetConsole(con);
|
sl@0
|
879 |
TRAP(ret,TestsL());
|
sl@0
|
880 |
if (ret)
|
sl@0
|
881 |
{
|
sl@0
|
882 |
test.Printf(_L("Unexpected leave\r\n"));
|
sl@0
|
883 |
}
|
sl@0
|
884 |
gLogging=EFalse;
|
sl@0
|
885 |
test.Close();
|
sl@0
|
886 |
delete cleanup;
|
sl@0
|
887 |
return(KErrNone);
|
sl@0
|
888 |
}
|