|
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 // |
|
15 |
|
16 // LBS includes. |
|
17 #include <lbs/test/lbsnetprotocolproxy.h> |
|
18 #include <lbs/lbsnetprotocolbase.h> |
|
19 #include <lbs/lbsassistancedatabuilderset.h> |
|
20 |
|
21 // LBS test includes. |
|
22 #include "ctlbsmolraccrefpos.h" |
|
23 #include <lbs/test/tlbsutils.h> |
|
24 #include "argutils.h" |
|
25 #include <lbs/test/activeyield.h> |
|
26 |
|
27 /** |
|
28 Static Constructor |
|
29 */ |
|
30 CT_LbsMOLRAccRefPos* CT_LbsMOLRAccRefPos::New(CT_LbsHybridMOLRServer& aParent) |
|
31 { |
|
32 // Note that we do not use ELeave. |
|
33 // This means that having insufficient memory will return NULL; |
|
34 CT_LbsMOLRAccRefPos* testStep = new CT_LbsMOLRAccRefPos(aParent); |
|
35 if (testStep) |
|
36 { |
|
37 TInt err = KErrNone; |
|
38 |
|
39 TRAP(err, testStep->ConstructL()); |
|
40 if (err) |
|
41 { |
|
42 delete testStep; |
|
43 testStep = NULL; |
|
44 } |
|
45 } |
|
46 return testStep; |
|
47 } |
|
48 |
|
49 /** |
|
50 * Constructor |
|
51 */ |
|
52 CT_LbsMOLRAccRefPos::CT_LbsMOLRAccRefPos(CT_LbsHybridMOLRServer& aParent) : CT_LbsHybridMOLRStep(aParent) |
|
53 { |
|
54 SetTestStepName(KLbsMOLRAccurateReferencePosition); |
|
55 iSessionId.SetSessionOwner(KRequestUid); |
|
56 iSessionId.SetSessionNum(0x0005); |
|
57 } |
|
58 |
|
59 |
|
60 void CT_LbsMOLRAccRefPos::ConstructL() |
|
61 { |
|
62 // Create the base class objects. |
|
63 CT_LbsHybridMOLRStep::ConstructL(); |
|
64 } |
|
65 |
|
66 |
|
67 /** |
|
68 * Destructor |
|
69 */ |
|
70 CT_LbsMOLRAccRefPos::~CT_LbsMOLRAccRefPos() |
|
71 { |
|
72 } |
|
73 |
|
74 TVerdict CT_LbsMOLRAccRefPos::doTestStepL() |
|
75 { |
|
76 INFO_PRINTF1(_L("CT_LbsHybridMOLRFutile::doTestStepL()")); |
|
77 // Stop the test if the preamble failed |
|
78 TESTL(TestStepResult() == EPass); |
|
79 |
|
80 const TInt KTimeOut = 60*1000*1000; |
|
81 |
|
82 // Carryout unique test actions. |
|
83 |
|
84 // Create Network Protocol Proxy |
|
85 CNetProtocolProxy* proxy = CNetProtocolProxy::NewL(); |
|
86 CleanupStack::PushL(proxy); |
|
87 |
|
88 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgGetCurrentCapabilitiesResponse); |
|
89 CLbsNetworkProtocolBase::TLbsSystemStatus status; |
|
90 TInt cleanupCnt; |
|
91 cleanupCnt = proxy->GetArgsLC(ENetMsgGetCurrentCapabilitiesResponse, &status); |
|
92 TESTL(status == CLbsNetworkProtocolBase::ESystemStatusNone); |
|
93 CleanupStack::PopAndDestroy(cleanupCnt); |
|
94 |
|
95 // Start Test Step |
|
96 RPositionServer server; |
|
97 TESTL(KErrNone == server.Connect()); |
|
98 CleanupClosePushL(server); |
|
99 |
|
100 RPositioner pos; |
|
101 TESTL(KErrNone == pos.Open(server)); |
|
102 CleanupClosePushL(pos); |
|
103 |
|
104 // Set the max fix time for the client request to ensure the location server does not complete the request too soon during the test. |
|
105 TPositionUpdateOptions |
|
106 posOpts(TTimeIntervalMicroSeconds(0), TTimeIntervalMicroSeconds(KMOLRFixTime)); |
|
107 pos.SetUpdateOptions(posOpts); |
|
108 |
|
109 CPosServerWatcher *pWatch = CPosServerWatcher::NewLC(pos, *this); |
|
110 |
|
111 // Request a self-locate MoLr. |
|
112 pWatch->IssueNotifyPositionUpdate(); |
|
113 |
|
114 // >> RequestSelfLocation() |
|
115 TESTL(proxy->WaitForResponse(KTimeOut) == ENetMsgRequestSelfLocation); |
|
116 |
|
117 // Process the response. |
|
118 TLbsNetSessionId* sessionId = NULL; |
|
119 TLbsNetPosRequestOptionsAssistance* opts = NULL; |
|
120 cleanupCnt = proxy->GetArgsLC(ENetMsgRequestSelfLocation, &sessionId, &opts); |
|
121 |
|
122 TBool qualitycheck = ArgUtils::CompareQuality( opts, |
|
123 ETrue, |
|
124 KMinHorizontalAcc, |
|
125 KMinVerticalAcc, |
|
126 KMOLRFixTime, |
|
127 0, |
|
128 EAssistanceDataReferenceTime, |
|
129 (TPositionModuleInfo::ETechnologyTerminal |
|
130 | TPositionModuleInfo::ETechnologyAssisted) |
|
131 ); |
|
132 TESTL(qualitycheck); |
|
133 |
|
134 iSessionId.SetSessionNum(sessionId->SessionNum()); |
|
135 iSessionId.SetSessionOwner(sessionId->SessionOwner()); |
|
136 |
|
137 CleanupStack::PopAndDestroy(cleanupCnt); |
|
138 sessionId = NULL; |
|
139 opts = NULL; |
|
140 |
|
141 // << ProcessStatusUpdate(EServiceSelfLocation) |
|
142 MLbsNetworkProtocolObserver::TLbsNetProtocolServiceMask serviceMask = |
|
143 MLbsNetworkProtocolObserver::EServiceSelfLocation; |
|
144 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
145 |
|
146 // << ProcessLocationUpdate(SessionId, RefPosition) |
|
147 TPositionInfo refPosInfo = ArgUtils::MolrReferencePositionInfo(); |
|
148 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &refPosInfo); |
|
149 |
|
150 // TEST: Get the ref pos app side. |
|
151 CheckForObserverEventTestsL(KTimeOut, *this); |
|
152 |
|
153 // << ProcessAssistanceData() |
|
154 TLbsAsistanceDataGroup dataMask = EAssistanceDataReferenceTime; |
|
155 RLbsAssistanceDataBuilderSet assistanceData; |
|
156 ArgUtils::PopulateLC(assistanceData); |
|
157 TInt reason(KErrNone); |
|
158 proxy->CallL(ENetMsgProcessAssistanceData, &dataMask, &assistanceData, &reason); |
|
159 CleanupStack::PopAndDestroy(); // assistanceData |
|
160 |
|
161 // << ProcessLocationUpdate - return network calculated pos |
|
162 TPositionInfo networkPosInfo = ArgUtils::MolrNetworkPositionInfo(); |
|
163 proxy->CallL(ENetMsgProcessLocationUpdate, &iSessionId, &networkPosInfo); |
|
164 |
|
165 // TEST: Get the final network position(= Ref Position) |
|
166 TESTL(iState == ERefLocReceived); |
|
167 |
|
168 // << ProcessSessionComplete(SessionId, KErrNone) |
|
169 reason = KErrNone; |
|
170 proxy->CallL(ENetMsgProcessSessionComplete, &iSessionId, &reason); |
|
171 |
|
172 // << ENetMsgProcessStatusUpdate() |
|
173 serviceMask = MLbsNetworkProtocolObserver::EServiceNone; |
|
174 proxy->CallL(ENetMsgProcessStatusUpdate, &serviceMask); |
|
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 |
|
182 // Done. Now cleanup... |
|
183 CleanupStack::PopAndDestroy(pWatch); |
|
184 CleanupStack::PopAndDestroy(); // pos |
|
185 CleanupStack::PopAndDestroy(); // server |
|
186 CleanupStack::PopAndDestroy(proxy); |
|
187 return TestStepResult(); |
|
188 } |
|
189 |
|
190 // MPosServerObserver |
|
191 void CT_LbsMOLRAccRefPos::OnGetLastKnownPosition(TInt32 /*aErr*/, const TPositionInfoBase& /*aPosInfo*/) |
|
192 { |
|
193 TEST(EFalse); // Shouldn't see this... |
|
194 ReturnToTestStep(); |
|
195 } |
|
196 |
|
197 void CT_LbsMOLRAccRefPos::OnNotifyPositionUpdate(TInt32 aErr, const TPositionInfoBase& aPosInfo) |
|
198 { |
|
199 // Verify position. |
|
200 TEST(aPosInfo.PositionClassType() == EPositionInfoClass); |
|
201 |
|
202 // Expecting ref pos. |
|
203 if (iState == EInitializing) |
|
204 { |
|
205 // Verify error. |
|
206 TEST(aErr == KErrNone); |
|
207 iState = ERefLocReceived; |
|
208 TEST(aPosInfo.PositionMode() == TPositionModuleInfo::ETechnologyNetwork); |
|
209 |
|
210 // check for refpos details |
|
211 const TPositionInfo posInfo = static_cast<const TPositionInfo&>(aPosInfo); |
|
212 TESTL(ArgUtils::ComparePositionInfoToMolrRefPos(posInfo)); |
|
213 } |
|
214 |
|
215 // Not expecting anything else. |
|
216 else |
|
217 { |
|
218 TEST(EFalse); |
|
219 } |
|
220 |
|
221 ReturnToTestStep(); |
|
222 } |