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 |
// testengine.cpp |
|
15 |
// @internalComponent |
|
16 |
// Test Case watchdog implementation |
|
17 |
// |
|
18 |
// |
|
19 |
||
20 |
#include <e32std.h> |
|
21 |
#include <e32std_private.h> |
|
22 |
#include <u32std.h> // unicode builds |
|
23 |
#include <e32base.h> |
|
24 |
#include <e32base_private.h> |
|
25 |
#include <e32cons.h> |
|
26 |
#include <e32Test.h> // RTest headder |
|
27 |
#include "testcaseroot.h" |
|
28 |
#include "TestCasewd.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
29 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
31 |
#include "testcasewdTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#endif |
0 | 33 |
|
34 |
||
35 |
||
36 |
||
37 |
const TInt KMagicNumberWDogValid = 0xF143F00D; |
|
38 |
_LIT(KMsgWatchdogPanicd, "Test Case watchdog error"); |
|
39 |
||
40 |
// |
|
41 |
// CTestCaseWatchdog: Timer for any OTG event (async calls) time-outs |
|
42 |
// |
|
43 |
||
44 |
CTestCaseWatchdog::CTestCaseWatchdog() |
|
45 |
: CTimer(EPriorityUserInput) |
|
46 |
{ |
|
47 |
} |
|
48 |
||
49 |
||
50 |
CTestCaseWatchdog::~CTestCaseWatchdog() |
|
51 |
{ |
|
52 |
Cancel(); |
|
53 |
iValidConstr = 0; |
|
54 |
} |
|
55 |
||
56 |
||
57 |
CTestCaseWatchdog* CTestCaseWatchdog::NewL() |
|
58 |
{ |
|
59 |
CTestCaseWatchdog *self = new (ELeave) CTestCaseWatchdog(); |
|
60 |
CleanupStack::PushL(self); |
|
61 |
self->ConstructL(); |
|
62 |
CleanupStack::Pop(); |
|
63 |
return self; |
|
64 |
} |
|
65 |
||
66 |
||
67 |
void CTestCaseWatchdog::ConstructL() |
|
68 |
{ |
|
69 |
iValidConstr = KMagicNumberWDogValid; |
|
70 |
CTimer::ConstructL(); |
|
71 |
CActiveScheduler::Add(this); |
|
72 |
} |
|
73 |
||
74 |
||
75 |
void CTestCaseWatchdog::RunL() |
|
76 |
// Timer request has completed, so notify the timer's owner that we timed out |
|
77 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
78 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
OstTraceFunctionEntry0(CTESTCASEWATCHDOG_RUNL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
} |
0 | 82 |
__ASSERT_ALWAYS(iCancelFriendFunc, User::Panic(KMsgWatchdogPanicd, EPanicWatchdogError)); |
83 |
__ASSERT_ALWAYS(iThisPointer, User::Panic(KMsgWatchdogPanicd, EPanicWatchdogError)); |
|
84 |
(*iCancelFriendFunc)(iThisPointer); |
|
85 |
iCancelFriendFunc = NULL; |
|
86 |
} |
|
87 |
||
88 |
||
89 |
// call back setup |
|
90 |
void CTestCaseWatchdog::IssueRequest(TInt aWatchdogIntervalMS, |
|
91 |
CTestCaseRoot* pRoot, |
|
92 |
WDCancellerMethod cancelMethod) |
|
93 |
{ |
|
94 |
LOG_VERBOSE2(_L("Watchdogging this step for %d ms\n"), aWatchdogIntervalMS); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
96 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
OstTrace1(TRACE_VERBOSE, CTESTCASEWATCHDOG_ISSUEREQUEST, "Watchdogging this step for %d ms\n", aWatchdogIntervalMS); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
98 |
} |
0 | 99 |
if (IsValid()) |
100 |
{ |
|
101 |
Cancel(); |
|
102 |
||
103 |
iThisPointer = pRoot; // save caller instance data |
|
104 |
iCancelFriendFunc = cancelMethod; // save cancel handler |
|
105 |
iMSRequested = aWatchdogIntervalMS; |
|
106 |
After(aWatchdogIntervalMS * 1000); // convert to uS |
|
107 |
} |
|
108 |
} |
|
109 |
||
110 |
||
111 |
/** IsValid |
|
112 |
A common mistake is to not new() this event source and start using it before instantiation |
|
113 |
*/ |
|
114 |
TBool CTestCaseWatchdog::IsValid() |
|
115 |
{ |
|
116 |
// return ETrue if the object is validly constructed |
|
117 |
// This is test code, or else we would ifdef this out |
|
118 |
if (KMagicNumberWDogValid!= iValidConstr) |
|
119 |
{ |
|
120 |
||
121 |
test.Printf(_L("CTestCaseWatchdog obj not properly constructed!\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
OstTrace0(TRACE_NORMAL, CTESTCASEWATCHDOG_ISVALID, "CTestCaseWatchdog obj not properly constructed!\n"); |
0 | 123 |
return(EFalse); |
124 |
} |
|
125 |
return(ETrue); |
|
126 |
} |
|
127 |
||
128 |
||
129 |