|
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 "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 // This is the class implementation for the Hybrid MoLr Tests |
|
15 // |
|
16 // |
|
17 |
|
18 |
|
19 // EPOC includes. |
|
20 #include <e32math.h> |
|
21 |
|
22 // LBS includes. |
|
23 #include <lbssatellite.h> |
|
24 #include <lbs/lbsgpsmeasurement.h> |
|
25 #include <lbs/lbsnetprotocolbase.h> |
|
26 #include <lbs/lbsassistancedatabuilderset.h> |
|
27 #include <lbs/lbsloccommon.h> |
|
28 #include <lbs/lbsx3p.h> |
|
29 #include <lbs/lbsnetprotocolbase.h> |
|
30 |
|
31 // LBS test includes. |
|
32 //#include "ctlbsuebasedmolrself.h" |
|
33 #include "ctlbsautonomousmolrfutile.h" |
|
34 #include <lbs/test/tlbsutils.h> |
|
35 #include "argutils.h" |
|
36 #include <lbs/test/activeyield.h> |
|
37 |
|
38 |
|
39 /** |
|
40 Static Constructor |
|
41 */ |
|
42 CT_LbsAutonomousMOLRFutile* CT_LbsAutonomousMOLRFutile::New(CT_LbsHybridMOLRServer& aParent) |
|
43 { |
|
44 // Note the lack of ELeave. |
|
45 // This means that having insufficient memory will return NULL; |
|
46 CT_LbsAutonomousMOLRFutile* testStep = new CT_LbsAutonomousMOLRFutile(aParent); |
|
47 if (testStep) |
|
48 { |
|
49 TInt err = KErrNone; |
|
50 |
|
51 TRAP(err, testStep->ConstructL()); |
|
52 if (err) |
|
53 { |
|
54 delete testStep; |
|
55 testStep = NULL; |
|
56 } |
|
57 } |
|
58 return testStep; |
|
59 } |
|
60 |
|
61 |
|
62 /** |
|
63 * Constructor |
|
64 */ |
|
65 CT_LbsAutonomousMOLRFutile::CT_LbsAutonomousMOLRFutile(CT_LbsHybridMOLRServer& aParent) : CT_LbsHybridMOLRStep(aParent) |
|
66 { |
|
67 SetTestStepName(KLbsAutonomousMOLRFutile); |
|
68 } |
|
69 |
|
70 |
|
71 void CT_LbsAutonomousMOLRFutile::ConstructL() |
|
72 { |
|
73 // Create the base class objects. |
|
74 CT_LbsHybridMOLRStep::ConstructL(); |
|
75 } |
|
76 |
|
77 /** |
|
78 * Destructor |
|
79 */ |
|
80 CT_LbsAutonomousMOLRFutile::~CT_LbsAutonomousMOLRFutile() |
|
81 { |
|
82 } |
|
83 |
|
84 |
|
85 TVerdict CT_LbsAutonomousMOLRFutile::doTestStepL() |
|
86 { |
|
87 INFO_PRINTF1(_L("CT_LbsAutonomousMOLRFutile::doTestStepL()")); |
|
88 |
|
89 // Stop the test if the preable failed |
|
90 TESTL(TestStepResult() == EPass); |
|
91 |
|
92 const TInt KTimeOut = 60*1000*1000; |
|
93 |
|
94 // Create Network Protocol Proxy |
|
95 CNetProtocolProxy* proxy = CNetProtocolProxy::NewL(); |
|
96 CleanupStack::PushL(proxy); |
|
97 |
|
98 // Recv --> GetCurrentCapabilitiesResponse. |
|
99 // Soak up the Lbs System Status (produced by A-GPS Manager startup). |
|
100 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse); |
|
101 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
102 TInt cleanupCnt; |
|
103 cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
104 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
105 CleanupStack::PopAndDestroy(cleanupCnt); |
|
106 |
|
107 // Do the /actual/ test step! |
|
108 |
|
109 // Setup location session and position watcher. |
|
110 RPositionServer server; |
|
111 TESTL(KErrNone == server.Connect()); |
|
112 CleanupClosePushL(server); |
|
113 |
|
114 RPositioner pos; |
|
115 TESTL(KErrNone == pos.Open(server)); |
|
116 CleanupClosePushL(pos); |
|
117 |
|
118 CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this); |
|
119 |
|
120 |
|
121 // Client Send - a self-locate request. |
|
122 pWatch->IssueNotifyPositionUpdate(); |
|
123 |
|
124 |
|
125 // Recv --> RequestSelfLocation. |
|
126 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation); |
|
127 |
|
128 // Process the response. |
|
129 TLbsNetSessionId* sessionId = NULL; |
|
130 TLbsNetPosRequestOptionsAssistance* opts = NULL; |
|
131 |
|
132 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts); |
|
133 |
|
134 TBool qualitycheck = ArgUtils::CompareQuality( opts, |
|
135 ETrue, |
|
136 KMinHorizontalAcc, |
|
137 KMinVerticalAcc, |
|
138 KDefaultMaxFixTime, |
|
139 0, |
|
140 EAssistanceDataNone, |
|
141 TPositionModuleInfo::ETechnologyTerminal |
|
142 ); |
|
143 |
|
144 TESTL(qualitycheck); |
|
145 |
|
146 iSessionId.SetSessionNum(sessionId->SessionNum()); |
|
147 iSessionId.SetSessionOwner(sessionId->SessionOwner()); |
|
148 |
|
149 CleanupStack::PopAndDestroy(cleanupCnt); |
|
150 sessionId = NULL; |
|
151 opts = NULL; |
|
152 |
|
153 |
|
154 // Send <-- ProcessStatusUpdate. |
|
155 MLbsNetworkProtocolObserver::TLbsNetProtocolService serviceMask = MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
156 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
157 |
|
158 // Wait for AGPs module to send update |
|
159 TInt KTimeout = 1000000; // 1 seconds |
|
160 TESTL(proxy->WaitForResponse(KTimeout) == ENetMsgTimeoutExpired); |
|
161 |
|
162 |
|
163 // Send <-- ProcessSessionComplete. |
|
164 TInt reason = KErrNone; |
|
165 proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
166 |
|
167 |
|
168 // Send <-- ProcessStatusUpdate. |
|
169 serviceMask = MLbsNetworkProtocolObserver::EServiceNone; |
|
170 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
171 |
|
172 |
|
173 // Client recv - the gps position determined by the gps module. |
|
174 CheckForObserverEventTestsL(KTimeOut, *this); |
|
175 |
|
176 // Wait for 10 seconds to ensure no additional responses turn up. |
|
177 TInt delta = 10 * 1000 * 1000; |
|
178 TNetProtocolResponseType mType = proxy->WaitForResponse(delta); |
|
179 TESTL(mType == ENetMsgTimeoutExpired); |
|
180 |
|
181 // Done. Now cleanup... |
|
182 CleanupStack::PopAndDestroy(pWatch); |
|
183 CleanupStack::PopAndDestroy(); // pos |
|
184 CleanupStack::PopAndDestroy(); // server |
|
185 CleanupStack::PopAndDestroy(proxy); |
|
186 |
|
187 |
|
188 return TestStepResult(); |
|
189 } |
|
190 |
|
191 |
|
192 // MPosServerObserver |
|
193 void CT_LbsAutonomousMOLRFutile::OnGetLastKnownPosition(TInt32 /*aErr*/, const TPositionInfoBase& /*aPosInfo*/) |
|
194 { |
|
195 TEST(EFalse); // Shouldn't see this... |
|
196 ReturnToTestStep(); |
|
197 } |
|
198 |
|
199 |
|
200 void CT_LbsAutonomousMOLRFutile::OnNotifyPositionUpdate(TInt32 aErr, const TPositionInfoBase& aPosInfo) |
|
201 { |
|
202 // Verify error. |
|
203 TEST(aErr == KPositionQualityLoss); |
|
204 |
|
205 if(iExpectedApiBehaviour == EApiVariant1) |
|
206 { // only for variant1 of the api a position is returned with KPositionQualityLoss |
|
207 // Verify position. |
|
208 TEST(aPosInfo.PositionClassType() == EPositionInfoClass); |
|
209 TEST(aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyTerminal); |
|
210 } |
|
211 ReturnToTestStep(); |
|
212 } |
|
213 |