author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// @file testpolicy.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include "TestPolicy.h" |
|
20 |
#include "TestCaseFactory.h" |
|
21 |
#include "BaseTestCase.h" |
|
22 |
#include "TestCaseFactory.h" |
|
23 |
#include "testdebug.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
24 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
#include "TestPolicyTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
27 |
#endif |
0 | 28 |
|
29 |
namespace NUnitTesting_USBDI |
|
30 |
{ |
|
31 |
||
32 |
CBasicTestPolicy* CBasicTestPolicy::NewL() |
|
33 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
OstTraceFunctionEntry0( CBASICTESTPOLICY_NEWL_ENTRY ); |
0 | 35 |
CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy; |
36 |
CleanupStack::PushL(self); |
|
37 |
self->ConstructL(); |
|
38 |
CleanupStack::Pop(self); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
39 |
OstTraceFunctionExit1( CBASICTESTPOLICY_NEWL_EXIT, ( TUint )( self ) ); |
0 | 40 |
return self; |
41 |
} |
|
42 |
||
43 |
||
44 |
CBasicTestPolicy::CBasicTestPolicy() |
|
45 |
: CActive(EPriorityStandard) |
|
46 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY, this ); |
0 | 48 |
CActiveScheduler::Add(this); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
OstTraceFunctionExit1( CBASICTESTPOLICY_CBASICTESTPOLICY_EXIT, this ); |
0 | 50 |
} |
51 |
||
52 |
||
53 |
CBasicTestPolicy::~CBasicTestPolicy() |
|
54 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY_DUP01, this ); |
0 | 56 |
|
57 |
Cancel(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
OstTraceFunctionExit1( CBASICTESTPOLICY_CBASICTESTPOLICY_EXIT_DUP01, this ); |
0 | 59 |
} |
60 |
||
61 |
||
62 |
void CBasicTestPolicy::ConstructL() |
|
63 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
OstTraceFunctionEntry1( CBASICTESTPOLICY_CONSTRUCTL_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
65 |
OstTraceFunctionExit1( CBASICTESTPOLICY_CONSTRUCTL_EXIT, this ); |
0 | 66 |
} |
67 |
||
68 |
||
69 |
void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus) |
|
70 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNTESTCASEL_ENTRY, this ); |
0 | 72 |
|
73 |
iNotifierStatus = &aNotifierStatus; |
|
74 |
||
75 |
// Create the specified test case |
|
76 |
||
77 |
iTestCase = RTestFactory::CreateTestCaseL(aTestCaseId,EFalse); |
|
78 |
iTestCase->SetTestPolicy(this); |
|
79 |
iTestCase->PerformTestL(); |
|
80 |
||
81 |
// Set the request of the notifier to pending |
|
82 |
||
83 |
*iNotifierStatus = iStatus = KRequestPending; |
|
84 |
SetActive(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
OstTraceFunctionExit1( CBASICTESTPOLICY_RUNTESTCASEL_EXIT, this ); |
0 | 86 |
} |
87 |
||
88 |
||
89 |
void CBasicTestPolicy::DoCancel() |
|
90 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
91 |
OstTraceFunctionEntry1( CBASICTESTPOLICY_DOCANCEL_ENTRY, this ); |
0 | 92 |
|
93 |
// Cancel running the test cases |
|
94 |
||
95 |
iTestCase->Cancel(); |
|
96 |
||
97 |
// Notify the test case controller that test case execution was cancelled |
|
98 |
||
99 |
User::RequestComplete(iNotifierStatus,KErrCancel); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
OstTraceFunctionExit1( CBASICTESTPOLICY_DOCANCEL_EXIT, this ); |
0 | 101 |
} |
102 |
||
103 |
||
104 |
void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode) |
|
105 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
OstTraceFunctionEntryExt( CBASICTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this ); |
0 | 107 |
|
108 |
// Complete the test policy request with the test case completion code |
|
109 |
// (Basically self completion) |
|
110 |
||
111 |
TRequestStatus* s = &iStatus; |
|
112 |
User::RequestComplete(s,aCompletionCode); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
OstTraceFunctionExit1( CBASICTESTPOLICY_SIGNALTESTCOMPLETE_EXIT, this ); |
0 | 114 |
} |
115 |
||
116 |
||
117 |
void CBasicTestPolicy::RunL() |
|
118 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
119 |
OstTraceFunctionEntry1( CBASICTESTPOLICY_RUNL_ENTRY, this ); |
0 | 120 |
|
121 |
// Complete the request of the notifier with the test case |
|
122 |
// completion code |
|
123 |
||
124 |
User::RequestComplete(iNotifierStatus,iStatus.Int()); |
|
125 |
||
126 |
// Destroy the test case |
|
127 |
||
128 |
delete iTestCase; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
OstTraceFunctionExit1( CBASICTESTPOLICY_RUNL_EXIT, this ); |
0 | 130 |
} |
131 |
||
132 |
||
133 |
TInt CBasicTestPolicy::RunError(TInt aError) |
|
134 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNERROR_ENTRY, this ); |
0 | 136 |
|
137 |
aError = KErrNone; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
OstTraceFunctionExitExt( CBASICTESTPOLICY_RUNERROR_EXIT, this, aError ); |
0 | 139 |
return aError; |
140 |
} |
|
141 |
||
142 |
CThreadTestPolicy* CThreadTestPolicy::NewL() |
|
143 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
OstTraceFunctionEntry0( CTHREADTESTPOLICY_NEWL_ENTRY ); |
0 | 145 |
CThreadTestPolicy* self = new (ELeave) CThreadTestPolicy; |
146 |
CleanupStack::PushL(self); |
|
147 |
self->ConstructL(); |
|
148 |
CleanupStack::Pop(self); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_NEWL_EXIT, ( TUint )( self ) ); |
0 | 150 |
return self; |
151 |
} |
|
152 |
||
153 |
||
154 |
CThreadTestPolicy::CThreadTestPolicy() |
|
155 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
156 |
OstTraceFunctionEntry1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_EXIT, this ); |
0 | 158 |
} |
159 |
||
160 |
||
161 |
CThreadTestPolicy::~CThreadTestPolicy() |
|
162 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
OstTraceFunctionEntry1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_ENTRY_DUP01, this ); |
0 | 164 |
iTestThread.Close(); |
165 |
if(iTestCaseId) |
|
166 |
{ |
|
167 |
delete iTestCaseId; |
|
168 |
iTestCaseId = NULL; |
|
169 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_EXIT_DUP01, this ); |
0 | 171 |
} |
172 |
||
173 |
void CThreadTestPolicy::ConstructL() |
|
174 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
OstTraceFunctionEntry1( CTHREADTESTPOLICY_CONSTRUCTL_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
176 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_CONSTRUCTL_EXIT, this ); |
0 | 177 |
} |
178 |
||
179 |
void CThreadTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus) |
|
180 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
181 |
OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNTESTCASEL_ENTRY, this ); |
0 | 182 |
|
183 |
iNotifierStatus = &aNotifierStatus; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL, "Creating thread for test case '%S'",aTestCaseId); |
0 | 185 |
|
186 |
if(iTestCaseId) |
|
187 |
{ |
|
188 |
delete iTestCaseId; |
|
189 |
iTestCaseId = NULL; |
|
190 |
} |
|
191 |
iTestCaseId = HBufC::NewL(aTestCaseId.Length()); |
|
192 |
*iTestCaseId = aTestCaseId; |
|
193 |
||
194 |
// Create the thread to run the test case in |
|
195 |
TInt err(iTestThread.Create(aTestCaseId,CThreadTestPolicy::ThreadFunction, |
|
196 |
KDefaultStackSize,NULL,reinterpret_cast<TAny*>(iTestCaseId))); |
|
197 |
||
198 |
if(err != KErrNone) |
|
199 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP01, "Test thread creation unsuccessful: %d",err); |
0 | 201 |
User::Leave(err); |
202 |
} |
|
203 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP02, "Test thread '%S' created",aTestCaseId); |
0 | 205 |
// Start the test case in the thread |
206 |
iTestThread.Logon(iStatus); |
|
207 |
SetActive(); |
|
208 |
iTestThread.Resume(); |
|
209 |
*iNotifierStatus = KRequestPending; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_RUNTESTCASEL_EXIT, this ); |
0 | 211 |
} |
212 |
||
213 |
||
214 |
void CThreadTestPolicy::SignalTestComplete(TInt aCompletionCode) |
|
215 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
OstTraceFunctionEntryExt( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this ); |
0 | 217 |
|
218 |
if(aCompletionCode == KErrNone) |
|
219 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE, "CActiveScheduler::Stop CThreadTestPolicy::SignalTestComplete"); |
0 | 221 |
CActiveScheduler::Stop(); |
222 |
} |
|
223 |
else |
|
224 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_DUP01, "Killing thread with: %d",aCompletionCode); |
0 | 226 |
iTestThread.Kill(aCompletionCode); |
227 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_EXIT, this ); |
0 | 229 |
} |
230 |
||
231 |
void CThreadTestPolicy::DoCancel() |
|
232 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
OstTraceFunctionEntry1( CTHREADTESTPOLICY_DOCANCEL_ENTRY, this ); |
0 | 234 |
|
235 |
iTestCase->Cancel(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL, ">> Debug point: 1"); |
0 | 237 |
TInt err(iTestThread.LogonCancel(iStatus)); |
238 |
if(err != KErrNone) |
|
239 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP01, "Unable to cancel thread logon: %d",err); |
0 | 241 |
} |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
242 |
OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP02, ">> Debug point: 2"); |
0 | 243 |
TRequestStatus cancelStatus; |
244 |
iTestThread.Logon(cancelStatus); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP03, ">> Debug point: 3"); |
0 | 246 |
iTestThread.Kill(KErrCancel); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP04, ">> Debug point: 4"); |
0 | 248 |
User::RequestComplete(iNotifierStatus,cancelStatus.Int()); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
249 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_DOCANCEL_EXIT, this ); |
0 | 250 |
} |
251 |
||
252 |
TInt CThreadTestPolicy::ThreadFunction(TAny* aThreadParameter) |
|
253 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
OstTraceFunctionEntry0( CTHREADTESTPOLICY_THREADFUNCTION_ENTRY); |
0 | 255 |
|
256 |
TInt err(KErrNone); |
|
257 |
TInt leaveCode(KErrNone); |
|
258 |
||
259 |
HBufC* testCaseId = reinterpret_cast<HBufC*>(aThreadParameter); |
|
260 |
||
261 |
// Create the cleanup stack for this thread |
|
262 |
CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
263 |
if(cleanup == NULL) |
|
264 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT, 0, KErrNoMemory ); |
0 | 266 |
return KErrNoMemory; |
267 |
} |
|
268 |
||
269 |
TRAP(leaveCode,err = CThreadTestPolicy::DoTestL(*testCaseId)); |
|
270 |
if(leaveCode != KErrNone) |
|
271 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_THREADFUNCTION, "<Error %d> Thread '%S' DoTest",leaveCode, *testCaseId); |
0 | 273 |
err = leaveCode; |
274 |
} |
|
275 |
||
276 |
delete cleanup; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
277 |
OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT_DUP01, 0, err ); |
0 | 278 |
return err; |
279 |
} |
|
280 |
||
281 |
||
282 |
TInt CThreadTestPolicy::DoTestL(const TDesC& aTestCaseId) |
|
283 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
284 |
OstTraceFunctionEntryExt( CTHREADTESTPOLICY_DOTESTL_ENTRY, 0 ); |
0 | 285 |
TInt err(KErrNone); |
286 |
||
287 |
// Create a new active scheduler for this thread |
|
288 |
CActiveScheduler* sched = new (ELeave) CActiveScheduler; |
|
289 |
CleanupStack::PushL(sched); |
|
290 |
CActiveScheduler::Install(sched); |
|
291 |
||
292 |
CBaseTestCase* testCase = RTestFactory::CreateTestCaseL(aTestCaseId,ETrue); |
|
293 |
CleanupStack::PushL(testCase); |
|
294 |
||
295 |
// Do the test |
|
296 |
testCase->PerformTestL(); |
|
297 |
||
298 |
if(!testCase->IsHostOnly()) |
|
299 |
{ |
|
300 |
// Loop for active objects |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOTESTL, "CActiveScheduler::Start in CThreadTestPolicy::DoTestL"); |
0 | 302 |
CActiveScheduler::Start(); |
303 |
} |
|
304 |
// Get the test case execution result |
|
305 |
err = testCase->TestResult(); |
|
306 |
||
307 |
// Destroy test case |
|
308 |
CleanupStack::PopAndDestroy(testCase); |
|
309 |
||
310 |
// Destroy the active scheduler |
|
311 |
CleanupStack::PopAndDestroy(sched); |
|
312 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
OstTraceFunctionExitExt( CTHREADTESTPOLICY_DOTESTL_EXIT, 0, err ); |
0 | 314 |
return err; |
315 |
} |
|
316 |
||
317 |
void CThreadTestPolicy::RunL() |
|
318 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
OstTraceFunctionEntry1( CTHREADTESTPOLICY_RUNL_ENTRY, this ); |
0 | 320 |
TInt completionCode(iStatus.Int()); |
321 |
||
322 |
TExitType exitType(iTestThread.ExitType()); |
|
323 |
TExitCategoryName exitName(iTestThread.ExitCategory()); |
|
324 |
TInt exitReason(iTestThread.ExitReason()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
325 |
OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL, "Test thread '%S' completed with completion code %d",iTestThread.Name(),completionCode); |
0 | 326 |
|
327 |
switch(exitType) |
|
328 |
{ |
|
329 |
// The test thread has panicked |
|
330 |
// This will occur if test API panics or RTest expression is false (i.e. test case fails) |
|
331 |
case EExitPanic: |
|
332 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
333 |
OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP01, "Test thread '%S' has panicked with category '%S' reason %d", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
334 |
iTestThread.Name(),exitName,exitReason); |
0 | 335 |
// May require to stop and start host/client USB depending on what panic category it is |
336 |
// can no longer trust RUsbHubDriver/RDevUsbcClient to be in good state |
|
337 |
completionCode = KErrAbort; |
|
338 |
} |
|
339 |
break; |
|
340 |
||
341 |
// The thread has been terminated |
|
342 |
case EExitTerminate: |
|
343 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
344 |
OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP02, "Test thread '%S' terminated with category %s reason %d", |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
iTestThread.Name(),exitName,exitReason); |
0 | 346 |
} |
347 |
break; |
|
348 |
||
349 |
// The thread has been killed |
|
350 |
// This will occur when the test thread executes normally or is cancelled |
|
351 |
case EExitKill: |
|
352 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP03, "Test thread '%S' has been killed with reason %d",iTestThread.Name(),exitReason); |
0 | 354 |
} |
355 |
break; |
|
356 |
||
357 |
// These cases should not occur at this stage |
|
358 |
case EExitPending: //follow through |
|
359 |
default: |
|
360 |
gtest(EFalse); // Panic main thread |
|
361 |
break; |
|
362 |
} |
|
363 |
||
364 |
// Close the just executed test thread |
|
365 |
iTestThread.Close(); |
|
366 |
||
367 |
// Complete the notifier's request status |
|
368 |
User::RequestComplete(iNotifierStatus,completionCode); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
369 |
OstTraceFunctionExit1( CTHREADTESTPOLICY_RUNL_EXIT, this ); |
0 | 370 |
} |
371 |
||
372 |
TInt CThreadTestPolicy::RunError(TInt aError) |
|
373 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
374 |
OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNERROR_ENTRY, this ); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
375 |
OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNERROR, "<Error %d><Test Policy> RunError",aError); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
OstTraceFunctionExitExt( CTHREADTESTPOLICY_RUNERROR_EXIT, this, KErrNone ); |
0 | 377 |
return KErrNone; |
378 |
} |
|
379 |
||
380 |
} |