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 |
// @internalComponent |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
||
19 |
#include <e32std.h> |
|
20 |
#include <e32std_private.h> |
|
21 |
#include <u32std.h> // unicode builds |
|
22 |
#include <e32base.h> |
|
23 |
#include <e32base_private.h> |
|
24 |
#include <e32cons.h> |
|
25 |
#include <e32Test.h> // RTest headder |
|
26 |
#include "testcaseroot.h" |
|
27 |
#include "testpolicy.h" |
|
28 |
#include "testcasefactory.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
#include "testpolicyTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#endif |
0 | 33 |
|
34 |
||
35 |
||
36 |
||
37 |
CBasicTestPolicy* CBasicTestPolicy::NewL() |
|
38 |
{ |
|
39 |
CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy; |
|
40 |
CleanupStack::PushL(self); |
|
41 |
self->ConstructL(); |
|
42 |
CleanupStack::Pop(self); |
|
43 |
return self; |
|
44 |
} |
|
45 |
||
46 |
||
47 |
CBasicTestPolicy::CBasicTestPolicy() |
|
48 |
: CActive(EPriorityStandard) |
|
49 |
{ |
|
50 |
CActiveScheduler::Add(this); |
|
51 |
} |
|
52 |
||
53 |
||
54 |
void CBasicTestPolicy::ConstructL() |
|
55 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
56 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
58 |
OstTraceFunctionEntry0(CBASICTESTPOLICY_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
59 |
} |
0 | 60 |
|
61 |
} |
|
62 |
||
63 |
||
64 |
CBasicTestPolicy::~CBasicTestPolicy() |
|
65 |
{ |
|
66 |
Cancel(); |
|
67 |
if (iTestCase) |
|
68 |
{ |
|
69 |
delete iTestCase; |
|
70 |
} |
|
71 |
} |
|
72 |
||
73 |
||
74 |
/* Because the test policy can be referenced from the test case, parameters to pass to |
|
75 |
the test-case may be stored in this class in future for access on ad-hoc basis as each test |
|
76 |
case desires, without a need to modify all test cases |
|
77 |
*/ |
|
78 |
void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId, TRequestStatus* aNotifierStatus) |
|
79 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
OstTraceFunctionEntry0(CBASICTESTPOLICY_RUNTESTCASEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
} |
0 | 84 |
iNotifierStatus = aNotifierStatus; |
85 |
// delete previous test run |
|
86 |
if (iTestCase) |
|
87 |
{ |
|
88 |
delete iTestCase; |
|
89 |
iTestCase = NULL; |
|
90 |
} |
|
91 |
||
92 |
// create the test class |
|
93 |
iTestCase = RTestFactory::CreateTestCaseL(aTestCaseId); |
|
94 |
// configure it |
|
95 |
iTestCase->SetTestPolicy(this); |
|
96 |
||
97 |
iTestCase->DisplayTestCaseOptions(); // test preconditions and detail |
|
98 |
||
99 |
// run the test-case |
|
100 |
iTestCase->PerformTestL(); |
|
101 |
||
102 |
*iNotifierStatus = KRequestPending; |
|
103 |
} |
|
104 |
||
105 |
||
106 |
void CBasicTestPolicy::DoCancel() |
|
107 |
{ |
|
108 |
iTestCase->Cancel(); |
|
109 |
||
110 |
User::RequestComplete(iNotifierStatus, KErrCancel); |
|
111 |
} |
|
112 |
||
113 |
||
114 |
void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode) |
|
115 |
{ |
|
116 |
if (KErrNone == aCompletionCode) |
|
117 |
{ |
|
118 |
// Note there is no way to pass __FILE__ __LINE__ 'in' to this 'macro' |
|
119 |
test(ETrue); |
|
120 |
} |
|
121 |
else |
|
122 |
{ |
|
123 |
test(EFalse); // failed (PANIC here) |
|
124 |
} |
|
125 |
||
126 |
if (iNotifierStatus) // will be null if we already signalled earlier |
|
127 |
{ |
|
128 |
User::RequestComplete(iNotifierStatus, aCompletionCode); |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
||
133 |
void CBasicTestPolicy::RunL() |
|
134 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
136 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
137 |
OstTraceFunctionEntry0(CBASICTESTPOLICY_RUNL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
138 |
} |
0 | 139 |
|
140 |
} |
|
141 |
||
142 |
||
143 |
TInt CBasicTestPolicy::RunError(TInt /*aError*/) |
|
144 |
{ |
|
145 |
return KErrNone; |
|
146 |
} |
|
147 |
||
148 |