sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// testengine.cpp
|
sl@0
|
15 |
// @internalComponent
|
sl@0
|
16 |
// Test Case watchdog implementation
|
sl@0
|
17 |
//
|
sl@0
|
18 |
//
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <e32std.h>
|
sl@0
|
21 |
#include <e32std_private.h>
|
sl@0
|
22 |
#include <u32std.h> // unicode builds
|
sl@0
|
23 |
#include <e32base.h>
|
sl@0
|
24 |
#include <e32base_private.h>
|
sl@0
|
25 |
#include <e32cons.h>
|
sl@0
|
26 |
#include <e32Test.h> // RTest headder
|
sl@0
|
27 |
#include "testcaseroot.h"
|
sl@0
|
28 |
#include "TestCasewd.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
const TInt KMagicNumberWDogValid = 0xF143F00D;
|
sl@0
|
34 |
_LIT(KMsgWatchdogPanicd, "Test Case watchdog error");
|
sl@0
|
35 |
|
sl@0
|
36 |
//
|
sl@0
|
37 |
// CTestCaseWatchdog: Timer for any OTG event (async calls) time-outs
|
sl@0
|
38 |
//
|
sl@0
|
39 |
|
sl@0
|
40 |
CTestCaseWatchdog::CTestCaseWatchdog()
|
sl@0
|
41 |
: CTimer(EPriorityUserInput)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
CTestCaseWatchdog::~CTestCaseWatchdog()
|
sl@0
|
47 |
{
|
sl@0
|
48 |
Cancel();
|
sl@0
|
49 |
iValidConstr = 0;
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
CTestCaseWatchdog* CTestCaseWatchdog::NewL()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
CTestCaseWatchdog *self = new (ELeave) CTestCaseWatchdog();
|
sl@0
|
56 |
CleanupStack::PushL(self);
|
sl@0
|
57 |
self->ConstructL();
|
sl@0
|
58 |
CleanupStack::Pop();
|
sl@0
|
59 |
return self;
|
sl@0
|
60 |
}
|
sl@0
|
61 |
|
sl@0
|
62 |
|
sl@0
|
63 |
void CTestCaseWatchdog::ConstructL()
|
sl@0
|
64 |
{
|
sl@0
|
65 |
iValidConstr = KMagicNumberWDogValid;
|
sl@0
|
66 |
CTimer::ConstructL();
|
sl@0
|
67 |
CActiveScheduler::Add(this);
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
void CTestCaseWatchdog::RunL()
|
sl@0
|
72 |
// Timer request has completed, so notify the timer's owner that we timed out
|
sl@0
|
73 |
{
|
sl@0
|
74 |
LOG_FUNC
|
sl@0
|
75 |
__ASSERT_ALWAYS(iCancelFriendFunc, User::Panic(KMsgWatchdogPanicd, EPanicWatchdogError));
|
sl@0
|
76 |
__ASSERT_ALWAYS(iThisPointer, User::Panic(KMsgWatchdogPanicd, EPanicWatchdogError));
|
sl@0
|
77 |
(*iCancelFriendFunc)(iThisPointer);
|
sl@0
|
78 |
iCancelFriendFunc = NULL;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
|
sl@0
|
82 |
// call back setup
|
sl@0
|
83 |
void CTestCaseWatchdog::IssueRequest(TInt aWatchdogIntervalMS,
|
sl@0
|
84 |
CTestCaseRoot* pRoot,
|
sl@0
|
85 |
WDCancellerMethod cancelMethod)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
LOG_VERBOSE2(_L("Watchdogging this step for %d ms\n"), aWatchdogIntervalMS);
|
sl@0
|
88 |
if (IsValid())
|
sl@0
|
89 |
{
|
sl@0
|
90 |
Cancel();
|
sl@0
|
91 |
|
sl@0
|
92 |
iThisPointer = pRoot; // save caller instance data
|
sl@0
|
93 |
iCancelFriendFunc = cancelMethod; // save cancel handler
|
sl@0
|
94 |
iMSRequested = aWatchdogIntervalMS;
|
sl@0
|
95 |
After(aWatchdogIntervalMS * 1000); // convert to uS
|
sl@0
|
96 |
}
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
|
sl@0
|
100 |
/** IsValid
|
sl@0
|
101 |
A common mistake is to not new() this event source and start using it before instantiation
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
TBool CTestCaseWatchdog::IsValid()
|
sl@0
|
104 |
{
|
sl@0
|
105 |
// return ETrue if the object is validly constructed
|
sl@0
|
106 |
// This is test code, or else we would ifdef this out
|
sl@0
|
107 |
if (KMagicNumberWDogValid!= iValidConstr)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
|
sl@0
|
110 |
test.Printf(_L("CTestCaseWatchdog obj not properly constructed!\n"));
|
sl@0
|
111 |
return(EFalse);
|
sl@0
|
112 |
}
|
sl@0
|
113 |
return(ETrue);
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
|
sl@0
|
117 |
|