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 |
// testcaseb2broot.cpp |
|
15 |
// @internalComponent |
|
16 |
// |
|
17 |
// |
|
18 |
||
19 |
#include <e32std.h> |
|
20 |
#include <e32std_private.h> |
|
21 |
#include <u32std.h> // unicode builds |
|
22 |
#include <e32base.h> |
|
23 |
#include <e32base_private.h> |
|
24 |
#include <e32cons.h> |
|
25 |
#include <e32Test.h> // RTest header |
|
26 |
#include <e32ver.h> |
|
27 |
#include <e32def.h> |
|
28 |
#include <e32def_private.h> |
|
29 |
#include <d32otgdi.h> // OTGDI header |
|
30 |
#include <d32usbc.h> // USBCC header |
|
31 |
#include "testcaseroot.h" |
|
32 |
#include "b2bwatchers.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
#include "b2bwatchersTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
#endif |
0 | 37 |
|
38 |
||
39 |
||
40 |
void CNotifyWatcherBase::RunL() |
|
41 |
{ |
|
42 |
DisplayEvent(); |
|
43 |
iHandler.HandleEvent(iWatchType, GetEventValue()); // report the event upwards |
|
44 |
||
45 |
IssueAgain(); |
|
46 |
SetActive(); |
|
47 |
} |
|
48 |
||
49 |
||
50 |
CNotifyCollector::CNotifyCollector(TRequestStatus &aStatus) : iStatusStep(aStatus) |
|
51 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
53 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
54 |
OstTraceFunctionEntry0(CNOTIFYCOLLECTOR_CNOTIFYCOLLECTOR); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
55 |
} |
0 | 56 |
TTimeIntervalDays oneday(1); |
57 |
iTimeStarted.HomeTime(); |
|
58 |
iTimeStarted += (oneday); // force all durations to produce a negative (invalid) value |
|
59 |
} |
|
60 |
||
61 |
||
62 |
/*************************************************************** |
|
63 |
* ~CNotifyCollector |
|
64 |
*/ |
|
65 |
CNotifyCollector::~CNotifyCollector() |
|
66 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
67 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
68 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
OstTraceFunctionEntry0(CNOTIFYCOLLECTOR_DCNOTIFYCOLLECTOR); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
70 |
} |
0 | 71 |
|
72 |
ClearAllEvents(); // free event arrays |
|
73 |
||
74 |
iNotifyObjects.Close(); |
|
75 |
iFailureEvents.Close(); |
|
76 |
iRequiredEvents.Close(); |
|
77 |
iReceivedEvents.Close(); |
|
78 |
} |
|
79 |
||
80 |
||
81 |
/* The test-case calls this to clear the events stored. |
|
82 |
* Both the expected and already recieved events get cleared, this method |
|
83 |
* is typically called at the start of each test-step |
|
84 |
*/ |
|
85 |
void CNotifyCollector::ClearAllEvents(TBool aClearRecieved/*=ETrue*/, TBool aClearRequired /*=ETrue*/) |
|
86 |
{ |
|
87 |
if (aClearRequired) |
|
88 |
{ |
|
89 |
iRequiredEvents.Reset(); |
|
90 |
iFailureEvents.Reset(); |
|
91 |
} |
|
92 |
if (aClearRecieved) |
|
93 |
{ |
|
94 |
iReceivedEvents.Reset(); |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
||
99 |
/* Creates and starts all 4 observers |
|
100 |
* Note: The Watchdog does not get started, because it needs an interval |
|
101 |
*/ |
|
102 |
void CNotifyCollector::CreateObserversL(COtgRoot &aOtgDriver) |
|
103 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
OstTraceFunctionEntry0(CNOTIFYCOLLECTOR_CREATEOBSERVERSL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
} |
0 | 108 |
TInt watchType; |
109 |
ASSERT(aOtgDriver.LddLoaded()); |
|
110 |
||
111 |
for (watchType=EWatcherTimeouts; watchType < EWatcherInvalid; watchType++) |
|
112 |
{ |
|
113 |
CNotifyWatcherBase *pWatcher=0; |
|
114 |
switch ((TWatcherNotifyType )watchType) |
|
115 |
{ |
|
116 |
case EWatcherTimeouts: |
|
117 |
pWatcher = COtgWatchdogWatcher::NewL(*this, EWatcherTimeouts, aOtgDriver); |
|
118 |
break; |
|
119 |
case EWatcherState: |
|
120 |
pWatcher = COtgStateWatcher::NewL(*this , EWatcherState, aOtgDriver); |
|
121 |
break; |
|
122 |
case EWatcherEvent: |
|
123 |
pWatcher = COtgEventWatcher::NewL(*this, EWatcherEvent, aOtgDriver); |
|
124 |
break; |
|
125 |
case EWatcherMessage: |
|
126 |
pWatcher = COtgMessageWatcher::NewL(*this, EWatcherMessage, aOtgDriver); |
|
127 |
break; |
|
128 |
case EWatcherPeripheralState: |
|
129 |
pWatcher = CPeripheralStateWatcher::NewL(*this, EWatcherPeripheralState, aOtgDriver); |
|
130 |
break; |
|
131 |
case EWatcherAConnectionIdle: |
|
132 |
pWatcher = CAConnectionIdleWatcher::NewL(*this, EWatcherAConnectionIdle, aOtgDriver); |
|
133 |
break; |
|
134 |
||
135 |
} |
|
136 |
// the TRequest object is added to scheduler in it's own constructor |
|
137 |
||
138 |
// add it to our list so we can kill them after the test. |
|
139 |
iNotifyObjects.Append(pWatcher); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
|
0 | 141 |
|
142 |
// start all watchers, except for the watchdog |
|
143 |
if (watchType != EWatcherTimeouts) |
|
144 |
{ |
|
145 |
pWatcher->StartWatching(-1); |
|
146 |
} |
|
147 |
} |
|
148 |
test.Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
OstTrace0(TRACE_NORMAL, CNOTIFYCOLLECTOR_CREATEOBSERVERSL_DUP02, "\n"); |
0 | 150 |
} |
151 |
||
152 |
||
153 |
/* NOTE: OTG must still be loaded or else we cannot cancel the outstanding event watches here! |
|
154 |
*/ |
|
155 |
void CNotifyCollector::DestroyObservers() |
|
156 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
157 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
158 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
OstTraceFunctionEntry0(CNOTIFYCOLLECTOR_DESTROYOBSERVERS); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
} |
0 | 161 |
|
162 |
// Free the Watchers |
|
163 |
for (TInt idx=0; idx < iNotifyObjects.Count(); idx++) |
|
164 |
{ |
|
165 |
LOG_VERBOSE2(_L(".. %d .."), idx); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
166 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
167 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
OstTrace1(TRACE_VERBOSE, CNOTIFYCOLLECTOR_DESTROYOBSERVERS_DUP01, ".. %d ..", idx); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
169 |
} |
0 | 170 |
delete iNotifyObjects[idx]; // they will call their own Cancel() methods |
171 |
} |
|
172 |
iNotifyObjects.Close(); |
|
173 |
} |
|
174 |
||
175 |
||
176 |
void CNotifyCollector::AddRequiredNotification(TWatcherNotifyType aType, TInt aValue) |
|
177 |
{ |
|
178 |
AddRequiredOrFailureNotification(aType, aValue, EFalse); |
|
179 |
} |
|
180 |
||
181 |
void CNotifyCollector:: AddFailureNotification(const TWatcherNotifyType aType, TInt aValue) |
|
182 |
{ |
|
183 |
AddRequiredOrFailureNotification(aType, aValue, ETrue); |
|
184 |
} |
|
185 |
||
186 |
/* Checks that a watcher for the event exists, and then adds it to a list of events required for a PASS condition |
|
187 |
* The timout event does not get added to this list. |
|
188 |
* If the parameter is a time, the timer gets started |
|
189 |
* If aEventMeansFailure is set True, then the reception of the event will cause the current test step to fail |
|
190 |
*/ |
|
191 |
void CNotifyCollector::AddRequiredOrFailureNotification(TWatcherNotifyType aType, TInt aValue, TBool aEventMeansFailure) |
|
192 |
{ |
|
193 |
CNotifyWatcherBase *pWatcher=0; |
|
194 |
TInt index=0; |
|
195 |
TBuf<MAX_DSTRLEN> aDescription; |
|
196 |
||
197 |
// print a usefull debug message |
|
198 |
switch (aType) |
|
199 |
{ |
|
200 |
case EWatcherTimeouts: |
|
201 |
break; |
|
202 |
case EWatcherState: |
|
203 |
COtgRoot::OtgStateString(static_cast<RUsbOtgDriver::TOtgState>(aValue), aDescription); |
|
204 |
LOG_VERBOSE3(_L("AddRequiredNotification() State %d '%S' wanted\n"), aValue, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
206 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
OstTraceExt2(TRACE_VERBOSE, CNOTIFYCOLLECTOR_ADDREQUIREDORFAILURENOTIFICATION, "AddRequiredNotification() State %d '%S' wanted\n", aValue, aDescription); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
208 |
} |
0 | 209 |
break; |
210 |
case EWatcherEvent: |
|
211 |
COtgRoot::OtgEventString(static_cast<RUsbOtgDriver::TOtgEvent>(aValue), aDescription); |
|
212 |
LOG_VERBOSE3(_L("AddRequiredNotification() Event %d '%S' wanted\n"), aValue, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
214 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
OstTraceExt2(TRACE_VERBOSE, CNOTIFYCOLLECTOR_ADDREQUIREDORFAILURENOTIFICATION_DUP01, "AddRequiredNotification() Event %d '%S' wanted\n", aValue, aDescription); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
216 |
} |
0 | 217 |
break; |
218 |
case EWatcherMessage: |
|
219 |
COtgRoot::OtgMessageString(static_cast<RUsbOtgDriver::TOtgMessage>(aValue), aDescription); |
|
220 |
LOG_VERBOSE3(_L("AddRequiredNotification() Message %d '%S' wanted\n"), aValue, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
OstTraceExt2(TRACE_VERBOSE, CNOTIFYCOLLECTOR_ADDREQUIREDORFAILURENOTIFICATION_DUP02, "AddRequiredNotification() Message %d '%S' wanted\n", aValue, aDescription); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
} |
0 | 225 |
break; |
226 |
case EWatcherPeripheralState: |
|
227 |
COtgRoot::PeripheralStateString(static_cast<TUint>(aValue), aDescription); |
|
228 |
LOG_VERBOSE3(_L("AddRequiredNotification() Peripheral State %d '%S' wanted\n"), aValue, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
229 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
OstTraceExt2(TRACE_VERBOSE, CNOTIFYCOLLECTOR_ADDREQUIREDORFAILURENOTIFICATION_DUP03, "AddRequiredNotification() Peripheral State %d '%S' wanted\n", aValue, aDescription); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
} |
0 | 233 |
break; |
234 |
case EWatcherAConnectionIdle: |
|
235 |
COtgRoot::AConnectionIdleString(static_cast<RUsbOtgDriver::TOtgConnection>(aValue), aDescription); |
|
236 |
LOG_VERBOSE3(_L("AddRequiredNotification() AConnectionIdle %d '%S' wanted\n"), aValue, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
239 |
OstTraceExt2(TRACE_VERBOSE, CNOTIFYCOLLECTOR_ADDREQUIREDORFAILURENOTIFICATION_DUP04, "AddRequiredNotification() AConnectionIdle %d '%S' wanted\n", aValue, aDescription); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
} |
0 | 241 |
break; |
242 |
||
243 |
} |
|
244 |
||
245 |
// Find the watcher if possible |
|
246 |
while (index < iNotifyObjects.Count()) |
|
247 |
{ |
|
248 |
||
249 |
TEST_ASSERTION(iNotifyObjects[index]!=NULL, _L("iNotifyObjects element gone!")); |
|
250 |
||
251 |
if (iNotifyObjects[index]->GetType() == aType) |
|
252 |
{ |
|
253 |
pWatcher = iNotifyObjects[index]; |
|
254 |
break; |
|
255 |
} |
|
256 |
index++; |
|
257 |
} |
|
258 |
||
259 |
TEST_ASSERTION(pWatcher!=NULL, _L("pWatcher=0!")); |
|
260 |
if (aType == EWatcherTimeouts) |
|
261 |
{ // other watchers are already running, but we start the timer now |
|
262 |
pWatcher->StartWatching(aValue); |
|
263 |
} |
|
264 |
else |
|
265 |
{ // timeouts are not added to the Q |
|
266 |
TOtgObservedEvent evt(aType, aValue); |
|
267 |
if(aEventMeansFailure) |
|
268 |
{ |
|
269 |
iFailureEvents.Append(evt); |
|
270 |
} |
|
271 |
else |
|
272 |
{ |
|
273 |
iRequiredEvents.Append(evt); |
|
274 |
} |
|
275 |
} |
|
276 |
// flag as pending |
|
277 |
iStatusStep = KRequestPending; |
|
278 |
iTimeStarted.HomeTime(); |
|
279 |
} |
|
280 |
||
281 |
||
282 |
/* Return the number of milliseconds since the last call to AddRequiredNotification() |
|
283 |
*/ |
|
284 |
TInt CNotifyCollector::DurationElapsed() |
|
285 |
{ |
|
286 |
TTime TimeEnd; |
|
287 |
TInt Millisec; |
|
288 |
||
289 |
TimeEnd.HomeTime(); |
|
290 |
TTimeIntervalMicroSeconds ivlMicro(TimeEnd.MicroSecondsFrom(iTimeStarted)); |
|
291 |
Millisec = (TInt)(ivlMicro.Int64())/1000; // USB times are in uSec, but in ms for the user layer |
|
292 |
||
293 |
if (Millisec < 0) |
|
294 |
Millisec = -1; // TRUE for when the Notifiers are not yet being used. |
|
295 |
return(Millisec); |
|
296 |
} |
|
297 |
||
298 |
||
299 |
/* Search for an event in the received Q |
|
300 |
* @return :TRUE if the specified event has been received |
|
301 |
*/ |
|
302 |
TBool CNotifyCollector::EventReceivedAlready(const TOtgObservedEvent& aEvent) |
|
303 |
{ |
|
304 |
for (TInt idx=0; idx < iReceivedEvents.Count(); idx++) |
|
305 |
if (iReceivedEvents[idx] == aEvent) |
|
306 |
return(ETrue); |
|
307 |
return(EFalse); |
|
308 |
} |
|
309 |
||
310 |
/* Search for an event in the failure event queue |
|
311 |
* @return :TRUE if the specified event does denote a failure |
|
312 |
*/ |
|
313 |
TBool CNotifyCollector::IsFailureEvent(TOtgObservedEvent &aEvent) |
|
314 |
{ |
|
315 |
for (TInt idx=0; idx < iFailureEvents.Count(); idx++) |
|
316 |
if (iFailureEvents[idx] == aEvent) |
|
317 |
return(ETrue); |
|
318 |
return(EFalse); |
|
319 |
} |
|
320 |
||
321 |
/* @return 0 if the watcher has not yet been created. (for instance early in the test) |
|
322 |
*/ |
|
323 |
CNotifyWatcherBase* CNotifyCollector::GetWatcher(TWatcherNotifyType aType) |
|
324 |
{ |
|
325 |
CNotifyWatcherBase *pWatcher=0; |
|
326 |
// Find the watcher |
|
327 |
TInt index=0; |
|
328 |
||
329 |
while (index < iNotifyObjects.Count()) |
|
330 |
{ |
|
331 |
||
332 |
TEST_ASSERTION(iNotifyObjects[index]!=NULL, _L("iNotifyObjects element gone!")); |
|
333 |
||
334 |
if (iNotifyObjects[index]->GetType() == aType) |
|
335 |
{ |
|
336 |
pWatcher = iNotifyObjects[index]; |
|
337 |
break; |
|
338 |
} |
|
339 |
index++; |
|
340 |
} |
|
341 |
||
342 |
return(pWatcher); |
|
343 |
} |
|
344 |
||
345 |
||
346 |
/* Process the event. The OTG watchers are responsible for renewing themselves |
|
347 |
* but the Timer event does not renew |
|
348 |
*/ |
|
349 |
void CNotifyCollector::HandleEvent(TWatcherNotifyType aType, TInt aValue) |
|
350 |
{ |
|
351 |
if (aType == EWatcherTimeouts) |
|
352 |
{ |
|
353 |
test.Printf(_L("Step timed out..(%dms).\n\n"), GetWatcher(aType)->GetEventValue()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
354 |
OstTrace1(TRACE_NORMAL, CNOTIFYCOLLECTOR_HANDLEEVENT, "Step timed out..(%dms).\n\n", GetWatcher(aType)->GetEventValue()); |
0 | 355 |
CompleteStep(KTestCaseWatchdogTO); |
356 |
return; |
|
357 |
} |
|
358 |
||
359 |
TOtgObservedEvent evt(aType, aValue); |
|
360 |
TInt start=0; |
|
361 |
iReceivedEvents.Append(evt); // store incomming evt |
|
362 |
||
363 |
// Check to see whether the event denotes a failure for this event |
|
364 |
if (IsFailureEvent(evt)) |
|
365 |
{ |
|
366 |
test.Printf(_L("This event denotes failure for this test\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
OstTrace0(TRACE_NORMAL, CNOTIFYCOLLECTOR_HANDLEEVENT_DUP01, "This event denotes failure for this test\n"); |
0 | 368 |
CompleteStep(KTestCaseFailureEventReceived); |
369 |
return; |
|
370 |
} |
|
371 |
||
372 |
if (iRequiredEvents.Count()) |
|
373 |
{ |
|
374 |
// itterate all required events, search for each one in the incomming events list |
|
375 |
while (start< iRequiredEvents.Count()) |
|
376 |
{ |
|
377 |
||
378 |
if (!EventReceivedAlready(iRequiredEvents[start])) |
|
379 |
return; // missing still, continue |
|
380 |
start++; |
|
381 |
} |
|
382 |
// found all the required events |
|
383 |
LOG_VERBOSE1(_L("Found all.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
384 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
385 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
386 |
OstTrace0(TRACE_VERBOSE, CNOTIFYCOLLECTOR_HANDLEEVENT_DUP03, "Found all.\n"); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
} |
0 | 388 |
CompleteStep(KErrNone); |
389 |
} |
|
390 |
else |
|
391 |
{ |
|
392 |
test.Printf(_L("Warning : No required events!\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
OstTrace0(TRACE_NORMAL, CNOTIFYCOLLECTOR_HANDLEEVENT_DUP04, "Warning : No required events!\n"); |
0 | 394 |
} |
395 |
} |
|
396 |
||
397 |
// Complete the test step's TRequestStatus (checking it is currently KRequestPending |
|
398 |
// to try and avoid multiple completions). |
|
399 |
// |
|
400 |
void CNotifyCollector::CompleteStep(TInt aCompletionCode) |
|
401 |
{ |
|
402 |
if(iStatusStep.Int() != KRequestPending) |
|
403 |
{ |
|
404 |
test.Printf(_L("Can't complete step - not KRequestPending!\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
405 |
OstTrace0(TRACE_NORMAL, CNOTIFYCOLLECTOR_COMPLETESTEP, "Can't complete step - not KRequestPending!\n"); |
0 | 406 |
} |
407 |
else |
|
408 |
{ |
|
409 |
TRequestStatus *StatusStepPtr = &iStatusStep; |
|
410 |
User::RequestComplete(StatusStepPtr, aCompletionCode); |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
/**************************************************************************** |
|
415 |
* COtg Watchdog Watcher |
|
416 |
*/ |
|
417 |
COtgWatchdogWatcher *COtgWatchdogWatcher::NewL(MOtgNotificationHandler &wdHandler, |
|
418 |
const TWatcherNotifyType aWatchType, |
|
419 |
COtgRoot &aOtgRoot) |
|
420 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
421 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
422 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
423 |
OstTraceFunctionEntry0(CNOTIFYCOLLECTOR_COMPLETESTEP_DUP01); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
424 |
} |
0 | 425 |
COtgWatchdogWatcher* self = new (ELeave) COtgWatchdogWatcher(wdHandler, aWatchType, aOtgRoot); |
426 |
CleanupStack::PushL(self); |
|
427 |
self->ConstructL(); |
|
428 |
CleanupStack::Pop(self); |
|
429 |
return self; |
|
430 |
} |
|
431 |
||
432 |
||
433 |
void COtgWatchdogWatcher::ConstructL() |
|
434 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
435 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
436 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
437 |
OstTraceFunctionEntry0(COTGWATCHDOGWATCHER_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
438 |
} |
0 | 439 |
|
440 |
iTimer.CreateLocal(); |
|
441 |
iIntervalMs = -1; |
|
442 |
} |
|
443 |
||
444 |
||
445 |
void COtgWatchdogWatcher::StepExpired(TInt aInterval) |
|
446 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
447 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
448 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
449 |
OstTraceFunctionEntry0(COTGWATCHDOGWATCHER_STEPEXPIRED); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
450 |
} |
0 | 451 |
iHandler.HandleEvent(EWatcherTimeouts, aInterval) ; |
452 |
} |
|
453 |
||
454 |
||
455 |
void COtgWatchdogWatcher::RunL() |
|
456 |
{ |
|
457 |
StepExpired(iIntervalMs); |
|
458 |
} |
|
459 |
||
460 |
||
461 |
void COtgWatchdogWatcher::StartTimer(TInt aIntervalMs) |
|
462 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
463 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
464 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
465 |
OstTraceFunctionEntry0(COTGWATCHDOGWATCHER_STARTTIMER); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
466 |
} |
0 | 467 |
|
468 |
iIntervalMs = aIntervalMs; // save value for printing latter |
|
469 |
if (IsActive()) //cancel the last timer we set, this is easier than cancelling it in each test-step |
|
470 |
{ |
|
471 |
iTimer.Cancel(); |
|
472 |
User::WaitForRequest(iStatus); // swallow it |
|
473 |
iTimer.After(iStatus, aIntervalMs*1000); |
|
474 |
} |
|
475 |
else |
|
476 |
{ |
|
477 |
iTimer.After(iStatus, aIntervalMs*1000); |
|
478 |
SetActive(); |
|
479 |
} |
|
480 |
LOG_VERBOSE2(_L("wd Timer %dms\n"), aIntervalMs) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
481 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
482 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
483 |
OstTrace1(TRACE_VERBOSE, COTGWATCHDOGWATCHER_STARTTIMER_DUP01, "wd Timer %dms\n", aIntervalMs); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
484 |
} |
0 | 485 |
} |
486 |
||
487 |
||
488 |
/**************************************************************************** |
|
489 |
* OTG Event/State/Message Watchers |
|
490 |
*/ |
|
491 |
COtgMessageWatcher* COtgMessageWatcher::NewL(MOtgNotificationHandler &wdHandler, |
|
492 |
const TWatcherNotifyType aWatchType, |
|
493 |
COtgRoot &aOtgRoot) |
|
494 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
495 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
497 |
OstTraceFunctionEntry0(COTGMESSAGEWATCHER_NEWL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
} |
0 | 499 |
COtgMessageWatcher* self = new (ELeave) COtgMessageWatcher(wdHandler, aWatchType, aOtgRoot); |
500 |
CleanupStack::PushL(self); |
|
501 |
self->ConstructL(); |
|
502 |
CleanupStack::Pop(self); |
|
503 |
return self; |
|
504 |
} |
|
505 |
||
506 |
||
507 |
void COtgMessageWatcher::DisplayEvent() |
|
508 |
{ |
|
509 |
TBuf<MAX_DSTRLEN> aDescription; |
|
510 |
iOtgRoot.OtgMessageString(iMessage, aDescription); |
|
511 |
test.Printf(_L("Received Message %d '%S'\n"), iMessage, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
512 |
OstTraceExt2(TRACE_NORMAL, COTGMESSAGEWATCHER_DISPLAYEVENT, "Received Message %d '%S'\n", iMessage, aDescription); |
0 | 513 |
} |
514 |
||
515 |
||
516 |
COtgStateWatcher* COtgStateWatcher::NewL(MOtgNotificationHandler &wdHandler, |
|
517 |
const TWatcherNotifyType aWatchType, |
|
518 |
COtgRoot &aOtgRoot) |
|
519 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
520 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
521 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
522 |
OstTraceFunctionEntry0(COTGSTATEWATCHER_NEWL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
523 |
} |
0 | 524 |
COtgStateWatcher* self = new (ELeave) COtgStateWatcher(wdHandler, aWatchType, aOtgRoot); |
525 |
CleanupStack::PushL(self); |
|
526 |
self->ConstructL(); |
|
527 |
CleanupStack::Pop(self); |
|
528 |
return self; |
|
529 |
} |
|
530 |
||
531 |
||
532 |
void COtgStateWatcher::DisplayEvent() |
|
533 |
{ |
|
534 |
TBuf<MAX_DSTRLEN> aDescription; |
|
535 |
iOtgRoot.OtgStateString(iState, aDescription); |
|
536 |
test.Printf(_L("Received State %d '%S'\n"), iState, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
537 |
OstTraceExt2(TRACE_NORMAL, COTGSTATEWATCHER_DISPLAYEVENT_DUP01, "Received State %d '%S'\n", iState, aDescription); |
0 | 538 |
} |
539 |
||
540 |
||
541 |
COtgEventWatcher* COtgEventWatcher::NewL(MOtgNotificationHandler &wdHandler, |
|
542 |
const TWatcherNotifyType aWatchType, |
|
543 |
COtgRoot &aOtgRoot) |
|
544 |
{ |
|
545 |
COtgEventWatcher* self = new (ELeave) COtgEventWatcher(wdHandler, aWatchType, aOtgRoot); |
|
546 |
CleanupStack::PushL(self); |
|
547 |
self->ConstructL(); |
|
548 |
CleanupStack::Pop(self); |
|
549 |
return self; |
|
550 |
} |
|
551 |
||
552 |
void COtgEventWatcher::DisplayEvent() |
|
553 |
{ |
|
554 |
TBuf<MAX_DSTRLEN> aDescription; |
|
555 |
iOtgRoot.OtgEventString(iEvent, aDescription); |
|
556 |
test.Printf(_L("Received Event %d '%S'\n"), iEvent, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
OstTraceExt2(TRACE_NORMAL, COTGEVENTWATCHER_DISPLAYEVENT, "Received Event %d '%S'\n", iEvent, aDescription); |
0 | 558 |
} |
559 |
||
560 |
CPeripheralStateWatcher* CPeripheralStateWatcher::NewL(MOtgNotificationHandler &wdHandler, |
|
561 |
const TWatcherNotifyType aWatchType, |
|
562 |
COtgRoot &aOtgRoot) |
|
563 |
{ |
|
564 |
CPeripheralStateWatcher* self = new (ELeave) CPeripheralStateWatcher(wdHandler, aWatchType, aOtgRoot); |
|
565 |
CleanupStack::PushL(self); |
|
566 |
self->ConstructL(); |
|
567 |
CleanupStack::Pop(self); |
|
568 |
return self; |
|
569 |
} |
|
570 |
||
571 |
void CPeripheralStateWatcher::DisplayEvent() |
|
572 |
{ |
|
573 |
TBuf<MAX_DSTRLEN> aDescription; |
|
574 |
iOtgRoot.PeripheralStateString(iPeripheralState, aDescription); |
|
575 |
test.Printf(_L("Peripheral State %d '%S'\n"), iPeripheralState, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
OstTraceExt2(TRACE_NORMAL, CPERIPHERALSTATEWATCHER_DISPLAYEVENT, "Peripheral State %u '%S'\n", iPeripheralState, aDescription); |
0 | 577 |
} |
578 |
||
579 |
CAConnectionIdleWatcher* CAConnectionIdleWatcher::NewL(MOtgNotificationHandler &wdHandler, |
|
580 |
const TWatcherNotifyType aWatchType, |
|
581 |
COtgRoot &aOtgRoot) |
|
582 |
{ |
|
583 |
CAConnectionIdleWatcher* self = new (ELeave) CAConnectionIdleWatcher(wdHandler, aWatchType, aOtgRoot); |
|
584 |
CleanupStack::PushL(self); |
|
585 |
self->ConstructL(); |
|
586 |
CleanupStack::Pop(self); |
|
587 |
return self; |
|
588 |
} |
|
589 |
||
590 |
void CAConnectionIdleWatcher::RunL() |
|
591 |
{ |
|
592 |
// We need to override the RunL for this event type, as |
|
593 |
// the semantics of the asynchronous function are somewhat |
|
594 |
// different to the rest of the ones being serviced by |
|
595 |
// CNotifyWatcherBase. |
|
596 |
// |
|
597 |
// In the case of QueueOtgConnectionNotification, the value |
|
598 |
// passed in is updated *immediately* to reflect the current |
|
599 |
// activity or otherwise of the connection (unlike the other |
|
600 |
// async functions which update the value on completion). |
|
601 |
// The completion in the case of QueueOtgConnectionNotification |
|
602 |
// is used to indicate that the value has changed, and |
|
603 |
// another request should be queued to pick up this new value. |
|
604 |
// |
|
605 |
// The practical upshot of this is that the IssueAgain needs |
|
606 |
// to happen before the event is displayed and handled... |
|
607 |
||
608 |
IssueAgain(); |
|
609 |
DisplayEvent(); |
|
610 |
iHandler.HandleEvent(iWatchType, GetEventValue()); // report the event upwards |
|
611 |
SetActive(); |
|
612 |
} |
|
613 |
||
614 |
||
615 |
void CAConnectionIdleWatcher::DisplayEvent() |
|
616 |
{ |
|
617 |
TBuf<MAX_DSTRLEN> aDescription; |
|
618 |
iOtgRoot.AConnectionIdleString(iAConnectionIdle, aDescription); |
|
619 |
test.Printf(_L("AConnectionIdle %d '%S'\n"), iAConnectionIdle, &aDescription); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
620 |
OstTraceExt2(TRACE_NORMAL, CACONNECTIONIDLEWATCHER_DISPLAYEVENT, "AConnectionIdle %d '%S'\n", iAConnectionIdle, aDescription); |
0 | 621 |
} |