|
1 /* |
|
2 * Copyright (c) 2008-2009 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 * Example CTestStep derived implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 @test |
|
24 */ |
|
25 #include "ctpositionerteststep.h" |
|
26 #include "ctlbstestsuitedefs.h" |
|
27 #include <lbsareainfo.h> |
|
28 #include <lbspositioninfo.h> |
|
29 |
|
30 CPositionerTestStep::~CPositionerTestStep() |
|
31 /** |
|
32 * Destructor |
|
33 */ |
|
34 { |
|
35 } |
|
36 |
|
37 CPositionerTestStep::CPositionerTestStep() |
|
38 /** |
|
39 * Constructor |
|
40 */ |
|
41 { |
|
42 SetTestStepName(KPositionerTestStep); |
|
43 } |
|
44 |
|
45 TVerdict CPositionerTestStep::doTestStepPreambleL() |
|
46 /** |
|
47 * @return - TVerdict code |
|
48 * Override of base class virtual |
|
49 */ |
|
50 { |
|
51 |
|
52 CTe_TestSuiteStepBase::doTestStepPreambleL(); |
|
53 SetTestStepResult(EPass); |
|
54 return TestStepResult(); |
|
55 } |
|
56 |
|
57 |
|
58 TVerdict CPositionerTestStep::doTestStepL() |
|
59 /** |
|
60 * @return - TVerdict code |
|
61 * Override of base class pure virtual |
|
62 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
63 * not leave. That being the case, the current test result value will be EPass. |
|
64 */ |
|
65 { |
|
66 |
|
67 _LIT(KTestName, "CPositionerTestStep::doTestStepL()"); |
|
68 INFO_PRINTF1(KTestName); |
|
69 |
|
70 if (TestStepResult()==EPass) |
|
71 { |
|
72 TInt testIndex = KErrNotFound; |
|
73 if(!GetIntFromConfig(ConfigSection(),KTestCaseIdInt,testIndex)) |
|
74 { |
|
75 User::Leave(KErrNotFound); |
|
76 } |
|
77 _LIT(KTestName, "Call test by index"); |
|
78 INFO_PRINTF1(KTestName); |
|
79 TestByIndexL(testIndex); |
|
80 } |
|
81 return TestStepResult(); |
|
82 } |
|
83 |
|
84 void CPositionerTestStep::TestByIndexL(TInt aIndex) |
|
85 { |
|
86 switch (aIndex) |
|
87 { |
|
88 case 1: |
|
89 _LIT(KTestName1, "LBS Full ROM Variant2 - Location Monitor startup/closedown "); |
|
90 INFO_PRINTF1(KTestName1); |
|
91 TdVariant2_FullRom_Check_LocMonitor_PersistentL(); |
|
92 break; |
|
93 case 2: |
|
94 _LIT(KTestName2, "LBS StandAlonePrivacy ROM Variant2 - Location Monitor startup/closedown"); |
|
95 INFO_PRINTF1(KTestName2); |
|
96 TdVariant2_StandAlonePrivacyRom_Check_LocMonitor_TransientL(); |
|
97 break; |
|
98 |
|
99 default: |
|
100 _LIT(KTestName10, "This test step doesn't exist"); |
|
101 INFO_PRINTF1(KTestName10); |
|
102 SetTestStepResult(EFail); |
|
103 break; |
|
104 |
|
105 } |
|
106 } |
|
107 |
|
108 |
|
109 TVerdict CPositionerTestStep::TdVariant2_StandAlonePrivacyRom_Check_LocMonitor_TransientL() |
|
110 { |
|
111 |
|
112 // Check if the location monitor process is transient in |
|
113 // the standalone privacy mode |
|
114 //_LIT(KLocMonitorExeName, "\\sys\\bin\\locationmonitor.exe"); |
|
115 |
|
116 // Validate that the location monitor is not started by the root |
|
117 // in this configuration |
|
118 _LIT(KLocMonitorServerName, "locationmonitor.exe"); |
|
119 TFindServer findServer(KLocMonitorServerName); |
|
120 TInt err; |
|
121 TFullName name; |
|
122 err = findServer.Next(name); |
|
123 |
|
124 if ((err==KErrNone)||(err==KErrAlreadyExists)) |
|
125 { |
|
126 _LIT(KFailLog, "Location monitor process started by root - so test case failed"); |
|
127 ERR_PRINTF1(KFailLog); |
|
128 SetTestStepResult(EFail); |
|
129 } |
|
130 else |
|
131 { |
|
132 |
|
133 _LIT(KPassInfoLog, "Location Monitor NOT started by the root process"); |
|
134 INFO_PRINTF1(KPassInfoLog); |
|
135 |
|
136 RPositionServer server; |
|
137 User::LeaveIfError(server.Connect()); |
|
138 CleanupClosePushL(server); |
|
139 |
|
140 User::After(100000); |
|
141 |
|
142 _LIT(KTest, "Session with epos location server opened successfully"); |
|
143 INFO_PRINTF1(KTest); |
|
144 |
|
145 RPositioner positioner; |
|
146 TInt err = positioner.Open(server); |
|
147 |
|
148 if(KErrNone != err) |
|
149 { |
|
150 ERR_PRINTF1(KFailedOpenPositioner); |
|
151 SetTestStepResult(EFail); |
|
152 CleanupStack::PopAndDestroy(&server); |
|
153 return TestStepResult(); |
|
154 } |
|
155 |
|
156 CleanupClosePushL(positioner); |
|
157 _LIT(KTest2, "SubSession with epos location server opened successfully"); |
|
158 INFO_PRINTF1(KTest2); |
|
159 |
|
160 // Validate that the location monitor gets started up when |
|
161 // a client opens a session with the EPos location server. |
|
162 _LIT(KLocMonitorServerName, "locationmonitor.exe"); |
|
163 TFindServer findServer2(KLocMonitorServerName); |
|
164 TFullName name2; |
|
165 err = -1; // assign the default value of -1 [KErrNotFound] |
|
166 err = findServer2.Next(name2); |
|
167 if ((err!=KErrNone)&&(err!=KErrAlreadyExists)) |
|
168 { |
|
169 _LIT(KFailInfoLog, "Location Monitor NOT started even after a client connects to the epos location server"); |
|
170 ERR_PRINTF1(KFailInfoLog); |
|
171 SetTestStepResult(EFail); |
|
172 return TestStepResult(); |
|
173 } |
|
174 |
|
175 if ((err==KErrNone)||(err==KErrAlreadyExists)) |
|
176 { |
|
177 _LIT(KPassInfoLog, "Location Monitor started after a client connects to the epos location server"); |
|
178 INFO_PRINTF1(KPassInfoLog); |
|
179 } |
|
180 |
|
181 CleanupStack::PopAndDestroy(2, &server); |
|
182 User::After(15000000); |
|
183 |
|
184 //Validate that the location monitor no longer exists after the client |
|
185 //closes the handle with the location server |
|
186 TFindServer findServer3(KLocMonitorServerName); |
|
187 TFullName name3; |
|
188 err = 0; // assign the default value of 0 [KErrNone] |
|
189 err = findServer3.Next(name3); |
|
190 if ((err==KErrNone)||(err==KErrAlreadyExists)) |
|
191 { |
|
192 _LIT(KFailInfoLog, "Location Monitor NOT shut down even after all the clients disconnect from the epos location server"); |
|
193 ERR_PRINTF1(KFailInfoLog); |
|
194 SetTestStepResult(EFail); |
|
195 return TestStepResult(); |
|
196 } |
|
197 |
|
198 } |
|
199 |
|
200 return TestStepResult(); |
|
201 |
|
202 } |
|
203 |
|
204 TVerdict CPositionerTestStep::TdVariant2_FullRom_Check_LocMonitor_PersistentL() |
|
205 { |
|
206 |
|
207 // The root process should have already been started before entering |
|
208 // this function [by start lbs test step] |
|
209 //_LIT(KLocMonitorExeName, "\\sys\\bin\\locationmonitor.exe"); |
|
210 _LIT(KLocMonitorServerName, "locationmonitor.exe"); |
|
211 |
|
212 // Check if the location monitor process is running |
|
213 TFindServer findServer(KLocMonitorServerName); |
|
214 TInt err; |
|
215 TFullName name; |
|
216 err = findServer.Next(name); |
|
217 |
|
218 if ((err!=KErrNone)&&(err!=KErrAlreadyExists)) |
|
219 { |
|
220 _LIT(KFailLog, "Location monitor process not started by root - so test case failed"); |
|
221 ERR_PRINTF1(KFailLog); |
|
222 SetTestStepResult(EFail); |
|
223 } |
|
224 else |
|
225 { |
|
226 |
|
227 _LIT(KPassInfoLog, "Location Monitor started by the root process"); |
|
228 INFO_PRINTF1(KPassInfoLog); |
|
229 |
|
230 RPositionServer server; |
|
231 User::LeaveIfError(server.Connect()); |
|
232 CleanupClosePushL(server); |
|
233 |
|
234 _LIT(KTest, "Session with epos location server opened successfully"); |
|
235 INFO_PRINTF1(KTest); |
|
236 |
|
237 RPositioner positioner; |
|
238 TInt err = positioner.Open(server); |
|
239 |
|
240 if(KErrNone != err) |
|
241 { |
|
242 ERR_PRINTF1(KFailedOpenPositioner); |
|
243 SetTestStepResult(EFail); |
|
244 CleanupStack::PopAndDestroy(&server); |
|
245 return TestStepResult(); |
|
246 } |
|
247 |
|
248 _LIT(KTest2, "SubSession with epos location server opened successfully"); |
|
249 INFO_PRINTF1(KTest2); |
|
250 |
|
251 //CleanupClosePushL(positioner); |
|
252 positioner.Close(); |
|
253 CleanupStack::PopAndDestroy(&server); |
|
254 User::After(5000); |
|
255 |
|
256 // Check if the process exists even after the client |
|
257 // closes the handle with the location server |
|
258 |
|
259 _LIT(KTest3, "Epos location server closed down as the clients are disconnected"); |
|
260 INFO_PRINTF1(KTest3); |
|
261 |
|
262 _LIT(KLocMonitorServerName, "locationmonitor.exe"); |
|
263 TFindServer findServer2(KLocMonitorServerName); |
|
264 TFullName name2; |
|
265 err = -1; // assign the default value of -1 [KErrNotFound] |
|
266 err = findServer2.Next(name2); |
|
267 if ((err!=KErrNone)&&(err!=KErrAlreadyExists)) |
|
268 { |
|
269 _LIT(KPassInfoLog2, "Location Monitor dies when the epos location server is closed down"); |
|
270 ERR_PRINTF1(KPassInfoLog2); |
|
271 SetTestStepResult(EFail); |
|
272 return TestStepResult(); |
|
273 } |
|
274 _LIT(KPassInfoLog2, "Location Monitor exists even after the location server is closed down"); |
|
275 INFO_PRINTF1(KPassInfoLog2); |
|
276 } |
|
277 return TestStepResult(); |
|
278 |
|
279 } |
|
280 |
|
281 |
|
282 TVerdict CPositionerTestStep::doTestStepPostambleL() |
|
283 /** |
|
284 * @return - TVerdict code |
|
285 * Override of base class virtual |
|
286 */ |
|
287 { |
|
288 return TestStepResult(); |
|
289 } |
|
290 |
|
291 |