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 "testcasewd.h" |
|
28 |
#include "testcasefactory.h" |
|
29 |
#include "exampletestcase.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#include "exampletestcaseTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
#endif |
0 | 34 |
|
35 |
||
36 |
||
37 |
// the name below is used to add a pointer to our construction method to a pointer MAP in |
|
38 |
// the class factory |
|
39 |
_LIT(KTestCaseId,"EXAMPLETESTCASE"); |
|
40 |
||
41 |
// UNcomment the next line to add the test to the catalog(factory) |
|
42 |
const TTestCaseFactoryReceipt<CExampleTestCase> CExampleTestCase::iFactoryReceipt(KTestCaseId); |
|
43 |
||
44 |
CExampleTestCase* CExampleTestCase::NewL(TBool aHost) |
|
45 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
46 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
47 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
48 |
OstTraceFunctionEntry0(CEXAMPLETESTCASE_NEWL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
49 |
} |
0 | 50 |
CExampleTestCase* self = new (ELeave) CExampleTestCase(aHost); |
51 |
CleanupStack::PushL(self); |
|
52 |
self->ConstructL(); |
|
53 |
CleanupStack::Pop(self); |
|
54 |
return self; |
|
55 |
} |
|
56 |
||
57 |
||
58 |
CExampleTestCase::CExampleTestCase(TBool aHost) |
|
59 |
: CTestCaseRoot(KTestCaseId, aHost) |
|
60 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
OstTraceFunctionEntry0(CEXAMPLETESTCASE_CEXAMPLETESTCASE); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
64 |
} |
0 | 65 |
} |
66 |
||
67 |
||
68 |
void CExampleTestCase::ConstructL() |
|
69 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
OstTraceFunctionEntry0(CEXAMPLETESTCASE_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
} |
0 | 74 |
BaseConstructL(); |
75 |
iWDTimer = CTestCaseWatchdog::NewL(); |
|
76 |
} |
|
77 |
||
78 |
||
79 |
CExampleTestCase::~CExampleTestCase() |
|
80 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
83 |
OstTraceFunctionEntry0(CEXAMPLETESTCASE_DCEXAMPLETESTCASE); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
84 |
} |
0 | 85 |
|
86 |
delete iWDTimer; |
|
87 |
Cancel(); |
|
88 |
} |
|
89 |
||
90 |
||
91 |
void CExampleTestCase::ExecuteTestCaseL() |
|
92 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
94 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
OstTraceFunctionEntry0(CEXAMPLETESTCASE_EXECUTETESTCASEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
} |
0 | 97 |
iCaseStep = EFirstStep; |
98 |
||
99 |
// |
|
100 |
CActiveScheduler::Add(this); |
|
101 |
// run our root RunL() |
|
102 |
SelfComplete(); |
|
103 |
||
104 |
} |
|
105 |
||
106 |
void CExampleTestCase::DescribePreconditions() |
|
107 |
{ |
|
108 |
test.Printf(_L("This is an example test, there is nothing to do beforehand.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
109 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_DESCRIBEPRECONDITIONS, "This is an example test, there is nothing to do beforehand.\n"); |
0 | 110 |
} |
111 |
||
112 |
void CExampleTestCase::DoCancel() |
|
113 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
OstTraceFunctionEntry0(CEXAMPLETESTCASE_DOCANCEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
} |
0 | 118 |
|
119 |
} |
|
120 |
||
121 |
||
122 |
void CExampleTestCase::ProcessKey(TKeyCode &aKey) |
|
123 |
{ // the default implementation does this already, but we will store the key here again anyway |
|
124 |
iKeyCodeInput = aKey; |
|
125 |
||
126 |
} |
|
127 |
||
128 |
void CExampleTestCase::FuncA(CTestCaseRoot *pThis) |
|
129 |
{ |
|
130 |
CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis); |
|
131 |
// cancel any pending call, and then complete our active obj with a timeout value |
|
132 |
test.Printf(_L("@@@ FuncA cancel a keyboard Read() @@@\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
133 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_FUNCA, "@@@ FuncA cancel a keyboard Read(@@@\n")); |
0 | 134 |
|
135 |
p->iConsole->ReadCancel(); |
|
136 |
||
137 |
} |
|
138 |
||
139 |
void CExampleTestCase::FuncB(CTestCaseRoot *pThis) |
|
140 |
{ |
|
141 |
CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis); |
|
142 |
// cancel any pending call, and then complete our active obj with a timeout value |
|
143 |
test.Printf(_L("@@@ FuncB cancel a 'B' keyboard Read() @@@\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
144 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_FUNCB, "@@@ FuncB cancel a 'B' keyboard Read(@@@\n")); |
0 | 145 |
|
146 |
p->Cancel(); |
|
147 |
p->iConsole->ReadCancel(); |
|
148 |
||
149 |
TRequestStatus* s = &p->iStatus; |
|
150 |
p->iStatus = KRequestPending; |
|
151 |
||
152 |
p->SetActive(); |
|
153 |
User::RequestComplete(s, KTestCaseWatchdogTO); |
|
154 |
||
155 |
} |
|
156 |
||
157 |
||
158 |
// handle event completion |
|
159 |
void CExampleTestCase::RunStepL() |
|
160 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
161 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
163 |
OstTraceFunctionEntry0(CEXAMPLETESTCASE_RUNSTEPL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
164 |
} |
0 | 165 |
|
166 |
// Obtain the completion code for this CActive obj. |
|
167 |
TInt completionCode(iStatus.Int()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP01, "Example test iStatus compl.=%d\n", completionCode); |
0 | 169 |
|
170 |
switch(iCaseStep) |
|
171 |
{ |
|
172 |
case EFirstStep: |
|
173 |
iCaseStep=ESecondStep; |
|
174 |
test.Printf(_L("Test step 1\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP03, "Test step 1\n"); |
0 | 176 |
|
177 |
SelfComplete(); |
|
178 |
break; |
|
179 |
case ESecondStep: |
|
180 |
iCaseStep=EThirdStep; |
|
181 |
test.Printf(_L("Test step 2\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
182 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP04, "Test step 2\n"); |
0 | 183 |
test.Printf(_L("(this test step uses Keyboard)\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP05, "(this test step uses Keyboard\n")); |
0 | 185 |
test.Printf(_L("Press ANY key once you have removed the 'A' connector...\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP06, "Press ANY key once you have removed the 'A' connector...\n"); |
0 | 187 |
RequestCharacter(); |
188 |
iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncA); |
|
189 |
break; |
|
190 |
case EThirdStep: |
|
191 |
test.Printf(_L("key was a '%c'\n"), iKeyCodeInput); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP07, "key was a '%c'\n", iKeyCodeInput); |
0 | 193 |
iWDTimer->Cancel(); |
194 |
iCaseStep=EFourthStep; |
|
195 |
test.Printf(_L("Test step 3\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP08, "Test step 3\n"); |
0 | 197 |
test.Printf(_L("(this test step uses Keyboard)\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
198 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP09, "(this test step uses Keyboard\n")); |
0 | 199 |
test.Printf(_L("Press <SPACE> key once you have removed the 'A' connector...\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
200 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP10, "Press <SPACE> key once you have removed the 'A' connector...\n"); |
0 | 201 |
RequestCharacter(); |
202 |
iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncB); |
|
203 |
||
204 |
break; |
|
205 |
case EFourthStep: |
|
206 |
test.Printf(_L("key was a '%c'\n"), iKeyCodeInput); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP11, "key was a '%c'\n", iKeyCodeInput); |
0 | 208 |
test.Printf(_L("Test step 4\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP12, "Test step 4\n"); |
0 | 210 |
iWDTimer->Cancel(); |
211 |
||
212 |
iCaseStep=EFifthStep; |
|
213 |
if (' ' != iKeyCodeInput) |
|
214 |
{ |
|
215 |
||
216 |
iCaseStep=EThirdStep; |
|
217 |
} |
|
218 |
SelfComplete(); |
|
219 |
break; |
|
220 |
case EFifthStep: |
|
221 |
iCaseStep=ESixthStep; |
|
222 |
test.Printf(_L("Test step 5\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP13, "Test step 5\n"); |
0 | 224 |
test.Printf(_L("(this test uses a delay)\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP14, "(this test uses a delay\n")); |
0 | 226 |
iTimer.After(iStatus, 500000); |
227 |
SetActive(); |
|
228 |
break; |
|
229 |
case ESixthStep: |
|
230 |
iCaseStep=ELastStep; |
|
231 |
test.Printf(_L("Test step 6(%d)\n"), completionCode); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP15, "Test step 6(%d)\n", completionCode); |
0 | 233 |
RequestCharacter(); |
234 |
iConsole->ReadCancel(); |
|
235 |
Cancel(); |
|
236 |
RequestCharacter(); |
|
237 |
||
238 |
//SelfComplete(); |
|
239 |
break; |
|
240 |
case ELastStep: |
|
241 |
iCaseStep=ESecondStep; |
|
242 |
test.Printf(_L("LAST step7 code (%d)\n"), completionCode); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP16, "LAST step7 code (%d)\n", completionCode); |
0 | 244 |
TestPolicy().SignalTestComplete(KErrNone); |
245 |
return TestPassed(); |
|
246 |
//break; |
|
247 |
||
248 |
default: |
|
249 |
Cancel(); |
|
250 |
TestFailed(KErrCorrupt, _L("unknown test step")); |
|
251 |
break; |
|
252 |
} |
|
253 |
||
254 |
} |
|
255 |
||
256 |