56 |
49 |
57 |
50 |
58 CExampleTestCase::CExampleTestCase(TBool aHost) |
51 CExampleTestCase::CExampleTestCase(TBool aHost) |
59 : CTestCaseRoot(KTestCaseId, aHost) |
52 : CTestCaseRoot(KTestCaseId, aHost) |
60 { |
53 { |
61 if(gVerboseOutput) |
54 LOG_FUNC |
62 { |
|
63 OstTraceFunctionEntry0(CEXAMPLETESTCASE_CEXAMPLETESTCASE); |
|
64 } |
|
65 } |
55 } |
66 |
56 |
67 |
57 |
68 void CExampleTestCase::ConstructL() |
58 void CExampleTestCase::ConstructL() |
69 { |
59 { |
70 if(gVerboseOutput) |
60 LOG_FUNC |
71 { |
|
72 OstTraceFunctionEntry0(CEXAMPLETESTCASE_CONSTRUCTL); |
|
73 } |
|
74 BaseConstructL(); |
61 BaseConstructL(); |
75 iWDTimer = CTestCaseWatchdog::NewL(); |
62 iWDTimer = CTestCaseWatchdog::NewL(); |
76 } |
63 } |
77 |
64 |
78 |
65 |
79 CExampleTestCase::~CExampleTestCase() |
66 CExampleTestCase::~CExampleTestCase() |
80 { |
67 { |
81 if(gVerboseOutput) |
68 LOG_FUNC |
82 { |
|
83 OstTraceFunctionEntry0(CEXAMPLETESTCASE_DCEXAMPLETESTCASE); |
|
84 } |
|
85 |
69 |
86 delete iWDTimer; |
70 delete iWDTimer; |
87 Cancel(); |
71 Cancel(); |
88 } |
72 } |
89 |
73 |
90 |
74 |
91 void CExampleTestCase::ExecuteTestCaseL() |
75 void CExampleTestCase::ExecuteTestCaseL() |
92 { |
76 { |
93 if(gVerboseOutput) |
77 LOG_FUNC |
94 { |
|
95 OstTraceFunctionEntry0(CEXAMPLETESTCASE_EXECUTETESTCASEL); |
|
96 } |
|
97 iCaseStep = EFirstStep; |
78 iCaseStep = EFirstStep; |
98 |
79 |
99 // |
80 // |
100 CActiveScheduler::Add(this); |
81 CActiveScheduler::Add(this); |
101 // run our root RunL() |
82 // run our root RunL() |
128 void CExampleTestCase::FuncA(CTestCaseRoot *pThis) |
105 void CExampleTestCase::FuncA(CTestCaseRoot *pThis) |
129 { |
106 { |
130 CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis); |
107 CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis); |
131 // cancel any pending call, and then complete our active obj with a timeout value |
108 // cancel any pending call, and then complete our active obj with a timeout value |
132 test.Printf(_L("@@@ FuncA cancel a keyboard Read() @@@\n")); |
109 test.Printf(_L("@@@ FuncA cancel a keyboard Read() @@@\n")); |
133 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_FUNCA, "@@@ FuncA cancel a keyboard Read(@@@\n")); |
|
134 |
110 |
135 p->iConsole->ReadCancel(); |
111 p->iConsole->ReadCancel(); |
136 |
112 |
137 } |
113 } |
138 |
114 |
139 void CExampleTestCase::FuncB(CTestCaseRoot *pThis) |
115 void CExampleTestCase::FuncB(CTestCaseRoot *pThis) |
140 { |
116 { |
141 CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis); |
117 CExampleTestCase * p = REINTERPRET_CAST(CExampleTestCase *,pThis); |
142 // cancel any pending call, and then complete our active obj with a timeout value |
118 // 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")); |
119 test.Printf(_L("@@@ FuncB cancel a 'B' keyboard Read() @@@\n")); |
144 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_FUNCB, "@@@ FuncB cancel a 'B' keyboard Read(@@@\n")); |
|
145 |
120 |
146 p->Cancel(); |
121 p->Cancel(); |
147 p->iConsole->ReadCancel(); |
122 p->iConsole->ReadCancel(); |
148 |
123 |
149 TRequestStatus* s = &p->iStatus; |
124 TRequestStatus* s = &p->iStatus; |
156 |
131 |
157 |
132 |
158 // handle event completion |
133 // handle event completion |
159 void CExampleTestCase::RunStepL() |
134 void CExampleTestCase::RunStepL() |
160 { |
135 { |
161 if(gVerboseOutput) |
136 LOG_FUNC |
162 { |
|
163 OstTraceFunctionEntry0(CEXAMPLETESTCASE_RUNSTEPL); |
|
164 } |
|
165 |
137 |
166 // Obtain the completion code for this CActive obj. |
138 // Obtain the completion code for this CActive obj. |
167 TInt completionCode(iStatus.Int()); |
139 TInt completionCode(iStatus.Int()); |
168 OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP01, "Example test iStatus compl.=%d\n", completionCode); |
140 RDebug::Printf("Example test iStatus compl.=%d\n", completionCode); |
|
141 //test.Printf(_L("Example test iStatus compl.=%d\n"), completionCode); |
169 |
142 |
170 switch(iCaseStep) |
143 switch(iCaseStep) |
171 { |
144 { |
172 case EFirstStep: |
145 case EFirstStep: |
173 iCaseStep=ESecondStep; |
146 iCaseStep=ESecondStep; |
174 test.Printf(_L("Test step 1\n")); |
147 test.Printf(_L("Test step 1\n")); |
175 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP03, "Test step 1\n"); |
|
176 |
148 |
177 SelfComplete(); |
149 SelfComplete(); |
178 break; |
150 break; |
179 case ESecondStep: |
151 case ESecondStep: |
180 iCaseStep=EThirdStep; |
152 iCaseStep=EThirdStep; |
181 test.Printf(_L("Test step 2\n")); |
153 test.Printf(_L("Test step 2\n")); |
182 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP04, "Test step 2\n"); |
|
183 test.Printf(_L("(this test step uses Keyboard)\n")); |
154 test.Printf(_L("(this test step uses Keyboard)\n")); |
184 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP05, "(this test step uses Keyboard\n")); |
|
185 test.Printf(_L("Press ANY key once you have removed the 'A' connector...\n")); |
155 test.Printf(_L("Press ANY key once you have removed the 'A' connector...\n")); |
186 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP06, "Press ANY key once you have removed the 'A' connector...\n"); |
|
187 RequestCharacter(); |
156 RequestCharacter(); |
188 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncA); |
157 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncA); |
189 break; |
158 break; |
190 case EThirdStep: |
159 case EThirdStep: |
191 test.Printf(_L("key was a '%c'\n"), iKeyCodeInput); |
160 test.Printf(_L("key was a '%c'\n"), iKeyCodeInput); |
192 OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP07, "key was a '%c'\n", iKeyCodeInput); |
|
193 iWDTimer->Cancel(); |
161 iWDTimer->Cancel(); |
194 iCaseStep=EFourthStep; |
162 iCaseStep=EFourthStep; |
195 test.Printf(_L("Test step 3\n")); |
163 test.Printf(_L("Test step 3\n")); |
196 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP08, "Test step 3\n"); |
|
197 test.Printf(_L("(this test step uses Keyboard)\n")); |
164 test.Printf(_L("(this test step uses Keyboard)\n")); |
198 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP09, "(this test step uses Keyboard\n")); |
|
199 test.Printf(_L("Press <SPACE> key once you have removed the 'A' connector...\n")); |
165 test.Printf(_L("Press <SPACE> key once you have removed the 'A' connector...\n")); |
200 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP10, "Press <SPACE> key once you have removed the 'A' connector...\n"); |
|
201 RequestCharacter(); |
166 RequestCharacter(); |
202 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncB); |
167 iWDTimer->IssueRequest(KDelayDurationForUserActivityMS, this, &FuncB); |
203 |
168 |
204 break; |
169 break; |
205 case EFourthStep: |
170 case EFourthStep: |
206 test.Printf(_L("key was a '%c'\n"), iKeyCodeInput); |
171 test.Printf(_L("key was a '%c'\n"), iKeyCodeInput); |
207 OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP11, "key was a '%c'\n", iKeyCodeInput); |
|
208 test.Printf(_L("Test step 4\n")); |
172 test.Printf(_L("Test step 4\n")); |
209 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP12, "Test step 4\n"); |
|
210 iWDTimer->Cancel(); |
173 iWDTimer->Cancel(); |
211 |
174 |
212 iCaseStep=EFifthStep; |
175 iCaseStep=EFifthStep; |
213 if (' ' != iKeyCodeInput) |
176 if (' ' != iKeyCodeInput) |
214 { |
177 { |
218 SelfComplete(); |
181 SelfComplete(); |
219 break; |
182 break; |
220 case EFifthStep: |
183 case EFifthStep: |
221 iCaseStep=ESixthStep; |
184 iCaseStep=ESixthStep; |
222 test.Printf(_L("Test step 5\n")); |
185 test.Printf(_L("Test step 5\n")); |
223 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP13, "Test step 5\n"); |
|
224 test.Printf(_L("(this test uses a delay)\n")); |
186 test.Printf(_L("(this test uses a delay)\n")); |
225 OstTrace0(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP14, "(this test uses a delay\n")); |
|
226 iTimer.After(iStatus, 500000); |
187 iTimer.After(iStatus, 500000); |
227 SetActive(); |
188 SetActive(); |
228 break; |
189 break; |
229 case ESixthStep: |
190 case ESixthStep: |
230 iCaseStep=ELastStep; |
191 iCaseStep=ELastStep; |
231 test.Printf(_L("Test step 6(%d)\n"), completionCode); |
192 test.Printf(_L("Test step 6(%d)\n"), completionCode); |
232 OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP15, "Test step 6(%d)\n", completionCode); |
|
233 RequestCharacter(); |
193 RequestCharacter(); |
234 iConsole->ReadCancel(); |
194 iConsole->ReadCancel(); |
235 Cancel(); |
195 Cancel(); |
236 RequestCharacter(); |
196 RequestCharacter(); |
237 |
197 |
238 //SelfComplete(); |
198 //SelfComplete(); |
239 break; |
199 break; |
240 case ELastStep: |
200 case ELastStep: |
241 iCaseStep=ESecondStep; |
201 iCaseStep=ESecondStep; |
242 test.Printf(_L("LAST step7 code (%d)\n"), completionCode); |
202 test.Printf(_L("LAST step7 code (%d)\n"), completionCode); |
243 OstTrace1(TRACE_NORMAL, CEXAMPLETESTCASE_RUNSTEPL_DUP16, "LAST step7 code (%d)\n", completionCode); |
|
244 TestPolicy().SignalTestComplete(KErrNone); |
203 TestPolicy().SignalTestComplete(KErrNone); |
245 return TestPassed(); |
204 return TestPassed(); |
246 //break; |
205 //break; |
247 |
206 |
248 default: |
207 default: |
|
208 //test.Printf(_L("<Error> unknown test step")); |
249 Cancel(); |
209 Cancel(); |
250 TestFailed(KErrCorrupt, _L("unknown test step")); |
210 TestFailed(KErrCorrupt, _L("unknown test step")); |
251 break; |
211 break; |
252 } |
212 } |
253 |
213 |