14 // Test Wap Status reports |
14 // Test Wap Status reports |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
18 /** |
18 /** |
19 @file |
19 @file |
|
20 @test |
20 */ |
21 */ |
21 |
22 |
22 #include "WapStatusReports.h" |
23 #include "WapStatusReports.h" |
23 |
24 |
|
25 #include <Gsmumsg.h> |
|
26 #include <simtsy.h> |
|
27 |
|
28 #include "WapProtSuiteDefs.h" |
|
29 |
24 /** |
30 /** |
25 Preamble for all status report steps |
31 Preamble for all status report steps |
26 */ |
32 */ |
27 TVerdict CTestWapStatusReports::doTestStepPreambleL() |
33 TVerdict CTestWapStatusReports::doTestStepPreambleL() |
28 { |
34 { |
29 CWapProtSuiteStepBase::doTestStepPreambleL(); |
35 CWapProtSuiteStepBase::doTestStepPreambleL(); |
30 |
36 |
31 SetTestNumberL(); |
37 OpenSocketL(iSocketServer, iSocket); |
32 |
38 |
33 // Connect to socket server |
39 SetCodingSchemeL(); |
34 User::LeaveIfError(iSocketServer.Connect()); |
40 INFO_PRINTF1(_L("Coding scheme set is successful ...")); |
35 |
41 SetMessageTypeL(); |
36 // Define and open the socket |
42 INFO_PRINTF1(_L("Message type setup is successful ...")); |
37 User::LeaveIfError(iSocket.Open(iSocketServer,KWAPSMSAddrFamily,KSockDatagram,KWAPSMSDatagramProtocol)); |
43 ReadWapPortSettingsL(iWapAddr, KWapPort); |
38 |
44 INFO_PRINTF1(_L("Reading Wap port setting is successful ...")); |
39 // Waiting for the phone to be initialised |
45 |
40 WaitForInitializeL(); |
46 // Bind |
41 |
47 User::LeaveIfError(iSocket.Bind(iWapAddr)); |
42 SetCodingSchemeL(); |
48 |
43 SetMessageTypeL(); |
49 TTimeIntervalMicroSeconds32 InitPause=9000000; //Required Pause to Allow SMSStack to Complete its Async Init |
44 SetWapAddrL(); |
50 User::After(InitPause); //call to the TSY and finish its StartUp. |
45 |
51 |
46 return TestStepResult(); |
52 |
47 } |
53 return TestStepResult(); |
|
54 } |
|
55 |
|
56 /** |
|
57 Postamble for all status report steps |
|
58 */ |
|
59 TVerdict CTestWapStatusReports::doTestStepPostambleL() |
|
60 { |
|
61 iSocket.Close(); |
|
62 |
|
63 CWapProtSuiteStepBase::doTestStepPostambleL(); |
|
64 |
|
65 return TestStepResult(); |
|
66 } |
48 |
67 |
49 /** |
68 /** |
50 Utility for sending a wap message |
69 Utility for sending a wap message |
51 */ |
70 */ |
52 void CTestWapStatusReports::SendWapMessageL() |
71 void CTestWapStatusReports::SendWapMessageL() |
53 { |
72 { |
54 // Indicating to the protocol that it's a new client |
73 // Indicating to the protocol that it's a new client |
55 //INFO_PRINTF1(_L("Socket set option for indicating new client")); |
74 //INFO_PRINTF1(_L("Socket set option for indicating new client")); |
56 //User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
75 //User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0)); |
57 |
76 |
58 //Get the data |
77 //Get the data |
59 TPtrC textData; |
78 TPtrC textData; |
60 GetStringFromConfig(ConfigSection(),_L("message"), textData); |
79 GetStringFromConfig(ConfigSection(),_L("message"), textData); |
61 |
80 |
62 //Set the buffer |
81 //Set the buffer |
63 TBuf8<1000> data; |
82 TBuf8<1000> data; |
64 data.Copy(textData); |
83 data.Copy(textData); |
65 |
84 |
66 //Send the message |
85 //Send the message |
67 TRequestStatus status; |
86 TRequestStatus status; |
68 iSocket.SendTo(data, iWapAddr, 0, status); |
87 iSocket.SendTo(data, iWapAddr, 0, status); |
69 User::WaitForRequest(status); |
88 User::WaitForRequest(status); |
70 User::LeaveIfError(status.Int()); |
89 User::LeaveIfError(status.Int()); |
71 INFO_PRINTF1(_L("Message sent!")); |
90 INFO_PRINTF1(_L("Message sent!")); |
72 } |
91 } |
73 |
|
74 |
92 |
75 /** |
93 /** |
76 Utility for getting the expected status |
94 Utility for getting the expected status |
77 */ |
95 */ |
78 void CTestWapStatusReports::GetExpectedStatus() |
96 void CTestWapStatusReports::GetExpectedStatus() |
79 { |
97 { |
80 //Get the port number from the ini file |
98 //Get the port number from the ini file |
81 GetIntFromConfig(ConfigSection(),_L("expectedStatus"), iExpectedStatus); |
99 GetIntFromConfig(ConfigSection(),_L("expectedStatus"), iExpectedStatus); |
82 } |
100 } |
83 |
101 |
84 /** |
102 /** |
85 Utility for receiving status reports |
103 Utility for receiving status reports |
86 */ |
104 */ |
87 TSmsStatus::TSmsStatusValue CTestWapStatusReports::ReceiveStatusReportL() |
105 TSmsStatus::TSmsStatusValue CTestWapStatusReports::ReceiveStatusReportL() |
88 { |
106 { |
89 INFO_PRINTF1(_L("waiting for incoming status report...") ); |
107 INFO_PRINTF1(_L("waiting for incoming status report...") ); |
90 WaitForRecvL(iStatusReportSocket); |
108 WaitForRecvL(iStatusReportSocket); |
91 CSmsMessage* smsMessage = RecvSmsL(iStatusReportSocket); |
109 CSmsMessage* smsMessage = RecvSmsL(iStatusReportSocket); |
92 |
110 |
93 INFO_PRINTF1(_L("incoming SMS") ); |
111 INFO_PRINTF1(_L("incoming SMS") ); |
94 |
112 |
95 //Check the status report |
113 //Check the status report |
96 CleanupStack::PushL(smsMessage); |
114 CleanupStack::PushL(smsMessage); |
97 TBool isSR = (smsMessage->Type()==CSmsPDU::ESmsStatusReport); |
115 TBool isSR = (smsMessage->Type()==CSmsPDU::ESmsStatusReport); |
98 |
116 |
99 if (isSR) |
117 if (isSR) |
100 { |
118 { |
101 INFO_PRINTF1(_L("Received status report")); |
119 INFO_PRINTF1(_L("Received status report")); |
102 TSmsServiceCenterAddress telephoneNumber=smsMessage->ToFromAddress(); |
120 TSmsServiceCenterAddress telephoneNumber=smsMessage->ToFromAddress(); |
103 } |
121 } |
104 else |
122 else |
105 { |
123 { |
106 INFO_PRINTF1(_L("Received SMS is NOT a Status report!")); |
124 INFO_PRINTF1(_L("Received SMS is NOT a Status report!")); |
107 } |
125 } |
108 |
126 |
109 TEST(isSR==1); |
127 TEST(isSR); |
110 |
128 |
111 //Get the status report |
129 //Get the status report |
112 CSmsStatusReport& statusReport = static_cast<CSmsStatusReport&>(smsMessage->SmsPDU()); |
130 CSmsStatusReport& statusReport = static_cast<CSmsStatusReport&>(smsMessage->SmsPDU()); |
113 TSmsStatus::TSmsStatusValue status = statusReport.Status(); |
131 TSmsStatus::TSmsStatusValue status = statusReport.Status(); |
114 |
132 |
115 CleanupStack::PopAndDestroy(smsMessage); |
133 CleanupStack::PopAndDestroy(smsMessage); |
116 |
134 |
117 return status; |
135 return status; |
118 } |
136 } |
119 |
|
120 |
|
121 /** |
|
122 Postamble for all status report steps |
|
123 */ |
|
124 TVerdict CTestWapStatusReports::doTestStepPostambleL() |
|
125 { |
|
126 iSocket.Close(); |
|
127 iSocketServer.Close(); |
|
128 |
|
129 CWapProtSuiteStepBase::doTestStepPostambleL(); |
|
130 |
|
131 return TestStepResult(); |
|
132 } |
|
133 |
137 |
134 //----------------------------------------------------------------------------- |
138 //----------------------------------------------------------------------------- |
135 |
139 |
136 /** |
140 /** |
137 Setup the SMS for TP-SRR operations on the SMS |
141 Setup the SMS for TP-SRR operations on the SMS |
138 */ |
142 */ |
139 TVerdict CTestRequestingStatusReports::doTestStepPreambleL() |
143 TVerdict CTestRequestingStatusReports::doTestStepPreambleL() |
140 { |
144 { |
141 //Call the base class preamble |
145 //Call the base class preamble |
142 CTestWapStatusReports::doTestStepPreambleL(); |
146 CTestWapStatusReports::doTestStepPreambleL(); |
143 |
147 |
144 return TestStepResult(); |
148 return TestStepResult(); |
145 } |
149 } |
146 |
150 |
147 /** |
151 /** |
148 Common test steps for all status reports steps |
152 Common test steps for all status reports steps |
149 */ |
153 */ |
150 TVerdict CTestRequestingStatusReports::doTestStepL() |
154 TVerdict CTestRequestingStatusReports::doTestStepL() |
151 { |
155 { |
152 SendWapMessageL(); |
156 SendWapMessageL(); |
153 |
157 |
154 return TestStepResult(); |
158 return TestStepResult(); |
155 } |
159 } |
|
160 |
156 //----------------------------------------------------------------------------- |
161 //----------------------------------------------------------------------------- |
157 /** |
162 /** |
158 Setup the SMS for TP-SRR operations on the SMS |
163 Setup the SMS for TP-SRR operations on the SMS |
159 */ |
164 */ |
160 TVerdict CTestRequestingStatusReportsWithOption::doTestStepPreambleL() |
165 TVerdict CTestRequestingStatusReportsWithOption::doTestStepPreambleL() |
161 { |
166 { |
162 //Call the base class preamble |
167 //Call the base class preamble |
163 CTestRequestingStatusReports::doTestStepPreambleL(); |
168 CTestRequestingStatusReports::doTestStepPreambleL(); |
164 |
169 |
165 INFO_PRINTF1(_L("Socket set option for indicating last PDU status report")); |
170 INFO_PRINTF1(_L("Socket set option for indicating last PDU status report")); |
166 User::LeaveIfError(iSocket.SetOpt(KWapSmsStatusReportScheme, KWapSmsOptionLevel, EWapSmsTPSRR)); |
171 User::LeaveIfError(iSocket.SetOpt(KWapSmsStatusReportScheme, KWapSmsOptionLevel, EWapSmsTPSRR)); |
167 |
172 |
168 return TestStepResult(); |
173 return TestStepResult(); |
169 } |
174 } |
|
175 |
170 //----------------------------------------------------------------------------- |
176 //----------------------------------------------------------------------------- |
171 |
177 |
172 /** |
178 /** |
173 Setup the SMS for TP-SRR operations on the SMS |
179 Setup the SMS for TP-SRR operations on the SMS |
174 */ |
180 */ |
175 TVerdict CTestReceivingStatusReports::doTestStepPreambleL() |
181 TVerdict CTestReceivingStatusReports::doTestStepPreambleL() |
176 { |
182 { |
177 //Call the base class preamble |
183 //Call the base class preamble |
178 CTestWapStatusReports::doTestStepPreambleL(); |
184 CTestWapStatusReports::doTestStepPreambleL(); |
179 |
185 |
180 GetExpectedStatus(); |
186 GetExpectedStatus(); |
181 SetupStatusReportSocketL(); |
187 SetupStatusReportSocketL(); |
182 |
188 |
183 return TestStepResult(); |
189 return TestStepResult(); |
184 } |
190 } |
185 |
191 |
186 /** |
192 /** |
187 Common test steps for all status reports steps |
193 Common test steps for all status reports steps |
188 */ |
194 */ |
189 TVerdict CTestReceivingStatusReports::doTestStepL() |
195 TVerdict CTestReceivingStatusReports::doTestStepL() |
190 { |
196 { |
191 SendWapMessageL(); |
197 SendWapMessageL(); |
192 TSmsStatus::TSmsStatusValue status; |
198 TSmsStatus::TSmsStatusValue status; |
193 status=ReceiveStatusReportL(); |
199 status=ReceiveStatusReportL(); |
194 |
200 |
195 TESTL(status == iExpectedStatus); |
201 TESTL(status == iExpectedStatus); |
196 |
202 |
197 return TestStepResult(); |
203 return TestStepResult(); |
198 } |
204 } |
199 |
205 |
200 /** |
206 /** |
201 Common test steps for all status reports steps |
207 Common test steps for all status reports steps |
202 */ |
208 */ |
203 TVerdict CTestReceivingStatusReports::doTestStepPostambleL() |
209 TVerdict CTestReceivingStatusReports::doTestStepPostambleL() |
204 { |
210 { |
205 iStatusReportSocket.Close(); |
211 iStatusReportSocket.Close(); |
206 |
212 |
207 //Call the base class preamble |
213 //Call the base class preamble |
208 CTestWapStatusReports::doTestStepPostambleL(); |
214 CTestWapStatusReports::doTestStepPostambleL(); |
209 |
215 |
210 return TestStepResult(); |
216 return TestStepResult(); |
211 } |
217 } |
212 |
218 |
213 //----------------------------------------------------------------------------- |
219 //----------------------------------------------------------------------------- |
214 |
220 |
215 /** |
221 /** |
216 Common test steps for all status reports steps |
222 Common test steps for all status reports steps |
217 */ |
223 */ |
218 TVerdict CTestReceivingStatusReportsSevenBitMultiplePDUs::doTestStepL() |
224 TVerdict CTestReceivingStatusReportsSevenBitMultiplePDUs::doTestStepL() |
219 { |
225 { |
220 CTestReceivingStatusReports::doTestStepL(); |
226 CTestReceivingStatusReports::doTestStepL(); |
221 |
227 |
222 //We will receive 2 status reports for this message |
228 //We will receive 3 status reports for this message |
223 TSmsStatus::TSmsStatusValue status; |
229 TSmsStatus::TSmsStatusValue status; |
224 status=ReceiveStatusReportL(); |
230 status=ReceiveStatusReportL(); |
225 TESTL(status == iExpectedStatus); |
231 TESTL(status == iExpectedStatus); |
226 |
232 |
227 return TestStepResult(); |
233 status=ReceiveStatusReportL(); |
228 } |
234 TESTL(status == iExpectedStatus); |
|
235 return TestStepResult(); |
|
236 } |
229 //----------------------------------------------------------------------------- |
237 //----------------------------------------------------------------------------- |
230 |
238 |
231 |
239 |
232 TVerdict CTestReceivingStatusReportsWithOption::doTestStepPreambleL() |
240 TVerdict CTestReceivingStatusReportsWithOption::doTestStepPreambleL() |
233 { |
241 { |
234 //Sets up the socket for receiving status reports |
242 //Sets up the socket for receiving status reports |
235 CTestReceivingStatusReports::doTestStepPreambleL(); |
243 CTestReceivingStatusReports::doTestStepPreambleL(); |
236 |
244 |
237 //Set the option for last PDU only (TPSRR Scheme) |
245 //Set the option for last PDU only (TPSRR Scheme) |
238 INFO_PRINTF1(_L("Socket set option for indicating last PDU status report")); |
246 INFO_PRINTF1(_L("Socket set option for indicating last PDU status report")); |
239 User::LeaveIfError(iSocket.SetOpt(KWapSmsStatusReportScheme, KWapSmsOptionLevel, EWapSmsTPSRR)); |
247 User::LeaveIfError(iSocket.SetOpt(KWapSmsStatusReportScheme, KWapSmsOptionLevel, EWapSmsTPSRR)); |
240 |
248 |
241 return TestStepResult(); |
249 return TestStepResult(); |
242 } |
250 } |
243 |
251 |
244 //----------------------------------------------------------------------------- |
252 //----------------------------------------------------------------------------- |
245 |
|
246 |
|