email/pop3andsmtpmtm/clientmtms/test/src/T_IMCM01.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 1998-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 // Name of test harness: T_IMCM01
       
    15 // Component: IMCM
       
    16 // Owner: KP
       
    17 // Brief description of test harness:
       
    18 // Installs SMTP, POP3, IMAP4 MTMs, creates SMTP, POP3 IMAP4 emails and tests
       
    19 // global find implementation in SMTP, POP3, IMAP4 client 
       
    20 // Detailed description of test harness:
       
    21 // As above
       
    22 // Input files required to run test harness:
       
    23 // None
       
    24 // Intermediate files produced while running test harness:
       
    25 // <DRIVE>:\msglogs\T_IMCM01\T_IMCM.log
       
    26 // Output files produced by running test harness:
       
    27 // <DRIVE>:\msglogs\T_IMCM01.<PLATFORM>.<VARIANT>.LOG.txt
       
    28 // Description of how to build test harness:
       
    29 // cd \msg\imcm\
       
    30 // bldmake bldfiles
       
    31 // abld test build
       
    32 // Description of how to run test harness:
       
    33 // The following instructions are the same for all platforms:
       
    34 // 1. Build T_DB test harness from COMMDB component:
       
    35 // cd \commdb\group
       
    36 // bldmake bldfiles
       
    37 // abld test build t_db
       
    38 // 2. Build the test utilities:
       
    39 // cd \msg\testutils\group\
       
    40 // bldmake bldfiles
       
    41 // abld build
       
    42 // WINS running instructions:
       
    43 // 1. \epoc32\release\wins\<VARIANT>\T_IMCM01.exe can be used at the command prompt
       
    44 // or executable can be run from Windows Explorer.
       
    45 // All other platform running instructions:
       
    46 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_IMCM01.exe onto the other platform
       
    47 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into 
       
    48 // <DRIVE>:\system\libs on the other platform
       
    49 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into 
       
    50 // <DRIVE>:\system\libs on the other platform
       
    51 // 4. Run T_IMCM01.exe on the other platform
       
    52 // 
       
    53 //
       
    54 
       
    55 #include "emailtestutils.h"
       
    56 
       
    57 #include <msvfind.h>
       
    58 #include <miutlog.h>
       
    59 #include <msvsearchsortquery.h>
       
    60 #include <msvsearchsortoperation.h>
       
    61 
       
    62 
       
    63 #define _L8(a) (TPtrC8((const TText8 *)(a)))
       
    64 
       
    65 RTest test(_L("Find Testrig"));
       
    66 LOCAL_D CEmailTestUtils* testUtils;
       
    67 LOCAL_D CTrapCleanup* theCleanup;
       
    68 LOCAL_D CImLog* log;
       
    69 
       
    70 LOCAL_D TMsvId folderId;
       
    71 LOCAL_D TMsvId entry1Id;
       
    72 LOCAL_D TMsvId entry2Id;
       
    73 LOCAL_D TMsvId entry3Id;
       
    74 
       
    75 
       
    76 TBuf<32> ShortDescription(_L("find some text in here"));
       
    77 TBuf<32> ShortDetails(_L("find some text in here"));
       
    78 
       
    79 TBuf<32> MatchingDescription(_L("abcDEFghi Jkl mno"));
       
    80 TBuf<32> MatchingDetails(_L("abcDEFghi Jkl mno"));
       
    81 
       
    82 const TUid KUidFindTestPOP3Mtm = {0x10001029};
       
    83 const TUid KUidFindTestSMTPMtm = {0x10001028};
       
    84 const TUid KUidFindTestIMAP4Mtm = {0x1000102A};
       
    85 
       
    86 _LIT(KMiutSubject, "short mail about something interesting");
       
    87 _LIT8(KMiutMsgId, "0123456789AB.CdeFGHIj@symbian.com");
       
    88 _LIT(KMiutFrom, "ralph-greenwell@psion.com");
       
    89 _LIT(KMiutReplyTo, "ralph.greenwell@virgin.net");
       
    90 _LIT(KMiutToRecipients1, "recipient1@address.com");
       
    91 _LIT(KMiutToRecipients2, "recipient2@address.com");
       
    92 _LIT(KMiutCcRecipients1, "cc1@address.com");
       
    93 _LIT(KMiutCcRecipients2, "cc2@address.com");
       
    94 _LIT(KMiutBccRecipients, "bcc@address.com");
       
    95 _LIT8(KMiutResentMsgId, "0123456789AB.CdeFGHIj@symbian.com");
       
    96 _LIT(KMiutResentFrom, "test@psion6.demon.co.uk");
       
    97 _LIT(KMiutResentToRecipients1, "recipient1@address.com");
       
    98 _LIT(KMiutResentToRecipients2, "recipient2@address.com");
       
    99 _LIT(KMiutResentCcRecipients1, "cc1@address.com");
       
   100 _LIT(KMiutResentCcRecipients2, "cc2@address.com");
       
   101 _LIT(KMiutResentBccRecipients, "bcc@address.com");
       
   102 
       
   103 #define KMiutRemoteSize 					123456
       
   104 #define KMaxImHeaderStringLengthLong		KMaxImHeaderStringLength+1
       
   105 
       
   106 
       
   107 LOCAL_D TBuf<KMaxImHeaderStringLengthLong> longValue;
       
   108 LOCAL_D TBuf8<KMaxImHeaderStringLengthLong> longValue2;
       
   109 
       
   110 
       
   111 //
       
   112 
       
   113 //**********************************
       
   114 // TMsvFindResultDateRange
       
   115 //**********************************
       
   116 //
       
   117 // An enumeration that specifies the date comparison to perform
       
   118 //
       
   119 
       
   120 enum TMsvFindResultDateRange
       
   121 	{
       
   122 	EMsvOnDate,
       
   123 	EMsvBeforeDate,
       
   124 	EMsvAfterDate
       
   125 	};
       
   126 
       
   127 //**********************************
       
   128 // CMsvFindDateOperation
       
   129 //**********************************
       
   130 //
       
   131 // An operation that extends global find to restrict searching by date
       
   132 //
       
   133 
       
   134 class CMsvFindDateOperation : public CMsvFindOperation
       
   135 	{
       
   136 public:
       
   137 	static CMsvFindDateOperation* FindInSelectionL(CMsvSession& aMsvSession, const TDesC& aTextToFind, const CMsvEntrySelection& aSel, TMsvPartList aPartList, const TTime& aDate, TMsvFindResultDateRange aRange, TRequestStatus& aObserverRequestStatus);
       
   138 	static CMsvFindDateOperation* FindInChildrenL(CMsvSession& aMsvSession, const TDesC& aTextToFind, TMsvId aId, TMsvPartList aPartList, const TTime& aDate, TMsvFindResultDateRange aRange, TRequestStatus& aObserverRequestStatus);
       
   139 	//
       
   140 protected:
       
   141 	CMsvFindDateOperation(CMsvSession& aMsvSession, const TDesC& aTextToFind, TMsvPartList aPartList, const TTime& aDate, TMsvFindResultDateRange aRange, TRequestStatus& aObserverRequestStatus);
       
   142 	//
       
   143 private:
       
   144 	TBool IsValid(const TMsvEntry& aEntry) const;
       
   145 	//
       
   146 private:
       
   147 	TTime iDate;
       
   148 	TMsvFindResultDateRange iRange;
       
   149 	};
       
   150 
       
   151 CMsvFindDateOperation* CMsvFindDateOperation::FindInSelectionL(CMsvSession& aMsvSession, const TDesC& aTextToFind, const CMsvEntrySelection& aSel, TMsvPartList aPartList, const TTime& aDate, TMsvFindResultDateRange aRange, TRequestStatus& aObserverRequestStatus)
       
   152 //
       
   153 //
       
   154 //
       
   155 	{
       
   156 	CMsvFindDateOperation* self = new(ELeave)CMsvFindDateOperation(aMsvSession, aTextToFind, aPartList, aDate, aRange, aObserverRequestStatus);
       
   157 	CleanupStack::PushL(self);
       
   158 	self->ConstructFindInSelectionL(aSel);
       
   159 	CleanupStack::Pop(); // self
       
   160 	return self;	
       
   161 	}
       
   162 
       
   163 CMsvFindDateOperation* CMsvFindDateOperation::FindInChildrenL(CMsvSession& aMsvSession, const TDesC& aTextToFind, TMsvId aId, TMsvPartList aPartList, const TTime& aDate, TMsvFindResultDateRange aRange, TRequestStatus& aObserverRequestStatus)
       
   164 //
       
   165 // 
       
   166 //
       
   167 	{
       
   168 	CMsvFindDateOperation* self = new(ELeave)CMsvFindDateOperation(aMsvSession, aTextToFind, aPartList, aDate, aRange, aObserverRequestStatus);
       
   169 	CleanupStack::PushL(self);
       
   170 	self->ConstructFindInChildrenL(aId);
       
   171 	CleanupStack::Pop(); // self
       
   172 	return self;	
       
   173 	}
       
   174 
       
   175 CMsvFindDateOperation::CMsvFindDateOperation(CMsvSession& aMsvSession, const TDesC& aTextToFind, TMsvPartList aPartList, const TTime& aDate, TMsvFindResultDateRange aRange, TRequestStatus& aObserverRequestStatus)
       
   176 : CMsvFindOperation(aMsvSession, aTextToFind, aPartList, aObserverRequestStatus), iDate(aDate), iRange(aRange)
       
   177 	{
       
   178 	}
       
   179 
       
   180 TBool CMsvFindDateOperation::IsValid(const TMsvEntry& aEntry) const
       
   181 //
       
   182 //
       
   183 //
       
   184 	{
       
   185 	TDateTime dt;
       
   186 		
       
   187 	dt = aEntry.iDate.DateTime();
       
   188 	TTime date1(TDateTime(dt.Year(), dt.Month(), dt.Day(), 0, 0, 0, 0));
       
   189 
       
   190 	dt = iDate.DateTime();
       
   191 	TTime date2(TDateTime(dt.Year(), dt.Month(), dt.Day(), 0, 0, 0, 0));
       
   192 
       
   193 	switch (iRange)
       
   194 		{
       
   195 		case EMsvOnDate:
       
   196 			return date1 == date2;
       
   197 		case EMsvBeforeDate:
       
   198 			return date1 < date2;
       
   199 		case EMsvAfterDate:
       
   200 			return date1 > date2;
       
   201 		}
       
   202 	return EFalse;
       
   203 	}
       
   204 
       
   205 //
       
   206 
       
   207 LOCAL_C void InitL()
       
   208 	{
       
   209 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
   210 	CActiveScheduler::Install(scheduler);
       
   211 	CleanupStack::PushL(scheduler);
       
   212 
       
   213 	testUtils = CEmailTestUtils::NewLC(test);
       
   214 	testUtils->CreateAllTestDirectories();
       
   215 	testUtils->FileSession().SetSessionPath(_L("C:\\"));
       
   216 	testUtils->CleanMessageFolderL();
       
   217 	testUtils->GoServerSideL();
       
   218 
       
   219 	log = CImLog::NewL(_L("c:\\logs\\email\\T_IMCM.log"), EAppend);
       
   220 	CleanupStack::PushL(log);
       
   221 	log->AppendComment(_L8("******* T_IMCM01 Test Client MTM Global Find *******"));
       
   222 	TBuf8<80> buf;
       
   223 
       
   224 #if defined(__WINS__)	
       
   225 	buf.Append(_L8("WINS "));
       
   226 #else
       
   227 	buf.Append(_L8("MARM "));
       
   228 #endif
       
   229 #if defined(_UNICODE)
       
   230 	buf.Append(_L8("U"));
       
   231 #endif
       
   232 #if defined(_DEBUG)
       
   233 	buf.Append(_L8("DEB"));
       
   234 #else
       
   235 	buf.Append(_L8("REL"));
       
   236 #endif
       
   237 	log->AppendComment(buf);
       
   238 	}
       
   239 
       
   240 LOCAL_C void Closedown()
       
   241 	{
       
   242 	log->AppendComment(_L8("**********    T_IMCM01 Tests Complete    **********"));
       
   243 	log->AppendComment(_L8(""));
       
   244 
       
   245 	CleanupStack::PopAndDestroy(3);  //testUtils, log, scheduler 
       
   246 	}
       
   247 
       
   248 LOCAL_C void CreateMessageHeader(CImHeader& imHeader)
       
   249 	{
       
   250 	// a bunch of data for the header object....
       
   251 	imHeader.Reset();
       
   252 	imHeader.SetSubjectL(KMiutSubject);
       
   253 
       
   254 	imHeader.SetImMsgIdL(KMiutMsgId);
       
   255 
       
   256 	imHeader.SetFromL(KMiutFrom);
       
   257 	imHeader.SetReplyToL(KMiutReplyTo);
       
   258 	imHeader.SetRemoteSize(KMiutRemoteSize);
       
   259 
       
   260 	imHeader.ToRecipients().AppendL(KMiutToRecipients1);
       
   261 	imHeader.ToRecipients().AppendL(KMiutToRecipients2);
       
   262 	imHeader.CcRecipients().AppendL(KMiutCcRecipients1);
       
   263 	imHeader.CcRecipients().AppendL(KMiutCcRecipients2);
       
   264 	imHeader.BccRecipients().AppendL(KMiutBccRecipients);
       
   265 	}
       
   266 
       
   267 LOCAL_C void CreateMessageHeader2(CImHeader& imHeader)
       
   268 	{
       
   269 	// a bunch of data for the header object....
       
   270 	imHeader.Reset();
       
   271 	imHeader.SetSubjectL(KMiutSubject);
       
   272 
       
   273 	imHeader.SetImMsgIdL(KMiutMsgId);
       
   274 
       
   275 	imHeader.SetFromL(KMiutFrom);
       
   276 	imHeader.SetReplyToL(KMiutReplyTo);
       
   277 	imHeader.SetRemoteSize(KMiutRemoteSize);
       
   278 
       
   279 	imHeader.ToRecipients().AppendL(KMiutToRecipients1);
       
   280 	imHeader.ToRecipients().AppendL(KMiutToRecipients2);
       
   281 	imHeader.CcRecipients().AppendL(KMiutCcRecipients1);
       
   282 	imHeader.CcRecipients().AppendL(KMiutCcRecipients2);
       
   283 	imHeader.BccRecipients().AppendL(KMiutBccRecipients);
       
   284 	
       
   285 	imHeader.SetResentMsgIdL(KMiutResentMsgId);
       
   286 	imHeader.SetResentFromL(KMiutResentFrom);
       
   287 	imHeader.ResentToRecipients().AppendL(KMiutResentToRecipients1);
       
   288 	imHeader.ResentToRecipients().AppendL(KMiutResentToRecipients2);
       
   289 	imHeader.ResentCcRecipients().AppendL(KMiutResentCcRecipients1);
       
   290 	imHeader.ResentCcRecipients().AppendL(KMiutResentCcRecipients2);
       
   291 	imHeader.ResentBccRecipients().AppendL(KMiutResentBccRecipients);
       
   292 	}
       
   293 
       
   294 LOCAL_C void CreateLongMessageHeader(CImHeader& imHeader)
       
   295 	{
       
   296 	// a bunch of data for the header object....
       
   297 	// all the fields are set to a length greater than 1000 i.e 1001
       
   298 
       
   299 	imHeader.Reset();
       
   300 	longValue.Fill('x',KMaxImHeaderStringLengthLong);
       
   301 	longValue2.Fill('x',KMaxImHeaderStringLengthLong);
       
   302 
       
   303 	imHeader.SetSubjectL(longValue);
       
   304 
       
   305 	imHeader.SetImMsgIdL(longValue2);
       
   306 
       
   307 	imHeader.SetFromL(longValue);
       
   308 	imHeader.SetReplyToL(longValue);
       
   309 	imHeader.SetRemoteSize(KMiutRemoteSize);
       
   310 
       
   311 	imHeader.ToRecipients().AppendL(longValue);
       
   312 	imHeader.ToRecipients().AppendL(longValue);
       
   313 	imHeader.CcRecipients().AppendL(longValue);
       
   314 	imHeader.CcRecipients().AppendL(longValue);
       
   315 	imHeader.BccRecipients().AppendL(longValue);
       
   316 
       
   317 	imHeader.SetResentMsgIdL(longValue2);
       
   318 	imHeader.SetResentFromL(longValue);
       
   319 	}
       
   320 
       
   321 LOCAL_C void CreateMessagesL(TUid aMtm)
       
   322 	{
       
   323 	CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
       
   324 	CleanupStack::PushL(paraLayer);
       
   325 	CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
       
   326 	CleanupStack::PushL(charLayer);
       
   327 
       
   328 	// create entry to work under
       
   329 	TMsvEntry folder;
       
   330 	folder.iType = KUidMsvFolderEntry;
       
   331 	folder.iMtm = KUidMsvLocalServiceMtm;
       
   332 	folder.iServiceId = KMsvLocalServiceIndexEntryId;
       
   333 	testUtils->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   334 	testUtils->iMsvEntry->CreateL(folder);
       
   335 	testUtils->iMsvEntry->SetEntryL(folder.Id());
       
   336 	folderId=folder.Id();
       
   337 
       
   338 	TMsvEntry entry1;
       
   339 	entry1.iType = KUidMsvMessageEntry;
       
   340 	entry1.iServiceId = KMsvLocalServiceIndexEntryId;
       
   341 	entry1.iMtm = aMtm;
       
   342 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   343 	testUtils->iMsvEntry->CreateL(entry1);
       
   344 	TRAPD(error,testUtils->iMsvEntry->SetEntryL(entry1.Id()));
       
   345 	entry1Id=entry1.Id();
       
   346 
       
   347 	CMsvStore* fileStore = testUtils->iMsvEntry->EditStoreL();
       
   348 	CleanupStack::PushL(fileStore);
       
   349 
       
   350 	CImHeader* header = CImHeader::NewLC(); // Cleaned up when exiting this menu selection
       
   351 	CreateMessageHeader(*header);
       
   352 	header->StoreL(*fileStore);
       
   353 	fileStore->CommitL();
       
   354 	CleanupStack::PopAndDestroy(2); // filestore, header
       
   355 
       
   356 	TMsvEmailEntry ementry1;
       
   357 	ementry1.iMtm = aMtm;
       
   358 	ementry1.iServiceId = testUtils->iMsvEntry->Entry().iServiceId;
       
   359 	ementry1.iType = KUidMsvEmailTextEntry;
       
   360 	testUtils->iMsvEntry->CreateL(ementry1);
       
   361 	TRAP(error,testUtils->iMsvEntry->SetEntryL(ementry1.Id()));
       
   362 
       
   363 	fileStore=NULL;
       
   364 	fileStore = testUtils->iMsvEntry->EditStoreL();
       
   365 	CleanupStack::PushL(fileStore);
       
   366 	
       
   367 	CRichText* text1=CRichText::NewL(paraLayer, charLayer);
       
   368 	CleanupStack::PushL(text1);
       
   369 	text1->InsertL(0,_L("Some Rich Text 1"));
       
   370 	fileStore->StoreBodyTextL(*text1);
       
   371 	fileStore->CommitL();
       
   372 	CleanupStack::PopAndDestroy(2); // filestore
       
   373 
       
   374 
       
   375 	fileStore=NULL;
       
   376 	TMsvEntry entry2;
       
   377 	entry2.iType = KUidMsvMessageEntry;
       
   378 	entry2.iMtm = aMtm;
       
   379 	entry2.iServiceId = KMsvLocalServiceIndexEntryId;
       
   380 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   381 	testUtils->iMsvEntry->CreateL(entry2);
       
   382 	TRAP(error,testUtils->iMsvEntry->SetEntryL(entry2.Id()));
       
   383 	entry2Id=entry2.Id();
       
   384 
       
   385 	fileStore = testUtils->iMsvEntry->EditStoreL();
       
   386 	CleanupStack::PushL(fileStore);
       
   387 	CImHeader* header1 = CImHeader::NewLC(); 
       
   388 	CreateMessageHeader2(*header1);
       
   389 	header1->StoreL(*fileStore);
       
   390 	fileStore->CommitL();
       
   391 	CleanupStack::PopAndDestroy(2); // filestore,header
       
   392 
       
   393 
       
   394 	TMsvEmailEntry ementry2;
       
   395 	ementry2.iMtm = aMtm;
       
   396 	ementry2.iServiceId = testUtils->iMsvEntry->Entry().iServiceId;
       
   397 	ementry2.iType = KUidMsvEmailTextEntry;
       
   398 	testUtils->iMsvEntry->CreateL(ementry2);
       
   399 	TRAP(error,testUtils->iMsvEntry->SetEntryL(ementry2.Id()));
       
   400 
       
   401 	fileStore=NULL;
       
   402 	fileStore = testUtils->iMsvEntry->EditStoreL();
       
   403 	CleanupStack::PushL(fileStore);
       
   404 	CRichText* text2=CRichText::NewL(paraLayer, charLayer);
       
   405 	CleanupStack::PushL(text2);
       
   406 	text2->InsertL(0,_L("Some Rich Text 2"));
       
   407 	fileStore->StoreBodyTextL(*text2);
       
   408 	fileStore->CommitL();
       
   409 	CleanupStack::PopAndDestroy(2); // filestore,text
       
   410 
       
   411 
       
   412 	fileStore=NULL;
       
   413 	TMsvEntry entry3;
       
   414 	entry3.iType = KUidMsvMessageEntry;
       
   415 	entry3.iMtm = aMtm;
       
   416 	entry3.iServiceId = KMsvLocalServiceIndexEntryId;
       
   417 	testUtils->iMsvEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
       
   418 	testUtils->iMsvEntry->CreateL(entry3);
       
   419 	TRAP(error,testUtils->iMsvEntry->SetEntryL(entry3.Id()));
       
   420 	entry3Id=entry3.Id();
       
   421 	
       
   422 	fileStore = testUtils->iMsvEntry->EditStoreL();
       
   423 	CleanupStack::PushL(fileStore);
       
   424 	CImHeader* header2 = CImHeader::NewLC(); 
       
   425 	CreateLongMessageHeader(*header2);
       
   426 	header2->StoreL(*fileStore);
       
   427 	fileStore->CommitL();
       
   428 	CleanupStack::PopAndDestroy(2); // filestore,header
       
   429 	
       
   430 	
       
   431 	TMsvEmailEntry ementry3;
       
   432 	ementry3.iMtm = aMtm;
       
   433 	ementry3.iServiceId = testUtils->iMsvEntry->Entry().iServiceId;
       
   434 	ementry3.iType = KUidMsvEmailTextEntry;
       
   435 	testUtils->iMsvEntry->CreateL(ementry3);
       
   436 	TRAP(error,testUtils->iMsvEntry->SetEntryL(ementry3.Id()));
       
   437 
       
   438 	fileStore=NULL;
       
   439 	fileStore = testUtils->iMsvEntry->EditStoreL();
       
   440 	CleanupStack::PushL(fileStore);
       
   441 	CRichText* text3=CRichText::NewL(paraLayer, charLayer);
       
   442 	CleanupStack::PushL(text3);
       
   443 	text3->InsertL(0,_L("Some Rich Text 3"));
       
   444 	fileStore->StoreBodyTextL(*text3);
       
   445 	fileStore->CommitL();
       
   446 	CleanupStack::PopAndDestroy(4); // filestore,header,text,layers
       
   447 	}
       
   448 
       
   449 
       
   450 LOCAL_C void TestFindInSelectionL()
       
   451 	{
       
   452 	CMsvOperationWait* active = CMsvOperationWait::NewLC();
       
   453 	CMsvFindOperation* find = NULL;
       
   454 	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
       
   455 	CleanupStack::PushL(selection);
       
   456 
       
   457 	selection->AppendL(folderId);
       
   458 	selection->AppendL(entry1Id);
       
   459 	selection->AppendL(entry2Id);
       
   460 	selection->AppendL(entry3Id);
       
   461 
       
   462 	// Test invalid arguments
       
   463 	TRAPD(error, CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("short mail"), *selection, KMsvMessagePartDescription, /*TMsvFindResultAny(),*/ active->iStatus));
       
   464 	test(error == KErrArgument);
       
   465 
       
   466 	selection->Delete(0);
       
   467 	selection->InsertL(1, folderId);
       
   468 
       
   469 	// Test find in selection
       
   470 	active->Start();
       
   471 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("short mail"), *selection, KMsvMessagePartDescription, /*TMsvFindResultAny(),*/ active->iStatus);
       
   472 	CleanupStack::PushL(find);
       
   473 	CActiveScheduler::Start();
       
   474 	
       
   475 	// Test the progress
       
   476     TPckgBuf<TMsvFindOperationProgress> progress;
       
   477     progress.Copy(find->FinalProgress());
       
   478 	test(progress().iError == KErrArgument);
       
   479 	test(progress().iCompleted == 1);
       
   480 	test(progress().iRemaining == 3);
       
   481 
       
   482 	selection->Delete(1);
       
   483 	selection->InsertL(2, folderId);
       
   484 
       
   485 	// Test results
       
   486 	test(find->GetFindResult().Count() == 1);
       
   487 
       
   488 	CleanupStack::PopAndDestroy(); // find
       
   489 
       
   490 	// Test find in selection
       
   491 	active->Start();
       
   492 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("short mail"), *selection, KMsvMessagePartDescription, /*TMsvFindResultAny(),*/ active->iStatus);
       
   493 	CleanupStack::PushL(find);
       
   494 	CActiveScheduler::Start();
       
   495 	
       
   496 	// Test the progress
       
   497     progress.Copy(find->FinalProgress());
       
   498 	test(progress().iError == KErrArgument);
       
   499 	test(progress().iCompleted == 2);
       
   500 	test(progress().iRemaining == 2);
       
   501 
       
   502 	selection->Delete(2);
       
   503 	selection->InsertL(3, folderId);
       
   504 
       
   505 	// Test results
       
   506 	test(find->GetFindResult().Count() == 2);
       
   507 
       
   508 	CleanupStack::PopAndDestroy(); // find
       
   509 
       
   510 	// Test find in selection
       
   511 	active->Start();
       
   512 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("short mail"), *selection, KMsvMessagePartDescription, /*TMsvFindResultAny(),*/ active->iStatus);
       
   513 	CleanupStack::PushL(find);
       
   514 	CActiveScheduler::Start();
       
   515 	
       
   516 	// Test the progress
       
   517     progress.Copy(find->FinalProgress());
       
   518 	test(progress().iError == KErrArgument);
       
   519 	test(progress().iCompleted == 3);
       
   520 	test(progress().iRemaining == 1);
       
   521 
       
   522 	selection->Delete(3);
       
   523 
       
   524 	// Test results
       
   525 	test(find->GetFindResult().Count() == 2);
       
   526 
       
   527 	CleanupStack::PopAndDestroy(); // find
       
   528 
       
   529 	// Test find in selection
       
   530 	active->Start();
       
   531 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("short mail"), *selection, KMsvMessagePartDescription, /*TMsvFindResultAny(),*/ active->iStatus);
       
   532 	CleanupStack::PushL(find);
       
   533 	CActiveScheduler::Start();
       
   534 	
       
   535 	// Test the progress
       
   536     progress.Copy(find->FinalProgress());
       
   537 	test(progress().iError == KErrNone);
       
   538 	test(progress().iCompleted == 3);
       
   539 	test(progress().iRemaining == 0);
       
   540 
       
   541 	// Test results
       
   542 	test(find->GetFindResult().Count() == 2);
       
   543 
       
   544 	test(selection->At(0) == find->GetFindResult().At(0).iId);
       
   545 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartDescription);
       
   546 
       
   547 	CleanupStack::PopAndDestroy(3); // find, selection, active, testUtils->iMsvEntry, testUtils->iMsvSession, ob
       
   548 	}
       
   549 
       
   550 
       
   551 
       
   552 LOCAL_C void TestFindDescriptionSelectionL()
       
   553 	{
       
   554 	CMsvOperationWait* active = CMsvOperationWait::NewLC();
       
   555 
       
   556 	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
       
   557 	CleanupStack::PushL(selection);
       
   558 
       
   559 	CMsvFindOperation* find = NULL;
       
   560 
       
   561 	selection->AppendL(entry1Id);
       
   562 	selection->AppendL(entry2Id);
       
   563 	selection->AppendL(entry3Id);
       
   564 
       
   565 	// Test find in selection
       
   566 	active->Start();
       
   567 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("short mail"), *selection, KMsvMessagePartDescription, /*TMsvFindResultAny(),*/ active->iStatus);
       
   568 	CleanupStack::PushL(find);
       
   569 	CActiveScheduler::Start();
       
   570 
       
   571 	// Test the progress
       
   572     TPckgBuf<TMsvFindOperationProgress> progress;
       
   573     progress.Copy(find->FinalProgress());
       
   574 	test(progress().iError == KErrNone);
       
   575 	test(progress().iCompleted == 3);
       
   576 	test(progress().iRemaining == 0);
       
   577 
       
   578 	// Test results
       
   579 
       
   580 	test(find->GetFindResult().Count() == 2);
       
   581 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   582 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartDescription);
       
   583 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   584 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartDescription);
       
   585 
       
   586 	CleanupStack::PopAndDestroy(); // find
       
   587 
       
   588 	// Test find in selection
       
   589 	active->Start();
       
   590 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("something"), *selection, KMsvMessagePartDescription, /*TMsvFindResultAny(),*/ active->iStatus);
       
   591 	CleanupStack::PushL(find);
       
   592 	CActiveScheduler::Start();
       
   593 
       
   594 	// Test the progress
       
   595     progress.Copy(find->FinalProgress());
       
   596 	test(progress().iError == KErrNone);
       
   597 	test(progress().iCompleted == 3);
       
   598 	test(progress().iRemaining == 0);
       
   599 
       
   600 	// Test results
       
   601 
       
   602 	test(find->GetFindResult().Count() == 2);
       
   603 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   604 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartDescription);
       
   605 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   606 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartDescription);
       
   607 
       
   608 	CleanupStack::PopAndDestroy(); // find
       
   609 
       
   610 	// Test find in selection - case sensitive
       
   611 	active->Start();
       
   612 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("mail"), *selection, KMsvMessagePartDescription | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
   613 	CleanupStack::PushL(find);
       
   614 	CActiveScheduler::Start();
       
   615 
       
   616 	// Test the progress
       
   617     progress.Copy(find->FinalProgress());
       
   618 	test(progress().iError == KErrNone);
       
   619 	test(progress().iCompleted == 3);
       
   620 	test(progress().iRemaining == 0);
       
   621 
       
   622 	// Test results
       
   623 
       
   624 	test(find->GetFindResult().Count() == 2);
       
   625 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   626 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartDescription);
       
   627 
       
   628 	CleanupStack::PopAndDestroy(); // find
       
   629 
       
   630 	// Test find in selection - match whole word
       
   631 	active->Start();
       
   632 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("mai"), *selection, KMsvMessagePartDescription | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
   633 	CleanupStack::PushL(find);
       
   634 	CActiveScheduler::Start();
       
   635 
       
   636 	// Test the progress
       
   637     progress.Copy(find->FinalProgress());
       
   638 	test(progress().iError == KErrNone);
       
   639 	test(progress().iCompleted == 3);
       
   640 	test(progress().iRemaining == 0);
       
   641 
       
   642 	// Test results
       
   643 
       
   644 	test(find->GetFindResult().Count() == 0);
       
   645 
       
   646 	CleanupStack::PopAndDestroy(); // find
       
   647 
       
   648 	// Test find in selection - match whole word
       
   649 	active->Start();
       
   650 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("interesting"), *selection, KMsvMessagePartDescription | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
   651 	CleanupStack::PushL(find);
       
   652 	CActiveScheduler::Start();
       
   653 
       
   654 	// Test the progress
       
   655     progress.Copy(find->FinalProgress());
       
   656 	test(progress().iError == KErrNone);
       
   657 	test(progress().iCompleted == 3);
       
   658 	test(progress().iRemaining == 0);
       
   659 
       
   660 	// Test results
       
   661 
       
   662 	test(find->GetFindResult().Count() == 2);
       
   663 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   664 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartDescription);
       
   665 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   666 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartDescription);
       
   667 
       
   668 	CleanupStack::PopAndDestroy(); // find
       
   669 
       
   670 	// Test find in selection - match whole word and case sensitive
       
   671 	active->Start();
       
   672 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("Mail"), *selection, KMsvMessagePartDescription | KMsvFindWholeWord | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
   673 	CleanupStack::PushL(find);
       
   674 	CActiveScheduler::Start();
       
   675 
       
   676 	// Test the progress
       
   677     progress.Copy(find->FinalProgress());
       
   678 	test(progress().iError == KErrNone);
       
   679 	test(progress().iCompleted == 3);
       
   680 	test(progress().iRemaining == 0);
       
   681 
       
   682 	// Test results
       
   683 
       
   684 	test(find->GetFindResult().Count() == 0);
       
   685 
       
   686 	CleanupStack::PopAndDestroy(); // find
       
   687 
       
   688 	// Test find in selection - match whole word and case sensitive
       
   689 	active->Start();
       
   690 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("something"), *selection, KMsvMessagePartDescription | KMsvFindWholeWord | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
   691 	CleanupStack::PushL(find);
       
   692 	CActiveScheduler::Start();
       
   693 
       
   694 	// Test the progress
       
   695     progress.Copy(find->FinalProgress());
       
   696 	test(progress().iError == KErrNone);
       
   697 	test(progress().iCompleted == 3);
       
   698 	test(progress().iRemaining == 0);
       
   699 
       
   700 	// Test results
       
   701 
       
   702 	test(find->GetFindResult().Count() == 2);
       
   703 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   704 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartDescription);
       
   705 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   706 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartDescription);
       
   707 
       
   708 	CleanupStack::PopAndDestroy(); // find
       
   709 
       
   710 	CleanupStack::PopAndDestroy(2); // selection, active, 
       
   711 	}
       
   712 
       
   713 LOCAL_C void TestFindOriginatorSelectionL()
       
   714 	{
       
   715 	CMsvOperationWait* active = CMsvOperationWait::NewLC();
       
   716 
       
   717 	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
       
   718 	CleanupStack::PushL(selection);
       
   719 
       
   720 	CMsvFindOperation* find = NULL;
       
   721 
       
   722 	selection->AppendL(entry1Id);
       
   723 	selection->AppendL(entry2Id);
       
   724 	selection->AppendL(entry3Id);
       
   725 
       
   726 	// Test find in selection
       
   727 	active->Start();
       
   728 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("psion.com"), *selection, KMsvMessagePartOriginator, /*TMsvFindResultAny(),*/ active->iStatus);
       
   729 	CleanupStack::PushL(find);
       
   730 	CActiveScheduler::Start();
       
   731 
       
   732 	// Test the progress
       
   733     TPckgBuf<TMsvFindOperationProgress> progress;
       
   734     progress.Copy(find->FinalProgress());
       
   735 	test(progress().iError == KErrNone);
       
   736 	test(progress().iCompleted == 3);
       
   737 	test(progress().iRemaining == 0);
       
   738 
       
   739 	// Test results
       
   740 
       
   741 	test(find->GetFindResult().Count() == 2);
       
   742 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   743 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartOriginator);
       
   744 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   745 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartOriginator);
       
   746 
       
   747 	CleanupStack::PopAndDestroy(); // find
       
   748 
       
   749 	// Test find in selection
       
   750 	active->Start();
       
   751 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("PSION.COM"), *selection, KMsvMessagePartOriginator, /*TMsvFindResultAny(),*/ active->iStatus);
       
   752 	CleanupStack::PushL(find);
       
   753 	CActiveScheduler::Start();
       
   754 
       
   755 	// Test the progress
       
   756     progress.Copy(find->FinalProgress());
       
   757 	test(progress().iError == KErrNone);
       
   758 	test(progress().iCompleted == 3);
       
   759 	test(progress().iRemaining == 0);
       
   760 
       
   761 	// Test results
       
   762 
       
   763 	test(find->GetFindResult().Count() == 2);
       
   764 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   765 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartOriginator);
       
   766 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   767 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartOriginator);
       
   768 
       
   769 	CleanupStack::PopAndDestroy(); // find
       
   770 
       
   771 	// Test find in selection - case sensitive
       
   772 	active->Start();
       
   773 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("psion"), *selection, KMsvMessagePartOriginator | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
   774 	CleanupStack::PushL(find);
       
   775 	CActiveScheduler::Start();
       
   776 
       
   777 	// Test the progress
       
   778     progress.Copy(find->FinalProgress());
       
   779 	test(progress().iError == KErrNone);
       
   780 	test(progress().iCompleted == 3);
       
   781 	test(progress().iRemaining == 0);
       
   782 
       
   783 	// Test results
       
   784 
       
   785 	test(find->GetFindResult().Count() == 2);
       
   786 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   787 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartOriginator);
       
   788 
       
   789 	CleanupStack::PopAndDestroy(); // find
       
   790 
       
   791 	// Test find in selection - match whole word
       
   792 	active->Start();
       
   793 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("ps"), *selection, KMsvMessagePartOriginator | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
   794 	CleanupStack::PushL(find);
       
   795 	CActiveScheduler::Start();
       
   796 
       
   797 	// Test the progress
       
   798     progress.Copy(find->FinalProgress());
       
   799 	test(progress().iError == KErrNone);
       
   800 	test(progress().iCompleted == 3);
       
   801 	test(progress().iRemaining == 0);
       
   802 
       
   803 	// Test results
       
   804 
       
   805 	test(find->GetFindResult().Count() == 0);
       
   806 
       
   807 	CleanupStack::PopAndDestroy(); // find
       
   808 
       
   809 	// Test find in selection - match whole word
       
   810 	active->Start();
       
   811 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("ralph-greenwell@psion.com"), *selection, KMsvMessagePartOriginator | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
   812 	CleanupStack::PushL(find);
       
   813 	CActiveScheduler::Start();
       
   814 
       
   815 	// Test the progress
       
   816     progress.Copy(find->FinalProgress());
       
   817 	test(progress().iError == KErrNone);
       
   818 	test(progress().iCompleted == 3);
       
   819 	test(progress().iRemaining == 0);
       
   820 
       
   821 	// Test results
       
   822 
       
   823 	test(find->GetFindResult().Count() == 2);
       
   824 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   825 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartOriginator);
       
   826 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   827 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartOriginator);
       
   828 
       
   829 	CleanupStack::PopAndDestroy(); // find
       
   830 
       
   831 	// Test find in selection - match whole word and case sensitive
       
   832 	active->Start();
       
   833 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("ralph-greenwell@psio"), *selection, KMsvMessagePartOriginator | KMsvFindWholeWord | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
   834 	CleanupStack::PushL(find);
       
   835 	CActiveScheduler::Start();
       
   836 
       
   837 	// Test the progress
       
   838     progress.Copy(find->FinalProgress());
       
   839 	test(progress().iError == KErrNone);
       
   840 	test(progress().iCompleted == 3);
       
   841 	test(progress().iRemaining == 0);
       
   842 
       
   843 	// Test results
       
   844 
       
   845 	test(find->GetFindResult().Count() == 0);
       
   846 
       
   847 	CleanupStack::PopAndDestroy(); // find
       
   848 
       
   849 	// Test find in selection - match whole word and case sensitive
       
   850 	active->Start();
       
   851 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("ralph-greenwell@psion.com"), *selection, KMsvMessagePartOriginator | KMsvFindWholeWord | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
   852 	CleanupStack::PushL(find);
       
   853 	CActiveScheduler::Start();
       
   854 
       
   855 	// Test the progress
       
   856     progress.Copy(find->FinalProgress());
       
   857 	test(progress().iError == KErrNone);
       
   858 	test(progress().iCompleted == 3);
       
   859 	test(progress().iRemaining == 0);
       
   860 
       
   861 	// Test results
       
   862 
       
   863 	test(find->GetFindResult().Count() == 2);
       
   864 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   865 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartOriginator);
       
   866 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   867 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartOriginator);
       
   868 
       
   869 	CleanupStack::PopAndDestroy(); // find
       
   870 
       
   871 	CleanupStack::PopAndDestroy(2); // selection, active, 
       
   872 	}
       
   873 
       
   874 
       
   875 LOCAL_C void TestFindRecipientSelectionL()
       
   876 	{
       
   877 	CMsvOperationWait* active = CMsvOperationWait::NewLC();
       
   878 
       
   879 	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
       
   880 	CleanupStack::PushL(selection);
       
   881 
       
   882 	selection->AppendL(entry1Id);
       
   883 	selection->AppendL(entry2Id);
       
   884 	selection->AppendL(entry3Id);
       
   885 
       
   886 	CMsvFindOperation* find = NULL;
       
   887 
       
   888 	active->Start();
       
   889 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("address"), *selection, KMsvMessagePartRecipient, /*TMsvFindResultAny(),*/ active->iStatus);
       
   890 	CleanupStack::PushL(find);
       
   891 	CActiveScheduler::Start();
       
   892 
       
   893 	// Test the progress
       
   894     TPckgBuf<TMsvFindOperationProgress> progress;
       
   895     progress.Copy(find->FinalProgress());
       
   896 	test(progress().iError == KErrNone);
       
   897 	test(progress().iCompleted == 3);
       
   898 	test(progress().iRemaining == 0);
       
   899 
       
   900 	// Test results
       
   901 
       
   902 	test(find->GetFindResult().Count() == 2);
       
   903 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   904 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartRecipient);
       
   905 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   906 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartRecipient);
       
   907 
       
   908 	CleanupStack::PopAndDestroy(); // find
       
   909 
       
   910 	active->Start();
       
   911 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("xxx"), *selection, KMsvMessagePartRecipient, /*TMsvFindResultAny(),*/ active->iStatus);
       
   912 	CleanupStack::PushL(find);
       
   913 	CActiveScheduler::Start();
       
   914 
       
   915 	// Test the progress
       
   916     progress.Copy(find->FinalProgress());
       
   917 	test(progress().iError == KErrNone);
       
   918 	test(progress().iCompleted == 3);
       
   919 	test(progress().iRemaining == 0);
       
   920 
       
   921 	// Test results
       
   922 
       
   923 	test(find->GetFindResult().Count() == 1);
       
   924 	test(find->GetFindResult().At(0).iId == entry3Id);
       
   925 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartRecipient);
       
   926 
       
   927 	CleanupStack::PopAndDestroy(); // find
       
   928 
       
   929 	active->Start();
       
   930 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("Address"), *selection, KMsvMessagePartRecipient | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
   931 	CleanupStack::PushL(find);
       
   932 	CActiveScheduler::Start();
       
   933 
       
   934 	// Test the progress
       
   935     progress.Copy(find->FinalProgress());
       
   936 	test(progress().iError == KErrNone);
       
   937 	test(progress().iCompleted == 3);
       
   938 	test(progress().iRemaining == 0);
       
   939 
       
   940 	// Test results
       
   941 
       
   942 	test(find->GetFindResult().Count() == 0);
       
   943 
       
   944 	CleanupStack::PopAndDestroy(); // find
       
   945 
       
   946 	active->Start();
       
   947 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("addr"), *selection, KMsvMessagePartRecipient | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
   948 	CleanupStack::PushL(find);
       
   949 	CActiveScheduler::Start();
       
   950 
       
   951 	// Test the progress
       
   952     progress.Copy(find->FinalProgress());
       
   953 	test(progress().iError == KErrNone);
       
   954 	test(progress().iCompleted == 3);
       
   955 	test(progress().iRemaining == 0);
       
   956 
       
   957 	// Test results
       
   958 
       
   959 	test(find->GetFindResult().Count() == 0);
       
   960 
       
   961 	CleanupStack::PopAndDestroy(); // find
       
   962 
       
   963 	active->Start();
       
   964 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("recipient2@address.com"), *selection, KMsvMessagePartRecipient | KMsvFindCaseSensitive | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
   965 	CleanupStack::PushL(find);
       
   966 	CActiveScheduler::Start();
       
   967 
       
   968 	// Test the progress
       
   969     progress.Copy(find->FinalProgress());
       
   970 	test(progress().iError == KErrNone);
       
   971 	test(progress().iCompleted == 3);
       
   972 	test(progress().iRemaining == 0);
       
   973 
       
   974 	// Test results
       
   975 
       
   976 	test(find->GetFindResult().Count() == 2);
       
   977 	test(find->GetFindResult().At(0).iId == entry1Id);
       
   978 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartRecipient);
       
   979 	test(find->GetFindResult().At(1).iId == entry2Id);
       
   980 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartRecipient);
       
   981 
       
   982 	CleanupStack::PopAndDestroy(); // find
       
   983 
       
   984 	CleanupStack::PopAndDestroy(2); // selection, active, testUtils->iMsvEntry, testUtils->iMsvSession, ob
       
   985 	}
       
   986 
       
   987 
       
   988 LOCAL_C void TestFindBodySelectionL()
       
   989 	{
       
   990 	CMsvOperationWait* active = CMsvOperationWait::NewLC();
       
   991 
       
   992 	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
       
   993 	CleanupStack::PushL(selection);
       
   994 
       
   995 	CMsvFindOperation* find = NULL;
       
   996 
       
   997 	selection->AppendL(entry1Id);
       
   998 	selection->AppendL(entry2Id);
       
   999 	selection->AppendL(entry3Id);
       
  1000 
       
  1001 	// Test find in selection
       
  1002 	active->Start();
       
  1003 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("rich"), *selection, KMsvMessagePartBody, /*TMsvFindResultAny(),*/ active->iStatus);
       
  1004 	CleanupStack::PushL(find);
       
  1005 	CActiveScheduler::Start();
       
  1006 
       
  1007 	// Test the progress
       
  1008     TPckgBuf<TMsvFindOperationProgress> progress;
       
  1009     progress.Copy(find->FinalProgress());
       
  1010 	test(progress().iError == KErrNone);
       
  1011 	test(progress().iCompleted == 3);
       
  1012 	test(progress().iRemaining == 0);
       
  1013 
       
  1014 	// Test results
       
  1015 
       
  1016 	test(find->GetFindResult().Count() == 3);
       
  1017 	test(find->GetFindResult().At(0).iId == entry1Id);
       
  1018 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartBody);
       
  1019 	test(find->GetFindResult().At(1).iId == entry2Id);
       
  1020 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartBody);
       
  1021 	test(find->GetFindResult().At(2).iId == entry3Id);
       
  1022 	test(find->GetFindResult().At(2).iPartList == KMsvMessagePartBody);
       
  1023 
       
  1024 	CleanupStack::PopAndDestroy(); // find
       
  1025 
       
  1026 	// Test find in selection
       
  1027 	active->Start();
       
  1028 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("RICH"), *selection, KMsvMessagePartBody, /*TMsvFindResultAny(),*/ active->iStatus);
       
  1029 	CleanupStack::PushL(find);
       
  1030 	CActiveScheduler::Start();
       
  1031 
       
  1032 	// Test the progress
       
  1033     progress.Copy(find->FinalProgress());
       
  1034 	test(progress().iError == KErrNone);
       
  1035 	test(progress().iCompleted == 3);
       
  1036 	test(progress().iRemaining == 0);
       
  1037 
       
  1038 	// Test results
       
  1039 
       
  1040 	test(find->GetFindResult().Count() == 3);
       
  1041 	test(find->GetFindResult().At(0).iId == entry1Id);
       
  1042 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartBody);
       
  1043 	test(find->GetFindResult().At(1).iId == entry2Id);
       
  1044 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartBody);
       
  1045 	test(find->GetFindResult().At(2).iId == entry3Id);
       
  1046 	test(find->GetFindResult().At(2).iPartList == KMsvMessagePartBody);
       
  1047 
       
  1048 
       
  1049 	CleanupStack::PopAndDestroy(); // find
       
  1050 
       
  1051 	// Test find in selection - case sensitive
       
  1052 	active->Start();
       
  1053 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("rich"), *selection, KMsvMessagePartBody | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
  1054 	CleanupStack::PushL(find);
       
  1055 	CActiveScheduler::Start();
       
  1056 
       
  1057 	// Test the progress
       
  1058     progress.Copy(find->FinalProgress());
       
  1059 	test(progress().iError == KErrNone);
       
  1060 	test(progress().iCompleted == 3);
       
  1061 	test(progress().iRemaining == 0);
       
  1062 
       
  1063 	// Test results
       
  1064 
       
  1065 	test(find->GetFindResult().Count() == 0);
       
  1066 
       
  1067 	CleanupStack::PopAndDestroy(); // find
       
  1068 
       
  1069 	// Test find in selection - match whole word
       
  1070 	active->Start();
       
  1071 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("ric"), *selection, KMsvMessagePartBody | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
  1072 	CleanupStack::PushL(find);
       
  1073 	CActiveScheduler::Start();
       
  1074 
       
  1075 	// Test the progress
       
  1076     progress.Copy(find->FinalProgress());
       
  1077 	test(progress().iError == KErrNone);
       
  1078 	test(progress().iCompleted == 3);
       
  1079 	test(progress().iRemaining == 0);
       
  1080 
       
  1081 	// Test results
       
  1082 
       
  1083 	test(find->GetFindResult().Count() == 0);
       
  1084 
       
  1085 	CleanupStack::PopAndDestroy(); // find
       
  1086 
       
  1087 	// Test find in selection - match whole word
       
  1088 	active->Start();
       
  1089 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("rich"), *selection, KMsvMessagePartBody | KMsvFindWholeWord, /*TMsvFindResultAny(),*/ active->iStatus);
       
  1090 	CleanupStack::PushL(find);
       
  1091 	CActiveScheduler::Start();
       
  1092 
       
  1093 	// Test the progress
       
  1094     progress.Copy(find->FinalProgress());
       
  1095 	test(progress().iError == KErrNone);
       
  1096 	test(progress().iCompleted == 3);
       
  1097 	test(progress().iRemaining == 0);
       
  1098 
       
  1099 	// Test results
       
  1100 
       
  1101 	test(find->GetFindResult().Count() == 3);
       
  1102 	test(find->GetFindResult().At(0).iId == entry1Id);
       
  1103 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartBody);
       
  1104 	test(find->GetFindResult().At(1).iId == entry2Id);
       
  1105 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartBody);
       
  1106 	test(find->GetFindResult().At(2).iId == entry3Id);
       
  1107 	test(find->GetFindResult().At(2).iPartList == KMsvMessagePartBody);
       
  1108 
       
  1109 
       
  1110 	CleanupStack::PopAndDestroy(); // find
       
  1111 
       
  1112 	// Test find in selection - match whole word and case sensitive
       
  1113 	active->Start();
       
  1114 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("rich"), *selection, KMsvMessagePartBody | KMsvFindWholeWord | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
  1115 	CleanupStack::PushL(find);
       
  1116 	CActiveScheduler::Start();
       
  1117 
       
  1118 	// Test the progress
       
  1119     progress.Copy(find->FinalProgress());
       
  1120 	test(progress().iError == KErrNone);
       
  1121 	test(progress().iCompleted == 3);
       
  1122 	test(progress().iRemaining == 0);
       
  1123 
       
  1124 	// Test results
       
  1125 
       
  1126 	test(find->GetFindResult().Count() == 0);
       
  1127 
       
  1128 	CleanupStack::PopAndDestroy(); // find
       
  1129 
       
  1130 	// Test find in selection - match whole word and case sensitive
       
  1131 	active->Start();
       
  1132 	find = CMsvFindOperation::FindInSelectionL(*testUtils->iMsvSession, _L("Rich"), *selection, KMsvMessagePartBody | KMsvFindWholeWord | KMsvFindCaseSensitive, /*TMsvFindResultAny(),*/ active->iStatus);
       
  1133 	CleanupStack::PushL(find);
       
  1134 	CActiveScheduler::Start();
       
  1135 
       
  1136 	// Test the progress
       
  1137     progress.Copy(find->FinalProgress());
       
  1138 	test(progress().iError == KErrNone);
       
  1139 	test(progress().iCompleted == 3);
       
  1140 	test(progress().iRemaining == 0);
       
  1141 
       
  1142 	// Test results
       
  1143 
       
  1144 	test(find->GetFindResult().Count() == 3);
       
  1145 	test(find->GetFindResult().At(0).iId == entry1Id);
       
  1146 	test(find->GetFindResult().At(0).iPartList == KMsvMessagePartBody);
       
  1147 	test(find->GetFindResult().At(1).iId == entry2Id);
       
  1148 	test(find->GetFindResult().At(1).iPartList == KMsvMessagePartBody);
       
  1149 	test(find->GetFindResult().At(2).iId == entry3Id);
       
  1150 	test(find->GetFindResult().At(2).iPartList == KMsvMessagePartBody);
       
  1151 
       
  1152 	CleanupStack::PopAndDestroy(3); // selection, find,active
       
  1153 	}
       
  1154 
       
  1155 
       
  1156 LOCAL_C void doMainL()
       
  1157 	{
       
  1158 	InitL();
       
  1159 
       
  1160 	testUtils->GoClientSideL();
       
  1161 	CreateMessagesL(KUidFindTestPOP3Mtm);
       
  1162 	testUtils->TestStart(1);
       
  1163 	test.Start(_L("POP3 - Finding text in selection"));
       
  1164 	TestFindInSelectionL();
       
  1165 	log->AppendComment(_L8("Test 1 OK"));
       
  1166 	testUtils->TestFinish(1);
       
  1167 	testUtils->TestStart(2);
       
  1168 	test.Next(_L("POP3 - Finding text in description"));
       
  1169 	TestFindDescriptionSelectionL();
       
  1170 	log->AppendComment(_L8("Test 2 OK"));
       
  1171 	testUtils->TestFinish(2);
       
  1172 
       
  1173 	testUtils->TestStart(3);
       
  1174 	test.Next(_L("POP3 - Finding text in recipient"));
       
  1175 	TestFindRecipientSelectionL();
       
  1176 	log->AppendComment(_L8("Test 3 OK"));
       
  1177 	testUtils->TestFinish(3);
       
  1178 
       
  1179 	testUtils->TestStart(4);
       
  1180 	test.Next(_L("POP3 - Finding text in originator"));
       
  1181 	TestFindOriginatorSelectionL();
       
  1182 	log->AppendComment(_L8("Test 4 OK"));
       
  1183 	testUtils->TestFinish(4);
       
  1184 
       
  1185 	testUtils->TestStart(5);
       
  1186 	test.Next(_L("POP3 - Finding text in body"));
       
  1187 	TestFindBodySelectionL();
       
  1188 	log->AppendComment(_L8("Test 5 OK"));
       
  1189 	testUtils->TestFinish(5);
       
  1190 
       
  1191 	testUtils->TestStart(6);
       
  1192 	CreateMessagesL(KUidFindTestSMTPMtm);
       
  1193 	test.Next(_L("SMTP - Finding text in selection"));
       
  1194 	TestFindInSelectionL();
       
  1195 	log->AppendComment(_L8("Test 6 OK"));
       
  1196 	testUtils->TestFinish(6);
       
  1197 
       
  1198 	testUtils->TestStart(7);
       
  1199 	test.Next(_L("SMTP - Finding text in description"));
       
  1200 	TestFindDescriptionSelectionL();
       
  1201 	log->AppendComment(_L8("Test 7 OK"));
       
  1202 	testUtils->TestFinish(7);
       
  1203 
       
  1204 	testUtils->TestStart(8);
       
  1205 	test.Next(_L("SMTP - Finding text in recipient"));
       
  1206 	TestFindRecipientSelectionL();
       
  1207 	log->AppendComment(_L8("Test 8 OK"));
       
  1208 	testUtils->TestFinish(8);
       
  1209 
       
  1210 	testUtils->TestStart(9);
       
  1211 	test.Next(_L("SMTP - Finding text in originator"));
       
  1212 	TestFindOriginatorSelectionL();
       
  1213 	log->AppendComment(_L8("Test 9 OK"));
       
  1214 	testUtils->TestFinish(9);
       
  1215 
       
  1216 	testUtils->TestStart(10);
       
  1217 	test.Next(_L("SMTP - Finding text in body"));
       
  1218 	TestFindBodySelectionL();
       
  1219 	log->AppendComment(_L8("Test 10 OK"));
       
  1220 	testUtils->TestFinish(10);
       
  1221 
       
  1222 	testUtils->TestStart(11);
       
  1223 	CreateMessagesL(KUidFindTestIMAP4Mtm);
       
  1224 	test.Next(_L("IMAP4 - Finding text in selection"));
       
  1225 	TestFindInSelectionL();
       
  1226 	log->AppendComment(_L8("Test 11 OK"));
       
  1227 	testUtils->TestFinish(11);
       
  1228 
       
  1229 	testUtils->TestStart(12);
       
  1230 	test.Next(_L("IMAP4 - Finding text in description"));
       
  1231 	TestFindDescriptionSelectionL();
       
  1232 	log->AppendComment(_L8("Test 12 OK"));
       
  1233 	testUtils->TestFinish(12);
       
  1234 
       
  1235 	testUtils->TestStart(13);
       
  1236 	test.Next(_L("IMAP4 - Finding text in recipient"));
       
  1237 	TestFindRecipientSelectionL();
       
  1238 	log->AppendComment(_L8("Test 13 OK"));
       
  1239 	testUtils->TestFinish(13);
       
  1240 
       
  1241 	testUtils->TestStart(14);
       
  1242 	test.Next(_L("IMAP4 - Finding text in originator"));
       
  1243 	TestFindOriginatorSelectionL();
       
  1244 	log->AppendComment(_L8("Test 14 OK"));
       
  1245 	testUtils->TestFinish(14);
       
  1246 
       
  1247 	testUtils->TestStart(15);
       
  1248 	test.Next(_L("IMAP4 - Finding text in body"));
       
  1249 	TestFindBodySelectionL();
       
  1250 	log->AppendComment(_L8("Test 15 OK"));
       
  1251 	testUtils->TestFinish(15);
       
  1252 
       
  1253 	log->AppendComment(_L8("TESTS PASSED"));
       
  1254 	testUtils->TestHarnessCompleted();
       
  1255 	Closedown();		
       
  1256 	}
       
  1257 	
       
  1258 
       
  1259 LOCAL_C void doFindTestL()
       
  1260 	{
       
  1261 	InitL();
       
  1262 
       
  1263 	testUtils->GoClientSideL();
       
  1264 	CreateMessagesL(KUidFindTestPOP3Mtm);
       
  1265 	testUtils->TestStart(1);
       
  1266 	test.Start(_L("POP3 - Finding text in Header"));
       
  1267 	log->AppendComment(_L8("Test 1 OK"));
       
  1268 	testUtils->TestFinish(1);
       
  1269 	
       
  1270 	log->AppendComment(_L8("TESTS PASSED"));
       
  1271 	testUtils->TestHarnessCompleted();
       
  1272 	Closedown();		
       
  1273 	}
       
  1274 
       
  1275 
       
  1276 GLDEF_C TInt E32Main()
       
  1277 	{
       
  1278 	__UHEAP_MARK;
       
  1279 	theCleanup=CTrapCleanup::New();
       
  1280 	TRAPD(ret,doMainL());		
       
  1281 	test(ret==KErrNone);
       
  1282 	delete theCleanup;	
       
  1283 	test.Console()->SetPos(0, 13);
       
  1284 	test.End();
       
  1285 	test.Close();
       
  1286 	__UHEAP_MARKEND;
       
  1287 	return(KErrNone);
       
  1288 	}
       
  1289