|
1 // Copyright (c) 2000-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 "T_smcm.h" |
|
17 |
|
18 #include <csmsaccount.h> |
|
19 |
|
20 CSmcmTest::CSmcmTest(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest) |
|
21 : CSmsTestBase(aSmsTest, aScriptFile, aNextTest) |
|
22 { |
|
23 } |
|
24 |
|
25 void CSmcmTest::RunAutoL() |
|
26 { |
|
27 iSmsTest.TestStart(++iNextTest, _L("CSmsSettings")); |
|
28 TestSettingsL(); |
|
29 iSmsTest.TestFinish(iNextTest); |
|
30 |
|
31 iSmsTest.TestStart(++iNextTest, _L("CSmsClientMtm Capabilities")); |
|
32 TestCapabilitiesL(); |
|
33 iSmsTest.TestFinish(iNextTest); |
|
34 |
|
35 iSmsTest.TestStart(++iNextTest, _L("CSmsClientMtm Global Find")); |
|
36 TestFindL(); |
|
37 iSmsTest.TestFinish(iNextTest); |
|
38 |
|
39 iSmsTest.TestStart(++iNextTest, _L("CSmsClientMtm Reply")); |
|
40 TestReplyL(); |
|
41 iSmsTest.TestFinish(iNextTest); |
|
42 |
|
43 iSmsTest.TestStart(++iNextTest, _L("CSmsClientMtm Forward")); |
|
44 TestForwardL(); |
|
45 iSmsTest.TestFinish(iNextTest); |
|
46 |
|
47 iSmsTest.TestStart(++iNextTest, _L("CSmsClientMtm Async Functions")); |
|
48 // There are no async function in sms client mtm |
|
49 iSmsTest.TestFinish(iNextTest); |
|
50 |
|
51 iSmsTest.TestStart(++iNextTest, _L("CSmsClientMtm Sync Functions")); |
|
52 TestSyncFunctionsL(); |
|
53 iSmsTest.TestFinish(iNextTest); |
|
54 } |
|
55 |
|
56 CSmcmTest::~CSmcmTest() |
|
57 { |
|
58 delete iSmsHeader; |
|
59 delete iRichText; |
|
60 delete iParaLayer; |
|
61 delete iCharLayer; |
|
62 } |
|
63 |
|
64 void CSmcmTest::ConstructL() |
|
65 { |
|
66 SetTestNameL(KSmsClientMtmTestName); |
|
67 iSmsTest.SetLogToFile(); // Lets log to a file |
|
68 iSmsTest.InstantiateClientMtmsL(); |
|
69 |
|
70 iSelection = new (ELeave) CMsvEntrySelection(); |
|
71 iTimer = CTestTimer::NewL(); |
|
72 |
|
73 iParaLayer =CParaFormatLayer::NewL(); // Rich Text for the body part of the message |
|
74 iCharLayer = CCharFormatLayer::NewL(); |
|
75 iRichText = CRichText::NewL(iParaLayer, iCharLayer, CEditableText::EFlatStorage,256); |
|
76 |
|
77 CActiveScheduler::Add(this); |
|
78 } |
|
79 |
|
80 CSmcmTest* CSmcmTest::NewLC(CSmsTestUtils& aSmsTest, const TDesC& aScriptFile, TInt& aNextTest) |
|
81 { |
|
82 CSmcmTest* self = new (ELeave) CSmcmTest(aSmsTest, aScriptFile, aNextTest); |
|
83 CleanupStack::PushL(self); |
|
84 |
|
85 self->ConstructL(); |
|
86 return self; |
|
87 } |
|
88 |
|
89 void CSmcmTest::ShowMenuL() |
|
90 { |
|
91 iSmsTest.ResetMenu(); |
|
92 |
|
93 iSmsTest.AppendToMenuL(_L("Start")); |
|
94 |
|
95 TInt result = iSmsTest.DisplayMenu(_L("SMS Client MTM Test")); |
|
96 |
|
97 if (result <= 0) |
|
98 return; |
|
99 |
|
100 switch (result) |
|
101 { |
|
102 case 1: |
|
103 RunAutoL(); |
|
104 break; |
|
105 default: |
|
106 User::Leave(KErrArgument); |
|
107 break; |
|
108 } |
|
109 |
|
110 if (!iSmsTest.RunAuto()) |
|
111 { |
|
112 iSmsTest.Printf(_L("Press any key to continue...\n")); |
|
113 iSmsTest.Test().Getch(); |
|
114 } |
|
115 |
|
116 ShowMenuL(); |
|
117 } |
|
118 |
|
119 void CSmcmTest::TestSettingsL() |
|
120 { |
|
121 iSmsTest.Printf(_L("Testing Create Settings...\n")); |
|
122 MsvEntry().SetEntryL(iSmsTest.iSmsServiceId); |
|
123 |
|
124 // Lets create sms settings (just in case it does not exist yet) |
|
125 |
|
126 CSmsSettings* settings = CSmsSettings::NewL(); |
|
127 CleanupStack::PushL(settings); |
|
128 settings->AddServiceCenterL(_L("Radiolinja0"),_L("+358508771010")); |
|
129 settings->AddServiceCenterL(_L("Radiolinja1"),_L("+358508771010")); |
|
130 settings->AddServiceCenterL(_L("Nokia"),_L("+358454400050")); |
|
131 settings->SetDefaultServiceCenter(2); |
|
132 iSmsTest(settings->DefaultServiceCenter()==2); |
|
133 settings->SetValidityPeriod(ESmsVPWeek); |
|
134 settings->SetReplyQuoted(ETrue); |
|
135 settings->SetRejectDuplicate(ETrue); |
|
136 settings->SetDelivery(ESmsDeliveryImmediately); |
|
137 settings->SetDeliveryReport(ETrue); |
|
138 settings->SetReplyPath(EFalse); |
|
139 settings->SetMessageConversion(ESmsConvPIDNone); |
|
140 settings->SetCanConcatenate(ETrue); |
|
141 settings->SetCharacterSet(TSmsDataCodingScheme::ESmsAlphabet8Bit); |
|
142 settings->SetValidityPeriodFormat(TSmsFirstOctet::ESmsVPFSemiOctet); |
|
143 settings->SetStatusReportHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
144 settings->SetSpecialMessageHandling(CSmsSettings::EMoveReportToInboxVisible); |
|
145 |
|
146 |
|
147 CSmsAccount* smsAccount = CSmsAccount::NewLC(); |
|
148 smsAccount->SaveSettingsL(*settings); |
|
149 CleanupStack::PopAndDestroy(smsAccount); |
|
150 |
|
151 |
|
152 iSmsTest.iServiceSettings->CopyL(*settings); |
|
153 CleanupStack::PopAndDestroy(); //settings |
|
154 } |
|
155 |
|
156 // Now we shall test the recipient handling, find and validate features |
|
157 |
|
158 void CSmcmTest::TestFindL() |
|
159 { |
|
160 iSmsTest.Test().Next(_L("Testing CSmsClientMtm Global Find")); |
|
161 |
|
162 // Before testing the find and validate we need a dummy message to play with |
|
163 |
|
164 TMsvPartList partList; |
|
165 TMsvId id = iSmsTest.CreateDummyMessageToSendL(); |
|
166 Client().SwitchCurrentEntryL(id); |
|
167 |
|
168 // Lets load the message we just created |
|
169 Client().LoadMessageL(); |
|
170 |
|
171 // And add some recipients |
|
172 Client().AddAddresseeL(_L("+358503367709"), _L("Mico3")); |
|
173 Client().AddAddresseeL(_L("+358503367709"), _L("Mico4")); |
|
174 Client().AddAddresseeL(_L("//\\"), _L("\n")); |
|
175 Client().AddAddresseeL(_L("\n0"), _L("^")); |
|
176 Client().AddAddresseeL(_L("1234"), _L("~¨")); |
|
177 Client().AddAddresseeL(_L("äöåÖÅÖÖ¤"), _L("fdsa4324521{[]}")); |
|
178 Client().AddAddresseeL(_L("äöåÖÅÖÖ¤"), _L("")); |
|
179 Client().AddAddresseeL(_L("äöåÖÅÖÖ¤")); |
|
180 |
|
181 // Remove Recipient |
|
182 Client().RemoveAddressee(2); |
|
183 |
|
184 // Validating Message |
|
185 partList=KMsvMessagePartRecipient; |
|
186 iSmsTest(Client().ValidateMessage(partList)); // All the addresses are not valid |
|
187 |
|
188 Client().RemoveAddressee(Client().AddresseeList().Count()-1); |
|
189 Client().RemoveAddressee(Client().AddresseeList().Count()-1); |
|
190 Client().RemoveAddressee(Client().AddresseeList().Count()-1); |
|
191 Client().RemoveAddressee(Client().AddresseeList().Count()-2); |
|
192 Client().RemoveAddressee(Client().AddresseeList().Count()-2); |
|
193 |
|
194 partList=KMsvMessagePartRecipient; // supported |
|
195 iSmsTest(!Client().ValidateMessage(partList)); |
|
196 partList=KMsvMessagePartBody; // not supported, returns 0 |
|
197 iSmsTest(!Client().ValidateMessage(partList)); |
|
198 partList=KMsvMessagePartOriginator; // not supported, returns 0 |
|
199 iSmsTest(!Client().ValidateMessage(partList)); |
|
200 partList=KMsvMessagePartDescription; // not supported, returns 0 |
|
201 iSmsTest(!Client().ValidateMessage(partList)); |
|
202 partList=KMsvMessagePartDate; // not supported, returns 0 |
|
203 iSmsTest(!Client().ValidateMessage(partList)); |
|
204 partList=KMsvMessagePartAttachments; // not supported, returns 0 |
|
205 iSmsTest(!Client().ValidateMessage(partList)); |
|
206 partList=KMsvMessagePartBody|KMsvMessagePartRecipient; |
|
207 iSmsTest(!Client().ValidateMessage(partList)); |
|
208 iSmsTest.Printf(_L("Test Validate Passed\n")); |
|
209 |
|
210 // Find in body and recipients |
|
211 Client().AddAddresseeL(_L("+358503367709"), _L("Mr. Tester")); |
|
212 partList=KMsvMessagePartRecipient; |
|
213 iSmsTest(Client().Find(_L("est"),partList)==KMsvMessagePartRecipient); |
|
214 partList=KMsvMessagePartBody; |
|
215 iSmsTest(Client().Find(_L("end"),partList)==KMsvMessagePartBody); |
|
216 partList=KMsvMessagePartOriginator; |
|
217 iSmsTest(!Client().Find(_L("end"),partList)); |
|
218 partList=KMsvMessagePartDescription; // not supported, returns 0 |
|
219 iSmsTest(!Client().Find(_L("end"),partList)); |
|
220 partList=KMsvMessagePartDate; // not supported, returns 0 |
|
221 iSmsTest(!Client().Find(_L("end"),partList)); |
|
222 partList=KMsvMessagePartAttachments; // not supported, returns 0 |
|
223 iSmsTest(!Client().Find(_L("end"),partList)); |
|
224 partList=KMsvMessagePartBody|KMsvMessagePartRecipient; |
|
225 // resultList=Client().Find(_L(""),partList); // crashes with empty string |
|
226 iSmsTest(Client().Find(_L("\n"),partList)); |
|
227 iSmsTest(Client().Find(_L("äöå"),partList)); |
|
228 iSmsTest(!Client().Find(_L("{[}]"),partList)); |
|
229 iSmsTest(!Client().Find(_L("\\"),partList)); |
|
230 iSmsTest(!Client().Find(_L("4352316542631753dfgfdgs4t6543w563vsd4"),partList)); |
|
231 iSmsTest(Client().Find(_L("~"),partList)); |
|
232 iSmsTest(Client().Find(_L(" "),partList)); |
|
233 iSmsTest(!Client().Find(_L("^"),partList)); |
|
234 iSmsTest(!Client().Find(_L(" \"dsasaf¤;¨"),partList)); |
|
235 iSmsTest(!Client().Find(_L("\\"),partList)); |
|
236 iSmsTest(!Client().Find(_L(" "),partList)); // alt+255 |
|
237 iSmsTest(Client().Find(_L("¨"),partList)); |
|
238 iSmsTest(!Client().Find(_L("/\\"),partList)); |
|
239 iSmsTest(!Client().Find(_L("\\ "),partList)); |
|
240 iSmsTest.Printf(_L("Test Find Passed\n")); |
|
241 } |
|
242 |
|
243 void CSmcmTest::TestCapabilitiesL() |
|
244 { |
|
245 // Query MTM's capabilities |
|
246 TInt response; |
|
247 iSmsTest(Client().QueryCapability(KUidMtmQueryMaxBodySize,response)==KErrNone); |
|
248 // iSmsTest(response==KSmscMaxTotalMsgSize); |
|
249 iSmsTest(Client().QueryCapability(KUidMtmQueryMaxTotalMsgSize,response)==KErrNone); |
|
250 // iSmsTest(response==KSmcmMaxMessageNumber*KSmcmMaxCharsInMessageConcatenated7Bit); |
|
251 iSmsTest(Client().QueryCapability(KUidMtmQuerySupportedBody,response)==KErrNone); |
|
252 iSmsTest(response==KMtm7BitBody + KMtm8BitBody + KMtm16BitBody); |
|
253 iSmsTest(Client().QueryCapability(KUidMtmQuerySupportAttachments,response)==KErrNotSupported); |
|
254 iSmsTest(response); |
|
255 iSmsTest(Client().QueryCapability(KUidMtmQuerySupportSubject,response)==KErrNotSupported); |
|
256 iSmsTest(response); |
|
257 iSmsTest(Client().QueryCapability(KUidMtmQuerySupportsFolder,response)==KErrNotSupported); |
|
258 iSmsTest(response); |
|
259 iSmsTest(Client().QueryCapability(KUidMtmQueryOffLineAllowed,response)==KErrNotSupported); |
|
260 iSmsTest(response); |
|
261 iSmsTest(Client().QueryCapability(KUidMtmQueryCanSendMsg,response)==KErrNone); |
|
262 iSmsTest(response); |
|
263 iSmsTest(Client().QueryCapability(KUidMtmQueryCanReceiveMsg,response)==KErrNone); |
|
264 iSmsTest(response); |
|
265 iSmsTest(Client().QueryCapability(KUidMtmQueryMaxRecipientCount,response)==KErrNone); |
|
266 iSmsTest(response==-1); |
|
267 iSmsTest(Client().QueryCapability(KUidMtmQuerySendAsRequiresRenderedImage,response)==KErrNotSupported); |
|
268 iSmsTest(response); |
|
269 iSmsTest(Client().QueryCapability(KUidMtmQuerySendAsRenderingUid,response)==KErrNotSupported); |
|
270 iSmsTest(response); |
|
271 iSmsTest(Client().QueryCapability(KUidMsvMtmQueryEditorUid,response)==KErrNone); |
|
272 iSmsTest(response==268441151); // 0x1000163f in hex form |
|
273 iSmsTest(Client().QueryCapability(KUidMsvQuerySupportsBioMsg,response)==KErrNone); |
|
274 iSmsTest(response); |
|
275 iSmsTest(Client().QueryCapability(KUidMsvQuerySupportsScheduling,response)==KErrNone); |
|
276 iSmsTest(response); |
|
277 iSmsTest(Client().QueryCapability(KUidSmcmTestNonSense,response)==KErrNotSupported); |
|
278 iSmsTest(response); |
|
279 iSmsTest.Printf(_L("Test Query Capabilities Passed\n")); |
|
280 } |
|
281 |
|
282 // Now testing replying to received messages |
|
283 void CSmcmTest::TestReplyL() |
|
284 { |
|
285 iSmsTest.Test().Next(_L("CSmsClientMtm Reply")); |
|
286 iSmsTest.Printf(_L("This test is INCOMPLETE\n")); |
|
287 |
|
288 // First we need a received message that we will reply soon |
|
289 TMsvId id = iSmsTest.CreateDummyMessageToReceiveL(); |
|
290 iSmsTest.SetEntryL(id); |
|
291 |
|
292 Client().SwitchCurrentEntryL(id); // Lets point at the received message |
|
293 Client().LoadMessageL(); |
|
294 |
|
295 TMsvPartList part=0; |
|
296 CMsvOperationWait* wait = CMsvOperationWait::NewLC(); |
|
297 CMsvOperation* op=Client().ReplyL(KMsvDraftEntryId, part, wait->iStatus); |
|
298 CleanupStack::PushL(op); |
|
299 wait->Start(); |
|
300 CActiveScheduler::Start(); |
|
301 |
|
302 TPckgBuf<TMsvId> pkg; |
|
303 pkg.Copy(op->ProgressL()); |
|
304 TMsvId progress = pkg(); |
|
305 |
|
306 CleanupStack::PopAndDestroy(2); //op, wait |
|
307 |
|
308 Client().SwitchCurrentEntryL(progress); |
|
309 Client().LoadMessageL(); |
|
310 Client().Body().InsertL(0,_L("This is reply")); |
|
311 Client().SaveMessageL(); |
|
312 } |
|
313 |
|
314 void CSmcmTest::TestForwardL() |
|
315 { |
|
316 iSmsTest.Test().Next(_L("CSmsClientMtm Forward")); |
|
317 iSmsTest.Printf(_L("This test is INCOMPLETE\n")); |
|
318 |
|
319 TMsvId id = iSmsTest.CreateDummyMessageToReceiveL(); |
|
320 Client().SwitchCurrentEntryL(id); |
|
321 Client().LoadMessageL(); |
|
322 TMsvPartList part=0; |
|
323 TRequestStatus status(0); |
|
324 CMsvOperation* op = Client().ForwardL(KMsvDraftEntryId, part, status); |
|
325 CleanupStack::PushL(op); |
|
326 |
|
327 TMsvId temp; |
|
328 TPckgC<TMsvId> paramPack(temp); |
|
329 const TDesC8& progBuf2 = op->ProgressL(); |
|
330 paramPack.Set(progBuf2); |
|
331 TMsvId progress=paramPack(); |
|
332 |
|
333 CleanupStack::PopAndDestroy(); //op |
|
334 op = NULL; |
|
335 |
|
336 Client().SwitchCurrentEntryL(progress); |
|
337 |
|
338 Client().LoadMessageL(); |
|
339 Client().Body().InsertL(0,_L("This is forward")); |
|
340 Client().AddAddresseeL(_L("+358503367709"), _L("MicoForward")); |
|
341 |
|
342 CSmsSettings* smssett = CSmsSettings::NewL(); |
|
343 CleanupStack::PushL(smssett); |
|
344 smssett->CopyL(Client().ServiceSettings()); |
|
345 CleanupStack::PopAndDestroy(); //smssett |
|
346 |
|
347 Client().SaveMessageL(); |
|
348 } |
|
349 |
|
350 void CSmcmTest::TestSyncFunctionsL() |
|
351 { |
|
352 iSmsTest.Test().Next(_L("Test CSmsClientMtm Sync Functions")); |
|
353 iSmsTest.Printf(_L("This test is INCOMPLETE\n")); |
|
354 } |