|
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 |
|
117 // test.Next(_L("OK: RMobileUssdMessaging's Receive & Send Message")); |
|
118 |
|
119 // Send Message NoFdnCheck |
|
120 |
|
121 // asynchronous |
|
122 |
|
123 sendMsg = DMMTSY_USSD_MESSAGE_PDU; |
|
124 sendAtts.iFlags = DMMTSY_USSD_ATTRIBUTE_FLAGS; |
|
125 sendAtts.iFormat = DMMTSY_USSD_ATTRIBUTE_FORMAT; |
|
126 sendAtts.iType = DMMTSY_USSD_ATTRIBUTE_TYPE; |
|
127 sendAtts.iDcs = DMMTSY_USSD_ATTRIBUTE_DCS; |
|
128 |
|
129 ussdMessaging.SendMessageNoFdnCheck(reqStatus, sendMsg, sendAttsPckg); |
|
130 User::WaitForRequest(reqStatus); |
|
131 TEST(reqStatus.Int()==KErrNone); |
|
132 |
|
133 // asynchronous & cancel |
|
134 |
|
135 ussdMessaging.SendMessageNoFdnCheck(reqStatus, sendMsg, sendAttsPckg); |
|
136 ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingSendMessageNoFdnCheck); |
|
137 User::WaitForRequest(reqStatus); |
|
138 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
139 if (reqStatus.Int()==KErrCancel) |
|
140 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessageNoFdnCheck (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
141 else |
|
142 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendMessageNoFdnCheck (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
143 |
|
144 // test.Next(_L("OK: RMobileUssdMessaging's Receive & Send Message with No Fdn Check")); |
|
145 |
|
146 //Send Release |
|
147 RMobilePhone::TMobilePhoneSendSSRequestV3 ssRequest; |
|
148 RMobilePhone::TMobilePhoneSendSSRequestV3Pckg ssRequestPckg(ssRequest); |
|
149 |
|
150 //asynchronous |
|
151 |
|
152 ussdMessaging.SendRelease(reqStatus, ssRequestPckg); |
|
153 User::WaitForRequest(reqStatus); |
|
154 TEST(reqStatus.Int()==KErrNone); |
|
155 TEST(ssRequest.iOpCode == DMMTSY_PHONE_NOTIFY_OPCODE); |
|
156 TEST(ssRequest.iAdditionalInfo.Compare(DMMTSY_PHONE_NOTIFY_ADDINFO)==0); |
|
157 |
|
158 // asynchronous & cancel |
|
159 |
|
160 ussdMessaging.SendRelease(reqStatus, ssRequestPckg); |
|
161 ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingSendRelease); |
|
162 User::WaitForRequest(reqStatus); |
|
163 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
164 if (reqStatus.Int()==KErrCancel) |
|
165 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendRelease (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
166 else |
|
167 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::SendRelease (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
168 |
|
169 //Notify Network Release (deprecated version) |
|
170 |
|
171 //asynchronous |
|
172 |
|
173 ussdMessaging.NotifyNetworkRelease(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.NotifyNetworkRelease(reqStatus, ssRequestPckg); |
|
182 ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingNotifyNetworkRelease); |
|
183 User::WaitForRequest(reqStatus); |
|
184 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
185 if (reqStatus.Int()==KErrCancel) |
|
186 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (deprecated version) (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
187 else |
|
188 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (deprecated version) (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
189 |
|
190 //Notify Network Release |
|
191 |
|
192 //asynchronous |
|
193 |
|
194 ussdMessaging.NotifyNetworkRelease(reqStatus, ssRequestPckg, sendAttsPckg); |
|
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 TEST(sendAtts.iFlags == DMMTSY_USSD_ATTRIBUTE_FLAGS); |
|
200 TEST(sendAtts.iFormat == DMMTSY_USSD_ATTRIBUTE_FORMAT); |
|
201 TEST(sendAtts.iType == DMMTSY_USSD_ATTRIBUTE_TYPE); |
|
202 TEST(sendAtts.iDcs == DMMTSY_USSD_ATTRIBUTE_DCS); |
|
203 |
|
204 // asynchronous & cancel |
|
205 |
|
206 ussdMessaging.NotifyNetworkRelease(reqStatus, ssRequestPckg, sendAttsPckg); |
|
207 ussdMessaging.CancelAsyncRequest(EMobileUssdMessagingNotifyNetworkRelease); |
|
208 User::WaitForRequest(reqStatus); |
|
209 TEST(reqStatus.Int()==KErrNone || reqStatus.Int()==KErrCancel); |
|
210 if (reqStatus.Int()==KErrCancel) |
|
211 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (async & cancel (Cancelled Request)) passed"), iTestCount++); |
|
212 else |
|
213 INFO_PRINTF2(_L("Test %d - RMobileUssdMessaging::NotifyNetworkRelease (async & cancel (Request Not Cancelled)) passed"), iTestCount++); |
|
214 |
|
215 ussdMessaging.Close(); |
|
216 mmPhone.Close(); |
|
217 INFO_PRINTF1(_L("")); |
|
218 |
|
219 return TestStepResult(); |
|
220 } |
|
221 |
|
222 |
|
223 void CTestUssdMessaging::ValidateUssdMessage(const TDesC8& aMsg, const RMobileUssdMessaging::TMobileUssdAttributesV1 &aAtts) |
|
224 { |
|
225 TEST(aMsg.Compare(DMMTSY_USSD_MESSAGE_PDU) == 0); |
|
226 TEST(aAtts.iFlags == DMMTSY_USSD_ATTRIBUTE_FLAGS); |
|
227 TEST(aAtts.iFormat == DMMTSY_USSD_ATTRIBUTE_FORMAT); |
|
228 TEST(aAtts.iType == DMMTSY_USSD_ATTRIBUTE_TYPE); |
|
229 TEST(aAtts.iDcs == DMMTSY_USSD_ATTRIBUTE_DCS); |
|
230 } |
|
231 |