22 CReceiveSMS::CReceiveSMS(RSocketServ &aSocketServer) |
22 CReceiveSMS::CReceiveSMS(RSocketServ &aSocketServer) |
23 /** |
23 /** |
24 Each test step initialises it's own name |
24 Each test step initialises it's own name |
25 */ |
25 */ |
26 { |
26 { |
27 iSocketServer = &aSocketServer; |
27 iSharedSocketServer = &aSocketServer; |
|
28 iPartOfMultiStepTestCase = ETrue; |
28 } |
29 } |
29 |
30 |
30 /** |
31 /** |
31 Receive SMS Message |
32 Receive SMS Message |
32 */ |
33 */ |
33 TVerdict CReceiveSMS::doTestStepL() |
34 TVerdict CReceiveSMS::doTestStepL() |
34 { |
35 { |
35 #ifndef _DEBUG |
36 #ifndef _DEBUG |
36 INFO_PRINTF1(_L("This test can only be run when the SMS Stack is in debug mode.")); |
37 INFO_PRINTF1(_L("This test can only be run when the SMS Stack is in debug mode.")); |
37 #else |
38 #else |
38 |
39 //Read from the INI file |
39 //Read from the INI file. |
|
40 TInt timeout=10; |
40 TInt timeout=10; |
41 GetIntFromConfig(ConfigSection(), _L("timeout"), timeout); |
41 GetIntFromConfig(ConfigSection(), _L("timeout"), timeout); |
42 |
42 |
|
43 TBool messageExpected; |
|
44 GetBoolFromConfig(ConfigSection(), _L("isClientExpectingMessage"), messageExpected); |
43 |
45 |
44 TBool isThisADiskSpaceMonitorTest; |
46 if( messageExpected && timeout < 40 ) |
45 GetBoolFromConfig(_L("DiskSpaceMonitor"), _L("diskSpaceMonitor"), isThisADiskSpaceMonitorTest); |
|
46 TBool isClientExpectingMessage; |
|
47 GetBoolFromConfig(ConfigSection(), _L("isClientExpectingMessage"), isClientExpectingMessage); |
|
48 |
|
49 //Disk SpaceMonitor tests are only run in DEBUG builds |
|
50 if(isThisADiskSpaceMonitorTest) |
|
51 { |
|
52 #ifndef _DEBUG |
|
53 return TestStepResult(); |
|
54 #endif |
|
55 } |
|
56 |
|
57 if( isClientExpectingMessage && timeout < 40 ) |
|
58 { |
47 { |
59 // Change timeout to be 40 seconds |
48 // Change timeout to be 40 seconds |
60 timeout = 40; |
49 timeout = 40; |
61 } |
50 } |
62 |
51 |
63 INFO_PRINTF1(_L("Receiving SMS message...")); |
52 INFO_PRINTF1(_L("Receiving SMS message...")); |
64 |
53 |
65 //Open the socket for receiving messages |
54 //Open the socket for receiving messages |
66 INFO_PRINTF1(_L("Opening socket and loading SMS Protocol")); |
|
67 RSocket socket; |
55 RSocket socket; |
68 OpenSmsSocketL(*iSocketServer, socket, ESmsAddrRecvAny); |
56 OpenSmsSocketL(*iSharedSocketServer, socket, ESmsAddrRecvAny); |
|
57 CleanupClosePushL(socket); |
69 |
58 |
70 //Message must be received in "timeout" else the test will fail |
59 //Message must be received in "timeout" else the test will fail |
71 INFO_PRINTF2(_L("Wait for message (timeout: %d)..."), timeout); |
60 INFO_PRINTF2(_L("Wait for message (timeout: %d)..."), timeout); |
72 TBool messageReceived = TimedWaitForRecvL(socket, timeout*1000000); |
61 TBool messageReceived = TimedWaitForRecvL(socket, timeout*1000000); |
73 |
62 |
74 if(messageReceived) |
63 if( !messageReceived ) |
75 { |
64 { |
76 INFO_PRINTF1(_L("Message received!")); |
65 if( messageExpected ) |
77 } |
66 { |
78 |
67 ERR_PRINTF1(_L("Message expected - not received!")); |
79 //Set the result to "fail" if no message is received in the specified time |
68 TEST(EFalse); |
80 if(messageReceived && isClientExpectingMessage ) |
69 } |
81 { |
70 else |
82 CSmsMessage *smsMessage=RecvSmsL(socket); //Get the message from the STACK. |
71 { |
83 CleanupStack::PushL(smsMessage); |
72 INFO_PRINTF1(_L("No message expected and not received")); |
84 |
73 } |
85 //Get the text from the ini file |
74 } |
86 TPtrC messageText; |
75 else |
87 GetStringFromConfig(ConfigSection(), _L("messageExpected"), messageText); |
76 { |
|
77 CSmsMessage* smsMessage = RecvSmsL(socket); //Get the message from the STACK. |
|
78 CleanupStack::PushL(smsMessage); |
|
79 |
|
80 if( !messageExpected ) |
|
81 { |
|
82 ERR_PRINTF1(_L("Message not expected!")); |
|
83 TEST(EFalse); |
|
84 } |
|
85 else |
|
86 { |
|
87 //Get the text from the ini file |
|
88 TPtrC messageText; |
|
89 GetStringFromConfig(ConfigSection(), _L("messageExpected"), messageText); |
88 |
90 |
89 if(messageText!=_L("")) |
91 if(messageText!=_L("")) |
90 { |
92 { |
91 TestSmsContentsL(smsMessage,messageText); |
93 TestSmsContentsL(smsMessage,messageText); |
92 } |
94 } |
93 |
95 } |
94 CleanupStack::PopAndDestroy(smsMessage); |
96 CleanupStack::PopAndDestroy(smsMessage); |
95 } |
97 } |
96 |
98 CleanupStack::PopAndDestroy(&socket); |
97 else if((!messageReceived && isClientExpectingMessage) || |
|
98 (messageReceived && !isClientExpectingMessage)) |
|
99 { |
|
100 if( !messageReceived && isClientExpectingMessage ) |
|
101 { |
|
102 INFO_PRINTF1(_L("Message expected - not received")); |
|
103 } |
|
104 TEST(EFalse); |
|
105 } |
|
106 |
|
107 socket.Close(); |
|
108 #endif |
99 #endif |
109 return TestStepResult(); |
100 return TestStepResult(); |
110 } |
101 } |
111 |
|
112 //----------------------------------------------------------------------------- |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|