|
1 // Copyright (c) 2003-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 // implementation of test steps |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 |
|
23 #include "WapIoctlSteps.h" |
|
24 #include "WapProtSuiteDefs.h" |
|
25 #include <etel.h> |
|
26 #include <es_wsms.h> |
|
27 #include <simtsy.h> |
|
28 #include <sacls.h> |
|
29 #include <s32mem.h> |
|
30 #include <smspver.h> |
|
31 |
|
32 |
|
33 TVerdict CIoctlStep_1::doTestStepL() |
|
34 /** |
|
35 * Test step one: |
|
36 * Sends/receives a 7Bit business card using IOCTL |
|
37 * @return - TVerdict code |
|
38 * |
|
39 */ |
|
40 { |
|
41 INFO_PRINTF1(_L("IOCTL Test step 1: send/receive 7-Bit business card")); |
|
42 |
|
43 TPtrC TestData1; |
|
44 TPtrC16 TelNumber; |
|
45 TInt port=226; |
|
46 TInt testNumber=1; |
|
47 |
|
48 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
49 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
50 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
51 { |
|
52 // Leave if there's any error. |
|
53 User::Leave(KErrNotFound); |
|
54 } |
|
55 |
|
56 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
57 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
58 |
|
59 // |
|
60 // Setting the port number and service center number of the wap address |
|
61 // The service center number should be the same as the sim phone number used |
|
62 // for test (not required for SIM tsy) |
|
63 // |
|
64 TWapAddr wapAddr; |
|
65 TWapAddr recvWapAddr; |
|
66 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
67 |
|
68 TBuf8<100> scNumber; |
|
69 scNumber.Copy(TelNumber); |
|
70 TPtrC8 scAddr(scNumber); |
|
71 wapAddr.SetWapAddress(scAddr); |
|
72 |
|
73 // |
|
74 // Connect to socket server |
|
75 // |
|
76 RSocketServ socketServer; |
|
77 User::LeaveIfError(socketServer.Connect()); |
|
78 CleanupClosePushL(socketServer); |
|
79 |
|
80 // |
|
81 // Define and open the socket |
|
82 // |
|
83 RSocket sock; |
|
84 OpenSocketLC(socketServer, sock); |
|
85 // |
|
86 // Waiting for the phone to be initialised |
|
87 // |
|
88 WaitForInitializeL(); |
|
89 |
|
90 TRequestStatus ioctlStatus; |
|
91 TRequestStatus recvStatus; |
|
92 TPckgBuf<TInt> length; |
|
93 |
|
94 // |
|
95 // Indicating to the protocol that it's a new client |
|
96 // |
|
97 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
98 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
99 |
|
100 // |
|
101 // Bind |
|
102 // |
|
103 User::LeaveIfError(sock.Bind(wapAddr)); |
|
104 |
|
105 // |
|
106 // Send a business card |
|
107 // |
|
108 TRequestStatus status; |
|
109 |
|
110 TBuf8<200> data; |
|
111 data.Copy(TestData1); |
|
112 sock.SendTo(data, wapAddr, 0, status); |
|
113 User::WaitForRequest(status); |
|
114 User::LeaveIfError(status.Int()); |
|
115 INFO_PRINTF1(_L("Message sent...")); |
|
116 |
|
117 // |
|
118 // Issue Ioctl for getting the length of the message |
|
119 // |
|
120 INFO_PRINTF1(_L("Issue of IOCTL for GetLength")); |
|
121 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
122 |
|
123 // |
|
124 // Get the size of the first incomming message |
|
125 // |
|
126 User::WaitForRequest(ioctlStatus); |
|
127 User::LeaveIfError(ioctlStatus.Int()); |
|
128 INFO_PRINTF1(_L("IOCTL completed")); |
|
129 |
|
130 // |
|
131 // Check if reported length is correct |
|
132 // |
|
133 TBuf8<256> recvBuf(length); |
|
134 |
|
135 TEST(length()==data.Length()); |
|
136 |
|
137 // |
|
138 // Receiving a datagram |
|
139 // |
|
140 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
141 User::WaitForRequest(recvStatus); |
|
142 User::LeaveIfError(recvStatus.Int()); |
|
143 INFO_PRINTF1(_L("Received the message...")); |
|
144 |
|
145 // |
|
146 // Confirm the receipt of the message to the client |
|
147 // |
|
148 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
149 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
150 TEST(recvBuf.Compare(data) == 0); |
|
151 |
|
152 // |
|
153 // Closing the socket |
|
154 // |
|
155 CleanupStack::PopAndDestroy(&sock); |
|
156 CleanupStack::PopAndDestroy(&socketServer); |
|
157 |
|
158 return TestStepResult(); |
|
159 } |
|
160 |
|
161 |
|
162 TVerdict CIoctlStep_2::doTestStepL() |
|
163 /** |
|
164 * Test step two: |
|
165 * Sends/receives a 7-Bit calendar entry and VCard using IOCTL(two segments each) |
|
166 * @return - TVerdict code |
|
167 * |
|
168 */ |
|
169 { |
|
170 |
|
171 INFO_PRINTF1(_L("IOCTL Test step 2: send/receive a VCal and VCard")); |
|
172 |
|
173 TPtrC TestData1; |
|
174 TPtrC TestData2; |
|
175 TPtrC16 TelNumber; |
|
176 TInt port=226; |
|
177 TInt testNumber = 2; |
|
178 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
179 !GetStringFromConfig(ConfigSection(),KTestData2, TestData2) || |
|
180 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
181 !GetIntFromConfig(ConfigSection(),KWapPort,port) |
|
182 ) |
|
183 { |
|
184 // Leave if there's any error. |
|
185 User::Leave(KErrNotFound); |
|
186 } |
|
187 |
|
188 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
189 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
190 |
|
191 // |
|
192 // Setting the port number and service center number of the wap address |
|
193 // The service center number should be the same as the sim phone number used |
|
194 // for test (not required for SIM Tsy) |
|
195 // |
|
196 TWapAddr wapAddr; |
|
197 TWapAddr recvWapAddr; |
|
198 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
199 TBuf8<100> scNumber; |
|
200 scNumber.Copy(TelNumber); |
|
201 TPtrC8 scAddr(scNumber); |
|
202 wapAddr.SetWapAddress(scAddr); |
|
203 |
|
204 // |
|
205 // Connect to socket server |
|
206 // |
|
207 RSocketServ socketServer; |
|
208 User::LeaveIfError(socketServer.Connect()); |
|
209 CleanupClosePushL(socketServer); |
|
210 |
|
211 // |
|
212 // Define and open the socket |
|
213 // |
|
214 RSocket sock; |
|
215 OpenSocketLC(socketServer, sock); |
|
216 |
|
217 // |
|
218 // Waiting for the phone to be initialised |
|
219 // |
|
220 WaitForInitializeL(); |
|
221 |
|
222 TRequestStatus ioctlStatus; |
|
223 TRequestStatus recvStatus; |
|
224 TPckgBuf<TInt> length; |
|
225 |
|
226 // |
|
227 // Indicating to the protocol that it's a new client |
|
228 // |
|
229 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
230 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
231 // |
|
232 // Bind |
|
233 // |
|
234 User::LeaveIfError(sock.Bind(wapAddr)); |
|
235 |
|
236 // |
|
237 // Issue Ioctl for getting the length of the message |
|
238 // |
|
239 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for first VCal entry")); |
|
240 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
241 |
|
242 |
|
243 TBuf8<300> data; |
|
244 |
|
245 // |
|
246 // Send a calendar entry |
|
247 // |
|
248 TRequestStatus status; |
|
249 |
|
250 data.Copy(TestData1); |
|
251 sock.SendTo(data, wapAddr, 0, status); |
|
252 User::WaitForRequest(status); |
|
253 User::LeaveIfError(status.Int()); |
|
254 INFO_PRINTF1(_L("First Message (VCal) sent...")); |
|
255 |
|
256 // Send a VCard entry |
|
257 data.Copy(TestData2); |
|
258 sock.SendTo(data, wapAddr, 0, status); |
|
259 User::WaitForRequest(status); |
|
260 User::LeaveIfError(status.Int()); |
|
261 INFO_PRINTF1(_L("Second message (VCard with extended GSM alphabets) sent...")); |
|
262 |
|
263 // |
|
264 // Get the size of the first incomming message |
|
265 // |
|
266 User::WaitForRequest(ioctlStatus); |
|
267 User::LeaveIfError(ioctlStatus.Int()); |
|
268 INFO_PRINTF1(_L("IOCTL completed")); |
|
269 // |
|
270 // Check if reported length is correct |
|
271 // |
|
272 TBuf8<300> recvBuf; |
|
273 TEST(length()==TestData1.Length()); |
|
274 |
|
275 // |
|
276 // Receiving a datagram |
|
277 // |
|
278 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
279 User::WaitForRequest(recvStatus); |
|
280 User::LeaveIfError(recvStatus.Int()); |
|
281 INFO_PRINTF1(_L("Received the first message (VCal)...")); |
|
282 |
|
283 // Compare the received VCal message with the original one. |
|
284 // They should be identical |
|
285 data.Copy(TestData1); |
|
286 if (recvBuf.Compare(data) != 0) |
|
287 { |
|
288 ERR_PRINTF1(_L("VCal message received does not match with original message.")); |
|
289 TEST(recvBuf.Compare(data) == 0); |
|
290 } |
|
291 |
|
292 // |
|
293 // Confirm the receipt of the message to the client |
|
294 // |
|
295 INFO_PRINTF1(_L("Socket set option for indicating receipt of first message (VCal)")); |
|
296 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
297 |
|
298 |
|
299 //Issue Ioctl for getting the length of the second message |
|
300 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for second VCard entry")); |
|
301 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
302 |
|
303 //Get the size of the second incomming message |
|
304 User::WaitForRequest(ioctlStatus); |
|
305 User::LeaveIfError(ioctlStatus.Int()); |
|
306 INFO_PRINTF1(_L("IOCTL completed for second message (VCard)")); |
|
307 |
|
308 //Check if reported length is correct |
|
309 TEST(length()==TestData2.Length()); |
|
310 |
|
311 //Receiving a datagram (VCard) |
|
312 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
313 User::WaitForRequest(recvStatus); |
|
314 User::LeaveIfError(recvStatus.Int()); |
|
315 INFO_PRINTF1(_L("Received the second message (VCard)...")); |
|
316 |
|
317 // Compare the received VCard message with the original one |
|
318 // They should be identical |
|
319 data.Copy(TestData2); |
|
320 if (recvBuf.Compare(data) != 0) |
|
321 { |
|
322 ERR_PRINTF1(_L("VCard message received does not match with original message.")); |
|
323 TEST(recvBuf.Compare(data) == 0); |
|
324 } |
|
325 |
|
326 //Confirm the receipt of the message to the client |
|
327 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
328 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
329 // |
|
330 // Closing the socket |
|
331 // |
|
332 sock.Close(); |
|
333 socketServer.Close(); |
|
334 CleanupStack::PopAndDestroy(&sock); |
|
335 CleanupStack::Pop(&socketServer); |
|
336 |
|
337 return TestStepResult(); |
|
338 } |
|
339 |
|
340 |
|
341 TVerdict CIoctlStep_3::doTestStepL() |
|
342 /** |
|
343 * Test step 3: |
|
344 * send/receive one 7-Bit two segments message and one 7-Bit one segment message |
|
345 * @return - TVerdict code |
|
346 * |
|
347 */ |
|
348 { |
|
349 INFO_PRINTF1(_L("IOCTL Test step 3: send/receive two 7-Bit messages")); |
|
350 |
|
351 TPtrC TestData1; |
|
352 TPtrC TestData2; |
|
353 TPtrC16 TelNumber; |
|
354 TInt port=226; |
|
355 TInt testNumber = 3; |
|
356 |
|
357 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
358 !GetStringFromConfig(ConfigSection(),KTestData2, TestData2) || |
|
359 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
360 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
361 { |
|
362 // Leave if there's any error. |
|
363 User::Leave(KErrNotFound); |
|
364 } |
|
365 |
|
366 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
367 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
368 |
|
369 // |
|
370 // Setting the port number and service center number of the wap address |
|
371 // The service center number should be the same as the sim phone number used |
|
372 // for test |
|
373 // |
|
374 TWapAddr wapAddr; |
|
375 TWapAddr recvWapAddr; |
|
376 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
377 TBuf8<100> scNumber; |
|
378 scNumber.Copy(TelNumber); |
|
379 TPtrC8 scAddr(scNumber); |
|
380 wapAddr.SetWapAddress(scAddr); |
|
381 |
|
382 // |
|
383 // Connect to socket server |
|
384 // |
|
385 RSocketServ socketServer; |
|
386 User::LeaveIfError(socketServer.Connect()); |
|
387 CleanupClosePushL(socketServer); |
|
388 |
|
389 // |
|
390 // Define and open the socket |
|
391 // |
|
392 RSocket sock; |
|
393 OpenSocketLC(socketServer, sock); |
|
394 |
|
395 // |
|
396 // Waiting for the phone to be initialised |
|
397 // |
|
398 WaitForInitializeL(); |
|
399 |
|
400 TRequestStatus ioctlStatus; |
|
401 TRequestStatus recvStatus; |
|
402 TPckgBuf<TInt> length; |
|
403 |
|
404 // |
|
405 // Indicating to the protocol that it's a new client |
|
406 // |
|
407 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
408 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
409 |
|
410 // |
|
411 // Bind |
|
412 // |
|
413 User::LeaveIfError(sock.Bind(wapAddr)); |
|
414 |
|
415 // |
|
416 // Issue Ioctl for getting the length of the message |
|
417 // |
|
418 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
419 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
420 |
|
421 // |
|
422 // Send a calendar entry |
|
423 // |
|
424 TRequestStatus status; |
|
425 |
|
426 TBuf8<300> data2; |
|
427 data2.Copy(TestData2); |
|
428 sock.SendTo(data2, wapAddr, 0, status); |
|
429 User::WaitForRequest(status); |
|
430 User::LeaveIfError(status.Int()); |
|
431 INFO_PRINTF1(_L("First message sent...")); |
|
432 |
|
433 // |
|
434 // Send a business card |
|
435 // |
|
436 TBuf8<200> data1; |
|
437 data1.Copy(TestData1); |
|
438 sock.SendTo(data1, wapAddr, 0, status); |
|
439 User::WaitForRequest(status); |
|
440 User::LeaveIfError(status.Int()); |
|
441 INFO_PRINTF1(_L("Second message sent...")); |
|
442 // |
|
443 // Get the size of the first incomming message |
|
444 // |
|
445 User::WaitForRequest(ioctlStatus); |
|
446 User::LeaveIfError(ioctlStatus.Int()); |
|
447 INFO_PRINTF1(_L("IOCTL completed...")); |
|
448 TBuf8<256> recvBuf2(length); |
|
449 |
|
450 // |
|
451 // Receiving a datagram |
|
452 // |
|
453 sock.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
454 User::WaitForRequest(recvStatus); |
|
455 User::LeaveIfError(recvStatus.Int()); |
|
456 INFO_PRINTF1(_L("Received the first message...")); |
|
457 TEST(recvBuf2.Compare(data2) == 0); |
|
458 |
|
459 // |
|
460 // Confirm the receipt of the message to the client |
|
461 // |
|
462 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
463 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
464 // |
|
465 // Issue Ioctl for getting the length of the second message |
|
466 // |
|
467 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
468 INFO_PRINTF1(_L("Issue of the 2nd IOCTL for GetLength")); |
|
469 |
|
470 // |
|
471 // Get the size of the SECOND incomming message |
|
472 // |
|
473 User::WaitForRequest(ioctlStatus); |
|
474 User::LeaveIfError(ioctlStatus.Int()); |
|
475 INFO_PRINTF1(_L("IOCTL completed")); |
|
476 // |
|
477 // Check if reported length is correct |
|
478 // |
|
479 TBuf8<256> recvBuf1(length); |
|
480 TEST(length()==data1.Length()); |
|
481 |
|
482 // |
|
483 // Receiving the second message |
|
484 // |
|
485 sock.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
|
486 User::WaitForRequest(recvStatus); |
|
487 User::LeaveIfError(recvStatus.Int()); |
|
488 INFO_PRINTF1(_L("Receievd the second datagram")); |
|
489 TEST(recvBuf1.Compare(data1) == 0); |
|
490 |
|
491 // |
|
492 // Confirm the receipt of the second message to the client |
|
493 // |
|
494 INFO_PRINTF1(_L("Socket set option for indicating receipt of the second message")); |
|
495 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
496 |
|
497 // |
|
498 // Closing the socket |
|
499 // |
|
500 sock.Close(); |
|
501 socketServer.Close(); |
|
502 CleanupStack::PopAndDestroy(&sock); |
|
503 CleanupStack::Pop(&socketServer); |
|
504 |
|
505 return TestStepResult(); |
|
506 } |
|
507 |
|
508 |
|
509 TVerdict CIoctlStep_4::doTestStepL() |
|
510 /** |
|
511 * |
|
512 * Test step 4: |
|
513 * simulating client crash conditions with 7bit message |
|
514 * @return - TVerdict code |
|
515 * |
|
516 */ |
|
517 { |
|
518 INFO_PRINTF1(_L("IOCTL Test step 4: client crash condition 7-Bit message ")); |
|
519 |
|
520 TPtrC TestData; |
|
521 TPtrC16 TelNumber; |
|
522 TInt port=226; |
|
523 TInt testNumber =4; |
|
524 |
|
525 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData) || |
|
526 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
527 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
528 { |
|
529 // Leave if there's any error. |
|
530 User::Leave(KErrNotFound); |
|
531 } |
|
532 |
|
533 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
534 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
535 |
|
536 // |
|
537 // Setting the port number and service center number of the wap address |
|
538 // The service center number should be the same as the sim phone number used |
|
539 // for test |
|
540 // |
|
541 TWapAddr wapAddr; |
|
542 TWapAddr recvWapAddr; |
|
543 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
544 TBuf8<100> scNumber; |
|
545 scNumber.Copy(TelNumber); |
|
546 TPtrC8 scAddr(scNumber); |
|
547 wapAddr.SetWapAddress(scAddr); |
|
548 |
|
549 // |
|
550 // Connect to socket server |
|
551 // |
|
552 RSocketServ socketServer; |
|
553 User::LeaveIfError(socketServer.Connect()); |
|
554 CleanupClosePushL(socketServer); |
|
555 |
|
556 // |
|
557 // Define and open the socket |
|
558 // |
|
559 RSocket sock; |
|
560 OpenSocketLC(socketServer, sock); |
|
561 |
|
562 // |
|
563 // Waiting for the phone to be initialised |
|
564 // |
|
565 WaitForInitializeL(); |
|
566 |
|
567 TRequestStatus ioctlStatus; |
|
568 TRequestStatus recvStatus; |
|
569 TPckgBuf<TInt> length; |
|
570 |
|
571 // |
|
572 // Indicating to the protocol that it's a new client |
|
573 // |
|
574 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
575 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
576 // |
|
577 // Bind |
|
578 // |
|
579 User::LeaveIfError(sock.Bind(wapAddr)); |
|
580 |
|
581 // |
|
582 // Issue Ioctl for getting the length of the message |
|
583 // |
|
584 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
585 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
586 |
|
587 // |
|
588 // Send a business card |
|
589 // |
|
590 TRequestStatus status; |
|
591 |
|
592 TBuf8<200> data; |
|
593 data.Copy(TestData); |
|
594 sock.SendTo(data, wapAddr, 0, status); |
|
595 User::WaitForRequest(status); |
|
596 User::LeaveIfError(status.Int()); |
|
597 INFO_PRINTF1(_L("Message sent...")); |
|
598 // |
|
599 // Get the size of the incomming message |
|
600 // |
|
601 User::WaitForRequest(ioctlStatus); |
|
602 User::LeaveIfError(ioctlStatus.Int()); |
|
603 INFO_PRINTF1(_L("IOCTL completed...")); |
|
604 // |
|
605 // Check if reported length is correct |
|
606 // |
|
607 TBuf8<256> recvBuf(length); |
|
608 TEST(length()==data.Length()); |
|
609 |
|
610 // |
|
611 // Receiving a datagram |
|
612 // |
|
613 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
614 User::WaitForRequest(recvStatus); |
|
615 User::LeaveIfError(recvStatus.Int()); |
|
616 INFO_PRINTF1(_L("Received the message...")); |
|
617 // |
|
618 // Close socket |
|
619 // |
|
620 sock.Close(); |
|
621 INFO_PRINTF1(_L("Socket was closed...")); |
|
622 // |
|
623 // Open the socket |
|
624 // |
|
625 OpenSocketL(socketServer, sock); |
|
626 INFO_PRINTF1(_L("Socket was opened...")); |
|
627 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
628 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
629 User::LeaveIfError(sock.Bind(wapAddr)); |
|
630 // |
|
631 // Issue another get length of datagram as if not aware of the previous message |
|
632 // |
|
633 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
634 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
635 // |
|
636 // waiting for request to be completed |
|
637 // |
|
638 User::WaitForRequest(ioctlStatus); |
|
639 User::LeaveIfError(ioctlStatus.Int()); |
|
640 INFO_PRINTF1(_L("IOCTL completed...")); |
|
641 // |
|
642 // Check if reported length is correct |
|
643 // |
|
644 TBuf8<256> newRecvBuf(length); |
|
645 TEST(length()==data.Length()); |
|
646 |
|
647 // |
|
648 // New message retrieved from SAR store |
|
649 // |
|
650 sock.RecvFrom(newRecvBuf,recvWapAddr,0,recvStatus); |
|
651 User::WaitForRequest(recvStatus); |
|
652 User::LeaveIfError(recvStatus.Int()); |
|
653 INFO_PRINTF1(_L("Received the message...")); |
|
654 TEST(newRecvBuf.Compare(data) == 0); |
|
655 |
|
656 // |
|
657 // Confirm the receipt of the message to the client |
|
658 // |
|
659 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
660 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
661 |
|
662 // |
|
663 // Closing the socket |
|
664 // |
|
665 sock.Close(); |
|
666 socketServer.Close(); |
|
667 CleanupStack::PopAndDestroy(&sock); |
|
668 CleanupStack::Pop(&socketServer); |
|
669 |
|
670 return TestStepResult(); |
|
671 } |
|
672 |
|
673 |
|
674 TVerdict CIoctlStep_5::doTestStepL() |
|
675 /** |
|
676 * |
|
677 * Test step 5: |
|
678 * simulating client crash conditions with 8bit push message |
|
679 * @return - TVerdict code |
|
680 * |
|
681 */ |
|
682 { |
|
683 INFO_PRINTF1(_L("IOCTL Test step 5: client crash condition with 8Bit push message")); |
|
684 |
|
685 TPtrC16 TelNumber; |
|
686 TInt port=226; |
|
687 TInt testNumber= 5; |
|
688 |
|
689 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
690 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
691 { |
|
692 // Leave if there's any error. |
|
693 User::Leave(KErrNotFound); |
|
694 } |
|
695 |
|
696 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
697 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
698 |
|
699 // |
|
700 // Setting the port number and service center number of the wap address |
|
701 // The service center number should be the same as the sim phone number used |
|
702 // for test |
|
703 // |
|
704 |
|
705 TWapAddr wapAddr; |
|
706 TWapAddr recvWapAddr; |
|
707 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
708 TBuf8<100> scNumber; |
|
709 scNumber.Copy(TelNumber); |
|
710 TPtrC8 scAddr(scNumber); |
|
711 wapAddr.SetWapAddress(scAddr); |
|
712 |
|
713 // |
|
714 // Connect to socket server |
|
715 // |
|
716 RSocketServ socketServer; |
|
717 User::LeaveIfError(socketServer.Connect()); |
|
718 CleanupClosePushL(socketServer); |
|
719 |
|
720 // |
|
721 // Open the socket |
|
722 // |
|
723 RSocket sock; |
|
724 OpenSocketLC(socketServer, sock); |
|
725 |
|
726 // |
|
727 // Waiting for the phone to be initialised |
|
728 // |
|
729 WaitForInitializeL(); |
|
730 |
|
731 TRequestStatus ioctlStatus; |
|
732 TRequestStatus recvStatus; |
|
733 TPckgBuf<TInt> length; |
|
734 |
|
735 // |
|
736 // Indicating to the protocol that it's a new client |
|
737 // |
|
738 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
739 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
740 // |
|
741 // Bind |
|
742 // |
|
743 User::LeaveIfError(sock.Bind(wapAddr)); |
|
744 // |
|
745 // Issue Ioctl for getting the length of the message |
|
746 // |
|
747 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
748 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
749 |
|
750 // |
|
751 // Get the size of the incomming message |
|
752 // |
|
753 User::WaitForRequest(ioctlStatus); |
|
754 User::LeaveIfError(ioctlStatus.Int()); |
|
755 INFO_PRINTF1(_L("IOCTL completed...")); |
|
756 |
|
757 TBuf8<256> recvBuf(length); |
|
758 // |
|
759 // Receiving a datagram |
|
760 // |
|
761 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
762 User::WaitForRequest(recvStatus); |
|
763 User::LeaveIfError(recvStatus.Int()); |
|
764 INFO_PRINTF1(_L("Received the message...")); |
|
765 // |
|
766 // Close socket |
|
767 // |
|
768 sock.Close(); |
|
769 INFO_PRINTF1(_L("Socket was closed...")); |
|
770 // |
|
771 // Open the socket |
|
772 // |
|
773 OpenSocketL(socketServer, sock); |
|
774 INFO_PRINTF1(_L("Socket was opened...")); |
|
775 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
776 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
777 User::LeaveIfError(sock.Bind(wapAddr)); |
|
778 // |
|
779 // Issue another get length of datagram as if not aware of the previous message |
|
780 // |
|
781 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
782 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
783 // |
|
784 // waiting for request to be completed |
|
785 // |
|
786 User::WaitForRequest(ioctlStatus); |
|
787 User::LeaveIfError(ioctlStatus.Int()); |
|
788 INFO_PRINTF1(_L("IOCTL completed...")); |
|
789 // |
|
790 // Allocate buffer |
|
791 // |
|
792 TBuf8<256> newRecvBuf(length); |
|
793 |
|
794 // |
|
795 // New message retrieved from SAR store |
|
796 // |
|
797 sock.RecvFrom(newRecvBuf,recvWapAddr,0,recvStatus); |
|
798 User::WaitForRequest(recvStatus); |
|
799 User::LeaveIfError(recvStatus.Int()); |
|
800 INFO_PRINTF1(_L("Received the message...")); |
|
801 |
|
802 // |
|
803 // Confirm the receipt of the message to the client |
|
804 // |
|
805 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
806 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
807 |
|
808 // |
|
809 // Compare the received message with the previous one |
|
810 // They should be identical |
|
811 // |
|
812 TEST(newRecvBuf.Compare(recvBuf) == 0); |
|
813 |
|
814 // |
|
815 // Closing the socket |
|
816 // |
|
817 sock.Close(); |
|
818 socketServer.Close(); |
|
819 CleanupStack::PopAndDestroy(&sock); |
|
820 CleanupStack::Pop(&socketServer); |
|
821 |
|
822 return TestStepResult(); |
|
823 } |
|
824 |
|
825 |
|
826 TVerdict CIoctlStep_6::doTestStepL() |
|
827 /** |
|
828 * Test step 6: |
|
829 * Sends/receives a business card (Old client testing) |
|
830 * @return - TVerdict code |
|
831 * |
|
832 */ |
|
833 { |
|
834 INFO_PRINTF1(_L("IOCTL Test step 6: send/receive a VCard (Old client testing)")); |
|
835 |
|
836 TPtrC TestData1; |
|
837 TPtrC16 TelNumber; |
|
838 TInt port=226; |
|
839 TInt testNumber = 6; |
|
840 |
|
841 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
842 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
843 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
844 { |
|
845 // Leave if there's any error. |
|
846 User::Leave(KErrNotFound); |
|
847 } |
|
848 |
|
849 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
850 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
851 |
|
852 // |
|
853 // Setting the port number and service center number of the wap address |
|
854 // The service center number should be the same as the sim phone number used |
|
855 // for test |
|
856 // |
|
857 TWapAddr wapAddr; |
|
858 TWapAddr recvWapAddr; |
|
859 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
860 |
|
861 TBuf8<100> scNumber; |
|
862 scNumber.Copy(TelNumber); |
|
863 TPtrC8 scAddr(scNumber); |
|
864 wapAddr.SetWapAddress(scAddr); |
|
865 |
|
866 // |
|
867 // Connect to socket server |
|
868 // |
|
869 RSocketServ socketServer; |
|
870 User::LeaveIfError(socketServer.Connect()); |
|
871 CleanupClosePushL(socketServer); |
|
872 |
|
873 // |
|
874 // Define and open the socket |
|
875 // |
|
876 RSocket sock; |
|
877 OpenSocketLC(socketServer, sock); |
|
878 |
|
879 // |
|
880 // Waiting for the phone to be initialised |
|
881 // |
|
882 WaitForInitializeL(); |
|
883 |
|
884 TRequestStatus recvStatus; |
|
885 |
|
886 // |
|
887 // Bind |
|
888 // |
|
889 User::LeaveIfError(sock.Bind(wapAddr)); |
|
890 |
|
891 // |
|
892 // Send a calendar entry |
|
893 // |
|
894 TRequestStatus status; |
|
895 |
|
896 TBuf8<200> data; |
|
897 data.Copy(TestData1); |
|
898 sock.SendTo(data, wapAddr, 0, status); |
|
899 User::WaitForRequest(status); |
|
900 User::LeaveIfError(status.Int()); |
|
901 INFO_PRINTF1(_L("Message sent...")); |
|
902 |
|
903 // |
|
904 // Receiving a datagram |
|
905 // |
|
906 TBuf8<256> recvBuf; |
|
907 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
908 User::WaitForRequest(recvStatus); |
|
909 User::LeaveIfError(recvStatus.Int()); |
|
910 INFO_PRINTF1(_L("Received the message...")); |
|
911 |
|
912 // |
|
913 // Closing the socket |
|
914 // |
|
915 sock.Close(); |
|
916 socketServer.Close(); |
|
917 CleanupStack::PopAndDestroy(&sock); |
|
918 CleanupStack::Pop(&socketServer); |
|
919 |
|
920 return TestStepResult(); |
|
921 } |
|
922 |
|
923 |
|
924 TVerdict CIoctlStep_7::doTestStepL() |
|
925 /** |
|
926 * Test step 7: |
|
927 * Receives a Push Message (8-Bit) |
|
928 * @return - TVerdict code |
|
929 * |
|
930 */ |
|
931 { |
|
932 INFO_PRINTF1(_L("IOCTL Test step 7: Receive push message(8-Bit)")); |
|
933 |
|
934 TPtrC16 TelNumber; |
|
935 TInt port=226; |
|
936 TInt testNumber = 7; |
|
937 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
938 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
939 { |
|
940 // Leave if there's any error. |
|
941 User::Leave(KErrNotFound); |
|
942 } |
|
943 |
|
944 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
945 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
946 |
|
947 // |
|
948 // Setting the port number and service center number of the wap address |
|
949 // The service center number should be the same as the sim phone number used |
|
950 // for test |
|
951 // |
|
952 TWapAddr wapAddr; |
|
953 TWapAddr recvWapAddr; |
|
954 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
955 TBuf8<100> scNumber; |
|
956 scNumber.Copy(TelNumber); |
|
957 TPtrC8 scAddr(scNumber); |
|
958 wapAddr.SetWapAddress(scAddr); |
|
959 |
|
960 // |
|
961 // Connect to socket server |
|
962 // |
|
963 RSocketServ socketServer; |
|
964 User::LeaveIfError(socketServer.Connect()); |
|
965 CleanupClosePushL(socketServer); |
|
966 |
|
967 // |
|
968 // Define and open the socket |
|
969 // |
|
970 RSocket sock; |
|
971 OpenSocketLC(socketServer, sock); |
|
972 |
|
973 // |
|
974 // Waiting for the phone to be initialised |
|
975 // |
|
976 WaitForInitializeL(); |
|
977 |
|
978 TRequestStatus ioctlStatus; |
|
979 TRequestStatus recvStatus; |
|
980 TPckgBuf<TInt> length; |
|
981 |
|
982 // |
|
983 // Indicating to the protocol that it's a new client |
|
984 // |
|
985 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
986 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
987 |
|
988 // |
|
989 // Bind |
|
990 // |
|
991 User::LeaveIfError(sock.Bind(wapAddr)); |
|
992 |
|
993 // |
|
994 // Issue Ioctl for getting the length of the message |
|
995 // |
|
996 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
997 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
998 // |
|
999 // Get the size of the incomming push message |
|
1000 // |
|
1001 User::WaitForRequest(ioctlStatus); |
|
1002 User::LeaveIfError(ioctlStatus.Int()); |
|
1003 INFO_PRINTF1(_L("IOCTL completed...")); |
|
1004 // |
|
1005 // Allocate buffer |
|
1006 // |
|
1007 TBuf8<256> recvBuf2(length); |
|
1008 |
|
1009 // |
|
1010 // Receiving push datagram |
|
1011 // |
|
1012 sock.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
1013 User::WaitForRequest(recvStatus); |
|
1014 User::LeaveIfError(recvStatus.Int()); |
|
1015 INFO_PRINTF1(_L("Received the push message...")); |
|
1016 |
|
1017 // |
|
1018 // Confirm the receipt of the message to the client |
|
1019 // |
|
1020 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
1021 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
1022 |
|
1023 // |
|
1024 // Closing the socket |
|
1025 // |
|
1026 sock.Close(); |
|
1027 socketServer.Close(); |
|
1028 CleanupStack::PopAndDestroy(&sock); |
|
1029 CleanupStack::Pop(&socketServer); |
|
1030 |
|
1031 return TestStepResult(); |
|
1032 } |
|
1033 |
|
1034 |
|
1035 TVerdict CIoctlStep_8::doTestStepL() |
|
1036 /** |
|
1037 * Test step 8: |
|
1038 * Receives two Push Messages (8-Bit) Tests store of 8-Bit messages |
|
1039 * @return - TVerdict code |
|
1040 * |
|
1041 */ |
|
1042 { |
|
1043 INFO_PRINTF1(_L("IOCTL Test step 8: Receive two push message(8-Bit)")); |
|
1044 |
|
1045 TPtrC16 TelNumber; |
|
1046 TInt port=226; |
|
1047 TInt testNumber=8; |
|
1048 |
|
1049 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1050 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1051 { |
|
1052 // Leave if there's any error. |
|
1053 User::Leave(KErrNotFound); |
|
1054 } |
|
1055 |
|
1056 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1057 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
1058 |
|
1059 // |
|
1060 // Setting the port number and service center number of the wap address |
|
1061 // The service center number should be the same as the sim phone number used |
|
1062 // for test |
|
1063 // |
|
1064 TWapAddr wapAddr; |
|
1065 TWapAddr recvWapAddr; |
|
1066 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1067 TBuf8<100> scNumber; |
|
1068 scNumber.Copy(TelNumber); |
|
1069 TPtrC8 scAddr(scNumber); |
|
1070 wapAddr.SetWapAddress(scAddr); |
|
1071 |
|
1072 // |
|
1073 // Connect to socket server |
|
1074 // |
|
1075 RSocketServ socketServer; |
|
1076 User::LeaveIfError(socketServer.Connect()); |
|
1077 CleanupClosePushL(socketServer); |
|
1078 |
|
1079 // |
|
1080 // Define and open the socket |
|
1081 // |
|
1082 RSocket sock; |
|
1083 OpenSocketLC(socketServer, sock); |
|
1084 |
|
1085 // |
|
1086 // Waiting for the phone to be initialised |
|
1087 // |
|
1088 WaitForInitializeL(); |
|
1089 |
|
1090 TRequestStatus ioctlStatus; |
|
1091 TRequestStatus recvStatus; |
|
1092 TPckgBuf<TInt> length; |
|
1093 |
|
1094 // |
|
1095 // Indicating to the protocol that it's a new client |
|
1096 // |
|
1097 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1098 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1099 // |
|
1100 // Bind |
|
1101 // |
|
1102 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1103 |
|
1104 // |
|
1105 // Issue Ioctl for getting the length of the message |
|
1106 // |
|
1107 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
1108 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1109 // |
|
1110 // Get the size of the incomming push message |
|
1111 // |
|
1112 User::WaitForRequest(ioctlStatus); |
|
1113 User::LeaveIfError(ioctlStatus.Int()); |
|
1114 INFO_PRINTF1(_L("IOCTL completed...")); |
|
1115 // |
|
1116 // Allocate buffer |
|
1117 // |
|
1118 TBuf8<256> recvBuf1(length); |
|
1119 |
|
1120 // |
|
1121 // Receiving push datagram |
|
1122 // |
|
1123 sock.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
|
1124 User::WaitForRequest(recvStatus); |
|
1125 User::LeaveIfError(recvStatus.Int()); |
|
1126 INFO_PRINTF1(_L("Received the push message...")); |
|
1127 |
|
1128 // |
|
1129 // Confirm the receipt of the message to the client |
|
1130 // |
|
1131 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
1132 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
1133 |
|
1134 // |
|
1135 // Issue another Ioctl for getting the length of the message |
|
1136 // |
|
1137 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
1138 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1139 // |
|
1140 // Get the size of the second incomming push message |
|
1141 // |
|
1142 User::WaitForRequest(ioctlStatus); |
|
1143 User::LeaveIfError(ioctlStatus.Int()); |
|
1144 INFO_PRINTF1(_L("IOCTL completed...")); |
|
1145 // |
|
1146 // Allocate buffer |
|
1147 // |
|
1148 TBuf8<256> recvBuf2(length); |
|
1149 |
|
1150 // |
|
1151 // Receiving push datagram |
|
1152 // |
|
1153 sock.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
1154 User::WaitForRequest(recvStatus); |
|
1155 User::LeaveIfError(recvStatus.Int()); |
|
1156 INFO_PRINTF1(_L("Received the second push message...")); |
|
1157 // |
|
1158 // Compare the received message with the previous one |
|
1159 // They should be identical |
|
1160 // |
|
1161 TEST(recvBuf2.Compare(recvBuf1) == 0); |
|
1162 |
|
1163 // |
|
1164 // Confirm the receipt of the message to the client |
|
1165 // |
|
1166 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
1167 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
1168 |
|
1169 // |
|
1170 // Closing the socket |
|
1171 // |
|
1172 sock.Close(); |
|
1173 socketServer.Close(); |
|
1174 CleanupStack::PopAndDestroy(&sock); |
|
1175 CleanupStack::Pop(&socketServer); |
|
1176 |
|
1177 return TestStepResult(); |
|
1178 } |
|
1179 |
|
1180 |
|
1181 TVerdict CIoctlStep_9::doTestStepL() |
|
1182 /** |
|
1183 * Test step 9: |
|
1184 * Receive a 8-Bit push message (Old client testing) |
|
1185 * @return - TVerdict code |
|
1186 * |
|
1187 */ |
|
1188 { |
|
1189 INFO_PRINTF1(_L("IOCTL Test step 9: receive a push message (Testing old client)")); |
|
1190 |
|
1191 TPtrC16 TelNumber; |
|
1192 TInt port=226; |
|
1193 TInt testNumber = 9; |
|
1194 |
|
1195 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1196 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1197 { |
|
1198 // Leave if there's any error. |
|
1199 User::Leave(KErrNotFound); |
|
1200 } |
|
1201 |
|
1202 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1203 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
1204 |
|
1205 // |
|
1206 // Setting the port number and service center number of the wap address |
|
1207 // The service center number should be the same as the sim phone number used |
|
1208 // for test |
|
1209 // |
|
1210 TWapAddr wapAddr; |
|
1211 TWapAddr recvWapAddr; |
|
1212 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1213 |
|
1214 TBuf8<100> scNumber; |
|
1215 scNumber.Copy(TelNumber); |
|
1216 TPtrC8 scAddr(scNumber); |
|
1217 wapAddr.SetWapAddress(scAddr); |
|
1218 |
|
1219 // |
|
1220 // Connect to socket server |
|
1221 // |
|
1222 RSocketServ socketServer; |
|
1223 User::LeaveIfError(socketServer.Connect()); |
|
1224 CleanupClosePushL(socketServer); |
|
1225 |
|
1226 // |
|
1227 // Define and open the socket |
|
1228 // |
|
1229 RSocket sock; |
|
1230 OpenSocketLC(socketServer, sock); |
|
1231 |
|
1232 // |
|
1233 // Waiting for the phone to be initialised |
|
1234 // |
|
1235 WaitForInitializeL(); |
|
1236 |
|
1237 TRequestStatus recvStatus; |
|
1238 |
|
1239 // |
|
1240 // Bind |
|
1241 // |
|
1242 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1243 |
|
1244 // |
|
1245 // Receiving a datagram |
|
1246 // |
|
1247 TBuf8<256> recvBuf; |
|
1248 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
1249 User::WaitForRequest(recvStatus); |
|
1250 User::LeaveIfError(recvStatus.Int()); |
|
1251 INFO_PRINTF1(_L("Received the message...")); |
|
1252 |
|
1253 // |
|
1254 // Closing the socket |
|
1255 // |
|
1256 sock.Close(); |
|
1257 socketServer.Close(); |
|
1258 CleanupStack::PopAndDestroy(&sock); |
|
1259 CleanupStack::Pop(&socketServer); |
|
1260 |
|
1261 return TestStepResult(); |
|
1262 } |
|
1263 |
|
1264 |
|
1265 TVerdict CIoctlStep_10::doTestStepL() |
|
1266 /** |
|
1267 * Test step Ten: |
|
1268 * Sends/receives a 7Bit business card using IOCTL |
|
1269 * @return - TVerdict code |
|
1270 * |
|
1271 */ |
|
1272 { |
|
1273 INFO_PRINTF1(_L("IOCTL Test step 10: send/receive 7-Bit business card using IOCTL")); |
|
1274 |
|
1275 TPtrC TestData1; |
|
1276 TPtrC16 TelNumber; |
|
1277 TInt port=226; |
|
1278 TInt testNumber=10; |
|
1279 |
|
1280 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
1281 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1282 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1283 { |
|
1284 // Leave if there's any error. |
|
1285 User::Leave(KErrNotFound); |
|
1286 } |
|
1287 |
|
1288 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1289 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
1290 |
|
1291 // |
|
1292 // Setting the port number and service center number of the wap address |
|
1293 // The service center number should be the same as the sim phone number used |
|
1294 // for test (not required for SIM tsy) |
|
1295 // |
|
1296 TWapAddr wapAddr; |
|
1297 TWapAddr recvWapAddr; |
|
1298 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1299 |
|
1300 TBuf8<100> scNumber; |
|
1301 scNumber.Copy(TelNumber); |
|
1302 TPtrC8 scAddr(scNumber); |
|
1303 wapAddr.SetWapAddress(scAddr); |
|
1304 |
|
1305 // |
|
1306 // Connect to socket server |
|
1307 // |
|
1308 RSocketServ socketServer; |
|
1309 User::LeaveIfError(socketServer.Connect()); |
|
1310 CleanupClosePushL(socketServer); |
|
1311 |
|
1312 // |
|
1313 // Define and open the socket |
|
1314 // |
|
1315 RSocket sock; |
|
1316 OpenSocketLC(socketServer, sock); |
|
1317 |
|
1318 // |
|
1319 // Waiting for the phone to be initialised |
|
1320 // |
|
1321 WaitForInitializeL(); |
|
1322 |
|
1323 TRequestStatus ioctlStatus; |
|
1324 TRequestStatus recvStatus; |
|
1325 TPckgBuf<TInt> length; |
|
1326 |
|
1327 // |
|
1328 // Indicating to the protocol that it's a new client |
|
1329 // |
|
1330 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1331 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1332 // |
|
1333 // Bind |
|
1334 // |
|
1335 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1336 |
|
1337 // |
|
1338 // Send a calendar entry |
|
1339 // |
|
1340 TRequestStatus status; |
|
1341 |
|
1342 TBuf8<200> data; |
|
1343 data.Copy(TestData1); |
|
1344 sock.SendTo(data, wapAddr, 0, status); |
|
1345 User::WaitForRequest(status); |
|
1346 User::LeaveIfError(status.Int()); |
|
1347 INFO_PRINTF1(_L("Message sent...")); |
|
1348 |
|
1349 // |
|
1350 // Issue Ioctl for getting the length of the message |
|
1351 // |
|
1352 INFO_PRINTF1(_L("Issue of IOCTL for GetLength")); |
|
1353 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1354 |
|
1355 // |
|
1356 // Get the size of the first incomming message |
|
1357 // |
|
1358 User::WaitForRequest(ioctlStatus); |
|
1359 User::LeaveIfError(ioctlStatus.Int()); |
|
1360 INFO_PRINTF1(_L("IOCTL completed")); |
|
1361 // |
|
1362 // Check if reported length is correct |
|
1363 // |
|
1364 TBuf8<256> recvBuf(length); |
|
1365 TEST(length()==data.Length()); |
|
1366 |
|
1367 // |
|
1368 // Receiving a datagram |
|
1369 // |
|
1370 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
1371 User::WaitForRequest(recvStatus); |
|
1372 User::LeaveIfError(recvStatus.Int()); |
|
1373 INFO_PRINTF1(_L("Received the message...")); |
|
1374 TEST(recvBuf.Compare(data) == 0); |
|
1375 |
|
1376 // |
|
1377 // Confirm the receipt of the message to the client |
|
1378 // |
|
1379 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
1380 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
1381 |
|
1382 // |
|
1383 // Closing the socket |
|
1384 // |
|
1385 sock.Close(); |
|
1386 socketServer.Close(); |
|
1387 CleanupStack::PopAndDestroy(&sock); |
|
1388 CleanupStack::Pop(&socketServer); |
|
1389 |
|
1390 return TestStepResult(); |
|
1391 } |
|
1392 |
|
1393 |
|
1394 |
|
1395 TVerdict CIoctlStep_11::doTestStepL() |
|
1396 /** |
|
1397 * Test step 11: |
|
1398 * Test Cancel IOCTL |
|
1399 * @return - TVerdict code |
|
1400 * |
|
1401 */ |
|
1402 { |
|
1403 INFO_PRINTF1(_L("IOCTL Test step 11: Testing CancelIOCTL")); |
|
1404 |
|
1405 TPtrC16 TelNumber; |
|
1406 TInt port=226; |
|
1407 |
|
1408 |
|
1409 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1410 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1411 { |
|
1412 // Leave if there's any error. |
|
1413 User::Leave(KErrNotFound); |
|
1414 } |
|
1415 |
|
1416 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1417 |
|
1418 // |
|
1419 // Setting the port number and service center number of the wap address |
|
1420 // The service center number should be the same as the sim phone number used |
|
1421 // for test (not required for SIM tsy) |
|
1422 // |
|
1423 TWapAddr wapAddr; |
|
1424 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1425 |
|
1426 TBuf8<100> scNumber; |
|
1427 scNumber.Copy(TelNumber); |
|
1428 TPtrC8 scAddr(scNumber); |
|
1429 wapAddr.SetWapAddress(scAddr); |
|
1430 |
|
1431 // |
|
1432 // Connect to socket server |
|
1433 // |
|
1434 RSocketServ socketServer; |
|
1435 User::LeaveIfError(socketServer.Connect()); |
|
1436 CleanupClosePushL(socketServer); |
|
1437 |
|
1438 // |
|
1439 // Define and open the socket |
|
1440 // |
|
1441 RSocket sock; |
|
1442 OpenSocketLC(socketServer, sock); |
|
1443 |
|
1444 // |
|
1445 // Waiting for the phone to be initialised |
|
1446 // |
|
1447 WaitForInitializeL(); |
|
1448 |
|
1449 TRequestStatus ioctlStatus; |
|
1450 TPckgBuf<TInt> length; |
|
1451 |
|
1452 // |
|
1453 // Indicating to the protocol that it's a new client |
|
1454 // |
|
1455 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1456 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1457 // |
|
1458 // Bind |
|
1459 // |
|
1460 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1461 |
|
1462 // |
|
1463 // Issue Ioctl for getting the length of the message |
|
1464 // |
|
1465 INFO_PRINTF1(_L("Issue of IOCTL for GetLength")); |
|
1466 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1467 |
|
1468 // |
|
1469 // Issue Cancel Ioctl |
|
1470 // |
|
1471 INFO_PRINTF1(_L("Issue of cancel IOCTL for GetLength")); |
|
1472 sock.CancelIoctl(); |
|
1473 |
|
1474 // |
|
1475 // Check if the outstanding IOCTL has been canceled |
|
1476 // |
|
1477 TEST(ioctlStatus==KErrCancel); |
|
1478 |
|
1479 // |
|
1480 // Closing the socket |
|
1481 // |
|
1482 sock.Close(); |
|
1483 socketServer.Close(); |
|
1484 CleanupStack::PopAndDestroy(&sock); |
|
1485 CleanupStack::Pop(&socketServer); |
|
1486 |
|
1487 return TestStepResult(); |
|
1488 } |
|
1489 |
|
1490 |
|
1491 TVerdict CIoctlStep_12::doTestStepL() |
|
1492 /** |
|
1493 * Test step 12: |
|
1494 * Test issue IOCTL without SetOption NewStyleClient |
|
1495 * @return - TVerdict code |
|
1496 * |
|
1497 */ |
|
1498 { |
|
1499 INFO_PRINTF1(_L("IOCTL Test step 12: Test issue IOCTL without SetOption NewStyleClient")); |
|
1500 |
|
1501 TPtrC16 TelNumber; |
|
1502 TInt port=226; |
|
1503 |
|
1504 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1505 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1506 { |
|
1507 // Leave if there's any error. |
|
1508 User::Leave(KErrNotFound); |
|
1509 } |
|
1510 |
|
1511 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1512 |
|
1513 // |
|
1514 // Setting the port number and service center number of the wap address |
|
1515 // The service center number should be the same as the sim phone number used |
|
1516 // for test (not required for SIM tsy) |
|
1517 // |
|
1518 TWapAddr wapAddr; |
|
1519 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1520 |
|
1521 TBuf8<100> scNumber; |
|
1522 scNumber.Copy(TelNumber); |
|
1523 TPtrC8 scAddr(scNumber); |
|
1524 wapAddr.SetWapAddress(scAddr); |
|
1525 |
|
1526 // |
|
1527 // Connect to socket server |
|
1528 // |
|
1529 RSocketServ socketServer; |
|
1530 User::LeaveIfError(socketServer.Connect()); |
|
1531 CleanupClosePushL(socketServer); |
|
1532 |
|
1533 // |
|
1534 // Define and open the socket |
|
1535 // |
|
1536 RSocket sock; |
|
1537 OpenSocketLC(socketServer, sock); |
|
1538 |
|
1539 // |
|
1540 // Waiting for the phone to be initialised |
|
1541 // |
|
1542 WaitForInitializeL(); |
|
1543 |
|
1544 TRequestStatus ioctlStatus; |
|
1545 |
|
1546 TPckgBuf<TInt> length; |
|
1547 |
|
1548 // |
|
1549 // Bind |
|
1550 // |
|
1551 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1552 |
|
1553 // |
|
1554 // Issue Ioctl for getting the length of the message (should fail) |
|
1555 // |
|
1556 INFO_PRINTF1(_L("Issue of IOCTL for GetLength")); |
|
1557 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1558 User::WaitForRequest(ioctlStatus); |
|
1559 TEST(ioctlStatus!=KErrNone); |
|
1560 |
|
1561 // |
|
1562 // Closing the socket |
|
1563 // |
|
1564 sock.Close(); |
|
1565 socketServer.Close(); |
|
1566 CleanupStack::PopAndDestroy(&sock); |
|
1567 CleanupStack::Pop(&socketServer); |
|
1568 |
|
1569 return TestStepResult(); |
|
1570 } |
|
1571 |
|
1572 |
|
1573 |
|
1574 TVerdict CIoctlStep_13::doTestStepL() |
|
1575 /** |
|
1576 * Test step two: |
|
1577 * Sends/receives a 8-Bit calendar entry using IOCTL(two segments) |
|
1578 * @return - TVerdict code |
|
1579 * |
|
1580 */ |
|
1581 { |
|
1582 |
|
1583 INFO_PRINTF1(_L("IOCTL Test step 13: send/receive a 8-Bit VCal")); |
|
1584 |
|
1585 TPtrC TestData; |
|
1586 TPtrC16 TelNumber; |
|
1587 TInt port=226; |
|
1588 TInt testNumber = 13; |
|
1589 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData) || |
|
1590 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1591 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1592 { |
|
1593 // Leave if there's any error. |
|
1594 User::Leave(KErrNotFound); |
|
1595 } |
|
1596 |
|
1597 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1598 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
1599 |
|
1600 // |
|
1601 // Setting the port number and service center number of the wap address |
|
1602 // The service center number should be the same as the sim phone number used |
|
1603 // for test (not required for SIM Tsy) |
|
1604 // |
|
1605 TWapAddr wapAddr; |
|
1606 TWapAddr recvWapAddr; |
|
1607 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1608 TBuf8<100> scNumber; |
|
1609 scNumber.Copy(TelNumber); |
|
1610 TPtrC8 scAddr(scNumber); |
|
1611 wapAddr.SetWapAddress(scAddr); |
|
1612 |
|
1613 // |
|
1614 // Connect to socket server |
|
1615 // |
|
1616 RSocketServ socketServer; |
|
1617 User::LeaveIfError(socketServer.Connect()); |
|
1618 CleanupClosePushL(socketServer); |
|
1619 |
|
1620 // |
|
1621 // Define and open the socket |
|
1622 // |
|
1623 RSocket sock; |
|
1624 OpenSocketLC(socketServer, sock); |
|
1625 |
|
1626 // |
|
1627 // Waiting for the phone to be initialised |
|
1628 // |
|
1629 WaitForInitializeL(); |
|
1630 |
|
1631 TRequestStatus ioctlStatus; |
|
1632 TRequestStatus recvStatus; |
|
1633 TPckgBuf<TInt> length; |
|
1634 |
|
1635 // |
|
1636 // Indicating to the protocol that it's a new client |
|
1637 // |
|
1638 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1639 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1640 |
|
1641 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms8BitDCS)); |
|
1642 |
|
1643 // |
|
1644 // Bind |
|
1645 // |
|
1646 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1647 |
|
1648 // |
|
1649 // Issue Ioctl for getting the length of the message |
|
1650 // |
|
1651 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength")); |
|
1652 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1653 |
|
1654 // |
|
1655 // Send a calendar entry |
|
1656 // |
|
1657 TRequestStatus status; |
|
1658 |
|
1659 TBuf8<300> data; |
|
1660 data.Copy(TestData); |
|
1661 sock.SendTo(data, wapAddr, 0, status); |
|
1662 User::WaitForRequest(status); |
|
1663 User::LeaveIfError(status.Int()); |
|
1664 INFO_PRINTF1(_L("Message sent...")); |
|
1665 |
|
1666 // |
|
1667 // Get the size of the incomming message |
|
1668 // |
|
1669 User::WaitForRequest(ioctlStatus); |
|
1670 User::LeaveIfError(ioctlStatus.Int()); |
|
1671 INFO_PRINTF1(_L("IOCTL completed")); |
|
1672 // |
|
1673 // Check if reported length is correct |
|
1674 // |
|
1675 TBuf8<300> recvBuf(length); |
|
1676 TEST(length()==data.Length()); |
|
1677 |
|
1678 // |
|
1679 // Receiving a datagram |
|
1680 // |
|
1681 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
1682 User::WaitForRequest(recvStatus); |
|
1683 User::LeaveIfError(recvStatus.Int()); |
|
1684 INFO_PRINTF1(_L("Received the message...")); |
|
1685 TEST(recvBuf.Compare(data) == 0); |
|
1686 |
|
1687 // |
|
1688 // Confirm the receipt of the message to the client |
|
1689 // |
|
1690 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
1691 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
1692 |
|
1693 // |
|
1694 // Closing the socket |
|
1695 // |
|
1696 sock.Close(); |
|
1697 socketServer.Close(); |
|
1698 CleanupStack::PopAndDestroy(&sock); |
|
1699 CleanupStack::Pop(&socketServer); |
|
1700 |
|
1701 return TestStepResult(); |
|
1702 } |
|
1703 |
|
1704 |
|
1705 TVerdict CIoctlStep_14::doTestStepL() |
|
1706 /** |
|
1707 * |
|
1708 * Test step 14: |
|
1709 * simulating client crash conditions with 8bit calendar entry |
|
1710 * @return - TVerdict code |
|
1711 * |
|
1712 */ |
|
1713 { |
|
1714 INFO_PRINTF1(_L("IOCTL Test step 14: client crash condition 8-Bit calendar entry ")); |
|
1715 |
|
1716 TPtrC TestData; |
|
1717 TPtrC16 TelNumber; |
|
1718 TInt port=226; |
|
1719 TInt testNumber =14; |
|
1720 |
|
1721 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData) || |
|
1722 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1723 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1724 { |
|
1725 // Leave if there's any error. |
|
1726 User::Leave(KErrNotFound); |
|
1727 } |
|
1728 |
|
1729 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1730 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
1731 |
|
1732 // |
|
1733 // Setting the port number and service center number of the wap address |
|
1734 // The service center number should be the same as the sim phone number used |
|
1735 // for test |
|
1736 // |
|
1737 |
|
1738 TWapAddr wapAddr; |
|
1739 TWapAddr recvWapAddr; |
|
1740 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1741 TBuf8<100> scNumber; |
|
1742 scNumber.Copy(TelNumber); |
|
1743 TPtrC8 scAddr(scNumber); |
|
1744 wapAddr.SetWapAddress(scAddr); |
|
1745 |
|
1746 // |
|
1747 // Connect to socket server |
|
1748 // |
|
1749 RSocketServ socketServer; |
|
1750 User::LeaveIfError(socketServer.Connect()); |
|
1751 CleanupClosePushL(socketServer); |
|
1752 |
|
1753 // |
|
1754 // Define and open the socket |
|
1755 // |
|
1756 RSocket sock; |
|
1757 OpenSocketLC(socketServer, sock); |
|
1758 |
|
1759 // |
|
1760 // Waiting for the phone to be initialised |
|
1761 // |
|
1762 WaitForInitializeL(); |
|
1763 |
|
1764 TRequestStatus ioctlStatus; |
|
1765 TRequestStatus recvStatus; |
|
1766 TPckgBuf<TInt> length; |
|
1767 |
|
1768 // |
|
1769 // Indicating to the protocol that it's a new client |
|
1770 // |
|
1771 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1772 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1773 |
|
1774 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms8BitDCS)); |
|
1775 |
|
1776 // |
|
1777 // Bind |
|
1778 // |
|
1779 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1780 |
|
1781 // |
|
1782 // Issue Ioctl for getting the length of the message |
|
1783 // |
|
1784 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
1785 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1786 |
|
1787 // |
|
1788 // Send a Calendar entry |
|
1789 // |
|
1790 TRequestStatus status; |
|
1791 |
|
1792 TBuf8<300> data; |
|
1793 data.Copy(TestData); |
|
1794 sock.SendTo(data, wapAddr, 0, status); |
|
1795 User::WaitForRequest(status); |
|
1796 User::LeaveIfError(status.Int()); |
|
1797 INFO_PRINTF1(_L("Message sent...")); |
|
1798 // |
|
1799 // Get the size of the incomming message |
|
1800 // |
|
1801 User::WaitForRequest(ioctlStatus); |
|
1802 User::LeaveIfError(ioctlStatus.Int()); |
|
1803 INFO_PRINTF1(_L("IOCTL completed...")); |
|
1804 // |
|
1805 // Check if reported length is correct |
|
1806 // |
|
1807 TBuf8<300> recvBuf(length); |
|
1808 TEST(length()==data.Length()); |
|
1809 |
|
1810 // |
|
1811 // Receiving a datagram |
|
1812 // |
|
1813 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
1814 User::WaitForRequest(recvStatus); |
|
1815 User::LeaveIfError(recvStatus.Int()); |
|
1816 INFO_PRINTF1(_L("Received the message...")); |
|
1817 // |
|
1818 // Close socket |
|
1819 // |
|
1820 sock.Close(); |
|
1821 INFO_PRINTF1(_L("Socket was closed...")); |
|
1822 // |
|
1823 // Open the socket |
|
1824 // |
|
1825 OpenSocketL(socketServer, sock); |
|
1826 INFO_PRINTF1(_L("Socket was opened...")); |
|
1827 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1828 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1829 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1830 // |
|
1831 // Issue another get length of datagram as if not aware of the previous message |
|
1832 // |
|
1833 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
1834 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1835 // |
|
1836 // waiting for request to be completed |
|
1837 // |
|
1838 User::WaitForRequest(ioctlStatus); |
|
1839 User::LeaveIfError(ioctlStatus.Int()); |
|
1840 INFO_PRINTF1(_L("IOCTL completed...")); |
|
1841 // |
|
1842 // Check if reported length is correct |
|
1843 // |
|
1844 TBuf8<300> newRecvBuf(length); |
|
1845 TEST(length()==data.Length()); |
|
1846 |
|
1847 // |
|
1848 // New message retrieved from SAR store |
|
1849 // |
|
1850 sock.RecvFrom(newRecvBuf,recvWapAddr,0,recvStatus); |
|
1851 User::WaitForRequest(recvStatus); |
|
1852 User::LeaveIfError(recvStatus.Int()); |
|
1853 INFO_PRINTF1(_L("Received the message...")); |
|
1854 TEST(newRecvBuf.Compare(data) == 0); |
|
1855 |
|
1856 // |
|
1857 // Confirm the receipt of the message to the client |
|
1858 // |
|
1859 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
1860 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
1861 |
|
1862 // |
|
1863 // Closing the socket |
|
1864 // |
|
1865 sock.Close(); |
|
1866 socketServer.Close(); |
|
1867 CleanupStack::PopAndDestroy(&sock); |
|
1868 CleanupStack::Pop(&socketServer); |
|
1869 |
|
1870 return TestStepResult(); |
|
1871 } |
|
1872 |
|
1873 |
|
1874 TVerdict CIoctlStep_15::doTestStepL() |
|
1875 /** |
|
1876 * Test step fifteen: |
|
1877 * Receives a 7Bit v-card using IOCTL with concatenation for new style client |
|
1878 * @return - TVerdict code |
|
1879 * |
|
1880 */ |
|
1881 { |
|
1882 INFO_PRINTF1(_L("IOCTL Test step 15: send/receive 7-Bit v-card")); |
|
1883 |
|
1884 TPtrC16 TelNumber; |
|
1885 TInt port=9204; |
|
1886 TInt testNumber=15; |
|
1887 |
|
1888 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1889 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
1890 { |
|
1891 // Leave if there's any error. |
|
1892 User::Leave(KErrNotFound); |
|
1893 } |
|
1894 |
|
1895 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
1896 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
1897 |
|
1898 // |
|
1899 // Setting the port number and service center number of the wap address |
|
1900 // The service center number should be the same as the sim phone number used |
|
1901 // for test (not required for SIM tsy) |
|
1902 // |
|
1903 TWapAddr wapAddr; |
|
1904 TWapAddr recvWapAddr; |
|
1905 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
1906 |
|
1907 TBuf8<100> scNumber; |
|
1908 scNumber.Copy(TelNumber); |
|
1909 TPtrC8 scAddr(scNumber); |
|
1910 wapAddr.SetWapAddress(scAddr); |
|
1911 |
|
1912 // |
|
1913 // Connect to socket server |
|
1914 // |
|
1915 RSocketServ socketServer; |
|
1916 User::LeaveIfError(socketServer.Connect()); |
|
1917 CleanupClosePushL(socketServer); |
|
1918 |
|
1919 // |
|
1920 // Define and open the socket |
|
1921 // |
|
1922 RSocket sock; |
|
1923 OpenSocketLC(socketServer, sock); |
|
1924 |
|
1925 // |
|
1926 // Waiting for the phone to be initialised |
|
1927 // |
|
1928 WaitForInitializeL(); |
|
1929 |
|
1930 TRequestStatus ioctlStatus; |
|
1931 TRequestStatus recvStatus; |
|
1932 TPckgBuf<TInt> length; |
|
1933 |
|
1934 // |
|
1935 // Indicating to the protocol that it's a new client |
|
1936 // |
|
1937 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1938 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1939 // |
|
1940 // Bind |
|
1941 // |
|
1942 User::LeaveIfError(sock.Bind(wapAddr)); |
|
1943 |
|
1944 // |
|
1945 // Issue Ioctl for getting the length of the message |
|
1946 // |
|
1947 INFO_PRINTF1(_L("Issue of IOCTL for GetLength")); |
|
1948 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
1949 |
|
1950 // |
|
1951 // Get the size of the first incoming message |
|
1952 // |
|
1953 User::WaitForRequest(ioctlStatus); |
|
1954 User::LeaveIfError(ioctlStatus.Int()); |
|
1955 INFO_PRINTF1(_L("IOCTL completed")); |
|
1956 |
|
1957 TBuf8<360> recvBuf(length); |
|
1958 |
|
1959 // |
|
1960 // Receiving a datagram that is 7bit with a concatenated length of > 160 characters |
|
1961 // |
|
1962 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
1963 User::WaitForRequest(recvStatus); |
|
1964 User::LeaveIfError(recvStatus.Int()); |
|
1965 INFO_PRINTF1(_L("Received the message...")); |
|
1966 |
|
1967 // |
|
1968 // Confirm the receipt of the message to the client |
|
1969 // |
|
1970 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
1971 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
1972 |
|
1973 // |
|
1974 // Closing the socket |
|
1975 // |
|
1976 sock.Close(); |
|
1977 socketServer.Close(); |
|
1978 CleanupStack::PopAndDestroy(&sock); |
|
1979 CleanupStack::Pop(&socketServer); |
|
1980 |
|
1981 return TestStepResult(); |
|
1982 } |
|
1983 |
|
1984 |
|
1985 TInt CBackupRestoreStep::SendWapL() |
|
1986 { |
|
1987 //modified from test 10 |
|
1988 INFO_PRINTF1(_L("SendWapL: send 7-Bit business card using IOCTL")); |
|
1989 |
|
1990 TInt ret = KErrNone; |
|
1991 TPtrC TestData1; |
|
1992 TPtrC16 TelNumber; |
|
1993 TInt port=226; |
|
1994 |
|
1995 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
1996 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
1997 !GetIntFromConfig(ConfigSection(),KWapPort,port) |
|
1998 ) |
|
1999 { |
|
2000 // Leave if there's any error. |
|
2001 User::Leave(KErrNotFound); |
|
2002 } |
|
2003 |
|
2004 |
|
2005 // |
|
2006 // Setting the port number and service center number of the wap address |
|
2007 // The service center number should be the same as the sim phone number used |
|
2008 // for test (not required for SIM tsy) |
|
2009 // |
|
2010 TWapAddr wapAddr; |
|
2011 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
2012 |
|
2013 TBuf8<100> scNumber; |
|
2014 scNumber.Copy(TelNumber); |
|
2015 TPtrC8 scAddr(scNumber); |
|
2016 wapAddr.SetWapAddress(scAddr); |
|
2017 |
|
2018 |
|
2019 |
|
2020 // |
|
2021 // Define and open the socket |
|
2022 // |
|
2023 RSocket sock; |
|
2024 ret = sock.Open(iSocketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol); |
|
2025 if (ret != KErrNone) |
|
2026 { |
|
2027 // |
|
2028 // PREQ399 changes mean that -1 is sometimes now returned from Open() when |
|
2029 // a Backup and Restore session is in progress (DEF114381). |
|
2030 // |
|
2031 INFO_PRINTF2(_L("Socket could not be opened (error %d)..."), ret); |
|
2032 |
|
2033 return ret; |
|
2034 } |
|
2035 CleanupClosePushL(sock); |
|
2036 |
|
2037 // |
|
2038 // Waiting for the phone to be initialised |
|
2039 // |
|
2040 WaitForInitializeL(); |
|
2041 |
|
2042 TRequestStatus status; |
|
2043 |
|
2044 // |
|
2045 // Indicating to the protocol that it's a new client |
|
2046 // |
|
2047 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2048 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
2049 // |
|
2050 // Bind |
|
2051 // |
|
2052 User::LeaveIfError(sock.Bind(wapAddr)); |
|
2053 |
|
2054 // |
|
2055 // Send a calendar entry |
|
2056 // |
|
2057 TBuf8<200> data; |
|
2058 data.Copy(TestData1); |
|
2059 sock.SendTo(data, wapAddr, 0, status); |
|
2060 User::WaitForRequest(status); |
|
2061 ret = status.Int(); |
|
2062 |
|
2063 if(ret == KErrNone) |
|
2064 { |
|
2065 INFO_PRINTF1(_L("Message sent...")); |
|
2066 } |
|
2067 else |
|
2068 { |
|
2069 INFO_PRINTF2(_L("Message NOT sent (error %d)..."), ret); |
|
2070 } |
|
2071 |
|
2072 |
|
2073 // |
|
2074 // Closing the socket |
|
2075 // |
|
2076 sock.Close(); |
|
2077 |
|
2078 CleanupStack::PopAndDestroy(&sock); |
|
2079 |
|
2080 |
|
2081 return ret; |
|
2082 } |
|
2083 |
|
2084 TBool CBackupRestoreStep::IsWapFileOpenL() |
|
2085 { |
|
2086 TBool ret = ETrue; //assume the file was open |
|
2087 RFs fsSession; |
|
2088 User::LeaveIfError(fsSession.Connect()); |
|
2089 CleanupClosePushL(fsSession); |
|
2090 |
|
2091 CFileMan* fileManager = CFileMan::NewL(fsSession); |
|
2092 CleanupStack::PushL(fileManager); |
|
2093 |
|
2094 _LIT(KWapFile,"C:\\Private\\101F7989\\sms\\wapreast.dat"); |
|
2095 _LIT(KWapFileBackup,"C:\\Private\\101f7989\\sms\\wapreast.backup"); |
|
2096 |
|
2097 TEntry entry; |
|
2098 if (fsSession.Entry(KWapFile,entry)==KErrNone) // File found |
|
2099 { |
|
2100 TInt moveStatus = fileManager->Move(KWapFile,KWapFileBackup); |
|
2101 TESTL(moveStatus == KErrNone || moveStatus == KErrInUse); |
|
2102 |
|
2103 // If the move was successful, the file is not opened |
|
2104 // If the move failed with KErrInUse the file is opened |
|
2105 if (moveStatus == KErrNone) |
|
2106 { |
|
2107 // move it back |
|
2108 TEST(fileManager->Move(KWapFileBackup,KWapFile) == KErrNone); |
|
2109 ret = EFalse; |
|
2110 } |
|
2111 else // moveStatus == KErrInUse |
|
2112 { |
|
2113 ret = ETrue; |
|
2114 } |
|
2115 } |
|
2116 else |
|
2117 { |
|
2118 //file not found so it couldn't be open |
|
2119 ret = EFalse; |
|
2120 } |
|
2121 |
|
2122 CleanupStack::PopAndDestroy(fileManager); |
|
2123 CleanupStack::PopAndDestroy(&fsSession); |
|
2124 |
|
2125 if(ret) |
|
2126 INFO_PRINTF1(_L("Wapfile open...")); |
|
2127 else |
|
2128 INFO_PRINTF1(_L("Wapfile closed...")); |
|
2129 |
|
2130 return ret; |
|
2131 } |
|
2132 |
|
2133 TVerdict CBackupRestoreStep::doTestStepL() |
|
2134 /** |
|
2135 * |
|
2136 * Test step 16: |
|
2137 * simulating backup and restore |
|
2138 * @return - TVerdict code |
|
2139 * |
|
2140 */ |
|
2141 { |
|
2142 TInt testNumber =16; |
|
2143 RProperty testNumberProperty; |
|
2144 |
|
2145 User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
|
2146 CleanupClosePushL(testNumberProperty); |
|
2147 |
|
2148 TRequestStatus status; |
|
2149 testNumberProperty.Subscribe(status); |
|
2150 User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNumber)); |
|
2151 User::WaitForRequest(status); |
|
2152 User::LeaveIfError(status.Int()); |
|
2153 TInt testNumberCheck; |
|
2154 User::LeaveIfError(testNumberProperty.Get(testNumberCheck)); |
|
2155 if (testNumber != testNumberCheck) |
|
2156 User::Leave(KErrNotFound); |
|
2157 |
|
2158 // |
|
2159 // Connect to socket server |
|
2160 // |
|
2161 User::LeaveIfError(iSocketServer.Connect()); |
|
2162 |
|
2163 INFO_PRINTF1(_L("IOCTL Test step 16: send 7-Bit business card using IOCTL to test backup and restore")); |
|
2164 |
|
2165 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
|
2166 TEST(SendWapL() == KErrNone); |
|
2167 TEST(IsWapFileOpenL() != EFalse); |
|
2168 |
|
2169 // Notify the WAPPROT server that a backup is about to take place and |
|
2170 // that the server should close the wapstor |
|
2171 INFO_PRINTF1(_L("Simulating a backup notification")); |
|
2172 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
2173 EBURBackupFull, EBackupBase); |
|
2174 |
|
2175 INFO_PRINTF1(_L("Expecting SendWapL to fail and the wap data file to be closed")); |
|
2176 TEST(SendWapL() != KErrNone); |
|
2177 TEST(IsWapFileOpenL() == EFalse); |
|
2178 |
|
2179 // Notify the WAPPROT server that a backup has completed |
|
2180 // that the server should open the wapstor |
|
2181 INFO_PRINTF1(_L("Simulating a backup complete notification")); |
|
2182 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
2183 EBURNormal, ENoBackup); |
|
2184 |
|
2185 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
|
2186 TEST(SendWapL() == KErrNone); |
|
2187 TEST(IsWapFileOpenL() != EFalse); |
|
2188 |
|
2189 // Notify the WAPPROT server that a restore is about to take place and |
|
2190 // that the server should close the wapstor |
|
2191 INFO_PRINTF1(_L("Simulating a restore notification")); |
|
2192 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
2193 EBURRestorePartial, EBackupIncrement); |
|
2194 |
|
2195 INFO_PRINTF1(_L("Expecting SendWapL to fail and the wap data file to be closed")); |
|
2196 TEST(SendWapL() != KErrNone); |
|
2197 TEST(IsWapFileOpenL() == EFalse); |
|
2198 |
|
2199 // Notify the WAPPROT server that a restore has completed |
|
2200 // that the server should open the wapstor |
|
2201 INFO_PRINTF1(_L("Simulating a restore complete notification")); |
|
2202 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
|
2203 EBURNormal, ENoBackup); |
|
2204 |
|
2205 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
|
2206 TEST(SendWapL() == KErrNone); |
|
2207 TEST(IsWapFileOpenL() != EFalse); |
|
2208 |
|
2209 INFO_PRINTF1(_L("Closing SocketServer ...")); |
|
2210 iSocketServer.Close(); |
|
2211 |
|
2212 CleanupStack::PopAndDestroy(&testNumberProperty); |
|
2213 return TestStepResult(); |
|
2214 } |
|
2215 |
|
2216 TVerdict CIoctlStep_17::doTestStepL() |
|
2217 /** |
|
2218 * Test step seventeen: |
|
2219 * Sends a 7_Bit business card. Using IOCTL query SMS transport parameters |
|
2220 * @return - TVerdict code |
|
2221 * |
|
2222 */ |
|
2223 { |
|
2224 INFO_PRINTF1(_L("IOCTL Test step 17: send 7-Bit v-card and query SMS transport parameters")); |
|
2225 |
|
2226 TInt result = KErrNone; |
|
2227 TPtrC TestData1; |
|
2228 TPtrC16 TelNumber; |
|
2229 TInt port=226; |
|
2230 TInt testNumber=1; |
|
2231 |
|
2232 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
2233 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
2234 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
2235 { |
|
2236 result = KErrNotFound; |
|
2237 } |
|
2238 |
|
2239 TESTL(result==KErrNone); |
|
2240 |
|
2241 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
2242 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
2243 |
|
2244 // |
|
2245 // Setting the port number and service center number of the wap address |
|
2246 // The service center number should be the same as the sim phone number used |
|
2247 // for test (not required for SIM tsy) |
|
2248 // |
|
2249 TWapAddr wapAddr; |
|
2250 TWapAddr recvWapAddr; |
|
2251 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
2252 |
|
2253 TBuf8<100> scNumber; |
|
2254 scNumber.Copy(TelNumber); |
|
2255 TPtrC8 scAddr(scNumber); |
|
2256 wapAddr.SetWapAddress(scAddr); |
|
2257 |
|
2258 // |
|
2259 // Connect to socket server |
|
2260 // |
|
2261 RSocketServ socketServer; |
|
2262 User::LeaveIfError(socketServer.Connect()); |
|
2263 CleanupClosePushL(socketServer); |
|
2264 |
|
2265 // |
|
2266 // Define and open the socket |
|
2267 // |
|
2268 RSocket sock; |
|
2269 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
2270 CleanupClosePushL(sock); |
|
2271 |
|
2272 // |
|
2273 // Waiting for the phone to be initialised |
|
2274 // |
|
2275 WaitForInitializeL(); |
|
2276 |
|
2277 // |
|
2278 // Indicating to the protocol that it's a new client |
|
2279 // |
|
2280 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2281 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
2282 |
|
2283 // |
|
2284 // Bind |
|
2285 // |
|
2286 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
2287 |
|
2288 // |
|
2289 // Send a business card |
|
2290 // |
|
2291 TRequestStatus status; |
|
2292 TBuf8<200> data; |
|
2293 data.Copy(TestData1); |
|
2294 sock.SendTo(data, wapAddr, 0, status); |
|
2295 User::WaitForRequest(status); |
|
2296 TESTL(status.Int()==KErrNone); |
|
2297 INFO_PRINTF1(_L("Message sent...")); |
|
2298 |
|
2299 // |
|
2300 // Create a descriptor with correct size for obtaining the message parameter |
|
2301 // |
|
2302 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2303 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
2304 |
|
2305 // |
|
2306 // Get the message parameter value |
|
2307 // |
|
2308 GetMessageParameterL(sock, parameterStorePtr); |
|
2309 |
|
2310 // |
|
2311 // Internalise the message parameter and check |
|
2312 // |
|
2313 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
2314 |
|
2315 CleanupStack::PopAndDestroy(parameterStore); |
|
2316 |
|
2317 // |
|
2318 // Closing the socket |
|
2319 // |
|
2320 CleanupStack::PopAndDestroy(&sock); |
|
2321 CleanupStack::PopAndDestroy(&socketServer); |
|
2322 |
|
2323 return TestStepResult(); |
|
2324 } |
|
2325 |
|
2326 TVerdict CIoctlStep_18::doTestStepL() |
|
2327 /** |
|
2328 * Test step eighteen: |
|
2329 * Sends a 7-Bit calendar entry (two segments). Using IOCTL query SMS transport parameters. |
|
2330 * @return - TVerdict code |
|
2331 * |
|
2332 */ |
|
2333 { |
|
2334 INFO_PRINTF1(_L("IOCTL Test step 18: Sends a 7-Bit calendar entry (two segments). Using IOCTL query SMS transport parameters.")); |
|
2335 |
|
2336 TInt result = KErrNone; |
|
2337 TPtrC TestData; |
|
2338 TPtrC16 TelNumber; |
|
2339 TInt port=226; |
|
2340 TInt testNumber = 2; |
|
2341 |
|
2342 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData) || |
|
2343 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
2344 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
2345 { |
|
2346 result = KErrNotFound; |
|
2347 } |
|
2348 |
|
2349 TESTL(result==KErrNone); |
|
2350 |
|
2351 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
2352 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
2353 |
|
2354 // |
|
2355 // Setting the port number and service center number of the wap address |
|
2356 // The service center number should be the same as the sim phone number used |
|
2357 // for test (not required for SIM Tsy) |
|
2358 // |
|
2359 TWapAddr wapAddr; |
|
2360 TWapAddr recvWapAddr; |
|
2361 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
2362 TBuf8<100> scNumber; |
|
2363 scNumber.Copy(TelNumber); |
|
2364 TPtrC8 scAddr(scNumber); |
|
2365 wapAddr.SetWapAddress(scAddr); |
|
2366 |
|
2367 // |
|
2368 // Connect to socket server |
|
2369 // |
|
2370 RSocketServ socketServer; |
|
2371 User::LeaveIfError(socketServer.Connect()); |
|
2372 CleanupClosePushL(socketServer); |
|
2373 |
|
2374 // |
|
2375 // Define and open the socket |
|
2376 // |
|
2377 RSocket sock; |
|
2378 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
2379 CleanupClosePushL(sock); |
|
2380 |
|
2381 // |
|
2382 // Waiting for the phone to be initialised |
|
2383 // |
|
2384 WaitForInitializeL(); |
|
2385 |
|
2386 // |
|
2387 // Indicating to the protocol that it's a new client |
|
2388 // |
|
2389 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2390 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
2391 // |
|
2392 // Bind |
|
2393 // |
|
2394 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
2395 |
|
2396 // |
|
2397 // Send a calendar entry |
|
2398 // |
|
2399 TRequestStatus status; |
|
2400 TBuf8<300> data; |
|
2401 data.Copy(TestData); |
|
2402 sock.SendTo(data, wapAddr, 0, status); |
|
2403 User::WaitForRequest(status); |
|
2404 TESTL(status.Int()==KErrNone); |
|
2405 INFO_PRINTF1(_L("Message sent...")); |
|
2406 |
|
2407 // |
|
2408 // Create a descriptor with correct size for obtaining the message parameter |
|
2409 // |
|
2410 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2411 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
2412 |
|
2413 // |
|
2414 // Get the message parameter value |
|
2415 // |
|
2416 GetMessageParameterL(sock, parameterStorePtr); |
|
2417 |
|
2418 // |
|
2419 // Internalise the message parameter and check |
|
2420 // |
|
2421 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
2422 |
|
2423 CleanupStack::PopAndDestroy(parameterStore); |
|
2424 |
|
2425 // |
|
2426 // Closing the socket |
|
2427 |
|
2428 CleanupStack::PopAndDestroy(&sock); |
|
2429 CleanupStack::PopAndDestroy(&socketServer); |
|
2430 |
|
2431 return TestStepResult(); |
|
2432 } |
|
2433 |
|
2434 TVerdict CIoctlStep_19::doTestStepL() |
|
2435 /** |
|
2436 * Test step 19: |
|
2437 * send/receive one 7-Bit two segments message and one 7-Bit one segment message |
|
2438 * @return - TVerdict code |
|
2439 * |
|
2440 */ |
|
2441 { |
|
2442 INFO_PRINTF1(_L("IOCTL Test step 19: send/receive two 7-Bit messages")); |
|
2443 |
|
2444 TInt result = KErrNone; |
|
2445 TPtrC TestData1; |
|
2446 TPtrC TestData2; |
|
2447 TPtrC16 TelNumber; |
|
2448 TInt port=226; |
|
2449 TInt testNumber = 3; |
|
2450 |
|
2451 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
2452 !GetStringFromConfig(ConfigSection(),KTestData2, TestData2) || |
|
2453 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
2454 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
2455 { |
|
2456 result = KErrNotFound; |
|
2457 } |
|
2458 |
|
2459 TESTL(result==KErrNone); |
|
2460 |
|
2461 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
2462 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
2463 |
|
2464 // |
|
2465 // Setting the port number and service center number of the wap address |
|
2466 // The service center number should be the same as the sim phone number used |
|
2467 // for test |
|
2468 // |
|
2469 TWapAddr wapAddr; |
|
2470 TWapAddr recvWapAddr; |
|
2471 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
2472 TBuf8<100> scNumber; |
|
2473 scNumber.Copy(TelNumber); |
|
2474 TPtrC8 scAddr(scNumber); |
|
2475 wapAddr.SetWapAddress(scAddr); |
|
2476 |
|
2477 // |
|
2478 // Connect to socket server |
|
2479 // |
|
2480 RSocketServ socketServer; |
|
2481 User::LeaveIfError(socketServer.Connect()); |
|
2482 CleanupClosePushL(socketServer); |
|
2483 |
|
2484 // |
|
2485 // Define and open the socket |
|
2486 // |
|
2487 RSocket sock; |
|
2488 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
2489 CleanupClosePushL(sock); |
|
2490 |
|
2491 // |
|
2492 // Waiting for the phone to be initialised |
|
2493 // |
|
2494 WaitForInitializeL(); |
|
2495 |
|
2496 TRequestStatus ioctlStatus; |
|
2497 TRequestStatus recvStatus; |
|
2498 TPckgBuf<TInt> length; |
|
2499 |
|
2500 // |
|
2501 // Indicating to the protocol that it's a new client |
|
2502 // |
|
2503 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2504 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
2505 // |
|
2506 // Bind |
|
2507 // |
|
2508 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
2509 |
|
2510 // |
|
2511 // Issue Ioctl for getting the length of the message |
|
2512 // |
|
2513 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
2514 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
2515 |
|
2516 // |
|
2517 // Send a calendar entry |
|
2518 // |
|
2519 TRequestStatus status; |
|
2520 |
|
2521 TBuf8<300> data2; |
|
2522 data2.Copy(TestData2); |
|
2523 sock.SendTo(data2, wapAddr, 0, status); |
|
2524 User::WaitForRequest(status); |
|
2525 TESTL(status.Int()==KErrNone); |
|
2526 INFO_PRINTF1(_L("First message sent...")); |
|
2527 // |
|
2528 // Send a business card |
|
2529 // |
|
2530 TBuf8<200> data1; |
|
2531 data1.Copy(TestData1); |
|
2532 sock.SendTo(data1, wapAddr, 0, status); |
|
2533 User::WaitForRequest(status); |
|
2534 TESTL(status.Int()==KErrNone); |
|
2535 INFO_PRINTF1(_L("Second message sent...")); |
|
2536 // |
|
2537 // Get the size of the first incoming message |
|
2538 // |
|
2539 User::WaitForRequest(ioctlStatus); |
|
2540 TESTL(ioctlStatus.Int()==KErrNone); |
|
2541 INFO_PRINTF1(_L("IOCTL for GetLength completed...")); |
|
2542 TBuf8<256> recvBuf2(length); |
|
2543 |
|
2544 INFO_PRINTF1(_L("Getting parameter value of first message...")); |
|
2545 |
|
2546 // |
|
2547 // Create a descriptor with correct size for obtaining the first message parameter |
|
2548 // |
|
2549 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2550 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
2551 |
|
2552 // |
|
2553 // Get the first message parameter value |
|
2554 // |
|
2555 GetMessageParameterL(sock, parameterStorePtr); |
|
2556 |
|
2557 // |
|
2558 // Internalise the first message parameter and check |
|
2559 // |
|
2560 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
2561 |
|
2562 CleanupStack::PopAndDestroy(parameterStore); |
|
2563 |
|
2564 // |
|
2565 // Receiving a datagram |
|
2566 // |
|
2567 sock.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
2568 User::WaitForRequest(recvStatus); |
|
2569 TESTL(recvStatus.Int()==KErrNone); |
|
2570 INFO_PRINTF1(_L("Received the first message...")); |
|
2571 |
|
2572 // |
|
2573 // Confirm the receipt of the message to the client |
|
2574 // |
|
2575 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
2576 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
|
2577 |
|
2578 // |
|
2579 // Issue Ioctl for getting the length of the second message |
|
2580 // |
|
2581 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
2582 INFO_PRINTF1(_L("Issue of the 2nd IOCTL for GetLength")); |
|
2583 |
|
2584 // |
|
2585 // Get the size of the SECOND incoming message |
|
2586 // |
|
2587 User::WaitForRequest(ioctlStatus); |
|
2588 TESTL(ioctlStatus.Int()==KErrNone); |
|
2589 INFO_PRINTF1(_L("IOCTL completed")); |
|
2590 |
|
2591 // |
|
2592 // Check if reported length is correct |
|
2593 // |
|
2594 TBuf8<256> recvBuf1(length); |
|
2595 TESTL(length()==data1.Length()); |
|
2596 |
|
2597 INFO_PRINTF1(_L("Getting parameter value of second message...")); |
|
2598 |
|
2599 // |
|
2600 // Create a descriptor with correct size for obtaining the second message parameter |
|
2601 // |
|
2602 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2603 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
|
2604 |
|
2605 // |
|
2606 // Get the second message parameter value |
|
2607 // |
|
2608 GetMessageParameterL(sock, parameterStorePtr2); |
|
2609 |
|
2610 // |
|
2611 // Internalise the second message parameter and check |
|
2612 // |
|
2613 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
|
2614 |
|
2615 CleanupStack::PopAndDestroy(parameterStore2); |
|
2616 |
|
2617 // |
|
2618 // Receiving the second message |
|
2619 // |
|
2620 sock.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
|
2621 User::WaitForRequest(recvStatus); |
|
2622 TESTL(recvStatus.Int()==KErrNone); |
|
2623 INFO_PRINTF1(_L("Receievd the second datagram")); |
|
2624 TEST(recvBuf1.Compare(data1) == 0); |
|
2625 |
|
2626 // |
|
2627 // Confirm the receipt of the second message to the client |
|
2628 // |
|
2629 INFO_PRINTF1(_L("Socket set option for indicating receipt of the second message")); |
|
2630 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
|
2631 |
|
2632 // |
|
2633 // Closing the socket |
|
2634 // |
|
2635 CleanupStack::PopAndDestroy(&sock); |
|
2636 CleanupStack::PopAndDestroy(&socketServer); |
|
2637 |
|
2638 return TestStepResult(); |
|
2639 } |
|
2640 |
|
2641 TVerdict CIoctlStep_20::doTestStepL() |
|
2642 /** |
|
2643 * |
|
2644 * Test step 20: |
|
2645 * simulating client crash conditions with 7bit message |
|
2646 * @return - TVerdict code |
|
2647 * |
|
2648 */ |
|
2649 { |
|
2650 INFO_PRINTF1(_L("IOCTL Test step 20: client crash condition 7-Bit message ")); |
|
2651 |
|
2652 TInt result = KErrNone; |
|
2653 TPtrC TestData; |
|
2654 TPtrC16 TelNumber; |
|
2655 TInt port=226; |
|
2656 TInt testNumber =4; |
|
2657 |
|
2658 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData) || |
|
2659 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
2660 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
2661 { |
|
2662 result=KErrNotFound; |
|
2663 } |
|
2664 |
|
2665 TESTL(result==KErrNone); |
|
2666 |
|
2667 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
2668 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
2669 |
|
2670 // |
|
2671 // Setting the port number and service center number of the wap address |
|
2672 // The service center number should be the same as the sim phone number used |
|
2673 // for test |
|
2674 // |
|
2675 TWapAddr wapAddr; |
|
2676 TWapAddr recvWapAddr; |
|
2677 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
2678 TBuf8<100> scNumber; |
|
2679 scNumber.Copy(TelNumber); |
|
2680 TPtrC8 scAddr(scNumber); |
|
2681 wapAddr.SetWapAddress(scAddr); |
|
2682 |
|
2683 // |
|
2684 // Connect to socket server |
|
2685 // |
|
2686 RSocketServ socketServer; |
|
2687 User::LeaveIfError(socketServer.Connect()); |
|
2688 CleanupClosePushL(socketServer); |
|
2689 |
|
2690 // |
|
2691 // Define and open the socket |
|
2692 // |
|
2693 RSocket sock; |
|
2694 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
2695 CleanupClosePushL(sock); |
|
2696 |
|
2697 // |
|
2698 // Waiting for the phone to be initialised |
|
2699 // |
|
2700 WaitForInitializeL(); |
|
2701 |
|
2702 TRequestStatus ioctlStatus; |
|
2703 TRequestStatus recvStatus; |
|
2704 TPckgBuf<TInt> length; |
|
2705 |
|
2706 // |
|
2707 // Indicating to the protocol that it's a new client |
|
2708 // |
|
2709 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2710 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
2711 // |
|
2712 // Bind |
|
2713 // |
|
2714 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
2715 |
|
2716 // |
|
2717 // Issue Ioctl for getting the length of the message |
|
2718 // |
|
2719 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
2720 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
2721 |
|
2722 // |
|
2723 // Send a business card |
|
2724 // |
|
2725 TRequestStatus status; |
|
2726 TBuf8<200> data; |
|
2727 data.Copy(TestData); |
|
2728 sock.SendTo(data, wapAddr, 0, status); |
|
2729 User::WaitForRequest(status); |
|
2730 TESTL(status.Int()==KErrNone); |
|
2731 INFO_PRINTF1(_L("Message sent...")); |
|
2732 // |
|
2733 // Get the size of the incoming message |
|
2734 // |
|
2735 User::WaitForRequest(ioctlStatus); |
|
2736 TESTL(ioctlStatus.Int()==KErrNone); |
|
2737 INFO_PRINTF1(_L("IOCTL completed...")); |
|
2738 // |
|
2739 // Check if reported length is correct |
|
2740 // |
|
2741 TBuf8<256> recvBuf(length); |
|
2742 TESTL(length()==data.Length()); |
|
2743 |
|
2744 // |
|
2745 // Create a descriptor with correct size for obtaining the message parameter |
|
2746 // |
|
2747 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2748 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
2749 |
|
2750 // |
|
2751 // Get the message parameter value |
|
2752 // |
|
2753 GetMessageParameterL(sock, parameterStorePtr); |
|
2754 |
|
2755 // |
|
2756 // Internalise the message parameter and check |
|
2757 // |
|
2758 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
2759 |
|
2760 CleanupStack::PopAndDestroy(parameterStore); |
|
2761 |
|
2762 // |
|
2763 // Receiving a datagram |
|
2764 // |
|
2765 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
2766 User::WaitForRequest(recvStatus); |
|
2767 TESTL(recvStatus.Int()==KErrNone); |
|
2768 INFO_PRINTF1(_L("Received the message...")); |
|
2769 |
|
2770 // |
|
2771 // Close socket |
|
2772 // |
|
2773 sock.Close(); |
|
2774 INFO_PRINTF1(_L("Socket was closed...")); |
|
2775 |
|
2776 // |
|
2777 // Open the socket |
|
2778 // |
|
2779 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
2780 INFO_PRINTF1(_L("Socket was opened...")); |
|
2781 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
2782 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2783 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
2784 |
|
2785 // |
|
2786 // Issue another get length of datagram as if not aware of the previous message |
|
2787 // |
|
2788 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
2789 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
2790 |
|
2791 // |
|
2792 // waiting for request to be completed |
|
2793 // |
|
2794 User::WaitForRequest(ioctlStatus); |
|
2795 TESTL(ioctlStatus.Int()==KErrNone); |
|
2796 INFO_PRINTF1(_L("IOCTL completed...")); |
|
2797 |
|
2798 // |
|
2799 // Check if reported length is correct |
|
2800 // |
|
2801 TBuf8<256> newRecvBuf(length); |
|
2802 TESTL(length()==data.Length()); |
|
2803 |
|
2804 // |
|
2805 // Recreate a descriptor with correct size for obtaining the message parameter |
|
2806 // |
|
2807 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2808 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
|
2809 |
|
2810 // |
|
2811 // Get the message parameter value |
|
2812 // |
|
2813 GetMessageParameterL(sock, parameterStorePtr2); |
|
2814 |
|
2815 // |
|
2816 // Internalise the message parameter and check |
|
2817 // |
|
2818 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
|
2819 |
|
2820 CleanupStack::PopAndDestroy(parameterStore2); |
|
2821 |
|
2822 // |
|
2823 // New message retrieved from SAR store |
|
2824 // |
|
2825 sock.RecvFrom(newRecvBuf,recvWapAddr,0,recvStatus); |
|
2826 User::WaitForRequest(recvStatus); |
|
2827 TESTL(recvStatus.Int()==KErrNone); |
|
2828 INFO_PRINTF1(_L("Received the message...")); |
|
2829 TEST(newRecvBuf.Compare(data) == 0); |
|
2830 |
|
2831 // |
|
2832 // Confirm the receipt of the message to the client |
|
2833 // |
|
2834 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
2835 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
|
2836 |
|
2837 // |
|
2838 // Closing the socket |
|
2839 // |
|
2840 CleanupStack::PopAndDestroy(&sock); |
|
2841 CleanupStack::PopAndDestroy(&socketServer); |
|
2842 |
|
2843 return TestStepResult(); |
|
2844 } |
|
2845 |
|
2846 TVerdict CIoctlStep_21::doTestStepL() |
|
2847 /** |
|
2848 * |
|
2849 * Test step 21: |
|
2850 * simulating client crash conditions with 8bit push message |
|
2851 * @return - TVerdict code |
|
2852 * |
|
2853 */ |
|
2854 { |
|
2855 INFO_PRINTF1(_L("IOCTL Test step 21: client crash condition with 8Bit push message")); |
|
2856 |
|
2857 TInt result = KErrNone; |
|
2858 TPtrC16 TelNumber; |
|
2859 TInt port=226; |
|
2860 TInt testNumber= 5; |
|
2861 |
|
2862 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
2863 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
2864 { |
|
2865 result=KErrNotFound; |
|
2866 } |
|
2867 |
|
2868 TESTL(result==KErrNone); |
|
2869 |
|
2870 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
2871 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
2872 |
|
2873 // |
|
2874 // Setting the port number and service center number of the wap address |
|
2875 // The service center number should be the same as the sim phone number used |
|
2876 // for test |
|
2877 // |
|
2878 TWapAddr wapAddr; |
|
2879 TWapAddr recvWapAddr; |
|
2880 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
2881 TBuf8<100> scNumber; |
|
2882 scNumber.Copy(TelNumber); |
|
2883 TPtrC8 scAddr(scNumber); |
|
2884 wapAddr.SetWapAddress(scAddr); |
|
2885 |
|
2886 // |
|
2887 // Connect to socket server |
|
2888 // |
|
2889 RSocketServ socketServer; |
|
2890 User::LeaveIfError(socketServer.Connect()); |
|
2891 CleanupClosePushL(socketServer); |
|
2892 |
|
2893 // |
|
2894 // Open the socket |
|
2895 // |
|
2896 RSocket sock; |
|
2897 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
2898 CleanupClosePushL(sock); |
|
2899 |
|
2900 // |
|
2901 // Waiting for the phone to be initialised |
|
2902 // |
|
2903 WaitForInitializeL(); |
|
2904 |
|
2905 TRequestStatus ioctlStatus; |
|
2906 TRequestStatus recvStatus; |
|
2907 TPckgBuf<TInt> length; |
|
2908 |
|
2909 // |
|
2910 // Indicating to the protocol that it's a new client |
|
2911 // |
|
2912 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2913 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
2914 |
|
2915 // |
|
2916 // Bind |
|
2917 // |
|
2918 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
2919 |
|
2920 // |
|
2921 // Issue Ioctl for getting the length of the message |
|
2922 // |
|
2923 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
2924 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
2925 |
|
2926 // |
|
2927 // Get the size of the incoming message |
|
2928 // |
|
2929 User::WaitForRequest(ioctlStatus); |
|
2930 TESTL(ioctlStatus.Int()==KErrNone); |
|
2931 INFO_PRINTF1(_L("IOCTL completed...")); |
|
2932 |
|
2933 TBuf8<256> recvBuf(length); |
|
2934 |
|
2935 // |
|
2936 // Create a descriptor with correct size for obtaining the message parameter |
|
2937 // |
|
2938 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2939 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
2940 |
|
2941 // |
|
2942 // Get the message parameter value |
|
2943 // |
|
2944 GetMessageParameterL(sock, parameterStorePtr); |
|
2945 |
|
2946 // |
|
2947 // Internalise the message parameter and check |
|
2948 // |
|
2949 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
2950 |
|
2951 CleanupStack::PopAndDestroy(parameterStore); |
|
2952 |
|
2953 // |
|
2954 // Receiving a datagram |
|
2955 // |
|
2956 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
2957 User::WaitForRequest(recvStatus); |
|
2958 TESTL(recvStatus.Int()==KErrNone); |
|
2959 INFO_PRINTF1(_L("Received the message...")); |
|
2960 |
|
2961 // |
|
2962 // Close socket |
|
2963 // |
|
2964 sock.Close(); |
|
2965 INFO_PRINTF1(_L("Socket was closed...")); |
|
2966 |
|
2967 // |
|
2968 // Open the socket |
|
2969 // |
|
2970 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
2971 INFO_PRINTF1(_L("Socket was opened...")); |
|
2972 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
2973 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
2974 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
2975 |
|
2976 // |
|
2977 // Issue another get length of datagram as if not aware of the previous message |
|
2978 // |
|
2979 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
2980 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
2981 |
|
2982 // |
|
2983 // waiting for request to be completed |
|
2984 // |
|
2985 User::WaitForRequest(ioctlStatus); |
|
2986 TESTL(ioctlStatus.Int()==KErrNone); |
|
2987 INFO_PRINTF1(_L("IOCTL completed...")); |
|
2988 |
|
2989 // |
|
2990 // Allocate buffer |
|
2991 // |
|
2992 TBuf8<256> newRecvBuf(length); |
|
2993 |
|
2994 // |
|
2995 // Recreate a descriptor with correct size for obtaining the message parameter |
|
2996 // |
|
2997 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2998 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
|
2999 |
|
3000 // |
|
3001 // Get the message parameter value |
|
3002 // |
|
3003 GetMessageParameterL(sock, parameterStorePtr2); |
|
3004 |
|
3005 // |
|
3006 // Internalise the message parameter and check |
|
3007 // |
|
3008 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
|
3009 |
|
3010 CleanupStack::PopAndDestroy(parameterStore2); |
|
3011 |
|
3012 // |
|
3013 // New message retrieved from SAR store |
|
3014 // |
|
3015 sock.RecvFrom(newRecvBuf,recvWapAddr,0,recvStatus); |
|
3016 User::WaitForRequest(recvStatus); |
|
3017 TESTL(recvStatus.Int()==KErrNone); |
|
3018 INFO_PRINTF1(_L("Received the message...")); |
|
3019 |
|
3020 // |
|
3021 // Confirm the receipt of the message to the client |
|
3022 // |
|
3023 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
3024 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
|
3025 |
|
3026 // |
|
3027 // Compare the received message with the previous one |
|
3028 // They should be identical |
|
3029 // |
|
3030 TESTL(newRecvBuf.Compare(recvBuf)==0); |
|
3031 |
|
3032 // |
|
3033 // Closing the socket |
|
3034 // |
|
3035 CleanupStack::PopAndDestroy(&sock); |
|
3036 CleanupStack::PopAndDestroy(&socketServer); |
|
3037 |
|
3038 return TestStepResult(); |
|
3039 } |
|
3040 |
|
3041 TVerdict CIoctlStep_22::doTestStepL() |
|
3042 /** |
|
3043 * Test step 22: |
|
3044 * Push Message (8-Bit). Using IOCTL query SMS transport parameters |
|
3045 * @return - TVerdict code |
|
3046 * |
|
3047 */ |
|
3048 { |
|
3049 INFO_PRINTF1(_L("IOCTL Test step 22: Push Message (8-Bit) and query SMS transport parameters")); |
|
3050 |
|
3051 TInt result = KErrNone; |
|
3052 TPtrC16 TelNumber; |
|
3053 TInt port=226; |
|
3054 TInt testNumber = 7; |
|
3055 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
3056 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
3057 { |
|
3058 result=KErrNotFound; |
|
3059 } |
|
3060 |
|
3061 TESTL(result==KErrNone); |
|
3062 |
|
3063 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
3064 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
3065 |
|
3066 // |
|
3067 // Setting the port number and service center number of the wap address |
|
3068 // The service center number should be the same as the sim phone number used |
|
3069 // for test |
|
3070 // |
|
3071 TWapAddr wapAddr; |
|
3072 TWapAddr recvWapAddr; |
|
3073 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
3074 TBuf8<100> scNumber; |
|
3075 scNumber.Copy(TelNumber); |
|
3076 TPtrC8 scAddr(scNumber); |
|
3077 wapAddr.SetWapAddress(scAddr); |
|
3078 |
|
3079 // |
|
3080 // Connect to socket server |
|
3081 // |
|
3082 RSocketServ socketServer; |
|
3083 User::LeaveIfError(socketServer.Connect()); |
|
3084 CleanupClosePushL(socketServer); |
|
3085 |
|
3086 // |
|
3087 // Define and open the socket |
|
3088 // |
|
3089 RSocket sock; |
|
3090 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
3091 CleanupClosePushL(sock); |
|
3092 |
|
3093 // |
|
3094 // Waiting for the phone to be initialised |
|
3095 // |
|
3096 WaitForInitializeL(); |
|
3097 |
|
3098 // |
|
3099 // Indicating to the protocol that it's a new client |
|
3100 // |
|
3101 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
3102 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
3103 |
|
3104 // |
|
3105 // Bind |
|
3106 // |
|
3107 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
3108 |
|
3109 // |
|
3110 // Create a descriptor with correct size for obtaining the message parameter |
|
3111 // |
|
3112 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
3113 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
3114 |
|
3115 // |
|
3116 // Get the message parameter value |
|
3117 // |
|
3118 GetMessageParameterL(sock, parameterStorePtr); |
|
3119 |
|
3120 // |
|
3121 // Internalise the message parameter and check |
|
3122 // |
|
3123 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
3124 |
|
3125 CleanupStack::PopAndDestroy(parameterStore); |
|
3126 |
|
3127 // |
|
3128 // Closing the socket |
|
3129 // |
|
3130 CleanupStack::PopAndDestroy(&sock); |
|
3131 CleanupStack::PopAndDestroy(&socketServer); |
|
3132 |
|
3133 return TestStepResult(); |
|
3134 } |
|
3135 |
|
3136 TVerdict CIoctlStep_23::doTestStepL() |
|
3137 /** |
|
3138 * Test step 23: |
|
3139 * Two Push Messages (8-Bit). Using IOCTL query SMS transport parameters |
|
3140 * @return - TVerdict code |
|
3141 * |
|
3142 */ |
|
3143 { |
|
3144 INFO_PRINTF1(_L("IOCTL Test step 23: Push two push message(8-Bit) query transport parameters")); |
|
3145 |
|
3146 TInt result=KErrNone; |
|
3147 TPtrC16 TelNumber; |
|
3148 TInt port=226; |
|
3149 TInt testNumber=8; |
|
3150 |
|
3151 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
3152 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
3153 { |
|
3154 result=KErrNotFound; |
|
3155 } |
|
3156 |
|
3157 TESTL(result==KErrNone); |
|
3158 |
|
3159 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
3160 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
3161 |
|
3162 // |
|
3163 // Setting the port number and service center number of the wap address |
|
3164 // The service center number should be the same as the sim phone number used |
|
3165 // for test |
|
3166 // |
|
3167 TWapAddr wapAddr; |
|
3168 TWapAddr recvWapAddr; |
|
3169 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
3170 TBuf8<100> scNumber; |
|
3171 scNumber.Copy(TelNumber); |
|
3172 TPtrC8 scAddr(scNumber); |
|
3173 wapAddr.SetWapAddress(scAddr); |
|
3174 |
|
3175 // |
|
3176 // Connect to socket server |
|
3177 // |
|
3178 RSocketServ socketServer; |
|
3179 User::LeaveIfError(socketServer.Connect()); |
|
3180 CleanupClosePushL(socketServer); |
|
3181 |
|
3182 // |
|
3183 // Define and open the socket |
|
3184 // |
|
3185 RSocket sock; |
|
3186 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
3187 CleanupClosePushL(sock); |
|
3188 |
|
3189 // |
|
3190 // Waiting for the phone to be initialised |
|
3191 // |
|
3192 WaitForInitializeL(); |
|
3193 |
|
3194 TRequestStatus ioctlStatus; |
|
3195 TRequestStatus recvStatus; |
|
3196 TPckgBuf<TInt> length; |
|
3197 |
|
3198 // |
|
3199 // Indicating to the protocol that it's a new client |
|
3200 // |
|
3201 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
3202 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
3203 |
|
3204 // |
|
3205 // Bind |
|
3206 // |
|
3207 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
3208 |
|
3209 // |
|
3210 // Issue Ioctl for getting the length of the message |
|
3211 // |
|
3212 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
3213 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
3214 |
|
3215 // |
|
3216 // Get the size of the incoming push message |
|
3217 // |
|
3218 User::WaitForRequest(ioctlStatus); |
|
3219 TESTL(ioctlStatus.Int()==KErrNone); |
|
3220 INFO_PRINTF1(_L("IOCTL completed...")); |
|
3221 |
|
3222 INFO_PRINTF1(_L("Getting parameter value of first message...")); |
|
3223 |
|
3224 // |
|
3225 // Create a descriptor with correct size for obtaining the first message parameter |
|
3226 // |
|
3227 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
3228 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
3229 |
|
3230 // |
|
3231 // Get the first message parameter value |
|
3232 // |
|
3233 GetMessageParameterL(sock, parameterStorePtr); |
|
3234 |
|
3235 // |
|
3236 // Internalise the first message parameter and check |
|
3237 // |
|
3238 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
3239 |
|
3240 CleanupStack::PopAndDestroy(parameterStore); |
|
3241 |
|
3242 // |
|
3243 // Allocate buffer |
|
3244 // |
|
3245 TBuf8<256> recvBuf1(length); |
|
3246 |
|
3247 // |
|
3248 // Receiving push datagram |
|
3249 // |
|
3250 sock.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
|
3251 User::WaitForRequest(recvStatus); |
|
3252 TESTL(recvStatus.Int()==KErrNone); |
|
3253 INFO_PRINTF1(_L("Received the push message...")); |
|
3254 |
|
3255 // |
|
3256 // Confirm the receipt of the message to the client |
|
3257 // |
|
3258 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
3259 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
|
3260 |
|
3261 // |
|
3262 // Issue another Ioctl for getting the length of the message |
|
3263 // |
|
3264 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
3265 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
3266 |
|
3267 // |
|
3268 // Get the size of the second incoming push message |
|
3269 // |
|
3270 User::WaitForRequest(ioctlStatus); |
|
3271 TESTL(ioctlStatus.Int()==KErrNone); |
|
3272 INFO_PRINTF1(_L("IOCTL completed...")); |
|
3273 |
|
3274 INFO_PRINTF1(_L("Getting parameter value of second message...")); |
|
3275 |
|
3276 // |
|
3277 // Create a descriptor with correct size for obtaining the second message parameter |
|
3278 // |
|
3279 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
3280 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
|
3281 |
|
3282 // |
|
3283 // Get the second message parameter value |
|
3284 // |
|
3285 GetMessageParameterL(sock, parameterStorePtr2); |
|
3286 |
|
3287 // |
|
3288 // Internalise the second message parameter and check |
|
3289 // |
|
3290 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
|
3291 |
|
3292 CleanupStack::PopAndDestroy(parameterStore2); |
|
3293 |
|
3294 // |
|
3295 // Allocate buffer |
|
3296 // |
|
3297 TBuf8<256> recvBuf2(length); |
|
3298 |
|
3299 // |
|
3300 // Receiving push datagram |
|
3301 // |
|
3302 sock.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
3303 User::WaitForRequest(recvStatus); |
|
3304 TESTL(recvStatus.Int()==KErrNone); |
|
3305 INFO_PRINTF1(_L("Received the second push message...")); |
|
3306 |
|
3307 // |
|
3308 // Compare the received message with the previous one |
|
3309 // They should be identical |
|
3310 // |
|
3311 TESTL(recvBuf2.Compare(recvBuf1)==0); |
|
3312 |
|
3313 // |
|
3314 // Confirm the receipt of the message to the client |
|
3315 // |
|
3316 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
3317 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
|
3318 |
|
3319 // |
|
3320 // Closing the socket |
|
3321 // |
|
3322 CleanupStack::PopAndDestroy(&sock); |
|
3323 CleanupStack::PopAndDestroy(&socketServer); |
|
3324 |
|
3325 return TestStepResult(); |
|
3326 } |
|
3327 |
|
3328 TVerdict CIoctlStep_24::doTestStepL() |
|
3329 /** |
|
3330 * Test step 24: |
|
3331 * Test Cancel IOCTL |
|
3332 * @return - TVerdict code |
|
3333 * |
|
3334 */ |
|
3335 { |
|
3336 INFO_PRINTF1(_L("IOCTL Test step 24: Testing Cancel IOCTL")); |
|
3337 |
|
3338 TInt result=KErrNone; |
|
3339 TPtrC16 TelNumber; |
|
3340 TInt port=226; |
|
3341 |
|
3342 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
3343 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
3344 { |
|
3345 result=KErrNotFound; |
|
3346 } |
|
3347 |
|
3348 TESTL(result==KErrNone); |
|
3349 |
|
3350 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
3351 |
|
3352 // |
|
3353 // Setting the port number and service center number of the wap address |
|
3354 // The service center number should be the same as the sim phone number used |
|
3355 // for test (not required for SIM tsy) |
|
3356 // |
|
3357 TWapAddr wapAddr; |
|
3358 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
3359 |
|
3360 TBuf8<100> scNumber; |
|
3361 scNumber.Copy(TelNumber); |
|
3362 TPtrC8 scAddr(scNumber); |
|
3363 wapAddr.SetWapAddress(scAddr); |
|
3364 |
|
3365 // |
|
3366 // Connect to socket server |
|
3367 // |
|
3368 RSocketServ socketServer; |
|
3369 User::LeaveIfError(socketServer.Connect()); |
|
3370 CleanupClosePushL(socketServer); |
|
3371 |
|
3372 // |
|
3373 // Define and open the socket |
|
3374 // |
|
3375 RSocket sock; |
|
3376 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
3377 CleanupClosePushL(sock); |
|
3378 |
|
3379 // |
|
3380 // Waiting for the phone to be initialised |
|
3381 // |
|
3382 WaitForInitializeL(); |
|
3383 |
|
3384 TRequestStatus ioctlStatus; |
|
3385 TBuf8<200> smsdata; |
|
3386 TPckgBuf<TInt> paramLength; |
|
3387 |
|
3388 // |
|
3389 // Indicating to the protocol that it's a new client |
|
3390 // |
|
3391 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
3392 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
3393 |
|
3394 // |
|
3395 // Bind |
|
3396 // |
|
3397 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
3398 |
|
3399 // |
|
3400 // Issue Ioctl for getting the length of the message parameter |
|
3401 // |
|
3402 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParametersLength")); |
|
3403 sock.Ioctl(KSOGetMessageParametersLength, ioctlStatus, &smsdata, KSolWapProv); |
|
3404 |
|
3405 // |
|
3406 // Issue Cancel Ioctl |
|
3407 // |
|
3408 INFO_PRINTF1(_L("Issue of cancel IOCTL for KSOGetMessageParametersLength")); |
|
3409 sock.CancelIoctl(); |
|
3410 |
|
3411 // |
|
3412 // Check if the outstanding IOCTL has been cancelled |
|
3413 // |
|
3414 TESTL(ioctlStatus.Int()==KErrCancel); |
|
3415 |
|
3416 // |
|
3417 // Issue Ioctl for getting the message parameter |
|
3418 // |
|
3419 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
|
3420 sock.Ioctl(KSOGetMessageParameters, ioctlStatus, &smsdata, KSolWapProv); |
|
3421 |
|
3422 // |
|
3423 // Issue Cancel Ioctl |
|
3424 // |
|
3425 INFO_PRINTF1(_L("Issue of cancel IOCTL for KSOGetMessageParameters")); |
|
3426 sock.CancelIoctl(); |
|
3427 |
|
3428 // |
|
3429 // Check if the outstanding IOCTL has been cancelled |
|
3430 // |
|
3431 TESTL(ioctlStatus==KErrCancel); |
|
3432 |
|
3433 // |
|
3434 // Closing the socket |
|
3435 // |
|
3436 CleanupStack::PopAndDestroy(&sock); |
|
3437 CleanupStack::PopAndDestroy(&socketServer); |
|
3438 |
|
3439 return TestStepResult(); |
|
3440 } |
|
3441 |
|
3442 TVerdict CIoctlStep_25::doTestStepL() |
|
3443 /** |
|
3444 * Test step 25: |
|
3445 * Test issue IOCTL without SetOption NewStyleClient |
|
3446 * @return - TVerdict code |
|
3447 * |
|
3448 */ |
|
3449 { |
|
3450 INFO_PRINTF1(_L("IOCTL Test step 25: Test issue IOCTL without SetOption NewStyleClient")); |
|
3451 |
|
3452 TInt result=KErrNone; |
|
3453 TPtrC16 TelNumber; |
|
3454 TInt port=226; |
|
3455 |
|
3456 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
3457 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
3458 { |
|
3459 result=KErrNotFound; |
|
3460 } |
|
3461 |
|
3462 TESTL(result==KErrNone); |
|
3463 |
|
3464 // |
|
3465 // Setting the port number and service center number of the wap address |
|
3466 // The service center number should be the same as the sim phone number used |
|
3467 // for test (not required for SIM tsy) |
|
3468 // |
|
3469 TWapAddr wapAddr; |
|
3470 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
3471 |
|
3472 TBuf8<100> scNumber; |
|
3473 scNumber.Copy(TelNumber); |
|
3474 TPtrC8 scAddr(scNumber); |
|
3475 wapAddr.SetWapAddress(scAddr); |
|
3476 |
|
3477 // |
|
3478 // Connect to socket server |
|
3479 // |
|
3480 RSocketServ socketServer; |
|
3481 User::LeaveIfError(socketServer.Connect()); |
|
3482 CleanupClosePushL(socketServer); |
|
3483 |
|
3484 // |
|
3485 // Define and open the socket |
|
3486 // |
|
3487 RSocket sock; |
|
3488 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
3489 CleanupClosePushL(sock); |
|
3490 |
|
3491 // |
|
3492 // Waiting for the phone to be initialised |
|
3493 // |
|
3494 WaitForInitializeL(); |
|
3495 |
|
3496 TRequestStatus ioctlStatus; |
|
3497 TBuf8<200> smsdata; |
|
3498 TPckgBuf<TInt> paramLength; |
|
3499 |
|
3500 // |
|
3501 // Bind |
|
3502 // |
|
3503 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
3504 |
|
3505 // |
|
3506 // Issue Ioctl for getting the length of the message parameter (should fail) |
|
3507 // |
|
3508 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParametersLength")); |
|
3509 sock.Ioctl(KSOGetMessageParametersLength, ioctlStatus, ¶mLength, KSolWapProv); |
|
3510 TESTL(ioctlStatus.Int()!=KErrNone); |
|
3511 |
|
3512 // |
|
3513 // Issue Ioctl for getting the message parameter (should fail) |
|
3514 // |
|
3515 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
|
3516 sock.Ioctl(KSOGetMessageParameters, ioctlStatus, &smsdata, KSolWapProv); |
|
3517 User::WaitForRequest(ioctlStatus); |
|
3518 TESTL(ioctlStatus.Int()!=KErrNone); |
|
3519 |
|
3520 // |
|
3521 // Closing the socket |
|
3522 // |
|
3523 CleanupStack::PopAndDestroy(&sock); |
|
3524 CleanupStack::PopAndDestroy(&socketServer); |
|
3525 |
|
3526 return TestStepResult(); |
|
3527 } |
|
3528 |
|
3529 TVerdict CIoctlStep_26::doTestStepL() |
|
3530 /** |
|
3531 * Test step 26: |
|
3532 * Sends a 8-Bit calendar entry using IOCTL(two segments) |
|
3533 * @return - TVerdict code |
|
3534 * |
|
3535 */ |
|
3536 { |
|
3537 INFO_PRINTF1(_L("IOCTL Test step 26: send a 8-Bit VCal (two segments)")); |
|
3538 |
|
3539 TInt result=KErrNone; |
|
3540 TPtrC TestData; |
|
3541 TPtrC16 TelNumber; |
|
3542 TInt port=226; |
|
3543 TInt testNumber = 13; |
|
3544 |
|
3545 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData) || |
|
3546 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
3547 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
3548 { |
|
3549 result=KErrNotFound; |
|
3550 } |
|
3551 |
|
3552 TESTL(result==KErrNone); |
|
3553 |
|
3554 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
3555 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
3556 |
|
3557 // |
|
3558 // Setting the port number and service center number of the wap address |
|
3559 // The service center number should be the same as the sim phone number used |
|
3560 // for test (not required for SIM Tsy) |
|
3561 // |
|
3562 TWapAddr wapAddr; |
|
3563 TWapAddr recvWapAddr; |
|
3564 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
3565 TBuf8<100> scNumber; |
|
3566 scNumber.Copy(TelNumber); |
|
3567 TPtrC8 scAddr(scNumber); |
|
3568 wapAddr.SetWapAddress(scAddr); |
|
3569 |
|
3570 // |
|
3571 // Connect to socket server |
|
3572 // |
|
3573 RSocketServ socketServer; |
|
3574 User::LeaveIfError(socketServer.Connect()); |
|
3575 CleanupClosePushL(socketServer); |
|
3576 |
|
3577 // |
|
3578 // Define and open the socket |
|
3579 // |
|
3580 RSocket sock; |
|
3581 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
3582 CleanupClosePushL(sock); |
|
3583 |
|
3584 // |
|
3585 // Waiting for the phone to be initialised |
|
3586 // |
|
3587 WaitForInitializeL(); |
|
3588 |
|
3589 // |
|
3590 // Indicating to the protocol that it's a new client |
|
3591 // |
|
3592 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
3593 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
3594 TESTL(sock.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms8BitDCS)==KErrNone); |
|
3595 |
|
3596 // |
|
3597 // Bind |
|
3598 // |
|
3599 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
3600 |
|
3601 // |
|
3602 // Send a calendar entry |
|
3603 // |
|
3604 TRequestStatus status; |
|
3605 |
|
3606 TBuf8<300> data; |
|
3607 data.Copy(TestData); |
|
3608 sock.SendTo(data, wapAddr, 0, status); |
|
3609 User::WaitForRequest(status); |
|
3610 TESTL(status.Int()==KErrNone); |
|
3611 INFO_PRINTF1(_L("Message sent...")); |
|
3612 |
|
3613 // |
|
3614 // Create a descriptor with correct size for obtaining the message parameter |
|
3615 // |
|
3616 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
3617 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
3618 |
|
3619 // |
|
3620 // Get the message parameter value |
|
3621 // |
|
3622 GetMessageParameterL(sock, parameterStorePtr); |
|
3623 |
|
3624 // |
|
3625 // Internalise the message parameter and check |
|
3626 // |
|
3627 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
3628 |
|
3629 CleanupStack::PopAndDestroy(parameterStore); |
|
3630 |
|
3631 // |
|
3632 // Closing the socket |
|
3633 // |
|
3634 CleanupStack::PopAndDestroy(&sock); |
|
3635 CleanupStack::PopAndDestroy(&socketServer); |
|
3636 |
|
3637 return TestStepResult(); |
|
3638 } |
|
3639 |
|
3640 struct SOneOpTestThreadInfo |
|
3641 { |
|
3642 CIoctlStep_27* iTest; |
|
3643 TPtrC* iTestData1; |
|
3644 TPtrC16* iTelNumber; |
|
3645 TInt iPort; |
|
3646 }; |
|
3647 |
|
3648 TInt CIoctlStep_27::DoPanicTestL(TPtrC* aTestData1, TPtrC16* aTelNumber, TInt aPort) |
|
3649 { |
|
3650 TInt testNumber = 1; |
|
3651 TInt port = aPort; |
|
3652 TPtrC TestData1 = *aTestData1; |
|
3653 TPtrC16 TelNumber = *aTelNumber; |
|
3654 |
|
3655 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
3656 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
3657 |
|
3658 // |
|
3659 // Setting the port number and service center number of the wap address |
|
3660 // The service center number should be the same as the sim phone number used |
|
3661 // for test (not required for SIM tsy) |
|
3662 // |
|
3663 TWapAddr wapAddr; |
|
3664 TWapAddr recvWapAddr; |
|
3665 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
3666 |
|
3667 TBuf8<100> scNumber; |
|
3668 scNumber.Copy(TelNumber); |
|
3669 TPtrC8 scAddr(scNumber); |
|
3670 wapAddr.SetWapAddress(scAddr); |
|
3671 |
|
3672 // |
|
3673 // Connect to socket server |
|
3674 // |
|
3675 RSocketServ socketServer; |
|
3676 User::LeaveIfError(socketServer.Connect()); |
|
3677 CleanupClosePushL(socketServer); |
|
3678 |
|
3679 // |
|
3680 // Define and open the socket |
|
3681 // |
|
3682 RSocket sock; |
|
3683 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
3684 CleanupClosePushL(sock); |
|
3685 |
|
3686 // |
|
3687 // Waiting for the phone to be initialised |
|
3688 // |
|
3689 WaitForInitializeL(); |
|
3690 |
|
3691 // |
|
3692 // Indicating to the protocol that it's a new client |
|
3693 // |
|
3694 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
3695 |
|
3696 // |
|
3697 // Bind |
|
3698 // |
|
3699 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
3700 |
|
3701 // |
|
3702 // Send a business card |
|
3703 // |
|
3704 TRequestStatus status; |
|
3705 |
|
3706 TBuf8<200> data; |
|
3707 data.Copy(TestData1); |
|
3708 sock.SendTo(data, wapAddr, 0, status); |
|
3709 User::WaitForRequest(status); |
|
3710 TESTL(status.Int()==KErrNone); |
|
3711 |
|
3712 TRequestStatus ioctlStatus; |
|
3713 TRequestStatus recvStatus; |
|
3714 TPckgBuf<TInt> length; |
|
3715 |
|
3716 TRequestStatus ioctlmessageStatus; |
|
3717 TBuf8<200> smsdata; |
|
3718 |
|
3719 // |
|
3720 // Issue Ioctl for getting the length of the message |
|
3721 // |
|
3722 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
3723 |
|
3724 // |
|
3725 // Issue Ioctl for getting the message parameters (should panic!) |
|
3726 // |
|
3727 sock.Ioctl(KSOGetMessageParameters, ioctlmessageStatus, &smsdata, KSolWapProv); |
|
3728 |
|
3729 // |
|
3730 // Get the size of the first incoming message |
|
3731 // |
|
3732 User::WaitForRequest(ioctlStatus); |
|
3733 TESTL(ioctlStatus.Int()==KErrNone); |
|
3734 |
|
3735 // |
|
3736 // Receiving a datagram |
|
3737 // |
|
3738 TBuf8<256> recvBuf(length); |
|
3739 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
3740 User::WaitForRequest(recvStatus); |
|
3741 TESTL(recvStatus.Int()==KErrNone); |
|
3742 TEST(recvBuf.Compare(data) == 0); |
|
3743 |
|
3744 // |
|
3745 // Confirm the receipt of the message to the client |
|
3746 // |
|
3747 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
|
3748 |
|
3749 // |
|
3750 // Closing the socket |
|
3751 // |
|
3752 CleanupStack::PopAndDestroy(&sock); |
|
3753 CleanupStack::PopAndDestroy(&socketServer); |
|
3754 |
|
3755 return KErrNone; |
|
3756 } |
|
3757 |
|
3758 TInt testPanicsL(TAny* aPtr) |
|
3759 { |
|
3760 SOneOpTestThreadInfo *pI=(SOneOpTestThreadInfo *)aPtr; |
|
3761 |
|
3762 __UHEAP_MARK; |
|
3763 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
3764 TRAPD(err, pI->iTest->DoPanicTestL(pI->iTestData1, pI->iTelNumber, pI->iPort)); |
|
3765 |
|
3766 delete cleanup; |
|
3767 __UHEAP_MARKEND; |
|
3768 return err; |
|
3769 } |
|
3770 |
|
3771 TVerdict CIoctlStep_27::doTestStepL() |
|
3772 /** |
|
3773 * Test step 27: |
|
3774 * Send a 7_Bit business card. Issue both a get length and get message parameters to IOCTL at sametime |
|
3775 * @return - TVerdict code |
|
3776 * |
|
3777 */ |
|
3778 { |
|
3779 const TUint KHeapMinSize=0x01000; |
|
3780 const TUint KHeapMaxSize=0x10000; |
|
3781 |
|
3782 TPtrC TestData1; |
|
3783 TPtrC16 TelNumber; |
|
3784 TInt port=226; |
|
3785 |
|
3786 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
3787 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
3788 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
3789 { |
|
3790 User::Leave(KErrNotFound); |
|
3791 } |
|
3792 |
|
3793 INFO_PRINTF1(_L("Send a 7_Bit business card. Issue both a get length and get message parameters to IOCTL")); |
|
3794 |
|
3795 TBool jitEnabled = User::JustInTime(); |
|
3796 |
|
3797 User::SetJustInTime(EFalse); |
|
3798 |
|
3799 SOneOpTestThreadInfo info; |
|
3800 |
|
3801 info.iTest=this; |
|
3802 info.iTestData1=&TestData1; |
|
3803 info.iTelNumber=&TelNumber; |
|
3804 info.iPort=226; |
|
3805 |
|
3806 RThread thread; |
|
3807 TInt rc = thread.Create(_L("PanicThread"),testPanicsL,KDefaultStackSize,KHeapMinSize,KHeapMaxSize,&info); |
|
3808 |
|
3809 TESTL(rc==KErrNone); |
|
3810 |
|
3811 TRequestStatus s; |
|
3812 thread.Logon(s); |
|
3813 thread.Resume(); |
|
3814 User::WaitForRequest(s); |
|
3815 TESTL(thread.ExitType()==EExitPanic); |
|
3816 |
|
3817 INFO_PRINTF2(_L("Exit type is: %d"), thread.ExitType()); |
|
3818 |
|
3819 thread.Close(); |
|
3820 |
|
3821 User::SetJustInTime(jitEnabled); |
|
3822 |
|
3823 return TestStepResult(); |
|
3824 } |
|
3825 |
|
3826 TVerdict CIoctlStep_28::doTestStepPreambleL() |
|
3827 { |
|
3828 __UHEAP_MARK; |
|
3829 |
|
3830 iScheduler = new(ELeave) CActiveScheduler; |
|
3831 CActiveScheduler::Install(iScheduler); |
|
3832 |
|
3833 TInt err; |
|
3834 err=User::LoadPhysicalDevice(PDD_NAME); |
|
3835 TESTL(err==KErrNone || err==KErrAlreadyExists); |
|
3836 |
|
3837 err=User::LoadLogicalDevice(LDD_NAME); |
|
3838 TESTL(err==KErrNone || err==KErrAlreadyExists); |
|
3839 |
|
3840 err = StartC32(); |
|
3841 ERR_PRINTF2(TRefByValue<const TDesC>(_L("Start Comms Process Status = %d")), err); |
|
3842 TESTL(err==KErrNone || err==KErrAlreadyExists); |
|
3843 |
|
3844 INFO_PRINTF1(_L("Deleting segmentation and reassembly stores...")); |
|
3845 |
|
3846 RFs fileServer; |
|
3847 User::LeaveIfError(fileServer.Connect()); |
|
3848 |
|
3849 // delete segmentation and reassembly store files before the test |
|
3850 _LIT(KReassemblyStoreName,"C:\\Private\\101F7989\\sms\\smsreast.dat"); |
|
3851 _LIT(KSegmentationStoreName,"C:\\Private\\101F7989\\sms\\smssegst.dat"); |
|
3852 _LIT(KWapReassemblyStoreName,"C:\\Private\\101F7989\\sms\\wapreast.dat"); |
|
3853 |
|
3854 fileServer.Delete(KWapReassemblyStoreName); |
|
3855 fileServer.Delete(KReassemblyStoreName); |
|
3856 fileServer.Delete(KSegmentationStoreName); |
|
3857 |
|
3858 fileServer.Close(); |
|
3859 |
|
3860 return TestStepResult(); |
|
3861 } |
|
3862 |
|
3863 TVerdict CIoctlStep_28::doTestStepPostambleL() |
|
3864 { |
|
3865 delete iScheduler; |
|
3866 iScheduler = NULL; |
|
3867 |
|
3868 __UHEAP_MARKEND; |
|
3869 |
|
3870 return TestStepResult(); |
|
3871 } |
|
3872 |
|
3873 TVerdict CIoctlStep_28::doTestStepL() |
|
3874 |
|
3875 /** |
|
3876 * Test step seventeen: |
|
3877 * Sends a 7_Bit business card. Issue a get message parameters to IOCTL without correct platform security |
|
3878 * @return - TVerdict code |
|
3879 * |
|
3880 */ |
|
3881 { |
|
3882 INFO_PRINTF1(_L("Sends a 7_Bit business card. Issue a get message parameters to IOCTL without correct platform security")); |
|
3883 |
|
3884 TInt result=KErrNone; |
|
3885 TPtrC TestData1; |
|
3886 TPtrC16 TelNumber; |
|
3887 TInt port=226; |
|
3888 TInt testNumber=1; |
|
3889 |
|
3890 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
|
3891 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
3892 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
|
3893 { |
|
3894 result=KErrNotFound; |
|
3895 } |
|
3896 |
|
3897 TESTL(result==KErrNone); |
|
3898 |
|
3899 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
3900 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
3901 |
|
3902 // |
|
3903 // Setting the port number and service center number of the wap address |
|
3904 // The service center number should be the same as the sim phone number used |
|
3905 // for test (not required for SIM tsy) |
|
3906 // |
|
3907 TWapAddr wapAddr; |
|
3908 TWapAddr recvWapAddr; |
|
3909 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
3910 |
|
3911 TBuf8<100> scNumber; |
|
3912 scNumber.Copy(TelNumber); |
|
3913 TPtrC8 scAddr(scNumber); |
|
3914 wapAddr.SetWapAddress(scAddr); |
|
3915 |
|
3916 // |
|
3917 // Connect to socket server |
|
3918 // |
|
3919 RSocketServ socketServer; |
|
3920 User::LeaveIfError(socketServer.Connect()); |
|
3921 CleanupClosePushL(socketServer); |
|
3922 |
|
3923 // |
|
3924 // Define and open the socket |
|
3925 // |
|
3926 RSocket sock; |
|
3927 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
|
3928 CleanupClosePushL(sock); |
|
3929 |
|
3930 // |
|
3931 // Waiting for the phone to be initialised |
|
3932 // |
|
3933 WaitForInitializeL(); |
|
3934 |
|
3935 // |
|
3936 // Indicating to the protocol that it's a new client |
|
3937 // |
|
3938 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
3939 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
|
3940 |
|
3941 // |
|
3942 // Bind |
|
3943 // |
|
3944 TESTL(sock.Bind(wapAddr)==KErrNone); |
|
3945 |
|
3946 // |
|
3947 // Send a business card |
|
3948 // |
|
3949 TRequestStatus status; |
|
3950 TBuf8<200> data; |
|
3951 data.Copy(TestData1); |
|
3952 sock.SendTo(data, wapAddr, 0, status); |
|
3953 User::WaitForRequest(status); |
|
3954 TESTL(status.Int()==KErrNone); |
|
3955 INFO_PRINTF1(_L("Message sent...")); |
|
3956 |
|
3957 // |
|
3958 // Issue Ioctl for getting the message parameters |
|
3959 // |
|
3960 TRequestStatus testStatus; |
|
3961 TBuf8<200> smsdata; |
|
3962 |
|
3963 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
|
3964 sock.Ioctl(KSOGetMessageParameters, testStatus, &smsdata, KSolWapProv); |
|
3965 |
|
3966 User::WaitForRequest(testStatus); |
|
3967 TESTL(testStatus.Int()==KErrPermissionDenied); |
|
3968 INFO_PRINTF2(_L("KSOGetMessageParameters on Ioctl failed to complete with: %d"), testStatus.Int()); |
|
3969 |
|
3970 // |
|
3971 // Closing the socket |
|
3972 // |
|
3973 CleanupStack::PopAndDestroy(&sock); |
|
3974 CleanupStack::PopAndDestroy(&socketServer); |
|
3975 |
|
3976 return TestStepResult(); |
|
3977 } |
|
3978 |
|
3979 |
|
3980 TVerdict CSetDiskMonitorLimits::doTestStepL() |
|
3981 /** |
|
3982 Creates smsu.rsc file which defines the upper and lower limits for the disk space monitor |
|
3983 */ |
|
3984 |
|
3985 { |
|
3986 #ifndef _DEBUG |
|
3987 INFO_PRINTF1(_L("This test can only be run when the SMS Stack is in debug mode.")); |
|
3988 #else |
|
3989 TInt highDrop = 4; |
|
3990 TInt lowDrop = 10; |
|
3991 TInt freeDrop = 0; |
|
3992 |
|
3993 GetIntFromConfig(_L("DiskMonitorLimits"), _L("highDrop"), highDrop); |
|
3994 GetIntFromConfig(_L("DiskMonitorLimits"), _L("lowDrop"), lowDrop); |
|
3995 |
|
3996 SetHighLowLimitsAndDiskSpaceLevelL(highDrop, lowDrop, freeDrop); |
|
3997 #endif |
|
3998 return TestStepResult(); |
|
3999 } |
|
4000 |
|
4001 /** |
|
4002 * Set free disk space to the required limit |
|
4003 */ |
|
4004 TVerdict CSetDiskSpace::doTestStepL() |
|
4005 { |
|
4006 #ifndef _DEBUG |
|
4007 INFO_PRINTF1(_L("This test can only be run when the SMS Stack is in debug mode.")); |
|
4008 #else |
|
4009 ReleaseDiskSpaceL(); |
|
4010 |
|
4011 TInt freeDrop = 0; |
|
4012 GetIntFromConfig(ConfigSection(), _L("freeDrop"), freeDrop); |
|
4013 |
|
4014 SetFreeDiskSpaceFromDropLevelL(freeDrop); |
|
4015 #endif |
|
4016 return TestStepResult(); |
|
4017 } |
|
4018 |
|
4019 /** |
|
4020 Free up disk space by deleting the temp files created |
|
4021 */ |
|
4022 TVerdict CFreeDiskSpace::doTestStepL() |
|
4023 { |
|
4024 #ifndef _DEBUG |
|
4025 INFO_PRINTF1(_L("This test can only be run when the SMS Stack is in debug mode.")); |
|
4026 #else |
|
4027 ReleaseDiskSpaceL(); |
|
4028 |
|
4029 TInt err = RProperty::Delete(KUidPSSMSStackCategory, KUidPSSMSStackFreeDiskSpaceKey); |
|
4030 if (err != KErrNone && err != KErrNotFound) |
|
4031 { |
|
4032 ERR_PRINTF2(_L("RProperty::Delete() failure [err=%d]"), err); |
|
4033 } |
|
4034 #endif |
|
4035 |
|
4036 return TestStepResult(); |
|
4037 } |
|
4038 |
|
4039 /** |
|
4040 Free up disk space by deleting the temp files created |
|
4041 */ |
|
4042 TVerdict CInitializePhone::doTestStepL() |
|
4043 { |
|
4044 SetTestNumberL(); |
|
4045 WaitForInitializeL(); |
|
4046 |
|
4047 #ifdef _DEBUG |
|
4048 TInt err = RProperty::Define(KUidPSSMSStackCategory, KUidPSSMSStackFreeDiskSpaceKey, RProperty::EInt); |
|
4049 if ((err != KErrNone) && (err != KErrAlreadyExists)) |
|
4050 { |
|
4051 ERR_PRINTF2(_L("RProperty::Define() failure [err=%d]"), err); |
|
4052 User::Leave(err); |
|
4053 } |
|
4054 #endif |
|
4055 |
|
4056 return TestStepResult(); |
|
4057 } |
|
4058 |
|
4059 |
|
4060 /** |
|
4061 Free up disk space by deleting the temp files created |
|
4062 */ |
|
4063 TVerdict CReceiveWapMessage::doTestStepL() |
|
4064 { |
|
4065 #ifndef _DEBUG |
|
4066 INFO_PRINTF1(_L("This test can only be run when the SMS Stack is in debug mode.")); |
|
4067 #else |
|
4068 |
|
4069 // Connect to socket server |
|
4070 RSocketServ socketServer; |
|
4071 User::LeaveIfError(socketServer.Connect()); |
|
4072 CleanupClosePushL(socketServer); |
|
4073 // Define and open the socket |
|
4074 RSocket sock; |
|
4075 OpenSocketLC(socketServer, sock); |
|
4076 WaitForInitializeL(); |
|
4077 |
|
4078 //Read port and SC number from ini file |
|
4079 TWapAddr wapAddr; |
|
4080 ReadWapPortSettingsL(wapAddr); |
|
4081 // |
|
4082 // Indicating to the protocol that it's a new client |
|
4083 // |
|
4084 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
4085 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
4086 |
|
4087 // Bind |
|
4088 // |
|
4089 User::LeaveIfError(sock.Bind(wapAddr)); |
|
4090 |
|
4091 TRequestStatus recvStatus; |
|
4092 TRequestStatus ioctlStatus; |
|
4093 TPckgBuf<TInt> length; |
|
4094 |
|
4095 // |
|
4096 // Send a business card |
|
4097 // |
|
4098 TRequestStatus status; |
|
4099 TPtrC testData; |
|
4100 GetStringFromConfig(ConfigSection(),KTestData1, testData); |
|
4101 TBuf8<200> data; |
|
4102 data.Copy(testData); |
|
4103 sock.SendTo(data, wapAddr, 0, status); |
|
4104 User::WaitForRequest(status); |
|
4105 User::LeaveIfError(status.Int()); |
|
4106 INFO_PRINTF1(_L("Message sent...")); |
|
4107 |
|
4108 // Issue Ioctl for getting the length of the message |
|
4109 TBool messageIsExpected; |
|
4110 GetBoolFromConfig(ConfigSection(), _L("messageIsExpected"), messageIsExpected); |
|
4111 |
|
4112 //Setup delay |
|
4113 TRequestStatus timerStatus; |
|
4114 RTimer timer; |
|
4115 //Read from the INI file. |
|
4116 TInt timeout; |
|
4117 TBool found = GetIntFromConfig(_L("ReceiveTimeout"), _L("timeout"), timeout); |
|
4118 //Timeout must be specified |
|
4119 if(!found) |
|
4120 { |
|
4121 timeout=10000000; // else a default of 10 seconds will be used |
|
4122 } |
|
4123 |
|
4124 timer.CreateLocal(); |
|
4125 timer.After(timerStatus, TTimeIntervalMicroSeconds32(timeout)); |
|
4126 |
|
4127 // Get the size of the first incomming message |
|
4128 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength")); |
|
4129 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
4130 |
|
4131 //Check if there is in fact a message |
|
4132 TBool received=EFalse; |
|
4133 User::WaitForRequest(timerStatus, ioctlStatus); |
|
4134 |
|
4135 if(ioctlStatus == KRequestPending) |
|
4136 { |
|
4137 // if timer elapsed but ESock request is still pending |
|
4138 sock.CancelIoctl(); |
|
4139 User::WaitForRequest(ioctlStatus); |
|
4140 } |
|
4141 else |
|
4142 { |
|
4143 // ESock request is done. Cancel timer |
|
4144 timer.Cancel(); |
|
4145 User::WaitForRequest(timerStatus); |
|
4146 // check ESock error status |
|
4147 if(ioctlStatus.Int() == KErrNone) |
|
4148 { |
|
4149 received=ETrue; |
|
4150 } |
|
4151 } |
|
4152 timer.Close(); |
|
4153 |
|
4154 if(received && messageIsExpected) |
|
4155 { |
|
4156 // Receiving push datagram |
|
4157 TWapAddr recvWapAddr; |
|
4158 TBuf8<256> recvBuf1(length); |
|
4159 sock.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
|
4160 User::WaitForRequest(recvStatus); |
|
4161 User::LeaveIfError(recvStatus.Int()); |
|
4162 INFO_PRINTF1(_L("Received the push message...")); |
|
4163 TEST(recvBuf1.Compare(data) == 0); |
|
4164 |
|
4165 // |
|
4166 // Confirm the receipt of the message to the client |
|
4167 // |
|
4168 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
4169 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
4170 |
|
4171 } |
|
4172 else if (received || messageIsExpected) |
|
4173 { |
|
4174 //Message is not expected |
|
4175 TEST(EFalse); |
|
4176 } |
|
4177 |
|
4178 CleanupStack::Pop(&sock); |
|
4179 CleanupStack::Pop(&socketServer); |
|
4180 sock.Close(); |
|
4181 socketServer.Close(); |
|
4182 INFO_PRINTF1(_L("End of ReceiveWapMessage test step")); |
|
4183 #endif |
|
4184 |
|
4185 return TestStepResult(); |
|
4186 } |
|
4187 |
|
4188 |
|
4189 /** |
|
4190 * Tests enumerating of a VCard which needs to go via the observer and not returned to the client. |
|
4191 * |
|
4192 * @return A TVerdict code. |
|
4193 */ |
|
4194 TVerdict CTestEnumeratingVCard::doTestStepL() |
|
4195 { |
|
4196 // |
|
4197 // Setup the test... |
|
4198 // |
|
4199 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
4200 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, 34)); |
|
4201 |
|
4202 // |
|
4203 // Connect to socket server |
|
4204 // |
|
4205 RSocketServ socketServer; |
|
4206 |
|
4207 User::LeaveIfError(socketServer.Connect()); |
|
4208 CleanupClosePushL(socketServer); |
|
4209 |
|
4210 // |
|
4211 // Waiting for the phone to be initialised |
|
4212 // |
|
4213 WaitForInitializeL(); |
|
4214 |
|
4215 // |
|
4216 // Define and open the socket to receive the datagram on... |
|
4217 // |
|
4218 RSocket sock; |
|
4219 TWapAddr wapAddr; |
|
4220 OpenSocketLC(socketServer, sock); |
|
4221 |
|
4222 wapAddr.SetWapPort(TWapPortNumber(226)); |
|
4223 User::LeaveIfError(sock.Bind(wapAddr)); |
|
4224 |
|
4225 // |
|
4226 // Indicate to the protocol that it's a new client |
|
4227 // |
|
4228 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
4229 |
|
4230 // |
|
4231 // Create a socket for the enumeration... |
|
4232 // |
|
4233 RSocket enumerateSock; |
|
4234 TSmsAddr smsAddr; |
|
4235 |
|
4236 OpenSocketLC(socketServer, enumerateSock, KSMSAddrFamily,KSMSDatagramProtocol); |
|
4237 |
|
4238 smsAddr.SetSmsAddrFamily(ESmsAddrLocalOperation); |
|
4239 User::LeaveIfError(enumerateSock.Bind(smsAddr)); |
|
4240 |
|
4241 // |
|
4242 // Trigger the enumeration... |
|
4243 // |
|
4244 TPckgBuf<TUint> messageCount; |
|
4245 TRequestStatus enumStatus; |
|
4246 |
|
4247 User::After(1000000); // Gives SMS Prot and WAP Prot time to initialise after loading! |
|
4248 enumerateSock.Ioctl(KIoctlEnumerateSmsMessages, enumStatus, &messageCount, KSolSmsProv); |
|
4249 User::WaitForRequest(enumStatus); |
|
4250 TESTL(enumStatus.Int() == KErrNone); |
|
4251 TEST(messageCount() == 0); |
|
4252 |
|
4253 // |
|
4254 // Issue an Ioctl for getting the length of the enumerated datagram... |
|
4255 // |
|
4256 TRequestStatus ioctlStatus; |
|
4257 TPckgBuf<TInt> length; |
|
4258 |
|
4259 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
4260 User::WaitForRequest(ioctlStatus); |
|
4261 TESTL(ioctlStatus.Int() == KErrNone); |
|
4262 TEST(length() == 118); |
|
4263 |
|
4264 // |
|
4265 // Receive the VCard... |
|
4266 // |
|
4267 TRequestStatus recvStatus; |
|
4268 TBuf8<256> recvBuf; |
|
4269 TBuf<256> vcardBuf16; |
|
4270 TWapAddr recvWapAddr; |
|
4271 |
|
4272 sock.RecvFrom(recvBuf, recvWapAddr, 0, recvStatus); |
|
4273 User::WaitForRequest(recvStatus); |
|
4274 TESTL(recvStatus.Int() == KErrNone); |
|
4275 |
|
4276 vcardBuf16.Copy(recvBuf); |
|
4277 INFO_PRINTF2(_L("Received the VCard: \"%S\""), &vcardBuf16); |
|
4278 |
|
4279 // |
|
4280 // Confirm the receipt of the message... |
|
4281 // |
|
4282 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
4283 |
|
4284 // |
|
4285 // Close all the sockets |
|
4286 // |
|
4287 CleanupStack::PopAndDestroy(&enumerateSock); |
|
4288 CleanupStack::PopAndDestroy(&sock); |
|
4289 CleanupStack::PopAndDestroy(&socketServer); |
|
4290 |
|
4291 return TestStepResult(); |
|
4292 } // CTestEnumeratingVCard::doTestStepL |
|
4293 |
|
4294 |
|
4295 /** |
|
4296 * Sends a 7-bit VCard with an email address in it, to ensure that '@' |
|
4297 * characters are sent correctly. |
|
4298 * |
|
4299 * @return EPass or EFail. |
|
4300 */ |
|
4301 TVerdict CTest7BitBusinessCardWithEmail::doTestStepL() |
|
4302 { |
|
4303 TPtrC testData; |
|
4304 TPtrC16 telNumber; |
|
4305 TInt port; |
|
4306 TInt testNumber = 35; |
|
4307 |
|
4308 if(!GetStringFromConfig(ConfigSection(), KTestData1, testData) || |
|
4309 !GetStringFromConfig(ConfigSection(), KSCNumber, telNumber) || |
|
4310 !GetIntFromConfig(ConfigSection(), KWapPort, port)) |
|
4311 { |
|
4312 // Leave if there's any error. |
|
4313 User::Leave(KErrNotFound); |
|
4314 } |
|
4315 |
|
4316 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
4317 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
|
4318 |
|
4319 // |
|
4320 // Setting the port number and service center number of the wap address |
|
4321 // The service center number should be the same as the sim phone number used |
|
4322 // for test (not required for SIM tsy) |
|
4323 // |
|
4324 TWapAddr wapAddr; |
|
4325 TWapAddr recvWapAddr; |
|
4326 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
4327 |
|
4328 TBuf8<100> scNumber; |
|
4329 scNumber.Copy(telNumber); |
|
4330 TPtrC8 scAddr(scNumber); |
|
4331 wapAddr.SetWapAddress(scAddr); |
|
4332 |
|
4333 // |
|
4334 // Connect to socket server |
|
4335 // |
|
4336 RSocketServ socketServer; |
|
4337 User::LeaveIfError(socketServer.Connect()); |
|
4338 CleanupClosePushL(socketServer); |
|
4339 |
|
4340 // |
|
4341 // Define and open the socket |
|
4342 // |
|
4343 RSocket sock; |
|
4344 OpenSocketLC(socketServer, sock); |
|
4345 |
|
4346 // |
|
4347 // Waiting for the phone to be initialised |
|
4348 // |
|
4349 WaitForInitializeL(); |
|
4350 |
|
4351 // |
|
4352 // Indicating to the protocol that it's a new client |
|
4353 // |
|
4354 INFO_PRINTF1(_L("Socket set option for indicating new client...")); |
|
4355 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient, KWapSmsOptionLevel, 0)); |
|
4356 |
|
4357 // |
|
4358 // Bind to the port... |
|
4359 // |
|
4360 User::LeaveIfError(sock.Bind(wapAddr)); |
|
4361 |
|
4362 // |
|
4363 // Send a business card with the email address. |
|
4364 // |
|
4365 TRequestStatus status; |
|
4366 |
|
4367 TBuf8<200> data; |
|
4368 data.Copy(testData); |
|
4369 sock.SendTo(data, wapAddr, 0, status); |
|
4370 User::WaitForRequest(status); |
|
4371 User::LeaveIfError(status.Int()); |
|
4372 INFO_PRINTF1(_L("Message sent...")); |
|
4373 |
|
4374 // |
|
4375 // Issue Ioctl for getting the length of the message |
|
4376 // |
|
4377 TPckgBuf<TInt> length; |
|
4378 |
|
4379 INFO_PRINTF1(_L("Issue of IOCTL for GetLength...")); |
|
4380 sock.Ioctl(KSOGetLength, status, &length, KSolWapProv); |
|
4381 User::WaitForRequest(status); |
|
4382 User::LeaveIfError(status.Int()); |
|
4383 |
|
4384 // |
|
4385 // Check if reported length is correct |
|
4386 // |
|
4387 TEST(length() == data.Length()); |
|
4388 |
|
4389 // |
|
4390 // Receiving a datagram |
|
4391 // |
|
4392 TBuf8<256> recvBuf(length); |
|
4393 |
|
4394 sock.RecvFrom(recvBuf, recvWapAddr, 0, status); |
|
4395 User::WaitForRequest(status); |
|
4396 User::LeaveIfError(status.Int()); |
|
4397 INFO_PRINTF1(_L("Received the message...")); |
|
4398 |
|
4399 // |
|
4400 // Confirm the receipt of the message to the client |
|
4401 // |
|
4402 INFO_PRINTF1(_L("Socket set option for indicating receipt of message...")); |
|
4403 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
4404 TEST(recvBuf.Compare(data) == 0); |
|
4405 |
|
4406 // |
|
4407 // Closing the socket |
|
4408 // |
|
4409 CleanupStack::PopAndDestroy(&sock); |
|
4410 CleanupStack::PopAndDestroy(&socketServer); |
|
4411 |
|
4412 return TestStepResult(); |
|
4413 } // CTest7BitBusinessCardWithEmail::doTestStepL |
|
4414 |
|
4415 |
|
4416 /** |
|
4417 * Attempts to send datagrams bigger than the maximum message and bigger |
|
4418 * than the maximum size of an MBuf. |
|
4419 * |
|
4420 * @return EPass or EFail. |
|
4421 */ |
|
4422 TVerdict CTestOversizedDatagram::doTestStepL() |
|
4423 { |
|
4424 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
|
4425 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, 1)); |
|
4426 |
|
4427 TWapAddr wapAddr; |
|
4428 wapAddr.SetWapPort(TWapPortNumber(226)); |
|
4429 |
|
4430 // |
|
4431 // Connect to socket server... |
|
4432 // |
|
4433 RSocketServ socketServer; |
|
4434 |
|
4435 User::LeaveIfError(socketServer.Connect()); |
|
4436 CleanupClosePushL(socketServer); |
|
4437 |
|
4438 // |
|
4439 // Define and open the socket... |
|
4440 // |
|
4441 RSocket sock; |
|
4442 OpenSocketLC(socketServer, sock); |
|
4443 |
|
4444 // |
|
4445 // Wait for the phone to be initialised... |
|
4446 // |
|
4447 WaitForInitializeL(); |
|
4448 |
|
4449 // |
|
4450 // Indicating to the protocol that it's a new client... |
|
4451 // |
|
4452 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
4453 |
|
4454 // |
|
4455 // Send a datagram of the maximum datagram size (this will fail because |
|
4456 // of the WAP headers)... |
|
4457 // |
|
4458 TRequestStatus status; |
|
4459 |
|
4460 HBufC8* textBuf = HBufC8::NewL(65536+1); |
|
4461 CleanupStack::PushL(textBuf); |
|
4462 TPtr8 textPtr = textBuf->Des(); |
|
4463 |
|
4464 textPtr.Fill('A', KWAPSMSMaxDatagramSize); |
|
4465 sock.SendTo(textPtr, wapAddr, 0, status); |
|
4466 User::WaitForRequest(status); |
|
4467 TEST(status.Int() == KErrOverflow); |
|
4468 |
|
4469 // |
|
4470 // Send a datagram bigger than the maximum datagram... |
|
4471 // |
|
4472 textPtr.Fill('B', KWAPSMSMaxDatagramSize+1); |
|
4473 sock.SendTo(textPtr, wapAddr, 0, status); |
|
4474 User::WaitForRequest(status); |
|
4475 TEST(status.Int() == KErrTooBig); |
|
4476 |
|
4477 // |
|
4478 // Send a datagram bigger than the maximum MBuf... |
|
4479 // |
|
4480 textPtr.Fill('C', 65536+1); |
|
4481 sock.SendTo(textPtr, wapAddr, 0, status); |
|
4482 User::WaitForRequest(status); |
|
4483 TEST(status.Int() == KErrTooBig); |
|
4484 |
|
4485 CleanupStack::PopAndDestroy(textBuf); |
|
4486 |
|
4487 // |
|
4488 // Close the socket... |
|
4489 // |
|
4490 CleanupStack::PopAndDestroy(&sock); |
|
4491 CleanupStack::PopAndDestroy(&socketServer); |
|
4492 |
|
4493 return TestStepResult(); |
|
4494 } // CTestOversizedDatagram::doTestStepL |
|
4495 |
|
4496 |
|
4497 TVerdict CTestWapDatagramSegmentContainingNoData::doTestStepL() |
|
4498 /** |
|
4499 * Test step: Receive 3 Wap Datagrams, each WAP message contains |
|
4500 * one or more segments which comprise of a wap header but no data. |
|
4501 * |
|
4502 * @return - TVerdict code |
|
4503 * |
|
4504 */ |
|
4505 { |
|
4506 INFO_PRINTF1(_L("CTestWapDatagramSegmentContainingNoData:")); |
|
4507 |
|
4508 TVerdict verdict = EPass; |
|
4509 |
|
4510 // Create an empty string which will encode into a single segment wap message which contains a wap header, but no wap data. |
|
4511 _LIT8(KLocalTestData1, ""); |
|
4512 TBuf8<300> data1(KLocalTestData1); |
|
4513 // Create a VCard which will encode into 2 segment wapdatagram, the 2nd segment contains a wap header, but no wap data. |
|
4514 // Use a local literal string rather than reading from a text file. This prevents extra unwanted '\' being added to the string, for example \\r\\n |
|
4515 _LIT8(KLocalTestData2,"BEGIN:VCARD\r\nVERSION:2.1\r\nREV:20090403T094807Z\r\nUID:83702f931a905a6e-00e14456815a8324-33\r\nN:;3SIM;;;\r\nTEL;WORK;CELL:07878931672\r\nEND:VCARD\r"); |
|
4516 TBuf8<300> data2(KLocalTestData2); |
|
4517 |
|
4518 |
|
4519 TPtrC16 TelNumber; |
|
4520 TInt port=9204; |
|
4521 TInt testNumber = 36; |
|
4522 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber)) |
|
4523 { |
|
4524 // Leave if there's any error. |
|
4525 User::Leave(KErrNotFound); |
|
4526 } |
|
4527 |
|
4528 RProperty phonePowerProperty; |
|
4529 User::LeaveIfError(phonePowerProperty.Attach(KUidSystemCategory, KUidPhonePwr.iUid)); |
|
4530 CleanupClosePushL(phonePowerProperty); |
|
4531 |
|
4532 RProperty testNumberProperty; |
|
4533 User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
|
4534 CleanupClosePushL(testNumberProperty); |
|
4535 |
|
4536 TRequestStatus status; |
|
4537 phonePowerProperty.Subscribe(status); |
|
4538 User::LeaveIfError(phonePowerProperty.Set(KUidSystemCategory,KUidPhonePwr.iUid,ESAPhoneOn)); |
|
4539 User::WaitForRequest(status); |
|
4540 User::LeaveIfError(status.Int()); |
|
4541 |
|
4542 testNumberProperty.Subscribe(status); |
|
4543 User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNumber)); |
|
4544 User::WaitForRequest(status); |
|
4545 User::LeaveIfError(status.Int()); |
|
4546 TInt testNumberCheck; |
|
4547 User::LeaveIfError(testNumberProperty.Get(testNumberCheck)); |
|
4548 if (testNumber != testNumberCheck) |
|
4549 { |
|
4550 User::Leave(KErrNotFound); |
|
4551 } |
|
4552 // |
|
4553 // Setting the port number and service center number of the wap address |
|
4554 // The service center number should be the same as the sim phone number used |
|
4555 // for test (not required for SIM Tsy) |
|
4556 // |
|
4557 TWapAddr wapAddr; |
|
4558 TWapAddr recvWapAddr; |
|
4559 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
4560 TBuf8<100> scNumber; |
|
4561 scNumber.Copy(TelNumber); |
|
4562 TPtrC8 scAddr(scNumber); |
|
4563 wapAddr.SetWapAddress(scAddr); |
|
4564 |
|
4565 // |
|
4566 // Connect to socket server |
|
4567 // |
|
4568 RSocketServ socketServer; |
|
4569 User::LeaveIfError(socketServer.Connect()); |
|
4570 CleanupClosePushL(socketServer); |
|
4571 |
|
4572 // |
|
4573 // Define and open the socket |
|
4574 // |
|
4575 RSocket sock; |
|
4576 OpenSocketLC(socketServer, sock); |
|
4577 |
|
4578 |
|
4579 // |
|
4580 // Waiting for the phone to be initialised |
|
4581 // |
|
4582 WaitForInitializeL(); |
|
4583 |
|
4584 TRequestStatus ioctlStatus; |
|
4585 TRequestStatus recvStatus; |
|
4586 TPckgBuf<TInt> length; |
|
4587 |
|
4588 // |
|
4589 // Indicating to the protocol that it's a new client |
|
4590 // |
|
4591 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
4592 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
4593 // |
|
4594 // Bind |
|
4595 // |
|
4596 User::LeaveIfError(sock.Bind(wapAddr)); |
|
4597 |
|
4598 // |
|
4599 // Issue Ioctl for getting the length of the message |
|
4600 // |
|
4601 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for first VCal entry")); |
|
4602 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
4603 |
|
4604 |
|
4605 TBuf8<300> data; |
|
4606 |
|
4607 // |
|
4608 // Send a SMS in order to trigger receiving the SMS messages. |
|
4609 // This is to make sure the SMS messages are not received before the |
|
4610 // wap address is bound to the socket. |
|
4611 // |
|
4612 sock.SendTo(data1, wapAddr, 0, status); |
|
4613 User::WaitForRequest(status); |
|
4614 User::LeaveIfError(status.Int()); |
|
4615 INFO_PRINTF1(_L("First Message (VCal) sent...")); |
|
4616 |
|
4617 // |
|
4618 // Get the size of the first incoming message |
|
4619 // The text string should be empty. |
|
4620 // |
|
4621 TBuf8<300> recvBuf; |
|
4622 User::WaitForRequest(ioctlStatus); |
|
4623 User::LeaveIfError(ioctlStatus.Int()); |
|
4624 INFO_PRINTF1(_L("IOCTL completed")); |
|
4625 // |
|
4626 // Check if reported length is correct |
|
4627 // |
|
4628 if(length()!=data1.Length()) |
|
4629 { |
|
4630 verdict = EFail; |
|
4631 } |
|
4632 //> // Receiving a datagram |
|
4633 // |
|
4634 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
4635 User::WaitForRequest(recvStatus); |
|
4636 User::LeaveIfError(recvStatus.Int()); |
|
4637 INFO_PRINTF1(_L("Received the first message (VCal)...")); |
|
4638 |
|
4639 // The receive buffer should contain an empty string. |
|
4640 // This is as a consequence of the wapprot receiving |
|
4641 // a single segment wap message which contains no data. |
|
4642 if(recvBuf.Compare(data1)) |
|
4643 { |
|
4644 ERR_PRINTF1(_L("Non empty string returned")); |
|
4645 verdict = EFail; |
|
4646 } |
|
4647 |
|
4648 // |
|
4649 // Confirm the receipt of the message to the client |
|
4650 // |
|
4651 INFO_PRINTF1(_L("Socket set option for indicating receipt of first message (VCal)")); |
|
4652 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
4653 |
|
4654 |
|
4655 //Issue Ioctl for getting the length of the second message |
|
4656 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for second VCard entry")); |
|
4657 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
4658 |
|
4659 //Get the size of the second incoming message |
|
4660 User::WaitForRequest(ioctlStatus); |
|
4661 User::LeaveIfError(ioctlStatus.Int()); |
|
4662 INFO_PRINTF1(_L("IOCTL completed for second message (VCard)")); |
|
4663 |
|
4664 //Check if reported length is correct |
|
4665 if(length()!=data2.Length()) |
|
4666 { |
|
4667 verdict = EFail; |
|
4668 } |
|
4669 |
|
4670 //Receiving a datagram (VCard) |
|
4671 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
4672 User::WaitForRequest(recvStatus); |
|
4673 User::LeaveIfError(recvStatus.Int()); |
|
4674 INFO_PRINTF1(_L("Received the second message (VCard)...")); |
|
4675 |
|
4676 // Compare the received VCard message with the original one. |
|
4677 // They should be identical. This checks that the WAPPROT |
|
4678 // can receive a 2 segment wap datagram, with the 2nd segment containing no data. |
|
4679 // |
|
4680 if(recvBuf.Compare(data2)) |
|
4681 { |
|
4682 ERR_PRINTF1(_L("VCard message received does not match with original message.")); |
|
4683 verdict = EFail; |
|
4684 } |
|
4685 |
|
4686 //Confirm the receipt of the message to the client |
|
4687 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
4688 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
4689 //Issue Ioctl for getting the length of the third message |
|
4690 |
|
4691 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for second VCard entry")); |
|
4692 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
4693 |
|
4694 //Get the size of the third incoming message |
|
4695 User::WaitForRequest(ioctlStatus); |
|
4696 User::LeaveIfError(ioctlStatus.Int()); |
|
4697 INFO_PRINTF1(_L("IOCTL completed for third message (VCard)")); |
|
4698 |
|
4699 //Check if reported length is correct |
|
4700 if(length()!=data1.Length()) |
|
4701 { |
|
4702 verdict = EFail; |
|
4703 } |
|
4704 |
|
4705 //Receiving a datagram (VCard) |
|
4706 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
4707 User::WaitForRequest(recvStatus); |
|
4708 User::LeaveIfError(recvStatus.Int()); |
|
4709 INFO_PRINTF1(_L("Received the third message (VCard)...")); |
|
4710 |
|
4711 // The receive buffer should contain an empty string. |
|
4712 // This is as a consequence of the WAPPROT containing 2 concatenated WAP Datagrams |
|
4713 // each datagram segement containing no data. |
|
4714 if(recvBuf.Compare(data1)) |
|
4715 { |
|
4716 ERR_PRINTF1(_L("VCard message received does not match with original message.")); |
|
4717 verdict = EFail; |
|
4718 } |
|
4719 |
|
4720 //Confirm the receipt of the message to the client |
|
4721 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
4722 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
4723 // |
|
4724 // Closing the socket |
|
4725 // |
|
4726 sock.Close(); |
|
4727 socketServer.Close(); |
|
4728 CleanupStack::PopAndDestroy(&sock); |
|
4729 CleanupStack::Pop(&socketServer); |
|
4730 CleanupStack::PopAndDestroy(&testNumberProperty); |
|
4731 CleanupStack::PopAndDestroy(&phonePowerProperty); |
|
4732 INFO_PRINTF1(_L("End of CTestWapDatagramSegmentContainingNoData")); |
|
4733 SetTestStepResult(verdict); |
|
4734 return TestStepResult(); |
|
4735 } |
|
4736 |