|
1 |
|
2 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 // All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Nokia Corporation - initial contribution. |
|
11 // |
|
12 // Contributors: |
|
13 // |
|
14 // Description: |
|
15 // @file |
|
16 // |
|
17 // |
|
18 |
|
19 #include "TE_R6SMSbase.h" |
|
20 #include "TE_testR6SMS.h" |
|
21 |
|
22 #include "Gsmumsg.h" |
|
23 #include "gsmumsgadditionalattributes.h" |
|
24 #include "Gsmuelem.h" |
|
25 #include "gsmuset.h" |
|
26 |
|
27 #include "EMSInformationElement.h" |
|
28 #include "EMSFormatIE.h" |
|
29 |
|
30 |
|
31 |
|
32 TVerdict CTestCSmsMessageAdditionalAttributes1::doTestStepL() |
|
33 { |
|
34 /** |
|
35 * Test 1: The class CSmsMessageAdditionalAttributes is a container class used to store |
|
36 * the CSmsMessage's new attributes so that CSmsMessage maintains Data Compatibility. |
|
37 * |
|
38 * CSmsMessageAdditionalAttributes contains a set of queues which are used to store |
|
39 * the control information elements needed by release 6 SMS. |
|
40 * |
|
41 * This test case performs the following initial tests. |
|
42 * |
|
43 * (1) Queries for the 1st entry when the queue is empty. |
|
44 * (2) Checks that an attempt to add a NULL information element can be handled (exception scenario). |
|
45 * (3) Checks that the 1st information element can be added successfully. |
|
46 * (4) Checks that a series of attempts to add information elements using invalid input parameters can be handled. |
|
47 * (5) Checks that a search for a not existent information element can be handled. |
|
48 * (6) Checks that a search can find the information element using the correct input parameters. |
|
49 * (7) Checks that a search for a second instance of the same information element returns EFalse. |
|
50 * (8) Checks that a search for a second instance of a non existent information element returns EFalse |
|
51 * (9) Gets a reference to the information element contained on the queue. |
|
52 * (10) Attempts to reference the information element at an index which is out of range. |
|
53 * (11) Attempts to index an non existent type of information element. |
|
54 * (12) Attempt to locate a non existent type of information element. |
|
55 * (13) Attempts to get reference to an invalid category of information element. |
|
56 * (14) Attempts to a get a reference to the correct category of information element but one that is out range. |
|
57 * (15) Attempts to remove the information element from the queue, but uses various combinations of invalid input parameters. |
|
58 * (16) Removes the information element using the required input parameters. |
|
59 * (17) Adds 2 new information elements to the queue |
|
60 * (18) Locates the second information element. |
|
61 * (19) Resets the class attributes |
|
62 * (20) Attempt to access an invalid type of operation - done here to get the branch coverage. |
|
63 */ |
|
64 __UHEAP_MARK; |
|
65 |
|
66 CSmsMessageAdditionalAttributes* aCollectionOfAttributes = CSmsMessageAdditionalAttributes::NewL(); |
|
67 |
|
68 CleanupStack::PushL(aCollectionOfAttributes); |
|
69 |
|
70 _LIT8(KIeData, "hi"); |
|
71 TBuf8<3> data(KIeData); |
|
72 CSmsInformationElement* aIE = CSmsInformationElement::NewL(CSmsInformationElement::ESmsIEISCSpecificUse1, KIeData); |
|
73 CleanupStack::PushL(aIE); |
|
74 |
|
75 // (1) Queries for the 1st entry when the queue is empty. |
|
76 TBool rc = ETrue; |
|
77 TUint index, startIndex = 0xFFFF; |
|
78 rc = aCollectionOfAttributes->Find1stInstanceOfControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse1, index); |
|
79 TEST(rc == EFalse); |
|
80 |
|
81 // (2) Checks that an attempt to add a NULL information element can be handled (exception scenario). |
|
82 TRAPD(err, aCollectionOfAttributes->AddControlInformationElementL(NULL)); |
|
83 TEST(err == KErrArgument); |
|
84 |
|
85 // (3) Checks that the 1st information element can be added successfully. |
|
86 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL(aIE)); |
|
87 TEST(err == KErrNone); |
|
88 CleanupStack::Pop(aIE); |
|
89 |
|
90 // (4) Checks that a series of attempts to add information elements using invalid input parameters can be handled. |
|
91 CSmsInformationElement* aIE1 = CSmsInformationElement::NewL(CSmsInformationElement::ESmsIEISCSpecificUse2, KIeData); |
|
92 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL((TSmsInformationElementCategories::TInformationElementCategory) 10, aIE1)); |
|
93 TEST(err == KErrArgument); |
|
94 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL(TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed, NULL)); |
|
95 TEST(err == KErrArgument); |
|
96 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL((TSmsInformationElementCategories::TInformationElementCategory) 10, NULL)); |
|
97 TEST(err == KErrArgument); |
|
98 |
|
99 // (5) Checks that a search for a not existent information element can be handled. |
|
100 rc = aCollectionOfAttributes->Find1stInstanceOfControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse2, index); |
|
101 TEST(rc == EFalse); |
|
102 |
|
103 // (6) Checks that a search can find the information element using the correct input parameters. |
|
104 rc = aCollectionOfAttributes->Find1stInstanceOfControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse1, index); |
|
105 TEST(rc != EFalse); |
|
106 |
|
107 // (7) Checks that a search for a second instance of the same information element returns false. |
|
108 startIndex = index; |
|
109 rc = aCollectionOfAttributes->FindNextInstanceOfControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse1, 1, index); |
|
110 TEST(rc == EFalse); |
|
111 |
|
112 // (8) Checks that a search for a second instance of a non existent information element returns false |
|
113 startIndex = 0; |
|
114 rc = aCollectionOfAttributes->FindNextInstanceOfControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse2, 0, index); |
|
115 TEST(rc == EFalse); |
|
116 |
|
117 // (9) Gets a reference to the information element contained on the queue. |
|
118 CSmsInformationElement& aIEReference = aCollectionOfAttributes->GetControlInformationElementL(CSmsInformationElement::ESmsIEISCSpecificUse1, 0); |
|
119 |
|
120 // (10) Attempts to reference the information element at an index which is out of range. |
|
121 TRAP(err,aCollectionOfAttributes->GetControlInformationElementL(CSmsInformationElement::ESmsIEISCSpecificUse1, 1)); |
|
122 TEST(err == KErrArgument); |
|
123 |
|
124 // (11) Attempts to index an non existent type of information element. |
|
125 TRAP(err,aCollectionOfAttributes->GetControlInformationElementL(CSmsInformationElement::ESmsIEISCSpecificUse2, 0)); |
|
126 TEST(err == KErrArgument); |
|
127 |
|
128 // (12) Attempt to locate a non existent type of information element. |
|
129 TRAP(err,aCollectionOfAttributes->GetControlInformationElementL((TSmsInformationElementCategories::TInformationElementCategory) 10, 0)); |
|
130 TEST(err == KErrArgument); |
|
131 |
|
132 // (13) Attempts to get reference to an invalid category of information element. |
|
133 TRAP(err,aCollectionOfAttributes->GetControlInformationElementL((TSmsInformationElementCategories::TInformationElementCategory) 0, 10)); |
|
134 TEST(err == KErrArgument); |
|
135 |
|
136 CSmsInformationElement* aInformationElement = NULL; |
|
137 CSmsInformationElement*& extractedInformationElement = aInformationElement; |
|
138 |
|
139 // (15) Attempts to remove the information element from the queue, but uses various combinations of invalid input parameters. |
|
140 rc = aCollectionOfAttributes->RemoveControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse2, startIndex, extractedInformationElement); |
|
141 TEST(rc == EFalse); |
|
142 rc = aCollectionOfAttributes->RemoveControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse1, 1, extractedInformationElement); |
|
143 TEST(rc == EFalse); |
|
144 rc = aCollectionOfAttributes->RemoveControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse2, 1, extractedInformationElement); |
|
145 TEST(rc == EFalse); |
|
146 |
|
147 // (16) Removes the information element using the required input parameters. |
|
148 aCollectionOfAttributes->RemoveControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse1, startIndex, extractedInformationElement); |
|
149 TEST(aIE == extractedInformationElement); |
|
150 |
|
151 // (17) Adds 2 new information elements to the queue |
|
152 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL(aIE)); |
|
153 TEST(err==KErrNone); |
|
154 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL(aIE1)); |
|
155 TEST(err==KErrNone); |
|
156 // (18) Locates the second information element. |
|
157 rc = aCollectionOfAttributes->FindNextInstanceOfControlInformationElement(CSmsInformationElement::ESmsIEISCSpecificUse1, 0, index); |
|
158 TEST(rc == EFalse); |
|
159 |
|
160 // (19) Resets the class attributes |
|
161 aCollectionOfAttributes->ResetAttributesL(); |
|
162 |
|
163 // (20) Attempt to access an invalid type of operation |
|
164 // Do this here to get the branch coverage |
|
165 TRAP(err,aCollectionOfAttributes->SetIEOperationL(NULL)); |
|
166 TEST(err==KErrArgument); |
|
167 |
|
168 CleanupStack::Pop(aCollectionOfAttributes); |
|
169 delete aCollectionOfAttributes; |
|
170 |
|
171 __UHEAP_MARKEND; |
|
172 |
|
173 return TestStepResult(); |
|
174 } |
|
175 |
|
176 |
|
177 TVerdict CTestCSmsMessageAdditionalAttributes2::doTestStepL() |
|
178 { |
|
179 /** |
|
180 * Test CSmsMessageAdditionalAttributes |
|
181 * |
|
182 * Test Scenario: |
|
183 * |
|
184 * Verify that 2 elements of the same type can be added to the collection, indexed and deleted. |
|
185 * |
|
186 * (1) Create 2 information elements and add to collection |
|
187 * (2) Find 1st instance |
|
188 * (3) Find 2nd instance |
|
189 * (4) Get references |
|
190 * (5) Remove and delete 1st element |
|
191 * (6) Remove and delete 2nd instance |
|
192 */ |
|
193 __UHEAP_MARK; |
|
194 |
|
195 CSmsMessageAdditionalAttributes* aCollectionOfAttributes = CSmsMessageAdditionalAttributes::NewL(); |
|
196 CleanupStack::PushL(aCollectionOfAttributes); |
|
197 |
|
198 // (1) Create 2 information elements and add to collection |
|
199 _LIT8(KIeData, "hi"); |
|
200 TBuf8<3> data(KIeData); |
|
201 CSmsInformationElement* aIE = CSmsInformationElement::NewL(CSmsInformationElement::ESmsHyperLinkFormat, KIeData); |
|
202 CleanupStack::PushL(aIE); |
|
203 TRAPD(err,aCollectionOfAttributes->AddControlInformationElementL(aIE)); |
|
204 TEST(err == KErrNone); |
|
205 CleanupStack::Pop(aIE); |
|
206 |
|
207 CSmsInformationElement* aIE1 = CSmsInformationElement::NewL(CSmsInformationElement::ESmsHyperLinkFormat, KIeData); |
|
208 CleanupStack::PushL(aIE1); |
|
209 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL(aIE1)); |
|
210 TEST(err == KErrNone); |
|
211 CleanupStack::Pop(aIE1); |
|
212 |
|
213 // (2) Find 1st instance |
|
214 TUint index, startIndex; |
|
215 TUint a2ndIndex = 0xFFFF; |
|
216 TBool found = aCollectionOfAttributes->Find1stInstanceOfControlInformationElement(CSmsInformationElement::ESmsHyperLinkFormat, index); |
|
217 TEST (found != EFalse); |
|
218 |
|
219 // (3) Find 2nd instance |
|
220 startIndex = index; |
|
221 found = aCollectionOfAttributes->FindNextInstanceOfControlInformationElement(CSmsInformationElement::ESmsHyperLinkFormat, startIndex, a2ndIndex); |
|
222 TEST (found != EFalse); |
|
223 TEST (a2ndIndex == 1); |
|
224 |
|
225 // (4) Get references |
|
226 TRAP(err, CSmsInformationElement& aIEReference = aCollectionOfAttributes->GetControlInformationElementL(CSmsInformationElement::ESmsHyperLinkFormat, startIndex)); |
|
227 TEST(err == KErrNone); |
|
228 TRAP(err, CSmsInformationElement& aIEReference1 = aCollectionOfAttributes->GetControlInformationElementL(CSmsInformationElement::ESmsHyperLinkFormat, a2ndIndex)); |
|
229 TEST(err == KErrNone); |
|
230 |
|
231 CSmsInformationElement* aInformationElement = NULL; |
|
232 CSmsInformationElement*& extractedInformationElement = aInformationElement; |
|
233 |
|
234 // (5) Remove and delete 1st element |
|
235 TBool deleted = aCollectionOfAttributes->RemoveControlInformationElement(CSmsInformationElement::ESmsHyperLinkFormat, startIndex, extractedInformationElement); |
|
236 TEST (deleted != EFalse); |
|
237 TEST (aIE == extractedInformationElement); |
|
238 |
|
239 delete aIE; |
|
240 |
|
241 // (6) Remove and delete 2nd instance |
|
242 deleted = aCollectionOfAttributes->RemoveControlInformationElement(CSmsInformationElement::ESmsHyperLinkFormat, |
|
243 --a2ndIndex, |
|
244 extractedInformationElement); |
|
245 TEST (deleted != EFalse); |
|
246 TEST (aIE1 == extractedInformationElement); |
|
247 |
|
248 delete aIE1; |
|
249 CleanupStack::Pop(aCollectionOfAttributes); |
|
250 delete aCollectionOfAttributes; |
|
251 |
|
252 __UHEAP_MARKEND; |
|
253 return TestStepResult(); |
|
254 } |
|
255 |
|
256 |
|
257 TVerdict CTestCSmsMessageAdditionalAttributes3::doTestStepL() |
|
258 { |
|
259 /** |
|
260 * Test CSmsMessageAdditionalAttributes, client facing methods. |
|
261 * |
|
262 * Verify that CSmsMessageAdditionalAttributes can handle the following requests: |
|
263 * |
|
264 * (1) the addition of 2 elements to one of its collections. |
|
265 * (2) an attempt to access information elements specifying an invalid (out of range) queue ID. |
|
266 * (3) a request to remove the control information element at back of the queue, transfering ownership to the client. |
|
267 * (4) a request to remove the control information element remaining on the queue, transfering ownership to the client. |
|
268 * (5) a request to remove a control information element from the now empty queue. |
|
269 * |
|
270 */ |
|
271 __UHEAP_MARK; |
|
272 |
|
273 CSmsMessageAdditionalAttributes* aCollectionOfAttributes = CSmsMessageAdditionalAttributes::NewL(); |
|
274 CleanupStack::PushL(aCollectionOfAttributes); |
|
275 |
|
276 // (1) Create 2 information elements and add to collection |
|
277 _LIT8(KIeData, "hi"); |
|
278 TBuf8<3> data(KIeData); |
|
279 |
|
280 CSmsInformationElement* aIE = CSmsInformationElement::NewL(CSmsInformationElement::ESmsHyperLinkFormat, KIeData); |
|
281 CleanupStack::PushL(aIE); |
|
282 TRAPD(err,aCollectionOfAttributes->AddControlInformationElementL(aIE)); |
|
283 TEST(err == KErrNone); |
|
284 CleanupStack::Pop(aIE); |
|
285 |
|
286 CSmsInformationElement* aIE1 = CSmsInformationElement::NewL(CSmsInformationElement::ESmsHyperLinkFormat, KIeData); |
|
287 CleanupStack::PushL(aIE1); |
|
288 TRAP(err,aCollectionOfAttributes->AddControlInformationElementL(aIE1)); |
|
289 TEST(err == KErrNone); |
|
290 CleanupStack::Pop(aIE1); |
|
291 |
|
292 CSmsInformationElement* IEptr = NULL; |
|
293 TBool rc; |
|
294 rc = aCollectionOfAttributes->RemoveNextControlInformationElement((TSmsInformationElementCategories::TInformationElementCategory) 10, IEptr); |
|
295 TEST(rc == EFalse); |
|
296 rc = aCollectionOfAttributes->RemoveNextControlInformationElement(TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed, IEptr); |
|
297 TEST(rc != EFalse); |
|
298 delete IEptr; |
|
299 IEptr = NULL; |
|
300 rc = aCollectionOfAttributes->RemoveNextControlInformationElement(TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed, IEptr); |
|
301 TEST(rc != EFalse); |
|
302 delete IEptr; |
|
303 IEptr = NULL; |
|
304 rc = aCollectionOfAttributes->RemoveNextControlInformationElement(TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed, IEptr); |
|
305 TEST(rc == EFalse); |
|
306 |
|
307 CleanupStack::Pop(aCollectionOfAttributes); |
|
308 delete aCollectionOfAttributes; |
|
309 |
|
310 __UHEAP_MARKEND; |
|
311 return TestStepResult(); |
|
312 } |
|
313 |
|
314 |
|
315 TVerdict CTestR6CSmsMessage::doTestStepL() |
|
316 { |
|
317 /** |
|
318 * Synopsis: Test New R6 CSmsMessage interfaces. |
|
319 * |
|
320 * Provide branch coverage. |
|
321 * |
|
322 * (1) Create all valid operations classes and one invalid operations class. |
|
323 * |
|
324 * (2) Test "Get" and "Set" methods that indicate that indicate whether |
|
325 * a particular message originated on the SIM and whether it should be forwarded |
|
326 * by the stack to its client. |
|
327 * |
|
328 */ |
|
329 RFs fs; |
|
330 User::LeaveIfError(fs.Connect()); |
|
331 |
|
332 __UHEAP_MARK; |
|
333 |
|
334 _LIT16(KName, "David Narey"); |
|
335 CSmsBuffer* buffer=CSmsBuffer::NewL(); |
|
336 buffer->InsertL(0,KName); |
|
337 |
|
338 CSmsMessage* smsMessage = CSmsMessage::NewL(fs, CSmsPDU::ESmsSubmit, buffer); |
|
339 |
|
340 TRAPD(err, smsMessage->GetOperationsForIEL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication)); |
|
341 TEST(err == KErrNone); |
|
342 TRAP(err, smsMessage->GetOperationsForIEL(CSmsInformationElement::ESmsHyperLinkFormat)); |
|
343 TEST(err == KErrNone); |
|
344 TRAP(err, smsMessage->GetOperationsForIEL(CSmsInformationElement::ESmsReplyAddressFormat)); |
|
345 TEST(err == KErrNone); |
|
346 TRAP(err, smsMessage->GetOperationsForIEL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation)); |
|
347 TEST(err == KErrNone); |
|
348 TRAP(err, smsMessage->GetOperationsForIEL(CSmsInformationElement::ESmsEnhancedextendedObjectDataRequest)); |
|
349 TEST(err == KErrArgument); |
|
350 |
|
351 smsMessage->SetDecodedOnSIM(EFalse); |
|
352 TEST(smsMessage->DecodedOnSim() == EFalse); |
|
353 smsMessage->SetDecodedOnSIM(ETrue); |
|
354 TEST(smsMessage->DecodedOnSim() != EFalse); |
|
355 smsMessage->SetForwardToClient(EFalse); |
|
356 TEST(smsMessage->ForwardToClient() == EFalse); |
|
357 smsMessage->SetForwardToClient(ETrue); |
|
358 TEST(smsMessage->ForwardToClient() != EFalse); |
|
359 |
|
360 delete smsMessage; |
|
361 |
|
362 __UHEAP_MARKEND; |
|
363 return TestStepResult(); |
|
364 } |
|
365 |
|
366 |
|
367 TVerdict CTestAddingIEsViaNewAndExistingInterfaces::doTestStepL() |
|
368 { |
|
369 /** |
|
370 * |
|
371 * Encode and Decode a Special SMS Message Indication into a single PDU |
|
372 * verifying the use of the new Special Message Waiting API and the existing |
|
373 * interface used by Special Message Waiting and other control information elements. |
|
374 */ |
|
375 RFs fs; |
|
376 User::LeaveIfError(fs.Connect()); |
|
377 |
|
378 __UHEAP_MARK; |
|
379 |
|
380 CSmsBuffer* buffer=CSmsBuffer::NewL(); |
|
381 |
|
382 CSmsMessage* message = CSmsMessage::NewL(fs, CSmsPDU::ESmsSubmit, buffer ); |
|
383 CleanupStack::PushL(message); |
|
384 |
|
385 TSmsUserDataSettings userDataSettings; |
|
386 userDataSettings.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabetUCS2); |
|
387 message->SetUserDataSettingsL(userDataSettings); |
|
388 |
|
389 // Get a handle to the user data |
|
390 CSmsPDU& submitPDU = message->SmsPDU(); |
|
391 CSmsUserData& userData = submitPDU.UserData(); |
|
392 |
|
393 // create a data field for undefined information elements. |
|
394 _LIT8(KUndefinedIE, "\xAA\xBB\xCC"); |
|
395 |
|
396 // Check that the user data interface does not support the addition of information elements whose values have not yet been defined. |
|
397 TRAPD(err,userData.AddInformationElementL((CSmsInformationElement::TSmsInformationElementIdentifier)0x21,KUndefinedIE)); |
|
398 TEST(err==KErrNotSupported); |
|
399 TRAP(err, userData.AddInformationElementL((CSmsInformationElement::TSmsInformationElementIdentifier)0x6F,KUndefinedIE)); |
|
400 TEST(err==KErrNotSupported); |
|
401 TRAP(err, userData.AddInformationElementL((CSmsInformationElement::TSmsInformationElementIdentifier)0xA0,KUndefinedIE)); |
|
402 TEST(err==KErrNotSupported); |
|
403 TRAP(err, userData.AddInformationElementL((CSmsInformationElement::TSmsInformationElementIdentifier)0xBF,KUndefinedIE)); |
|
404 TEST(err==KErrNotSupported); |
|
405 TRAP(err, userData.AddInformationElementL((CSmsInformationElement::TSmsInformationElementIdentifier)0xE0,KUndefinedIE)); |
|
406 TEST(err==KErrNotSupported); |
|
407 TRAP(err, userData.AddInformationElementL((CSmsInformationElement::TSmsInformationElementIdentifier)0xFF,KUndefinedIE)); |
|
408 TEST(err==KErrNotSupported); |
|
409 |
|
410 // add 1st special information element |
|
411 _LIT8(K1stSpecialMessageIE,"\x00\x01"); |
|
412 TRAP(err,userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication,K1stSpecialMessageIE)); |
|
413 TEST(err==KErrNone); |
|
414 // check the same special message cannot be added again |
|
415 // add 1st special information element (modified value) |
|
416 _LIT8(K1stSpecialMessageIEWithNewCount,"\x00\x02"); |
|
417 TRAP(err,userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication,K1stSpecialMessageIEWithNewCount)); |
|
418 TEST(err==KErrAlreadyExists); |
|
419 |
|
420 // add 2nd special information element |
|
421 _LIT8(K2ndSpecialMessageIE,"\x01\x03"); |
|
422 // add 3rd special information element |
|
423 _LIT8(K3rdSpecialMessageIE,"\x02\x04"); |
|
424 // add 4th special information element |
|
425 _LIT8(K4thSpecialMessageIE,"\x07\x05"); |
|
426 |
|
427 TRAP(err,userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication,K2ndSpecialMessageIE)); |
|
428 TEST(err==KErrNone); |
|
429 TRAP(err,userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication,K3rdSpecialMessageIE)); |
|
430 TEST(err==KErrNone); |
|
431 TRAP(err,userData.AddInformationElementL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication,K4thSpecialMessageIE)); |
|
432 TEST(err==KErrNone); |
|
433 |
|
434 // add mandatory information element |
|
435 _LIT8(KReplyAddress,"\x0C\x91\x53\x48\x80\x14\x55\x82"); |
|
436 CSmsInformationElement* iE = CSmsInformationElement::NewL(CSmsInformationElement::ESmsReplyAddressFormat, KReplyAddress); |
|
437 CleanupStack::PushL(iE); |
|
438 CSmsMessageAdditionalAttributes* additionalAttributes = (CSmsMessageAdditionalAttributes*) message->AdditionalInfo(); |
|
439 TRAP(err,additionalAttributes->AddControlInformationElementL(iE)); |
|
440 TEST(err==KErrNone); |
|
441 CleanupStack::Pop(iE); |
|
442 |
|
443 // Increase the branch coverage by exercising the method UpdateInformationElementArrayL() which the client cannot call directly. |
|
444 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsReplyAddressFormat, KReplyAddress)); |
|
445 TEST(err == KErrNone); |
|
446 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsReplyAddressFormat, KReplyAddress)); |
|
447 TEST(err == KErrAlreadyExists); |
|
448 TInt index = 0; |
|
449 TBool rc = userData.InformationElementIndex(CSmsInformationElement::ESmsReplyAddressFormat,index); |
|
450 TEST(rc != EFalse); |
|
451 userData.RemoveInformationElement(index); |
|
452 |
|
453 // Add a single PDU information element |
|
454 _LIT8(KEnhancedVoiceMail,"\x01\x02\x03\x04\x05\x06\x07\x08"); |
|
455 CSmsInformationElement* iE1 = CSmsInformationElement::NewL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation, KEnhancedVoiceMail); |
|
456 CleanupStack::PushL(iE1); |
|
457 TRAP(err,additionalAttributes->AddControlInformationElementL(iE1)); |
|
458 TEST(err == KErrNone); |
|
459 CleanupStack::Pop(iE1); |
|
460 |
|
461 // Increase the branch coverage by exercising the method UpdateInformationElement in ways the the client cannot do directly. |
|
462 // add single pdu information element. |
|
463 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation, KEnhancedVoiceMail)); |
|
464 TEST(err == KErrNone); |
|
465 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsEnhanceVoiceMailInformation, KEnhancedVoiceMail)); |
|
466 TEST(err == KErrAlreadyExists); |
|
467 index = 0; |
|
468 rc = userData.InformationElementIndex(CSmsInformationElement::ESmsEnhanceVoiceMailInformation,index); |
|
469 TEST(rc != EFalse); |
|
470 userData.RemoveInformationElement(index); |
|
471 |
|
472 // Increase the branch coverage by exercising the method UpdateInformationElement in ways the the client cannot do directly. |
|
473 // add email header |
|
474 _LIT8(KEmailHeader,"\x01\x02\x03\x04\x05\x06\x07\x08"); |
|
475 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsIEIRFC822EmailHeader, KEmailHeader)); |
|
476 TEST(err == KErrNone); |
|
477 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsIEIRFC822EmailHeader, KEmailHeader)); |
|
478 TEST(err == KErrAlreadyExists); |
|
479 index = 0; |
|
480 rc = userData.InformationElementIndex(CSmsInformationElement::ESmsIEIRFC822EmailHeader,index); |
|
481 TEST(rc != EFalse); |
|
482 userData.RemoveInformationElement(index); |
|
483 |
|
484 // Increase the branch coverage by exercising the method UpdateInformationElement in ways the the client cannot do directly. |
|
485 // add an information element which will be present in every PDU. |
|
486 _LIT8(KESmsIEISIMToolkitSecurityHeaders1,"\x01\x02\x03\x04\x05\x06\x07\x08"); |
|
487 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsIEISIMToolkitSecurityHeaders1, KESmsIEISIMToolkitSecurityHeaders1)); |
|
488 TEST(err == KErrNone); |
|
489 TRAP(err,userData.UpdateInformationElementArrayL(CSmsInformationElement::ESmsIEISIMToolkitSecurityHeaders1, KESmsIEISIMToolkitSecurityHeaders1)); |
|
490 TEST(err == KErrAlreadyExists); |
|
491 index = 0; |
|
492 rc = userData.InformationElementIndex(CSmsInformationElement::ESmsIEISIMToolkitSecurityHeaders1,index); |
|
493 TEST(rc != EFalse); |
|
494 userData.RemoveInformationElement(index); |
|
495 |
|
496 // Test adding 17 Multi PDU Hyper Links |
|
497 |
|
498 for (TUint i = 0; i < 17; i++) |
|
499 { |
|
500 _LIT8(KBinaryTestData,"\x00\x00\x0F\x0E"); |
|
501 CSmsInformationElement* iE = CSmsInformationElement::NewL(CSmsInformationElement::ESmsHyperLinkFormat, KBinaryTestData); |
|
502 CleanupStack::PushL(iE); |
|
503 CSmsMessageAdditionalAttributes* additionalAttributes1 = (CSmsMessageAdditionalAttributes*) message->AdditionalInfo(); |
|
504 TRAP(err,additionalAttributes1->AddControlInformationElementL(iE)); |
|
505 TEST(err == KErrNone); |
|
506 CleanupStack::Pop(iE); |
|
507 } |
|
508 |
|
509 CArrayFixFlat<TGsmSms>* smsArray=new(ELeave) CArrayFixFlat<TGsmSms>(8); |
|
510 |
|
511 TRAP(err,rc = message->EncodeIntoSinglePDUL(*smsArray)); |
|
512 TEST(err == KErrNone); |
|
513 TEST(rc != EFalse); |
|
514 |
|
515 CleanupStack::Pop(message); |
|
516 delete message; |
|
517 |
|
518 // now decode the message and check the information elements returned. |
|
519 CSmsBuffer* receiveBuffer = CSmsBuffer::NewL(); |
|
520 TGsmSms& sms = smsArray->operator[](0); |
|
521 |
|
522 CSmsMessage* decodedMessage = CSmsMessage::NewL(fs, sms, receiveBuffer, EFalse, EFalse); |
|
523 CleanupStack::PushL(decodedMessage); |
|
524 |
|
525 CSmsMessageAdditionalAttributes* additionalDecodedAttributes = (CSmsMessageAdditionalAttributes*) decodedMessage->AdditionalInfo(); |
|
526 |
|
527 TUint numberOfElementsMandatoryIn1stPDU = additionalDecodedAttributes->NumberOfControlInformationElements(TSmsInformationElementCategories::ECtrlMandatoryIn1stPDUOnly); |
|
528 TEST(numberOfElementsMandatoryIn1stPDU==1); |
|
529 |
|
530 TUint numberOfSingleInstanceElement = additionalDecodedAttributes->NumberOfControlInformationElements(TSmsInformationElementCategories::ECtrlSingleInstanceOnly); |
|
531 TEST(numberOfSingleInstanceElement==1); |
|
532 |
|
533 TUint numberOfMultipleInstanceElements = additionalDecodedAttributes->NumberOfControlInformationElements(TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed); |
|
534 TEST(numberOfMultipleInstanceElements==17); |
|
535 |
|
536 CSmsPDU& decodedSubmitPDU = decodedMessage->SmsPDU(); |
|
537 CSmsUserData& decodedUserData = decodedSubmitPDU.UserData(); |
|
538 |
|
539 CArrayFixFlat<TInt>* indices = new(ELeave) CArrayFixFlat<TInt>(8); |
|
540 |
|
541 TRAP(err, decodedUserData.InformationElementIndicesL(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, *indices)); |
|
542 TEST(err == KErrNone); |
|
543 TESTL(indices->Count() == 4); |
|
544 |
|
545 for (TUint8 i = 0; i < 4; i++) |
|
546 { |
|
547 CSmsInformationElement*& specialSMSI1 = decodedUserData.InformationElementPtr(indices->operator[](i)); |
|
548 } |
|
549 |
|
550 delete indices; |
|
551 |
|
552 CleanupStack::Pop(decodedMessage); |
|
553 delete decodedMessage; |
|
554 |
|
555 delete smsArray; |
|
556 |
|
557 __UHEAP_MARKEND; |
|
558 return TestStepResult(); |
|
559 } |
|
560 |
|
561 |
|
562 TVerdict CTestIECategoryDefinitions::doTestStepL() |
|
563 { |
|
564 /** |
|
565 * Synopsis: |
|
566 * |
|
567 * Test that each type of information element can be mapped to its correct category |
|
568 * using the utility mehtod TSmsInformationElementCategories::GetCategoryDefinition(); |
|
569 * |
|
570 */ |
|
571 TSmsInformationElementCategories::TInformationElementCategory category; |
|
572 |
|
573 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsIEIConcatenatedShortMessages8BitReference, category)); |
|
574 TEST(category==TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU ); |
|
575 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsIEIConcatenatedShortMessages16BitReference, category)); |
|
576 TEST(category==TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU ); |
|
577 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsIEISMSCControlParameters, category)); |
|
578 TEST(category==TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU ); |
|
579 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsIEIRFC822EmailHeader, category)); |
|
580 TEST(category==TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUButWithValueSpecificToPDU ); |
|
581 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsIEISpecialSMSMessageIndication, category)); |
|
582 TEST(category== TSmsInformationElementCategories::ECtrlMandatoryInEveryPDUMultipleInstancesPerPDU ); |
|
583 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsHyperLinkFormat, category)); |
|
584 TEST(category==TSmsInformationElementCategories::ECtrlMultipleInstancesAllowed ); |
|
585 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsReplyAddressFormat, category)); |
|
586 TEST(category==TSmsInformationElementCategories::ECtrlMandatoryIn1stPDUOnly ); |
|
587 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedPredefinedSound, category)); |
|
588 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
589 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedUserDefinedSound, category)); |
|
590 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
591 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedPredefinedAnimation, category)); |
|
592 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
593 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedLargeAnimation, category)); |
|
594 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
595 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedSmallAnimation, category)); |
|
596 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
597 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedVariablePicture, category)); |
|
598 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
599 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedUserPromptIndicator, category)); |
|
600 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
601 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedExtendedObject, category)); |
|
602 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
603 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedReusedExtendedObject, category)); |
|
604 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
605 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedCompressionControl, category)); |
|
606 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
607 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedODI, category)); |
|
608 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
609 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedStandardWVG, category)); |
|
610 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
611 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedCharacterSizeWVG, category)); |
|
612 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
613 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsEnhancedextendedObjectDataRequest, category)); |
|
614 TEST(category==TSmsInformationElementCategories::EEmsInformationElement ); |
|
615 |
|
616 // |
|
617 // Some invalid categories... |
|
618 // |
|
619 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::ESmsIEIReserved, category) == EFalse); |
|
620 TEST(TSmsInformationElementCategories::GetCategoryDefinition(CSmsInformationElement::TSmsInformationElementIdentifier(9999), category) == EFalse); |
|
621 |
|
622 return TestStepResult(); |
|
623 } |
|
624 |
|
625 |
|
626 TVerdict CTestR6DCS::doTestStepL() |
|
627 /** |
|
628 * |
|
629 * Test the Data coding scheme bytes can be correctly configured |
|
630 * when R6 automatic deletion feature is active. |
|
631 */ |
|
632 { |
|
633 TSmsDataCodingScheme dataCodingScheme; |
|
634 dataCodingScheme.SetBits7To4((TSmsDataCodingScheme::TSmsDCSBits7To4)0x40); |
|
635 |
|
636 // Turn on compression |
|
637 TEST(dataCodingScheme.TextCompressed() == EFalse); |
|
638 dataCodingScheme.SetTextCompressed(ETrue); |
|
639 TEST(dataCodingScheme.TextCompressed() != EFalse); |
|
640 |
|
641 // Test switching from 7 bit to 8 bit encoding. |
|
642 TEST(dataCodingScheme.Alphabet() == TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
643 dataCodingScheme.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
644 TEST(dataCodingScheme.Alphabet() == TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
645 |
|
646 // Test switching on and off class |
|
647 dataCodingScheme.SetClass(ETrue,(TSmsDataCodingScheme::TSmsClass) 1); |
|
648 TSmsDataCodingScheme::TSmsClass testClass; |
|
649 dataCodingScheme.Class(testClass); |
|
650 TEST(testClass == (TSmsDataCodingScheme::TSmsClass) 1); |
|
651 dataCodingScheme.SetClass(ETrue,(TSmsDataCodingScheme::TSmsClass) 2); |
|
652 dataCodingScheme.Class(testClass); |
|
653 TEST(testClass == (TSmsDataCodingScheme::TSmsClass) 2); |
|
654 |
|
655 // Turn off compression |
|
656 dataCodingScheme.SetTextCompressed(EFalse); |
|
657 TEST(dataCodingScheme.TextCompressed() == EFalse); |
|
658 |
|
659 // Switch from 8 bit to 7 bit encoding |
|
660 // Test switching from 7 bit to 8 bit encoding. |
|
661 TEST(dataCodingScheme.Alphabet() == TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
662 dataCodingScheme.SetAlphabet(TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
663 TEST(dataCodingScheme.Alphabet() == TSmsDataCodingScheme::ESmsAlphabet7Bit); |
|
664 |
|
665 // Test data coding scheme class |
|
666 dataCodingScheme.Class(testClass); |
|
667 TEST(testClass == (TSmsDataCodingScheme::TSmsClass) 2); |
|
668 dataCodingScheme.Class(testClass); |
|
669 TEST(testClass == (TSmsDataCodingScheme::TSmsClass) 2); |
|
670 |
|
671 return TestStepResult(); |
|
672 } |