|
1 // Copyright (c) 2008-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 "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 // Example CTestStep derived implementation |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file TrackingSessionStep.cpp |
|
20 @internalTechnology |
|
21 */ |
|
22 #include "trackingsessionstep.h" |
|
23 #include "te_defproxysuitedefs.h" |
|
24 |
|
25 CTrackingSessionStep::~CTrackingSessionStep() |
|
26 /** |
|
27 * Destructor |
|
28 */ |
|
29 { |
|
30 } |
|
31 |
|
32 CTrackingSessionStep::CTrackingSessionStep() |
|
33 /** |
|
34 * Constructor |
|
35 */ |
|
36 { |
|
37 SetTestStepName(KTrackingSessionStep); |
|
38 } |
|
39 |
|
40 TVerdict CTrackingSessionStep::doTestStepPreambleL() |
|
41 /** |
|
42 * @return - TVerdict code |
|
43 * Override of base class virtual |
|
44 */ |
|
45 { |
|
46 CTe_defproxySuiteStepBase::doTestStepPreambleL(); |
|
47 SetTestStepResult(EPass); |
|
48 return TestStepResult(); |
|
49 } |
|
50 |
|
51 |
|
52 TVerdict CTrackingSessionStep::doTestStepL() |
|
53 /** |
|
54 * @return - TVerdict code |
|
55 * Override of base class pure virtual |
|
56 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
57 * not leave. That being the case, the current test result value will be EPass. |
|
58 */ |
|
59 { |
|
60 StandardPrepareL(); |
|
61 |
|
62 const TInt KInterval = 1 * KSecondsToMicro; |
|
63 const TTimeIntervalMicroSeconds KFirstRequestDelay = 200 * 1000; // 0.2 sec |
|
64 const TTimeIntervalMicroSeconds KNormalRequestDelay = 200 * 1000; // 0.2 sec |
|
65 const TInt KDiff = 200 * 1000; // 0.2 sec |
|
66 const TInt KIntervalError = 100 * 1000; // 0.1 sec |
|
67 |
|
68 TRequestStatus status; |
|
69 TWatch watch; |
|
70 TTime secondRequest, stopTracking; |
|
71 TInt interval; |
|
72 |
|
73 HPositionGenericInfo* genInfo = HPositionGenericInfo::NewLC(); |
|
74 |
|
75 // setup : only PSY6 |
|
76 ToggleModuleL(KUidLcfPsy1, EFalse); |
|
77 ToggleModuleL(KUidLcfPsy3, EFalse); |
|
78 |
|
79 // make one request to allow default proxy rebuild its database |
|
80 // this will guarantee that first request will be as fast as possible |
|
81 TPositionCourseInfo courseInfo; |
|
82 PositionRequestWithCheck(courseInfo, KErrArgument, KNullUid); |
|
83 |
|
84 // setup tracking session |
|
85 TPositionUpdateOptions updateOptions; |
|
86 updateOptions.SetUpdateInterval(KInterval); |
|
87 iPositioner.SetUpdateOptions(updateOptions); |
|
88 |
|
89 // 1st request |
|
90 // first request must be quick |
|
91 watch.Tick(); |
|
92 PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); |
|
93 if(watch.ElapsedFromTick() > KFirstRequestDelay) |
|
94 { |
|
95 ERR_PRINTF1(KFirstDelayTooLong); |
|
96 SetTestStepResult(EFail); |
|
97 } |
|
98 |
|
99 // drop delay and make 2nd and 3rd requests |
|
100 genInfo->ClearRequestedFields(); |
|
101 { |
|
102 watch.Tick(); |
|
103 PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); |
|
104 secondRequest.UniversalTime(); |
|
105 interval = (TInt) watch.ElapsedFromTick().Int64(); |
|
106 if(Abs(interval - KInterval) > KIntervalError) |
|
107 { |
|
108 ERR_PRINTF1(KSecondDelayOutOfRange); |
|
109 SetTestStepResult(EFail); |
|
110 } |
|
111 |
|
112 watch.Tick(); |
|
113 PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); |
|
114 interval = watch.ElapsedFromTick().Int64(); |
|
115 if(Abs(interval - KInterval) > KIntervalError) |
|
116 { |
|
117 ERR_PRINTF1(KThirdDelayOutOfRange); |
|
118 SetTestStepResult(EFail); |
|
119 } |
|
120 } |
|
121 |
|
122 // stop tracking |
|
123 updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(0)); |
|
124 iPositioner.SetUpdateOptions(updateOptions); |
|
125 stopTracking.UniversalTime(); |
|
126 |
|
127 // psy6 must return event log |
|
128 genInfo->SetRequestedField(KPSY6FieldEventLog); |
|
129 watch.Tick(); |
|
130 PositionRequestWithCheck(*genInfo, KErrNone, KUidLcfPsy6); |
|
131 if(watch.ElapsedFromTick() > KNormalRequestDelay) |
|
132 { |
|
133 ERR_PRINTF1(KNormalDelayTooBig); |
|
134 SetTestStepResult(EFail); |
|
135 } |
|
136 |
|
137 // Analyze event log from PSY6 |
|
138 TQueryEvent* eventArray = GetPsy6EventLogL(*genInfo); |
|
139 |
|
140 TInt32 logSize; |
|
141 if(KErrNone != genInfo->GetValue(KPSY6FieldEventLogSize, logSize)) |
|
142 { |
|
143 ERR_PRINTF1(KFailedReadLogsize); |
|
144 SetTestStepResult(EFail); |
|
145 return TestStepResult(); |
|
146 } |
|
147 |
|
148 TUint expectedEvents[] = {EUpdate, |
|
149 ETrackingStart, |
|
150 EUpdate, |
|
151 EUpdate, |
|
152 ETrackingStop, |
|
153 EUpdate}; |
|
154 TUint numExpectedEvents = sizeof(expectedEvents) / sizeof(TUint); |
|
155 |
|
156 CheckExpectedResult(logSize, numExpectedEvents, KWrongEventNumberPSY6); |
|
157 |
|
158 // check event types |
|
159 for (TInt32 index = 0; index < Min(logSize, numExpectedEvents); index++) |
|
160 { |
|
161 TQueryEvent& event = *(eventArray + index); |
|
162 CheckExpectedResult(event.iEventType, expectedEvents[index], KUnexpectedEvent); |
|
163 } |
|
164 |
|
165 // check event times |
|
166 if(logSize != numExpectedEvents) |
|
167 { |
|
168 ERR_PRINTF1(KCannotCheckEventTimes); |
|
169 SetTestStepResult(EFail); |
|
170 return TestStepResult(); |
|
171 } |
|
172 |
|
173 |
|
174 // ( ETrackingStart should have happenned right after first |
|
175 // request was completed ) |
|
176 // Harley: Because of intelligent Default Proxy change, the tracking start |
|
177 // shall happen just before the second location request is issued to the PSY. |
|
178 TQueryEvent& event = *(eventArray + 1); |
|
179 if(Abs(secondRequest.MicroSecondsFrom(event.iTime).Int64()) > KDiff) |
|
180 { |
|
181 ERR_PRINTF1(KStartEventBeyondExpectendRange); |
|
182 SetTestStepResult(EFail); |
|
183 } |
|
184 |
|
185 // ETrackingStop should have happenned right after second |
|
186 // SetUpdateOptions |
|
187 event = *(eventArray + 4); |
|
188 |
|
189 if(Abs(stopTracking.MicroSecondsFrom(event.iTime).Int64()) > KDiff) |
|
190 { |
|
191 ERR_PRINTF1(KStopEventBeyondExpectendRange); |
|
192 SetTestStepResult(EFail); |
|
193 } |
|
194 // cleanup |
|
195 CleanupStack::PopAndDestroy(genInfo); |
|
196 StandardCleanup(); |
|
197 return TestStepResult(); |
|
198 } |
|
199 |
|
200 |
|
201 |
|
202 TVerdict CTrackingSessionStep::doTestStepPostambleL() |
|
203 /** |
|
204 * @return - TVerdict code |
|
205 * Override of base class virtual |
|
206 */ |
|
207 { |
|
208 CTe_defproxySuiteStepBase::doTestStepPostambleL(); |
|
209 return TestStepResult(); |
|
210 } |