24
|
1 |
// Copyright (c) 1997-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 |
//
|
|
15 |
|
|
16 |
#include <e32test.h>
|
|
17 |
|
|
18 |
#include "TE_EtelMMTestStepBase.h"
|
|
19 |
#include "TE_mmussd.h"
|
|
20 |
#include "testdef.h"
|
|
21 |
|
|
22 |
CTestUssdMessaging::CTestUssdMessaging()
|
|
23 |
/** Each test step initialises it's own name
|
|
24 |
*/
|
|
25 |
{
|
|
26 |
// store the name of this test case
|
|
27 |
// this is the name that is used by the script file
|
|
28 |
SetTestStepName(_L("TestUssdMessaging"));
|
|
29 |
}
|
|
30 |
|
|
31 |
enum TVerdict CTestUssdMessaging::doTestStepL()
|
|
32 |
//
|
|
33 |
// Test USSD Messaging Functions
|
|
34 |
//
|
|
35 |
{
|
|
36 |
iTestCount=1;
|
|
37 |
INFO_PRINTF1(_L(""));
|
|
38 |
INFO_PRINTF1(_L("Test Mobile USSD Messaging Functionality"));
|
|
39 |
// LOGTEXT(_L8("Test Mobile USSD Messaging Functionality"));
|
|
40 |
|
|
41 |
RMobilePhone mmPhone;
|
|
42 |
TInt ret=mmPhone.Open(iTelServer,DMMTSY_PHONE_NAME);
|
|
43 |
TEST(ret==KErrNone);
|
|
44 |
|
|
45 |
RMobileUssdMessaging ussdMessaging;
|
|
46 |
ret=ussdMessaging.Open(mmPhone);
|
|
47 |
TEST(ret==KErrNone);
|
|
48 |
|
|
49 |
TRequestStatus reqStatus;
|
|
50 |
|
|
51 |
// Get USSD messaging caps
|
|
52 |
RMobileUssdMessaging::TMobileUssdCapsV1 ussdCaps;
|
|
53 |
RMobileUssdMessaging::TMobileUssdCapsV1Pckg ussdCapsPckg(ussdCaps);
|
|
54 |
|
|
55 |
TEST(ussdMessaging.GetCaps(ussdCapsPckg)==KErrNone);
|
|
56 |
|
|
57 |
ussdCaps=ussdCapsPckg();
|
|
58 |
TEST(ussdCaps.iUssdTypes==DMMTSY_USSD_MESSAGING_TYPE_CAPS);
|
|
59 |
|
|
60 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::GetCaps (sync) passed"), iTestCount++);
|
|
61 |
|
|
62 |
// test.Next(_L("OK: RMobileUssdMessaging's Get Ussd caps"));
|
|
63 |
|
|
64 |
// Receiving Ussd messages
|
|
65 |
|
|
66 |
RMobileUssdMessaging::TGsmUssdMessageData msg, sendMsg;
|
|
67 |
RMobileUssdMessaging::TMobileUssdAttributesV1 atts, sendAtts;
|
|
68 |
RMobileUssdMessaging::TMobileUssdAttributesV1Pckg attsPckg(atts);
|
|
69 |
RMobileUssdMessaging::TMobileUssdAttributesV1Pckg sendAttsPckg(sendAtts);
|
|
70 |
|
|
71 |
// asynchronous
|
|
72 |
|
|
73 |
ussdMessaging.ReceiveMessage(reqStatus, msg, attsPckg);
|
|
74 |
User::WaitForRequest(reqStatus);
|
|
75 |
TEST(reqStatus.Int()==KErrNone);
|
|
76 |
ValidateUssdMessage(msg,atts);
|
|
77 |
|
|
78 |
// asynchronous & cancel
|
|
79 |
|
|
80 |
ussdMessaging.ReceiveMessage(reqStatus, msg, attsPckg);
|
|
81 |
ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingReceiveMessage);
|
|
82 |
User::WaitForRequest(reqStatus);
|
|
83 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
84 |
if (reqStatus.Int()==KErrCancel)
|
|
85 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::ReceiveMessage (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
86 |
else
|
|
87 |
{
|
|
88 |
ValidateUssdMessage(msg,atts);
|
|
89 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::ReceiveMessage (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
90 |
}
|
|
91 |
|
|
92 |
// Send Message
|
|
93 |
|
|
94 |
// asynchronous
|
|
95 |
|
|
96 |
sendMsg = DMMTSY_USSD_MESSAGE_PDU;
|
|
97 |
sendAtts.iFlags = DMMTSY_USSD_ATTRIBUTE_FLAGS;
|
|
98 |
sendAtts.iFormat = DMMTSY_USSD_ATTRIBUTE_FORMAT;
|
|
99 |
sendAtts.iType = DMMTSY_USSD_ATTRIBUTE_TYPE;
|
|
100 |
sendAtts.iDcs = DMMTSY_USSD_ATTRIBUTE_DCS;
|
|
101 |
|
|
102 |
ussdMessaging.SendMessage(reqStatus, sendMsg, sendAttsPckg);
|
|
103 |
User::WaitForRequest(reqStatus);
|
|
104 |
TEST(reqStatus.Int()==KErrNone);
|
|
105 |
|
|
106 |
// asynchronous & cancel
|
|
107 |
|
|
108 |
ussdMessaging.SendMessage(reqStatus, sendMsg, sendAttsPckg);
|
|
109 |
ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingSendMessage);
|
|
110 |
User::WaitForRequest(reqStatus);
|
|
111 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
112 |
if (reqStatus.Int()==KErrCancel)
|
|
113 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessage (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
114 |
else
|
|
115 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessage (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
116 |
|
77
|
117 |
sendMsg = DMMTSY_USSD_MESSAGE_PDU;
|
|
118 |
sendAtts.iFlags = DMMTSY_USSD_ATTRIBUTE_FLAGS;
|
|
119 |
sendAtts.iFormat = DMMTSY_USSD_ATTRIBUTE_FORMAT;
|
|
120 |
sendAtts.iType = DMMTSY_USSD_ATTRIBUTE_TYPE;
|
|
121 |
sendAtts.iDcs = DMMTSY_USSD_ATTRIBUTE_DCS;
|
|
122 |
|
|
123 |
ussdMessaging.SendMessage(reqStatus, sendMsg, sendAttsPckg, RMobileUssdMessaging::ETransferToDefaultHandler);
|
|
124 |
User::WaitForRequest(reqStatus);
|
|
125 |
TEST(reqStatus.Int()==KErrNone);
|
|
126 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessage /EMobileUssdMessagingSendMessageDefaultHandler/ passed"), iTestCount++);
|
|
127 |
|
|
128 |
// asynchronous & cancel
|
|
129 |
ussdMessaging.SendMessage(reqStatus, sendMsg, sendAttsPckg, RMobileUssdMessaging::ETransferToDefaultHandler);
|
|
130 |
ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingSendMessageDefaultHandler);
|
|
131 |
User::WaitForRequest(reqStatus);
|
|
132 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
133 |
if (reqStatus.Int()==KErrCancel)
|
|
134 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessage /EMobileUssdMessagingSendMessageDefaultHandler/ (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
135 |
else
|
|
136 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessage /EMobileUssdMessagingSendMessageDefaultHandler/ (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
137 |
|
24
|
138 |
// test.Next(_L("OK: RMobileUssdMessaging's Receive & Send Message"));
|
|
139 |
|
|
140 |
// Send Message NoFdnCheck
|
|
141 |
|
|
142 |
// asynchronous
|
|
143 |
|
|
144 |
sendMsg = DMMTSY_USSD_MESSAGE_PDU;
|
|
145 |
sendAtts.iFlags = DMMTSY_USSD_ATTRIBUTE_FLAGS;
|
|
146 |
sendAtts.iFormat = DMMTSY_USSD_ATTRIBUTE_FORMAT;
|
|
147 |
sendAtts.iType = DMMTSY_USSD_ATTRIBUTE_TYPE;
|
|
148 |
sendAtts.iDcs = DMMTSY_USSD_ATTRIBUTE_DCS;
|
|
149 |
|
|
150 |
ussdMessaging.SendMessageNoFdnCheck(reqStatus, sendMsg, sendAttsPckg);
|
|
151 |
User::WaitForRequest(reqStatus);
|
|
152 |
TEST(reqStatus.Int()==KErrNone);
|
|
153 |
|
|
154 |
// asynchronous & cancel
|
|
155 |
|
|
156 |
ussdMessaging.SendMessageNoFdnCheck(reqStatus, sendMsg, sendAttsPckg);
|
|
157 |
ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingSendMessageNoFdnCheck);
|
|
158 |
User::WaitForRequest(reqStatus);
|
|
159 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
160 |
if (reqStatus.Int()==KErrCancel)
|
|
161 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessageNoFdnCheck (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
162 |
else
|
|
163 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessageNoFdnCheck (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
164 |
|
|
165 |
// test.Next(_L("OK: RMobileUssdMessaging's Receive & Send Message with No Fdn Check"));
|
|
166 |
|
|
167 |
//Send Release
|
|
168 |
RMobilePhone::TMobilePhoneSendSSRequestV3 ssRequest;
|
|
169 |
RMobilePhone::TMobilePhoneSendSSRequestV3Pckg ssRequestPckg(ssRequest);
|
|
170 |
|
|
171 |
//asynchronous
|
|
172 |
|
|
173 |
ussdMessaging.SendRelease(reqStatus, ssRequestPckg);
|
|
174 |
User::WaitForRequest(reqStatus);
|
|
175 |
TEST(reqStatus.Int()==KErrNone);
|
|
176 |
TEST(ssRequest.iOpCode == DMMTSY_PHONE_NOTIFY_OPCODE);
|
|
177 |
TEST(ssRequest.iAdditionalInfo.Compare(DMMTSY_PHONE_NOTIFY_ADDINFO)==0);
|
|
178 |
|
|
179 |
// asynchronous & cancel
|
|
180 |
|
|
181 |
ussdMessaging.SendRelease(reqStatus, ssRequestPckg);
|
|
182 |
ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingSendRelease);
|
|
183 |
User::WaitForRequest(reqStatus);
|
|
184 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
185 |
if (reqStatus.Int()==KErrCancel)
|
|
186 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendRelease (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
187 |
else
|
|
188 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendRelease (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
189 |
|
|
190 |
//Notify Network Release (deprecated version)
|
|
191 |
|
|
192 |
//asynchronous
|
|
193 |
|
|
194 |
ussdMessaging.NotifyNetworkRelease(reqStatus, ssRequestPckg);
|
|
195 |
User::WaitForRequest(reqStatus);
|
|
196 |
TEST(reqStatus.Int()==KErrNone);
|
|
197 |
TEST(ssRequest.iOpCode == DMMTSY_PHONE_NOTIFY_OPCODE);
|
|
198 |
TEST(ssRequest.iAdditionalInfo.Compare(DMMTSY_PHONE_NOTIFY_ADDINFO)==0);
|
|
199 |
|
|
200 |
// asynchronous & cancel
|
|
201 |
|
|
202 |
ussdMessaging.NotifyNetworkRelease(reqStatus, ssRequestPckg);
|
|
203 |
ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingNotifyNetworkRelease);
|
|
204 |
User::WaitForRequest(reqStatus);
|
|
205 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
206 |
if (reqStatus.Int()==KErrCancel)
|
|
207 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (deprecated version) (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
208 |
else
|
|
209 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (deprecated version) (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
210 |
|
|
211 |
//Notify Network Release
|
|
212 |
|
|
213 |
//asynchronous
|
|
214 |
|
|
215 |
ussdMessaging.NotifyNetworkRelease(reqStatus, ssRequestPckg, sendAttsPckg);
|
|
216 |
User::WaitForRequest(reqStatus);
|
|
217 |
TEST(reqStatus.Int()==KErrNone);
|
|
218 |
TEST(ssRequest.iOpCode == DMMTSY_PHONE_NOTIFY_OPCODE);
|
|
219 |
TEST(ssRequest.iAdditionalInfo.Compare(DMMTSY_PHONE_NOTIFY_ADDINFO)==0);
|
|
220 |
TEST(sendAtts.iFlags == DMMTSY_USSD_ATTRIBUTE_FLAGS);
|
|
221 |
TEST(sendAtts.iFormat == DMMTSY_USSD_ATTRIBUTE_FORMAT);
|
|
222 |
TEST(sendAtts.iType == DMMTSY_USSD_ATTRIBUTE_TYPE);
|
|
223 |
TEST(sendAtts.iDcs == DMMTSY_USSD_ATTRIBUTE_DCS);
|
|
224 |
|
|
225 |
// asynchronous & cancel
|
|
226 |
|
|
227 |
ussdMessaging.NotifyNetworkRelease(reqStatus, ssRequestPckg, sendAttsPckg);
|
|
228 |
ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingNotifyNetworkRelease);
|
|
229 |
User::WaitForRequest(reqStatus);
|
|
230 |
TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel);
|
|
231 |
if (reqStatus.Int()==KErrCancel)
|
|
232 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (async & cancel (Cancelled Request)) passed"), iTestCount++);
|
|
233 |
else
|
|
234 |
INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (async & cancel (Request Not Cancelled)) passed"), iTestCount++);
|
|
235 |
|
|
236 |
ussdMessaging.Close();
|
|
237 |
mmPhone.Close();
|
|
238 |
INFO_PRINTF1(_L(""));
|
|
239 |
|
|
240 |
return TestStepResult();
|
|
241 |
}
|
|
242 |
|
|
243 |
|
|
244 |
void CTestUssdMessaging::ValidateUssdMessage(const TDesC8& aMsg, const RMobileUssdMessaging::TMobileUssdAttributesV1 &aAtts)
|
|
245 |
{
|
|
246 |
TEST(aMsg.Compare(DMMTSY_USSD_MESSAGE_PDU) == 0);
|
|
247 |
TEST(aAtts.iFlags == DMMTSY_USSD_ATTRIBUTE_FLAGS);
|
|
248 |
TEST(aAtts.iFormat == DMMTSY_USSD_ATTRIBUTE_FORMAT);
|
|
249 |
TEST(aAtts.iType == DMMTSY_USSD_ATTRIBUTE_TYPE);
|
|
250 |
TEST(aAtts.iDcs == DMMTSY_USSD_ATTRIBUTE_DCS);
|
|
251 |
}
|
|
252 |
|