748
|
1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
872
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
748
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
748
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file ctlbsclientstep_openclose.cpp
|
|
15 |
// This is the class implementation for the Server Open Close Tests
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "ctlbsclientstepopenclose.h"
|
|
20 |
|
|
21 |
#include <lbs.h>
|
|
22 |
|
|
23 |
|
|
24 |
/**
|
|
25 |
* Destructor
|
|
26 |
*/
|
|
27 |
CT_LbsClientStep_OpenClose::~CT_LbsClientStep_OpenClose()
|
|
28 |
{
|
|
29 |
}
|
|
30 |
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Constructor
|
|
34 |
*/
|
|
35 |
CT_LbsClientStep_OpenClose::CT_LbsClientStep_OpenClose(CT_LbsClientServer& aParent) : CT_LbsClientStep(aParent)
|
|
36 |
{
|
|
37 |
SetTestStepName(KLbsClientStep_OpenClose);
|
|
38 |
}
|
|
39 |
|
|
40 |
|
|
41 |
/**
|
|
42 |
Static Constructor
|
|
43 |
*/
|
|
44 |
CT_LbsClientStep_OpenClose* CT_LbsClientStep_OpenClose::New(CT_LbsClientServer& aParent)
|
|
45 |
{
|
|
46 |
return new CT_LbsClientStep_OpenClose(aParent);
|
|
47 |
// Note the lack of ELeave.
|
|
48 |
// This means that having insufficient memory will return NULL;
|
|
49 |
}
|
|
50 |
|
|
51 |
/**
|
|
52 |
* @return - TVerdict code
|
|
53 |
* Override of base class pure virtual
|
|
54 |
* Our implementation only gets called if the base class doTestStepPreambleL() did
|
|
55 |
* not leave. That being the case, the current test result value will be EPass.
|
|
56 |
*/
|
|
57 |
TVerdict CT_LbsClientStep_OpenClose::doTestStepL()
|
|
58 |
{
|
|
59 |
// Generic test step used to test the LBS Client server open and close APIs.
|
|
60 |
INFO_PRINTF1(_L(">>CT_LbsClientStep_OpenClose::doTestStepL()"));
|
|
61 |
|
|
62 |
if (TestStepResult() == EPass)
|
|
63 |
{
|
|
64 |
|
|
65 |
TUint howManyModules = 0;
|
|
66 |
TPositionModuleInfo myModuleInfo;
|
|
67 |
TInt err = KErrNone;
|
|
68 |
TPositionCriteria criteria;
|
|
69 |
|
|
70 |
|
|
71 |
// Carryout common test action.
|
|
72 |
err = iServer.Connect(); // Function under test.
|
|
73 |
if (KErrNone == err)
|
|
74 |
{
|
|
75 |
INFO_PRINTF1(_L("server opened"));
|
|
76 |
|
|
77 |
|
|
78 |
// Carryout unquie test actions.
|
|
79 |
TInt testCaseId;
|
|
80 |
if (GetIntFromConfig(ConfigSection(), KTestCaseId, testCaseId))
|
|
81 |
{
|
|
82 |
switch (testCaseId)
|
|
83 |
{
|
|
84 |
// Test case LBS-OpenClose-0001
|
|
85 |
case 1:
|
|
86 |
{
|
|
87 |
TPositionModuleId serverDefaultModuleId;
|
|
88 |
User::LeaveIfError(iServer.GetDefaultModuleId(serverDefaultModuleId));
|
|
89 |
err = iPositioner.Open(iServer, serverDefaultModuleId);
|
|
90 |
if(err != KErrNone)
|
|
91 |
{
|
|
92 |
INFO_PRINTF1(_L("** SubSession Failed to open **"));
|
|
93 |
SetTestStepResult(EFail);
|
|
94 |
}
|
|
95 |
}
|
|
96 |
break;
|
|
97 |
|
|
98 |
// Test case LBS-OpenClose-0002
|
|
99 |
case 2:
|
|
100 |
{
|
|
101 |
User::LeaveIfError(iServer.GetNumModules(howManyModules));
|
|
102 |
User::LeaveIfError(iServer.GetModuleInfoByIndex(howManyModules-1, myModuleInfo));
|
|
103 |
err = iPositioner.Open(iServer, myModuleInfo.ModuleId());
|
|
104 |
if(err != KErrNone)
|
|
105 |
{
|
|
106 |
INFO_PRINTF1(_L("** SubSession Failed to open **"));
|
|
107 |
SetTestStepResult(EFail);
|
|
108 |
}
|
|
109 |
}
|
|
110 |
break;
|
|
111 |
|
|
112 |
// Test case LBS-OpenClose-0003
|
|
113 |
case 3:
|
|
114 |
{
|
|
115 |
// PassInNullUID
|
|
116 |
err = iPositioner.Open(iServer, KPositionNullModuleId );
|
|
117 |
if (KErrNotFound == err)
|
|
118 |
{
|
|
119 |
INFO_PRINTF1(_L("** SubSession failed to open: Negative Test Successful **"));
|
|
120 |
}
|
|
121 |
else
|
|
122 |
{
|
|
123 |
INFO_PRINTF1(_L("** SubSession Opened, test failed **"));
|
|
124 |
SetTestStepResult(EFail);
|
|
125 |
}
|
|
126 |
}
|
|
127 |
break;
|
|
128 |
|
|
129 |
// Test case LBS-OpenCloseExtend-0001
|
|
130 |
case 11:
|
|
131 |
{
|
|
132 |
criteria.AddRequiredCapabilities(TPositionModuleInfo::ECapabilitySatellite);
|
|
133 |
err = iPositioner.Open(iServer, criteria);
|
|
134 |
if(err != KErrNone)
|
|
135 |
{
|
|
136 |
INFO_PRINTF1(_L("** SubSession Failed to open **"));
|
|
137 |
SetTestStepResult(EFail);
|
|
138 |
}
|
|
139 |
}
|
|
140 |
break;
|
|
141 |
|
|
142 |
// Test case LBS-OpenCloseExtend-0002
|
|
143 |
case 12:
|
|
144 |
{
|
|
145 |
// Set capabilities not supported by the module:
|
|
146 |
criteria.AddRequiredCapabilities(TPositionModuleInfo::ECapabilityAddress);
|
|
147 |
err = iPositioner.Open(iServer, criteria);
|
|
148 |
if (KErrNotFound == err)
|
|
149 |
{
|
|
150 |
INFO_PRINTF1(_L("** SubSession failed to open: Negative Test Successful **"));
|
|
151 |
}
|
|
152 |
else
|
|
153 |
{
|
|
154 |
INFO_PRINTF1(_L("** SubSession Opened, test failed **"));
|
|
155 |
SetTestStepResult(EFail);
|
|
156 |
}
|
|
157 |
}
|
|
158 |
break;
|
|
159 |
|
|
160 |
// Test case LBS-OpenCloseMultiple-0001
|
|
161 |
case 20:
|
|
162 |
{
|
|
163 |
User::LeaveIfError(iPositioner.Open(iServer));
|
|
164 |
RPositioner positioner2;
|
|
165 |
err = positioner2.Open(iServer);
|
|
166 |
if(err != KErrNone)
|
|
167 |
{
|
|
168 |
INFO_PRINTF1(_L("** SubSession Failed to open **"));
|
|
169 |
SetTestStepResult(EFail);
|
|
170 |
}
|
|
171 |
positioner2.Close();
|
|
172 |
}
|
|
173 |
break;
|
|
174 |
|
|
175 |
// Test case LBS-ReOpen-0001
|
|
176 |
case 30:
|
|
177 |
{
|
|
178 |
User::LeaveIfError(iPositioner.Open(iServer));
|
|
179 |
User::LeaveIfError(iPositioner.Open(iServer));
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
// Test case LBS-OpenClose-0041
|
|
183 |
case 41:
|
|
184 |
{
|
|
185 |
err = iServer.CancelRequest(EPositionerNotifyPositionUpdate);
|
|
186 |
if(err != KErrNotFound)
|
|
187 |
{
|
|
188 |
INFO_PRINTF2(_L("** Failed to return KErrnotFound, instead returned %d**"),err);
|
|
189 |
SetTestStepResult(EFail);
|
|
190 |
}
|
|
191 |
}
|
|
192 |
break;
|
|
193 |
|
|
194 |
// Test case LBS-OpenClose-0042
|
|
195 |
case 42:
|
|
196 |
{
|
|
197 |
err = iPositioner.Open(iServer);
|
|
198 |
if(err != KErrNone)
|
|
199 |
{
|
|
200 |
INFO_PRINTF1(_L("** SubSession Failed to open **"));
|
|
201 |
SetTestStepResult(EFail);
|
|
202 |
}
|
|
203 |
|
|
204 |
err = 0; // reset Err
|
|
205 |
|
|
206 |
err = iPositioner.CancelRequest(EPositionerNotifyPositionUpdate);
|
|
207 |
if(err != KErrNotFound)
|
|
208 |
{
|
|
209 |
INFO_PRINTF2(_L("** Failed to return KErrnotFound, instead returned %d**"),err);
|
|
210 |
SetTestStepResult(EFail);
|
|
211 |
}
|
|
212 |
}
|
|
213 |
break;
|
|
214 |
|
|
215 |
// Test case LBS-OpenClose-0043
|
|
216 |
case 43:
|
|
217 |
{
|
|
218 |
err = iPositioner.Open(iServer);
|
|
219 |
if(err != KErrNone)
|
|
220 |
{
|
|
221 |
INFO_PRINTF1(_L("** SubSession Failed to open **"));
|
|
222 |
SetTestStepResult(EFail);
|
|
223 |
}
|
|
224 |
|
|
225 |
err = 0; // reset Err
|
|
226 |
|
|
227 |
err = iPositioner.CancelRequest(EPositionerGetLastKnownPosition);
|
|
228 |
if(err != KErrNotFound)
|
|
229 |
{
|
|
230 |
INFO_PRINTF2(_L("** Failed to return KErrnotFound, instead returned %d**"),err);
|
|
231 |
SetTestStepResult(EFail);
|
|
232 |
}
|
|
233 |
}
|
|
234 |
break;
|
|
235 |
|
|
236 |
// Test case LBS-OpenClose-0044
|
|
237 |
case 44:
|
|
238 |
{
|
|
239 |
err = iServer.CancelRequest(EPositionServerNotifyModuleStatusEvent);
|
|
240 |
if(err != KErrNotFound)
|
|
241 |
{
|
|
242 |
INFO_PRINTF2(_L("** Failed to return KErrnotFound, instead returned %d**"),err);
|
|
243 |
SetTestStepResult(EFail);
|
|
244 |
}
|
|
245 |
}
|
|
246 |
break;
|
|
247 |
|
|
248 |
default:
|
|
249 |
User::Leave(KErrArgument);
|
|
250 |
break;
|
|
251 |
}
|
|
252 |
|
|
253 |
iPositioner.Close();
|
|
254 |
iServer.Close();
|
|
255 |
}
|
|
256 |
else
|
|
257 |
{
|
|
258 |
INFO_PRINTF1(_L("Bad Ini file"));
|
|
259 |
SetTestStepResult(EFail);
|
|
260 |
}
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
INFO_PRINTF1(_L("SubSession failed to open"));
|
|
265 |
SetTestStepResult(EFail);
|
|
266 |
}
|
|
267 |
|
|
268 |
}
|
|
269 |
|
|
270 |
INFO_PRINTF1(_L("<<CT_LbsClientStep_OpenClose::doTestStepL()"));
|
|
271 |
|
|
272 |
return TestStepResult();
|
|
273 |
}
|