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 |
// testengine.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
||
20 |
#include <e32std.h> |
|
21 |
#include <e32std_private.h> |
|
22 |
#include <u32std.h> // unicode builds |
|
23 |
#include <e32base.h> |
|
24 |
#include <e32base_private.h> |
|
25 |
#include <e32cons.h> |
|
26 |
#include <e32Test.h> // RTest headder |
|
27 |
#include <e32def.h> |
|
28 |
#include <e32def_private.h> |
|
29 |
#include "testcaseroot.h" |
|
30 |
#include "testcasecontroller.h" |
|
31 |
#include "testengine.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
#include "testcasecontrollerTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
#endif |
0 | 36 |
|
37 |
||
38 |
||
39 |
||
40 |
CTestCaseController* CTestCaseController::NewL(CTestEngine& aTestEngine,TBool aHostRole) |
|
41 |
{ |
|
42 |
CTestCaseController* self = new (ELeave) CTestCaseController(aTestEngine,aHostRole); |
|
43 |
CleanupStack::PushL(self); |
|
44 |
self->ConstructL(); |
|
45 |
CleanupStack::Pop(self); |
|
46 |
return self; |
|
47 |
} |
|
48 |
||
49 |
||
50 |
CTestCaseController::CTestCaseController(CTestEngine& aTestEngine,TBool aHostRole) |
|
51 |
: CActive(EPriorityStandard), |
|
52 |
iTestEngine(aTestEngine), |
|
53 |
iHostRole(aHostRole) |
|
54 |
{ |
|
55 |
// Add to current threads active scheduler |
|
56 |
CActiveScheduler::Add(this); |
|
57 |
} |
|
58 |
||
59 |
||
60 |
CTestCaseController::~CTestCaseController() |
|
61 |
{ |
|
62 |
// Cancel any outstanding test cases |
|
63 |
Cancel(); |
|
64 |
delete iTestPolicy; |
|
65 |
} |
|
66 |
||
67 |
||
68 |
void CTestCaseController::ConstructL() |
|
69 |
{ |
|
70 |
TInt err(KErrNone); |
|
71 |
||
72 |
iTestPolicy = CBasicTestPolicy::NewL(); |
|
73 |
||
74 |
err = iTestEngine.NextTestCaseId(iTestCaseId); |
|
75 |
if (err != KErrNone) |
|
76 |
User::Leave(-2); |
|
77 |
||
78 |
test.Next(iTestCaseId); |
|
79 |
// pass control to the test-policy (which merely instantiates and runs the test) |
|
80 |
iTestPolicy->RunTestCaseL(iTestCaseId, &iStatus); |
|
81 |
SetActive(); // when the 1st test finnishes, we drop into our own RunL active processing loop |
|
82 |
} |
|
83 |
||
84 |
||
85 |
void CTestCaseController::DoCancel() |
|
86 |
{ |
|
87 |
// Cancel the outstanding test case running |
|
88 |
iTestPolicy->Cancel(); |
|
89 |
} |
|
90 |
||
91 |
||
92 |
void CTestCaseController::RunL() |
|
93 |
{ |
|
94 |
// Retrieve the completion code of the last test case run |
|
95 |
TInt err(iStatus.Int()); |
|
96 |
||
97 |
if (err != KErrNone) |
|
98 |
{ |
|
99 |
test.Printf(_L("<Error> Test case %lS failed\n"),&iTestCaseId); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
OstTraceExt1(TRACE_NORMAL, CTESTCASECONTROLLER_RUNL, "<Error> Test case %lS failed\n",iTestCaseId); |
0 | 101 |
} |
102 |
else |
|
103 |
{ |
|
104 |
test.Printf(_L("Test case %lS passed\n"),&iTestCaseId); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
OstTraceExt1(TRACE_NORMAL, CTESTCASECONTROLLER_RUNL_DUP01, "Test case %lS passed\n",iTestCaseId); |
0 | 106 |
} |
107 |
||
108 |
// Find next test to run |
|
109 |
err = iTestEngine.NextTestCaseId(iTestCaseId); |
|
110 |
if (err == KErrNone) |
|
111 |
{ |
|
112 |
test.Printf(_L("\n")); // ensures blank line between tests |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
113 |
OstTrace0(TRACE_NORMAL, CTESTCASECONTROLLER_RUNL_DUP02, "\n"); // ensures blank line between tests |
0 | 114 |
test.Printf(_L("\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
OstTrace0(TRACE_NORMAL, CTESTCASECONTROLLER_RUNL_DUP03, "\n"); |
0 | 116 |
test.Next(iTestCaseId); |
117 |
||
118 |
// run the next test here |
|
119 |
iTestPolicy->RunTestCaseL(iTestCaseId, &iStatus); |
|
120 |
SetActive(); |
|
121 |
} |
|
122 |
else if (err == KErrNotFound) |
|
123 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
124 |
OstTrace0(TRACE_NORMAL, CTESTCASECONTROLLER_RUNL_DUP04, "All specified test cases performed"); |
0 | 125 |
CActiveScheduler::Stop(); |
126 |
} |
|
127 |
else |
|
128 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
129 |
OstTrace1(TRACE_NORMAL, CTESTCASECONTROLLER_RUNL_DUP05, "<Error %d> Unknown error from CTestEngine::NextTestCaseId",err); |
0 | 130 |
User::Leave(err); |
131 |
} |
|
132 |
} |
|
133 |
||
134 |
||
135 |
TInt CTestCaseController::RunError(TInt aError) |
|
136 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
OstTraceFunctionEntry0(CTESTCASECONTROLLER_RUNERROR); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
} |
0 | 141 |
switch (aError) |
142 |
{ |
|
143 |
case KErrNoMemory: |
|
144 |
default: |
|
145 |
// Panic the test module |
|
146 |
test(EFalse); |
|
147 |
break; |
|
148 |
} |
|
149 |
return KErrNone; |
|
150 |
} |
|
151 |
||
152 |
||
153 |