|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class definition of CDiagTestPluginBase |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS DECLARATION |
|
20 #include <DiagTestPluginBase.h> |
|
21 |
|
22 // SYSTEM INCLUDE FILES |
|
23 #include <coemain.h> // CCoeEnv::Static() |
|
24 #include <DiagTestExecParam.h> // TDiagTestExecParam |
|
25 #include <DiagResultsDbItemBuilder.h> // CDiagResultsDbItemBuilder |
|
26 #include <DiagTestObserver.h> // MDiagTestObserver |
|
27 #include <DiagPluginConstructionParam.h> // CDiagPluginConstructionParam |
|
28 #include <DiagFrameworkDebug.h> // LOGSTRING |
|
29 #include <DiagResultDetailBasic.h> // CDiagResultDetailBasic |
|
30 #include <DiagEngineCommon.h> // MDiagEngineCommon |
|
31 #include <DiagPluginPool.h> // CDiagPluginPool |
|
32 #include <DiagResultsDatabase.h> // RDiagResultsDatabase |
|
33 #include <DiagPluginWaitingDialogWrapper.h> // CDiagPluginWaitingDialogWrapper |
|
34 #include <DiagPluginExecPlan.h> // MDiagPluginExecPlan |
|
35 #include <DiagSuitePlugin.h> // MDiagSuitePlugin |
|
36 // ADO & Platformization Changes |
|
37 #include <avkon.hrh> // EAknSoftkeyYes |
|
38 |
|
39 // USER INCLUDE FILES |
|
40 #include "diagpluginbaseutils.h" // DiagPluginBaseUtils |
|
41 #include "diagpluginbase.pan" // Panic Codes |
|
42 |
|
43 // CONSTANTS |
|
44 |
|
45 // priority of result value. Entries that are earlier have higher priority |
|
46 static const CDiagResultsDatabaseItem::TResult KResultPriority[] = |
|
47 { |
|
48 CDiagResultsDatabaseItem::EQueuedToRun, |
|
49 CDiagResultsDatabaseItem::EDependencyFailed, |
|
50 CDiagResultsDatabaseItem::EFailed, |
|
51 CDiagResultsDatabaseItem::ECancelled, |
|
52 CDiagResultsDatabaseItem::ESkipped, |
|
53 CDiagResultsDatabaseItem::EInterrupted, |
|
54 CDiagResultsDatabaseItem::EWatchdogCancel, |
|
55 CDiagResultsDatabaseItem::ENotPerformed, |
|
56 CDiagResultsDatabaseItem::ESuspended, |
|
57 CDiagResultsDatabaseItem::ESuccess |
|
58 }; |
|
59 |
|
60 static const TInt KResultPriorityCount = |
|
61 sizeof( KResultPriority ) / sizeof( CDiagResultsDatabaseItem::TResult ); |
|
62 |
|
63 // LOCAL TYPES |
|
64 class CDiagTestPluginBase::TPrivateData |
|
65 { |
|
66 public: // Constructor |
|
67 // Note that this is not a C-class, and ALL member must be explicitly initialized. |
|
68 TPrivateData( CCoeEnv& aCoeEnv ) |
|
69 : iDtorIdKey( TUid::Null() ), |
|
70 iPluginResourceLoader( aCoeEnv ), |
|
71 iWaitingDialogWrapper( NULL ), |
|
72 iResultBuilder( NULL ), |
|
73 iExecParam( NULL ), |
|
74 iCustomParam( NULL ), |
|
75 iDependencyCheckSkipped( EFalse ), |
|
76 iDependencyExecution( EFalse ), |
|
77 iSinglePluginExecution( EFalse ), |
|
78 iWatchdogResultType( CDiagResultsDatabaseItem::EWatchdogCancel ) |
|
79 {} |
|
80 |
|
81 public: |
|
82 /** |
|
83 * ECOM Destructor key. |
|
84 */ |
|
85 TUid iDtorIdKey; |
|
86 |
|
87 /** |
|
88 * Resource loader for derived class resource. |
|
89 */ |
|
90 RConeResourceLoader iPluginResourceLoader; |
|
91 |
|
92 /** |
|
93 * Wrapper class for displaying waiting dialogs. |
|
94 * Ownership: Shared. Normally, dialog will dismiss itself. However, |
|
95 * if plug-in is being deleted, it can be deleted by the plug-in as well. |
|
96 */ |
|
97 CDiagPluginWaitingDialogWrapper* iWaitingDialogWrapper; |
|
98 |
|
99 /** |
|
100 * Results Db Item Builder. This will be used to build the result db item. |
|
101 * Owneship: this. |
|
102 */ |
|
103 CDiagResultsDbItemBuilder* iResultBuilder; |
|
104 |
|
105 /** |
|
106 * Test execution parameter. |
|
107 * Ownership: this. |
|
108 */ |
|
109 TDiagTestExecParam* iExecParam; |
|
110 |
|
111 /** |
|
112 * Custom test execution parameter |
|
113 * Ownership: Does not own. Owned by application. |
|
114 */ |
|
115 TAny* iCustomParam; |
|
116 |
|
117 /** |
|
118 * This indicates whether this test session has skipped dependency check. |
|
119 */ |
|
120 TBool iDependencyCheckSkipped; |
|
121 |
|
122 /** |
|
123 * This indicates whether this test is being executed to satisfy dependency. |
|
124 */ |
|
125 TBool iDependencyExecution; |
|
126 |
|
127 /** |
|
128 * Indicates if the plugin is run as a single plugin |
|
129 * or as a part of suite |
|
130 */ |
|
131 TBool iSinglePluginExecution; |
|
132 |
|
133 /** |
|
134 * Result type to use when watchdog is timed out. |
|
135 */ |
|
136 CDiagResultsDatabaseItem::TResult iWatchdogResultType; |
|
137 }; |
|
138 |
|
139 // ======== LOCAL FUNCTIONS ======== |
|
140 |
|
141 // ======== MEMBER FUNCTIONS ======== |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CDiagTestPluginBase::CDiagTestPluginBase |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C CDiagTestPluginBase::CDiagTestPluginBase( |
|
148 CDiagPluginConstructionParam* aParam ) |
|
149 : CActive( EPriorityStandard ), |
|
150 iConstructionParam( aParam ), |
|
151 iCoeEnv ( *CCoeEnv::Static() ) |
|
152 { |
|
153 __ASSERT_ALWAYS( aParam, Panic( EDiagPluginBasePanicBadArgument ) ); |
|
154 |
|
155 CActiveScheduler::Add(this); |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CDiagTestPluginBase::BaseConstructL |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C void CDiagTestPluginBase::BaseConstructL( const TDesC& aResourceFileName ) |
|
163 { |
|
164 iData = new ( ELeave ) TPrivateData( CoeEnv() ); |
|
165 |
|
166 DiagPluginBaseUtils::OpenResourceFileL( |
|
167 aResourceFileName, iData->iPluginResourceLoader, CoeEnv().FsSession() ); |
|
168 } |
|
169 |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // CDiagTestPluginBase::~CDiagTestPluginBase |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 EXPORT_C CDiagTestPluginBase::~CDiagTestPluginBase() |
|
176 { |
|
177 if ( iData ) |
|
178 { |
|
179 // In case test was still running, clean up. |
|
180 // It takes care of: |
|
181 // iData->iWaitingDialog |
|
182 // iData->iIsDialogDismessedByUserResponsePtr |
|
183 // iData->iResultBuilder |
|
184 // iData->iExecParam |
|
185 // It must be trapped, since it is part of object destruction. |
|
186 TRAPD( err, StopAndCleanupL() ); |
|
187 if ( err != KErrNone ) |
|
188 { |
|
189 LOGSTRING3( "CDiagTestPluginBase::~CDiagTestPluginBase(). " |
|
190 L"StopAndCleaupL() failed Uid = 0x%08x , err = %d", |
|
191 Uid(), |
|
192 err ); |
|
193 } |
|
194 |
|
195 // Call DestroyedImplementation only if it was set. |
|
196 // SetDtorIdKey may not have been called if it is not actually an |
|
197 // ECOM plug-in. |
|
198 if ( iData->iDtorIdKey != TUid::Null() ) |
|
199 { |
|
200 REComSession::DestroyedImplementation( iData->iDtorIdKey ); |
|
201 } |
|
202 |
|
203 iData->iPluginResourceLoader.Close(); |
|
204 |
|
205 delete iData; |
|
206 iData = NULL; |
|
207 } |
|
208 |
|
209 delete iConstructionParam; |
|
210 iConstructionParam = NULL; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // From CActive |
|
215 // CDiagTestPluginBase::RunError |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 EXPORT_C TInt CDiagTestPluginBase::RunError( TInt aError ) |
|
219 { |
|
220 LOGSTRING2( "CDiagTestPluginBase::RunError( %d )", aError ) |
|
221 |
|
222 // Check if we are executing a test. |
|
223 if ( iData->iExecParam != NULL ) |
|
224 { |
|
225 // Catch error from CompleteTestL. If there is an error while calling |
|
226 // CompleteTestL(), return the error to active scheduler. |
|
227 aError = KErrNone; |
|
228 TRAP( aError, CompleteTestL( CDiagResultsDatabaseItem::EFailed ) ); |
|
229 } |
|
230 |
|
231 return aError; |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // From MDiagTestPlugin |
|
236 // CDiagTestPluginBase::GetServiceLogicalNameL |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 EXPORT_C const TDesC& CDiagTestPluginBase::ServiceLogicalName() const |
|
240 { |
|
241 return iConstructionParam->ServiceProvided(); |
|
242 } |
|
243 |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // From MDiagTestPlugin |
|
247 // CDiagTestPluginBase::GetLogicalDependenciesL |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 EXPORT_C void CDiagTestPluginBase::GetLogicalDependenciesL( |
|
251 CPtrCArray& aArray ) const |
|
252 { |
|
253 aArray.CopyL( iConstructionParam->ServicesRequired() ); |
|
254 } |
|
255 |
|
256 |
|
257 // --------------------------------------------------------------------------- |
|
258 // From MDiagTestPlugin |
|
259 // CDiagTestPluginBase::Type |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 EXPORT_C MDiagPlugin::TPluginType CDiagTestPluginBase::Type() const |
|
263 { |
|
264 return ETypeTestPlugin; |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // From MDiagTestPlugin |
|
269 // CDiagTestPluginBase::CreateIconL |
|
270 // --------------------------------------------------------------------------- |
|
271 // |
|
272 EXPORT_C CGulIcon* CDiagTestPluginBase::CreateIconL() const |
|
273 { |
|
274 return NULL; |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // From MDiagTestPlugin |
|
279 // CDiagTestPluginBase::IsSupported |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 EXPORT_C TBool CDiagTestPluginBase::IsSupported() const |
|
283 { |
|
284 return ETrue; |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // From MDiagTestPlugin |
|
289 // CDiagTestPluginBase::ParentUid |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 EXPORT_C TUid CDiagTestPluginBase::ParentUid() const |
|
293 { |
|
294 return iConstructionParam->ParentUid(); |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // From MDiagTestPlugin |
|
299 // CDiagTestPluginBase::Order |
|
300 // --------------------------------------------------------------------------- |
|
301 // |
|
302 EXPORT_C TUint CDiagTestPluginBase::Order() const |
|
303 { |
|
304 return iConstructionParam->Order(); |
|
305 } |
|
306 |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // From MDiagTestPlugin |
|
310 // CDiagTestPluginBase::SetDtorIdKey |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 EXPORT_C void CDiagTestPluginBase::SetDtorIdKey( TUid aDtorIdKey ) |
|
314 { |
|
315 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
316 LOGSTRING3( "CDiagTestPluginBase::SetDtorIdKey: Old=0x%x, New=0x%x", |
|
317 iData->iDtorIdKey.iUid, aDtorIdKey.iUid ) |
|
318 iData->iDtorIdKey = aDtorIdKey; |
|
319 } |
|
320 |
|
321 // --------------------------------------------------------------------------- |
|
322 // From MDiagTestPlugin |
|
323 // CDiagTestPluginBase::GetTitleL |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 EXPORT_C HBufC* CDiagTestPluginBase::GetTitleL() const |
|
327 { |
|
328 // Currently, GetTitleL() is not supported. |
|
329 User::Leave( KErrNotSupported ); |
|
330 return NULL; |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // From MDiagTestPlugin |
|
335 // CDiagTestPluginBase::GetDescriptionL |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 EXPORT_C HBufC* CDiagTestPluginBase::GetDescriptionL() const |
|
339 { |
|
340 // Currently, GetDescriptionL() is not supported. |
|
341 User::Leave( KErrNotSupported ); |
|
342 return NULL; |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // From MDiagTestPlugin |
|
347 // CDiagTestPluginBase::CustomOperationL |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 EXPORT_C TAny* CDiagTestPluginBase::CustomOperationL( TUid /* aUid */, |
|
351 TAny* /* aParam */ ) |
|
352 { |
|
353 LOGSTRING( "CDiagTestPluginBase::CustomOperationL: KErrNotSupported" ) |
|
354 User::Leave( KErrNotSupported ); |
|
355 return NULL; |
|
356 } |
|
357 |
|
358 |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // From MDiagTestPlugin |
|
362 // CDiagTestPluginBase::GetCustomL |
|
363 // --------------------------------------------------------------------------- |
|
364 // |
|
365 EXPORT_C TAny* CDiagTestPluginBase::GetCustomL( TUid /* aUid*/, |
|
366 TAny* /* aParam */ ) |
|
367 { |
|
368 LOGSTRING( "CDiagTestPluginBase::GetCustomL: KErrNotSupported" ) |
|
369 User::Leave( KErrNotSupported ); |
|
370 return NULL; |
|
371 } |
|
372 |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // From MDiagTestPlugin |
|
376 // CDiagTestPluginBase::TestSessionBeginL |
|
377 // --------------------------------------------------------------------------- |
|
378 // |
|
379 EXPORT_C void CDiagTestPluginBase::TestSessionBeginL( |
|
380 MDiagEngineCommon& /* aEngine */, |
|
381 TBool /* aSkipDependencyCheck */, |
|
382 TAny* /* aCustomParams */ ) |
|
383 { |
|
384 } |
|
385 |
|
386 // --------------------------------------------------------------------------- |
|
387 // From MDiagTestPlugin |
|
388 // CDiagTestPluginBase::TestSessionEndL |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 EXPORT_C void CDiagTestPluginBase::TestSessionEndL( |
|
392 MDiagEngineCommon& /* aEngine */, |
|
393 TBool /* aSkipDependencyCheck */, |
|
394 TAny* /* aCustomParams */ ) |
|
395 { |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // From CDiagTestPluginBase |
|
400 // CDiagTestPluginBase::RunTestL |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 EXPORT_C void CDiagTestPluginBase::RunTestL( |
|
404 TDiagTestExecParam* aExecParam, |
|
405 TBool aSkipDependencyCheck, |
|
406 TBool aDependencyExecution, |
|
407 TAny* aCustomParam ) |
|
408 { |
|
409 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
410 __ASSERT_DEBUG( iData->iExecParam == NULL, Panic( EDiagPluginBasePanicInternal ) ); |
|
411 __ASSERT_DEBUG( iData->iResultBuilder == NULL, Panic( EDiagPluginBasePanicInternal ) ); |
|
412 delete iData->iExecParam; |
|
413 delete iData->iResultBuilder; |
|
414 |
|
415 iData->iExecParam = aExecParam; |
|
416 iData->iCustomParam = aCustomParam; |
|
417 iData->iDependencyCheckSkipped = aSkipDependencyCheck; |
|
418 iData->iDependencyExecution = aDependencyExecution; |
|
419 iData->iResultBuilder = CDiagResultsDbItemBuilder::NewL( Uid(), aDependencyExecution ); |
|
420 ResetWatchdogToDefault(); |
|
421 |
|
422 // checking if this is a single test execution or not |
|
423 iData->iSinglePluginExecution = |
|
424 ( aExecParam->Engine().ExecutionPlanL().TestCount( EFalse ) == 1 ); |
|
425 |
|
426 // verify that dependencies are satisfied. |
|
427 RArray<TUid>* failedUids = NULL; |
|
428 CDiagResultsDatabaseItem::TResult dependencyResult = CDiagResultsDatabaseItem::ESuccess; |
|
429 |
|
430 if ( !aSkipDependencyCheck ) |
|
431 { |
|
432 dependencyResult = VerifyDependenciesL( |
|
433 aExecParam->Engine(), |
|
434 failedUids ); |
|
435 } |
|
436 |
|
437 if(dependencyResult == CDiagResultsDatabaseItem::ESuccess) |
|
438 LOGSTRING( "This is to remove compiler warning"); |
|
439 |
|
440 |
|
441 if ( failedUids ) |
|
442 { |
|
443 failedUids->Reset(); |
|
444 failedUids->Close(); |
|
445 delete failedUids; |
|
446 failedUids = NULL; |
|
447 } |
|
448 DoRunTestL(); |
|
449 /*if ( dependencyResult == CDiagResultsDatabaseItem::ESuccess ) |
|
450 { |
|
451 |
|
452 } |
|
453 else |
|
454 { |
|
455 // Create dependency failed test result and send it to engine. |
|
456 // Note that we can't actually call CompleteTestL(), or StopAndCleanupL() |
|
457 // here because we haven't actually called the derived class. |
|
458 // So, reporting and clean up must be done manually. |
|
459 |
|
460 // Map dependent test result to what we should report. |
|
461 switch ( dependencyResult ) |
|
462 { |
|
463 case CDiagResultsDatabaseItem::EFailed: |
|
464 dependencyResult = CDiagResultsDatabaseItem::EDependencyFailed; |
|
465 break; |
|
466 |
|
467 case CDiagResultsDatabaseItem::EWatchdogCancel: |
|
468 case CDiagResultsDatabaseItem::ESkipped: |
|
469 case CDiagResultsDatabaseItem::EInterrupted: |
|
470 case CDiagResultsDatabaseItem::ENotPerformed: |
|
471 dependencyResult = CDiagResultsDatabaseItem::EDependencySkipped; |
|
472 break; |
|
473 |
|
474 default: |
|
475 // no change is needed. |
|
476 break; |
|
477 } |
|
478 |
|
479 iData->iResultBuilder->SetTestCompleted( dependencyResult ); |
|
480 |
|
481 iData->iExecParam->Observer().TestExecutionCompletedL( *this, |
|
482 iData->iResultBuilder->ToResultsDatabaseItemL() ); |
|
483 |
|
484 BaseStopAndCleanup(); |
|
485 }*/ |
|
486 } |
|
487 |
|
488 // --------------------------------------------------------------------------- |
|
489 // CDiagTestPluginBase::ExecutionParam |
|
490 // --------------------------------------------------------------------------- |
|
491 // |
|
492 EXPORT_C TDiagTestExecParam& CDiagTestPluginBase::ExecutionParam() |
|
493 { |
|
494 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
495 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
496 return *(iData->iExecParam); |
|
497 } |
|
498 |
|
499 // --------------------------------------------------------------------------- |
|
500 // CDiagTestPluginBase::IsDependencyCheckSkipped |
|
501 // --------------------------------------------------------------------------- |
|
502 // |
|
503 EXPORT_C TBool CDiagTestPluginBase::IsDependencyCheckSkipped() const |
|
504 { |
|
505 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
506 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
507 return iData->iDependencyCheckSkipped; |
|
508 } |
|
509 |
|
510 // --------------------------------------------------------------------------- |
|
511 // CDiagTestPluginBase::IsDependencyExecution |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 EXPORT_C TBool CDiagTestPluginBase::IsDependencyExecution() const |
|
515 { |
|
516 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
517 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
518 return iData->iDependencyExecution; |
|
519 } |
|
520 |
|
521 // --------------------------------------------------------------------------- |
|
522 // CDiagTestPluginBase::CustomParam |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 EXPORT_C TAny* CDiagTestPluginBase::CustomParam() const |
|
526 { |
|
527 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
528 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
529 return iData->iCustomParam; |
|
530 } |
|
531 |
|
532 // --------------------------------------------------------------------------- |
|
533 // CDiagTestPluginBase::ResultsDbItemBuilder |
|
534 // --------------------------------------------------------------------------- |
|
535 // |
|
536 EXPORT_C CDiagResultsDbItemBuilder& CDiagTestPluginBase::ResultsDbItemBuilder() |
|
537 { |
|
538 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
539 __ASSERT_ALWAYS( iData->iResultBuilder, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
540 return *(iData->iResultBuilder); |
|
541 } |
|
542 |
|
543 // --------------------------------------------------------------------------- |
|
544 // CDiagTestPluginBase::ReportTestProgressL |
|
545 // --------------------------------------------------------------------------- |
|
546 // |
|
547 EXPORT_C void CDiagTestPluginBase::ReportTestProgressL( TUint aCurrentStep ) |
|
548 { |
|
549 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
550 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
551 |
|
552 iData->iExecParam->Observer().TestProgressL( *this, aCurrentStep ); |
|
553 } |
|
554 |
|
555 // --------------------------------------------------------------------------- |
|
556 // CDiagTestPluginBase::ResetWatchdog |
|
557 // --------------------------------------------------------------------------- |
|
558 // |
|
559 EXPORT_C void CDiagTestPluginBase::ResetWatchdog( |
|
560 TDiagEngineWatchdogTypes aWatchdogType, |
|
561 CDiagResultsDatabaseItem::TResult aWatchdogResultType ) |
|
562 { |
|
563 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
564 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
565 |
|
566 LOGSTRING3( "CDiagTestPluginBase::ResetWatchdog() Type = %d, result = %d", |
|
567 aWatchdogType, aWatchdogResultType ) |
|
568 |
|
569 iData->iWatchdogResultType = aWatchdogResultType; |
|
570 iData->iExecParam->Engine().ResetWatchdog( aWatchdogType ); |
|
571 } |
|
572 |
|
573 // --------------------------------------------------------------------------- |
|
574 // CDiagTestPluginBase::ResetWatchdog |
|
575 // --------------------------------------------------------------------------- |
|
576 // |
|
577 EXPORT_C void CDiagTestPluginBase::ResetWatchdog( |
|
578 TInt aTimeToCompletion, |
|
579 CDiagResultsDatabaseItem::TResult aWatchdogResultType ) |
|
580 { |
|
581 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
582 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
583 |
|
584 LOGSTRING3( "CDiagTestPluginBase::ResetWatchdog() time = %d, result = %d", |
|
585 aTimeToCompletion, aWatchdogResultType ) |
|
586 |
|
587 iData->iWatchdogResultType = aWatchdogResultType; |
|
588 iData->iExecParam->Engine().ResetWatchdog( aTimeToCompletion ); |
|
589 } |
|
590 |
|
591 // --------------------------------------------------------------------------- |
|
592 // CDiagTestPluginBase::ResetWatchdogToDefault |
|
593 // --------------------------------------------------------------------------- |
|
594 // |
|
595 EXPORT_C void CDiagTestPluginBase::ResetWatchdogToDefault() |
|
596 { |
|
597 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
598 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
599 |
|
600 if ( RunMode() == EAutomatic ) |
|
601 { |
|
602 ResetWatchdog( EDiagEngineWatchdogTypeAutomatic, |
|
603 CDiagResultsDatabaseItem::EWatchdogCancel ); |
|
604 } |
|
605 else |
|
606 { |
|
607 ResetWatchdog( EDiagEngineWatchdogTypeInteractive, |
|
608 CDiagResultsDatabaseItem::EWatchdogCancel ); |
|
609 } |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------------------------- |
|
613 // CDiagTestPluginBase::CompleteTestL |
|
614 // --------------------------------------------------------------------------- |
|
615 // |
|
616 EXPORT_C void CDiagTestPluginBase::CompleteTestL( |
|
617 CDiagResultsDatabaseItem::TResult aResult ) |
|
618 { |
|
619 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
620 __ASSERT_ALWAYS( iData->iResultBuilder, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
621 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
622 |
|
623 iData->iResultBuilder->SetTestCompleted( aResult ); |
|
624 iData->iExecParam->Observer().TestExecutionCompletedL( *this, |
|
625 iData->iResultBuilder->ToResultsDatabaseItemL() ); |
|
626 |
|
627 StopAndCleanupL(); |
|
628 } |
|
629 |
|
630 // --------------------------------------------------------------------------- |
|
631 // CDiagTestPluginBase::StopAndCleanupL |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 EXPORT_C void CDiagTestPluginBase::StopAndCleanupL() |
|
635 { |
|
636 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
637 // Cancel active request |
|
638 Cancel(); |
|
639 |
|
640 // Clean up only if it was already running. |
|
641 if ( iData->iExecParam != NULL || iData->iResultBuilder != NULL ) |
|
642 { |
|
643 // allow derived class to clean up first. |
|
644 DoStopAndCleanupL(); |
|
645 |
|
646 BaseStopAndCleanup(); |
|
647 } |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // from MDiagTestPlugin |
|
652 // CDiagTestPluginBase::ExecutionStopL |
|
653 // --------------------------------------------------------------------------- |
|
654 // |
|
655 EXPORT_C CDiagResultsDatabaseItem* CDiagTestPluginBase::ExecutionStopL( |
|
656 MDiagTestPlugin::TStopReason aReason ) |
|
657 { |
|
658 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
659 __ASSERT_ALWAYS( iData->iResultBuilder, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
660 __ASSERT_ALWAYS( iData->iExecParam, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
661 |
|
662 // Determine default reason. |
|
663 CDiagResultsDatabaseItem::TResult result; |
|
664 |
|
665 if ( aReason == MDiagTestPlugin::EWatchdog ) |
|
666 { |
|
667 result = iData->iWatchdogResultType; |
|
668 } |
|
669 else |
|
670 { |
|
671 result = CDiagResultsDatabaseItem::EInterrupted; |
|
672 } |
|
673 |
|
674 // Allow derived class to provide custom behavor |
|
675 DoExecutionStopL( aReason, result ); |
|
676 |
|
677 iData->iResultBuilder->SetTestCompleted( result ); |
|
678 |
|
679 CDiagResultsDatabaseItem* dbItem = iData->iResultBuilder->ToResultsDatabaseItemL(); |
|
680 |
|
681 // Stop and clean up before returning to the engine. |
|
682 CleanupStack::PushL( dbItem ); |
|
683 StopAndCleanupL(); |
|
684 CleanupStack::Pop( dbItem ); |
|
685 |
|
686 return dbItem; // ownership transfer |
|
687 } |
|
688 |
|
689 // --------------------------------------------------------------------------- |
|
690 // From MDiagTestPlugin |
|
691 // CDiagTestPluginBase::SuspendL |
|
692 // --------------------------------------------------------------------------- |
|
693 // |
|
694 EXPORT_C void CDiagTestPluginBase::SuspendL() |
|
695 { |
|
696 LOGSTRING( "CDiagTestPluginBase::SuspendL: KErrNotSupported" ) |
|
697 User::Leave( KErrNotSupported ); |
|
698 } |
|
699 |
|
700 // --------------------------------------------------------------------------- |
|
701 // From MDiagTestPlugin |
|
702 // CDiagTestPluginBase::ResumeL |
|
703 // --------------------------------------------------------------------------- |
|
704 // |
|
705 EXPORT_C void CDiagTestPluginBase::ResumeL() |
|
706 { |
|
707 LOGSTRING( "CDiagTestPluginBase::ResumeL: KErrNotSupported" ) |
|
708 User::Leave( KErrNotSupported ); |
|
709 } |
|
710 |
|
711 // --------------------------------------------------------------------------- |
|
712 // From MDiagTestPlugin |
|
713 // CDiagTestPluginBase::CreateDetailL |
|
714 // --------------------------------------------------------------------------- |
|
715 EXPORT_C MDiagResultDetail* CDiagTestPluginBase::CreateDetailL( |
|
716 const CDiagResultsDatabaseItem& aResult ) const |
|
717 { |
|
718 // Use basic version by default |
|
719 return new( ELeave )CDiagResultDetailBasic( aResult.TestResult() ); |
|
720 } |
|
721 |
|
722 |
|
723 // --------------------------------------------------------------------------- |
|
724 // CDiagTestPluginBase::DoExecutionStopL |
|
725 // --------------------------------------------------------------------------- |
|
726 // |
|
727 EXPORT_C void CDiagTestPluginBase::DoExecutionStopL( |
|
728 MDiagTestPlugin::TStopReason /* aReason */, |
|
729 CDiagResultsDatabaseItem::TResult& /* aTestResult */ ) |
|
730 { |
|
731 // default implementation. Does nothing. |
|
732 } |
|
733 |
|
734 // --------------------------------------------------------------------------- |
|
735 // CDiagTestPluginBase::AreDependenciesSatisfiedL |
|
736 // --------------------------------------------------------------------------- |
|
737 // |
|
738 EXPORT_C TBool CDiagTestPluginBase::AreDependenciesSatisfiedL( |
|
739 MDiagEngineCommon& aEngine, |
|
740 RArray<TUid>*& aFailedUids ) const |
|
741 { |
|
742 CDiagResultsDatabaseItem::TResult result = VerifyDependenciesL( aEngine, aFailedUids ); |
|
743 |
|
744 return result == CDiagResultsDatabaseItem::ESuccess; |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------------------------- |
|
748 // CDiagTestPluginBase::VerifyDependenciesL |
|
749 // --------------------------------------------------------------------------- |
|
750 // |
|
751 EXPORT_C CDiagResultsDatabaseItem::TResult CDiagTestPluginBase::VerifyDependenciesL( |
|
752 MDiagEngineCommon& aEngine, |
|
753 RArray< TUid >*& aFailedUids ) const |
|
754 { |
|
755 // Create a failed uid list array |
|
756 RArray<TUid>* failedUids = new( ELeave )RArray<TUid>(); |
|
757 CleanupStack::PushL( failedUids ); // to delete array itself. |
|
758 CleanupClosePushL( *failedUids ); // to call close. |
|
759 |
|
760 // First, convert dependency list to a plugin list |
|
761 RPointerArray< MDiagTestPlugin > pluginList; |
|
762 CleanupClosePushL( pluginList ); // destroy not needed since elements are not owned. |
|
763 |
|
764 // Expand suites. |
|
765 GetAllDependentTestsL( aEngine, pluginList ); |
|
766 |
|
767 // Analyze result of each plug-in. |
|
768 CDiagResultsDatabaseItem::TResult result = |
|
769 SummarizeOverallTestResultsL( aEngine, pluginList, *failedUids ); |
|
770 |
|
771 CleanupStack::PopAndDestroy( &pluginList ); // pluginList.Close() |
|
772 |
|
773 if ( result == CDiagResultsDatabaseItem::ESuccess ) |
|
774 { |
|
775 __ASSERT_DEBUG( failedUids->Count() == 0, |
|
776 Panic( EDiagPluginBasePanicInternal ) ); |
|
777 CleanupStack::PopAndDestroy( failedUids ); // call close. |
|
778 CleanupStack::PopAndDestroy( failedUids ); // delete RArray |
|
779 failedUids = NULL; |
|
780 } |
|
781 else |
|
782 { |
|
783 __ASSERT_DEBUG( failedUids->Count() > 0, |
|
784 Panic( EDiagPluginBasePanicInternal ) ); |
|
785 CleanupStack::Pop( failedUids ); // call close. |
|
786 CleanupStack::Pop( failedUids ); // delete RArray |
|
787 } |
|
788 |
|
789 aFailedUids = failedUids; |
|
790 |
|
791 return result; |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // CDiagTestPluginBase::GetAllDependentTestsL |
|
796 // --------------------------------------------------------------------------- |
|
797 // |
|
798 void CDiagTestPluginBase::GetAllDependentTestsL( |
|
799 MDiagEngineCommon& aEngine, |
|
800 RPointerArray< MDiagTestPlugin >& aPluginList ) const |
|
801 { |
|
802 TInt i = 0; |
|
803 |
|
804 // first create an array of dependent plug-ins. |
|
805 RPointerArray< MDiagPlugin > mixedPluginList; |
|
806 CleanupClosePushL( mixedPluginList ); // to call close. |
|
807 |
|
808 CPtrCArray* dependencyList = new( ELeave )CPtrCArray( 1 ); |
|
809 CleanupStack::PushL( dependencyList ); |
|
810 GetLogicalDependenciesL( *dependencyList ); |
|
811 |
|
812 TInt count = dependencyList->Count(); |
|
813 for ( i = 0; i < count; i++ ) |
|
814 { |
|
815 MDiagPlugin* plugin = NULL; |
|
816 User::LeaveIfError( aEngine.PluginPool().FindPlugin( ( *dependencyList )[i], plugin ) ); |
|
817 mixedPluginList.AppendL( plugin ); |
|
818 } |
|
819 |
|
820 CleanupStack::PopAndDestroy( dependencyList ); |
|
821 dependencyList = NULL; |
|
822 |
|
823 // expand suites into tests. |
|
824 i = 0; |
|
825 while ( i < mixedPluginList.Count() ) |
|
826 { |
|
827 if ( mixedPluginList[i]->Type() == ETypeTestPlugin ) |
|
828 { |
|
829 // test plug-in. move to next item. |
|
830 aPluginList.AppendL( static_cast< MDiagTestPlugin* >( mixedPluginList[i] ) ); |
|
831 i++; |
|
832 } |
|
833 else |
|
834 { |
|
835 // suite. remove and replace them with its children. |
|
836 MDiagSuitePlugin& suitePlugin = |
|
837 static_cast< MDiagSuitePlugin& >( *mixedPluginList[i] ); |
|
838 |
|
839 mixedPluginList.Remove( i ); |
|
840 |
|
841 RPointerArray<MDiagPlugin> children; |
|
842 CleanupClosePushL( children ); // destroy not needed since ownership not transferred. |
|
843 |
|
844 suitePlugin.GetChildrenL( children, MDiagSuitePlugin::ESortByPosition ); |
|
845 |
|
846 TInt childCount = children.Count(); |
|
847 for ( TInt childIndex = 0; childIndex < childCount; childIndex++ ) |
|
848 { |
|
849 mixedPluginList.InsertL( children[childIndex], i + childIndex ); |
|
850 } |
|
851 |
|
852 CleanupStack::PopAndDestroy( &children ); // children.Close() |
|
853 // do not increment 'i' to allow re-examination of item just inserted. |
|
854 } |
|
855 } |
|
856 |
|
857 CleanupStack::PopAndDestroy( &mixedPluginList ); // mixedPluginList.Close() |
|
858 } |
|
859 |
|
860 // --------------------------------------------------------------------------- |
|
861 // CDiagTestPluginBase::SummarizeOverallTestResultsL |
|
862 // --------------------------------------------------------------------------- |
|
863 // |
|
864 CDiagResultsDatabaseItem::TResult CDiagTestPluginBase::SummarizeOverallTestResultsL( |
|
865 MDiagEngineCommon& aEngine, |
|
866 const RPointerArray< MDiagTestPlugin >& aPluginList, |
|
867 RArray< TUid >& aFailedUidList ) const |
|
868 { |
|
869 // Check result of each item. |
|
870 // and the result will override it. |
|
871 // by default, we start with ESuccess. |
|
872 CDiagResultsDatabaseItem::TResult result = CDiagResultsDatabaseItem::ESuccess; |
|
873 TInt pluginListCount = aPluginList.Count(); |
|
874 for ( TInt i = 0; i < pluginListCount; i++ ) |
|
875 { |
|
876 MDiagTestPlugin& plugin = *( aPluginList[i] ); |
|
877 |
|
878 CDiagResultsDatabaseItem* resultItem = NULL; |
|
879 TInt err = aEngine.DbRecord().GetTestResult( plugin.Uid(), resultItem ); |
|
880 |
|
881 // KErrNotFound is acceptable. |
|
882 if ( err != KErrNone && err != KErrNotFound ) |
|
883 { |
|
884 delete resultItem; |
|
885 User::Leave( err ); |
|
886 } |
|
887 |
|
888 CDiagResultsDatabaseItem::TResult newResult; |
|
889 if ( resultItem == NULL ) |
|
890 { |
|
891 newResult = CDiagResultsDatabaseItem::EQueuedToRun; |
|
892 } |
|
893 else |
|
894 { |
|
895 newResult = resultItem->TestResult(); |
|
896 } |
|
897 |
|
898 delete resultItem; |
|
899 resultItem = NULL; |
|
900 |
|
901 // add items to failed list if not successful. |
|
902 if ( newResult != CDiagResultsDatabaseItem::ESuccess ) |
|
903 { |
|
904 LOGSTRING3( "CDiagTestPluginBase::SummarizeOverallTestResultsL(): " |
|
905 L"Failed test 0x%08x, result = %d", |
|
906 plugin.Uid().iUid, |
|
907 newResult ) |
|
908 aFailedUidList.AppendL( plugin.Uid() ); |
|
909 } |
|
910 |
|
911 // update to new result based on result priority. |
|
912 // check for condition where newResult == result. If they are equal |
|
913 // there is no reason to run the loop. |
|
914 for ( TInt priorityIndex = 0; |
|
915 priorityIndex < KResultPriorityCount && newResult != result; |
|
916 priorityIndex++ ) |
|
917 { |
|
918 if ( KResultPriority[priorityIndex] == newResult ) |
|
919 { |
|
920 result = newResult; |
|
921 } |
|
922 } |
|
923 } |
|
924 |
|
925 LOGSTRING3( "CDiagTestPluginBase::SummarizeOverallTestResultsL(): " |
|
926 L"Plugin 0x%08x Overall depencency result = %d", |
|
927 Uid().iUid, |
|
928 result ) |
|
929 return result; |
|
930 } |
|
931 |
|
932 |
|
933 // --------------------------------------------------------------------------- |
|
934 // CDiagTestPluginBase::RunWaitingDialogL |
|
935 // --------------------------------------------------------------------------- |
|
936 EXPORT_C TBool CDiagTestPluginBase::RunWaitingDialogL( CAknDialog* aDialog, |
|
937 TInt& aDialogResponse ) |
|
938 { |
|
939 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
940 |
|
941 // this function can display only one dialog at a time. |
|
942 __ASSERT_ALWAYS( iData->iWaitingDialogWrapper == NULL, |
|
943 Panic( EDiagPluginBasePanicDialogAlreadyUp ) ); |
|
944 |
|
945 iData->iWaitingDialogWrapper = CDiagPluginWaitingDialogWrapper::NewL( aDialog ); |
|
946 |
|
947 TBool isUserResonse = iData->iWaitingDialogWrapper->RunLD( aDialogResponse ); |
|
948 |
|
949 if ( isUserResonse ) |
|
950 { |
|
951 // local variable can be accessed only if it was returned due to |
|
952 // user response. |
|
953 iData->iWaitingDialogWrapper = NULL; |
|
954 } |
|
955 |
|
956 return isUserResonse; |
|
957 } |
|
958 |
|
959 // --------------------------------------------------------------------------- |
|
960 // CDiagTestPluginBase::DismissWaitingDialog |
|
961 // --------------------------------------------------------------------------- |
|
962 EXPORT_C void CDiagTestPluginBase::DismissWaitingDialog() |
|
963 { |
|
964 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
965 |
|
966 if ( iData->iWaitingDialogWrapper ) |
|
967 { |
|
968 LOGSTRING( "CDiagTestPluginBase::DismissWaitingDialog() Dialog dismissed." ) |
|
969 delete iData->iWaitingDialogWrapper; |
|
970 iData->iWaitingDialogWrapper = NULL; |
|
971 } |
|
972 } |
|
973 |
|
974 // --------------------------------------------------------------------------- |
|
975 // CDiagTestPluginBase::CoeEnv |
|
976 // --------------------------------------------------------------------------- |
|
977 // |
|
978 EXPORT_C CCoeEnv& CDiagTestPluginBase::CoeEnv() |
|
979 { |
|
980 return iCoeEnv; |
|
981 } |
|
982 |
|
983 // --------------------------------------------------------------------------- |
|
984 // CDiagTestPluginBase::SinglePluginExecution |
|
985 // --------------------------------------------------------------------------- |
|
986 // |
|
987 EXPORT_C TBool CDiagTestPluginBase::SinglePluginExecution() const |
|
988 { |
|
989 __ASSERT_ALWAYS( iData, Panic( EDiagPluginBasePanicInvalidState ) ); |
|
990 return iData->iSinglePluginExecution; |
|
991 } |
|
992 |
|
993 // --------------------------------------------------------------------------- |
|
994 // CDiagTestPluginBase::BaseStopAndCleanup |
|
995 // --------------------------------------------------------------------------- |
|
996 // |
|
997 void CDiagTestPluginBase::BaseStopAndCleanup() |
|
998 { |
|
999 DismissWaitingDialog(); |
|
1000 |
|
1001 delete iData->iResultBuilder; |
|
1002 iData->iResultBuilder = NULL; |
|
1003 |
|
1004 delete iData->iExecParam; |
|
1005 iData->iExecParam = NULL; |
|
1006 |
|
1007 iData->iCustomParam = NULL; |
|
1008 } |
|
1009 |
|
1010 // ADO & Platformization Changes |
|
1011 /* |
|
1012 |
|
1013 // --------------------------------------------------------------------------- |
|
1014 // CDiagSpeakerPlugin::AskCancelExecutionL |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // |
|
1017 EXPORT_C TInt CDiagTestPluginBase::AskCancelExecutionL( TInt& aButtonId ) |
|
1018 { |
|
1019 LOGSTRING( "CDiagTestPluginBase::AskCancelExecutionL() IN" ) |
|
1020 |
|
1021 CAknDialog* dialog; |
|
1022 TBool result; |
|
1023 |
|
1024 // set softkey for single execution |
|
1025 if ( !SinglePluginExecution() ) |
|
1026 { |
|
1027 // Create common dialog by invoking Engine |
|
1028 dialog = ExecutionParam().Engine(). |
|
1029 CreateCommonDialogLC( EDiagCommonDialogConfirmCancelAll, NULL ); |
|
1030 |
|
1031 // Launch dialog and get result from it |
|
1032 result = RunWaitingDialogL( dialog, aButtonId ); |
|
1033 } |
|
1034 else |
|
1035 { |
|
1036 CompleteTestL( CDiagResultsDatabaseItem::ECancelled ); |
|
1037 aButtonId = EAknSoftkeyYes; |
|
1038 return ETrue; |
|
1039 } |
|
1040 |
|
1041 LOGSTRING3( "CDiagTestPluginBase::AskCancelExecutionL() OUT aButtonId=%d result=%d", aButtonId, result ) |
|
1042 return result; |
|
1043 } |
|
1044 */ |
|
1045 // End of File |
|
1046 |
|
1047 |
|
1048 |
|
1049 |