|
1 // Copyright (c) 1999-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 "emailsmokecommands.h" |
|
17 |
|
18 #ifndef _NO_IAP_PREFS |
|
19 #include <iapprefs.h> |
|
20 #endif |
|
21 |
|
22 _LIT(K_T_MSG_STRUCT_FILE, "c:\\logs\\email\\Entry_Structure.txt"); |
|
23 _LIT(KCountText, "[%4d] Children of '%S' counted -\n\t\t\t Services: %4d, Folders: %4d, Messages: %4d, Attachments: %4d\n"); |
|
24 _LIT(KErrService, "[%4d] Error! No service has been created or used!"); |
|
25 _LIT(KErrSelectText, "Error! Cannot find entry '%S'.\n"); |
|
26 |
|
27 const TInt KDefaultWaitTime = 5000000; |
|
28 |
|
29 const TInt KNoBodyText = -1; |
|
30 |
|
31 class TLineReader : public CBase |
|
32 { |
|
33 private: |
|
34 RFile& iFile; |
|
35 TBuf8<512> iBuffer; |
|
36 TInt iBufferIndex; |
|
37 |
|
38 TBool Peek(char& rChar) |
|
39 { |
|
40 TBool characterFound = ETrue; |
|
41 if (iBufferIndex == iBuffer.Size()) |
|
42 { |
|
43 // Refresh buffer |
|
44 TInt readError = iFile.Read(iBuffer); |
|
45 iBufferIndex = 0; |
|
46 if ((readError != KErrNone) || (iBuffer.Size() == 0)) |
|
47 { |
|
48 characterFound = EFalse; |
|
49 } |
|
50 } |
|
51 |
|
52 if (characterFound) |
|
53 { |
|
54 rChar = iBuffer[iBufferIndex]; |
|
55 } |
|
56 |
|
57 return characterFound; |
|
58 }; |
|
59 |
|
60 TBool GetCharacter(char& rChar) |
|
61 { |
|
62 TBool characterFound = Peek(rChar); |
|
63 if (characterFound) |
|
64 { |
|
65 iBufferIndex++; |
|
66 } |
|
67 |
|
68 return characterFound; |
|
69 } |
|
70 |
|
71 public: |
|
72 TLineReader(RFile& rFile) : iFile(rFile), iBufferIndex(0) |
|
73 {}; |
|
74 |
|
75 HBufC8* GetLineLC() |
|
76 { |
|
77 // Find next cr or lf (and ignore subsequent cr's or lf's) |
|
78 HBufC8* newLine = HBufC8::NewLC(512); |
|
79 |
|
80 char ch; |
|
81 |
|
82 TBool characterFound = GetCharacter(ch); |
|
83 TBool eolFound = EFalse; |
|
84 |
|
85 while ((characterFound) && (!eolFound)) |
|
86 { |
|
87 if ((ch == 0x0d) || (ch == 0x0a)) |
|
88 // cr or lf found, ignore subsequent cr and lf's |
|
89 { |
|
90 eolFound = ETrue; |
|
91 while ((characterFound) && ((ch == 0x0d) || (ch == 0x0a))) |
|
92 { |
|
93 characterFound = Peek(ch); |
|
94 if ((characterFound) && ((ch == 0x0d) || (ch == 0x0a))) |
|
95 { |
|
96 characterFound = GetCharacter(ch); |
|
97 } |
|
98 } |
|
99 } |
|
100 |
|
101 if ((characterFound) && (!eolFound)) |
|
102 { |
|
103 newLine->Des().Append(ch); |
|
104 characterFound = GetCharacter(ch); |
|
105 } |
|
106 } |
|
107 |
|
108 return newLine; |
|
109 }; |
|
110 }; |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 // |
|
116 // |
|
117 // CMsvTestCleanMessageFolder |
|
118 // |
|
119 |
|
120 void CCleanMessageFolder::StartL(TRequestStatus& aStatus) |
|
121 { |
|
122 TInt err=KErrNone; |
|
123 TRAP(err, iTestUtils.CleanMessageFolderL()); |
|
124 TRAP(err,iTestUtils.ClearEmailAccountsL()); |
|
125 TRequestStatus* status = &aStatus; |
|
126 User::RequestComplete(status, err); |
|
127 } |
|
128 |
|
129 CCleanMessageFolder::CCleanMessageFolder(CEmailTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
130 { |
|
131 } |
|
132 |
|
133 |
|
134 // |
|
135 // |
|
136 // CDumpMailStore |
|
137 // |
|
138 |
|
139 void CDumpMailStore::StartL(TRequestStatus& aStatus) |
|
140 { |
|
141 TFileName filepath(iPath); |
|
142 filepath.Insert(0, _L("dump\\")); |
|
143 TParse parsedFileName; |
|
144 iTestUtils.ResolveLogFile(filepath, parsedFileName); |
|
145 |
|
146 // Clean up any existing logs |
|
147 CFileMan* fileMan = CFileMan::NewL(iTestUtils.FileSession()); |
|
148 CleanupStack::PushL(fileMan); |
|
149 TInt err = fileMan->RmDir(parsedFileName.FullName()); |
|
150 |
|
151 if(err == KErrNone || err == KErrNotFound) |
|
152 { |
|
153 iTestUtils.ResolveLogFile(filepath, parsedFileName); // create logs dir again |
|
154 TRAP(err, iTestUtils.FindChildrenL(KMsvRootIndexEntryId, parsedFileName.FullName())); |
|
155 } |
|
156 |
|
157 CleanupStack::PopAndDestroy(); // fileman |
|
158 TRequestStatus* status = &aStatus; |
|
159 User::RequestComplete(status, err); |
|
160 } |
|
161 |
|
162 CDumpMailStore::CDumpMailStore(CEmailTestUtils& aTestUtils, const TDesC& aPath) : iTestUtils(aTestUtils) |
|
163 { |
|
164 iPath = aPath; |
|
165 } |
|
166 |
|
167 |
|
168 // |
|
169 // |
|
170 // CCompareFiles |
|
171 // |
|
172 // Compares two files passed in as arguments, the first residing in \MsgLogs\t_email\dump\ and the second |
|
173 // residing in \msgtest\emailsmoke\reference\ . |
|
174 |
|
175 void CCompareFiles::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
176 { |
|
177 // Build parameter list. |
|
178 VA_LIST list; |
|
179 VA_START(list, format); |
|
180 TBuf<0x100> buf; |
|
181 buf.FormatList(format, list); |
|
182 |
|
183 // Log the debug buffer. |
|
184 iTestUtils.WriteComment(buf); |
|
185 } |
|
186 |
|
187 |
|
188 void CCompareFiles::StartL(TRequestStatus& aStatus) |
|
189 { |
|
190 TInt err=KErrNone; |
|
191 |
|
192 RFileReadStream file1; |
|
193 RFileReadStream file2; |
|
194 HBufC8* line1Buffer = HBufC8::NewLC(1024); |
|
195 TPtr8 line1 = line1Buffer->Des(); |
|
196 TBuf8<1> aChar1; |
|
197 |
|
198 HBufC8* line2Buffer = HBufC8::NewLC(1024); |
|
199 TPtr8 line2 = line2Buffer->Des(); |
|
200 TBuf8<1> aChar2; |
|
201 |
|
202 // Generate the file names, first the result file and then the reference file. |
|
203 |
|
204 TFileName file1Name(iPath1); |
|
205 file1Name.Insert(0, _L("dump\\")); |
|
206 TParse parsedFileName1; |
|
207 iTestUtils.ResolveLogFile(file1Name, parsedFileName1); |
|
208 |
|
209 |
|
210 TFileName file2Name(iPath2); |
|
211 TParse parsedFileName2; |
|
212 iTestUtils.ResolveFile(_L("emailsmoke\\reference"), file2Name, parsedFileName2); |
|
213 |
|
214 TInt error1=KErrNone; |
|
215 TInt error2=KErrNone; |
|
216 |
|
217 error1=file1.Open(iTestUtils.FileSession(), parsedFileName1.FullName(), EFileShareAny); |
|
218 if(error1!=KErrNone) |
|
219 { |
|
220 LogCommentFormat( _L("\nERROR %d opening file %s"), error1, file1Name); |
|
221 err = KErrUnknown; |
|
222 } |
|
223 else |
|
224 { |
|
225 error2=file2.Open(iTestUtils.FileSession(), parsedFileName2.FullName(), EFileShareAny); |
|
226 if(error2!=KErrNone) |
|
227 { |
|
228 LogCommentFormat( _L("\nERROR %d opening file %s"), error2, file2Name); |
|
229 err = KErrUnknown; |
|
230 } |
|
231 else |
|
232 LogCommentFormat( _L("\nFiles open")); |
|
233 } |
|
234 |
|
235 if((error1==KErrNone)&&(error2==KErrNone)) |
|
236 { |
|
237 // read the file into the conversion object |
|
238 TInt file1LineCounter = 0; |
|
239 |
|
240 TBool finished = EFalse; |
|
241 |
|
242 do { |
|
243 line1.FillZ(); |
|
244 line1.SetLength(0); |
|
245 // compile the lines one char at a time |
|
246 do { |
|
247 TRAPD( error, file1.ReadL(aChar1, 1) ); |
|
248 if (error!=KErrEof) |
|
249 line1.Append(aChar1); |
|
250 else |
|
251 { |
|
252 finished = ETrue; |
|
253 break; |
|
254 } |
|
255 // stop at the end of line or no more data |
|
256 } |
|
257 while((aChar1[0]!=0x0A)&&(line1.Length()<1024)); |
|
258 |
|
259 line2.FillZ(); |
|
260 line2.SetLength(0); |
|
261 do { |
|
262 TRAPD( error, file2.ReadL(aChar2, 1) ); |
|
263 if (error!=KErrEof) |
|
264 line2.Append(aChar2); |
|
265 else |
|
266 { |
|
267 finished = ETrue; |
|
268 break; |
|
269 } |
|
270 // stop at the end of line or no more data |
|
271 } |
|
272 while((aChar2[0]!=0x0A)&&(line2.Length()<1024)); |
|
273 |
|
274 if(!finished) |
|
275 { |
|
276 line1.TrimRight(); |
|
277 line2.TrimRight(); |
|
278 |
|
279 if(aChar1[0]==0x0A) |
|
280 file1LineCounter++; |
|
281 |
|
282 if(line1.Compare(line2)) |
|
283 { |
|
284 LogCommentFormat(_L("\nERROR - Line %d is different "), file1LineCounter); |
|
285 err = KErrUnknown; |
|
286 } |
|
287 } |
|
288 } |
|
289 while(!finished); |
|
290 } |
|
291 |
|
292 file1.Close(); |
|
293 file2.Close(); |
|
294 |
|
295 CleanupStack::PopAndDestroy(2); //line 1 , line 2 |
|
296 |
|
297 TRequestStatus* status = &aStatus; |
|
298 User::RequestComplete(status, err); |
|
299 |
|
300 } |
|
301 |
|
302 CCompareFiles::CCompareFiles(CMsvTestUtils& aTestUtils, const TDesC& aPath1, const TDesC& aPath2) : iTestUtils(aTestUtils) |
|
303 { |
|
304 iPath1 = aPath1; |
|
305 iPath2 = aPath2; |
|
306 } |
|
307 |
|
308 |
|
309 // |
|
310 // |
|
311 // CDumpToFile |
|
312 // |
|
313 |
|
314 void CDumpToFile::WriteToFileL(RFile& aFile, const TDesC& aInputLine) |
|
315 { |
|
316 HBufC8* pOutputLine = HBufC8::NewLC(aInputLine.Length()*2); |
|
317 TPtr8 pOutput = pOutputLine->Des(); |
|
318 pOutput.Zero(); |
|
319 |
|
320 TUint lowChar; |
|
321 TUint highChar; |
|
322 TInt i=0; |
|
323 |
|
324 while(i<aInputLine.Length()) |
|
325 { |
|
326 lowChar=((TUint)aInputLine[i])&0x00FF; |
|
327 pOutput.Append(lowChar); |
|
328 highChar=((TUint)aInputLine[i++])&0xFF00; |
|
329 pOutput.Append(highChar); |
|
330 } |
|
331 |
|
332 aFile.Write(pOutput); |
|
333 CleanupStack::PopAndDestroy(); // pBodyText |
|
334 } |
|
335 |
|
336 |
|
337 |
|
338 // |
|
339 // |
|
340 // CDumpBodyText |
|
341 // |
|
342 |
|
343 void CDumpBodyText::StartL(TRequestStatus& aStatus) |
|
344 { |
|
345 TInt err = KErrNone; |
|
346 TFileName filepath(iPath); |
|
347 filepath.Insert(0, _L("dump\\")); |
|
348 TParse parsedFileName; |
|
349 iTestUtils.ResolveLogFile(filepath, parsedFileName); |
|
350 |
|
351 // delete any previous logs |
|
352 err = iTestUtils.FileSession().Delete(parsedFileName.FullName()); |
|
353 |
|
354 if(err == KErrNone || err == KErrNotFound) |
|
355 { |
|
356 RFile file; |
|
357 err = file.Replace(iTestUtils.FileSession(), parsedFileName.FullName(), EFileShareAny | EFileStreamText | EFileWrite); |
|
358 if(err == KErrNone) |
|
359 { |
|
360 TInt offset=0; |
|
361 err = file.Seek(ESeekEnd, offset); |
|
362 |
|
363 if (err == KErrNone) |
|
364 { |
|
365 TInt numEmails = iSelection.Count(); |
|
366 TMsvId entryId; |
|
367 |
|
368 // dump the contents of every message in the selection to the file |
|
369 for(TInt i=0; i<numEmails; i++) |
|
370 { |
|
371 entryId = iSelection.At(i); |
|
372 DumpBodyTextToFileL(file, entryId); |
|
373 } |
|
374 } |
|
375 file.Close(); |
|
376 } |
|
377 } |
|
378 |
|
379 TRequestStatus* status = &aStatus; |
|
380 User::RequestComplete(status, err); |
|
381 } |
|
382 |
|
383 void CDumpBodyText::DumpBodyTextToFileL(RFile& aFile, TMsvId& aEntryId) |
|
384 { |
|
385 TBuf<100> buf; |
|
386 CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL(); |
|
387 CleanupStack::PushL(paraFormatLayer); |
|
388 |
|
389 CCharFormatLayer* charFormatLayer=CCharFormatLayer::NewL(); |
|
390 CleanupStack::PushL(charFormatLayer); |
|
391 |
|
392 CRichText* bodyText=CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256); |
|
393 CleanupStack::PushL(bodyText); |
|
394 |
|
395 CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(iTestUtils.iMsvEntry)); |
|
396 imEmailMessage->GetBodyTextL(aEntryId, CImEmailMessage::EThisMessageOnly, *bodyText, *paraFormatLayer, *charFormatLayer); |
|
397 |
|
398 HBufC* pBodyText = HBufC::NewLC(bodyText->DocumentLength()+(bodyText->DocumentLength()/70)+1); |
|
399 TPtr pBody = pBodyText->Des(); |
|
400 bodyText->Extract(pBody, 0); |
|
401 |
|
402 buf.Zero(); |
|
403 //buf.AppendFormat(_L("*** %d *************** RichText Data ***************\n"), aEntryId); |
|
404 buf.AppendFormat(_L("************************** RichText Data ***************\n")); |
|
405 buf.AppendFormat(_L("Size >>> %d\n"), bodyText->DocumentLength()); |
|
406 WriteToFileL(aFile, buf); |
|
407 |
|
408 RemoveRichtextFormating(pBody); |
|
409 WriteToFileL(aFile, pBody); |
|
410 |
|
411 buf.Zero(); |
|
412 buf.AppendFormat(_L("\n********************* end of Body ***********************\n")); |
|
413 WriteToFileL(aFile, buf); |
|
414 |
|
415 CleanupStack::PopAndDestroy(); // pBodyText |
|
416 CleanupStack::PopAndDestroy(); // imEmailMessage |
|
417 CleanupStack::PopAndDestroy(3); // bodyText, charFormatLayer, paraFormatLayer |
|
418 } |
|
419 |
|
420 CDumpBodyText::CDumpBodyText(CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils, const TDesC& aPath) : |
|
421 iSelection(aSelection), |
|
422 iTestUtils(aTestUtils) |
|
423 { |
|
424 iPath = aPath; |
|
425 } |
|
426 |
|
427 void CDumpBodyText::RemoveRichtextFormating(TDes& aSourceLine) |
|
428 { |
|
429 TUint8* ptr = (TUint8*)aSourceLine.Ptr(); |
|
430 TUint8* start = ptr; |
|
431 |
|
432 TInt totalLength = aSourceLine.Length()*2; |
|
433 do { |
|
434 if(*ptr==CEditableText::EParagraphDelimiter || *ptr==CEditableText::ELineBreak || *ptr==CEditableText::EPageBreak) |
|
435 *ptr=0x0A; |
|
436 } while((++ptr-start)<totalLength); |
|
437 } |
|
438 |
|
439 |
|
440 // |
|
441 // |
|
442 // CGetAttachmentNames |
|
443 // |
|
444 |
|
445 void CGetAttachmentNames::StartL(TRequestStatus& aStatus) |
|
446 { |
|
447 TInt err = KErrNone; |
|
448 TFileName filepath(iPath); |
|
449 filepath.Insert(0, _L("dump\\")); |
|
450 TParse parsedFileName; |
|
451 iTestUtils.ResolveLogFile(filepath, parsedFileName); |
|
452 |
|
453 // delete any previous logs |
|
454 err = iTestUtils.FileSession().Delete(parsedFileName.FullName()); |
|
455 |
|
456 if(err == KErrNone || err == KErrNotFound) |
|
457 { |
|
458 RFile file; |
|
459 err = file.Replace(iTestUtils.FileSession(), parsedFileName.FullName(), EFileShareAny | EFileStreamText | EFileWrite); |
|
460 if(err == KErrNone) |
|
461 { |
|
462 TInt offset=0; |
|
463 err = file.Seek(ESeekEnd, offset); |
|
464 |
|
465 if (err == KErrNone) |
|
466 { |
|
467 TInt numEmails = iSelection.Count(); |
|
468 TMsvId entryId; |
|
469 |
|
470 // dump the attachment names of every message in the selection to the file |
|
471 for(TInt i=0; i<numEmails; i++) |
|
472 { |
|
473 entryId = iSelection.At(i); |
|
474 DumpAttachmentNamesToFileL(file, entryId); |
|
475 } |
|
476 } |
|
477 file.Close(); |
|
478 } |
|
479 } |
|
480 |
|
481 TRequestStatus* status = &aStatus; |
|
482 User::RequestComplete(status, err); |
|
483 } |
|
484 |
|
485 void CGetAttachmentNames::DumpAttachmentNamesToFileL(RFile& aFile, TMsvId& aEntryId) |
|
486 { |
|
487 TBuf<100> buf; |
|
488 |
|
489 CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(iTestUtils.iMsvEntry)); |
|
490 imEmailMessage->GetAttachmentsListL(aEntryId, CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly); |
|
491 |
|
492 TPtrC attachName(KNullDesC); |
|
493 |
|
494 MMsvAttachmentManager& manager = imEmailMessage->AttachmentManager(); |
|
495 |
|
496 for(TInt i =0; i<manager.AttachmentCount(); i++) |
|
497 { |
|
498 CMsvAttachment* attachmentInfo = manager.GetAttachmentInfoL(i); |
|
499 CleanupStack::PushL(attachmentInfo); |
|
500 |
|
501 attachName.Set(attachmentInfo->AttachmentName()); |
|
502 WriteToFileL(aFile, attachName); |
|
503 buf.Zero(); |
|
504 buf.AppendFormat(_L("\n")); |
|
505 WriteToFileL(aFile, buf); |
|
506 |
|
507 CleanupStack::PopAndDestroy(attachmentInfo); |
|
508 } |
|
509 |
|
510 CleanupStack::PopAndDestroy(imEmailMessage); // imEmailMessage |
|
511 } |
|
512 |
|
513 CGetAttachmentNames::CGetAttachmentNames(CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils, const TDesC& aPath) : |
|
514 iSelection(aSelection), |
|
515 iTestUtils(aTestUtils) |
|
516 { |
|
517 iPath = aPath; |
|
518 } |
|
519 |
|
520 |
|
521 // |
|
522 // |
|
523 // CDumpHeaderFields |
|
524 // |
|
525 |
|
526 void CDumpHeaderFields::StartL(TRequestStatus& aStatus) |
|
527 { |
|
528 TInt err = KErrNone; |
|
529 TFileName filepath(iPath); |
|
530 filepath.Insert(0, _L("dump\\")); |
|
531 TParse parsedFileName; |
|
532 iTestUtils.ResolveLogFile(filepath, parsedFileName); |
|
533 |
|
534 // delete any previous logs |
|
535 err = iTestUtils.FileSession().Delete(parsedFileName.FullName()); |
|
536 |
|
537 if(err == KErrNone || err == KErrNotFound) |
|
538 { |
|
539 RFile file; |
|
540 err = file.Replace(iTestUtils.FileSession(), parsedFileName.FullName(), EFileShareAny | EFileStreamText | EFileWrite); |
|
541 if(err == KErrNone) |
|
542 { |
|
543 TInt offset=0; |
|
544 err = file.Seek(ESeekEnd, offset); |
|
545 |
|
546 if (err == KErrNone) |
|
547 { |
|
548 TInt numEmails = iSelection.Count(); |
|
549 TMsvId entryId; |
|
550 |
|
551 // dump the header fields of every message in the selection to the file |
|
552 for(TInt i=0; i<numEmails; i++) |
|
553 { |
|
554 entryId = iSelection.At(i); |
|
555 DumpHeaderFieldsToFileL(file, entryId); |
|
556 } |
|
557 } |
|
558 file.Close(); |
|
559 } |
|
560 } |
|
561 |
|
562 TRequestStatus* status = &aStatus; |
|
563 User::RequestComplete(status, err); |
|
564 } |
|
565 |
|
566 void CDumpHeaderFields::DumpHeaderFieldsToFileL(RFile& aFile, TMsvId& aEntryId) |
|
567 { |
|
568 TInt i; |
|
569 |
|
570 iTestUtils.iMsvEntry->SetEntryL(aEntryId); |
|
571 CImHeader* imHeader = CImHeader::NewLC(); |
|
572 |
|
573 CMsvStore* store = iTestUtils.EditStoreL(); |
|
574 CleanupStack::PushL(store); |
|
575 |
|
576 imHeader->RestoreL(*store); |
|
577 |
|
578 TPtrC subjectField(imHeader->Subject()); |
|
579 WriteToFileL(aFile, subjectField); |
|
580 WriteToFileL(aFile, _L("\n")); |
|
581 |
|
582 TPtrC fromField(imHeader->From()); |
|
583 WriteToFileL(aFile, fromField); |
|
584 WriteToFileL(aFile, _L("\n")); |
|
585 |
|
586 const CDesCArray& toField = imHeader->ToRecipients(); |
|
587 for (i=0; i < toField.Count(); i++) |
|
588 { |
|
589 WriteToFileL(aFile, toField[i]); |
|
590 } |
|
591 WriteToFileL(aFile, _L("\n")); |
|
592 |
|
593 const CDesCArray& ccField = imHeader->CcRecipients(); |
|
594 for (i=0; i < ccField.Count(); i++) |
|
595 { |
|
596 WriteToFileL(aFile, ccField[i]); |
|
597 } |
|
598 WriteToFileL(aFile, _L("\n")); |
|
599 |
|
600 const CDesCArray& bccField = imHeader->BccRecipients(); |
|
601 for (i=0; i < bccField.Count(); i++) |
|
602 { |
|
603 WriteToFileL(aFile, bccField[i]); |
|
604 } |
|
605 WriteToFileL(aFile, _L("\n")); |
|
606 |
|
607 CleanupStack::PopAndDestroy(2, imHeader); // store, imHeader |
|
608 } |
|
609 |
|
610 CDumpHeaderFields::CDumpHeaderFields(CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils, const TDesC& aPath) : |
|
611 iSelection(aSelection), |
|
612 iTestUtils(aTestUtils) |
|
613 { |
|
614 iPath = aPath; |
|
615 } |
|
616 |
|
617 |
|
618 // |
|
619 // |
|
620 // CChangeCharset |
|
621 // |
|
622 |
|
623 CChangeCharset::CChangeCharset(TUint aNewCharset, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
624 : iTestUtils(aTestUtils), |
|
625 iSelection(aSelection), |
|
626 iNewCharset(aNewCharset) |
|
627 { |
|
628 } |
|
629 |
|
630 void CChangeCharset::StartL(TRequestStatus& aStatus) |
|
631 { |
|
632 TInt err = KErrNone; |
|
633 TInt numEmails = iSelection.Count(); |
|
634 TMsvId entryId; |
|
635 CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*(iTestUtils.iMsvEntry)); |
|
636 TUint storedCharset; |
|
637 TInt override; |
|
638 CImHeader* imHeader = CImHeader::NewLC(); |
|
639 |
|
640 // change the charset of every message in the selection |
|
641 for(TInt i=0; i<numEmails; i++) |
|
642 { |
|
643 entryId = iSelection.At(i); |
|
644 imEmailMessage->SetCharacterSetL(entryId, iNewCharset); |
|
645 // Verify the charset has been changed, and it's been overriden |
|
646 imEmailMessage->GetCharacterSetL(entryId, storedCharset, override); |
|
647 if(storedCharset != iNewCharset || override == FALSE) |
|
648 err = KErrUnknown; |
|
649 |
|
650 // do the header charset as well |
|
651 iTestUtils.iMsvEntry->SetEntryL(entryId); |
|
652 |
|
653 CMsvStore* store = iTestUtils.EditStoreL(); |
|
654 CleanupStack::PushL(store); |
|
655 |
|
656 imHeader->RestoreL(*store); |
|
657 imHeader->SetOverrideCharset(iNewCharset); |
|
658 // Verify we can retrieve it |
|
659 storedCharset = imHeader->OverrideCharset(); |
|
660 |
|
661 // redecode header fields |
|
662 imHeader->ReDecodeL(iTestUtils.FileSession()); |
|
663 // store it for later |
|
664 imHeader->StoreL(*store); |
|
665 |
|
666 store->CommitL(); |
|
667 |
|
668 CleanupStack::PopAndDestroy(store); |
|
669 } |
|
670 CleanupStack::PopAndDestroy(2, imEmailMessage); // imHeader, imEmailMessage |
|
671 |
|
672 TRequestStatus* status = &aStatus; |
|
673 User::RequestComplete(status, err); |
|
674 } |
|
675 |
|
676 |
|
677 // |
|
678 // |
|
679 // CAddComment |
|
680 // |
|
681 |
|
682 CAddComment* CAddComment::NewL(const CDesCArrayFlat& aComment, CMsvTestUtils& aTestUtils) |
|
683 { |
|
684 CAddComment* self = new (ELeave) CAddComment(aTestUtils); |
|
685 CleanupStack::PushL(self); |
|
686 self->ConstructL(aComment); |
|
687 CleanupStack::Pop(self); |
|
688 return self; |
|
689 } |
|
690 |
|
691 void CAddComment::ConstructL(const CDesCArrayFlat& aComment) |
|
692 { |
|
693 // need to construct one big HBufC string to use as the comment |
|
694 // first, find out size of array... |
|
695 TInt commentSize = 0; |
|
696 for(TInt i = 0; i < aComment.Count(); i++) |
|
697 commentSize += ((aComment[i]).Length() + _L(" ").Size()); // extra 1 added for padding between words. |
|
698 |
|
699 // second, construct HBufC.... |
|
700 iComment = HBufC::NewL(commentSize); |
|
701 |
|
702 // create a pointer to the HBufC, so that we can add text to it. |
|
703 TPtr commentPtr = iComment->Des(); |
|
704 |
|
705 // now create string |
|
706 for(TInt j = 0; j < aComment.Count(); j++) |
|
707 { |
|
708 commentPtr.Append((aComment)[j]); |
|
709 commentPtr.Append(_L(" ")); // extra 1 added for padding between words. |
|
710 } |
|
711 |
|
712 // hopefully everything should be added ok! |
|
713 } |
|
714 |
|
715 void CAddComment::StartL(TRequestStatus& aStatus) |
|
716 { |
|
717 // now we have to add the debugging line number which we only know at run time... |
|
718 TBuf<7> commentString; |
|
719 commentString.Format(_L("[%4d] "), iDebugInfo.LineNumber()); |
|
720 |
|
721 // create a pointer to the HBufC, realloc size and then insert new data... |
|
722 iComment = iComment->ReAllocL(iComment->Size() + commentString.Size()); |
|
723 TPtr commentPtr = iComment->Des(); |
|
724 commentPtr.Insert(0, commentString); |
|
725 |
|
726 iTestUtils.WriteComment(*iComment); |
|
727 |
|
728 TRequestStatus* status = &aStatus; |
|
729 User::RequestComplete(status, KErrNone); |
|
730 } |
|
731 |
|
732 CAddComment::CAddComment(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
733 { |
|
734 } |
|
735 |
|
736 CAddComment::~CAddComment() |
|
737 { |
|
738 delete iComment; |
|
739 } |
|
740 |
|
741 // |
|
742 // |
|
743 // CCreateEmailService |
|
744 // |
|
745 |
|
746 void CCreateEmailService::StartL() |
|
747 // This function should always be called by the StartL function of |
|
748 // any derived classes. It should be called by the StartL function of any derived classes. |
|
749 { |
|
750 } |
|
751 |
|
752 CCreateEmailService::CCreateEmailService(CEmailClientTest& aTestHarness) : iTestHarness(aTestHarness) |
|
753 { |
|
754 } |
|
755 |
|
756 CCreateEmailService::~CCreateEmailService() |
|
757 { |
|
758 delete iDetails; |
|
759 } |
|
760 |
|
761 TMsvEntry& CCreateEmailService::Entry() |
|
762 { |
|
763 return iEntry; |
|
764 } |
|
765 |
|
766 void CCreateEmailService::SetDetailsStringL(const TDesC& aDetails) |
|
767 { |
|
768 delete iDetails; |
|
769 iDetails = 0; |
|
770 iDetails = HBufC::NewL(aDetails.Length()); |
|
771 (*iDetails) = aDetails; |
|
772 iEntry.iDetails.Set(*iDetails); |
|
773 } |
|
774 |
|
775 |
|
776 // |
|
777 // |
|
778 // CCountChildren |
|
779 // |
|
780 CCountChildren::CCountChildren(TMsvId& aParentFolder, CEmailClientTest& aTestHarness) |
|
781 : iTestHarness(aTestHarness), |
|
782 iParentFolder(aParentFolder) |
|
783 { |
|
784 } |
|
785 |
|
786 void CCountChildren::StartL(TRequestStatus& aStatus) |
|
787 { |
|
788 |
|
789 iTestHarness.EmailTestUtils().iMsvEntry->SetEntryL(iParentFolder); |
|
790 |
|
791 // get a list of children underneath the parent. |
|
792 CMsvEntrySelection* tempSelection = iTestHarness.EmailTestUtils().iMsvEntry->ChildrenL(); |
|
793 CleanupStack::PushL(tempSelection); |
|
794 |
|
795 // create a temp CMsvEntry to use to find out message type. |
|
796 CMsvEntry& msvEntry = *(iTestHarness.EmailTestUtils().iMsvEntry); |
|
797 |
|
798 // and while we are pointing at the parent, find out its iDetails |
|
799 HBufC* messageDetails = HBufC::NewLC(msvEntry.Entry().iDetails.Size()); |
|
800 (messageDetails->Des()).Copy(msvEntry.Entry().iDetails); |
|
801 |
|
802 // Counters |
|
803 TInt noServices = 0; |
|
804 TInt noFolders = 0; |
|
805 TInt noMessages = 0; |
|
806 TInt noAttachments = 0; |
|
807 |
|
808 // Copy the child entries to the given selection |
|
809 TInt index = tempSelection->Count(); |
|
810 while (index--) |
|
811 { |
|
812 msvEntry.SetEntryL((*tempSelection)[index]); |
|
813 if(msvEntry.Entry().iType == KUidMsvServiceEntry) |
|
814 { |
|
815 noServices++; |
|
816 } |
|
817 else if(msvEntry.Entry().iType == KUidMsvFolderEntry) |
|
818 { |
|
819 noFolders++; |
|
820 } |
|
821 else if(msvEntry.Entry().iType == KUidMsvMessageEntry) |
|
822 { |
|
823 noMessages++; |
|
824 } |
|
825 else if(msvEntry.Entry().iType == KUidMsvAttachmentEntry) |
|
826 { |
|
827 noAttachments++; |
|
828 } |
|
829 } |
|
830 |
|
831 TBuf<256> countString; |
|
832 countString.Format(KCountText, iDebugInfo.LineNumber(), messageDetails, noServices, noFolders, noMessages, noAttachments); |
|
833 HBufC* countStringHBufC = HBufC::NewLC(countString.Length()); |
|
834 (countStringHBufC->Des()).Copy(countString); |
|
835 |
|
836 iTestHarness.EmailTestUtils().WriteComment(*countStringHBufC); |
|
837 CleanupStack::PopAndDestroy(3); |
|
838 |
|
839 TRequestStatus* status = &aStatus; |
|
840 User::RequestComplete(status, KErrNone); |
|
841 } |
|
842 |
|
843 |
|
844 // |
|
845 // |
|
846 // CCheckService |
|
847 // |
|
848 CCheckService::CCheckService(CEmailClientTest& aTestHarness) : iTestHarness(aTestHarness) |
|
849 { |
|
850 } |
|
851 |
|
852 void CCheckService::StartL(TRequestStatus& aStatus) |
|
853 { |
|
854 TInt err = KErrNone; |
|
855 |
|
856 // This is in the wrong parser!!!! As this contains IMAP specific code it |
|
857 // should be moved to imaptests.cpp |
|
858 |
|
859 if(!iTestHarness.EmailTestUtils().iImapServiceId) |
|
860 { |
|
861 TBuf<100> logString; |
|
862 logString.Format(KErrService, iDebugInfo.LineNumber()); |
|
863 iTestHarness.LogComment(logString); |
|
864 err = KErrUnknown; |
|
865 } |
|
866 |
|
867 TRequestStatus* status = &aStatus; |
|
868 User::RequestComplete(status, err); |
|
869 } |
|
870 |
|
871 |
|
872 // |
|
873 // |
|
874 // CGoClientSide |
|
875 // |
|
876 |
|
877 void CGoClientSide::StartL(TRequestStatus& aStatus) |
|
878 { |
|
879 iTestUtils.GoClientSideL(); |
|
880 TRequestStatus* status = &aStatus; |
|
881 User::RequestComplete(status, KErrNone); |
|
882 } |
|
883 |
|
884 CGoClientSide::CGoClientSide(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
885 {} |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 // |
|
891 // |
|
892 // CGoServerSide |
|
893 // |
|
894 |
|
895 void CGoServerSide::StartL(TRequestStatus& aStatus) |
|
896 { |
|
897 iTestUtils.GoServerSideL(); |
|
898 TRequestStatus* status = &aStatus; |
|
899 User::RequestComplete(status, KErrNone); |
|
900 } |
|
901 |
|
902 CGoServerSide::CGoServerSide(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
903 {} |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 // |
|
909 // |
|
910 // CResetMessageServer |
|
911 // |
|
912 |
|
913 void CResetMessageServer::StartL(TRequestStatus& aStatus) |
|
914 { |
|
915 iTestUtils.Reset(); |
|
916 TRequestStatus* status = &aStatus; |
|
917 User::RequestComplete(status, KErrNone); |
|
918 } |
|
919 |
|
920 CResetMessageServer::CResetMessageServer(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
921 {} |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 // |
|
929 // |
|
930 // CCheckMessageFolder |
|
931 // |
|
932 |
|
933 void CCheckMessageFolder::StartL(TRequestStatus& aStatus) |
|
934 { |
|
935 TBool matched = ETrue; |
|
936 iTestUtils.FindChildrenL(0x01000, ETrue); |
|
937 |
|
938 RFile file1; |
|
939 User::LeaveIfError(file1.Open(iTestUtils.FileSession(), K_T_MSG_STRUCT_FILE, EFileShareAny)); |
|
940 |
|
941 RFile file2; |
|
942 User::LeaveIfError(file2.Open(iTestUtils.FileSession(), iFileName, EFileShareAny)); |
|
943 |
|
944 TLineReader lineReader1(file1); |
|
945 TLineReader lineReader2(file2); |
|
946 |
|
947 HBufC8* actualLine = lineReader1.GetLineLC(); |
|
948 HBufC8* expectedLine = lineReader2.GetLineLC(); |
|
949 |
|
950 while ((actualLine->Des().Size() > 0) && (expectedLine->Des().Size() > 0) && (matched)) |
|
951 { |
|
952 if (actualLine->Des() != expectedLine->Des()) |
|
953 matched = EFalse; |
|
954 |
|
955 CleanupStack::PopAndDestroy(2); // actualLine, expectedLinw |
|
956 |
|
957 actualLine = lineReader1.GetLineLC(); |
|
958 expectedLine = lineReader2.GetLineLC(); |
|
959 } |
|
960 |
|
961 if ((actualLine->Des().Size() != 0) |
|
962 || (expectedLine->Des().Size() != 0)) |
|
963 { |
|
964 matched = EFalse; |
|
965 } |
|
966 |
|
967 CleanupStack::PopAndDestroy(2); // actualLine, expectedLinw |
|
968 |
|
969 if (!matched) |
|
970 { |
|
971 User::Leave(KErrNotFound); |
|
972 } |
|
973 |
|
974 file1.Close(); |
|
975 file2.Close(); |
|
976 |
|
977 TRequestStatus* status = &aStatus; |
|
978 User::RequestComplete(status, KErrNone); |
|
979 } |
|
980 |
|
981 CCheckMessageFolder::CCheckMessageFolder(const TDesC& aFileName, CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
982 { |
|
983 iFileName = aFileName; |
|
984 } |
|
985 |
|
986 |
|
987 // |
|
988 // |
|
989 // CChangeMsvDrive |
|
990 // |
|
991 |
|
992 CChangeMsvDrive::CChangeMsvDrive(CMsvClientTest& aParentTestHarness, TInt aDrive) : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness), iDrive(aDrive) |
|
993 { |
|
994 CActiveScheduler::Add(this); |
|
995 } |
|
996 |
|
997 void CChangeMsvDrive::StartL(TRequestStatus& aStatus) |
|
998 { |
|
999 iReportStatus = &aStatus; |
|
1000 |
|
1001 iParentTestHarness.SetCurrentOperation(iParentTestHarness.MsvTestUtils().iMsvSession->ChangeDriveL(iDrive, iStatus)); |
|
1002 aStatus = KRequestPending; |
|
1003 SetActive(); |
|
1004 } |
|
1005 |
|
1006 void CChangeMsvDrive::RunL() |
|
1007 { |
|
1008 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
1009 } |
|
1010 |
|
1011 void CChangeMsvDrive::DoCancel() |
|
1012 { |
|
1013 iParentTestHarness.CurrentOperation().Cancel(); |
|
1014 } |
|
1015 |
|
1016 CChangeMsvDrive::~CChangeMsvDrive() |
|
1017 { |
|
1018 } |
|
1019 |
|
1020 |
|
1021 // |
|
1022 // |
|
1023 // CRemoveFileOrDir |
|
1024 // |
|
1025 |
|
1026 CRemoveFileOrDir::CRemoveFileOrDir(CMsvTestUtils& aTestUtils, const TDesC& aPath) : iTestUtils(aTestUtils) |
|
1027 { |
|
1028 iPath = aPath; |
|
1029 } |
|
1030 |
|
1031 void CRemoveFileOrDir::StartL(TRequestStatus& aStatus) |
|
1032 { |
|
1033 CFileMan* fileMan = CFileMan::NewL(iTestUtils.FileSession()); |
|
1034 CleanupStack::PushL(fileMan); |
|
1035 TParse parse; |
|
1036 |
|
1037 parse.Set(iPath, NULL, NULL); |
|
1038 TInt error; |
|
1039 if(parse.NamePresent()) |
|
1040 { |
|
1041 // specified a file to delete |
|
1042 error = fileMan->Delete(parse.FullName()); |
|
1043 error = iTestUtils.FileSession().Delete(parse.FullName()); |
|
1044 } |
|
1045 else |
|
1046 { |
|
1047 // specified a directoy to delete |
|
1048 error = fileMan->RmDir(parse.DriveAndPath()); |
|
1049 error = iTestUtils.FileSession().RmDir(parse.DriveAndPath()); |
|
1050 } |
|
1051 if (!(error==KErrNotFound||error==KErrNone)) |
|
1052 { |
|
1053 TPtrC driveAndPath = parse.DriveAndPath(); |
|
1054 iTestUtils.Printf(_L("Directory %S cannot be removed. "), &driveAndPath); |
|
1055 iTestUtils.Printf(_L("Please ensure directory is not in use.\n")); |
|
1056 User::Leave(KErrAccessDenied); |
|
1057 } |
|
1058 CleanupStack::PopAndDestroy(); |
|
1059 |
|
1060 TRequestStatus* status = &aStatus; |
|
1061 User::RequestComplete(status, KErrNone); |
|
1062 } |
|
1063 |
|
1064 |
|
1065 // |
|
1066 // |
|
1067 // CSelectEntry |
|
1068 // |
|
1069 |
|
1070 CSelectEntry::CSelectEntry(const TMsvId& aCurrentFolderId, TMsvId* aEntryId, CMsvTestUtils& aTestUtils) |
|
1071 : iTestUtils(aTestUtils), |
|
1072 iCurrentFolderId(aCurrentFolderId), |
|
1073 iEntryId(aEntryId) |
|
1074 { |
|
1075 iEntrySelection = NULL; |
|
1076 } |
|
1077 |
|
1078 CSelectEntry::CSelectEntry(const TMsvId& aCurrentFolderId, CMsvEntrySelection* aSelection, CMsvTestUtils& aTestUtils) |
|
1079 : iTestUtils(aTestUtils), |
|
1080 iCurrentFolderId(aCurrentFolderId), |
|
1081 iEntrySelection(aSelection) |
|
1082 { |
|
1083 iEntryId = NULL; |
|
1084 } |
|
1085 |
|
1086 CSelectEntry* CSelectEntry::NewL(const TDesC& aName, const TMsvId& aCurrentFolderId, TMsvId* aEntryId, CMsvTestUtils& aTestUtils) |
|
1087 { |
|
1088 CSelectEntry* self = new (ELeave) CSelectEntry(aCurrentFolderId, aEntryId, aTestUtils); |
|
1089 CleanupStack::PushL(self); |
|
1090 self->ConstructL(aName); |
|
1091 CleanupStack::Pop(self); |
|
1092 return self; |
|
1093 } |
|
1094 |
|
1095 CSelectEntry* CSelectEntry::NewL(const TDesC& aName, const TMsvId& aCurrentFolderId, CMsvEntrySelection* aSelection, CMsvTestUtils& aTestUtils) |
|
1096 { |
|
1097 CSelectEntry* self = new (ELeave) CSelectEntry(aCurrentFolderId, aSelection, aTestUtils); |
|
1098 CleanupStack::PushL(self); |
|
1099 self->ConstructL(aName); |
|
1100 CleanupStack::Pop(self); |
|
1101 return self; |
|
1102 } |
|
1103 |
|
1104 void CSelectEntry::ConstructL(const TDesC& aName) |
|
1105 { |
|
1106 iEntryName = HBufC::NewL(aName.Length()); |
|
1107 (*iEntryName) = aName; |
|
1108 } |
|
1109 |
|
1110 void CSelectEntry::StartL(TRequestStatus& aStatus) |
|
1111 { |
|
1112 // Select current folder |
|
1113 CMsvEntry& entry = *(iTestUtils.iMsvEntry); |
|
1114 entry.SetEntryL(iCurrentFolderId); |
|
1115 |
|
1116 // show the invisible folders..... |
|
1117 TMsvSelectionOrdering order; |
|
1118 order.SetShowInvisibleEntries(ETrue); |
|
1119 entry.SetSortTypeL(order); |
|
1120 |
|
1121 CMsvEntrySelection* tempSelection = entry.ChildrenL(); |
|
1122 CleanupStack::PushL(tempSelection); |
|
1123 |
|
1124 // Check each child entry for a matching string |
|
1125 TBool found = EFalse; |
|
1126 TInt entryIndex = tempSelection->Count(); |
|
1127 while ((!found) && (entryIndex-- != 0)) |
|
1128 { |
|
1129 entry.SetEntryL((*tempSelection)[entryIndex]); |
|
1130 if (iEntryName->CompareF(entry.Entry().iDescription) == 0) |
|
1131 { |
|
1132 found = ETrue; |
|
1133 } |
|
1134 else if (iEntryName->CompareF(entry.Entry().iDetails) == 0) |
|
1135 { |
|
1136 found = ETrue; |
|
1137 } |
|
1138 } |
|
1139 |
|
1140 if (found) |
|
1141 { |
|
1142 // decide if its a Selection thats required, or an Entry |
|
1143 if(iEntryId) |
|
1144 { |
|
1145 *iEntryId = entry.Entry().Id(); |
|
1146 } |
|
1147 else |
|
1148 { |
|
1149 (*iEntrySelection).Reset(); |
|
1150 (*iEntrySelection).AppendL(entry.Entry().Id()); |
|
1151 } |
|
1152 |
|
1153 TRequestStatus* status = &aStatus; |
|
1154 User::RequestComplete(status, KErrNone); |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 TBuf<256> errorString; |
|
1159 errorString.Format(KErrSelectText, iEntryName); |
|
1160 HBufC* errorStringHBufC = HBufC::NewLC(errorString.Length()); |
|
1161 (errorStringHBufC->Des()).Copy(errorString); |
|
1162 |
|
1163 iTestUtils.WriteComment(*errorStringHBufC); |
|
1164 CleanupStack::PopAndDestroy(); |
|
1165 |
|
1166 TRequestStatus* status = &aStatus; |
|
1167 User::RequestComplete(status, KErrNotFound); |
|
1168 } |
|
1169 |
|
1170 CleanupStack::PopAndDestroy(tempSelection); |
|
1171 } |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 CSelectEntry::~CSelectEntry() |
|
1177 { |
|
1178 delete iEntryName; |
|
1179 } |
|
1180 /* |
|
1181 CSelectEntry::CSelectEntry(const TMsvId& aCurrentFolderId, TMsvId& aEntryId, CMsvTestUtils& aTestUtils) : iCurrentFolderId(aCurrentFolderId), iTestUtils(aTestUtils), iEntryId(aEntryId) |
|
1182 { |
|
1183 } |
|
1184 |
|
1185 |
|
1186 CSelectEntry* CSelectEntry::NewL(const TDesC& aName, const TMsvId& aCurrentFolderId, TMsvId& aEntryId, CMsvTestUtils& aTestUtils) |
|
1187 { |
|
1188 CSelectEntry* self = new (ELeave) CSelectEntry(aCurrentFolderId, aEntryId, aTestUtils); |
|
1189 CleanupStack::PushL(self); |
|
1190 self->ConstructL(aName); |
|
1191 CleanupStack::Pop(self); |
|
1192 return self; |
|
1193 } |
|
1194 |
|
1195 void CSelectEntry::ConstructL(const TDesC& aName) |
|
1196 { |
|
1197 iEntryName = HBufC::NewL(aName.Length()); |
|
1198 (*iEntryName) = aName; |
|
1199 } |
|
1200 |
|
1201 void CSelectEntry::StartL(TRequestStatus& aStatus) |
|
1202 { |
|
1203 // Select current folder |
|
1204 CMsvEntry& entry = *(iTestUtils.iMsvEntry); |
|
1205 entry.SetEntryL(iCurrentFolderId); |
|
1206 |
|
1207 // show the invisible folders..... |
|
1208 TMsvSelectionOrdering order; |
|
1209 order.SetShowInvisibleEntries(ETrue); |
|
1210 entry.SetSortTypeL(order); |
|
1211 |
|
1212 CMsvEntrySelection* tempSelection = entry.ChildrenL(); |
|
1213 CleanupStack::PushL(tempSelection); |
|
1214 |
|
1215 // Check each child entry for a matching string |
|
1216 TBool found = EFalse; |
|
1217 TInt entryIndex = tempSelection->Count(); |
|
1218 while ((!found) && (entryIndex-- != 0)) |
|
1219 { |
|
1220 entry.SetEntryL((*tempSelection)[entryIndex]); |
|
1221 if (iEntryName->CompareF(entry.Entry().iDescription) == 0) |
|
1222 { |
|
1223 found = ETrue; |
|
1224 } |
|
1225 else if (iEntryName->CompareF(entry.Entry().iDetails) == 0) |
|
1226 { |
|
1227 found = ETrue; |
|
1228 } |
|
1229 } |
|
1230 |
|
1231 if (found) |
|
1232 { |
|
1233 iEntryId = entry.Entry().Id(); |
|
1234 |
|
1235 TRequestStatus* status = &aStatus; |
|
1236 User::RequestComplete(status, KErrNone); |
|
1237 } |
|
1238 else |
|
1239 { |
|
1240 TBuf<256> errorString; |
|
1241 errorString.Format(KErrSelectText, iEntryName); |
|
1242 HBufC* errorStringHBufC = HBufC::NewLC(errorString.Length()); |
|
1243 (errorStringHBufC->Des()).Copy(errorString); |
|
1244 |
|
1245 iTestUtils.WriteComment(*errorStringHBufC); |
|
1246 CleanupStack::PopAndDestroy(); |
|
1247 |
|
1248 TRequestStatus* status = &aStatus; |
|
1249 User::RequestComplete(status, KErrNotFound); |
|
1250 } |
|
1251 |
|
1252 CleanupStack::PopAndDestroy(tempSelection); |
|
1253 } |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 CSelectEntry::~CSelectEntry() |
|
1259 { |
|
1260 delete iEntryName; |
|
1261 } |
|
1262 */ |
|
1263 |
|
1264 // |
|
1265 // |
|
1266 // CCheckSelectionCount |
|
1267 // |
|
1268 |
|
1269 CCheckSelectionCount::CCheckSelectionCount(TInt aCount, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1270 : iTestUtils(aTestUtils), |
|
1271 iSelection(aSelection), |
|
1272 iTestCount(aCount) |
|
1273 { |
|
1274 } |
|
1275 |
|
1276 void CCheckSelectionCount::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
1277 { |
|
1278 // Build parameter list. |
|
1279 VA_LIST list; |
|
1280 VA_START(list, format); |
|
1281 TBuf<0x100> buf; |
|
1282 buf.FormatList(format, list); |
|
1283 |
|
1284 // Log the debug buffer. |
|
1285 iTestUtils.WriteComment(buf); |
|
1286 } |
|
1287 |
|
1288 void CCheckSelectionCount::StartL(TRequestStatus& aStatus) |
|
1289 { |
|
1290 TInt err=KErrNone; |
|
1291 TInt selectionCount=iSelection.Count(); |
|
1292 |
|
1293 LogCommentFormat(_L("[%4d] Folder contains %d entries when %d expected."), iDebugInfo.LineNumber(), selectionCount, iTestCount); |
|
1294 |
|
1295 if (!(selectionCount == iTestCount || selectionCount == iTestCount+1)) |
|
1296 { |
|
1297 LogCommentFormat(_L("Error!")); |
|
1298 err = KErrUnknown; |
|
1299 } |
|
1300 |
|
1301 TRequestStatus* status = &aStatus; |
|
1302 User::RequestComplete(status, err); |
|
1303 } |
|
1304 |
|
1305 |
|
1306 // |
|
1307 // |
|
1308 // CCheckNewFlag |
|
1309 // |
|
1310 |
|
1311 CCheckNewFlag::CCheckNewFlag(TInt aSelectedIndex, TBool aTestNewStatus, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1312 :iTestUtils(aTestUtils), |
|
1313 iSelection(aSelection), |
|
1314 iSelectedIndex(aSelectedIndex), |
|
1315 iTestNewStatus(aTestNewStatus) |
|
1316 { |
|
1317 } |
|
1318 |
|
1319 void CCheckNewFlag::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
1320 { |
|
1321 // Build parameter list. |
|
1322 VA_LIST list; |
|
1323 VA_START(list, format); |
|
1324 TBuf<0x100> buf; |
|
1325 buf.FormatList(format, list); |
|
1326 |
|
1327 // Log the debug buffer. |
|
1328 iTestUtils.WriteComment(buf); |
|
1329 } |
|
1330 |
|
1331 void CCheckNewFlag::StartL(TRequestStatus& aStatus) |
|
1332 // Check the status flag of the selected entry is the same as the test value |
|
1333 { |
|
1334 TInt err=KErrNone; |
|
1335 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
1336 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
1337 msvEntry.SetEntryL(entryId); |
|
1338 TBool entryIsNew = msvEntry.Entry().New(); |
|
1339 |
|
1340 // Check if the Entry is New |
|
1341 if (entryIsNew) |
|
1342 { |
|
1343 // Check if the entry Should be New |
|
1344 if (iTestNewStatus) |
|
1345 { |
|
1346 // The entry is new |
|
1347 _LIT(KNewEntry, "Entry %d is New"); |
|
1348 LogCommentFormat(KNewEntry, iSelectedIndex); |
|
1349 } |
|
1350 else |
|
1351 { |
|
1352 // The Entry is New, but is should be old |
|
1353 _LIT(KErrNewEntry, "Error, the entry is New. It should be Old!"); |
|
1354 LogCommentFormat(KErrNewEntry); |
|
1355 err = KErrUnknown; |
|
1356 } |
|
1357 |
|
1358 } |
|
1359 else |
|
1360 { |
|
1361 // The Entry is Old. Check if it should be. |
|
1362 if (!iTestNewStatus) |
|
1363 { |
|
1364 // The entry is Old |
|
1365 _LIT(KOldEntry, "Entry %d is Old"); |
|
1366 LogCommentFormat(KOldEntry, iSelectedIndex); |
|
1367 } |
|
1368 else |
|
1369 { |
|
1370 // The Entry is Old, but is should be New |
|
1371 _LIT(KErrOldEntry, "Error, the entry is Old. It should be New!"); |
|
1372 LogCommentFormat(KErrOldEntry); |
|
1373 err = KErrUnknown; |
|
1374 } |
|
1375 } |
|
1376 |
|
1377 TRequestStatus* status = &aStatus; |
|
1378 User::RequestComplete(status, err); |
|
1379 } |
|
1380 |
|
1381 |
|
1382 |
|
1383 // |
|
1384 // |
|
1385 // CCheckPriority |
|
1386 // |
|
1387 |
|
1388 CCheckPriority::CCheckPriority(TInt aSelectedIndex, TInt aTestPriority, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1389 :iTestUtils(aTestUtils), |
|
1390 iSelection(aSelection), |
|
1391 iSelectedIndex(aSelectedIndex), |
|
1392 iTestPriority(aTestPriority) |
|
1393 { |
|
1394 } |
|
1395 |
|
1396 void CCheckPriority::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
1397 { |
|
1398 // Build parameter list. |
|
1399 VA_LIST list; |
|
1400 VA_START(list, format); |
|
1401 TBuf<0x100> buf; |
|
1402 buf.FormatList(format, list); |
|
1403 |
|
1404 // Log the debug buffer. |
|
1405 iTestUtils.WriteComment(buf); |
|
1406 } |
|
1407 |
|
1408 void CCheckPriority::StartL(TRequestStatus& aStatus) |
|
1409 // Check the Priority flag of the selected entry is the same as the test value |
|
1410 { |
|
1411 TInt err=KErrNone; |
|
1412 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
1413 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
1414 msvEntry.SetEntryL(entryId); |
|
1415 TMsvPriority priority = msvEntry.Entry().Priority(); |
|
1416 |
|
1417 // Check if the Priority flag is correct |
|
1418 if (priority == iTestPriority) |
|
1419 { |
|
1420 // Correct Priority |
|
1421 _LIT(KCorrectPriority, "Entry %d has Priority %d"); |
|
1422 LogCommentFormat(KCorrectPriority, entryId, priority); |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 _LIT(KInCorrectPriority, "Error, Entry %d has Priority %d"); |
|
1427 LogCommentFormat(KInCorrectPriority, entryId, priority); |
|
1428 err = KErrUnknown; |
|
1429 } |
|
1430 |
|
1431 TRequestStatus* status = &aStatus; |
|
1432 User::RequestComplete(status, err); |
|
1433 } |
|
1434 |
|
1435 |
|
1436 |
|
1437 // |
|
1438 // |
|
1439 // CCheckAttachment |
|
1440 // |
|
1441 |
|
1442 CCheckAttachment::CCheckAttachment(TInt aSelectedIndex, TBool aTestAttachment, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1443 :iTestUtils(aTestUtils), |
|
1444 iSelection(aSelection), |
|
1445 iSelectedIndex(aSelectedIndex), |
|
1446 iTestAttachment(aTestAttachment) |
|
1447 { |
|
1448 } |
|
1449 |
|
1450 void CCheckAttachment::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
1451 { |
|
1452 // Build parameter list. |
|
1453 VA_LIST list; |
|
1454 VA_START(list, format); |
|
1455 TBuf<0x100> buf; |
|
1456 buf.FormatList(format, list); |
|
1457 |
|
1458 // Log the debug buffer. |
|
1459 iTestUtils.WriteComment(buf); |
|
1460 } |
|
1461 |
|
1462 void CCheckAttachment::StartL(TRequestStatus& aStatus) |
|
1463 // Check the attachment flag for this entry is the same as the test value |
|
1464 { |
|
1465 TInt err=KErrNone; |
|
1466 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
1467 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
1468 msvEntry.SetEntryL(entryId); |
|
1469 TBool entryHasAttachment = EFalse; |
|
1470 |
|
1471 // Find out if the Entry has an attachment |
|
1472 // See if the Entry has a Child Folder Entry |
|
1473 CMsvEntrySelection* children = msvEntry.ChildrenWithTypeL(KUidMsvFolderEntry); |
|
1474 CleanupStack::PushL(children); |
|
1475 if(children->Count() > 0) |
|
1476 { |
|
1477 // Find out if the Child Folder Entry has an attachment |
|
1478 msvEntry.SetEntryL(children->At(0)); |
|
1479 CMsvEntrySelection* grandChildren = msvEntry.ChildrenWithTypeL(KUidMsvAttachmentEntry); |
|
1480 CleanupStack::PushL(grandChildren); |
|
1481 if(grandChildren->Count() > 0) |
|
1482 { |
|
1483 entryHasAttachment = ETrue; |
|
1484 } |
|
1485 |
|
1486 CleanupStack::PopAndDestroy(); //grandChildren |
|
1487 } |
|
1488 |
|
1489 CleanupStack::PopAndDestroy(); //children |
|
1490 |
|
1491 |
|
1492 // Check if the Entry has an attachment |
|
1493 if (entryHasAttachment) |
|
1494 { |
|
1495 // Check if the entry should have an Attachment |
|
1496 if (iTestAttachment) |
|
1497 { |
|
1498 // Entry has an attachment |
|
1499 _LIT(KAttachment, "Entry %d has an Attachment"); |
|
1500 LogCommentFormat(KAttachment, entryId); |
|
1501 } |
|
1502 else |
|
1503 { |
|
1504 // There should Not be an attachment, but there is |
|
1505 _LIT(KErrAttachment, "Error, Entry should NOT have an Attachment!"); |
|
1506 LogCommentFormat(KErrAttachment); |
|
1507 err = KErrUnknown; |
|
1508 } |
|
1509 } |
|
1510 else |
|
1511 { |
|
1512 // Check if the entry should NOT have an Attachment |
|
1513 if (!iTestAttachment) |
|
1514 { |
|
1515 // Entry does NOT have an attachment |
|
1516 _LIT(KNoAttachment, "Entry %d does not have an Attachment"); |
|
1517 LogCommentFormat(KNoAttachment, entryId); |
|
1518 } |
|
1519 else |
|
1520 { |
|
1521 // There should be an attachment, but there is NOT |
|
1522 _LIT(KErrNoAttachment, "Error, Entry should have an Attachment!"); |
|
1523 LogCommentFormat(KErrNoAttachment); |
|
1524 err = KErrUnknown; |
|
1525 } |
|
1526 } |
|
1527 |
|
1528 TRequestStatus* status = &aStatus; |
|
1529 User::RequestComplete(status, err); |
|
1530 } |
|
1531 |
|
1532 // |
|
1533 // |
|
1534 // CCheckChildren |
|
1535 // |
|
1536 |
|
1537 CCheckChildren::CCheckChildren(TInt aSelectedIndex, TBool aTestAttachment, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1538 :iTestUtils(aTestUtils), |
|
1539 iSelection(aSelection), |
|
1540 iSelectedIndex(aSelectedIndex), |
|
1541 iTestChildren(aTestAttachment) |
|
1542 { |
|
1543 } |
|
1544 |
|
1545 void CCheckChildren::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
1546 { |
|
1547 // Build parameter list. |
|
1548 VA_LIST list; |
|
1549 VA_START(list, format); |
|
1550 TBuf<0x100> buf; |
|
1551 buf.FormatList(format, list); |
|
1552 |
|
1553 // Log the debug buffer. |
|
1554 iTestUtils.WriteComment(buf); |
|
1555 } |
|
1556 |
|
1557 void CCheckChildren::StartL(TRequestStatus& aStatus) |
|
1558 { |
|
1559 TInt err=KErrNone; |
|
1560 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
1561 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
1562 msvEntry.SetEntryL(entryId); |
|
1563 TBool entryHasChildren = EFalse; |
|
1564 |
|
1565 // Find out if the Entry has children |
|
1566 entryHasChildren = msvEntry.Count(); |
|
1567 |
|
1568 // Check if the Entry has children |
|
1569 if (entryHasChildren) |
|
1570 { |
|
1571 // Check if the entry should have children |
|
1572 if (iTestChildren) |
|
1573 { |
|
1574 // Entry has children |
|
1575 _LIT(KChildren, "Entry %d has children"); |
|
1576 LogCommentFormat(KChildren, entryId); |
|
1577 } |
|
1578 else |
|
1579 { |
|
1580 // Entry should not have children, but there is |
|
1581 _LIT(KErrChildren, "Error, Entry should NOT have any children!"); |
|
1582 LogCommentFormat(KErrChildren); |
|
1583 err = KErrUnknown; |
|
1584 } |
|
1585 } |
|
1586 else |
|
1587 { |
|
1588 // Check if the entry should NOT have children |
|
1589 if (!iTestChildren) |
|
1590 { |
|
1591 // Entry does NOT have children |
|
1592 _LIT(KNoChildren, "Entry %d does not have any children"); |
|
1593 LogCommentFormat(KNoChildren, entryId); |
|
1594 } |
|
1595 else |
|
1596 { |
|
1597 // Entry should have children, but there is NOT |
|
1598 _LIT(KErrNoChildren, "Error, Entry should have children!"); |
|
1599 LogCommentFormat(KErrNoChildren); |
|
1600 err = KErrUnknown; |
|
1601 } |
|
1602 } |
|
1603 |
|
1604 TRequestStatus* status = &aStatus; |
|
1605 User::RequestComplete(status, err); |
|
1606 } |
|
1607 |
|
1608 // |
|
1609 // |
|
1610 // CCheckBodyText |
|
1611 // |
|
1612 |
|
1613 CCheckBodyText::CCheckBodyText(TInt aSelectedIndex, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1614 :iTestUtils(aTestUtils), |
|
1615 iSelection(aSelection), |
|
1616 iSelectedIndex(aSelectedIndex) |
|
1617 { |
|
1618 } |
|
1619 |
|
1620 CCheckBodyText* CCheckBodyText::NewL(TInt aSelectedIndex, TDesC& aTestBodyText, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1621 { |
|
1622 CCheckBodyText* self = new (ELeave) CCheckBodyText(aSelectedIndex, aSelection, aTestUtils); |
|
1623 CleanupStack::PushL(self); |
|
1624 self->ConstructL(aTestBodyText); |
|
1625 CleanupStack::Pop(self); |
|
1626 return self; |
|
1627 } |
|
1628 |
|
1629 void CCheckBodyText::ConstructL(TDesC& aTestBodyText) |
|
1630 { |
|
1631 iTestBodyText = HBufC::NewL(200); |
|
1632 iTestBodyText->Des().Append(aTestBodyText); |
|
1633 } |
|
1634 |
|
1635 CCheckBodyText::~CCheckBodyText() |
|
1636 { |
|
1637 delete iTestBodyText; |
|
1638 } |
|
1639 |
|
1640 void CCheckBodyText::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
1641 { |
|
1642 // Build parameter list. |
|
1643 VA_LIST list; |
|
1644 VA_START(list, format); |
|
1645 TBuf<0x100> buf; |
|
1646 buf.FormatList(format, list); |
|
1647 |
|
1648 // Log the debug buffer. |
|
1649 iTestUtils.WriteComment(buf); |
|
1650 } |
|
1651 |
|
1652 void CCheckBodyText::StartL(TRequestStatus& aStatus) |
|
1653 // Check the Body Text of this entry is the same as the test value |
|
1654 { |
|
1655 TInt err=KErrNone; |
|
1656 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
1657 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
1658 msvEntry.SetEntryL(entryId); |
|
1659 |
|
1660 // Get the ID of the Body Text Entry, by looking at the Child Entries |
|
1661 TMsvId bodyTextEntryId = KNoBodyText; |
|
1662 CMsvEntrySelection* children = msvEntry.ChildrenL(); |
|
1663 CleanupStack::PushL(children); |
|
1664 if(children->Count() > 0) |
|
1665 { |
|
1666 // Check if the Child Entry is Body Text or a Folder |
|
1667 msvEntry.SetEntryL(children->At(0)); |
|
1668 switch (msvEntry.Entry().iType.iUid) |
|
1669 { |
|
1670 case KUidMsvEmailTextEntryValue: |
|
1671 bodyTextEntryId = msvEntry.EntryId(); |
|
1672 break; |
|
1673 |
|
1674 case KUidMsvFolderEntryValue: |
|
1675 { |
|
1676 // Check if the Child Folder has a Child Body Text Entry |
|
1677 CMsvEntrySelection* grandChild = msvEntry.ChildrenWithTypeL(KUidMsvEmailTextEntry); |
|
1678 CleanupStack::PushL(grandChild); |
|
1679 if(grandChild->Count() > 0) |
|
1680 { |
|
1681 // Get the Id of the Body Text Entry |
|
1682 msvEntry.SetEntryL(grandChild->At(0)); |
|
1683 bodyTextEntryId = msvEntry.EntryId(); |
|
1684 } |
|
1685 |
|
1686 CleanupStack::PopAndDestroy(); // grandChild |
|
1687 break; |
|
1688 } |
|
1689 |
|
1690 default: |
|
1691 break; |
|
1692 } |
|
1693 } |
|
1694 |
|
1695 |
|
1696 // If there is a Body Text Entry, then check if the Text is correct |
|
1697 if (bodyTextEntryId == KNoBodyText) |
|
1698 { |
|
1699 _LIT(KErrNoBodyText, "Error, there is no Body Text"); |
|
1700 LogCommentFormat(KErrNoBodyText); |
|
1701 err = KErrUnknown; |
|
1702 } |
|
1703 else |
|
1704 { |
|
1705 // Set the Entry to be the Body Text |
|
1706 msvEntry.SetEntryL(bodyTextEntryId); |
|
1707 if (msvEntry.HasStoreL()) |
|
1708 { |
|
1709 // Get the store |
|
1710 CMsvStore* store = msvEntry.ReadStoreL(); |
|
1711 CleanupStack::PushL(store); |
|
1712 |
|
1713 // Get the body Text if it exists |
|
1714 CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); |
|
1715 CleanupStack::PushL(paraFormat); |
|
1716 CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); |
|
1717 CleanupStack::PushL(charFormat); |
|
1718 CRichText* richText = CRichText::NewL(paraFormat, charFormat); |
|
1719 CleanupStack::PushL(richText); |
|
1720 if (store->HasBodyTextL()) |
|
1721 store->RestoreBodyTextL(*richText); |
|
1722 |
|
1723 // Get the Entry Body Text. Make it the same length as the test Body Text, as the |
|
1724 // entry body text will also include the name of the attachmnet if there is one |
|
1725 HBufC* bodyText = HBufC::NewL(200); |
|
1726 CleanupStack::PushL(bodyText); |
|
1727 TPtr bodyTextPtr = bodyText->Des(); |
|
1728 richText->Extract(bodyTextPtr, 0); |
|
1729 bodyTextPtr.SetLength(iTestBodyText->Length()); |
|
1730 |
|
1731 // Check the Text is Correct |
|
1732 if (bodyTextPtr.Compare(*iTestBodyText) == 0) |
|
1733 { |
|
1734 _LIT(KCorrectBodyText, "Correct Body Text"); |
|
1735 LogCommentFormat(KCorrectBodyText); |
|
1736 } |
|
1737 else |
|
1738 { |
|
1739 _LIT(KErrWrongBodyText, "Error, Incorrect Body Text"); |
|
1740 LogCommentFormat(KErrWrongBodyText); |
|
1741 err = KErrUnknown; |
|
1742 } |
|
1743 |
|
1744 CleanupStack::PopAndDestroy(5);// store, paraFormat, charFormat, richText, bodyText |
|
1745 } |
|
1746 else |
|
1747 { |
|
1748 _LIT(KErrNoBodyText, "Error, Body Text Entry has No Store"); |
|
1749 LogCommentFormat(KErrNoBodyText); |
|
1750 err = KErrUnknown; |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 CleanupStack::PopAndDestroy(); // children |
|
1755 |
|
1756 |
|
1757 TRequestStatus* status = &aStatus; |
|
1758 User::RequestComplete(status, err); |
|
1759 } |
|
1760 |
|
1761 |
|
1762 |
|
1763 |
|
1764 // |
|
1765 // |
|
1766 // CCheckRemoteFolderSize |
|
1767 // |
|
1768 |
|
1769 CCheckRemoteFolderSize::CCheckRemoteFolderSize(TInt aCount, CMsvTestUtils& aTestUtils) |
|
1770 : iTestUtils(aTestUtils), |
|
1771 iTestCount(aCount) |
|
1772 { |
|
1773 } |
|
1774 |
|
1775 void CCheckRemoteFolderSize::LogCommentFormat(TRefByValue<const TDesC> format,...) |
|
1776 { |
|
1777 // Build parameter list. |
|
1778 VA_LIST list; |
|
1779 VA_START(list, format); |
|
1780 TBuf<0x100> buf; |
|
1781 buf.FormatList(format, list); |
|
1782 |
|
1783 // Log the debug buffer. |
|
1784 iTestUtils.WriteComment(buf); |
|
1785 } |
|
1786 |
|
1787 void CCheckRemoteFolderSize::StartL(TRequestStatus& aStatus) |
|
1788 { |
|
1789 TInt err=KErrNone; |
|
1790 |
|
1791 CMsvEntry& entry = *(iTestUtils.iMsvEntry); |
|
1792 TMsvEmailEntry message=entry.Entry(); |
|
1793 TInt remotecount=message.RemoteFolderEntries(); |
|
1794 |
|
1795 LogCommentFormat(_L("[%4d] Remote folder contains %d entries when %d expected."), iDebugInfo.LineNumber(), remotecount, iTestCount); |
|
1796 |
|
1797 if (remotecount != iTestCount) |
|
1798 { |
|
1799 LogCommentFormat(_L("Error!")); |
|
1800 err = KErrUnknown; |
|
1801 } |
|
1802 |
|
1803 TRequestStatus* status = &aStatus; |
|
1804 User::RequestComplete(status, err); |
|
1805 } |
|
1806 |
|
1807 |
|
1808 // |
|
1809 // |
|
1810 // CSelectPopulatedInSelection |
|
1811 // |
|
1812 |
|
1813 CSelectPopulatedInSelection::CSelectPopulatedInSelection(CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1814 : iTestUtils(aTestUtils), |
|
1815 iSelection(aSelection) |
|
1816 { |
|
1817 } |
|
1818 |
|
1819 void CSelectPopulatedInSelection::StartL(TRequestStatus& aStatus) |
|
1820 { |
|
1821 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
1822 |
|
1823 TInt pos=0; |
|
1824 while (pos<iSelection.Count()) |
|
1825 { |
|
1826 msvEntry.SetEntryL(iSelection[pos]); |
|
1827 TMsvEmailEntry entry(msvEntry.Entry()); |
|
1828 if (entry.BodyTextComplete()) |
|
1829 pos++; |
|
1830 else |
|
1831 iSelection.Delete(pos,1); |
|
1832 } |
|
1833 |
|
1834 TRequestStatus* status = &aStatus; |
|
1835 User::RequestComplete(status, KErrNone); |
|
1836 } |
|
1837 |
|
1838 |
|
1839 // |
|
1840 // |
|
1841 // CSelectLastInSelection |
|
1842 // |
|
1843 |
|
1844 CSelectLastInSelection::CSelectLastInSelection(TInt aCount, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1845 : iTestUtils(aTestUtils), |
|
1846 iSelection(aSelection), |
|
1847 iTestCount(aCount) |
|
1848 { |
|
1849 } |
|
1850 |
|
1851 void CSelectLastInSelection::StartL(TRequestStatus& aStatus) |
|
1852 { |
|
1853 TInt selectionCount=iSelection.Count(); |
|
1854 iTestCount=Min(iTestCount,selectionCount); |
|
1855 iSelection.Delete(iTestCount,iSelection.Count()-iTestCount); |
|
1856 TRequestStatus* status = &aStatus; |
|
1857 User::RequestComplete(status, KErrNone); |
|
1858 } |
|
1859 |
|
1860 // |
|
1861 // |
|
1862 // CSelectFirstInSelection |
|
1863 // |
|
1864 |
|
1865 CSelectFirstInSelection::CSelectFirstInSelection(TInt aCount, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1866 : iTestUtils(aTestUtils), |
|
1867 iSelection(aSelection), |
|
1868 iTestCount(aCount) |
|
1869 { |
|
1870 } |
|
1871 |
|
1872 void CSelectFirstInSelection::StartL(TRequestStatus& aStatus) |
|
1873 { |
|
1874 TInt selectionCount=iSelection.Count(); |
|
1875 iTestCount=Min(iTestCount,selectionCount); |
|
1876 iSelection.Delete(0,iSelection.Count()-iTestCount); |
|
1877 TRequestStatus* status = &aStatus; |
|
1878 User::RequestComplete(status, KErrNone); |
|
1879 } |
|
1880 |
|
1881 // |
|
1882 // |
|
1883 // CMsvTestEntry |
|
1884 // |
|
1885 |
|
1886 CMsvTestEntry::CMsvTestEntry(CMsvClientTest& aParentTestHarness) : iParentTestHarness(aParentTestHarness) |
|
1887 { |
|
1888 } |
|
1889 |
|
1890 void CMsvTestEntry::StartL(TRequestStatus& aStatus) |
|
1891 { |
|
1892 TInt err = KErrNone; |
|
1893 TBool match = ETrue; |
|
1894 |
|
1895 // Get access to the CMsvEntry owned by the test utils of the parent test harness |
|
1896 CMsvEntry* cMsvEntry = iParentTestHarness.MsvTestUtils().iMsvEntry; |
|
1897 |
|
1898 // Check that there is only one entry currently selected |
|
1899 if (iParentTestHarness.iCurrentSelection->Count() != 1) |
|
1900 { |
|
1901 match = EFalse; |
|
1902 iParentTestHarness.LogComment(_L("Incorrect number of entries selected")); |
|
1903 } |
|
1904 |
|
1905 // Set the CMsvEntry to point to the currently selected entry |
|
1906 // We have already checked that there is exactly one selected entry so the index is safe |
|
1907 cMsvEntry->SetEntryL((*iParentTestHarness.iCurrentSelection)[0]); |
|
1908 |
|
1909 // Get the TMsvEntry details that we are going to test |
|
1910 TMsvEntry entry = cMsvEntry->Entry(); |
|
1911 |
|
1912 if ((iTestVisible) && match) |
|
1913 // Test the Visible() flag |
|
1914 { |
|
1915 match = (iVisibleValue == entry.Visible()); |
|
1916 if (!match) |
|
1917 { |
|
1918 iParentTestHarness.LogComment(_L("Visible() not as expected")); |
|
1919 } |
|
1920 } |
|
1921 |
|
1922 if ((iTestComplete) && match) |
|
1923 // Test the Complete() flag |
|
1924 { |
|
1925 match = (iCompleteValue == entry.Complete()); |
|
1926 if (!match) |
|
1927 { |
|
1928 iParentTestHarness.LogComment(_L("Complete() not as expected")); |
|
1929 } |
|
1930 } |
|
1931 |
|
1932 if (!match) |
|
1933 // If the entry did not match then log it and complete with an error |
|
1934 { |
|
1935 iParentTestHarness.LogComment(_L("Entry not as expected")); |
|
1936 err = KErrUnknown; |
|
1937 } |
|
1938 |
|
1939 TRequestStatus* status = &aStatus; |
|
1940 User::RequestComplete(status, err); |
|
1941 } |
|
1942 |
|
1943 void CMsvTestEntry::TestVisible(TBool aVisibleValue) |
|
1944 { |
|
1945 iTestVisible = ETrue; // Specify that the visible flag will be tested |
|
1946 iVisibleValue = aVisibleValue; // Set the expected value |
|
1947 } |
|
1948 |
|
1949 void CMsvTestEntry::TestComplete(TBool aCompleteValue) |
|
1950 { |
|
1951 iTestComplete = ETrue; // Specify that the complete flag will be tested |
|
1952 iCompleteValue = aCompleteValue; // Set the expected value |
|
1953 } |
|
1954 |
|
1955 |
|
1956 // |
|
1957 // |
|
1958 // CSelectEntryById |
|
1959 // |
|
1960 |
|
1961 CSelectEntryById::CSelectEntryById(TMsvId aId, TMsvId& aEntryId, CMsvTestUtils& aTestUtils) |
|
1962 : iTestUtils(aTestUtils), |
|
1963 iIdToSelect(aId), |
|
1964 iEntryId(aEntryId) |
|
1965 { |
|
1966 } |
|
1967 |
|
1968 void CSelectEntryById::StartL(TRequestStatus& aStatus) |
|
1969 { |
|
1970 iTestUtils.iMsvEntry->SetEntryL(iIdToSelect); |
|
1971 iEntryId = iIdToSelect; |
|
1972 TRequestStatus* status = &aStatus; |
|
1973 User::RequestComplete(status, KErrNone); |
|
1974 } |
|
1975 |
|
1976 |
|
1977 |
|
1978 |
|
1979 // |
|
1980 // |
|
1981 // CSelectAllMessages |
|
1982 // |
|
1983 |
|
1984 CSelectAllMessages::CSelectAllMessages(TMsvId& aParentFolder, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1985 : iTestUtils(aTestUtils), |
|
1986 iParentFolder(aParentFolder), |
|
1987 iSelection(aSelection) |
|
1988 { |
|
1989 } |
|
1990 |
|
1991 void CSelectAllMessages::StartL(TRequestStatus& aStatus) |
|
1992 { |
|
1993 iSelection.Reset(); |
|
1994 iTestUtils.iMsvEntry->SetEntryL(iParentFolder); |
|
1995 |
|
1996 CMsvEntrySelection* tempSelection = iTestUtils.iMsvEntry->ChildrenL(); |
|
1997 CleanupStack::PushL(tempSelection); |
|
1998 // Copy the child entries to the given selection |
|
1999 TInt index = tempSelection->Count(); |
|
2000 while (index--) |
|
2001 { |
|
2002 iSelection.AppendL((*tempSelection)[index]); |
|
2003 } |
|
2004 CleanupStack::PopAndDestroy(tempSelection); |
|
2005 |
|
2006 TRequestStatus* status = &aStatus; |
|
2007 User::RequestComplete(status, KErrNone); |
|
2008 } |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 |
|
2014 // |
|
2015 // |
|
2016 // CLongWait |
|
2017 // |
|
2018 CLongWait::CLongWait() |
|
2019 : CActive(EPriorityNormal), |
|
2020 iWaitTime(KDefaultWaitTime) |
|
2021 { |
|
2022 CActiveScheduler::Add(this); |
|
2023 } |
|
2024 |
|
2025 CLongWait::CLongWait(TInt aWaitTime) |
|
2026 : CActive(EPriorityNormal) |
|
2027 { |
|
2028 iWaitTime = aWaitTime * 1000000; |
|
2029 CActiveScheduler::Add(this); |
|
2030 } |
|
2031 |
|
2032 CLongWait::~CLongWait() |
|
2033 { |
|
2034 delete iTimer; |
|
2035 } |
|
2036 |
|
2037 void CLongWait::StartL(TRequestStatus& aStatus) |
|
2038 { |
|
2039 delete iTimer; |
|
2040 iTimer = 0; |
|
2041 iTimer = CTestTimer::NewL(); |
|
2042 iReportStatus = &aStatus; |
|
2043 iTimer->AfterReq(iWaitTime, iStatus); |
|
2044 aStatus = KRequestPending; |
|
2045 SetActive(); |
|
2046 } |
|
2047 |
|
2048 |
|
2049 |
|
2050 void CLongWait::RunL() |
|
2051 { |
|
2052 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
2053 } |
|
2054 |
|
2055 void CLongWait::DoCancel() |
|
2056 { |
|
2057 } |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 |
|
2066 |
|
2067 // |
|
2068 // |
|
2069 // CCreateEmailMessage |
|
2070 // |
|
2071 |
|
2072 CCreateEmailMessage::CCreateEmailMessage(const TMsvId& aFolderId, const TMsvId& aServiceId, const TDesC& aFileName, CEmailTestUtils& aTestUtils,TInt aHowMany) : CActive(EPriorityNormal), iCurrentFolderId(aFolderId), iServiceId(aServiceId), iTestUtils(aTestUtils), iHowMany(aHowMany) |
|
2073 { |
|
2074 CActiveScheduler::Add(this); |
|
2075 iFileName = aFileName; |
|
2076 } |
|
2077 |
|
2078 void CCreateEmailMessage::StartL(TRequestStatus& aStatus) |
|
2079 { |
|
2080 // Close down the client side session and wait a few seconds |
|
2081 iTestUtils.Reset(); |
|
2082 delete iTimer; |
|
2083 iTimer = 0; |
|
2084 iTimer = CTestTimer::NewL(); |
|
2085 iReportStatus = &aStatus; |
|
2086 iTimer->AfterReq(5000000, iStatus); |
|
2087 aStatus = KRequestPending; |
|
2088 iState = ECreateEmailWait1; |
|
2089 SetActive(); |
|
2090 } |
|
2091 |
|
2092 void CCreateEmailMessage::RunL() |
|
2093 { |
|
2094 TInt i; |
|
2095 switch (iState) |
|
2096 { |
|
2097 case ECreateEmailWait1: |
|
2098 iTestUtils.GoServerSideL(); |
|
2099 // We should be on the server side now, so we can create the message |
|
2100 for (i=0; i<iHowMany; i++) |
|
2101 iTestUtils.CreateMessageL(iFileName, iServiceId, iCurrentFolderId); |
|
2102 |
|
2103 // Now go back to the client side and wait a few seconds. |
|
2104 iTestUtils.GoClientSideL(); |
|
2105 iTimer->AfterReq(5000000, iStatus); |
|
2106 iState = ECreateEmailWait2; |
|
2107 SetActive(); |
|
2108 break; |
|
2109 case ECreateEmailWait2: |
|
2110 // We should be safely back on the client side so we can continue. |
|
2111 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
2112 break; |
|
2113 }; |
|
2114 } |
|
2115 |
|
2116 void CCreateEmailMessage::DoCancel() |
|
2117 { |
|
2118 } |
|
2119 |
|
2120 CCreateEmailMessage::~CCreateEmailMessage() |
|
2121 { |
|
2122 if (iTimer) |
|
2123 { |
|
2124 iTimer->Cancel(); |
|
2125 } |
|
2126 delete iTimer; |
|
2127 } |
|
2128 |
|
2129 // |
|
2130 // |
|
2131 // CCopySelection |
|
2132 // |
|
2133 |
|
2134 CCopySelection::CCopySelection(CMsvClientTest& aParentTestHarness) : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness) |
|
2135 { |
|
2136 CActiveScheduler::Add(this); |
|
2137 } |
|
2138 |
|
2139 void CCopySelection::StartL(TRequestStatus& aStatus) |
|
2140 { |
|
2141 iParentTestHarness.MsvTestUtils().iMsvEntry->SetEntryL(iParentTestHarness.iSelectedFolder); |
|
2142 iReportStatus = &aStatus; |
|
2143 iParentTestHarness.SetCurrentOperation(iParentTestHarness.MsvTestUtils().iMsvEntry->CopyL(*(iParentTestHarness.iCurrentSelection), iParentTestHarness.iDestinationFolder, iStatus)); |
|
2144 aStatus = KRequestPending; |
|
2145 SetActive(); |
|
2146 } |
|
2147 |
|
2148 void CCopySelection::RunL() |
|
2149 { |
|
2150 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
2151 } |
|
2152 |
|
2153 void CCopySelection::DoCancel() |
|
2154 { |
|
2155 iParentTestHarness.CurrentOperation().Cancel(); |
|
2156 } |
|
2157 |
|
2158 |
|
2159 CCopySelection::~CCopySelection() |
|
2160 { |
|
2161 } |
|
2162 |
|
2163 |
|
2164 |
|
2165 // |
|
2166 // |
|
2167 // CMoveSelection |
|
2168 // |
|
2169 |
|
2170 CMoveSelection::CMoveSelection(CMsvClientTest& aParentTestHarness) : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness) |
|
2171 { |
|
2172 CActiveScheduler::Add(this); |
|
2173 } |
|
2174 |
|
2175 void CMoveSelection::StartL(TRequestStatus& aStatus) |
|
2176 { |
|
2177 iParentTestHarness.MsvTestUtils().iMsvEntry->SetEntryL(iParentTestHarness.iSelectedFolder); |
|
2178 iReportStatus = &aStatus; |
|
2179 iParentTestHarness.SetCurrentOperation(iParentTestHarness.MsvTestUtils().iMsvEntry->MoveL(*(iParentTestHarness.iCurrentSelection), iParentTestHarness.iDestinationFolder, iStatus)); |
|
2180 aStatus = KRequestPending; |
|
2181 SetActive(); |
|
2182 } |
|
2183 void CMoveSelection::RunL() |
|
2184 { |
|
2185 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
2186 } |
|
2187 |
|
2188 void CMoveSelection::DoCancel() |
|
2189 { |
|
2190 iParentTestHarness.CurrentOperation().Cancel(); |
|
2191 } |
|
2192 |
|
2193 |
|
2194 CMoveSelection::~CMoveSelection() |
|
2195 { |
|
2196 } |
|
2197 |
|
2198 |
|
2199 // |
|
2200 // |
|
2201 // CDeleteSelection |
|
2202 // |
|
2203 |
|
2204 CDeleteSelection::CDeleteSelection(CMsvClientTest& aParentTestHarness) : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness) |
|
2205 { |
|
2206 CActiveScheduler::Add(this); |
|
2207 } |
|
2208 |
|
2209 void CDeleteSelection::StartL(TRequestStatus& aStatus) |
|
2210 { |
|
2211 if (iParentTestHarness.iCurrentSelection->Count() == 0) |
|
2212 // If there are no entries currently selected then complete without an error |
|
2213 { |
|
2214 TRequestStatus* status = &aStatus; |
|
2215 User::RequestComplete(status, KErrNone); |
|
2216 } |
|
2217 else |
|
2218 // If there are some selected messages then delete them. |
|
2219 { |
|
2220 CMsvEntry& sharedCMsvEntry = *(iParentTestHarness.MsvTestUtils().iMsvEntry); |
|
2221 |
|
2222 // Set the CMsvEntry to point to the folder selected by the parent test harness |
|
2223 sharedCMsvEntry.SetEntryL(iParentTestHarness.iSelectedFolder); |
|
2224 |
|
2225 iReportStatus = &aStatus; |
|
2226 |
|
2227 // Start the delete operation |
|
2228 CMsvOperation* deleteOperaiton= sharedCMsvEntry.DeleteL(*(iParentTestHarness.iCurrentSelection), iStatus); |
|
2229 |
|
2230 // Set the current delete operation to be the current operation on the parent test harness |
|
2231 iParentTestHarness.SetCurrentOperation(deleteOperaiton); |
|
2232 aStatus = KRequestPending; |
|
2233 SetActive(); |
|
2234 } |
|
2235 } |
|
2236 |
|
2237 void CDeleteSelection::RunL() |
|
2238 { |
|
2239 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
2240 } |
|
2241 |
|
2242 void CDeleteSelection::DoCancel() |
|
2243 { |
|
2244 iParentTestHarness.CurrentOperation().Cancel(); |
|
2245 } |
|
2246 |
|
2247 |
|
2248 CDeleteSelection::~CDeleteSelection() |
|
2249 { |
|
2250 } |
|
2251 |
|
2252 |
|
2253 // |
|
2254 // |
|
2255 // CDeleteChildren |
|
2256 // |
|
2257 |
|
2258 CDeleteChildren::CDeleteChildren(CMsvClientTest& aParentTestHarness, TInt aSelectedIndex) |
|
2259 : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness), iSelectedIndex(aSelectedIndex) |
|
2260 { |
|
2261 CActiveScheduler::Add(this); |
|
2262 } |
|
2263 |
|
2264 void CDeleteChildren::StartL(TRequestStatus& aStatus) |
|
2265 // Deletes the children of this entry |
|
2266 { |
|
2267 CMsvEntry& msvEntry = *(iParentTestHarness.MsvTestUtils().iMsvEntry); |
|
2268 CMsvEntrySelection& selection = *(iParentTestHarness.iCurrentSelection); |
|
2269 TMsvId entryId = selection.At(iSelectedIndex); |
|
2270 msvEntry.SetEntryL(entryId); |
|
2271 |
|
2272 iReportStatus = &aStatus; |
|
2273 |
|
2274 selection.Reset(); |
|
2275 CMsvEntrySelection* tempSelection = msvEntry.ChildrenL(); |
|
2276 CleanupStack::PushL(tempSelection); |
|
2277 // Copy the child entries to the given selection |
|
2278 TInt index = tempSelection->Count(); |
|
2279 while (index--) |
|
2280 { |
|
2281 selection.AppendL((*tempSelection)[index]); |
|
2282 } |
|
2283 CleanupStack::PopAndDestroy(tempSelection); |
|
2284 |
|
2285 if (selection.Count() == 0) |
|
2286 // If the entry has no children then complete without an error |
|
2287 { |
|
2288 TRequestStatus* status = &aStatus; |
|
2289 User::RequestComplete(status, KErrNone); |
|
2290 } |
|
2291 else |
|
2292 // If the entry has children then delete them. |
|
2293 { |
|
2294 // Start the delete operation |
|
2295 CMsvOperation* deleteOperaiton= msvEntry.DeleteL(selection, iStatus); |
|
2296 |
|
2297 // Set the current delete operation to be the current operation on the parent test harness |
|
2298 iParentTestHarness.SetCurrentOperation(deleteOperaiton); |
|
2299 aStatus = KRequestPending; |
|
2300 SetActive(); |
|
2301 } |
|
2302 } |
|
2303 |
|
2304 void CDeleteChildren::RunL() |
|
2305 { |
|
2306 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
2307 } |
|
2308 |
|
2309 void CDeleteChildren::DoCancel() |
|
2310 { |
|
2311 iParentTestHarness.CurrentOperation().Cancel(); |
|
2312 } |
|
2313 |
|
2314 CDeleteChildren::~CDeleteChildren() |
|
2315 { |
|
2316 } |
|
2317 |