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