Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 // Test Case watchdog implementation
21 #include <e32std_private.h>
22 #include <u32std.h> // unicode builds
24 #include <e32base_private.h>
26 #include <e32Test.h> // RTest headder
27 #include "testcaseroot.h"
28 #include "TestCasewd.h"
33 const TInt KMagicNumberWDogValid = 0xF143F00D;
34 _LIT(KMsgWatchdogPanicd, "Test Case watchdog error");
37 // CTestCaseWatchdog: Timer for any OTG event (async calls) time-outs
40 CTestCaseWatchdog::CTestCaseWatchdog()
41 : CTimer(EPriorityUserInput)
46 CTestCaseWatchdog::~CTestCaseWatchdog()
53 CTestCaseWatchdog* CTestCaseWatchdog::NewL()
55 CTestCaseWatchdog *self = new (ELeave) CTestCaseWatchdog();
56 CleanupStack::PushL(self);
63 void CTestCaseWatchdog::ConstructL()
65 iValidConstr = KMagicNumberWDogValid;
67 CActiveScheduler::Add(this);
71 void CTestCaseWatchdog::RunL()
72 // Timer request has completed, so notify the timer's owner that we timed out
75 __ASSERT_ALWAYS(iCancelFriendFunc, User::Panic(KMsgWatchdogPanicd, EPanicWatchdogError));
76 __ASSERT_ALWAYS(iThisPointer, User::Panic(KMsgWatchdogPanicd, EPanicWatchdogError));
77 (*iCancelFriendFunc)(iThisPointer);
78 iCancelFriendFunc = NULL;
83 void CTestCaseWatchdog::IssueRequest(TInt aWatchdogIntervalMS,
85 WDCancellerMethod cancelMethod)
87 LOG_VERBOSE2(_L("Watchdogging this step for %d ms\n"), aWatchdogIntervalMS);
92 iThisPointer = pRoot; // save caller instance data
93 iCancelFriendFunc = cancelMethod; // save cancel handler
94 iMSRequested = aWatchdogIntervalMS;
95 After(aWatchdogIntervalMS * 1000); // convert to uS
101 A common mistake is to not new() this event source and start using it before instantiation
103 TBool CTestCaseWatchdog::IsValid()
105 // return ETrue if the object is validly constructed
106 // This is test code, or else we would ifdef this out
107 if (KMagicNumberWDogValid!= iValidConstr)
110 test.Printf(_L("CTestCaseWatchdog obj not properly constructed!\n"));