|
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 molr27Step.cpp |
|
20 @internalTechnology |
|
21 */ |
|
22 #include "molr27Step.h" |
|
23 #include "te_suplprotocolsuitedefs.h" |
|
24 #include <lbs/lbshostsettings.h> |
|
25 #include <centralrepository.h> |
|
26 |
|
27 |
|
28 Cmolr27Step::~Cmolr27Step() |
|
29 { |
|
30 } |
|
31 |
|
32 Cmolr27Step::Cmolr27Step() |
|
33 { |
|
34 SetTestStepName(Kmolr27Step); |
|
35 } |
|
36 |
|
37 /** |
|
38 * @return - TVerdict code |
|
39 * Override of base class virtual |
|
40 */ |
|
41 TVerdict Cmolr27Step::doTestStepPreambleL() |
|
42 |
|
43 { |
|
44 |
|
45 // Call base class method for pre test actions |
|
46 CTe_suplprotocolSuiteStepBase::doTestStepPreambleL(); |
|
47 |
|
48 TLbsNetProtocolModuleParams param(*iGatewayObserver); |
|
49 iModule = CSuplGatewayInterface::NewL(reinterpret_cast<TAny*>(¶m)); |
|
50 |
|
51 return TestStepResult(); |
|
52 } |
|
53 |
|
54 /** Perform CMoLrStep1 test step. |
|
55 This test verifies that the SUPL Protocol Module correctly handles |
|
56 an Cell-Based MO-LR Self Locate sequence . |
|
57 |
|
58 @return TVerdict test result code |
|
59 */ |
|
60 TVerdict Cmolr27Step::doTestStepL() |
|
61 { |
|
62 |
|
63 INFO_PRINTF1(_L("\t********************************************************************")); |
|
64 INFO_PRINTF1(_L("\tMOLR host selection - last modified network-provisioned host selected")); |
|
65 INFO_PRINTF1(_L("\t********************************************************************")); |
|
66 INFO_PRINTF1(_L("- START -")); |
|
67 |
|
68 //Clear the repository that keeps the host settings |
|
69 CRepository* rep = CRepository::NewL(KLbsHostSettingsSuplStoreId); |
|
70 CleanupStack::PushL(rep); |
|
71 User::LeaveIfError(rep->Reset()); |
|
72 CleanupStack::PopAndDestroy(rep); |
|
73 |
|
74 CLbsHostSettingsStore* slpSettingsStore = CLbsHostSettingsStore::NewL(KLbsHostSettingsSuplStoreId); |
|
75 CleanupStack::PushL(slpSettingsStore); |
|
76 |
|
77 |
|
78 // Delete the Default host if present |
|
79 TLbsHostSettingsSupl defSettings; |
|
80 TLbsHostSettingsId defSettingsId; |
|
81 if (KErrNone == slpSettingsStore->GetDefaultHostSettings(defSettings, defSettingsId)) |
|
82 { |
|
83 slpSettingsStore->DeleteHostSettings(defSettingsId); |
|
84 } |
|
85 |
|
86 |
|
87 // Create a "network-provisioned" entry which is not the default host |
|
88 INFO_PRINTF1(_L("[First network-provisioned host created]")); |
|
89 TLbsHostSettingsSupl networkSettings; |
|
90 TLbsHostNameAddress netHostAddr((TText8*)"supl1.provider.com"); |
|
91 TLbsHostName netHostName((TText8*)"netSuplServer1"); |
|
92 TLbsProviderId netHostProvider ((TText8*)"provider"); |
|
93 TLbsHostSettingsId netSettingsId; |
|
94 networkSettings.SetHostNameAddress(netHostAddr); |
|
95 networkSettings.SetName(netHostName); |
|
96 networkSettings.SetProviderId(netHostProvider); |
|
97 networkSettings.SetPortId(KLbsSuplUseDefaultPortId); |
|
98 networkSettings.SetConnectionPoint(1,TLbsHostSettingsSupl::ELbsConnectionTypeNap); |
|
99 networkSettings.SetAuthModesMOLR(TLbsHostSettingsSupl::EAuthTls); |
|
100 networkSettings.SetAuthModesMTLR(TLbsHostSettingsSupl::EAuthTls); |
|
101 |
|
102 if (KErrNone != slpSettingsStore->CreateHostSettings(networkSettings, KLbsHostSettingsDevProvCreatorId, netSettingsId)) |
|
103 { |
|
104 SetTestStepResult(EFail); |
|
105 return TestStepResult(); |
|
106 } |
|
107 |
|
108 // Create a "user-provisioned" entry which is NOT set as default host |
|
109 INFO_PRINTF1(_L("[User-provisioned host created]")); |
|
110 TLbsHostSettingsSupl userSettings; |
|
111 TLbsHostNameAddress userHostAddr((TText8*)"supl.thirdparty.com"); |
|
112 TLbsHostName userHostName((TText8*)"userSuplServer"); |
|
113 TLbsProviderId userHostProvider ((TText8*)"provider"); |
|
114 TLbsHostSettingsId userSettingsId; |
|
115 userSettings.SetHostNameAddress(userHostAddr); |
|
116 userSettings.SetName(userHostName); |
|
117 userSettings.SetProviderId(userHostProvider); |
|
118 userSettings.SetPortId(KLbsSuplUseDefaultPortId); |
|
119 TLbsHostCreatorId KTestMadeUpUid = {0x101010}; |
|
120 userSettings.SetConnectionPoint(1,TLbsHostSettingsSupl::ELbsConnectionTypeNap); |
|
121 userSettings.SetAuthModesMOLR(TLbsHostSettingsSupl::EAuthTls); |
|
122 userSettings.SetAuthModesMTLR(TLbsHostSettingsSupl::EAuthTls); |
|
123 |
|
124 if (KErrNone != slpSettingsStore->CreateHostSettings(userSettings, KTestMadeUpUid, userSettingsId)) |
|
125 { |
|
126 SetTestStepResult(EFail); |
|
127 return TestStepResult(); |
|
128 } |
|
129 |
|
130 // Create another "network-provisioned" entry which is not the default host entry. |
|
131 // Since this is the "last modified" network entry, and no other entry has |
|
132 // been set as "default", this is the host entry that the MOLR state machine |
|
133 // should select for connecting to. |
|
134 INFO_PRINTF1(_L("[Second network-provisioned host created]")); |
|
135 TLbsHostSettingsSupl networkSettings2; |
|
136 TLbsHostNameAddress netHostAddr2((TText8*)"supl2.provider.com"); |
|
137 TLbsHostName netHostName2((TText8*)"netSuplServer2"); |
|
138 TLbsProviderId netHostProvider2((TText8*)"provider"); |
|
139 TLbsHostSettingsId netSettingsId2; |
|
140 networkSettings2.SetHostNameAddress(netHostAddr2); |
|
141 networkSettings2.SetName(netHostName2); |
|
142 networkSettings2.SetProviderId(netHostProvider2); |
|
143 networkSettings2.SetPortId(KLbsSuplUseDefaultPortId); |
|
144 networkSettings2.SetConnectionPoint(1,TLbsHostSettingsSupl::ELbsConnectionTypeNap); |
|
145 networkSettings2.SetAuthModesMOLR(TLbsHostSettingsSupl::EAuthTls); |
|
146 networkSettings2.SetAuthModesMTLR(TLbsHostSettingsSupl::EAuthTls); |
|
147 |
|
148 |
|
149 if (KErrNone != slpSettingsStore->CreateHostSettings(networkSettings2, KLbsHostSettingsDevProvCreatorId, netSettingsId2)) |
|
150 { |
|
151 SetTestStepResult(EFail); |
|
152 return TestStepResult(); |
|
153 } |
|
154 |
|
155 // Initiate MO-LR |
|
156 INFO_PRINTF1(_L("\tLBS -> RequestNetworkLocation")); |
|
157 TLbsNetSessionId sessionId1(TUid::Uid(0x12345678), 0x1111); |
|
158 TLbsNetPosRequestOptions options1; |
|
159 options1.SetNewClientConnected(ETrue); |
|
160 TLbsNetPosRequestQuality quality1; |
|
161 options1.SetRequestQuality(quality1); |
|
162 iModule->RequestNetworkLocation(sessionId1, options1); |
|
163 |
|
164 // Check Connection Manager receives a request for connecting to the |
|
165 // host whose settings Id is netSettingsId2 |
|
166 if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq) || |
|
167 netSettingsId2 != iNetworkObserver->HostSettingsId()) |
|
168 { |
|
169 SetTestStepResult(EFail); |
|
170 return TestStepResult(); |
|
171 } |
|
172 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET")); |
|
173 |
|
174 // Simulate the connection is up (inject that event) |
|
175 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET")); |
|
176 iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId()); |
|
177 |
|
178 // Check Connection Manager receives a request to send a SUPL START |
|
179 if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESuplStartSendReq)) |
|
180 { |
|
181 SetTestStepResult(EFail); |
|
182 return TestStepResult(); |
|
183 } |
|
184 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL START -> NET")); |
|
185 |
|
186 // Inject a SUPL END (with position) |
|
187 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET")); |
|
188 CSuplMessageBase* suplEnd = BuildSuplEndL(ETrue); |
|
189 iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd); |
|
190 |
|
191 // Check gateway receives Location Update |
|
192 INFO_PRINTF1(_L("\tLBS <- ProcessLocationUpdate()")); |
|
193 if (EFail == CheckGatewayCallbackL( |
|
194 CSuplGatewayObserver::EProcessLocationUpdate)) |
|
195 { |
|
196 SetTestStepResult(EFail); |
|
197 return TestStepResult(); |
|
198 } |
|
199 |
|
200 // Check gateway receives a session complete indication |
|
201 if (EFail == CheckGatewayCallbackL( |
|
202 CSuplGatewayObserver::EProcessSessionComplete)) |
|
203 { |
|
204 SetTestStepResult(EFail); |
|
205 return TestStepResult(); |
|
206 } |
|
207 INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete")); |
|
208 |
|
209 // Check Connection Manager receives a disconnection request |
|
210 if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq)) |
|
211 { |
|
212 SetTestStepResult(EFail); |
|
213 return TestStepResult(); |
|
214 } |
|
215 INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET")); |
|
216 |
|
217 // Check if more observer activity takes place |
|
218 if (iGatewayObserver->IsMoreObserverActivity() || |
|
219 iNetworkObserver->IsMoreObserverActivity()) |
|
220 { |
|
221 SetTestStepResult(EFail); |
|
222 return TestStepResult(); |
|
223 } |
|
224 |
|
225 // Delete the entries in the SUPL HostSettings store created by this test |
|
226 slpSettingsStore->DeleteHostSettings(netSettingsId); |
|
227 slpSettingsStore->DeleteHostSettings(userSettingsId); |
|
228 slpSettingsStore->DeleteHostSettings(netSettingsId2); |
|
229 |
|
230 CleanupStack::PopAndDestroy(slpSettingsStore); |
|
231 |
|
232 INFO_PRINTF1(_L("- END -")); |
|
233 |
|
234 SetTestStepResult(EPass); |
|
235 return TestStepResult(); |
|
236 } |
|
237 |
|
238 |
|
239 /** |
|
240 * @return - TVerdict code |
|
241 * Override of base class virtual |
|
242 */ |
|
243 TVerdict Cmolr27Step::doTestStepPostambleL() |
|
244 { |
|
245 delete iModule; |
|
246 |
|
247 // Reset the repository that keeps the host settings |
|
248 // to its initial state |
|
249 CRepository* rep = CRepository::NewL(KLbsHostSettingsSuplStoreId); |
|
250 CleanupStack::PushL(rep); |
|
251 User::LeaveIfError(rep->Reset()); |
|
252 CleanupStack::PopAndDestroy(rep); |
|
253 |
|
254 // Call base class method for post test actions |
|
255 CTe_suplprotocolSuiteStepBase::doTestStepPostambleL(); |
|
256 return TestStepResult(); |
|
257 } |