24 CSendReceiveSMSWhileServerInOOM::CSendReceiveSMSWhileServerInOOM(RSocketServ &aSocketServer) |
24 CSendReceiveSMSWhileServerInOOM::CSendReceiveSMSWhileServerInOOM(RSocketServ &aSocketServer) |
25 /** |
25 /** |
26 Each test step initialises it's own name |
26 Each test step initialises it's own name |
27 */ |
27 */ |
28 { |
28 { |
29 iSocketServer = &aSocketServer; |
29 iSharedSocketServer = &aSocketServer; |
|
30 iPartOfMultiStepTestCase = ETrue; |
30 } |
31 } |
31 |
32 |
32 /** |
33 /** |
33 Send and Receive a SMS Message while the socket server has been placed in OOM |
34 Send and Receive a SMS Message while the socket server has been placed in OOM |
34 */ |
35 */ |
39 #else |
40 #else |
40 //Read from the INI file. |
41 //Read from the INI file. |
41 TInt timeout=10; |
42 TInt timeout=10; |
42 GetIntFromConfig(ConfigSection(), _L("timeout"), timeout); |
43 GetIntFromConfig(ConfigSection(), _L("timeout"), timeout); |
43 |
44 |
44 |
|
45 //Open the socket for sending messages |
45 //Open the socket for sending messages |
46 RSocket socket; |
46 RSocket socket; |
47 INFO_PRINTF1(_L("Opening socket and loading SMS Protocol")); |
47 OpenSmsSocketL(*iSharedSocketServer, socket, ESmsAddrSendOnly); |
48 OpenSmsSocketL(*iSocketServer, socket, ESmsAddrSendOnly); |
48 CleanupClosePushL(socket); |
49 |
49 |
50 //Create SMS |
50 //Create SMS |
51 CSmsMessage* iSms=CreateSMSL(); |
51 CSmsMessage* sms=CreateSMSL(); |
52 CleanupStack::PushL(iSms); |
52 CleanupStack::PushL(sms); |
53 |
53 |
54 TBool isClientExpectingMessage; |
54 TBool isClientExpectingMessage; |
55 GetBoolFromConfig(ConfigSection(), _L("isClientExpectingMessage"), isClientExpectingMessage); |
55 GetBoolFromConfig(ConfigSection(), _L("isClientExpectingMessage"), isClientExpectingMessage); |
56 |
56 |
57 INFO_PRINTF1(_L("Sending SMS...") ); |
57 INFO_PRINTF1(_L("Sending SMS...") ); |
58 PrintMessageL(iSms); |
58 PrintMessageL(sms); |
59 |
59 |
60 //Send SMS |
60 //Send SMS |
61 SendSmsL(iSms,socket); |
61 SendSmsL(sms,socket); |
62 CleanupStack::PopAndDestroy(iSms); |
62 CleanupStack::PopAndDestroy(sms); |
63 socket.Close(); |
63 CleanupStack::PopAndDestroy(&socket); |
64 |
64 |
65 //Open the socket for receiving messages |
65 //Open the socket for receiving messages |
66 INFO_PRINTF1(_L("Opening socket and loading SMS Protocol")); |
|
67 RSocket recSocket; |
66 RSocket recSocket; |
68 OpenSmsSocketL(*iSocketServer, recSocket, ESmsAddrRecvAny); |
67 OpenSmsSocketL(*iSharedSocketServer, recSocket, ESmsAddrRecvAny); |
69 |
68 CleanupClosePushL(recSocket); |
|
69 |
70 //Receive |
70 //Receive |
71 TInt allocFailCount=0; |
71 TInt allocFailCount=0; |
72 TInt ret=KErrNoMemory; |
72 TInt ret=KErrNoMemory; |
73 while (ret==KErrNoMemory || ret==KErrEof) |
73 while (ret==KErrNoMemory || ret==KErrEof) |
74 { |
74 { |
80 //Set the result to "fail" if no message is received in the specified time |
80 //Set the result to "fail" if no message is received in the specified time |
81 if(messageReceived && isClientExpectingMessage ) |
81 if(messageReceived && isClientExpectingMessage ) |
82 { |
82 { |
83 INFO_PRINTF1(_L("Message received!")); |
83 INFO_PRINTF1(_L("Message received!")); |
84 |
84 |
85 iSocketServer->__DbgMarkHeap(); |
85 iSharedSocketServer->__DbgMarkHeap(); |
86 iSocketServer->__DbgFailNext(allocFailCount); |
86 iSharedSocketServer->__DbgFailNext(allocFailCount); |
87 |
87 |
88 CSmsMessage *iSmsMessage=NULL; |
88 CSmsMessage *iSmsMessage=NULL; |
89 |
89 |
90 TRAP(ret,iSmsMessage=RecvSmsL(recSocket)); //Get the message from the STACK. |
90 TRAP(ret,iSmsMessage=RecvSmsL(recSocket)); //Get the message from the STACK. |
91 iSocketServer->__DbgMarkEnd(0); |
91 iSharedSocketServer->__DbgMarkEnd(0); |
92 |
92 |
93 //If a message was retrieved successfully. |
93 //If a message was retrieved successfully. |
94 if(ret==KErrNone) |
94 if(ret==KErrNone) |
95 { |
95 { |
96 INFO_PRINTF1(_L("Message received!")); |
96 INFO_PRINTF1(_L("Message received!")); |
103 |
103 |
104 if(messageText!=_L("")) |
104 if(messageText!=_L("")) |
105 { |
105 { |
106 TestSmsContentsL(iSmsMessage,messageText); |
106 TestSmsContentsL(iSmsMessage,messageText); |
107 } |
107 } |
108 |
|
109 CleanupStack::PopAndDestroy(iSmsMessage); |
108 CleanupStack::PopAndDestroy(iSmsMessage); |
110 } |
109 } |
111 |
110 ++allocFailCount; |
112 allocFailCount++; |
|
113 } |
111 } |
114 |
|
115 } |
112 } |
116 |
113 |
117 recSocket.Close(); |
114 CleanupStack::PopAndDestroy(&recSocket); |
118 iSocketServer->__DbgFailNext(-1); // Reset heap |
115 iSharedSocketServer->__DbgFailNext(-1); // Reset heap |
119 #endif |
116 #endif |
120 return TestStepResult(); |
117 return TestStepResult(); |
121 } |
118 } |
122 |
119 |
123 //------------------------------------------------------------------------------------- |
|