|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "ctlbsclientstepfallbackuninstall.h" |
|
22 #include "ctlbsclientdefs.h" |
|
23 #include <badesca.h> |
|
24 #include <epos_cposmodules.h> |
|
25 #include <epos_cposmoduleupdate.h> |
|
26 #include <epos_cposmoduleidlist.h> |
|
27 #include <lbscommon.h> |
|
28 #include <lbspositioninfo.h> |
|
29 #include <swi/launcher.h> |
|
30 #include "tctlbsclientmodulesobserver.h" |
|
31 #include "ctlbsinstallui.h" |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // --------------------------------------------------------- |
|
36 // Constructor. |
|
37 // --------------------------------------------------------- |
|
38 CT_LbsClientStepFallbackUninstall::CT_LbsClientStepFallbackUninstall(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) |
|
39 { |
|
40 _LIT(KTestName, "TP301 - Error on Uninstall"); |
|
41 SetTestStepName(KTestName); |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // Destructor. |
|
47 // --------------------------------------------------------- |
|
48 CT_LbsClientStepFallbackUninstall::~CT_LbsClientStepFallbackUninstall() |
|
49 { |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // CT_LbsClientStepFallbackUninstall::StartL |
|
54 // |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 void CT_LbsClientStepFallbackUninstall::StartL() |
|
58 { |
|
59 iError = EFalse; |
|
60 |
|
61 // Make sure the psy is uninstalled to begin with |
|
62 TInt appId; |
|
63 GetIntFromConfig(ConfigSection(),KLbsSisInstallAppId,appId); |
|
64 SISUninstallPsyL(TUid::Uid(appId)); // may return an error, but that's ok |
|
65 User::After(2000000); |
|
66 |
|
67 // Register as an observer to listen for events |
|
68 CPosModules* db = CPosModules::OpenL(); |
|
69 CleanupStack::PushL(db); |
|
70 |
|
71 db->SetObserverL(*this); |
|
72 |
|
73 // Make sure that only the delayed response (integrated, non-gps) test psy is enabled: |
|
74 SetupPsyL(iUidDelayedResponsePsy); |
|
75 |
|
76 //////////////////////////////////// |
|
77 // Install test psy: |
|
78 TPtrC sispath; |
|
79 GetStringFromConfig(ConfigSection(),KLbsSisInstallSisLocation,sispath); |
|
80 TInt err = SISInstallPsyL(sispath); |
|
81 if(err != KErrNone) |
|
82 { |
|
83 INFO_PRINTF2(_L("Failing: SISInstallPsyL returned %d\n"), err); |
|
84 SetTestStepResult(EFail); |
|
85 } |
|
86 iExpectedEvent = EPosModulesEventModuleInstalled; |
|
87 INFO_PRINTF1(_L("Wait for EPosModulesEventModuleInstalled event\n")); |
|
88 // Wait for event |
|
89 DoEventHandlingL(); |
|
90 //////////////////////////////////// |
|
91 |
|
92 //////////////////////////////////// |
|
93 // Set priorities with installed psy at top (so psy is in use when uninstalled): |
|
94 db->SetModulePriorityL(iUidInstallableTrackingPsy, 0); |
|
95 db->SetModulePriorityL(iUidDelayedResponsePsy, 1); |
|
96 //////////////////////////////////// |
|
97 |
|
98 //////////////////////////////////// |
|
99 // Make a periodic request to default proxy and verify it comes from the installed psy: |
|
100 RPositionServer posServer; |
|
101 CleanupClosePushL(posServer); |
|
102 err = posServer.Connect(); |
|
103 _LIT(KConnectErr, "Error when connecing to EPos server, %d"); |
|
104 AssertTrueL(err == KErrNone, KConnectErr, err); |
|
105 |
|
106 RPositioner positioner; |
|
107 CleanupClosePushL(positioner); |
|
108 err = positioner.Open(posServer); |
|
109 _LIT(KOpenErr, "Error when opening positioner, %d"); |
|
110 AssertTrueL(err == KErrNone, KOpenErr, err); |
|
111 |
|
112 TInt normalInterval = 5000000; // 5 seconds |
|
113 TTimeIntervalMicroSeconds interval = TTimeIntervalMicroSeconds(normalInterval); |
|
114 TPositionUpdateOptions posOption; |
|
115 posOption.SetUpdateInterval(interval); |
|
116 |
|
117 err = positioner.SetUpdateOptions(posOption); |
|
118 _LIT(KUpdateErr, "Error when setting update interval, %d"); |
|
119 AssertTrueL(err == KErrNone, KUpdateErr, err); |
|
120 INFO_PRINTF2(_L("Update Interval set to %d\n"), interval.Int64()); |
|
121 |
|
122 TPositionInfo positionInfo; |
|
123 TRequestStatus status; |
|
124 positioner.NotifyPositionUpdate(positionInfo, status); |
|
125 INFO_PRINTF1(_L("Wait for NotifyPositionUpdate request to complete\n")); |
|
126 User::WaitForRequest(status); |
|
127 |
|
128 VerifyPositionFromL(positionInfo, iUidInstallableTrackingPsy); |
|
129 |
|
130 if(status != KErrNone) |
|
131 { |
|
132 INFO_PRINTF2(_L("Failing: NotifyPositionUpdate returned %d\n"), status.Int()); |
|
133 } |
|
134 //////////////////////////////////// |
|
135 |
|
136 INFO_PRINTF1(_L("Issue another NotifyPositionUpdate() request (target time will be in the future)\n")); |
|
137 positioner.NotifyPositionUpdate(positionInfo, status); |
|
138 |
|
139 #ifndef __WINSCW__ // doesn't work on the emulator (where cannot uninstall an in-use dll) |
|
140 //////////////////////////////////// |
|
141 // UnInstall test psy while last request is outstanding: |
|
142 INFO_PRINTF1(_L("Uninstall the PSY\n")); |
|
143 err = SISUninstallPsyL(TUid::Uid(appId)); |
|
144 if(err != KErrNone) |
|
145 { |
|
146 INFO_PRINTF2(_L("Failing: SISUninstallPsyL returned %d\n"), err); |
|
147 SetTestStepResult(EFail); |
|
148 } |
|
149 iExpectedEvent = EPosModulesEventModuleRemoved; |
|
150 INFO_PRINTF1(_L("Wait for EPosModulesEventModuleRemoved event\n")); |
|
151 // Wait for event |
|
152 DoEventHandlingL(); |
|
153 //////////////////////////////////// |
|
154 #endif // not winscw |
|
155 |
|
156 INFO_PRINTF1(_L("Wait for second NotifyPositionUpdate() request to complete\n")); |
|
157 User::WaitForRequest(status); |
|
158 |
|
159 INFO_PRINTF2(_L("NotifyPositionUpdate() request completed with %d\n"), status.Int()); |
|
160 |
|
161 if(status != KErrNone) |
|
162 { |
|
163 INFO_PRINTF1(_L("Failing: On emulator NotifyPositionUpdate expected to completed with KErrNone\n")); |
|
164 SetTestStepResult(EFail); |
|
165 } |
|
166 #ifdef __WINSCW__ |
|
167 VerifyPositionFromL(positionInfo, iUidInstallableTrackingPsy); |
|
168 // make sure the psy is unloaded before trying to uninstall it on the emulator |
|
169 CleanupStack::PopAndDestroy(&positioner); |
|
170 CleanupStack::PopAndDestroy(&posServer); |
|
171 // Emulator will lock the psy plugin dll for a period of time when we can't uninstall it: |
|
172 User::After(30000000); |
|
173 // cleanup - uninstall the psy: |
|
174 err = SISUninstallPsyL(TUid::Uid(appId)); |
|
175 if(err != KErrNone) |
|
176 { |
|
177 INFO_PRINTF2(_L("Failing: SISUninstallPsyL returned %d\n"), err); |
|
178 SetTestStepResult(EFail); |
|
179 } |
|
180 #else // on arm the request should come from the ROM-based psy |
|
181 INFO_PRINTF1(_L("Verify the update came from the ROM-based PSY\n")); |
|
182 VerifyPositionFromL(positionInfo, iUidDelayedResponsePsy); |
|
183 INFO_PRINTF1(_L("Verify the uninstalled PSY is unloaded\n")); |
|
184 VerifyPsyUnloadedL(iUidInstallableTrackingPsy); |
|
185 CleanupStack::PopAndDestroy(&positioner); |
|
186 CleanupStack::PopAndDestroy(&posServer); |
|
187 #endif |
|
188 |
|
189 |
|
190 |
|
191 db->RemoveObserver(); |
|
192 CleanupStack::PopAndDestroy(db); |
|
193 |
|
194 } |
|
195 |
|
196 TInt CT_LbsClientStepFallbackUninstall::SISUninstallPsyL(const TUid& appId) |
|
197 { |
|
198 CUISisAdaptor* ui = CUISisAdaptor::NewLC(Logger()); |
|
199 |
|
200 TInt err = Swi::Launcher::Uninstall(*ui, appId); |
|
201 |
|
202 CleanupStack::PopAndDestroy(ui); |
|
203 |
|
204 INFO_PRINTF2(_L("Launcher::UnInstall returned %d\n"), err); |
|
205 |
|
206 return err; |
|
207 } |
|
208 |
|
209 TInt CT_LbsClientStepFallbackUninstall::SISInstallPsyL(const TDesC& aSisPath) |
|
210 { |
|
211 CUISisAdaptor *ui = CUISisAdaptor::NewLC(Logger()); |
|
212 CInstallPrefs* prefs = CInstallPrefs::NewLC(); |
|
213 |
|
214 TInt err = Swi::Launcher::Install(*ui, aSisPath, *prefs); |
|
215 |
|
216 CleanupStack::PopAndDestroy(prefs); |
|
217 CleanupStack::PopAndDestroy(ui); |
|
218 |
|
219 INFO_PRINTF2(_L("Launcher::Install returned %d\n"), err); |
|
220 |
|
221 return err; |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------- |
|
225 // CT_LbsClientStepFallbackUninstall::DoEventHandlingL |
|
226 // |
|
227 // --------------------------------------------------------- |
|
228 // |
|
229 void CT_LbsClientStepFallbackUninstall::DoEventHandlingL() |
|
230 { |
|
231 CActiveScheduler::Start(); |
|
232 CheckErrorL(); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------- |
|
236 // CT_LbsClientStepFallbackUninstall::CheckErrorL |
|
237 // |
|
238 // --------------------------------------------------------- |
|
239 // |
|
240 void CT_LbsClientStepFallbackUninstall::CheckErrorL() |
|
241 { |
|
242 if (iError) |
|
243 { |
|
244 LogErrorAndLeaveL(iErrorText); |
|
245 } |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------- |
|
249 // CT_LbsClientStepFallbackUninstall::HandleDatabaseChangeL |
|
250 // |
|
251 // --------------------------------------------------------- |
|
252 void CT_LbsClientStepFallbackUninstall::HandleSettingsChangeL(TPosModulesEvent aModuleEvent) |
|
253 { |
|
254 INFO_PRINTF2(_L("Event received %d\n"), aModuleEvent); |
|
255 CActiveScheduler::Stop(); |
|
256 if (aModuleEvent.iType != iExpectedEvent) |
|
257 { |
|
258 INFO_PRINTF2(_L("Unexpected Event received %d\n"), aModuleEvent); |
|
259 SetTestStepResult(EFail); |
|
260 } |
|
261 } |
|
262 |