|
1 // Copyright (c) 2003-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 "commands.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(KErrSelectText, "Error! Cannot find entry '%S'.\n"); |
|
24 |
|
25 const TInt KDefaultWaitTime = 5000000; |
|
26 |
|
27 |
|
28 class TLineReader : public CBase |
|
29 { |
|
30 private: |
|
31 RFile& iFile; |
|
32 TBuf8<512> iBuffer; |
|
33 TInt iBufferIndex; |
|
34 |
|
35 TBool Peek(char& rChar) |
|
36 { |
|
37 TBool characterFound = ETrue; |
|
38 if (iBufferIndex == iBuffer.Size()) |
|
39 { |
|
40 // Refresh buffer |
|
41 TInt readError = iFile.Read(iBuffer); |
|
42 iBufferIndex = 0; |
|
43 if ((readError != KErrNone) || (iBuffer.Size() == 0)) |
|
44 { |
|
45 characterFound = EFalse; |
|
46 } |
|
47 } |
|
48 |
|
49 if (characterFound) |
|
50 { |
|
51 rChar = iBuffer[iBufferIndex]; |
|
52 } |
|
53 |
|
54 return characterFound; |
|
55 }; |
|
56 |
|
57 TBool GetCharacter(char& rChar) |
|
58 { |
|
59 TBool characterFound = Peek(rChar); |
|
60 if (characterFound) |
|
61 { |
|
62 iBufferIndex++; |
|
63 } |
|
64 |
|
65 return characterFound; |
|
66 } |
|
67 |
|
68 public: |
|
69 TLineReader(RFile& rFile) : iFile(rFile), iBufferIndex(0) |
|
70 {}; |
|
71 |
|
72 HBufC8* GetLineLC() |
|
73 { |
|
74 // Find next cr or lf (and ignore subsequent cr's or lf's) |
|
75 HBufC8* newLine = HBufC8::NewLC(512); |
|
76 |
|
77 char ch; |
|
78 |
|
79 TBool characterFound = GetCharacter(ch); |
|
80 TBool eolFound = EFalse; |
|
81 |
|
82 while ((characterFound) && (!eolFound)) |
|
83 { |
|
84 if ((ch == 0x0d) || (ch == 0x0a)) |
|
85 // cr or lf found, ignore subsequent cr and lf's |
|
86 { |
|
87 eolFound = ETrue; |
|
88 while ((characterFound) && ((ch == 0x0d) || (ch == 0x0a))) |
|
89 { |
|
90 characterFound = Peek(ch); |
|
91 if ((characterFound) && ((ch == 0x0d) || (ch == 0x0a))) |
|
92 { |
|
93 characterFound = GetCharacter(ch); |
|
94 } |
|
95 } |
|
96 } |
|
97 |
|
98 if ((characterFound) && (!eolFound)) |
|
99 { |
|
100 newLine->Des().Append(ch); |
|
101 characterFound = GetCharacter(ch); |
|
102 } |
|
103 } |
|
104 |
|
105 return newLine; |
|
106 }; |
|
107 }; |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 // |
|
113 // |
|
114 // CMsvTestCleanMessageFolder |
|
115 // |
|
116 |
|
117 EXPORT_C void CCleanMessageFolder::StartL(TRequestStatus& aStatus) |
|
118 { |
|
119 TRAPD(err, iTestUtils.CleanMessageFolderL()); |
|
120 TRequestStatus* status = &aStatus; |
|
121 User::RequestComplete(status, err); |
|
122 } |
|
123 |
|
124 EXPORT_C CCleanMessageFolder::CCleanMessageFolder(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
125 { |
|
126 } |
|
127 |
|
128 |
|
129 // |
|
130 // |
|
131 // CAddComment |
|
132 // |
|
133 |
|
134 EXPORT_C CAddComment* CAddComment::NewL(const CDesCArrayFlat& aComment, CMsvTestUtils& aTestUtils) |
|
135 { |
|
136 CAddComment* self = new (ELeave) CAddComment(aTestUtils); |
|
137 CleanupStack::PushL(self); |
|
138 self->ConstructL(aComment); |
|
139 CleanupStack::Pop(self); |
|
140 return self; |
|
141 } |
|
142 |
|
143 void CAddComment::ConstructL(const CDesCArrayFlat& aComment) |
|
144 { |
|
145 // need to construct one big HBufC string to use as the comment |
|
146 // first, find out size of array... |
|
147 TInt commentSize = 0; |
|
148 for(TInt i = 0; i < aComment.Count(); i++) |
|
149 commentSize += ((aComment[i]).Length() + _L(" ").Size()); // extra 1 added for padding between words. |
|
150 |
|
151 // second, construct HBufC.... |
|
152 iComment = HBufC::NewL(commentSize); |
|
153 |
|
154 // create a pointer to the HBufC, so that we can add text to it. |
|
155 TPtr commentPtr = iComment->Des(); |
|
156 |
|
157 // now create string |
|
158 for(TInt j = 0; j < aComment.Count(); j++) |
|
159 { |
|
160 commentPtr.Append((aComment)[j]); |
|
161 commentPtr.Append(_L(" ")); // extra 1 added for padding between words. |
|
162 } |
|
163 |
|
164 // hopefully everything should be added ok! |
|
165 } |
|
166 |
|
167 EXPORT_C void CAddComment::StartL(TRequestStatus& aStatus) |
|
168 { |
|
169 // now we have to add the debugging line number which we only know at run time... |
|
170 TBuf<7> commentString; |
|
171 commentString.Format(_L("[%4d] "), iDebugInfo.LineNumber()); |
|
172 |
|
173 // create a pointer to the HBufC, realloc size and then insert new data... |
|
174 iComment = iComment->ReAllocL(iComment->Size() + commentString.Size()); |
|
175 TPtr commentPtr = iComment->Des(); |
|
176 commentPtr.Insert(0, commentString); |
|
177 |
|
178 iTestUtils.WriteComment(*iComment); |
|
179 |
|
180 TRequestStatus* status = &aStatus; |
|
181 User::RequestComplete(status, KErrNone); |
|
182 } |
|
183 |
|
184 CAddComment::CAddComment(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
185 { |
|
186 } |
|
187 |
|
188 EXPORT_C CAddComment::~CAddComment() |
|
189 { |
|
190 delete iComment; |
|
191 } |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 // |
|
197 // |
|
198 // CGoClientSide |
|
199 // |
|
200 |
|
201 EXPORT_C void CGoClientSide::StartL(TRequestStatus& aStatus) |
|
202 { |
|
203 iTestUtils.GoClientSideL(); |
|
204 TRequestStatus* status = &aStatus; |
|
205 User::RequestComplete(status, KErrNone); |
|
206 } |
|
207 |
|
208 EXPORT_C CGoClientSide::CGoClientSide(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
209 {} |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 // |
|
215 // |
|
216 // CGoServerSide |
|
217 // |
|
218 |
|
219 EXPORT_C void CGoServerSide::StartL(TRequestStatus& aStatus) |
|
220 { |
|
221 iTestUtils.GoServerSideL(); |
|
222 TRequestStatus* status = &aStatus; |
|
223 User::RequestComplete(status, KErrNone); |
|
224 } |
|
225 |
|
226 EXPORT_C CGoServerSide::CGoServerSide(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
227 {} |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 // |
|
233 // |
|
234 // CResetMessageServer |
|
235 // |
|
236 |
|
237 EXPORT_C void CResetMessageServer::StartL(TRequestStatus& aStatus) |
|
238 { |
|
239 iParentTestHarness.Reset(); |
|
240 TRequestStatus* status = &aStatus; |
|
241 User::RequestComplete(status, KErrNone); |
|
242 } |
|
243 |
|
244 EXPORT_C CResetMessageServer::CResetMessageServer(CMsvClientTest& aParentTestHarness) |
|
245 : iParentTestHarness(aParentTestHarness) |
|
246 {} |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 // |
|
254 // |
|
255 // CCheckMessageFolder |
|
256 // |
|
257 |
|
258 EXPORT_C void CCheckMessageFolder::StartL(TRequestStatus& aStatus) |
|
259 { |
|
260 TBool matched = ETrue; |
|
261 iTestUtils.FindChildrenL(0x01000, ETrue); |
|
262 |
|
263 RFile file1; |
|
264 User::LeaveIfError(file1.Open(iTestUtils.FileSession(), K_T_MSG_STRUCT_FILE, EFileShareAny)); |
|
265 |
|
266 RFile file2; |
|
267 User::LeaveIfError(file2.Open(iTestUtils.FileSession(), iFileName, EFileShareAny)); |
|
268 |
|
269 TLineReader lineReader1(file1); |
|
270 TLineReader lineReader2(file2); |
|
271 |
|
272 HBufC8* actualLine = lineReader1.GetLineLC(); |
|
273 HBufC8* expectedLine = lineReader2.GetLineLC(); |
|
274 |
|
275 while ((actualLine->Des().Size() > 0) && (expectedLine->Des().Size() > 0) && (matched)) |
|
276 { |
|
277 if (actualLine->Des() != expectedLine->Des()) |
|
278 matched = EFalse; |
|
279 |
|
280 CleanupStack::PopAndDestroy(2); // actualLine, expectedLinw |
|
281 |
|
282 actualLine = lineReader1.GetLineLC(); |
|
283 expectedLine = lineReader2.GetLineLC(); |
|
284 } |
|
285 |
|
286 if ((actualLine->Des().Size() != 0) |
|
287 || (expectedLine->Des().Size() != 0)) |
|
288 { |
|
289 matched = EFalse; |
|
290 } |
|
291 |
|
292 CleanupStack::PopAndDestroy(2); // actualLine, expectedLinw |
|
293 |
|
294 if (!matched) |
|
295 { |
|
296 User::Leave(KErrNotFound); |
|
297 } |
|
298 |
|
299 file1.Close(); |
|
300 file2.Close(); |
|
301 |
|
302 TRequestStatus* status = &aStatus; |
|
303 User::RequestComplete(status, KErrNone); |
|
304 } |
|
305 |
|
306 EXPORT_C CCheckMessageFolder::CCheckMessageFolder(const TDesC& aFileName, CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
307 { |
|
308 iFileName = aFileName; |
|
309 } |
|
310 |
|
311 |
|
312 |
|
313 // |
|
314 // |
|
315 // CSelectEntry |
|
316 // |
|
317 |
|
318 CSelectEntry::CSelectEntry(const TMsvId& aCurrentFolderId, TMsvId* aEntryId, CMsvTestUtils& aTestUtils) |
|
319 : iTestUtils(aTestUtils), |
|
320 iCurrentFolderId(aCurrentFolderId), |
|
321 iEntryId(aEntryId) |
|
322 { |
|
323 iEntrySelection = NULL; |
|
324 } |
|
325 |
|
326 CSelectEntry::CSelectEntry(const TMsvId& aCurrentFolderId, CMsvEntrySelection* aSelection, CMsvTestUtils& aTestUtils) |
|
327 : iTestUtils(aTestUtils), |
|
328 iCurrentFolderId(aCurrentFolderId), |
|
329 iEntrySelection(aSelection) |
|
330 { |
|
331 iEntryId = NULL; |
|
332 } |
|
333 |
|
334 EXPORT_C CSelectEntry* CSelectEntry::NewL(const TDesC& aName, const TMsvId& aCurrentFolderId, TMsvId* aEntryId, CMsvTestUtils& aTestUtils) |
|
335 { |
|
336 CSelectEntry* self = new (ELeave) CSelectEntry(aCurrentFolderId, aEntryId, aTestUtils); |
|
337 CleanupStack::PushL(self); |
|
338 self->ConstructL(aName); |
|
339 CleanupStack::Pop(self); |
|
340 return self; |
|
341 } |
|
342 |
|
343 EXPORT_C CSelectEntry* CSelectEntry::NewL(const TDesC& aName, const TMsvId& aCurrentFolderId, CMsvEntrySelection* aSelection, CMsvTestUtils& aTestUtils) |
|
344 { |
|
345 CSelectEntry* self = new (ELeave) CSelectEntry(aCurrentFolderId, aSelection, aTestUtils); |
|
346 CleanupStack::PushL(self); |
|
347 self->ConstructL(aName); |
|
348 CleanupStack::Pop(self); |
|
349 return self; |
|
350 } |
|
351 |
|
352 void CSelectEntry::ConstructL(const TDesC& aName) |
|
353 { |
|
354 iEntryName = HBufC::NewL(aName.Length()); |
|
355 (*iEntryName) = aName; |
|
356 } |
|
357 |
|
358 EXPORT_C void CSelectEntry::StartL(TRequestStatus& aStatus) |
|
359 { |
|
360 // Select current folder |
|
361 CMsvEntry& entry = *(iTestUtils.iMsvEntry); |
|
362 entry.SetEntryL(iCurrentFolderId); |
|
363 |
|
364 // show the invisible folders..... |
|
365 TMsvSelectionOrdering order; |
|
366 order.SetShowInvisibleEntries(ETrue); |
|
367 entry.SetSortTypeL(order); |
|
368 |
|
369 CMsvEntrySelection* tempSelection = entry.ChildrenL(); |
|
370 CleanupStack::PushL(tempSelection); |
|
371 |
|
372 // Check each child entry for a matching string |
|
373 TBool found = EFalse; |
|
374 TInt entryIndex = tempSelection->Count(); |
|
375 while ((!found) && (entryIndex-- != 0)) |
|
376 { |
|
377 entry.SetEntryL((*tempSelection)[entryIndex]); |
|
378 if (iEntryName->CompareF(entry.Entry().iDescription) == 0) |
|
379 { |
|
380 found = ETrue; |
|
381 } |
|
382 else if (iEntryName->CompareF(entry.Entry().iDetails) == 0) |
|
383 { |
|
384 found = ETrue; |
|
385 } |
|
386 } |
|
387 |
|
388 if (found) |
|
389 { |
|
390 // decide if its a Selection thats required, or an Entry |
|
391 if(iEntryId) |
|
392 { |
|
393 *iEntryId = entry.Entry().Id(); |
|
394 } |
|
395 else |
|
396 { |
|
397 (*iEntrySelection).Reset(); |
|
398 (*iEntrySelection).AppendL(entry.Entry().Id()); |
|
399 } |
|
400 |
|
401 TRequestStatus* status = &aStatus; |
|
402 User::RequestComplete(status, KErrNone); |
|
403 } |
|
404 else |
|
405 { |
|
406 TBuf<256> errorString; |
|
407 errorString.Format(KErrSelectText, iEntryName); |
|
408 HBufC* errorStringHBufC = HBufC::NewLC(errorString.Length()); |
|
409 (errorStringHBufC->Des()).Copy(errorString); |
|
410 |
|
411 iTestUtils.WriteComment(*errorStringHBufC); |
|
412 CleanupStack::PopAndDestroy(); |
|
413 |
|
414 TRequestStatus* status = &aStatus; |
|
415 User::RequestComplete(status, KErrNotFound); |
|
416 } |
|
417 |
|
418 CleanupStack::PopAndDestroy(tempSelection); |
|
419 } |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 EXPORT_C CSelectEntry::~CSelectEntry() |
|
425 { |
|
426 delete iEntryName; |
|
427 } |
|
428 /* |
|
429 CSelectEntry::CSelectEntry(const TMsvId& aCurrentFolderId, TMsvId& aEntryId, CMsvTestUtils& aTestUtils) : iCurrentFolderId(aCurrentFolderId), iTestUtils(aTestUtils), iEntryId(aEntryId) |
|
430 { |
|
431 } |
|
432 |
|
433 |
|
434 CSelectEntry* CSelectEntry::NewL(const TDesC& aName, const TMsvId& aCurrentFolderId, TMsvId& aEntryId, CMsvTestUtils& aTestUtils) |
|
435 { |
|
436 CSelectEntry* self = new (ELeave) CSelectEntry(aCurrentFolderId, aEntryId, aTestUtils); |
|
437 CleanupStack::PushL(self); |
|
438 self->ConstructL(aName); |
|
439 CleanupStack::Pop(self); |
|
440 return self; |
|
441 } |
|
442 |
|
443 void CSelectEntry::ConstructL(const TDesC& aName) |
|
444 { |
|
445 iEntryName = HBufC::NewL(aName.Length()); |
|
446 (*iEntryName) = aName; |
|
447 } |
|
448 |
|
449 void CSelectEntry::StartL(TRequestStatus& aStatus) |
|
450 { |
|
451 // Select current folder |
|
452 CMsvEntry& entry = *(iTestUtils.iMsvEntry); |
|
453 entry.SetEntryL(iCurrentFolderId); |
|
454 |
|
455 // show the invisible folders..... |
|
456 TMsvSelectionOrdering order; |
|
457 order.SetShowInvisibleEntries(ETrue); |
|
458 entry.SetSortTypeL(order); |
|
459 |
|
460 CMsvEntrySelection* tempSelection = entry.ChildrenL(); |
|
461 CleanupStack::PushL(tempSelection); |
|
462 |
|
463 // Check each child entry for a matching string |
|
464 TBool found = EFalse; |
|
465 TInt entryIndex = tempSelection->Count(); |
|
466 while ((!found) && (entryIndex-- != 0)) |
|
467 { |
|
468 entry.SetEntryL((*tempSelection)[entryIndex]); |
|
469 if (iEntryName->CompareF(entry.Entry().iDescription) == 0) |
|
470 { |
|
471 found = ETrue; |
|
472 } |
|
473 else if (iEntryName->CompareF(entry.Entry().iDetails) == 0) |
|
474 { |
|
475 found = ETrue; |
|
476 } |
|
477 } |
|
478 |
|
479 if (found) |
|
480 { |
|
481 iEntryId = entry.Entry().Id(); |
|
482 |
|
483 TRequestStatus* status = &aStatus; |
|
484 User::RequestComplete(status, KErrNone); |
|
485 } |
|
486 else |
|
487 { |
|
488 TBuf<256> errorString; |
|
489 errorString.Format(KErrSelectText, iEntryName); |
|
490 HBufC* errorStringHBufC = HBufC::NewLC(errorString.Length()); |
|
491 (errorStringHBufC->Des()).Copy(errorString); |
|
492 |
|
493 iTestUtils.WriteComment(*errorStringHBufC); |
|
494 CleanupStack::PopAndDestroy(); |
|
495 |
|
496 TRequestStatus* status = &aStatus; |
|
497 User::RequestComplete(status, KErrNotFound); |
|
498 } |
|
499 |
|
500 CleanupStack::PopAndDestroy(tempSelection); |
|
501 } |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 CSelectEntry::~CSelectEntry() |
|
507 { |
|
508 delete iEntryName; |
|
509 } |
|
510 */ |
|
511 |
|
512 // |
|
513 // |
|
514 // CDumpMessageStore |
|
515 // |
|
516 |
|
517 EXPORT_C void CDumpMessageStore::StartL(TRequestStatus& aStatus) |
|
518 { |
|
519 iTestUtils.FindChildrenL(KMsvRootIndexEntryId); |
|
520 TRequestStatus* status = &aStatus; |
|
521 User::RequestComplete(status, KErrNone); |
|
522 } |
|
523 |
|
524 EXPORT_C CDumpMessageStore::CDumpMessageStore(CMsvTestUtils& aTestUtils) : iTestUtils(aTestUtils) |
|
525 { |
|
526 } |
|
527 |
|
528 // |
|
529 // |
|
530 // CCheckSelectionCount |
|
531 // |
|
532 |
|
533 EXPORT_C CCheckSelectionCount::CCheckSelectionCount(TInt aCount, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
534 : iTestUtils(aTestUtils), |
|
535 iSelection(aSelection), |
|
536 iTestCount(aCount) |
|
537 { |
|
538 } |
|
539 |
|
540 void CCheckSelectionCount::LogCommentFormatL(TRefByValue<const TDesC> format,...) |
|
541 { |
|
542 // Build parameter list. |
|
543 VA_LIST list; |
|
544 VA_START(list, format); |
|
545 TBuf<0x100> buf; |
|
546 buf.FormatList(format, list); |
|
547 |
|
548 // Log the debug buffer. |
|
549 iTestUtils.WriteComment(buf); |
|
550 } |
|
551 |
|
552 EXPORT_C void CCheckSelectionCount::StartL(TRequestStatus& aStatus) |
|
553 { |
|
554 TInt err=KErrNone; |
|
555 TInt selectionCount=iSelection.Count(); |
|
556 |
|
557 LogCommentFormatL(_L("[%4d] Folder contains %d entries when %d expected."), iDebugInfo.LineNumber(), selectionCount, iTestCount); |
|
558 |
|
559 if (selectionCount != iTestCount) |
|
560 { |
|
561 LogCommentFormatL(_L("Error!")); |
|
562 err = KErrUnknown; |
|
563 } |
|
564 |
|
565 TRequestStatus* status = &aStatus; |
|
566 User::RequestComplete(status, err); |
|
567 } |
|
568 |
|
569 |
|
570 // |
|
571 // |
|
572 // CCheckNewFlag |
|
573 // |
|
574 |
|
575 EXPORT_C CCheckNewFlag::CCheckNewFlag(TInt aSelectedIndex, TBool aTestNewStatus, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
576 :iTestUtils(aTestUtils), |
|
577 iSelection(aSelection), |
|
578 iSelectedIndex(aSelectedIndex), |
|
579 iTestNewStatus(aTestNewStatus) |
|
580 { |
|
581 } |
|
582 |
|
583 void CCheckNewFlag::LogCommentFormatL(TRefByValue<const TDesC> format,...) |
|
584 { |
|
585 // Build parameter list. |
|
586 VA_LIST list; |
|
587 VA_START(list, format); |
|
588 TBuf<0x100> buf; |
|
589 buf.FormatList(format, list); |
|
590 |
|
591 // Log the debug buffer. |
|
592 iTestUtils.WriteComment(buf); |
|
593 } |
|
594 |
|
595 EXPORT_C void CCheckNewFlag::StartL(TRequestStatus& aStatus) |
|
596 // Check the status flag of the selected entry is the same as the test value |
|
597 { |
|
598 TInt err=KErrNone; |
|
599 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
600 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
601 msvEntry.SetEntryL(entryId); |
|
602 TBool entryIsNew = msvEntry.Entry().New(); |
|
603 |
|
604 // Check if the Entry is New |
|
605 if (entryIsNew) |
|
606 { |
|
607 // Check if the entry Should be New |
|
608 if (iTestNewStatus) |
|
609 { |
|
610 // The entry is new |
|
611 _LIT(KNewEntry, "Entry %d is New"); |
|
612 LogCommentFormatL(KNewEntry, iSelectedIndex); |
|
613 } |
|
614 else |
|
615 { |
|
616 // The Entry is New, but is should be old |
|
617 _LIT(KErrNewEntry, "Error, the entry is New. It should be Old!"); |
|
618 LogCommentFormatL(KErrNewEntry); |
|
619 err = KErrUnknown; |
|
620 } |
|
621 |
|
622 } |
|
623 else |
|
624 { |
|
625 // The Entry is Old. Check if it should be. |
|
626 if (!iTestNewStatus) |
|
627 { |
|
628 // The entry is Old |
|
629 _LIT(KOldEntry, "Entry %d is Old"); |
|
630 LogCommentFormatL(KOldEntry, iSelectedIndex); |
|
631 } |
|
632 else |
|
633 { |
|
634 // The Entry is Old, but is should be New |
|
635 _LIT(KErrOldEntry, "Error, the entry is Old. It should be New!"); |
|
636 LogCommentFormatL(KErrOldEntry); |
|
637 err = KErrUnknown; |
|
638 } |
|
639 } |
|
640 |
|
641 TRequestStatus* status = &aStatus; |
|
642 User::RequestComplete(status, err); |
|
643 } |
|
644 |
|
645 |
|
646 |
|
647 // |
|
648 // |
|
649 // CCheckPriority |
|
650 // |
|
651 |
|
652 EXPORT_C CCheckPriority::CCheckPriority(TInt aSelectedIndex, TInt aTestPriority, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
653 :iTestUtils(aTestUtils), |
|
654 iSelection(aSelection), |
|
655 iSelectedIndex(aSelectedIndex), |
|
656 iTestPriority(aTestPriority) |
|
657 { |
|
658 } |
|
659 |
|
660 void CCheckPriority::LogCommentFormatL(TRefByValue<const TDesC> format,...) |
|
661 { |
|
662 // Build parameter list. |
|
663 VA_LIST list; |
|
664 VA_START(list, format); |
|
665 TBuf<0x100> buf; |
|
666 buf.FormatList(format, list); |
|
667 |
|
668 // Log the debug buffer. |
|
669 iTestUtils.WriteComment(buf); |
|
670 } |
|
671 |
|
672 EXPORT_C void CCheckPriority::StartL(TRequestStatus& aStatus) |
|
673 // Check the Priority flag of the selected entry is the same as the test value |
|
674 { |
|
675 TInt err=KErrNone; |
|
676 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
677 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
678 msvEntry.SetEntryL(entryId); |
|
679 TMsvPriority priority = msvEntry.Entry().Priority(); |
|
680 |
|
681 // Check if the Priority flag is correct |
|
682 if (priority == iTestPriority) |
|
683 { |
|
684 // Correct Priority |
|
685 _LIT(KCorrectPriority, "Entry %d has Priority %d"); |
|
686 LogCommentFormatL(KCorrectPriority, entryId, priority); |
|
687 } |
|
688 else |
|
689 { |
|
690 _LIT(KInCorrectPriority, "Error, Entry %d has Priority %d"); |
|
691 LogCommentFormatL(KInCorrectPriority, entryId, priority); |
|
692 err = KErrUnknown; |
|
693 } |
|
694 |
|
695 TRequestStatus* status = &aStatus; |
|
696 User::RequestComplete(status, err); |
|
697 } |
|
698 |
|
699 |
|
700 |
|
701 // |
|
702 // |
|
703 // CCheckAttachment |
|
704 // |
|
705 |
|
706 EXPORT_C CCheckAttachment::CCheckAttachment(TInt aSelectedIndex, TBool aTestAttachment, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
707 :iTestUtils(aTestUtils), |
|
708 iSelection(aSelection), |
|
709 iSelectedIndex(aSelectedIndex), |
|
710 iTestAttachment(aTestAttachment) |
|
711 { |
|
712 } |
|
713 |
|
714 void CCheckAttachment::LogCommentFormatL(TRefByValue<const TDesC> format,...) |
|
715 { |
|
716 // Build parameter list. |
|
717 VA_LIST list; |
|
718 VA_START(list, format); |
|
719 TBuf<0x100> buf; |
|
720 buf.FormatList(format, list); |
|
721 |
|
722 // Log the debug buffer. |
|
723 iTestUtils.WriteComment(buf); |
|
724 } |
|
725 |
|
726 EXPORT_C void CCheckAttachment::StartL(TRequestStatus& aStatus) |
|
727 // Check the attachment flag for this entry is the same as the test value |
|
728 { |
|
729 TInt err=KErrNone; |
|
730 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
731 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
732 msvEntry.SetEntryL(entryId); |
|
733 TBool entryHasAttachment = EFalse; |
|
734 |
|
735 // Find out if the Entry has an attachment |
|
736 // See if the Entry has a Child Folder Entry |
|
737 CMsvEntrySelection* children = msvEntry.ChildrenWithTypeL(KUidMsvFolderEntry); |
|
738 CleanupStack::PushL(children); |
|
739 if(children->Count() > 0) |
|
740 { |
|
741 // Find out if the Child Folder Entry has an attachment |
|
742 msvEntry.SetEntryL(children->At(0)); |
|
743 CMsvEntrySelection* grandChildren = msvEntry.ChildrenWithTypeL(KUidMsvAttachmentEntry); |
|
744 CleanupStack::PushL(grandChildren); |
|
745 if(grandChildren->Count() > 0) |
|
746 { |
|
747 entryHasAttachment = ETrue; |
|
748 } |
|
749 |
|
750 CleanupStack::PopAndDestroy(); //grandChildren |
|
751 } |
|
752 |
|
753 CleanupStack::PopAndDestroy(); //children |
|
754 |
|
755 |
|
756 // Check if the Entry has an attachment |
|
757 if (entryHasAttachment) |
|
758 { |
|
759 // Check if the entry should have an Attachment |
|
760 if (iTestAttachment) |
|
761 { |
|
762 // Entry has an attachment |
|
763 _LIT(KAttachment, "Entry %d has an Attachment"); |
|
764 LogCommentFormatL(KAttachment, entryId); |
|
765 } |
|
766 else |
|
767 { |
|
768 // There should Not be an attachment, but there is |
|
769 _LIT(KErrAttachment, "Error, Entry should NOT have an Attachment!"); |
|
770 LogCommentFormatL(KErrAttachment); |
|
771 err = KErrUnknown; |
|
772 } |
|
773 } |
|
774 else |
|
775 { |
|
776 // Check if the entry should NOT have an Attachment |
|
777 if (!iTestAttachment) |
|
778 { |
|
779 // Entry does NOT have an attachment |
|
780 _LIT(KNoAttachment, "Entry %d does not have an Attachment"); |
|
781 LogCommentFormatL(KNoAttachment, entryId); |
|
782 } |
|
783 else |
|
784 { |
|
785 // There should be an attachment, but there is NOT |
|
786 _LIT(KErrNoAttachment, "Error, Entry should have an Attachment!"); |
|
787 LogCommentFormatL(KErrNoAttachment); |
|
788 err = KErrUnknown; |
|
789 } |
|
790 } |
|
791 |
|
792 TRequestStatus* status = &aStatus; |
|
793 User::RequestComplete(status, err); |
|
794 } |
|
795 |
|
796 |
|
797 |
|
798 |
|
799 // |
|
800 // |
|
801 // CCheckBodyText |
|
802 // |
|
803 |
|
804 CCheckBodyText::CCheckBodyText(TInt aSelectedIndex, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
805 :iTestUtils(aTestUtils), |
|
806 iSelection(aSelection), |
|
807 iSelectedIndex(aSelectedIndex) |
|
808 { |
|
809 } |
|
810 |
|
811 EXPORT_C CCheckBodyText* CCheckBodyText::NewL(TInt aSelectedIndex, TDesC& aTestBodyText, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
812 { |
|
813 CCheckBodyText* self = new (ELeave) CCheckBodyText(aSelectedIndex, aSelection, aTestUtils); |
|
814 CleanupStack::PushL(self); |
|
815 self->ConstructL(aTestBodyText); |
|
816 CleanupStack::Pop(self); |
|
817 return self; |
|
818 } |
|
819 |
|
820 void CCheckBodyText::ConstructL(TDesC& aTestBodyText) |
|
821 { |
|
822 iTestBodyText = HBufC::NewL(200); |
|
823 iTestBodyText->Des().Append(aTestBodyText); |
|
824 } |
|
825 |
|
826 EXPORT_C CCheckBodyText::~CCheckBodyText() |
|
827 { |
|
828 delete iTestBodyText; |
|
829 } |
|
830 |
|
831 void CCheckBodyText::LogCommentFormatL(TRefByValue<const TDesC> format,...) |
|
832 { |
|
833 // Build parameter list. |
|
834 VA_LIST list; |
|
835 VA_START(list, format); |
|
836 TBuf<0x100> buf; |
|
837 buf.FormatList(format, list); |
|
838 |
|
839 // Log the debug buffer. |
|
840 iTestUtils.WriteComment(buf); |
|
841 } |
|
842 |
|
843 // TODO: Commented out for the MMS Test Harness as leads to compile errors. |
|
844 |
|
845 EXPORT_C void CCheckBodyText::StartL(TRequestStatus& /*aStatus*/) |
|
846 // Check the Body Text of this entry is the same as the test value |
|
847 { |
|
848 /* TInt err=KErrNone; |
|
849 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
850 TMsvId entryId = iSelection.At(iSelectedIndex); |
|
851 msvEntry.SetEntryL(entryId); |
|
852 |
|
853 // Get the ID of the Body Text Entry, by looking at the Child Entries |
|
854 TMsvId bodyTextEntryId = KNoBodyText; |
|
855 CMsvEntrySelection* children = msvEntry.ChildrenL(); |
|
856 CleanupStack::PushL(children); |
|
857 if(children->Count() > 0) |
|
858 { |
|
859 // Check if the Child Entry is Body Text or a Folder |
|
860 msvEntry.SetEntryL(children->At(0)); |
|
861 switch (msvEntry.Entry().iType.iUid) |
|
862 { |
|
863 case KUidMsvEmailTextEntryValue: |
|
864 bodyTextEntryId = msvEntry.EntryId(); |
|
865 break; |
|
866 |
|
867 case KUidMsvFolderEntryValue: |
|
868 { |
|
869 // Check if the Child Folder has a Child Body Text Entry |
|
870 CMsvEntrySelection* grandChild = msvEntry.ChildrenWithTypeL(KUidMsvEmailTextEntry); |
|
871 CleanupStack::PushL(grandChild); |
|
872 if(grandChild->Count() > 0) |
|
873 { |
|
874 // Get the Id of the Body Text Entry |
|
875 msvEntry.SetEntryL(grandChild->At(0)); |
|
876 bodyTextEntryId = msvEntry.EntryId(); |
|
877 } |
|
878 |
|
879 CleanupStack::PopAndDestroy(); // grandChild |
|
880 break; |
|
881 } |
|
882 |
|
883 default: |
|
884 break; |
|
885 } |
|
886 } |
|
887 |
|
888 |
|
889 // If there is a Body Text Entry, then check if the Text is correct |
|
890 if (bodyTextEntryId == KNoBodyText) |
|
891 { |
|
892 _LIT(KErrNoBodyText, "Error, there is no Body Text"); |
|
893 LogCommentFormatL(KErrNoBodyText); |
|
894 err = KErrUnknown; |
|
895 } |
|
896 else |
|
897 { |
|
898 // Set the Entry to be the Body Text |
|
899 msvEntry.SetEntryL(bodyTextEntryId); |
|
900 if (msvEntry.HasStoreL()) |
|
901 { |
|
902 // Get the store |
|
903 CMsvStore* store = msvEntry.ReadStoreL(); |
|
904 CleanupStack::PushL(store); |
|
905 |
|
906 // Get the body Text if it exists |
|
907 CParaFormatLayer* paraFormat = CParaFormatLayer::NewL(); |
|
908 CleanupStack::PushL(paraFormat); |
|
909 CCharFormatLayer* charFormat = CCharFormatLayer::NewL(); |
|
910 CleanupStack::PushL(charFormat); |
|
911 CRichText* richText = CRichText::NewL(paraFormat, charFormat); |
|
912 CleanupStack::PushL(richText); |
|
913 if (store->HasBodyTextL()) |
|
914 store->RestoreBodyTextL(*richText); |
|
915 |
|
916 // Get the Entry Body Text. Make it the same length as the test Body Text, as the |
|
917 // entry body text will also include the name of the attachmnet if there is one |
|
918 HBufC* bodyText = HBufC::NewL(200); |
|
919 CleanupStack::PushL(bodyText); |
|
920 TPtr bodyTextPtr = bodyText->Des(); |
|
921 richText->Extract(bodyTextPtr, 0); |
|
922 bodyTextPtr.SetLength(iTestBodyText->Length()); |
|
923 |
|
924 // Check the Text is Correct |
|
925 if (bodyTextPtr.Compare(*iTestBodyText) == 0) |
|
926 { |
|
927 _LIT(KCorrectBodyText, "Correct Body Text"); |
|
928 LogCommentFormatL(KCorrectBodyText); |
|
929 } |
|
930 else |
|
931 { |
|
932 _LIT(KErrWrongBodyText, "Error, Incorrect Body Text"); |
|
933 LogCommentFormatL(KErrWrongBodyText); |
|
934 err = KErrUnknown; |
|
935 } |
|
936 |
|
937 CleanupStack::PopAndDestroy(5);// store, paraFormat, charFormat, richText, bodyText |
|
938 } |
|
939 else |
|
940 { |
|
941 _LIT(KErrNoBodyText, "Error, Body Text Entry has No Store"); |
|
942 LogCommentFormatL(KErrNoBodyText); |
|
943 err = KErrUnknown; |
|
944 } |
|
945 } |
|
946 |
|
947 CleanupStack::PopAndDestroy(); // children |
|
948 |
|
949 |
|
950 TRequestStatus* status = &aStatus; |
|
951 User::RequestComplete(status, err); |
|
952 */ |
|
953 } |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 // |
|
959 // |
|
960 // CCheckRemoteFolderSize |
|
961 // |
|
962 |
|
963 EXPORT_C CCheckRemoteFolderSize::CCheckRemoteFolderSize(TInt aCount, CMsvTestUtils& aTestUtils) |
|
964 : iTestUtils(aTestUtils), |
|
965 iTestCount(aCount) |
|
966 { |
|
967 } |
|
968 |
|
969 void CCheckRemoteFolderSize::LogCommentFormatL(TRefByValue<const TDesC> format,...) |
|
970 { |
|
971 // Build parameter list. |
|
972 VA_LIST list; |
|
973 VA_START(list, format); |
|
974 TBuf<0x100> buf; |
|
975 buf.FormatList(format, list); |
|
976 |
|
977 // Log the debug buffer. |
|
978 iTestUtils.WriteComment(buf); |
|
979 } |
|
980 |
|
981 // TODO: Commented out for the MMS Test Harness as leads to compile errors. |
|
982 |
|
983 EXPORT_C void CCheckRemoteFolderSize::StartL(TRequestStatus& /*aStatus*/) |
|
984 { |
|
985 /*TInt err=KErrNone; |
|
986 |
|
987 CMsvEntry& entry = *(iTestUtils.iMsvEntry); |
|
988 TMsvEmailEntry message=entry.Entry(); |
|
989 TInt remotecount=message.RemoteFolderEntries(); |
|
990 |
|
991 LogCommentFormatL(_L("[%4d] Remote folder contains %d entries when %d expected."), iDebugInfo.LineNumber(), remotecount, iTestCount); |
|
992 |
|
993 if (remotecount != iTestCount) |
|
994 { |
|
995 LogCommentFormatL(_L("Error!")); |
|
996 err = KErrUnknown; |
|
997 } |
|
998 |
|
999 TRequestStatus* status = &aStatus; |
|
1000 User::RequestComplete(status, err); |
|
1001 */ |
|
1002 } |
|
1003 |
|
1004 |
|
1005 // |
|
1006 // |
|
1007 // CSelectPopulatedInSelection |
|
1008 // |
|
1009 |
|
1010 EXPORT_C CSelectPopulatedInSelection::CSelectPopulatedInSelection(CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1011 : iTestUtils(aTestUtils), |
|
1012 iSelection(aSelection) |
|
1013 { |
|
1014 } |
|
1015 |
|
1016 // TODO: Commented out for the MMS Test Harness as leads to compile errors. |
|
1017 |
|
1018 EXPORT_C void CSelectPopulatedInSelection::StartL(TRequestStatus& /*aStatus*/) |
|
1019 { |
|
1020 /* |
|
1021 CMsvEntry& msvEntry = *(iTestUtils.iMsvEntry); |
|
1022 |
|
1023 TInt pos=0; |
|
1024 while (pos<iSelection.Count()) |
|
1025 { |
|
1026 msvEntry.SetEntryL(iSelection[pos]); |
|
1027 TMsvEmailEntry entry(msvEntry.Entry()); |
|
1028 if (entry.BodyTextComplete()) |
|
1029 pos++; |
|
1030 else |
|
1031 iSelection.Delete(pos,1); |
|
1032 } |
|
1033 |
|
1034 TRequestStatus* status = &aStatus; |
|
1035 User::RequestComplete(status, KErrNone); |
|
1036 */ |
|
1037 } |
|
1038 |
|
1039 |
|
1040 // |
|
1041 // |
|
1042 // CSelectLastInSelection |
|
1043 // |
|
1044 |
|
1045 EXPORT_C CSelectLastInSelection::CSelectLastInSelection(TInt aCount, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1046 : iTestUtils(aTestUtils), |
|
1047 iSelection(aSelection), |
|
1048 iTestCount(aCount) |
|
1049 { |
|
1050 } |
|
1051 |
|
1052 EXPORT_C void CSelectLastInSelection::StartL(TRequestStatus& aStatus) |
|
1053 { |
|
1054 TInt selectionCount=iSelection.Count(); |
|
1055 iTestCount=Min(iTestCount,selectionCount); |
|
1056 iSelection.Delete(iTestCount,iSelection.Count()-iTestCount); |
|
1057 TRequestStatus* status = &aStatus; |
|
1058 User::RequestComplete(status, KErrNone); |
|
1059 } |
|
1060 |
|
1061 // |
|
1062 // |
|
1063 // CSelectFirstInSelection |
|
1064 // |
|
1065 |
|
1066 EXPORT_C CSelectFirstInSelection::CSelectFirstInSelection(TInt aCount, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1067 : iTestUtils(aTestUtils), |
|
1068 iSelection(aSelection), |
|
1069 iTestCount(aCount) |
|
1070 { |
|
1071 } |
|
1072 |
|
1073 EXPORT_C void CSelectFirstInSelection::StartL(TRequestStatus& aStatus) |
|
1074 { |
|
1075 TInt selectionCount=iSelection.Count(); |
|
1076 iTestCount=Min(iTestCount,selectionCount); |
|
1077 iSelection.Delete(0,iSelection.Count()-iTestCount); |
|
1078 TRequestStatus* status = &aStatus; |
|
1079 User::RequestComplete(status, KErrNone); |
|
1080 } |
|
1081 |
|
1082 // |
|
1083 // |
|
1084 // CMsvTestEntry |
|
1085 // |
|
1086 |
|
1087 EXPORT_C CMsvTestEntry::CMsvTestEntry(CMsvClientTest& aParentTestHarness) : iParentTestHarness(aParentTestHarness) |
|
1088 { |
|
1089 } |
|
1090 |
|
1091 EXPORT_C void CMsvTestEntry::StartL(TRequestStatus& aStatus) |
|
1092 { |
|
1093 TInt err = KErrNone; |
|
1094 TBool match = ETrue; |
|
1095 |
|
1096 // Get access to the CMsvEntry owned by the test utils of the parent test harness |
|
1097 CMsvEntry* cMsvEntry = iParentTestHarness.MsvTestUtils().iMsvEntry; |
|
1098 |
|
1099 // Check that there is only one entry currently selected |
|
1100 if (iParentTestHarness.iCurrentSelection->Count() != 1) |
|
1101 { |
|
1102 match = EFalse; |
|
1103 iParentTestHarness.LogCommentL(_L("Incorrect number of entries selected")); |
|
1104 } |
|
1105 |
|
1106 // Set the CMsvEntry to point to the currently selected entry |
|
1107 // We have already checked that there is exactly one selected entry so the index is safe |
|
1108 cMsvEntry->SetEntryL((*iParentTestHarness.iCurrentSelection)[0]); |
|
1109 |
|
1110 // Get the TMsvEntry details that we are going to test |
|
1111 TMsvEntry entry = cMsvEntry->Entry(); |
|
1112 |
|
1113 if ((iTestVisible) && match) |
|
1114 // Test the Visible() flag |
|
1115 { |
|
1116 match = (iVisibleValue == entry.Visible()); |
|
1117 if (!match) |
|
1118 { |
|
1119 iParentTestHarness.LogCommentL(_L("Visible() not as expected")); |
|
1120 } |
|
1121 } |
|
1122 |
|
1123 if ((iTestComplete) && match) |
|
1124 // Test the Complete() flag |
|
1125 { |
|
1126 match = (iCompleteValue == entry.Complete()); |
|
1127 if (!match) |
|
1128 { |
|
1129 iParentTestHarness.LogCommentL(_L("Complete() not as expected")); |
|
1130 } |
|
1131 } |
|
1132 |
|
1133 if (!match) |
|
1134 // If the entry did not match then log it and complete with an error |
|
1135 { |
|
1136 iParentTestHarness.LogCommentL(_L("Entry not as expected")); |
|
1137 err = KErrUnknown; |
|
1138 } |
|
1139 |
|
1140 TRequestStatus* status = &aStatus; |
|
1141 User::RequestComplete(status, err); |
|
1142 } |
|
1143 |
|
1144 EXPORT_C void CMsvTestEntry::TestVisible(TBool aVisibleValue) |
|
1145 { |
|
1146 iTestVisible = ETrue; // Specify that the visible flag will be tested |
|
1147 iVisibleValue = aVisibleValue; // Set the expected value |
|
1148 } |
|
1149 |
|
1150 EXPORT_C void CMsvTestEntry::TestComplete(TBool aCompleteValue) |
|
1151 { |
|
1152 iTestComplete = ETrue; // Specify that the complete flag will be tested |
|
1153 iCompleteValue = aCompleteValue; // Set the expected value |
|
1154 } |
|
1155 |
|
1156 |
|
1157 // |
|
1158 // |
|
1159 // CSelectEntryById |
|
1160 // |
|
1161 |
|
1162 EXPORT_C CSelectEntryById::CSelectEntryById(TMsvId aId, TMsvId& aEntryId, CMsvTestUtils& aTestUtils) |
|
1163 : iTestUtils(aTestUtils), |
|
1164 iIdToSelect(aId), |
|
1165 iEntryId(aEntryId) |
|
1166 { |
|
1167 } |
|
1168 |
|
1169 EXPORT_C void CSelectEntryById::StartL(TRequestStatus& aStatus) |
|
1170 { |
|
1171 iTestUtils.iMsvEntry->SetEntryL(iIdToSelect); |
|
1172 iEntryId = iIdToSelect; |
|
1173 TRequestStatus* status = &aStatus; |
|
1174 User::RequestComplete(status, KErrNone); |
|
1175 } |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 // |
|
1181 // |
|
1182 // CSelectAllMessages |
|
1183 // |
|
1184 |
|
1185 EXPORT_C CSelectAllMessages::CSelectAllMessages(TMsvId& aParentFolder, CMsvEntrySelection& aSelection, CMsvTestUtils& aTestUtils) |
|
1186 : iTestUtils(aTestUtils), |
|
1187 iParentFolder(aParentFolder), |
|
1188 iSelection(aSelection) |
|
1189 { |
|
1190 } |
|
1191 |
|
1192 EXPORT_C void CSelectAllMessages::StartL(TRequestStatus& aStatus) |
|
1193 { |
|
1194 iSelection.Reset(); |
|
1195 iTestUtils.iMsvEntry->SetEntryL(iParentFolder); |
|
1196 |
|
1197 CMsvEntrySelection* tempSelection = iTestUtils.iMsvEntry->ChildrenL(); |
|
1198 CleanupStack::PushL(tempSelection); |
|
1199 // Copy the child entries to the given selection |
|
1200 TInt index = tempSelection->Count(); |
|
1201 while (index--) |
|
1202 { |
|
1203 iSelection.AppendL((*tempSelection)[index]); |
|
1204 } |
|
1205 CleanupStack::PopAndDestroy(tempSelection); |
|
1206 |
|
1207 TRequestStatus* status = &aStatus; |
|
1208 User::RequestComplete(status, KErrNone); |
|
1209 } |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 // |
|
1216 // |
|
1217 // CLongWait |
|
1218 // |
|
1219 EXPORT_C CLongWait::CLongWait() |
|
1220 : CActive(EPriorityNormal), |
|
1221 iWaitTime(KDefaultWaitTime) |
|
1222 { |
|
1223 CActiveScheduler::Add(this); |
|
1224 } |
|
1225 |
|
1226 EXPORT_C CLongWait::CLongWait(TInt aWaitTime) |
|
1227 : CActive(EPriorityNormal) |
|
1228 { |
|
1229 iWaitTime = aWaitTime * 1000000; |
|
1230 CActiveScheduler::Add(this); |
|
1231 } |
|
1232 |
|
1233 EXPORT_C CLongWait::~CLongWait() |
|
1234 { |
|
1235 delete iTimer; |
|
1236 } |
|
1237 |
|
1238 EXPORT_C void CLongWait::StartL(TRequestStatus& aStatus) |
|
1239 { |
|
1240 delete iTimer; |
|
1241 iTimer = 0; |
|
1242 iTimer = CTestTimer::NewL(); |
|
1243 iReportStatus = &aStatus; |
|
1244 iTimer->AfterReq(iWaitTime, iStatus); |
|
1245 aStatus = KRequestPending; |
|
1246 SetActive(); |
|
1247 } |
|
1248 |
|
1249 |
|
1250 |
|
1251 EXPORT_C void CLongWait::RunL() |
|
1252 { |
|
1253 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
1254 } |
|
1255 |
|
1256 EXPORT_C void CLongWait::DoCancel() |
|
1257 { |
|
1258 } |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 // |
|
1264 // |
|
1265 // CCopySelection |
|
1266 // |
|
1267 |
|
1268 EXPORT_C CCopySelection::CCopySelection(CMsvClientTest& aParentTestHarness) : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness) |
|
1269 { |
|
1270 CActiveScheduler::Add(this); |
|
1271 } |
|
1272 |
|
1273 EXPORT_C void CCopySelection::StartL(TRequestStatus& aStatus) |
|
1274 { |
|
1275 iParentTestHarness.MsvTestUtils().iMsvEntry->SetEntryL(iParentTestHarness.iSelectedFolder); |
|
1276 iReportStatus = &aStatus; |
|
1277 iParentTestHarness.SetCurrentOperation(iParentTestHarness.MsvTestUtils().iMsvEntry->CopyL(*(iParentTestHarness.iCurrentSelection), iParentTestHarness.iDestinationFolder, iStatus)); |
|
1278 aStatus = KRequestPending; |
|
1279 SetActive(); |
|
1280 } |
|
1281 |
|
1282 EXPORT_C void CCopySelection::RunL() |
|
1283 { |
|
1284 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
1285 } |
|
1286 |
|
1287 EXPORT_C void CCopySelection::DoCancel() |
|
1288 { |
|
1289 iParentTestHarness.CurrentOperation().Cancel(); |
|
1290 } |
|
1291 |
|
1292 |
|
1293 EXPORT_C CCopySelection::~CCopySelection() |
|
1294 { |
|
1295 } |
|
1296 |
|
1297 |
|
1298 |
|
1299 // |
|
1300 // |
|
1301 // CMoveSelection |
|
1302 // |
|
1303 |
|
1304 EXPORT_C CMoveSelection::CMoveSelection(CMsvClientTest& aParentTestHarness) : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness) |
|
1305 { |
|
1306 CActiveScheduler::Add(this); |
|
1307 } |
|
1308 |
|
1309 EXPORT_C void CMoveSelection::StartL(TRequestStatus& aStatus) |
|
1310 { |
|
1311 iParentTestHarness.MsvTestUtils().iMsvEntry->SetEntryL(iParentTestHarness.iSelectedFolder); |
|
1312 iReportStatus = &aStatus; |
|
1313 iParentTestHarness.SetCurrentOperation(iParentTestHarness.MsvTestUtils().iMsvEntry->MoveL(*(iParentTestHarness.iCurrentSelection), iParentTestHarness.iDestinationFolder, iStatus)); |
|
1314 aStatus = KRequestPending; |
|
1315 SetActive(); |
|
1316 } |
|
1317 EXPORT_C void CMoveSelection::RunL() |
|
1318 { |
|
1319 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
1320 } |
|
1321 |
|
1322 EXPORT_C void CMoveSelection::DoCancel() |
|
1323 { |
|
1324 iParentTestHarness.CurrentOperation().Cancel(); |
|
1325 } |
|
1326 |
|
1327 |
|
1328 EXPORT_C CMoveSelection::~CMoveSelection() |
|
1329 { |
|
1330 } |
|
1331 |
|
1332 |
|
1333 // |
|
1334 // |
|
1335 // CDeleteSelection |
|
1336 // |
|
1337 |
|
1338 EXPORT_C CDeleteSelection::CDeleteSelection(CMsvClientTest& aParentTestHarness) : CActive(EPriorityNormal), iParentTestHarness(aParentTestHarness) |
|
1339 { |
|
1340 CActiveScheduler::Add(this); |
|
1341 } |
|
1342 |
|
1343 EXPORT_C void CDeleteSelection::StartL(TRequestStatus& aStatus) |
|
1344 { |
|
1345 if (iParentTestHarness.iCurrentSelection->Count() == 0) |
|
1346 // If there are no entries currently selected then complete without an error |
|
1347 { |
|
1348 TRequestStatus* status = &aStatus; |
|
1349 User::RequestComplete(status, KErrNone); |
|
1350 } |
|
1351 else |
|
1352 // If there are some selected messages then delete them. |
|
1353 { |
|
1354 CMsvEntry& sharedCMsvEntry = *(iParentTestHarness.MsvTestUtils().iMsvEntry); |
|
1355 |
|
1356 // Set the CMsvEntry to point to the folder selected by the parent test harness |
|
1357 sharedCMsvEntry.SetEntryL(iParentTestHarness.iSelectedFolder); |
|
1358 |
|
1359 iReportStatus = &aStatus; |
|
1360 |
|
1361 // Start the delete operation |
|
1362 CMsvOperation* deleteOperaiton= sharedCMsvEntry.DeleteL(*(iParentTestHarness.iCurrentSelection), iStatus); |
|
1363 |
|
1364 // Set the current delete operation to be the current operation on the parent test harness |
|
1365 iParentTestHarness.SetCurrentOperation(deleteOperaiton); |
|
1366 aStatus = KRequestPending; |
|
1367 SetActive(); |
|
1368 } |
|
1369 } |
|
1370 |
|
1371 EXPORT_C void CDeleteSelection::RunL() |
|
1372 { |
|
1373 User::RequestComplete(iReportStatus, iStatus.Int()); |
|
1374 } |
|
1375 |
|
1376 EXPORT_C void CDeleteSelection::DoCancel() |
|
1377 { |
|
1378 iParentTestHarness.CurrentOperation().Cancel(); |
|
1379 } |
|
1380 |
|
1381 |
|
1382 EXPORT_C CDeleteSelection::~CDeleteSelection() |
|
1383 { |
|
1384 } |
|
1385 |