14 // implementation of test steps |
14 // implementation of test steps |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
18 /** |
18 /** |
19 @file |
19 @file |
|
20 @test |
20 */ |
21 */ |
21 |
22 |
22 |
|
23 #include "WapIoctlSteps.h" |
23 #include "WapIoctlSteps.h" |
|
24 |
|
25 #include <simtsy.h> |
|
26 #include <smspver.h> |
|
27 #include <wap_sock.h> |
|
28 |
|
29 #include "smsstacktestconsts.h" |
24 #include "WapProtSuiteDefs.h" |
30 #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 |
31 |
33 TVerdict CIoctlStep_1::doTestStepL() |
32 TVerdict CIoctlStep_1::doTestStepL() |
34 /** |
33 /** |
35 * Test step one: |
34 * Test step one: |
36 * Sends/receives a 7Bit business card using IOCTL |
35 * Sends/receives a 7Bit business card using IOCTL |
37 * @return - TVerdict code |
36 * @return - TVerdict code |
38 * |
|
39 */ |
37 */ |
40 { |
38 { |
41 INFO_PRINTF1(_L("IOCTL Test step 1: send/receive 7-Bit business card")); |
39 INFO_PRINTF1(_L("IOCTL Test step 1: send/receive 7-Bit business card")); |
42 |
40 // Configure and bind to a socket |
43 TPtrC TestData1; |
41 SetupWapSocketL(); |
44 TPtrC16 TelNumber; |
42 |
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 |
43 // Send a business card |
107 // |
44 TPtrC testData = GetStringFromConfigL(KTestData1); |
108 TRequestStatus status; |
45 |
109 |
46 SendWapMessage(testData); |
110 TBuf8<200> data; |
47 |
111 data.Copy(TestData1); |
48 // Receive the business card |
112 sock.SendTo(data, wapAddr, 0, status); |
49 ReceiveWapMessage(testData); |
113 User::WaitForRequest(status); |
50 |
114 User::LeaveIfError(status.Int()); |
51 iSocket.Close(); |
115 INFO_PRINTF1(_L("Message sent...")); |
52 return TestStepResult(); |
116 |
53 } |
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 |
54 |
162 TVerdict CIoctlStep_2::doTestStepL() |
55 TVerdict CIoctlStep_2::doTestStepL() |
163 /** |
56 /** |
164 * Test step two: |
57 * Test step two: |
165 * Sends/receives a 7-Bit calendar entry and VCard using IOCTL(two segments each) |
58 * Sends/receives a 7-Bit calendar entry and VCard using IOCTL(two segments each) |
166 * @return - TVerdict code |
59 * @return - TVerdict code |
167 * |
60 */ |
168 */ |
61 { |
169 { |
|
170 |
|
171 INFO_PRINTF1(_L("IOCTL Test step 2: send/receive a VCal and VCard")); |
62 INFO_PRINTF1(_L("IOCTL Test step 2: send/receive a VCal and VCard")); |
172 |
63 // Configure and bind to a socket |
173 TPtrC TestData1; |
64 SetupWapSocketL(); |
174 TPtrC TestData2; |
65 |
|
66 // Issue Ioctl for getting the length of the message |
|
67 TRequestStatus ioctlStatus; |
|
68 TPckgBuf<TInt> length; |
|
69 |
|
70 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the first message (VCal)...")); |
|
71 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
72 |
|
73 TPtrC testData1 = GetStringFromConfigL(KTestData1); |
|
74 TPtrC testData2 = GetStringFromConfigL(KTestData2); |
|
75 |
|
76 // Send a VCal entry |
|
77 SendWapMessage(testData1); |
|
78 |
|
79 // Send a VCard entry with extended GSM alphabets |
|
80 SendWapMessage(testData2); |
|
81 |
|
82 // Get the size of the first incoming message |
|
83 User::WaitForRequest(ioctlStatus); |
|
84 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
|
85 TESTCHECK(length(), testData1.Length(), "Check if reported length is correct"); |
|
86 |
|
87 // Receive the VCal message |
|
88 ReceiveWapMessageFromSocket(length(), testData1); |
|
89 |
|
90 // Receive the VCard message |
|
91 ReceiveWapMessage(testData2); |
|
92 |
|
93 iSocket.Close(); |
|
94 return TestStepResult(); |
|
95 } |
|
96 |
|
97 TVerdict CIoctlStep_3::doTestStepL() |
|
98 /** |
|
99 * Test step 3: |
|
100 * send/receive one 7-Bit two segments message and one 7-Bit one segment message |
|
101 * @return - TVerdict code |
|
102 */ |
|
103 { |
|
104 INFO_PRINTF1(_L("IOCTL Test step 3: send/receive two 7-Bit messages")); |
|
105 // Configure and bind to a socket |
|
106 SetupWapSocketL(); |
|
107 |
|
108 // Issue Ioctl for getting the length of the message |
|
109 TRequestStatus ioctlStatus; |
|
110 TPckgBuf<TInt> length; |
|
111 |
|
112 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the first message...")); |
|
113 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
114 |
|
115 TPtrC testData1 = GetStringFromConfigL(KTestData1); |
|
116 TPtrC testData2 = GetStringFromConfigL(KTestData2); |
|
117 |
|
118 // Send a business card |
|
119 SendWapMessage(testData2); |
|
120 |
|
121 // Send a business card |
|
122 SendWapMessage(testData1); |
|
123 |
|
124 // Get the size of the first incoming message |
|
125 User::WaitForRequest(ioctlStatus); |
|
126 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
|
127 TESTCHECK(length(), testData2.Length(), "Check if reported length is correct"); |
|
128 |
|
129 // Receive the first message |
|
130 ReceiveWapMessageFromSocket(length(), testData2); |
|
131 |
|
132 // Receive the second message |
|
133 ReceiveWapMessage(testData1); |
|
134 |
|
135 iSocket.Close(); |
|
136 return TestStepResult(); |
|
137 } |
|
138 |
|
139 TVerdict CIoctlStep_4::doTestStepL() |
|
140 /** |
|
141 * Test step 4: |
|
142 * simulating client crash conditions with 7bit message |
|
143 * @return - TVerdict code |
|
144 */ |
|
145 { |
|
146 INFO_PRINTF1(_L("IOCTL Test step 4: client crash condition 7-Bit message ")); |
|
147 // Configure and bind to a socket |
|
148 SetupWapSocketL(); |
|
149 |
|
150 // Issue Ioctl for getting the length of the message |
|
151 TRequestStatus ioctlStatus; |
|
152 TPckgBuf<TInt> length; |
|
153 |
|
154 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the first message...")); |
|
155 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
156 |
|
157 // Send a business card |
|
158 TPtrC testData = GetStringFromConfigL(KTestData1); |
|
159 SendWapMessage(testData); |
|
160 |
|
161 // Get the size of the first incoming message |
|
162 User::WaitForRequest(ioctlStatus); |
|
163 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
|
164 TESTCHECK(length(), testData.Length(), "Check if reported length is correct"); |
|
165 |
|
166 // Receive a message |
|
167 TRequestStatus recvStatus; |
|
168 TWapAddr recvWapAddr; |
|
169 HBufC8* recvBuf = HBufC8::NewLC(length()); |
|
170 TPtr8 recvPtr = recvBuf->Des(); |
|
171 |
|
172 iSocket.RecvFrom(recvPtr, recvWapAddr, 0, recvStatus); |
|
173 User::WaitForRequest(recvStatus); |
|
174 TESTCHECKL(recvStatus.Int(), KErrNone, "Receiving a message"); |
|
175 |
|
176 // Simulate a crash by closing and reopening the socket |
|
177 iSocket.Close(); |
|
178 INFO_PRINTF1(_L("Socket was closed...")); |
|
179 |
|
180 OpenSocketL(iSocketServer, iSocket); |
|
181 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
182 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
183 User::LeaveIfError(iSocket.Bind(iWapAddr)); |
|
184 INFO_PRINTF1(_L("Socket was opened...")); |
|
185 |
|
186 // Issue another get length of datagram as if not aware of the previous message |
|
187 // and retrieve the message from the SAR store |
|
188 ReceiveWapMessage(testData); |
|
189 |
|
190 iSocket.Close(); |
|
191 CleanupStack::PopAndDestroy(recvBuf); |
|
192 return TestStepResult(); |
|
193 } |
|
194 |
|
195 TVerdict CIoctlStep_5::doTestStepL() |
|
196 /** |
|
197 * Test step 5: |
|
198 * simulating client crash conditions with 8bit push message |
|
199 * @return - TVerdict code |
|
200 */ |
|
201 { |
|
202 INFO_PRINTF1(_L("IOCTL Test step 5: client crash condition with 8Bit push message")); |
|
203 // Configure and bind to a socket |
|
204 SetupWapSocketL(); |
|
205 |
|
206 // Issue Ioctl for getting the length of the message |
|
207 TRequestStatus ioctlStatus; |
|
208 TPckgBuf<TInt> length; |
|
209 |
|
210 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the first message...")); |
|
211 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
212 |
|
213 // Get the size of the incoming message |
|
214 User::WaitForRequest(ioctlStatus); |
|
215 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
|
216 |
|
217 // Receive a message |
|
218 TRequestStatus recvStatus; |
|
219 TWapAddr recvWapAddr; |
|
220 HBufC8* recvBuf = HBufC8::NewLC(length()); |
|
221 TPtr8 recvPtr = recvBuf->Des(); |
|
222 |
|
223 iSocket.RecvFrom(recvPtr, recvWapAddr, 0, recvStatus); |
|
224 User::WaitForRequest(recvStatus); |
|
225 TESTCHECKL(recvStatus.Int(), KErrNone, "Receiving a message"); |
|
226 |
|
227 // Simulate a crash by closing and reopening the socket |
|
228 iSocket.Close(); |
|
229 INFO_PRINTF1(_L("Socket was closed...")); |
|
230 |
|
231 OpenSocketL(iSocketServer, iSocket); |
|
232 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
233 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
234 User::LeaveIfError(iSocket.Bind(iWapAddr)); |
|
235 INFO_PRINTF1(_L("Socket was opened...")); |
|
236 |
|
237 // Issue another get length of datagram as if not aware of the previous message |
|
238 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
239 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
240 |
|
241 // waiting for request to be completed |
|
242 User::WaitForRequest(ioctlStatus); |
|
243 User::LeaveIfError(ioctlStatus.Int()); |
|
244 INFO_PRINTF1(_L("IOCTL completed...")); |
|
245 |
|
246 // New message retrieved from SAR store |
|
247 HBufC8* recvBuf2 = HBufC8::NewLC(length()); |
|
248 TPtr8 recvPtr2 = recvBuf2->Des(); |
|
249 |
|
250 iSocket.RecvFrom(recvPtr2,recvWapAddr,0,recvStatus); |
|
251 User::WaitForRequest(recvStatus); |
|
252 User::LeaveIfError(recvStatus.Int()); |
|
253 INFO_PRINTF1(_L("Received the message...")); |
|
254 |
|
255 // Confirm the receipt of the message to the client |
|
256 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
257 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
258 |
|
259 // Compare the received message with the previous one |
|
260 // They should be identical |
|
261 TEST(recvPtr2.Compare(recvPtr) == 0); |
|
262 |
|
263 iSocket.Close(); |
|
264 CleanupStack::PopAndDestroy(2, recvBuf); // recvBuf, recvBuf2 |
|
265 return TestStepResult(); |
|
266 } |
|
267 |
|
268 TVerdict CIoctlStep_6::doTestStepL() |
|
269 /** |
|
270 * Test step 6: |
|
271 * Sends/receives a business card (Old client testing) |
|
272 * @return - TVerdict code |
|
273 */ |
|
274 { |
|
275 INFO_PRINTF1(_L("IOCTL Test step 6: send/receive a VCard (Old client testing)")); |
|
276 // Configure and bind to a socket, do not set the "new style client" option |
|
277 SetupWapSocketL(iSocket, iWapAddr, KWapPort, EFalse); |
|
278 |
|
279 // Send a calendar entry |
|
280 TPtrC testData = GetStringFromConfigL(KTestData1); |
|
281 SendWapMessage(testData); |
|
282 |
|
283 // Receiving a datagram |
|
284 TRequestStatus recvStatus; |
|
285 TWapAddr recvWapAddr; |
|
286 TBuf8<256> recvBuf; |
|
287 |
|
288 INFO_PRINTF1(_L("Receiving a message from the socket...")); |
|
289 iSocket.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
290 User::WaitForRequest(recvStatus); |
|
291 TESTCHECKL(recvStatus.Int(), KErrNone, "Receiving a message"); |
|
292 |
|
293 iSocket.Close(); |
|
294 return TestStepResult(); |
|
295 } |
|
296 |
|
297 TVerdict CIoctlStep_7::doTestStepL() |
|
298 /** |
|
299 * Test step 7: |
|
300 * Receives a Push Message (8-Bit) |
|
301 * @return - TVerdict code |
|
302 */ |
|
303 { |
|
304 INFO_PRINTF1(_L("IOCTL Test step 7: Receive push message(8-Bit)")); |
|
305 // Configure and bind to a socket |
|
306 SetupWapSocketL(); |
|
307 |
|
308 // |
|
309 // Issue Ioctl for getting the length of the message |
|
310 TRequestStatus ioctlStatus; |
|
311 TPckgBuf<TInt> length; |
|
312 |
|
313 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
314 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
315 |
|
316 // |
|
317 // Get the size of the incomming push message |
|
318 // |
|
319 User::WaitForRequest(ioctlStatus); |
|
320 User::LeaveIfError(ioctlStatus.Int()); |
|
321 INFO_PRINTF1(_L("IOCTL completed...")); |
|
322 |
|
323 // |
|
324 // Receiving push datagram |
|
325 // |
|
326 TRequestStatus recvStatus; |
|
327 TWapAddr recvWapAddr; |
|
328 TBuf8<256> recvBuf2(length); |
|
329 |
|
330 iSocket.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
331 User::WaitForRequest(recvStatus); |
|
332 User::LeaveIfError(recvStatus.Int()); |
|
333 INFO_PRINTF1(_L("Received the push message...")); |
|
334 |
|
335 // |
|
336 // Confirm the receipt of the message to the client |
|
337 // |
|
338 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
339 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
340 |
|
341 iSocket.Close(); |
|
342 return TestStepResult(); |
|
343 } |
|
344 |
|
345 TVerdict CIoctlStep_8::doTestStepL() |
|
346 /** |
|
347 * Test step 8: |
|
348 * Receives two Push Messages (8-Bit) Tests store of 8-Bit messages |
|
349 * @return - TVerdict code |
|
350 */ |
|
351 { |
|
352 INFO_PRINTF1(_L("IOCTL Test step 8: Receive two push message(8-Bit)")); |
|
353 // Configure and bind to a socket |
|
354 SetupWapSocketL(); |
|
355 |
|
356 // |
|
357 // Issue Ioctl for getting the length of the message |
|
358 // |
|
359 TRequestStatus ioctlStatus; |
|
360 TPckgBuf<TInt> length; |
|
361 |
|
362 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
363 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
364 // |
|
365 // Get the size of the incomming push message |
|
366 // |
|
367 User::WaitForRequest(ioctlStatus); |
|
368 User::LeaveIfError(ioctlStatus.Int()); |
|
369 INFO_PRINTF1(_L("IOCTL completed...")); |
|
370 |
|
371 // |
|
372 // Receiving push datagram |
|
373 // |
|
374 TRequestStatus recvStatus; |
|
375 TWapAddr recvWapAddr; |
|
376 TBuf8<256> recvBuf1(length); |
|
377 |
|
378 iSocket.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
|
379 User::WaitForRequest(recvStatus); |
|
380 User::LeaveIfError(recvStatus.Int()); |
|
381 INFO_PRINTF1(_L("Received the push message...")); |
|
382 |
|
383 // |
|
384 // Confirm the receipt of the message to the client |
|
385 // |
|
386 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
387 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
388 |
|
389 // |
|
390 // Issue another Ioctl for getting the length of the message |
|
391 // |
|
392 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
|
393 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
394 // |
|
395 // Get the size of the second incomming push message |
|
396 // |
|
397 User::WaitForRequest(ioctlStatus); |
|
398 User::LeaveIfError(ioctlStatus.Int()); |
|
399 INFO_PRINTF1(_L("IOCTL completed...")); |
|
400 // |
|
401 // Allocate buffer |
|
402 // |
|
403 TBuf8<256> recvBuf2(length); |
|
404 |
|
405 // |
|
406 // Receiving push datagram |
|
407 // |
|
408 iSocket.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
409 User::WaitForRequest(recvStatus); |
|
410 User::LeaveIfError(recvStatus.Int()); |
|
411 INFO_PRINTF1(_L("Received the second push message...")); |
|
412 // |
|
413 // Compare the received message with the previous one |
|
414 // They should be identical |
|
415 // |
|
416 TEST(recvBuf2.Compare(recvBuf1) == 0); |
|
417 |
|
418 // |
|
419 // Confirm the receipt of the message to the client |
|
420 // |
|
421 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
422 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
423 |
|
424 iSocket.Close(); |
|
425 return TestStepResult(); |
|
426 } |
|
427 |
|
428 TVerdict CIoctlStep_9::doTestStepL() |
|
429 /** |
|
430 * Test step 9: |
|
431 * Receive a 8-Bit push message (Old client testing) |
|
432 * @return - TVerdict code |
|
433 */ |
|
434 { |
|
435 INFO_PRINTF1(_L("IOCTL Test step 9: receive a push message (Testing old client)")); |
|
436 // Configure and bind to a socket, do not set the "new style client" option |
|
437 SetupWapSocketL(iSocket, iWapAddr, KWapPort, EFalse); |
|
438 |
|
439 // |
|
440 // Receiving a datagram |
|
441 // |
|
442 TRequestStatus recvStatus; |
|
443 TWapAddr recvWapAddr; |
|
444 TBuf8<256> recvBuf; |
|
445 |
|
446 iSocket.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
447 User::WaitForRequest(recvStatus); |
|
448 User::LeaveIfError(recvStatus.Int()); |
|
449 INFO_PRINTF1(_L("Received the message...")); |
|
450 |
|
451 iSocket.Close(); |
|
452 return TestStepResult(); |
|
453 } |
|
454 |
|
455 TVerdict CIoctlStep_10::doTestStepL() |
|
456 /** |
|
457 * Test step Ten: |
|
458 * Sends/receives a 7Bit business card using IOCTL |
|
459 * @return - TVerdict code |
|
460 */ |
|
461 { |
|
462 INFO_PRINTF1(_L("IOCTL Test step 10: send/receive 7-Bit business card using IOCTL")); |
|
463 // Configure and bind to a socket |
|
464 SetupWapSocketL(); |
|
465 |
|
466 // Send a calendar entry |
|
467 TPtrC testData = GetStringFromConfigL(KTestData1); |
|
468 SendWapMessage(testData); |
|
469 |
|
470 ReceiveWapMessage(testData); |
|
471 |
|
472 iSocket.Close(); |
|
473 return TestStepResult(); |
|
474 } |
|
475 |
|
476 TVerdict CIoctlStep_11::doTestStepL() |
|
477 /** |
|
478 * Test step 11: |
|
479 * Test Cancel IOCTL |
|
480 * @return - TVerdict code |
|
481 */ |
|
482 { |
|
483 INFO_PRINTF1(_L("IOCTL Test step 11: Testing CancelIOCTL")); |
|
484 // Configure and bind to a socket |
|
485 SetupWapSocketL(); |
|
486 |
|
487 // Issue Ioctl for getting the length of the message |
|
488 TRequestStatus ioctlStatus; |
|
489 TPckgBuf<TInt> length; |
|
490 |
|
491 INFO_PRINTF1(_L("Issue of IOCTL for GetLength")); |
|
492 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
493 |
|
494 // Issue Cancel Ioctl |
|
495 INFO_PRINTF1(_L("Issue of cancel IOCTL for GetLength")); |
|
496 iSocket.CancelIoctl(); |
|
497 TESTCHECK(ioctlStatus.Int(), KErrCancel, "Check if the outstanding IOCTL has been canceled"); |
|
498 |
|
499 iSocket.Close(); |
|
500 return TestStepResult(); |
|
501 } |
|
502 |
|
503 TVerdict CIoctlStep_12::doTestStepL() |
|
504 /** |
|
505 * Test step 12: |
|
506 * Test issue IOCTL without SetOption NewStyleClient |
|
507 * @return - TVerdict code |
|
508 */ |
|
509 { |
|
510 INFO_PRINTF1(_L("IOCTL Test step 12: Test issue IOCTL without SetOption NewStyleClient")); |
|
511 // Configure and bind to a socket, do not set the "new style client" option |
|
512 SetupWapSocketL(iSocket, iWapAddr, KWapPort, EFalse); |
|
513 |
|
514 // Issue Ioctl for getting the length of the message (should fail) |
|
515 TRequestStatus ioctlStatus; |
|
516 TPckgBuf<TInt> length; |
|
517 |
|
518 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
|
519 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
520 TESTCHECKCONDITION(ioctlStatus.Int()!=KErrNone, "Getting the length of the incoming message"); |
|
521 |
|
522 iSocket.Close(); |
|
523 return TestStepResult(); |
|
524 } |
|
525 |
|
526 TVerdict CIoctlStep_13::doTestStepL() |
|
527 /** |
|
528 * Test step two: |
|
529 * Sends/receives a 8-Bit calendar entry using IOCTL(two segments) |
|
530 * @return - TVerdict code |
|
531 */ |
|
532 { |
|
533 INFO_PRINTF1(_L("IOCTL Test step 13: send/receive a 8-Bit VCal")); |
|
534 // Configure and bind to a socket |
|
535 SetupWapSocketL(); |
|
536 |
|
537 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms8BitDCS)); |
|
538 |
|
539 // Issue Ioctl for getting the length of the message |
|
540 TRequestStatus ioctlStatus; |
|
541 TPckgBuf<TInt> length; |
|
542 |
|
543 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
|
544 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
545 |
|
546 // Send a calendar entry |
|
547 TPtrC testData = GetStringFromConfigL(KTestData1); |
|
548 SendWapMessage(testData); |
|
549 |
|
550 // Get the size of the incoming message |
|
551 User::WaitForRequest(ioctlStatus); |
|
552 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the incoming message"); |
|
553 TESTCHECK(length(), testData.Length(), "Check if reported length is correct"); |
|
554 |
|
555 ReceiveWapMessageFromSocket(length(), testData); |
|
556 |
|
557 iSocket.Close(); |
|
558 return TestStepResult(); |
|
559 } |
|
560 |
|
561 TVerdict CIoctlStep_14::doTestStepL() |
|
562 /** |
|
563 * Test step 14: |
|
564 * simulating client crash conditions with 8bit calendar entry |
|
565 * @return - TVerdict code |
|
566 */ |
|
567 { |
|
568 INFO_PRINTF1(_L("IOCTL Test step 14: client crash condition 8-Bit calendar entry ")); |
|
569 // Configure and bind to a socket |
|
570 SetupWapSocketL(); |
|
571 |
|
572 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms8BitDCS)); |
|
573 |
|
574 // |
|
575 // Issue Ioctl for getting the length of the message |
|
576 // |
|
577 TRequestStatus ioctlStatus; |
|
578 TPckgBuf<TInt> length; |
|
579 |
|
580 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
|
581 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
582 |
|
583 // Send a Calendar entry |
|
584 TPtrC testData = GetStringFromConfigL(KTestData1); |
|
585 SendWapMessage(testData); |
|
586 |
|
587 // Get the size of the incoming message |
|
588 User::WaitForRequest(ioctlStatus); |
|
589 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the incoming message"); |
|
590 TESTCHECK(length(), testData.Length(), "Check if reported length is correct"); |
|
591 |
|
592 // Receive a message |
|
593 TRequestStatus recvStatus; |
|
594 TWapAddr recvWapAddr; |
|
595 HBufC8* recvBuf = HBufC8::NewLC(length()); |
|
596 TPtr8 recvPtr = recvBuf->Des(); |
|
597 |
|
598 iSocket.RecvFrom(recvPtr, recvWapAddr, 0, recvStatus); |
|
599 User::WaitForRequest(recvStatus); |
|
600 TESTCHECKL(recvStatus.Int(), KErrNone, "Receiving a message"); |
|
601 |
|
602 // Simulate a crash by closing and reopening the socket |
|
603 iSocket.Close(); |
|
604 INFO_PRINTF1(_L("Socket was closed...")); |
|
605 |
|
606 OpenSocketL(iSocketServer, iSocket); |
|
607 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
608 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
609 User::LeaveIfError(iSocket.Bind(iWapAddr)); |
|
610 INFO_PRINTF1(_L("Socket was opened...")); |
|
611 |
|
612 // Issue another get length of datagram as if not aware of the previous message |
|
613 // and retrieve the message from the SAR store |
|
614 ReceiveWapMessage(testData); |
|
615 |
|
616 iSocket.Close(); |
|
617 CleanupStack::PopAndDestroy(recvBuf); |
|
618 return TestStepResult(); |
|
619 } |
|
620 |
|
621 TVerdict CIoctlStep_15::doTestStepL() |
|
622 /** |
|
623 * Test step fifteen: |
|
624 * Receives a 7Bit v-card using IOCTL with concatenation for new style client |
|
625 * @return - TVerdict code |
|
626 */ |
|
627 { |
|
628 INFO_PRINTF1(_L("IOCTL Test step 15: send/receive 7-Bit v-card")); |
|
629 // Configure and bind to a socket |
|
630 SetupWapSocketL(); |
|
631 |
|
632 // |
|
633 // Issue Ioctl for getting the length of the message |
|
634 // |
|
635 TRequestStatus ioctlStatus; |
|
636 TPckgBuf<TInt> length; |
|
637 |
|
638 INFO_PRINTF1(_L("Issue of IOCTL for GetLength")); |
|
639 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
|
640 |
|
641 // |
|
642 // Get the size of the first incoming message |
|
643 // |
|
644 User::WaitForRequest(ioctlStatus); |
|
645 User::LeaveIfError(ioctlStatus.Int()); |
|
646 INFO_PRINTF1(_L("IOCTL completed")); |
|
647 |
|
648 // |
|
649 // Receiving a datagram that is 7bit with a concatenated length of > 160 characters |
|
650 // |
|
651 TRequestStatus recvStatus; |
|
652 TWapAddr recvWapAddr; |
|
653 TBuf8<360> recvBuf(length); |
|
654 |
|
655 iSocket.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
|
656 User::WaitForRequest(recvStatus); |
|
657 User::LeaveIfError(recvStatus.Int()); |
|
658 INFO_PRINTF1(_L("Received the message...")); |
|
659 |
|
660 // |
|
661 // Confirm the receipt of the message to the client |
|
662 // |
|
663 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
|
664 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
|
665 |
|
666 iSocket.Close(); |
|
667 return TestStepResult(); |
|
668 } |
|
669 |
|
670 TInt CBackupRestoreStep::SendWapL() |
|
671 { |
|
672 //modified from test 10 |
|
673 INFO_PRINTF1(_L("SendWapL: send 7-Bit business card using IOCTL")); |
|
674 |
|
675 TInt ret = KErrNone; |
|
676 |
175 TPtrC16 TelNumber; |
677 TPtrC16 TelNumber; |
176 TInt port=226; |
678 TInt port=226; |
177 TInt testNumber = 2; |
679 |
178 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData1) || |
680 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
179 !GetStringFromConfig(ConfigSection(),KTestData2, TestData2) || |
|
180 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
|
181 !GetIntFromConfig(ConfigSection(),KWapPort,port) |
681 !GetIntFromConfig(ConfigSection(),KWapPort,port) |
182 ) |
682 ) |
183 { |
683 { |
184 // Leave if there's any error. |
684 // Leave if there's any error. |
185 User::Leave(KErrNotFound); |
685 User::Leave(KErrNotFound); |
186 } |
686 } |
187 |
687 |
188 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
688 // |
189 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
689 // Setting the port number and service center number of the wap address |
190 |
690 // The service center number should be the same as the sim phone number used |
191 // |
691 // for test (not required for SIM tsy) |
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 // |
692 // |
196 TWapAddr wapAddr; |
693 TWapAddr wapAddr; |
197 TWapAddr recvWapAddr; |
|
198 wapAddr.SetWapPort(TWapPortNumber(port)); |
694 wapAddr.SetWapPort(TWapPortNumber(port)); |
|
695 |
199 TBuf8<100> scNumber; |
696 TBuf8<100> scNumber; |
200 scNumber.Copy(TelNumber); |
697 scNumber.Copy(TelNumber); |
201 TPtrC8 scAddr(scNumber); |
698 TPtrC8 scAddr(scNumber); |
202 wapAddr.SetWapAddress(scAddr); |
699 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 |
700 |
2020 // |
701 // |
2021 // Define and open the socket |
702 // Define and open the socket |
2022 // |
703 // |
2023 RSocket sock; |
704 RSocket sock; |
2130 return ret; |
802 return ret; |
2131 } |
803 } |
2132 |
804 |
2133 TVerdict CBackupRestoreStep::doTestStepL() |
805 TVerdict CBackupRestoreStep::doTestStepL() |
2134 /** |
806 /** |
2135 * |
|
2136 * Test step 16: |
807 * Test step 16: |
2137 * simulating backup and restore |
808 * simulating backup and restore |
2138 * @return - TVerdict code |
809 * @return - TVerdict code |
2139 * |
810 */ |
2140 */ |
811 { |
2141 { |
812 INFO_PRINTF1(_L("IOCTL Test step 16: send 7-Bit business card using IOCTL to test backup and restore")); |
2142 TInt testNumber =16; |
813 CSBEClient* secureBackupEngine = CSBEClient::NewL(); |
2143 RProperty testNumberProperty; |
814 CleanupStack::PushL(secureBackupEngine); |
2144 |
815 secureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
2145 User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
816 EBURNormal, ENoBackup); |
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 |
817 |
2165 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
818 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
2166 TEST(SendWapL() == KErrNone); |
819 TEST(SendWapL() == KErrNone); |
2167 TEST(IsWapFileOpenL() != EFalse); |
820 TEST(IsWapFileOpenL() != EFalse); |
2168 |
821 |
2169 // Notify the WAPPROT server that a backup is about to take place and |
822 // Notify the WAPPROT server that a backup is about to take place and |
2170 // that the server should close the wapstor |
823 // that the server should close the wapstor |
2171 INFO_PRINTF1(_L("Simulating a backup notification")); |
824 INFO_PRINTF1(_L("Simulating a backup notification")); |
2172 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
825 secureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
2173 EBURBackupFull, EBackupBase); |
826 EBURBackupFull, EBackupBase); |
2174 |
827 |
2175 INFO_PRINTF1(_L("Expecting SendWapL to fail and the wap data file to be closed")); |
828 INFO_PRINTF1(_L("Expecting SendWapL to fail and the wap data file to be closed")); |
2176 TEST(SendWapL() != KErrNone); |
829 TEST(SendWapL() != KErrNone); |
2177 TEST(IsWapFileOpenL() == EFalse); |
830 TEST(IsWapFileOpenL() == EFalse); |
2178 |
831 |
2179 // Notify the WAPPROT server that a backup has completed |
832 // Notify the WAPPROT server that a backup has completed |
2180 // that the server should open the wapstor |
833 // that the server should open the wapstor |
2181 INFO_PRINTF1(_L("Simulating a backup complete notification")); |
834 INFO_PRINTF1(_L("Simulating a backup complete notification")); |
2182 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
835 secureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
2183 EBURNormal, ENoBackup); |
836 EBURNormal, ENoBackup); |
2184 |
837 |
2185 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
838 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
2186 TEST(SendWapL() == KErrNone); |
839 TEST(SendWapL() == KErrNone); |
2187 TEST(IsWapFileOpenL() != EFalse); |
840 TEST(IsWapFileOpenL() != EFalse); |
2188 |
841 |
2189 // Notify the WAPPROT server that a restore is about to take place and |
842 // Notify the WAPPROT server that a restore is about to take place and |
2190 // that the server should close the wapstor |
843 // that the server should close the wapstor |
2191 INFO_PRINTF1(_L("Simulating a restore notification")); |
844 INFO_PRINTF1(_L("Simulating a restore notification")); |
2192 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
845 secureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
2193 EBURRestorePartial, EBackupIncrement); |
846 EBURRestorePartial, EBackupIncrement); |
2194 |
847 |
2195 INFO_PRINTF1(_L("Expecting SendWapL to fail and the wap data file to be closed")); |
848 INFO_PRINTF1(_L("Expecting SendWapL to fail and the wap data file to be closed")); |
2196 TEST(SendWapL() != KErrNone); |
849 TEST(SendWapL() != KErrNone); |
2197 TEST(IsWapFileOpenL() == EFalse); |
850 TEST(IsWapFileOpenL() == EFalse); |
2198 |
851 |
2199 // Notify the WAPPROT server that a restore has completed |
852 // Notify the WAPPROT server that a restore has completed |
2200 // that the server should open the wapstor |
853 // that the server should open the wapstor |
2201 INFO_PRINTF1(_L("Simulating a restore complete notification")); |
854 INFO_PRINTF1(_L("Simulating a restore complete notification")); |
2202 iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
855 secureBackupEngine->SetBURModeL(TDriveList(_L8("C")), |
2203 EBURNormal, ENoBackup); |
856 EBURNormal, ENoBackup); |
2204 |
857 |
2205 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
858 INFO_PRINTF1(_L("Expecting SendWapL to succeed and the wap data file to be open")); |
2206 TEST(SendWapL() == KErrNone); |
859 TEST(SendWapL() == KErrNone); |
2207 TEST(IsWapFileOpenL() != EFalse); |
860 TEST(IsWapFileOpenL() != EFalse); |
2208 |
861 |
2209 INFO_PRINTF1(_L("Closing SocketServer ...")); |
862 CleanupStack::PopAndDestroy(secureBackupEngine); // testNumberProperty, secureBackupEngine |
2210 iSocketServer.Close(); |
|
2211 |
|
2212 CleanupStack::PopAndDestroy(&testNumberProperty); |
|
2213 return TestStepResult(); |
863 return TestStepResult(); |
2214 } |
864 } |
2215 |
865 |
2216 TVerdict CIoctlStep_17::doTestStepL() |
866 TVerdict CIoctlStep_17::doTestStepL() |
2217 /** |
867 /** |
2218 * Test step seventeen: |
868 * Test step seventeen: |
2219 * Sends a 7_Bit business card. Using IOCTL query SMS transport parameters |
869 * Sends a 7_Bit business card. Using IOCTL query SMS transport parameters |
2220 * @return - TVerdict code |
870 * @return - TVerdict code |
2221 * |
|
2222 */ |
871 */ |
2223 { |
872 { |
2224 INFO_PRINTF1(_L("IOCTL Test step 17: send 7-Bit v-card and query SMS transport parameters")); |
873 INFO_PRINTF1(_L("IOCTL Test step 17: send 7-Bit v-card and query SMS transport parameters")); |
2225 |
874 // Configure and bind to a socket |
2226 TInt result = KErrNone; |
875 SetupWapSocketL(); |
2227 TPtrC TestData1; |
876 |
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 |
877 // Send a business card |
2290 // |
878 TPtrC testData = GetStringFromConfigL(KTestData1); |
2291 TRequestStatus status; |
879 SendWapMessage(testData); |
2292 TBuf8<200> data; |
880 |
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 |
881 // Create a descriptor with correct size for obtaining the message parameter |
2301 // |
882 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
2302 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2303 TPtr8 parameterStorePtr = parameterStore->Des(); |
883 TPtr8 parameterStorePtr = parameterStore->Des(); |
2304 |
884 |
2305 // |
|
2306 // Get the message parameter value |
885 // Get the message parameter value |
2307 // |
886 GetMessageParameterL(iSocket, parameterStorePtr); |
2308 GetMessageParameterL(sock, parameterStorePtr); |
887 |
2309 |
|
2310 // |
|
2311 // Internalise the message parameter and check |
888 // Internalise the message parameter and check |
2312 // |
889 TPtrC8 scAddr = iWapAddr.WapAddress(); |
|
890 |
2313 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
891 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
2314 |
892 |
|
893 iSocket.Close(); |
2315 CleanupStack::PopAndDestroy(parameterStore); |
894 CleanupStack::PopAndDestroy(parameterStore); |
2316 |
|
2317 // |
|
2318 // Closing the socket |
|
2319 // |
|
2320 CleanupStack::PopAndDestroy(&sock); |
|
2321 CleanupStack::PopAndDestroy(&socketServer); |
|
2322 |
|
2323 return TestStepResult(); |
895 return TestStepResult(); |
2324 } |
896 } |
2325 |
897 |
2326 TVerdict CIoctlStep_18::doTestStepL() |
898 TVerdict CIoctlStep_18::doTestStepL() |
2327 /** |
899 /** |
2328 * Test step eighteen: |
900 * Test step eighteen: |
2329 * Sends a 7-Bit calendar entry (two segments). Using IOCTL query SMS transport parameters. |
901 * Sends a 7-Bit calendar entry (two segments). Using IOCTL query SMS transport parameters. |
2330 * @return - TVerdict code |
902 * @return - TVerdict code |
2331 * |
|
2332 */ |
903 */ |
2333 { |
904 { |
2334 INFO_PRINTF1(_L("IOCTL Test step 18: Sends a 7-Bit calendar entry (two segments). Using IOCTL query SMS transport parameters.")); |
905 INFO_PRINTF1(_L("IOCTL Test step 18: Sends a 7-Bit calendar entry (two segments). Using IOCTL query SMS transport parameters.")); |
2335 |
906 // Configure and bind to a socket |
2336 TInt result = KErrNone; |
907 SetupWapSocketL(); |
2337 TPtrC TestData; |
908 |
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 |
909 // Send a calendar entry |
2398 // |
910 TPtrC testData = GetStringFromConfigL(KTestData1); |
2399 TRequestStatus status; |
911 SendWapMessage(testData); |
2400 TBuf8<300> data; |
912 |
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 |
913 // Create a descriptor with correct size for obtaining the message parameter |
2409 // |
914 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
2410 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2411 TPtr8 parameterStorePtr = parameterStore->Des(); |
915 TPtr8 parameterStorePtr = parameterStore->Des(); |
2412 |
916 |
2413 // |
|
2414 // Get the message parameter value |
917 // Get the message parameter value |
2415 // |
918 GetMessageParameterL(iSocket, parameterStorePtr); |
2416 GetMessageParameterL(sock, parameterStorePtr); |
919 |
2417 |
|
2418 // |
|
2419 // Internalise the message parameter and check |
920 // Internalise the message parameter and check |
2420 // |
921 TPtrC8 scAddr = iWapAddr.WapAddress(); |
|
922 |
2421 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
923 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
2422 |
924 |
|
925 iSocket.Close(); |
2423 CleanupStack::PopAndDestroy(parameterStore); |
926 CleanupStack::PopAndDestroy(parameterStore); |
2424 |
|
2425 // |
|
2426 // Closing the socket |
|
2427 |
|
2428 CleanupStack::PopAndDestroy(&sock); |
|
2429 CleanupStack::PopAndDestroy(&socketServer); |
|
2430 |
|
2431 return TestStepResult(); |
927 return TestStepResult(); |
2432 } |
928 } |
2433 |
929 |
2434 TVerdict CIoctlStep_19::doTestStepL() |
930 TVerdict CIoctlStep_19::doTestStepL() |
2435 /** |
931 /** |
2436 * Test step 19: |
932 * Test step 19: |
2437 * send/receive one 7-Bit two segments message and one 7-Bit one segment message |
933 * send/receive one 7-Bit two segments message and one 7-Bit one segment message |
2438 * @return - TVerdict code |
934 * @return - TVerdict code |
2439 * |
|
2440 */ |
935 */ |
2441 { |
936 { |
2442 INFO_PRINTF1(_L("IOCTL Test step 19: send/receive two 7-Bit messages")); |
937 INFO_PRINTF1(_L("IOCTL Test step 19: send/receive two 7-Bit messages")); |
2443 |
938 // Configure and bind to a socket |
2444 TInt result = KErrNone; |
939 SetupWapSocketL(); |
2445 TPtrC TestData1; |
940 |
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 // |
941 // |
2511 // Issue Ioctl for getting the length of the message |
942 // Issue Ioctl for getting the length of the message |
2512 // |
943 // |
2513 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
944 TRequestStatus ioctlStatus; |
2514 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
945 TPckgBuf<TInt> length; |
2515 |
946 |
2516 // |
947 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the first message...")); |
2517 // Send a calendar entry |
948 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
2518 // |
949 |
2519 TRequestStatus status; |
950 TPtrC testData1 = GetStringFromConfigL(KTestData1); |
2520 |
951 TPtrC testData2 = GetStringFromConfigL(KTestData2); |
2521 TBuf8<300> data2; |
952 |
2522 data2.Copy(TestData2); |
953 // Send a calendar entry |
2523 sock.SendTo(data2, wapAddr, 0, status); |
954 SendWapMessage(testData2); |
2524 User::WaitForRequest(status); |
955 |
2525 TESTL(status.Int()==KErrNone); |
|
2526 INFO_PRINTF1(_L("First message sent...")); |
|
2527 // |
|
2528 // Send a business card |
956 // Send a business card |
2529 // |
957 SendWapMessage(testData1); |
2530 TBuf8<200> data1; |
958 |
2531 data1.Copy(TestData1); |
959 // Get the size of the first incoming message |
2532 sock.SendTo(data1, wapAddr, 0, status); |
960 User::WaitForRequest(ioctlStatus); |
2533 User::WaitForRequest(status); |
961 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
2534 TESTL(status.Int()==KErrNone); |
962 |
2535 INFO_PRINTF1(_L("Second message sent...")); |
963 // Get the first message parameter value |
2536 // |
964 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
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(); |
965 TPtr8 parameterStorePtr = parameterStore->Des(); |
2551 |
966 |
2552 // |
967 INFO_PRINTF1(_L("Getting parameter value of first message...")); |
2553 // Get the first message parameter value |
968 GetMessageParameterL(iSocket, parameterStorePtr); |
2554 // |
969 |
2555 GetMessageParameterL(sock, parameterStorePtr); |
|
2556 |
|
2557 // |
|
2558 // Internalise the first message parameter and check |
970 // Internalise the first message parameter and check |
2559 // |
971 TPtrC8 scAddr = iWapAddr.WapAddress(); |
|
972 |
2560 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
973 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
2561 |
974 |
2562 CleanupStack::PopAndDestroy(parameterStore); |
975 CleanupStack::PopAndDestroy(parameterStore); |
2563 |
976 |
2564 // |
|
2565 // Receiving a datagram |
977 // Receiving a datagram |
2566 // |
978 TRequestStatus recvStatus; |
2567 sock.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
979 TWapAddr recvWapAddr; |
|
980 TBuf8<256> recvBuf2(length); |
|
981 |
|
982 iSocket.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
2568 User::WaitForRequest(recvStatus); |
983 User::WaitForRequest(recvStatus); |
2569 TESTL(recvStatus.Int()==KErrNone); |
984 TESTL(recvStatus.Int()==KErrNone); |
2570 INFO_PRINTF1(_L("Received the first message...")); |
985 INFO_PRINTF1(_L("Received the first message...")); |
2571 |
986 |
2572 // |
|
2573 // Confirm the receipt of the message to the client |
987 // Confirm the receipt of the message to the client |
2574 // |
|
2575 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
988 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
2576 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
989 TESTL(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
2577 |
990 |
2578 // |
991 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the second message...")); |
2579 // Issue Ioctl for getting the length of the second message |
992 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
2580 // |
993 |
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 |
994 // Get the size of the SECOND incoming message |
2586 // |
995 User::WaitForRequest(ioctlStatus); |
2587 User::WaitForRequest(ioctlStatus); |
996 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
2588 TESTL(ioctlStatus.Int()==KErrNone); |
997 TESTCHECK(length(), testData1.Length(), "Check if reported length is correct"); |
2589 INFO_PRINTF1(_L("IOCTL completed")); |
998 |
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 |
999 // Create a descriptor with correct size for obtaining the second message parameter |
2601 // |
1000 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
2602 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2603 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
1001 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
2604 |
1002 |
2605 // |
|
2606 // Get the second message parameter value |
1003 // Get the second message parameter value |
2607 // |
1004 INFO_PRINTF1(_L("Getting parameter value of second message...")); |
2608 GetMessageParameterL(sock, parameterStorePtr2); |
1005 GetMessageParameterL(iSocket, parameterStorePtr2); |
2609 |
1006 |
2610 // |
|
2611 // Internalise the second message parameter and check |
1007 // Internalise the second message parameter and check |
2612 // |
|
2613 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
1008 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
2614 |
1009 |
2615 CleanupStack::PopAndDestroy(parameterStore2); |
1010 CleanupStack::PopAndDestroy(parameterStore2); |
2616 |
1011 |
2617 // |
|
2618 // Receiving the second message |
1012 // Receiving the second message |
2619 // |
1013 ReceiveWapMessageFromSocket(length(), testData1); |
2620 sock.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
1014 |
2621 User::WaitForRequest(recvStatus); |
1015 iSocket.Close(); |
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(); |
1016 return TestStepResult(); |
2639 } |
1017 } |
2640 |
1018 |
2641 TVerdict CIoctlStep_20::doTestStepL() |
1019 TVerdict CIoctlStep_20::doTestStepL() |
2642 /** |
1020 /** |
2643 * |
|
2644 * Test step 20: |
1021 * Test step 20: |
2645 * simulating client crash conditions with 7bit message |
1022 * simulating client crash conditions with 7bit message |
2646 * @return - TVerdict code |
1023 * @return - TVerdict code |
2647 * |
|
2648 */ |
1024 */ |
2649 { |
1025 { |
2650 INFO_PRINTF1(_L("IOCTL Test step 20: client crash condition 7-Bit message ")); |
1026 INFO_PRINTF1(_L("IOCTL Test step 20: client crash condition 7-Bit message ")); |
2651 |
1027 // Configure and bind to a socket |
2652 TInt result = KErrNone; |
1028 SetupWapSocketL(); |
2653 TPtrC TestData; |
1029 |
2654 TPtrC16 TelNumber; |
1030 // Issue Ioctl for getting the length of the message |
2655 TInt port=226; |
1031 TRequestStatus ioctlStatus; |
2656 TInt testNumber =4; |
1032 TPckgBuf<TInt> length; |
2657 |
1033 |
2658 if(!GetStringFromConfig(ConfigSection(),KTestData1, TestData) || |
1034 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
2659 !GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
1035 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
2660 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
1036 |
2661 { |
1037 // Send a business card |
2662 result=KErrNotFound; |
1038 TPtrC testData = GetStringFromConfigL(KTestData1); |
2663 } |
1039 SendWapMessage(testData); |
|
1040 |
|
1041 // Get the size of the incoming message |
|
1042 User::WaitForRequest(ioctlStatus); |
|
1043 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
|
1044 TESTCHECK(length(), testData.Length(), "Check if reported length is correct"); |
|
1045 |
|
1046 // Create a descriptor with correct size for obtaining the message parameter |
|
1047 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
|
1048 TPtr8 parameterStorePtr = parameterStore->Des(); |
|
1049 |
|
1050 // Get the message parameter value |
|
1051 GetMessageParameterL(iSocket, parameterStorePtr); |
|
1052 |
|
1053 // Internalise the message parameter and check |
|
1054 TPtrC8 scAddr = iWapAddr.WapAddress(); |
|
1055 |
|
1056 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
|
1057 |
|
1058 CleanupStack::PopAndDestroy(parameterStore); |
|
1059 |
|
1060 // Receive a message |
|
1061 TRequestStatus recvStatus; |
|
1062 TWapAddr recvWapAddr; |
|
1063 HBufC8* recvBuf = HBufC8::NewLC(length()); |
|
1064 TPtr8 recvPtr = recvBuf->Des(); |
|
1065 |
|
1066 iSocket.RecvFrom(recvPtr, recvWapAddr, 0, recvStatus); |
|
1067 User::WaitForRequest(recvStatus); |
|
1068 TESTCHECKL(recvStatus.Int(), KErrNone, "Receiving a message"); |
|
1069 |
|
1070 // Simulate a crash by closing and reopening the socket |
|
1071 iSocket.Close(); |
|
1072 INFO_PRINTF1(_L("Socket was closed...")); |
|
1073 |
|
1074 OpenSocketL(iSocketServer, iSocket); |
|
1075 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
|
1076 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
|
1077 User::LeaveIfError(iSocket.Bind(iWapAddr)); |
|
1078 INFO_PRINTF1(_L("Socket was opened...")); |
2664 |
1079 |
2665 TESTL(result==KErrNone); |
1080 // Issue another get length of datagram as if not aware of the previous message |
2666 |
1081 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
2667 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
1082 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
2668 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
1083 |
2669 |
1084 // Get the size of the incoming message |
2670 // |
1085 User::WaitForRequest(ioctlStatus); |
2671 // Setting the port number and service center number of the wap address |
1086 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
2672 // The service center number should be the same as the sim phone number used |
1087 TESTCHECK(length(), testData.Length(), "Check if reported length is correct"); |
2673 // for test |
1088 |
2674 // |
1089 // Recreate a descriptor with correct size for obtaining the message parameter |
2675 TWapAddr wapAddr; |
1090 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
2676 TWapAddr recvWapAddr; |
1091 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
2677 wapAddr.SetWapPort(TWapPortNumber(port)); |
1092 |
2678 TBuf8<100> scNumber; |
1093 // Get the message parameter value |
2679 scNumber.Copy(TelNumber); |
1094 GetMessageParameterL(iSocket, parameterStorePtr2); |
2680 TPtrC8 scAddr(scNumber); |
1095 |
2681 wapAddr.SetWapAddress(scAddr); |
1096 // Internalise the message parameter and check |
2682 |
1097 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
2683 // |
1098 |
2684 // Connect to socket server |
1099 CleanupStack::PopAndDestroy(parameterStore2); |
2685 // |
1100 |
2686 RSocketServ socketServer; |
1101 // New message retrieved from SAR store |
2687 User::LeaveIfError(socketServer.Connect()); |
1102 ReceiveWapMessageFromSocket(length(), testData); |
2688 CleanupClosePushL(socketServer); |
1103 |
2689 |
1104 iSocket.Close(); |
2690 // |
1105 CleanupStack::PopAndDestroy(recvBuf); |
2691 // Define and open the socket |
1106 return TestStepResult(); |
2692 // |
1107 } |
2693 RSocket sock; |
1108 |
2694 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
1109 TVerdict CIoctlStep_21::doTestStepL() |
2695 CleanupClosePushL(sock); |
1110 /** |
2696 |
1111 * Test step 21: |
2697 // |
1112 * simulating client crash conditions with 8bit push message |
2698 // Waiting for the phone to be initialised |
1113 * @return - TVerdict code |
2699 // |
1114 */ |
2700 WaitForInitializeL(); |
1115 { |
2701 |
1116 INFO_PRINTF1(_L("IOCTL Test step 21: client crash condition with 8Bit push message")); |
2702 TRequestStatus ioctlStatus; |
1117 // Configure and bind to a socket |
2703 TRequestStatus recvStatus; |
1118 SetupWapSocketL(); |
2704 TPckgBuf<TInt> length; |
1119 |
2705 |
1120 // Issue Ioctl for getting the length of the message |
2706 // |
1121 TRequestStatus ioctlStatus; |
2707 // Indicating to the protocol that it's a new client |
1122 TPckgBuf<TInt> length; |
2708 // |
1123 |
2709 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
1124 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
2710 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
1125 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
2711 // |
1126 |
2712 // Bind |
1127 // Get the size of the incoming message |
2713 // |
1128 User::WaitForRequest(ioctlStatus); |
2714 TESTL(sock.Bind(wapAddr)==KErrNone); |
1129 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
2715 |
1130 |
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 |
1131 // Create a descriptor with correct size for obtaining the message parameter |
2746 // |
1132 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
2747 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
2748 TPtr8 parameterStorePtr = parameterStore->Des(); |
1133 TPtr8 parameterStorePtr = parameterStore->Des(); |
2749 |
1134 |
2750 // |
|
2751 // Get the message parameter value |
1135 // Get the message parameter value |
2752 // |
1136 GetMessageParameterL(iSocket, parameterStorePtr); |
2753 GetMessageParameterL(sock, parameterStorePtr); |
1137 |
2754 |
|
2755 // |
|
2756 // Internalise the message parameter and check |
1138 // Internalise the message parameter and check |
2757 // |
1139 TPtrC8 scAddr = iWapAddr.WapAddress(); |
|
1140 |
2758 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
1141 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
2759 |
1142 |
2760 CleanupStack::PopAndDestroy(parameterStore); |
1143 CleanupStack::PopAndDestroy(parameterStore); |
2761 |
1144 |
2762 // |
|
2763 // Receiving a datagram |
1145 // Receiving a datagram |
2764 // |
1146 TRequestStatus recvStatus; |
2765 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
1147 TWapAddr recvWapAddr; |
|
1148 TBuf8<256> recvBuf(length); |
|
1149 |
|
1150 iSocket.RecvFrom(recvBuf, recvWapAddr, 0, recvStatus); |
2766 User::WaitForRequest(recvStatus); |
1151 User::WaitForRequest(recvStatus); |
2767 TESTL(recvStatus.Int()==KErrNone); |
1152 TESTL(recvStatus.Int()==KErrNone); |
2768 INFO_PRINTF1(_L("Received the message...")); |
1153 INFO_PRINTF1(_L("Received the message...")); |
2769 |
1154 |
2770 // |
1155 // Simulate a crash by closing and reopening the socket |
2771 // Close socket |
1156 iSocket.Close(); |
2772 // |
|
2773 sock.Close(); |
|
2774 INFO_PRINTF1(_L("Socket was closed...")); |
1157 INFO_PRINTF1(_L("Socket was closed...")); |
2775 |
1158 |
2776 // |
1159 OpenSocketL(iSocketServer, iSocket); |
2777 // Open the socket |
1160 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
2778 // |
1161 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
2779 TESTL(sock.Open(socketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)==KErrNone); |
1162 User::LeaveIfError(iSocket.Bind(iWapAddr)); |
2780 INFO_PRINTF1(_L("Socket was opened...")); |
1163 INFO_PRINTF1(_L("Socket was opened...")); |
2781 TESTL(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)==KErrNone); |
1164 |
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 |
1165 // Issue another get length of datagram as if not aware of the previous message |
2787 // |
1166 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
2788 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
1167 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
2789 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
1168 |
2790 |
1169 // Get the size of the incoming message |
2791 // |
1170 User::WaitForRequest(ioctlStatus); |
2792 // waiting for request to be completed |
1171 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
2793 // |
1172 |
2794 User::WaitForRequest(ioctlStatus); |
1173 // Recreate a descriptor with correct size for obtaining the message parameter |
2795 TESTL(ioctlStatus.Int()==KErrNone); |
1174 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
2796 INFO_PRINTF1(_L("IOCTL completed...")); |
1175 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
2797 |
1176 |
2798 // |
1177 // Get the message parameter value |
2799 // Check if reported length is correct |
1178 GetMessageParameterL(iSocket, parameterStorePtr2); |
2800 // |
1179 |
|
1180 // Internalise the message parameter and check |
|
1181 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
|
1182 |
|
1183 CleanupStack::PopAndDestroy(parameterStore2); |
|
1184 |
|
1185 // New message retrieved from SAR store |
2801 TBuf8<256> newRecvBuf(length); |
1186 TBuf8<256> newRecvBuf(length); |
2802 TESTL(length()==data.Length()); |
1187 iSocket.RecvFrom(newRecvBuf,recvWapAddr,0,recvStatus); |
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); |
1188 User::WaitForRequest(recvStatus); |
2827 TESTL(recvStatus.Int()==KErrNone); |
1189 TESTL(recvStatus.Int()==KErrNone); |
2828 INFO_PRINTF1(_L("Received the message...")); |
1190 INFO_PRINTF1(_L("Received the message...")); |
2829 TEST(newRecvBuf.Compare(data) == 0); |
1191 |
2830 |
|
2831 // |
|
2832 // Confirm the receipt of the message to the client |
1192 // Confirm the receipt of the message to the client |
2833 // |
|
2834 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
1193 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
2835 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
1194 TESTL(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
2836 |
1195 |
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 |
1196 // Compare the received message with the previous one |
3028 // They should be identical |
1197 // They should be identical |
3029 // |
|
3030 TESTL(newRecvBuf.Compare(recvBuf)==0); |
1198 TESTL(newRecvBuf.Compare(recvBuf)==0); |
3031 |
1199 |
3032 // |
1200 iSocket.Close(); |
3033 // Closing the socket |
|
3034 // |
|
3035 CleanupStack::PopAndDestroy(&sock); |
|
3036 CleanupStack::PopAndDestroy(&socketServer); |
|
3037 |
|
3038 return TestStepResult(); |
1201 return TestStepResult(); |
3039 } |
1202 } |
3040 |
1203 |
3041 TVerdict CIoctlStep_22::doTestStepL() |
1204 TVerdict CIoctlStep_22::doTestStepL() |
3042 /** |
1205 /** |
3043 * Test step 22: |
1206 * Test step 22: |
3044 * Push Message (8-Bit). Using IOCTL query SMS transport parameters |
1207 * Push Message (8-Bit). Using IOCTL query SMS transport parameters |
3045 * @return - TVerdict code |
1208 * @return - TVerdict code |
3046 * |
|
3047 */ |
1209 */ |
3048 { |
1210 { |
3049 INFO_PRINTF1(_L("IOCTL Test step 22: Push Message (8-Bit) and query SMS transport parameters")); |
1211 INFO_PRINTF1(_L("IOCTL Test step 22: Push Message (8-Bit) and query SMS transport parameters")); |
3050 |
1212 // Configure and bind to a socket |
3051 TInt result = KErrNone; |
1213 SetupWapSocketL(); |
3052 TPtrC16 TelNumber; |
1214 |
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 |
1215 // Create a descriptor with correct size for obtaining the message parameter |
3111 // |
1216 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
3112 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
3113 TPtr8 parameterStorePtr = parameterStore->Des(); |
1217 TPtr8 parameterStorePtr = parameterStore->Des(); |
3114 |
1218 |
3115 // |
|
3116 // Get the message parameter value |
1219 // Get the message parameter value |
3117 // |
1220 GetMessageParameterL(iSocket, parameterStorePtr); |
3118 GetMessageParameterL(sock, parameterStorePtr); |
1221 |
3119 |
|
3120 // |
|
3121 // Internalise the message parameter and check |
1222 // Internalise the message parameter and check |
3122 // |
1223 TPtrC8 scAddr = iWapAddr.WapAddress(); |
|
1224 |
3123 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
1225 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
3124 |
1226 |
3125 CleanupStack::PopAndDestroy(parameterStore); |
1227 CleanupStack::PopAndDestroy(parameterStore); |
3126 |
1228 |
3127 // |
1229 iSocket.Close(); |
3128 // Closing the socket |
|
3129 // |
|
3130 CleanupStack::PopAndDestroy(&sock); |
|
3131 CleanupStack::PopAndDestroy(&socketServer); |
|
3132 |
|
3133 return TestStepResult(); |
1230 return TestStepResult(); |
3134 } |
1231 } |
3135 |
1232 |
3136 TVerdict CIoctlStep_23::doTestStepL() |
1233 TVerdict CIoctlStep_23::doTestStepL() |
3137 /** |
1234 /** |
3138 * Test step 23: |
1235 * Test step 23: |
3139 * Two Push Messages (8-Bit). Using IOCTL query SMS transport parameters |
1236 * Two Push Messages (8-Bit). Using IOCTL query SMS transport parameters |
3140 * @return - TVerdict code |
1237 * @return - TVerdict code |
3141 * |
|
3142 */ |
1238 */ |
3143 { |
1239 { |
3144 INFO_PRINTF1(_L("IOCTL Test step 23: Push two push message(8-Bit) query transport parameters")); |
1240 INFO_PRINTF1(_L("IOCTL Test step 23: Push two push message(8-Bit) query transport parameters")); |
3145 |
1241 // Configure and bind to a socket |
3146 TInt result=KErrNone; |
1242 SetupWapSocketL(); |
3147 TPtrC16 TelNumber; |
1243 |
3148 TInt port=226; |
1244 // Issue Ioctl for getting the length of the message |
3149 TInt testNumber=8; |
1245 TRequestStatus ioctlStatus; |
3150 |
1246 TPckgBuf<TInt> length; |
3151 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber) || |
1247 |
3152 !GetIntFromConfig(ConfigSection(),KWapPort,port)) |
1248 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
3153 { |
1249 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
3154 result=KErrNotFound; |
1250 |
3155 } |
1251 // Get the size of the incoming message |
3156 |
1252 User::WaitForRequest(ioctlStatus); |
3157 TESTL(result==KErrNone); |
1253 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
3158 |
1254 |
3159 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
1255 INFO_PRINTF1(_L("Getting parameter value of first message...")); |
3160 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, testNumber)); |
1256 |
3161 |
1257 // Create a descriptor with correct size for obtaining the first message parameter |
3162 // |
1258 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
3163 // Setting the port number and service center number of the wap address |
1259 TPtr8 parameterStorePtr = parameterStore->Des(); |
3164 // The service center number should be the same as the sim phone number used |
1260 |
3165 // for test |
1261 // Get the first message parameter value |
3166 // |
1262 GetMessageParameterL(iSocket, parameterStorePtr); |
3167 TWapAddr wapAddr; |
1263 |
3168 TWapAddr recvWapAddr; |
1264 // Internalise the first message parameter and check |
3169 wapAddr.SetWapPort(TWapPortNumber(port)); |
1265 TPtrC8 scAddr = iWapAddr.WapAddress(); |
3170 TBuf8<100> scNumber; |
1266 |
3171 scNumber.Copy(TelNumber); |
1267 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
3172 TPtrC8 scAddr(scNumber); |
1268 |
3173 wapAddr.SetWapAddress(scAddr); |
1269 CleanupStack::PopAndDestroy(parameterStore); |
3174 |
1270 |
3175 // |
1271 // Receiving push datagram |
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; |
1272 TRequestStatus recvStatus; |
3196 TPckgBuf<TInt> length; |
1273 TWapAddr recvWapAddr; |
3197 |
1274 TBuf8<256> recvBuf1(length); |
3198 // |
1275 |
3199 // Indicating to the protocol that it's a new client |
1276 iSocket.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
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); |
1277 User::WaitForRequest(recvStatus); |
3252 TESTL(recvStatus.Int()==KErrNone); |
1278 TESTL(recvStatus.Int()==KErrNone); |
3253 INFO_PRINTF1(_L("Received the push message...")); |
1279 INFO_PRINTF1(_L("Received the push message...")); |
3254 |
1280 |
3255 // |
|
3256 // Confirm the receipt of the message to the client |
1281 // Confirm the receipt of the message to the client |
3257 // |
|
3258 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
1282 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
3259 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
1283 TESTL(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
3260 |
1284 |
3261 // |
1285 INFO_PRINTF1(_L("Issuing IOCTL for getting the length of the message...")); |
3262 // Issue another Ioctl for getting the length of the message |
1286 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
3263 // |
1287 |
3264 INFO_PRINTF1(_L("Issue of first IOCTL for GetLength")); |
1288 // Get the size of the second incoming push message |
3265 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
1289 User::WaitForRequest(ioctlStatus); |
3266 |
1290 TESTCHECKL(ioctlStatus.Int(), KErrNone, "Getting the size of the first incoming message"); |
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 |
1291 |
3274 INFO_PRINTF1(_L("Getting parameter value of second message...")); |
1292 INFO_PRINTF1(_L("Getting parameter value of second message...")); |
3275 |
1293 |
3276 // |
|
3277 // Create a descriptor with correct size for obtaining the second message parameter |
1294 // Create a descriptor with correct size for obtaining the second message parameter |
3278 // |
1295 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
3279 HBufC8* parameterStore2 = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
3280 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
1296 TPtr8 parameterStorePtr2 = parameterStore2->Des(); |
3281 |
1297 |
3282 // |
|
3283 // Get the second message parameter value |
1298 // Get the second message parameter value |
3284 // |
1299 GetMessageParameterL(iSocket, parameterStorePtr2); |
3285 GetMessageParameterL(sock, parameterStorePtr2); |
1300 |
3286 |
|
3287 // |
|
3288 // Internalise the second message parameter and check |
1301 // Internalise the second message parameter and check |
3289 // |
|
3290 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
1302 InternaliseSmsDataAndCheckL(parameterStorePtr2, scAddr); |
3291 |
1303 |
3292 CleanupStack::PopAndDestroy(parameterStore2); |
1304 CleanupStack::PopAndDestroy(parameterStore2); |
3293 |
1305 |
3294 // |
1306 // Receiving push datagram |
3295 // Allocate buffer |
|
3296 // |
|
3297 TBuf8<256> recvBuf2(length); |
1307 TBuf8<256> recvBuf2(length); |
3298 |
1308 |
3299 // |
1309 iSocket.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
3300 // Receiving push datagram |
|
3301 // |
|
3302 sock.RecvFrom(recvBuf2,recvWapAddr,0,recvStatus); |
|
3303 User::WaitForRequest(recvStatus); |
1310 User::WaitForRequest(recvStatus); |
3304 TESTL(recvStatus.Int()==KErrNone); |
1311 TESTL(recvStatus.Int()==KErrNone); |
3305 INFO_PRINTF1(_L("Received the second push message...")); |
1312 INFO_PRINTF1(_L("Received the second push message...")); |
3306 |
1313 |
3307 // |
|
3308 // Compare the received message with the previous one |
1314 // Compare the received message with the previous one |
3309 // They should be identical |
1315 // They should be identical |
3310 // |
|
3311 TESTL(recvBuf2.Compare(recvBuf1)==0); |
1316 TESTL(recvBuf2.Compare(recvBuf1)==0); |
3312 |
1317 |
3313 // |
|
3314 // Confirm the receipt of the message to the client |
1318 // Confirm the receipt of the message to the client |
3315 // |
|
3316 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
1319 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
3317 TESTL(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
1320 TESTL(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)==KErrNone); |
3318 |
1321 |
3319 // |
1322 iSocket.Close(); |
3320 // Closing the socket |
|
3321 // |
|
3322 CleanupStack::PopAndDestroy(&sock); |
|
3323 CleanupStack::PopAndDestroy(&socketServer); |
|
3324 |
|
3325 return TestStepResult(); |
1323 return TestStepResult(); |
3326 } |
1324 } |
3327 |
1325 |
3328 TVerdict CIoctlStep_24::doTestStepL() |
1326 TVerdict CIoctlStep_24::doTestStepL() |
3329 /** |
1327 /** |
3330 * Test step 24: |
1328 * Test step 24: |
3331 * Test Cancel IOCTL |
1329 * Test Cancel IOCTL |
3332 * @return - TVerdict code |
1330 * @return - TVerdict code |
3333 * |
|
3334 */ |
1331 */ |
3335 { |
1332 { |
3336 INFO_PRINTF1(_L("IOCTL Test step 24: Testing Cancel IOCTL")); |
1333 INFO_PRINTF1(_L("IOCTL Test step 24: Testing Cancel IOCTL")); |
3337 |
1334 // Configure and bind to a socket |
3338 TInt result=KErrNone; |
1335 SetupWapSocketL(); |
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 |
1336 |
3384 TRequestStatus ioctlStatus; |
1337 TRequestStatus ioctlStatus; |
3385 TBuf8<200> smsdata; |
1338 TBuf8<200> smsdata; |
3386 TPckgBuf<TInt> paramLength; |
1339 TPckgBuf<TInt> paramLength; |
3387 |
1340 |
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 |
1341 // Issue Ioctl for getting the length of the message parameter |
3401 // |
|
3402 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParametersLength")); |
1342 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParametersLength")); |
3403 sock.Ioctl(KSOGetMessageParametersLength, ioctlStatus, &smsdata, KSolWapProv); |
1343 iSocket.Ioctl(KSOGetMessageParametersLength, ioctlStatus, &smsdata, KSolWapProv); |
3404 |
1344 |
3405 // |
|
3406 // Issue Cancel Ioctl |
1345 // Issue Cancel Ioctl |
3407 // |
|
3408 INFO_PRINTF1(_L("Issue of cancel IOCTL for KSOGetMessageParametersLength")); |
1346 INFO_PRINTF1(_L("Issue of cancel IOCTL for KSOGetMessageParametersLength")); |
3409 sock.CancelIoctl(); |
1347 iSocket.CancelIoctl(); |
3410 |
1348 TESTCHECKL(ioctlStatus.Int(), KErrCancel, "Checking if the outstanding IOCTL has been cancelled"); |
3411 // |
1349 |
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 |
1350 // Issue Ioctl for getting the message parameter |
3418 // |
|
3419 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
1351 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
3420 sock.Ioctl(KSOGetMessageParameters, ioctlStatus, &smsdata, KSolWapProv); |
1352 iSocket.Ioctl(KSOGetMessageParameters, ioctlStatus, &smsdata, KSolWapProv); |
3421 |
1353 |
3422 // |
|
3423 // Issue Cancel Ioctl |
1354 // Issue Cancel Ioctl |
3424 // |
|
3425 INFO_PRINTF1(_L("Issue of cancel IOCTL for KSOGetMessageParameters")); |
1355 INFO_PRINTF1(_L("Issue of cancel IOCTL for KSOGetMessageParameters")); |
3426 sock.CancelIoctl(); |
1356 iSocket.CancelIoctl(); |
3427 |
1357 TESTCHECKL(ioctlStatus.Int(), KErrCancel, "Checking if the outstanding IOCTL has been cancelled"); |
3428 // |
1358 |
3429 // Check if the outstanding IOCTL has been cancelled |
1359 iSocket.Close(); |
3430 // |
|
3431 TESTL(ioctlStatus==KErrCancel); |
|
3432 |
|
3433 // |
|
3434 // Closing the socket |
|
3435 // |
|
3436 CleanupStack::PopAndDestroy(&sock); |
|
3437 CleanupStack::PopAndDestroy(&socketServer); |
|
3438 |
|
3439 return TestStepResult(); |
1360 return TestStepResult(); |
3440 } |
1361 } |
3441 |
1362 |
3442 TVerdict CIoctlStep_25::doTestStepL() |
1363 TVerdict CIoctlStep_25::doTestStepL() |
3443 /** |
1364 /** |
3444 * Test step 25: |
1365 * Test step 25: |
3445 * Test issue IOCTL without SetOption NewStyleClient |
1366 * Test issue IOCTL without SetOption NewStyleClient |
3446 * @return - TVerdict code |
1367 * @return - TVerdict code |
3447 * |
|
3448 */ |
1368 */ |
3449 { |
1369 { |
3450 INFO_PRINTF1(_L("IOCTL Test step 25: Test issue IOCTL without SetOption NewStyleClient")); |
1370 INFO_PRINTF1(_L("IOCTL Test step 25: Test issue IOCTL without SetOption NewStyleClient")); |
3451 |
1371 // Configure and bind to a socket |
3452 TInt result=KErrNone; |
1372 SetupWapSocketL(iSocket, iWapAddr, KWapPort, EFalse); |
3453 TPtrC16 TelNumber; |
1373 |
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) |
1374 // Issue Ioctl for getting the length of the message parameter (should fail) |
3507 // |
1375 TRequestStatus ioctlStatus; |
|
1376 TPckgBuf<TInt> paramLength; |
|
1377 |
3508 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParametersLength")); |
1378 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParametersLength")); |
3509 sock.Ioctl(KSOGetMessageParametersLength, ioctlStatus, ¶mLength, KSolWapProv); |
1379 iSocket.Ioctl(KSOGetMessageParametersLength, ioctlStatus, ¶mLength, KSolWapProv); |
3510 TESTL(ioctlStatus.Int()!=KErrNone); |
1380 TESTL(ioctlStatus.Int()!=KErrNone); |
3511 |
1381 |
3512 // |
|
3513 // Issue Ioctl for getting the message parameter (should fail) |
1382 // Issue Ioctl for getting the message parameter (should fail) |
3514 // |
|
3515 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
1383 INFO_PRINTF1(_L("Issue of IOCTL for KSOGetMessageParameters")); |
3516 sock.Ioctl(KSOGetMessageParameters, ioctlStatus, &smsdata, KSolWapProv); |
1384 TBuf8<200> smsdata; |
|
1385 |
|
1386 iSocket.Ioctl(KSOGetMessageParameters, ioctlStatus, &smsdata, KSolWapProv); |
3517 User::WaitForRequest(ioctlStatus); |
1387 User::WaitForRequest(ioctlStatus); |
3518 TESTL(ioctlStatus.Int()!=KErrNone); |
1388 TESTL(ioctlStatus.Int()!=KErrNone); |
3519 |
1389 |
3520 // |
1390 iSocket.Close(); |
3521 // Closing the socket |
|
3522 // |
|
3523 CleanupStack::PopAndDestroy(&sock); |
|
3524 CleanupStack::PopAndDestroy(&socketServer); |
|
3525 |
|
3526 return TestStepResult(); |
1391 return TestStepResult(); |
3527 } |
1392 } |
3528 |
1393 |
3529 TVerdict CIoctlStep_26::doTestStepL() |
1394 TVerdict CIoctlStep_26::doTestStepL() |
3530 /** |
1395 /** |
3531 * Test step 26: |
1396 * Test step 26: |
3532 * Sends a 8-Bit calendar entry using IOCTL(two segments) |
1397 * Sends a 8-Bit calendar entry using IOCTL(two segments) |
3533 * @return - TVerdict code |
1398 * @return - TVerdict code |
3534 * |
|
3535 */ |
1399 */ |
3536 { |
1400 { |
3537 INFO_PRINTF1(_L("IOCTL Test step 26: send a 8-Bit VCal (two segments)")); |
1401 INFO_PRINTF1(_L("IOCTL Test step 26: send a 8-Bit VCal (two segments)")); |
3538 |
1402 // Configure and bind to a socket |
3539 TInt result=KErrNone; |
1403 SetupWapSocketL(); |
3540 TPtrC TestData; |
1404 |
3541 TPtrC16 TelNumber; |
1405 TESTL(iSocket.SetOpt(KWapSmsOptionNameDCS,KWapSmsOptionLevel,EWapSms8BitDCS)==KErrNone); |
3542 TInt port=226; |
1406 |
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 |
1407 // Send a calendar entry |
3603 // |
1408 TPtrC testData = GetStringFromConfigL(KTestData1); |
3604 TRequestStatus status; |
1409 SendWapMessage(testData); |
3605 |
1410 |
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 |
1411 // Create a descriptor with correct size for obtaining the message parameter |
3615 // |
1412 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(iSocket)); |
3616 HBufC8* parameterStore = HBufC8::NewLC(GetMessageParameterLengthL(sock)); |
|
3617 TPtr8 parameterStorePtr = parameterStore->Des(); |
1413 TPtr8 parameterStorePtr = parameterStore->Des(); |
3618 |
1414 |
3619 // |
|
3620 // Get the message parameter value |
1415 // Get the message parameter value |
3621 // |
1416 GetMessageParameterL(iSocket, parameterStorePtr); |
3622 GetMessageParameterL(sock, parameterStorePtr); |
1417 |
3623 |
|
3624 // |
|
3625 // Internalise the message parameter and check |
1418 // Internalise the message parameter and check |
3626 // |
1419 TPtrC8 scAddr = iWapAddr.WapAddress(); |
|
1420 |
3627 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
1421 InternaliseSmsDataAndCheckL(parameterStorePtr, scAddr); |
3628 |
1422 |
3629 CleanupStack::PopAndDestroy(parameterStore); |
1423 CleanupStack::PopAndDestroy(parameterStore); |
3630 |
1424 |
3631 // |
1425 iSocket.Close(); |
3632 // Closing the socket |
|
3633 // |
|
3634 CleanupStack::PopAndDestroy(&sock); |
|
3635 CleanupStack::PopAndDestroy(&socketServer); |
|
3636 |
|
3637 return TestStepResult(); |
1426 return TestStepResult(); |
3638 } |
1427 } |
3639 |
1428 |
3640 struct SOneOpTestThreadInfo |
1429 struct SOneOpTestThreadInfo |
3641 { |
1430 { |
4098 TRequestStatus status; |
1796 TRequestStatus status; |
4099 TPtrC testData; |
1797 TPtrC testData; |
4100 GetStringFromConfig(ConfigSection(),KTestData1, testData); |
1798 GetStringFromConfig(ConfigSection(),KTestData1, testData); |
4101 TBuf8<200> data; |
1799 TBuf8<200> data; |
4102 data.Copy(testData); |
1800 data.Copy(testData); |
4103 sock.SendTo(data, wapAddr, 0, status); |
1801 |
|
1802 iSocket.SendTo(data, iWapAddr, 0, status); |
4104 User::WaitForRequest(status); |
1803 User::WaitForRequest(status); |
4105 User::LeaveIfError(status.Int()); |
1804 TESTCHECKL(status.Int(), KErrNone, "Sending Message..."); |
4106 INFO_PRINTF1(_L("Message sent...")); |
1805 |
4107 |
|
4108 // Issue Ioctl for getting the length of the message |
|
4109 TBool messageIsExpected; |
1806 TBool messageIsExpected; |
4110 GetBoolFromConfig(ConfigSection(), _L("messageIsExpected"), messageIsExpected); |
1807 GetBoolFromConfig(ConfigSection(), _L("messageIsExpected"), messageIsExpected); |
4111 |
1808 |
4112 //Setup delay |
1809 //Setup delay |
4113 TRequestStatus timerStatus; |
1810 TRequestStatus timerStatus; |
4114 RTimer timer; |
1811 RTimer timer; |
4115 //Read from the INI file. |
1812 //Read from the INI file. |
4116 TInt timeout; |
1813 TInt timeout = 10000000; // default 10 seconds timeout |
4117 TBool found = GetIntFromConfig(_L("ReceiveTimeout"), _L("timeout"), timeout); |
1814 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 |
1815 |
4124 timer.CreateLocal(); |
1816 timer.CreateLocal(); |
4125 timer.After(timerStatus, TTimeIntervalMicroSeconds32(timeout)); |
1817 timer.After(timerStatus, TTimeIntervalMicroSeconds32(timeout)); |
4126 |
1818 |
4127 // Get the size of the first incomming message |
1819 // Get the size of the first incomming message |
4128 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength")); |
1820 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength")); |
4129 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
1821 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
4130 |
1822 |
4131 //Check if there is in fact a message |
1823 //Check if there is in fact a message |
4132 TBool received=EFalse; |
1824 TBool received=EFalse; |
4133 User::WaitForRequest(timerStatus, ioctlStatus); |
1825 User::WaitForRequest(timerStatus, ioctlStatus); |
4134 |
1826 |
4135 if(ioctlStatus == KRequestPending) |
1827 if(ioctlStatus == KRequestPending) |
4136 { |
1828 { |
4137 // if timer elapsed but ESock request is still pending |
1829 // if timer elapsed but ESock request is still pending |
4138 sock.CancelIoctl(); |
1830 iSocket.CancelIoctl(); |
4139 User::WaitForRequest(ioctlStatus); |
1831 User::WaitForRequest(ioctlStatus); |
4140 } |
1832 } |
4141 else |
1833 else |
4142 { |
1834 { |
4143 // ESock request is done. Cancel timer |
1835 // ESock request is done. Cancel timer |
4144 timer.Cancel(); |
1836 timer.Cancel(); |
4145 User::WaitForRequest(timerStatus); |
1837 User::WaitForRequest(timerStatus); |
4146 // check ESock error status |
1838 // check ESock error status |
4147 if(ioctlStatus.Int() == KErrNone) |
1839 if(ioctlStatus.Int() == KErrNone) |
4148 { |
1840 { |
|
1841 INFO_PRINTF1(_L("IOCTL for GetLength completed successfully")); |
4149 received=ETrue; |
1842 received=ETrue; |
4150 } |
1843 } |
4151 } |
1844 } |
4152 timer.Close(); |
1845 timer.Close(); |
4153 |
1846 |
4154 if(received && messageIsExpected) |
1847 if(received && messageIsExpected) |
4155 { |
1848 { |
4156 // Receiving push datagram |
1849 INFO_PRINTF1(_L("Receiving push datagram...")); |
4157 TWapAddr recvWapAddr; |
1850 TWapAddr recvWapAddr; |
4158 TBuf8<256> recvBuf1(length); |
1851 TBuf8<256> recvBuf1(length); |
4159 sock.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
1852 iSocket.RecvFrom(recvBuf1,recvWapAddr,0,recvStatus); |
4160 User::WaitForRequest(recvStatus); |
1853 User::WaitForRequest(recvStatus); |
4161 User::LeaveIfError(recvStatus.Int()); |
1854 User::LeaveIfError(recvStatus.Int()); |
4162 INFO_PRINTF1(_L("Received the push message...")); |
|
4163 TEST(recvBuf1.Compare(data) == 0); |
1855 TEST(recvBuf1.Compare(data) == 0); |
4164 |
1856 |
4165 // |
1857 // |
4166 // Confirm the receipt of the message to the client |
1858 // Confirm the receipt of the message to the client |
4167 // |
1859 // |
4168 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
1860 TInt ret = iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0); |
4169 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
1861 TESTCHECKL(ret, KErrNone, "Setting Socket option for indicating receipt of message" ) |
4170 |
|
4171 } |
1862 } |
4172 else if (received || messageIsExpected) |
1863 else if (received && !messageIsExpected) |
4173 { |
1864 { |
4174 //Message is not expected |
1865 ERR_PRINTF1(_L("Message is received but not expected")); |
4175 TEST(EFalse); |
1866 SetTestStepResult(EFail); |
4176 } |
1867 } |
4177 |
1868 else if (!received && messageIsExpected) |
4178 CleanupStack::Pop(&sock); |
1869 { |
4179 CleanupStack::Pop(&socketServer); |
1870 ERR_PRINTF1(_L("Message is expected but not received")); |
4180 sock.Close(); |
1871 SetTestStepResult(EFail); |
4181 socketServer.Close(); |
1872 } |
4182 INFO_PRINTF1(_L("End of ReceiveWapMessage test step")); |
1873 |
|
1874 iSocket.Close(); |
|
1875 iSocketServer.Close(); |
4183 #endif |
1876 #endif |
4184 |
|
4185 return TestStepResult(); |
1877 return TestStepResult(); |
4186 } |
1878 } |
4187 |
|
4188 |
1879 |
4189 /** |
1880 /** |
4190 * Tests enumerating of a VCard which needs to go via the observer and not returned to the client. |
1881 * Tests enumerating of a VCard which needs to go via the observer and not returned to the client. |
4191 * |
1882 * |
4192 * @return A TVerdict code. |
1883 * @return A TVerdict code. |
4193 */ |
1884 */ |
4194 TVerdict CTestEnumeratingVCard::doTestStepL() |
1885 TVerdict CTestEnumeratingVCard::doTestStepL() |
4195 { |
1886 { |
4196 // |
1887 // Configure and bind to a socket |
4197 // Setup the test... |
1888 SetupWapSocketL(); |
4198 // |
1889 |
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... |
1890 // Create a socket for the enumeration... |
4232 // |
|
4233 RSocket enumerateSock; |
1891 RSocket enumerateSock; |
4234 TSmsAddr smsAddr; |
1892 TSmsAddr smsAddr; |
4235 |
1893 |
4236 OpenSocketLC(socketServer, enumerateSock, KSMSAddrFamily,KSMSDatagramProtocol); |
1894 OpenSocketLC(iSocketServer, enumerateSock, KSMSAddrFamily,KSMSDatagramProtocol); |
4237 |
1895 |
4238 smsAddr.SetSmsAddrFamily(ESmsAddrLocalOperation); |
1896 smsAddr.SetSmsAddrFamily(ESmsAddrLocalOperation); |
4239 User::LeaveIfError(enumerateSock.Bind(smsAddr)); |
1897 User::LeaveIfError(enumerateSock.Bind(smsAddr)); |
4240 |
1898 |
4241 // |
|
4242 // Trigger the enumeration... |
1899 // Trigger the enumeration... |
4243 // |
1900 TPckgBuf<TUint> messageCount(0); |
4244 TPckgBuf<TUint> messageCount; |
|
4245 TRequestStatus enumStatus; |
1901 TRequestStatus enumStatus; |
4246 |
1902 |
4247 User::After(1000000); // Gives SMS Prot and WAP Prot time to initialise after loading! |
1903 User::After(1000000); // Gives SMS Prot and WAP Prot time to initialise after loading! |
4248 enumerateSock.Ioctl(KIoctlEnumerateSmsMessages, enumStatus, &messageCount, KSolSmsProv); |
1904 enumerateSock.Ioctl(KIoctlEnumerateSmsMessages, enumStatus, &messageCount, KSolSmsProv); |
4249 User::WaitForRequest(enumStatus); |
1905 User::WaitForRequest(enumStatus); |
4250 TESTL(enumStatus.Int() == KErrNone); |
1906 TESTL(enumStatus.Int() == KErrNone); |
4251 TEST(messageCount() == 0); |
1907 TEST(messageCount() == 0); |
4252 |
1908 |
4253 // |
|
4254 // Issue an Ioctl for getting the length of the enumerated datagram... |
1909 // Issue an Ioctl for getting the length of the enumerated datagram... |
4255 // |
|
4256 TRequestStatus ioctlStatus; |
1910 TRequestStatus ioctlStatus; |
4257 TPckgBuf<TInt> length; |
1911 TPckgBuf<TInt> length; |
4258 |
1912 |
4259 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
1913 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
4260 User::WaitForRequest(ioctlStatus); |
1914 User::WaitForRequest(ioctlStatus); |
4261 TESTL(ioctlStatus.Int() == KErrNone); |
1915 TESTL(ioctlStatus.Int() == KErrNone); |
4262 TEST(length() == 118); |
1916 TEST(length() == 118); |
4263 |
1917 |
4264 // |
|
4265 // Receive the VCard... |
1918 // Receive the VCard... |
4266 // |
|
4267 TRequestStatus recvStatus; |
1919 TRequestStatus recvStatus; |
4268 TBuf8<256> recvBuf; |
1920 TBuf8<256> recvBuf; |
4269 TBuf<256> vcardBuf16; |
1921 TBuf<256> vcardBuf16; |
4270 TWapAddr recvWapAddr; |
1922 TWapAddr recvWapAddr; |
4271 |
1923 |
4272 sock.RecvFrom(recvBuf, recvWapAddr, 0, recvStatus); |
1924 iSocket.RecvFrom(recvBuf, recvWapAddr, 0, recvStatus); |
4273 User::WaitForRequest(recvStatus); |
1925 User::WaitForRequest(recvStatus); |
4274 TESTL(recvStatus.Int() == KErrNone); |
1926 TESTL(recvStatus.Int() == KErrNone); |
4275 |
1927 |
4276 vcardBuf16.Copy(recvBuf); |
1928 vcardBuf16.Copy(recvBuf); |
4277 INFO_PRINTF2(_L("Received the VCard: \"%S\""), &vcardBuf16); |
1929 INFO_PRINTF2(_L("Received the VCard: \"%S\""), &vcardBuf16); |
4278 |
1930 |
4279 // |
|
4280 // Confirm the receipt of the message... |
1931 // Confirm the receipt of the message... |
4281 // |
1932 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
4282 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
1933 |
4283 |
1934 iSocket.Close(); |
4284 // |
1935 CleanupStack::PopAndDestroy(&enumerateSock); |
4285 // Close all the sockets |
1936 return TestStepResult(); |
4286 // |
1937 } |
4287 CleanupStack::PopAndDestroy(&enumerateSock); |
|
4288 CleanupStack::PopAndDestroy(&sock); |
|
4289 CleanupStack::PopAndDestroy(&socketServer); |
|
4290 |
|
4291 return TestStepResult(); |
|
4292 } // CTestEnumeratingVCard::doTestStepL |
|
4293 |
|
4294 |
1938 |
4295 /** |
1939 /** |
4296 * Sends a 7-bit VCard with an email address in it, to ensure that '@' |
1940 * Sends a 7-bit VCard with an email address in it, to ensure that '@' |
4297 * characters are sent correctly. |
1941 * characters are sent correctly. |
4298 * |
1942 * |
4299 * @return EPass or EFail. |
1943 * @return EPass or EFail. |
4300 */ |
1944 */ |
4301 TVerdict CTest7BitBusinessCardWithEmail::doTestStepL() |
1945 TVerdict CTest7BitBusinessCardWithEmail::doTestStepL() |
4302 { |
1946 { |
4303 TPtrC testData; |
1947 // Configure and bind to a socket |
4304 TPtrC16 telNumber; |
1948 SetupWapSocketL(); |
4305 TInt port; |
1949 |
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. |
1950 // Send a business card with the email address. |
4364 // |
1951 TPtrC testData = GetStringFromConfigL(KTestData1); |
4365 TRequestStatus status; |
1952 SendWapMessage(testData); |
4366 |
1953 |
4367 TBuf8<200> data; |
1954 ReceiveWapMessage(testData); |
4368 data.Copy(testData); |
1955 |
4369 sock.SendTo(data, wapAddr, 0, status); |
1956 iSocket.Close(); |
4370 User::WaitForRequest(status); |
1957 return TestStepResult(); |
4371 User::LeaveIfError(status.Int()); |
1958 } |
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 |
1959 |
4416 /** |
1960 /** |
4417 * Attempts to send datagrams bigger than the maximum message and bigger |
1961 * Attempts to send datagrams bigger than the maximum message and bigger |
4418 * than the maximum size of an MBuf. |
1962 * than the maximum size of an MBuf. |
4419 * |
1963 * |
4420 * @return EPass or EFail. |
1964 * @return EPass or EFail. |
4421 */ |
1965 */ |
4422 TVerdict CTestOversizedDatagram::doTestStepL() |
1966 TVerdict CTestOversizedDatagram::doTestStepL() |
4423 { |
1967 { |
4424 User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, ESAPhoneOn)); |
1968 // Configure and bind to a socket |
4425 User::LeaveIfError(RProperty::Set(KUidPSSimTsyCategory, KPSSimTsyTestNumber, 1)); |
1969 SetupWapSocketL(); |
4426 |
1970 |
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 |
1971 // Send a datagram of the maximum datagram size (this will fail because |
4456 // of the WAP headers)... |
1972 // of the WAP headers)... |
4457 // |
|
4458 TRequestStatus status; |
1973 TRequestStatus status; |
4459 |
1974 |
4460 HBufC8* textBuf = HBufC8::NewL(65536+1); |
1975 HBufC8* textBuf = HBufC8::NewLC(65536+1); |
4461 CleanupStack::PushL(textBuf); |
|
4462 TPtr8 textPtr = textBuf->Des(); |
1976 TPtr8 textPtr = textBuf->Des(); |
4463 |
1977 |
4464 textPtr.Fill('A', KWAPSMSMaxDatagramSize); |
1978 textPtr.Fill('A', KWAPSMSMaxDatagramSize); |
4465 sock.SendTo(textPtr, wapAddr, 0, status); |
1979 iSocket.SendTo(textPtr, iWapAddr, 0, status); |
4466 User::WaitForRequest(status); |
1980 User::WaitForRequest(status); |
4467 TEST(status.Int() == KErrOverflow); |
1981 TEST(status.Int() == KErrOverflow); |
4468 |
1982 |
4469 // |
|
4470 // Send a datagram bigger than the maximum datagram... |
1983 // Send a datagram bigger than the maximum datagram... |
4471 // |
|
4472 textPtr.Fill('B', KWAPSMSMaxDatagramSize+1); |
1984 textPtr.Fill('B', KWAPSMSMaxDatagramSize+1); |
4473 sock.SendTo(textPtr, wapAddr, 0, status); |
1985 iSocket.SendTo(textPtr, iWapAddr, 0, status); |
4474 User::WaitForRequest(status); |
1986 User::WaitForRequest(status); |
4475 TEST(status.Int() == KErrTooBig); |
1987 TEST(status.Int() == KErrTooBig); |
4476 |
1988 |
4477 // |
|
4478 // Send a datagram bigger than the maximum MBuf... |
1989 // Send a datagram bigger than the maximum MBuf... |
4479 // |
|
4480 textPtr.Fill('C', 65536+1); |
1990 textPtr.Fill('C', 65536+1); |
4481 sock.SendTo(textPtr, wapAddr, 0, status); |
1991 iSocket.SendTo(textPtr, iWapAddr, 0, status); |
4482 User::WaitForRequest(status); |
1992 User::WaitForRequest(status); |
4483 TEST(status.Int() == KErrTooBig); |
1993 TEST(status.Int() == KErrTooBig); |
4484 |
1994 |
|
1995 iSocket.Close(); |
4485 CleanupStack::PopAndDestroy(textBuf); |
1996 CleanupStack::PopAndDestroy(textBuf); |
4486 |
1997 return TestStepResult(); |
4487 // |
1998 } |
4488 // Close the socket... |
|
4489 // |
|
4490 CleanupStack::PopAndDestroy(&sock); |
|
4491 CleanupStack::PopAndDestroy(&socketServer); |
|
4492 |
|
4493 return TestStepResult(); |
|
4494 } // CTestOversizedDatagram::doTestStepL |
|
4495 |
|
4496 |
1999 |
4497 TVerdict CTestWapDatagramSegmentContainingNoData::doTestStepL() |
2000 TVerdict CTestWapDatagramSegmentContainingNoData::doTestStepL() |
4498 /** |
2001 /** |
4499 * Test step: Receive 3 Wap Datagrams, each WAP message contains |
2002 * Test step: Receive 3 Wap Datagrams, each WAP message contains |
4500 * one or more segments which comprise of a wap header but no data. |
2003 * one or more segments which comprise of a wap header but no data. |
4501 * |
2004 * |
4502 * @return - TVerdict code |
2005 * @return - TVerdict code |
4503 * |
|
4504 */ |
2006 */ |
4505 { |
2007 { |
4506 INFO_PRINTF1(_L("CTestWapDatagramSegmentContainingNoData:")); |
2008 INFO_PRINTF1(_L("CTestWapDatagramSegmentContainingNoData:")); |
4507 |
2009 // Configure and bind to a socket |
4508 TVerdict verdict = EPass; |
2010 SetupWapSocketL(); |
4509 |
2011 |
4510 // Create an empty string which will encode into a single segment wap message which contains a wap header, but no wap data. |
2012 TVerdict verdict = EPass; |
4511 _LIT8(KLocalTestData1, ""); |
2013 |
4512 TBuf8<300> data1(KLocalTestData1); |
2014 // Create an empty string which will encode into a single segment wap message which contains a wap header, but no wap data. |
4513 // Create a VCard which will encode into 2 segment wapdatagram, the 2nd segment contains a wap header, but no wap data. |
2015 _LIT8(KLocalTestData1, ""); |
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 |
2016 TBuf8<300> data1(KLocalTestData1); |
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"); |
2017 // Create a VCard which will encode into 2 segment wapdatagram, the 2nd segment contains a wap header, but no wap data. |
4516 TBuf8<300> data2(KLocalTestData2); |
2018 // 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 |
4517 |
2019 _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"); |
4518 |
2020 TBuf8<300> data2(KLocalTestData2); |
4519 TPtrC16 TelNumber; |
2021 |
4520 TInt port=9204; |
2022 |
4521 TInt testNumber = 36; |
2023 TRequestStatus ioctlStatus; |
4522 if(!GetStringFromConfig(ConfigSection(),KSCNumber,TelNumber)) |
2024 TRequestStatus recvStatus; |
4523 { |
2025 TPckgBuf<TInt> length; |
4524 // Leave if there's any error. |
2026 |
4525 User::Leave(KErrNotFound); |
2027 // |
4526 } |
2028 // Issue Ioctl for getting the length of the message |
4527 |
2029 // |
4528 RProperty phonePowerProperty; |
2030 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for first VCal entry")); |
4529 User::LeaveIfError(phonePowerProperty.Attach(KUidSystemCategory, KUidPhonePwr.iUid)); |
2031 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
4530 CleanupClosePushL(phonePowerProperty); |
2032 |
4531 |
2033 |
4532 RProperty testNumberProperty; |
2034 TBuf8<300> data; |
4533 User::LeaveIfError(testNumberProperty.Attach(KUidPSSimTsyCategory, KPSSimTsyTestNumber)); |
2035 |
4534 CleanupClosePushL(testNumberProperty); |
2036 // |
4535 |
2037 // Send a SMS in order to trigger receiving the SMS messages. |
4536 TRequestStatus status; |
2038 // This is to make sure the SMS messages are not received before the |
4537 phonePowerProperty.Subscribe(status); |
2039 // wap address is bound to the socket. |
4538 User::LeaveIfError(phonePowerProperty.Set(KUidSystemCategory,KUidPhonePwr.iUid,ESAPhoneOn)); |
2040 // |
4539 User::WaitForRequest(status); |
2041 TRequestStatus status; |
4540 User::LeaveIfError(status.Int()); |
2042 |
4541 |
2043 iSocket.SendTo(data1, iWapAddr, 0, status); |
4542 testNumberProperty.Subscribe(status); |
2044 User::WaitForRequest(status); |
4543 User::LeaveIfError(testNumberProperty.Set(KUidPSSimTsyCategory,KPSSimTsyTestNumber,testNumber)); |
2045 User::LeaveIfError(status.Int()); |
4544 User::WaitForRequest(status); |
2046 INFO_PRINTF1(_L("First Message (VCal) sent...")); |
4545 User::LeaveIfError(status.Int()); |
2047 |
4546 TInt testNumberCheck; |
2048 // |
4547 User::LeaveIfError(testNumberProperty.Get(testNumberCheck)); |
2049 // Get the size of the first incoming message |
4548 if (testNumber != testNumberCheck) |
2050 // The text string should be empty. |
4549 { |
2051 // |
4550 User::Leave(KErrNotFound); |
2052 TBuf8<300> recvBuf; |
4551 } |
2053 User::WaitForRequest(ioctlStatus); |
4552 // |
2054 User::LeaveIfError(ioctlStatus.Int()); |
4553 // Setting the port number and service center number of the wap address |
2055 INFO_PRINTF1(_L("IOCTL completed")); |
4554 // The service center number should be the same as the sim phone number used |
2056 |
4555 // for test (not required for SIM Tsy) |
2057 // |
4556 // |
2058 // Check if reported length is correct |
4557 TWapAddr wapAddr; |
2059 // |
4558 TWapAddr recvWapAddr; |
2060 if(length()!=data1.Length()) |
4559 wapAddr.SetWapPort(TWapPortNumber(port)); |
2061 { |
4560 TBuf8<100> scNumber; |
2062 verdict = EFail; |
4561 scNumber.Copy(TelNumber); |
2063 } |
4562 TPtrC8 scAddr(scNumber); |
2064 |
4563 wapAddr.SetWapAddress(scAddr); |
2065 // |
4564 |
2066 // Receiving a datagram |
4565 // |
2067 // |
4566 // Connect to socket server |
2068 TWapAddr recvWapAddr; |
4567 // |
2069 |
4568 RSocketServ socketServer; |
2070 iSocket.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
4569 User::LeaveIfError(socketServer.Connect()); |
2071 User::WaitForRequest(recvStatus); |
4570 CleanupClosePushL(socketServer); |
2072 User::LeaveIfError(recvStatus.Int()); |
4571 |
2073 INFO_PRINTF1(_L("Received the first message (VCal)...")); |
4572 // |
2074 |
4573 // Define and open the socket |
2075 // The receive buffer should contain an empty string. |
4574 // |
2076 // This is as a consequence of the wapprot receiving |
4575 RSocket sock; |
2077 // a single segment wap message which contains no data. |
4576 OpenSocketLC(socketServer, sock); |
2078 if(recvBuf.Compare(data1)) |
4577 |
2079 { |
4578 |
2080 ERR_PRINTF1(_L("Non empty string returned")); |
4579 // |
2081 verdict = EFail; |
4580 // Waiting for the phone to be initialised |
2082 } |
4581 // |
2083 |
4582 WaitForInitializeL(); |
2084 // |
4583 |
2085 // Confirm the receipt of the message to the client |
4584 TRequestStatus ioctlStatus; |
2086 // |
4585 TRequestStatus recvStatus; |
2087 INFO_PRINTF1(_L("Socket set option for indicating receipt of first message (VCal)")); |
4586 TPckgBuf<TInt> length; |
2088 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
4587 |
2089 |
4588 // |
2090 |
4589 // Indicating to the protocol that it's a new client |
2091 //Issue Ioctl for getting the length of the second message |
4590 // |
2092 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for second VCard entry")); |
4591 INFO_PRINTF1(_L("Socket set option for indicating new client")); |
2093 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
4592 User::LeaveIfError(sock.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
2094 |
4593 // |
2095 //Get the size of the second incoming message |
4594 // Bind |
2096 User::WaitForRequest(ioctlStatus); |
4595 // |
2097 User::LeaveIfError(ioctlStatus.Int()); |
4596 User::LeaveIfError(sock.Bind(wapAddr)); |
2098 INFO_PRINTF1(_L("IOCTL completed for second message (VCard)")); |
4597 |
2099 |
4598 // |
2100 //Check if reported length is correct |
4599 // Issue Ioctl for getting the length of the message |
2101 if(length()!=data2.Length()) |
4600 // |
2102 { |
4601 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for first VCal entry")); |
2103 verdict = EFail; |
4602 sock.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
2104 } |
4603 |
2105 |
4604 |
2106 //Receiving a datagram (VCard) |
4605 TBuf8<300> data; |
2107 iSocket.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
4606 |
2108 User::WaitForRequest(recvStatus); |
4607 // |
2109 User::LeaveIfError(recvStatus.Int()); |
4608 // Send a SMS in order to trigger receiving the SMS messages. |
2110 INFO_PRINTF1(_L("Received the second message (VCard)...")); |
4609 // This is to make sure the SMS messages are not received before the |
2111 |
4610 // wap address is bound to the socket. |
2112 // Compare the received VCard message with the original one. |
4611 // |
2113 // They should be identical. This checks that the WAPPROT |
4612 sock.SendTo(data1, wapAddr, 0, status); |
2114 // can receive a 2 segment wap datagram, with the 2nd segment containing no data. |
4613 User::WaitForRequest(status); |
2115 // |
4614 User::LeaveIfError(status.Int()); |
2116 if(recvBuf.Compare(data2)) |
4615 INFO_PRINTF1(_L("First Message (VCal) sent...")); |
2117 { |
4616 |
2118 ERR_PRINTF1(_L("VCard message received does not match with original message.")); |
4617 // |
2119 verdict = EFail; |
4618 // Get the size of the first incoming message |
2120 } |
4619 // The text string should be empty. |
2121 |
4620 // |
2122 //Confirm the receipt of the message to the client |
4621 TBuf8<300> recvBuf; |
2123 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
4622 User::WaitForRequest(ioctlStatus); |
2124 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
4623 User::LeaveIfError(ioctlStatus.Int()); |
2125 //Issue Ioctl for getting the length of the third message |
4624 INFO_PRINTF1(_L("IOCTL completed")); |
2126 |
4625 // |
2127 INFO_PRINTF1(_L("Issue of the IOCTL for GetLength for second VCard entry")); |
4626 // Check if reported length is correct |
2128 iSocket.Ioctl(KSOGetLength, ioctlStatus, &length, KSolWapProv); |
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 |
2129 |
4694 //Get the size of the third incoming message |
2130 //Get the size of the third incoming message |
4695 User::WaitForRequest(ioctlStatus); |
2131 User::WaitForRequest(ioctlStatus); |
4696 User::LeaveIfError(ioctlStatus.Int()); |
2132 User::LeaveIfError(ioctlStatus.Int()); |
4697 INFO_PRINTF1(_L("IOCTL completed for third message (VCard)")); |
2133 INFO_PRINTF1(_L("IOCTL completed for third message (VCard)")); |
|
2134 |
|
2135 //Check if reported length is correct |
|
2136 if(length()!=data1.Length()) |
|
2137 { |
|
2138 verdict = EFail; |
|
2139 } |
4698 |
2140 |
4699 //Check if reported length is correct |
2141 //Receiving a datagram (VCard) |
4700 if(length()!=data1.Length()) |
2142 iSocket.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
4701 { |
2143 User::WaitForRequest(recvStatus); |
4702 verdict = EFail; |
2144 User::LeaveIfError(recvStatus.Int()); |
4703 } |
2145 INFO_PRINTF1(_L("Received the third message (VCard)...")); |
4704 |
2146 |
4705 //Receiving a datagram (VCard) |
2147 // The receive buffer should contain an empty string. |
4706 sock.RecvFrom(recvBuf,recvWapAddr,0,recvStatus); |
2148 // This is as a consequence of the WAPPROT containing 2 concatenated WAP Datagrams |
4707 User::WaitForRequest(recvStatus); |
2149 // each datagram segement containing no data. |
4708 User::LeaveIfError(recvStatus.Int()); |
2150 if(recvBuf.Compare(data1)) |
4709 INFO_PRINTF1(_L("Received the third message (VCard)...")); |
2151 { |
4710 |
2152 ERR_PRINTF1(_L("VCard message received does not match with original message.")); |
4711 // The receive buffer should contain an empty string. |
2153 verdict = EFail; |
4712 // This is as a consequence of the WAPPROT containing 2 concatenated WAP Datagrams |
2154 } |
4713 // each datagram segement containing no data. |
2155 |
4714 if(recvBuf.Compare(data1)) |
2156 //Confirm the receipt of the message to the client |
4715 { |
2157 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
4716 ERR_PRINTF1(_L("VCard message received does not match with original message.")); |
2158 User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
4717 verdict = EFail; |
2159 |
4718 } |
2160 iSocket.Close(); |
4719 |
2161 SetTestStepResult(verdict); |
4720 //Confirm the receipt of the message to the client |
2162 return TestStepResult(); |
4721 INFO_PRINTF1(_L("Socket set option for indicating receipt of message")); |
2163 } |
4722 User::LeaveIfError(sock.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0)); |
2164 |
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 |
|