|
1 // Copyright (c) 2005-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 #include "Te_SimPhBkSmartCardTest.h" |
|
17 |
|
18 CSimPhBkSmartCardTest::CSimPhBkSmartCardTest() |
|
19 { |
|
20 SetTestStepName(_L("SmartCardTest")); |
|
21 } |
|
22 |
|
23 TVerdict CSimPhBkSmartCardTest::doTestStepL() |
|
24 { |
|
25 INFO_PRINTF1(_L("BeginPhBkSmartCardTest")); |
|
26 |
|
27 CreateConfigFileL(_L("c:\\config3.txt")); |
|
28 SetTestNumberL(10); |
|
29 |
|
30 RMobilePhone::TAID smartCardAppID; |
|
31 TUint count,smartCardIndex; |
|
32 TRequestStatus reqStatus; |
|
33 |
|
34 INFO_PRINTF1(_L("")); |
|
35 INFO_PRINTF1(_L("SmartCard test")); |
|
36 TInt ret = iPhone.Open(iTelServer,KPhoneName); |
|
37 INFO_PRINTF2(_L("Result: %d"),ret); |
|
38 TESTL(ret == KErrNone); |
|
39 INFO_PRINTF1(_L("Opened phone object")); |
|
40 |
|
41 // EnumerateSmartCardApplications |
|
42 INFO_PRINTF1(_L("EnumerateSmartCardApplications test")); |
|
43 enum {KSmartCardApps=10}; |
|
44 iPhone.EnumerateSmartCardApplications(reqStatus, count); |
|
45 User::WaitForRequest(reqStatus); |
|
46 TESTL(count==KSmartCardApps); |
|
47 CHECKPOINTL(reqStatus, KErrNone, CHP_APPS_CASE("O.1")); |
|
48 |
|
49 // GetSmartCardApplicationInfo |
|
50 INFO_PRINTF1(_L("GetSmartCardApplicationInfo test")); |
|
51 // Structured data to read in application info |
|
52 RMobilePhone::TSmartCardApplicationInfoV5 smartCardAppInfo; |
|
53 RMobilePhone::TSmartCardApplicationInfoV5Pckg smartCardAppInfoPckg(smartCardAppInfo); |
|
54 |
|
55 // first application |
|
56 smartCardIndex=0; |
|
57 iPhone.GetSmartCardApplicationInfo(reqStatus, smartCardIndex, smartCardAppInfoPckg); |
|
58 User::WaitForRequest(reqStatus); |
|
59 CHECKPOINTL(reqStatus, KErrNone, CHP_APPS_CASE("O.2")); |
|
60 // Test the contents of structured data |
|
61 TESTL(smartCardAppInfo.iAID.Compare(_L8("SCApp1")) == KErrNone); |
|
62 TESTL(smartCardAppInfo.iLabel.Compare(_L8("SmartCardApp1")) == KErrNone); |
|
63 |
|
64 // fifth application - USim Application |
|
65 smartCardIndex=4; |
|
66 iPhone.GetSmartCardApplicationInfo(reqStatus, smartCardIndex, smartCardAppInfoPckg); |
|
67 User::WaitForRequest(reqStatus); |
|
68 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.3")); |
|
69 TESTL(smartCardAppInfo.iAID.Compare(_L8("USimApp1")) == KErrNone); |
|
70 TESTL(smartCardAppInfo.iLabel.Compare(_L8("USimApplication1")) == KErrNone); |
|
71 |
|
72 // last application in array |
|
73 smartCardIndex=9; |
|
74 iPhone.GetSmartCardApplicationInfo(reqStatus, smartCardIndex, smartCardAppInfoPckg); |
|
75 User::WaitForRequest(reqStatus); |
|
76 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.4")); |
|
77 TESTL(smartCardAppInfo.iAID.Compare(_L8("SCAppThatIsTooLo")) == KErrNone); |
|
78 TESTL(smartCardAppInfo.iLabel.Compare(_L8("SmartCardAppThatIsMuchMuchMuchTo")) == KErrNone); |
|
79 |
|
80 // Out of range application |
|
81 smartCardIndex=10; |
|
82 iPhone.GetSmartCardApplicationInfo(reqStatus, smartCardIndex, smartCardAppInfoPckg); |
|
83 User::WaitForRequest(reqStatus); |
|
84 CHECKPOINT_EXL(reqStatus==KErrNotFound, CHP_APPS_CASE("O.5")); |
|
85 |
|
86 // NotifySmartCardApplicationInfoChange |
|
87 /* Activate application in order to terminate it later */ |
|
88 smartCardAppID=_L8("SCApp2"); |
|
89 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
90 User::WaitForRequest(reqStatus); |
|
91 TESTL(reqStatus==KErrNone); |
|
92 |
|
93 INFO_PRINTF1(_L("NotifySmartCardApplicationInfoChange test")); |
|
94 RMobilePhone::TSmartCardApplicationEvent event; |
|
95 /* Second application is terminated with an event in config.txt |
|
96 This is time dependent */ |
|
97 iPhone.NotifySmartCardApplicationInfoChange(reqStatus, smartCardAppID, event); |
|
98 User::WaitForRequest(reqStatus); |
|
99 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.6")); |
|
100 TESTL(smartCardAppID==_L8("SCApp2")); |
|
101 TESTL(event==RMobilePhone::EScApplicationTerminated); |
|
102 |
|
103 // First application will be activated |
|
104 smartCardAppID=_L8("SCApp1"); |
|
105 iPhone.NotifySmartCardApplicationInfoChange(reqStatus, smartCardAppID, event); |
|
106 User::WaitForRequest(reqStatus); |
|
107 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.7")); |
|
108 TESTL(smartCardAppID==_L8("SCApp1")); |
|
109 TESTL(event==RMobilePhone::EScApplicationActivated); |
|
110 |
|
111 // Notification for activation on already activated first application |
|
112 iPhone.NotifySmartCardApplicationInfoChange(reqStatus, smartCardAppID, event); |
|
113 User::WaitForRequest(reqStatus); |
|
114 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.8")); |
|
115 TESTL(smartCardAppID==_L8("SCApp1")); |
|
116 TESTL(event==RMobilePhone::EScApplicationActivated); |
|
117 |
|
118 // Terminate first application |
|
119 smartCardAppID=_L8("SCApp1"); |
|
120 iPhone.NotifySmartCardApplicationInfoChange(reqStatus, smartCardAppID, event); |
|
121 User::WaitForRequest(reqStatus); // Wait for notification of change |
|
122 CHECKPOINTL(reqStatus, KErrNone, CHP_APPS_CASE("O.9")); |
|
123 TESTL(smartCardAppID==_L8("SCApp1")); |
|
124 TESTL(event==RMobilePhone::EScApplicationTerminated); |
|
125 |
|
126 // GetCurrentActiveUSIMApplication |
|
127 smartCardAppID=_L8(""); |
|
128 INFO_PRINTF1(_L("GetCurrentActiveUSIMApplication test")); |
|
129 // There should be no active application at this point |
|
130 iPhone.GetCurrentActiveUSimApplication(reqStatus, smartCardAppID); |
|
131 User::WaitForRequest(reqStatus); // Wait for notification of change |
|
132 CHECKPOINTL(reqStatus, KErrMMEtelScApplicationNotActive, CHP_APPS_CASE("O.10")); |
|
133 TESTL(smartCardAppID==_L8("")); |
|
134 |
|
135 // Wait for event to activate second application |
|
136 smartCardAppID=_L8("USimApp2"); |
|
137 iPhone.NotifySmartCardApplicationInfoChange(reqStatus, smartCardAppID, event); |
|
138 User::WaitForRequest(reqStatus); // Wait for notification of change |
|
139 CHECKPOINTL(reqStatus, KErrNone, CHP_APPS_CASE("O.11")); |
|
140 TESTL(smartCardAppID==_L8("USimApp2")); |
|
141 TESTL(event==RMobilePhone::EScApplicationActivated); |
|
142 |
|
143 // There should be an active application at this point |
|
144 iPhone.GetCurrentActiveUSimApplication(reqStatus, smartCardAppID); |
|
145 User::WaitForRequest(reqStatus); // Wait for notification of change |
|
146 CHECKPOINTL(reqStatus, KErrNone, CHP_APPS_CASE("O.12")); |
|
147 TESTL(smartCardAppID==_L8("USimApp2")); |
|
148 |
|
149 // At this point there should be one active application, the USIM app, USimApp2 |
|
150 // SetSmartCardApplicationStatus |
|
151 INFO_PRINTF1(_L("SetSmartCardApplicationStatus test")); |
|
152 // Try and activate a second USIM application |
|
153 smartCardAppID=_L8("USimApp1"); |
|
154 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
155 User::WaitForRequest(reqStatus); |
|
156 CHECKPOINT_EXL(reqStatus==KErrAlreadyExists, CHP_APPS_CASE("O.13")); |
|
157 |
|
158 // Set other smart card apps to active |
|
159 smartCardAppID=_L8("SCApp3"); |
|
160 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
161 User::WaitForRequest(reqStatus); |
|
162 TESTL(reqStatus==KErrNone); |
|
163 |
|
164 // Set third smart card app to active |
|
165 smartCardAppID=_L8("SCApp4"); |
|
166 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
167 User::WaitForRequest(reqStatus); |
|
168 TESTL(reqStatus==KErrNone); |
|
169 |
|
170 // Set fourth smart card app to active |
|
171 smartCardAppID=_L8("SCApp5"); |
|
172 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
173 User::WaitForRequest(reqStatus); |
|
174 TESTL(reqStatus==KErrNone); |
|
175 |
|
176 /* Set fifth smart card app to active |
|
177 This should return with error code as it surpasses the max set in the config file */ |
|
178 smartCardAppID=_L8("SCApp6"); |
|
179 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
180 User::WaitForRequest(reqStatus); |
|
181 CHECKPOINT_EXL(reqStatus==KErrMMEtelScMaxApplicationsActive, CHP_APPS_CASE("O.14")); |
|
182 |
|
183 /* Attempt to status of a AID that does not exist */ |
|
184 smartCardAppID=_L8("NotFound"); |
|
185 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScTerminate); |
|
186 User::WaitForRequest(reqStatus); |
|
187 CHECKPOINT_EXL(reqStatus==KErrNotFound, CHP_APPS_CASE("O.15")); |
|
188 |
|
189 smartCardAppID=_L8("NotFound"); |
|
190 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
191 User::WaitForRequest(reqStatus); |
|
192 CHECKPOINT_EXL(reqStatus==KErrNotFound, CHP_APPS_CASE("O.16")); |
|
193 |
|
194 // Set fourth smart card app to active when already active |
|
195 smartCardAppID=_L8("SCApp5"); |
|
196 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
197 User::WaitForRequest(reqStatus); |
|
198 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.17")); |
|
199 |
|
200 INFO_PRINTF1(_L("GetScFileInfo test")); |
|
201 /* Attempt to get info on a file from an application that is not found */ |
|
202 RMobilePhone::TScFilePath filePath; |
|
203 RMobilePhone::TScFileInfoV5 scFileInfo; |
|
204 RMobilePhone::TScFileInfoV5Pckg scFileInfoPckg(scFileInfo); |
|
205 |
|
206 filePath.iAID = _L8("App2"); |
|
207 filePath.iPath = _L8("7FFF6F3C"); |
|
208 iPhone.GetScFileInfo(reqStatus, filePath, scFileInfoPckg); |
|
209 User::WaitForRequest(reqStatus); |
|
210 CHECKPOINT_EXL(reqStatus==KErrNotFound, CHP_APPS_CASE("O.18")); |
|
211 |
|
212 /* Attempt to get info on a file from an application that has not started */ |
|
213 filePath.iAID = _L8("SCApp1"); |
|
214 filePath.iPath = _L8("7FFF6F3C"); |
|
215 iPhone.GetScFileInfo(reqStatus, filePath, scFileInfoPckg); |
|
216 User::WaitForRequest(reqStatus); |
|
217 CHECKPOINT_EXL(reqStatus==KErrMMEtelScApplicationNotActive, CHP_APPS_CASE("O.19")); |
|
218 |
|
219 /* Attempt to get info on a file from an application that has been terminated */ |
|
220 smartCardAppID=_L8("SCApp3"); |
|
221 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScTerminate); |
|
222 User::WaitForRequest(reqStatus); |
|
223 TESTL(reqStatus==KErrNone); |
|
224 |
|
225 filePath.iAID = _L8("SCApp3"); |
|
226 filePath.iPath = _L8("7FFF6F3C"); |
|
227 iPhone.GetScFileInfo(reqStatus, filePath, scFileInfoPckg); |
|
228 User::WaitForRequest(reqStatus); |
|
229 CHECKPOINT_EXL(reqStatus==KErrMMEtelScApplicationNotActive, CHP_APPS_CASE("O.20")); |
|
230 |
|
231 smartCardAppID=_L8("SCApp4"); |
|
232 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScTerminate); |
|
233 User::WaitForRequest(reqStatus); |
|
234 TESTL(reqStatus==KErrNone); |
|
235 |
|
236 smartCardAppID=_L8("SCApp5"); |
|
237 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScTerminate); |
|
238 User::WaitForRequest(reqStatus); |
|
239 TESTL(reqStatus==KErrNone); |
|
240 |
|
241 /* Attempt to set SCApp5 to inactive when it already is inactive */ |
|
242 smartCardAppID=_L8("SCApp5"); |
|
243 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScTerminate); |
|
244 User::WaitForRequest(reqStatus); |
|
245 CHECKPOINT_EXL(reqStatus==KErrMMEtelScApplicationNotActive, CHP_APPS_CASE("O.21")); |
|
246 |
|
247 smartCardAppID=_L8("USimApp2"); |
|
248 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScTerminate); |
|
249 User::WaitForRequest(reqStatus); |
|
250 TESTL(reqStatus==KErrNone); |
|
251 |
|
252 filePath.iAID = _L8("SCApp1"); |
|
253 filePath.iPath = _L8("7FFF6F3C"); |
|
254 smartCardAppID = _L8("SCApp1"); |
|
255 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
256 User::WaitForRequest(reqStatus); |
|
257 TESTL(reqStatus==KErrNone); |
|
258 |
|
259 /* Attempt to get info on a pre-configured Linear Fixed Record based file */ |
|
260 iPhone.GetScFileInfo(reqStatus, filePath, scFileInfoPckg); |
|
261 User::WaitForRequest(reqStatus); |
|
262 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.22")); |
|
263 TESTL(scFileInfo.iFileID == (0x6F3C)); |
|
264 TESTL(scFileInfo.iNumberRecords == 2); |
|
265 TESTL(scFileInfo.iRecordLength == 5); |
|
266 TESTL(scFileInfo.iType == RMobilePhone::ELinearFixed); |
|
267 TESTL(scFileInfo.iTotalLength == 10); |
|
268 |
|
269 /* Attempt to get info on a pre-configured Cyclical Record based file, testing same filename |
|
270 in different application */ |
|
271 filePath.iAID = _L8("SCApp2"); |
|
272 smartCardAppID = _L8("SCApp2"); |
|
273 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
274 User::WaitForRequest(reqStatus); |
|
275 TESTL(reqStatus==KErrNone); |
|
276 |
|
277 filePath.iAID = _L8("SCApp2"); |
|
278 iPhone.GetScFileInfo(reqStatus, filePath, scFileInfoPckg); |
|
279 User::WaitForRequest(reqStatus); |
|
280 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.23")); |
|
281 TESTL(scFileInfo.iFileID == (0x6F3C)); |
|
282 TESTL(scFileInfo.iNumberRecords == 1); |
|
283 TESTL(scFileInfo.iRecordLength == 5); |
|
284 TESTL(scFileInfo.iType == RMobilePhone::ECyclic); |
|
285 TESTL(scFileInfo.iTotalLength == 5); |
|
286 |
|
287 /* Attempt to get info on a pre-configured Transparent Record based file, testing same filename |
|
288 in different application */ |
|
289 smartCardAppID=_L8("SCApp4"); |
|
290 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
291 User::WaitForRequest(reqStatus); |
|
292 TESTL(reqStatus==KErrNone); |
|
293 |
|
294 filePath.iAID = _L8("SCApp4"); |
|
295 iPhone.GetScFileInfo(reqStatus, filePath, scFileInfoPckg); |
|
296 User::WaitForRequest(reqStatus); |
|
297 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.24")); |
|
298 TESTL(scFileInfo.iFileID == (0x6F3C)); |
|
299 TESTL(scFileInfo.iNumberRecords == 0); |
|
300 TESTL(scFileInfo.iRecordLength == 0); |
|
301 TESTL(scFileInfo.iType == RMobilePhone::ETransparent); |
|
302 TESTL(scFileInfo.iTotalLength == 10); |
|
303 |
|
304 /* Simple interaction test with smart card not owned by application */ |
|
305 filePath.iAID = _L8(""); |
|
306 filePath.iPath = _L8("3FFF6F3C"); |
|
307 iPhone.GetScFileInfo(reqStatus, filePath, scFileInfoPckg); |
|
308 User::WaitForRequest(reqStatus); |
|
309 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.25")); |
|
310 TESTL(scFileInfo.iFileID == (0x6F3C)); |
|
311 TESTL(scFileInfo.iNumberRecords == 1); |
|
312 TESTL(scFileInfo.iRecordLength == 5); |
|
313 TESTL(scFileInfo.iType == RMobilePhone::ELinearFixed); |
|
314 TESTL(scFileInfo.iTotalLength == 5); |
|
315 |
|
316 INFO_PRINTF1(_L("ReadSCFile test")); |
|
317 /* Test ReadSCFile on Linear Fixed file with specified iAID, iPath first record */ |
|
318 RMobilePhone::TScFilePathWithAccessOffsets offsets; |
|
319 TBuf8<25> readBuffer; |
|
320 TBuf8<4> testBuffer; // buffer too small for a record |
|
321 |
|
322 offsets.iAID = _L8("SCApp1"); |
|
323 offsets.iPath = _L8("7FFF6F3C"); |
|
324 offsets.iType = RMobilePhone::ELinearFixed; |
|
325 offsets.iCount = 1; // number of records to read |
|
326 offsets.iStartOffset = 1; |
|
327 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
328 User::WaitForRequest(reqStatus); |
|
329 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.26")); |
|
330 TESTL(readBuffer == _L8("HELLO")); |
|
331 |
|
332 /* Test ReadSCFile, second record */ |
|
333 offsets.iStartOffset = 2; |
|
334 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
335 User::WaitForRequest(reqStatus); |
|
336 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.27")); |
|
337 TESTL(readBuffer == _L8("WORLD")); |
|
338 |
|
339 /* Test ReadSCFile, out of range record */ |
|
340 offsets.iStartOffset = 0; |
|
341 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
342 User::WaitForRequest(reqStatus); |
|
343 TESTL(reqStatus == KErrMMEtelScRecordNotFound); |
|
344 |
|
345 /* Test ReadSCFile, out of range record */ |
|
346 offsets.iStartOffset = 10; |
|
347 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
348 User::WaitForRequest(reqStatus); |
|
349 CHECKPOINT_EXL(reqStatus==KErrMMEtelScRecordNotFound, CHP_APPS_CASE("O.28")); |
|
350 |
|
351 /* Test ReadSCFile, buffer too small */ |
|
352 offsets.iStartOffset = 1; |
|
353 iPhone.ReadScFile(reqStatus, offsets, testBuffer); |
|
354 User::WaitForRequest(reqStatus); |
|
355 CHECKPOINT_EXL(reqStatus==KErrOverflow, CHP_APPS_CASE("O.29")); |
|
356 |
|
357 /* Simple ReadScFile test with smart card not owned by application */ |
|
358 offsets.iAID = _L8(""); |
|
359 offsets.iPath = _L8("3FFF6F3C"); |
|
360 offsets.iCount = 1; // number of records to read |
|
361 offsets.iStartOffset = 1; |
|
362 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
363 User::WaitForRequest(reqStatus); |
|
364 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.30")); |
|
365 TESTL(readBuffer == _L8("HELLO")); |
|
366 |
|
367 /* Test ReadSCFile on Cyclical file with specified iAID but without application active */ |
|
368 offsets.iAID = _L8("SCApp3"); |
|
369 offsets.iType = RMobilePhone::ECyclic; |
|
370 offsets.iCount = 1; // number of records to read |
|
371 offsets.iStartOffset = 1; |
|
372 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
373 User::WaitForRequest(reqStatus); |
|
374 CHECKPOINT_EXL(reqStatus==KErrMMEtelScApplicationNotActive, CHP_APPS_CASE("O.31")); |
|
375 |
|
376 smartCardAppID=_L8("SCApp3"); |
|
377 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
378 User::WaitForRequest(reqStatus); |
|
379 TESTL(reqStatus==KErrNone); |
|
380 |
|
381 /* Test ReadSCFile, with incorrect path */ |
|
382 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
383 User::WaitForRequest(reqStatus); |
|
384 CHECKPOINT_EXL(reqStatus==KErrMMEtelScFileNotFound, CHP_APPS_CASE("O.32")); |
|
385 |
|
386 /* Test ReadSCFile on Cyclical file with specified iAID, iPath last record written */ |
|
387 offsets.iPath = _L8("7FFF6F3C"); // set correct path |
|
388 |
|
389 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
390 User::WaitForRequest(reqStatus); |
|
391 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.33")); |
|
392 TESTL(readBuffer == _L8("WORLD")); |
|
393 |
|
394 /* Test ReadSCFile, second record, actually oldest record */ |
|
395 offsets.iStartOffset = 2; |
|
396 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
397 User::WaitForRequest(reqStatus); |
|
398 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.34")); |
|
399 TESTL(readBuffer == _L8("HELLO")); |
|
400 |
|
401 /* Test ReadSCFile, out of range record */ |
|
402 offsets.iStartOffset = 0; |
|
403 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
404 User::WaitForRequest(reqStatus); |
|
405 TESTL(reqStatus == KErrMMEtelScRecordNotFound); |
|
406 |
|
407 /* Test ReadSCFile, out of range record */ |
|
408 offsets.iStartOffset = 10; |
|
409 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
410 User::WaitForRequest(reqStatus); |
|
411 CHECKPOINT_EXL(reqStatus==KErrMMEtelScRecordNotFound, CHP_APPS_CASE("O.35")); |
|
412 |
|
413 /* Test ReadSCFile, buffer too small */ |
|
414 offsets.iStartOffset = 1; |
|
415 iPhone.ReadScFile(reqStatus, offsets, testBuffer); |
|
416 User::WaitForRequest(reqStatus); |
|
417 CHECKPOINT_EXL(reqStatus==KErrOverflow, CHP_APPS_CASE("O.36")); |
|
418 |
|
419 /* Test ReadSCFile on Transparent file with specified iAID, iPath first 4 bytes */ |
|
420 offsets.iAID = _L8("SCApp4"); |
|
421 offsets.iType = RMobilePhone::ETransparent; |
|
422 offsets.iCount = 4; // number of bytes to read |
|
423 offsets.iStartOffset = 0; |
|
424 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
425 User::WaitForRequest(reqStatus); |
|
426 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.37")); |
|
427 TESTL(readBuffer == _L8("HELL")); |
|
428 |
|
429 /* Test ReadSCFile, 5 bytes in for 5 bytes */ |
|
430 offsets.iCount = 5; // number of bytes to read |
|
431 offsets.iStartOffset = 5; |
|
432 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
433 User::WaitForRequest(reqStatus); |
|
434 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.38")); |
|
435 TESTL(readBuffer == _L8("WORLD")); |
|
436 |
|
437 /* Test ReadSCFile, buffer too small */ |
|
438 offsets.iStartOffset = 1; |
|
439 iPhone.ReadScFile(reqStatus, offsets, testBuffer); |
|
440 User::WaitForRequest(reqStatus); |
|
441 CHECKPOINT_EXL(reqStatus==KErrOverflow, CHP_APPS_CASE("O.39")); |
|
442 |
|
443 /* Test ReadSCFile, out of range record */ |
|
444 offsets.iStartOffset = 11; |
|
445 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
446 User::WaitForRequest(reqStatus); |
|
447 CHECKPOINT_EXL(reqStatus==KErrMMEtelScReferencedDataNotFound, CHP_APPS_CASE("O.40")); |
|
448 |
|
449 /* Test ReadSCFile, 5 bytes in for 10 bytes, beyond end of file */ |
|
450 offsets.iCount = 10; // number of bytes to read |
|
451 offsets.iStartOffset = 5; |
|
452 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
453 User::WaitForRequest(reqStatus); |
|
454 CHECKPOINT_EXL(reqStatus==KErrMMEtelScEofReached, CHP_APPS_CASE("O.41")); |
|
455 |
|
456 INFO_PRINTF1(_L("UpdateSCFile test")); |
|
457 /* Test UpdateSCFile on Linear Fixed file with specified iAID, write first record */ |
|
458 TBuf8<25> writeBuffer; |
|
459 |
|
460 /* Simple UpdateSCFile test with smart card not owned by application */ |
|
461 writeBuffer = _L8("EARTH"); |
|
462 offsets.iAID = _L8(""); |
|
463 offsets.iPath = _L8("3FFF6F3C"); |
|
464 offsets.iType = RMobilePhone::ELinearFixed; |
|
465 offsets.iCount = 1; // number of records to read |
|
466 offsets.iStartOffset = 1; |
|
467 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
468 User::WaitForRequest(reqStatus); |
|
469 TESTL(reqStatus == KErrNone); |
|
470 |
|
471 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
472 User::WaitForRequest(reqStatus); |
|
473 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.42")); |
|
474 TESTL(readBuffer == _L8("EARTH")); |
|
475 |
|
476 offsets.iAID = _L8("SCApp1"); |
|
477 offsets.iPath = _L8("7FFF6F3C"); |
|
478 offsets.iCount = 1; // number of records to write |
|
479 offsets.iStartOffset = 1; // record number to write |
|
480 writeBuffer = _L8("GOODB"); |
|
481 |
|
482 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
483 User::WaitForRequest(reqStatus); |
|
484 TESTL(reqStatus == KErrNone); |
|
485 |
|
486 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
487 User::WaitForRequest(reqStatus); |
|
488 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.43")); |
|
489 TESTL(readBuffer == _L8("GOODB")); |
|
490 |
|
491 /* Test UpdateSCFile on Linear Fixed file with specified iAID, write 2nd record */ |
|
492 offsets.iStartOffset = 2; // record number to write |
|
493 writeBuffer = _L8("EARTH"); |
|
494 |
|
495 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
496 User::WaitForRequest(reqStatus); |
|
497 TESTL(reqStatus == KErrNone); |
|
498 |
|
499 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
500 User::WaitForRequest(reqStatus); |
|
501 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.44")); |
|
502 TESTL(readBuffer == _L8("EARTH")); |
|
503 |
|
504 /* Test UpdateSCFile, out of range record */ |
|
505 offsets.iStartOffset = 0; |
|
506 iPhone.UpdateScFile(reqStatus, offsets, readBuffer); |
|
507 User::WaitForRequest(reqStatus); |
|
508 TESTL(reqStatus == KErrMMEtelScRecordNotFound); |
|
509 |
|
510 /* Test UpdateSCFile, out of range record */ |
|
511 offsets.iStartOffset = 10; |
|
512 iPhone.UpdateScFile(reqStatus, offsets, readBuffer); |
|
513 User::WaitForRequest(reqStatus); |
|
514 CHECKPOINT_EXL(reqStatus==KErrMMEtelScRecordNotFound, CHP_APPS_CASE("O.45")); |
|
515 |
|
516 /* Test UpdateSCFile on Linear Fixed file, buffer too small */ |
|
517 offsets.iStartOffset = 1; |
|
518 iPhone.UpdateScFile(reqStatus, offsets, testBuffer); |
|
519 User::WaitForRequest(reqStatus); |
|
520 CHECKPOINT_EXL(reqStatus==KErrMMEtelScWrongLength, CHP_APPS_CASE("O.46")); |
|
521 |
|
522 /* Test UpdateSCFile on Cyclic file with specified iAID, write oldest record at 1st position */ |
|
523 offsets.iAID = _L8("SCApp3"); |
|
524 offsets.iType = RMobilePhone::ECyclic; |
|
525 writeBuffer = _L8("GOODB"); |
|
526 |
|
527 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
528 User::WaitForRequest(reqStatus); |
|
529 TESTL(reqStatus == KErrNone); |
|
530 |
|
531 offsets.iStartOffset = 1; // record number to read (lastest written record) |
|
532 |
|
533 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
534 User::WaitForRequest(reqStatus); |
|
535 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.47")); |
|
536 TESTL(readBuffer == _L8("GOODB")); |
|
537 |
|
538 /* Test UpdateSCFile on Cyclic file with specified iAID, write oldest record, now at 2nd position */ |
|
539 writeBuffer = _L8("EARTH"); |
|
540 |
|
541 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
542 User::WaitForRequest(reqStatus); |
|
543 TESTL(reqStatus == KErrNone); |
|
544 |
|
545 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
546 User::WaitForRequest(reqStatus); |
|
547 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.48")); |
|
548 TESTL(readBuffer == _L8("EARTH")); |
|
549 |
|
550 /* Test UpdateSCFile on Cyclic file with specified iAID, write oldest record, now at back at 1st position */ |
|
551 writeBuffer = _L8("HELLO"); |
|
552 |
|
553 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
554 User::WaitForRequest(reqStatus); |
|
555 TESTL(reqStatus == KErrNone); |
|
556 |
|
557 offsets.iStartOffset = 2; // record number to read (oldest record) |
|
558 |
|
559 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
560 User::WaitForRequest(reqStatus); |
|
561 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.49")); |
|
562 TESTL(readBuffer == _L8("EARTH")); |
|
563 |
|
564 /* Test UpdateSCFile on Cyclic file, buffer too small */ |
|
565 offsets.iStartOffset = 1; |
|
566 iPhone.UpdateScFile(reqStatus, offsets, testBuffer); |
|
567 User::WaitForRequest(reqStatus); |
|
568 CHECKPOINT_EXL(reqStatus==KErrMMEtelScWrongLength, CHP_APPS_CASE("O.50")); |
|
569 |
|
570 /* Test UpdateSCFile on Transparent file with specified iAID, write from beginning */ |
|
571 offsets.iAID = _L8("SCApp4"); |
|
572 offsets.iType = RMobilePhone::ETransparent; |
|
573 writeBuffer = _L8("GOODB"); |
|
574 offsets.iCount = 5; // number of bytes to write |
|
575 offsets.iStartOffset = 0; // From position 0 |
|
576 |
|
577 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
578 User::WaitForRequest(reqStatus); |
|
579 TESTL(reqStatus == KErrNone); |
|
580 |
|
581 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
582 User::WaitForRequest(reqStatus); |
|
583 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.51")); |
|
584 TESTL(readBuffer == _L8("GOODB")); |
|
585 |
|
586 /* Test UpdateSCFile on Transparent file with specified iAID, write from half way through */ |
|
587 writeBuffer = _L8("EARTH"); |
|
588 offsets.iCount = 5; // number of bytes to write |
|
589 offsets.iStartOffset = 5; // From position 0 |
|
590 |
|
591 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
592 User::WaitForRequest(reqStatus); |
|
593 TESTL(reqStatus == KErrNone); |
|
594 |
|
595 offsets.iCount = 10; // number of bytes to write |
|
596 offsets.iStartOffset = 0; // From position 0 |
|
597 |
|
598 iPhone.ReadScFile(reqStatus, offsets, readBuffer); |
|
599 User::WaitForRequest(reqStatus); |
|
600 CHECKPOINT_EXL(reqStatus==KErrNone, CHP_APPS_CASE("O.52")); |
|
601 TESTL(readBuffer == _L8("GOODBEARTH")); |
|
602 |
|
603 /* Test UpdateSCFile, buffer too small */ |
|
604 offsets.iStartOffset = 1; |
|
605 iPhone.UpdateScFile(reqStatus, offsets, testBuffer); |
|
606 User::WaitForRequest(reqStatus); |
|
607 CHECKPOINT_EXL(reqStatus==KErrArgument, CHP_APPS_CASE("O.53")); |
|
608 |
|
609 /* Test UpdateSCFile, out of range record */ |
|
610 offsets.iStartOffset = 11; |
|
611 iPhone.UpdateScFile(reqStatus, offsets, readBuffer); |
|
612 User::WaitForRequest(reqStatus); |
|
613 CHECKPOINT_EXL(reqStatus==KErrMMEtelScReferencedDataNotFound, CHP_APPS_CASE("O.54")); |
|
614 |
|
615 /* Test UpdateSCFile, writing beyond range of file */ |
|
616 offsets.iStartOffset = 1; |
|
617 offsets.iCount = 11; // number of bytes to write |
|
618 iPhone.UpdateScFile(reqStatus, offsets, testBuffer); |
|
619 User::WaitForRequest(reqStatus); |
|
620 CHECKPOINT_EXL(reqStatus==KErrArgument, CHP_APPS_CASE("O.55")); |
|
621 |
|
622 /* Test UpdateSCFile on Linear file with specified iAID but without application active */ |
|
623 smartCardAppID=_L8("SCApp1"); |
|
624 offsets.iAID = _L8("SCApp1"); |
|
625 offsets.iType = RMobilePhone::ELinearFixed; |
|
626 offsets.iCount = 1; // number of records to write |
|
627 offsets.iStartOffset = 1; // record number to write |
|
628 writeBuffer = _L8("GOODB"); |
|
629 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScTerminate); |
|
630 User::WaitForRequest(reqStatus); |
|
631 TESTL(reqStatus==KErrNone); |
|
632 |
|
633 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
634 User::WaitForRequest(reqStatus); |
|
635 CHECKPOINT_EXL(reqStatus==KErrMMEtelScApplicationNotActive, CHP_APPS_CASE("O.56")); |
|
636 |
|
637 iPhone.SetSmartCardApplicationStatus(reqStatus,smartCardAppID,RMobilePhone::EScApplicationActivate); |
|
638 User::WaitForRequest(reqStatus); |
|
639 TESTL(reqStatus==KErrNone); |
|
640 |
|
641 /* Test UpdateSCFile, with incorrect path */ |
|
642 offsets.iPath = _L8("3FFF6F3C"); |
|
643 iPhone.UpdateScFile(reqStatus, offsets, writeBuffer); |
|
644 User::WaitForRequest(reqStatus); |
|
645 CHECKPOINT_EXL(reqStatus==KErrMMEtelScFileNotFound, CHP_APPS_CASE("O.57")); |
|
646 |
|
647 iPhone.Close(); |
|
648 ASSERT(RThread().RequestCount()==0); |
|
649 |
|
650 return TestStepResult(); |
|
651 } |
|
652 |