email/imap4mtm/imapsession/test/src/ctestimapidle.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-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 "ctestimapidle.h"
       
    17 
       
    18 #include "cfakeinputstream.h"
       
    19 #include "cfakeoutputstream.h"
       
    20 
       
    21 #include "moutputstream.h"
       
    22 #include "cimapsession.h"
       
    23 #include "cimapfolderinfo.h"
       
    24 #include "cimaputils.h"
       
    25 
       
    26 
       
    27 CTestImapIdle::CTestImapIdle()
       
    28 	: iInputStream(NULL)
       
    29 	, iOutputStream(NULL)
       
    30 	, iActiveWaiter(NULL)
       
    31 	, iImapSession(NULL)
       
    32 	{}
       
    33 
       
    34 CTestImapIdle::~CTestImapIdle()
       
    35 	{
       
    36 	delete iImapSession;
       
    37 	delete iActiveWaiter;
       
    38 	delete iOutputStream;
       
    39 	delete iInputStream;
       
    40 	CImapUtils::Delete();
       
    41 	}
       
    42 
       
    43 void CTestImapIdle::SetupL()
       
    44 	{
       
    45 	ASSERT(iInputStream == NULL);
       
    46 	ASSERT(iOutputStream == NULL);
       
    47 	ASSERT(iActiveWaiter == NULL);
       
    48 	ASSERT(iImapSession == NULL);
       
    49 
       
    50 	CImapUtils::CreateL();
       
    51 	iInputStream = CFakeInputStream::NewL(Logger());
       
    52 	iOutputStream = CFakeOutputStream::NewL(Logger());
       
    53 	iActiveWaiter = new(ELeave)CActiveWaiter(Logger());
       
    54 	
       
    55 	CImapSettings* imapSettings=NULL; 
       
    56 	CImapMailStore* imapMailStore=NULL;
       
    57 	
       
    58 	iImapSession = CImapSession::NewL(*imapSettings,*imapMailStore,*iInputStream, *iOutputStream);
       
    59 	
       
    60 	INFO_PRINTF1(_L("Setup: ServerGreeting"));
       
    61 	iInputStream->ResetInputStrings();
       
    62 	iInputStream->AppendInputStringL(_L8("* OK Microsoft Exchange 2000 IMAP4rev1 server version 6.0.6249.0 (lon-cn-exchng2k.msexchange2k.closedtest.intra) ready.\r\n"));
       
    63 	
       
    64 	ASSERT_EQUALS(CImapSession::EServerStateNone, iImapSession->ServerState());
       
    65 	
       
    66 	iImapSession->ReadServerGreetingL(iActiveWaiter->iStatus);
       
    67 	iActiveWaiter->WaitActive();
       
    68 	
       
    69 	INFO_PRINTF1(_L("...Login"));
       
    70 	iInputStream->ResetInputStrings();
       
    71 	iInputStream->AppendInputStringL(_L8("1 OK LOGIN completed\r\n"));
       
    72 			
       
    73 	iImapSession->LoginL(iActiveWaiter->iStatus, _L8("username"), _L8("password"));
       
    74 	iActiveWaiter->WaitActive();
       
    75 
       
    76 	ASSERT_EQUALS(CImapSession::EServerStateAuthenticated, iImapSession->ServerState());
       
    77 
       
    78 
       
    79 	INFO_PRINTF1(_L("...Select inbox"));
       
    80 	iInputStream->ResetInputStrings();
       
    81 	iInputStream->AppendInputStringL(_L8("* 23 EXISTS\r\n"));
       
    82 	iInputStream->AppendInputStringL(_L8("* 1 RECENT\r\n"));
       
    83 	iInputStream->AppendInputStringL(_L8("* OK [UNSEEN 12] Message 12 is first unseen\r\n"));
       
    84 	iInputStream->AppendInputStringL(_L8("* OK [UIDVALIDITY 3857529045] UIDs valid\r\n"));
       
    85 	iInputStream->AppendInputStringL(_L8("2 OK [READ-WRITE] SELECT completed\r\n"));
       
    86 		
       
    87 	CImapFolderInfo* folderInfo = CImapFolderInfo::NewL();
       
    88 	CleanupStack::PushL(folderInfo);
       
    89 	
       
    90 	folderInfo->SetNameL(_L16("inbox"));
       
    91 	CleanupStack::Pop(folderInfo);
       
    92 	iImapSession->SelectL(iActiveWaiter->iStatus, folderInfo);
       
    93 	iActiveWaiter->WaitActive();
       
    94 
       
    95 	ASSERT_EQUALS(CImapSession::EServerStateSelected, iImapSession->ServerState());
       
    96 	ASSERT_EQUALS(folderInfo, iImapSession->SelectedFolderInfo());
       
    97 	folderInfo = NULL;
       
    98 	}
       
    99 	
       
   100 void CTestImapIdle::TearDownL()
       
   101 	{
       
   102 	delete iImapSession;
       
   103 	iImapSession = NULL;
       
   104 	
       
   105 	delete iActiveWaiter;
       
   106 	iActiveWaiter = NULL;
       
   107 	
       
   108 	delete iOutputStream;
       
   109 	iOutputStream = NULL;
       
   110 	
       
   111 	delete iInputStream;
       
   112 	iInputStream = NULL;
       
   113 
       
   114 	CImapUtils::Delete();
       
   115 	}
       
   116 
       
   117 /**
       
   118 Simple test that enters idle, then sends DONE to leave idle.
       
   119 No idle data is received.
       
   120 */
       
   121 void CTestImapIdle::TestIdleEnterDoneL()
       
   122 	{
       
   123 	INFO_PRINTF1(_L("TestIdleEnterDoneL"));
       
   124 	
       
   125 	iInputStream->ResetInputStrings();	
       
   126 	iInputStream->AppendInputStringL(_L8("+ idling\r\n"));
       
   127 	iInputStream->AppendInputStringL(_L8("3 OK IDLE terminated\r\n"));
       
   128 		
       
   129 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   130 	iActiveWaiter->WaitActive();
       
   131 	
       
   132 	iImapSession->DoneIdle(iActiveWaiter->iStatus);
       
   133 	iActiveWaiter->WaitActive();
       
   134 	
       
   135 	INFO_PRINTF1(_L("Complete"));
       
   136 	}
       
   137 	
       
   138 /**
       
   139 Simple test that enters idle, then sends DONE to leave idle.
       
   140 No idle data is received.
       
   141 */
       
   142 void CTestImapIdle::TestIdleEnterDoneFlatL()
       
   143 	{
       
   144 	INFO_PRINTF1(_L("TestIdleEnterDoneFlatL"));
       
   145 	
       
   146 	iInputStream->ResetInputStrings();	
       
   147 	iInputStream->AppendInputStringL(_L8("+ idling\r\n3 OK IDLE terminated\r\n"));
       
   148 			
       
   149 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   150 	iActiveWaiter->WaitActive();
       
   151 	
       
   152 	iImapSession->DoneIdle(iActiveWaiter->iStatus);
       
   153 	iActiveWaiter->WaitActive();
       
   154 	
       
   155 	INFO_PRINTF1(_L("Complete"));
       
   156 	}
       
   157 	
       
   158 /**
       
   159 Simple test that enters idle, 
       
   160 waits for some data (the data is received)
       
   161 then sends DONE to leave idle.
       
   162 */
       
   163 void CTestImapIdle::TestIdleEnterWaitDoneL()
       
   164 	{
       
   165 	INFO_PRINTF1(_L("TestIdleEnterWaitDoneL"));
       
   166 	
       
   167 	iInputStream->ResetInputStrings();	
       
   168 	iInputStream->AppendInputStringL(_L8("+ idling\r\n"));
       
   169 	iInputStream->AppendInputStringL(_L8("* 22 EXPUNGE\r\n"));
       
   170 	iInputStream->AppendInputStringL(_L8("3 OK IDLE terminated\r\n"));
       
   171 			
       
   172 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   173 	iActiveWaiter->WaitActive();
       
   174 	
       
   175 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   176 	iActiveWaiter->WaitActive();
       
   177 	
       
   178 	iImapSession->DoneIdle(iActiveWaiter->iStatus);
       
   179 	iActiveWaiter->WaitActive();
       
   180 	
       
   181 	INFO_PRINTF1(_L("Complete"));
       
   182 	}
       
   183 	
       
   184 /**
       
   185 Simple test that enters idle, 
       
   186 waits for some data, but "cancels" before any is received.
       
   187 then sends DONE to leave idle.
       
   188 */
       
   189 void CTestImapIdle::TestIdleEnterWaitCancelDoneL()
       
   190 	{
       
   191 	INFO_PRINTF1(_L("TestIdleEnterWaitCancelDoneL"));
       
   192 	
       
   193 	iInputStream->ResetInputStrings();	
       
   194 	iInputStream->AppendInputStringL(_L8("+ idling\r\n"));
       
   195 	iInputStream->AppendInputStringL(_L8("3 OK IDLE terminated\r\n"));
       
   196 			
       
   197 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   198 	iActiveWaiter->WaitActive();
       
   199 	
       
   200 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   201 	iActiveWaiter->SetActiveAndCancel(*this);
       
   202 			
       
   203 	iImapSession->DoneIdle(iActiveWaiter->iStatus);
       
   204 	iActiveWaiter->WaitActive();
       
   205 	
       
   206 	CImapFolderInfo* info = iImapSession->SelectedFolderInfo();
       
   207 	ASSERT_NOT_NULL(info);
       
   208 	ASSERT_EQUALS(info->ExpungedMessages().Count(), 0);
       
   209 	
       
   210 	INFO_PRINTF1(_L("Complete"));
       
   211 	}
       
   212 
       
   213 /**
       
   214 Simple test that enters idle, 
       
   215 waits for some data, but "cancels" before it is received.
       
   216 then sends DONE to leave idle.
       
   217 */
       
   218 void CTestImapIdle::TestIdleEnterWaitCancelDataDoneL()
       
   219 	{
       
   220 	INFO_PRINTF1(_L("TestIdleEnterWaitCancelDataDoneL"));
       
   221 	
       
   222 	iInputStream->ResetInputStrings();
       
   223 	iInputStream->AppendInputStringL(_L8("+ idling\r\n"));
       
   224 	iInputStream->AppendInputStringL(_L8("* 22 EXPUNGE\r\n"));
       
   225 	iInputStream->AppendInputStringL(_L8("3 OK IDLE terminated\r\n"));
       
   226 			
       
   227 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   228 	iActiveWaiter->WaitActive();
       
   229 	
       
   230 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   231 	iActiveWaiter->SetActiveAndCancel(*this);
       
   232 	
       
   233 	iImapSession->DoneIdle(iActiveWaiter->iStatus); // possibly don't need aStatus for DoneIdle()
       
   234 	iActiveWaiter->WaitActive();
       
   235 	
       
   236 	CImapFolderInfo* info = iImapSession->SelectedFolderInfo();
       
   237 	ASSERT_NOT_NULL(info);
       
   238 	ASSERT_EQUALS(info->ExpungedMessages().Count(), 1);
       
   239 	ASSERT_EQUALS(info->ExpungedMessages()[0], (TUint)22);
       
   240 	
       
   241 	INFO_PRINTF1(_L("Complete"));
       
   242 	}
       
   243 	
       
   244 /**
       
   245 Lots of data is received here
       
   246 */
       
   247 void CTestImapIdle::TestIdleSequenceL()
       
   248 	{
       
   249 	INFO_PRINTF1(_L("TestIdleSequenceL"));
       
   250 	
       
   251 	CImapFolderInfo* selectedFolderInfo = iImapSession->SelectedFolderInfo();
       
   252 	ASSERT_NOT_NULL(selectedFolderInfo);
       
   253 	
       
   254 	iInputStream->ResetInputStrings();
       
   255 	
       
   256 	// initial summary information
       
   257 	iInputStream->AppendInputStringL(_L8("* 22 EXPUNGE\r\n"));
       
   258 	iInputStream->AppendInputStringL(_L8("* 23 EXISTS\r\n"));
       
   259 	iInputStream->AppendInputStringL(_L8("* 3 RECENT\r\n"));
       
   260 	iInputStream->AppendInputStringL(_L8("* 14 FETCH (FLAGS (Seen Deleted))\r\n")); // this line should be ignored by the parser
       
   261 	iInputStream->AppendInputStringL(_L8("+ idling\r\n"));
       
   262 	// events come in one at a time
       
   263 	iInputStream->AppendInputStringL(_L8("* 321 EXPUNGE\r\n"));
       
   264 	iInputStream->AppendInputStringL(_L8("* 12 EXPUNGE\r\n"));
       
   265 	// done here
       
   266 	iInputStream->AppendInputStringL(_L8("* 27 EXISTS\r\n"));
       
   267 	iInputStream->AppendInputStringL(_L8("3 OK IDLE terminated\r\n"));
       
   268 			
       
   269 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   270 	iActiveWaiter->WaitActive();
       
   271 	
       
   272 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   273 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)22);
       
   274 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 23);
       
   275 	ASSERT_EQUALS(selectedFolderInfo->Recent(), 3);
       
   276 	
       
   277 	selectedFolderInfo->ResetExpungedMessages();
       
   278 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 0);
       
   279 	
       
   280 	// receive the 1st expunge event.
       
   281 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   282 	iActiveWaiter->WaitActive();
       
   283 	
       
   284 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   285 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)321);
       
   286 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 22);	
       
   287 	
       
   288 	// receive the 2nd expunge event.
       
   289 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   290 	iActiveWaiter->WaitActive();
       
   291 	
       
   292 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 2);
       
   293 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)321);
       
   294 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[1], (TUint)12);
       
   295 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 21);	
       
   296 	
       
   297 	iImapSession->DoneIdle(iActiveWaiter->iStatus); // possibly don't need aStatus for DoneIdle()
       
   298 	iActiveWaiter->WaitActive();
       
   299 		
       
   300 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 27);
       
   301 	
       
   302 	INFO_PRINTF1(_L("Complete"));
       
   303 	}
       
   304 	
       
   305 /**
       
   306 Lots of data is received here, both before and after continuation.
       
   307 A wait for idle event is canceled.
       
   308 */
       
   309 void CTestImapIdle::TestIdleSequenceWithCancelL()
       
   310 	{
       
   311 	INFO_PRINTF1(_L("TestIdleSequenceWithCancelL"));
       
   312 	
       
   313 	CImapFolderInfo* selectedFolderInfo = iImapSession->SelectedFolderInfo();
       
   314 	ASSERT_NOT_NULL(selectedFolderInfo);
       
   315 	
       
   316 	iInputStream->ResetInputStrings();
       
   317 	
       
   318 	// initial summary information
       
   319 	iInputStream->AppendInputStringL(_L8("* 22 EXPUNGE\r\n"));
       
   320 	iInputStream->AppendInputStringL(_L8("* 23 EXISTS\r\n"));
       
   321 	iInputStream->AppendInputStringL(_L8("* 3 RECENT\r\n"));
       
   322 	iInputStream->AppendInputStringL(_L8("* 14 FETCH (FLAGS (Seen Deleted))\r\n")); // this line should be ignored by the parser
       
   323 	iInputStream->AppendInputStringL(_L8("+ idling\r\n"));
       
   324 	// events come in one at a time
       
   325 	iInputStream->AppendInputStringL(_L8("* 321 EXPUNGE\r\n"));
       
   326 	iInputStream->AppendInputStringL(_L8("* 12 EXPUNGE\r\n"));
       
   327 	// cancel & done here
       
   328 	iInputStream->AppendInputStringL(_L8("* 27 EXISTS\r\n"));
       
   329 	iInputStream->AppendInputStringL(_L8("* 100 EXPUNGE\r\n"));
       
   330 	iInputStream->AppendInputStringL(_L8("3 OK IDLE terminated\r\n"));
       
   331 		
       
   332 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   333 	iActiveWaiter->WaitActive();
       
   334 	
       
   335 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   336 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)22);
       
   337 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 23);
       
   338 	ASSERT_EQUALS(selectedFolderInfo->Recent(), 3);
       
   339 	
       
   340 	selectedFolderInfo->ResetExpungedMessages();
       
   341 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 0);
       
   342 	
       
   343 	// receive the 1st expunge event.
       
   344 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   345 	iActiveWaiter->WaitActive();
       
   346 	
       
   347 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   348 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)321);
       
   349 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 22);	
       
   350 	
       
   351 	// receive the 2nd expunge event.
       
   352 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   353 	iActiveWaiter->WaitActive();
       
   354 	
       
   355 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 2);
       
   356 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)321);
       
   357 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[1], (TUint)12);
       
   358 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 21);	
       
   359 	
       
   360 	selectedFolderInfo->ResetExpungedMessages();
       
   361 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 0);
       
   362 	
       
   363 	// start listening for more data, but then cancel
       
   364 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);	
       
   365 	iActiveWaiter->SetActiveAndCancel(*this);
       
   366 	
       
   367 	iImapSession->DoneIdle(iActiveWaiter->iStatus); // possibly don't need aStatus for DoneIdle()
       
   368 	iActiveWaiter->WaitActive();
       
   369 		
       
   370 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   371 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)100);
       
   372 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 26); // == 27 - 1
       
   373 	
       
   374 	INFO_PRINTF1(_L("Complete"));
       
   375 	}
       
   376 
       
   377 /**
       
   378 Lots of data is received here, both before and after continuation.
       
   379 Data is delivered arrives in blocks that need to be separated by the session
       
   380 while also sending one notification per line during the wait phase.
       
   381 */
       
   382 void CTestImapIdle::TestIdleSequenceWithCancelAndFlatL()
       
   383 	{
       
   384 	INFO_PRINTF1(_L("TestIdleSequenceWithCancelAndFlatL"));
       
   385 	
       
   386 	CImapFolderInfo* selectedFolderInfo = iImapSession->SelectedFolderInfo();
       
   387 	ASSERT_NOT_NULL(selectedFolderInfo);
       
   388 	
       
   389 	iInputStream->ResetInputStrings();
       
   390 	
       
   391 	// initial summary information
       
   392 	iInputStream->AppendInputStringL(_L8("* 22 EXPUNGE\r\n"));
       
   393 	iInputStream->AppendInputStringL(_L8("* 23 EXISTS\r\n"));
       
   394 	iInputStream->AppendInputStringL(_L8("* 3 RECENT\r\n"));
       
   395 	iInputStream->AppendInputStringL(_L8("* 14 FETCH (FLAGS (Seen Deleted))\r\n")); // this line should be ignored by the parser
       
   396 	iInputStream->AppendInputStringL(_L8("+ idling\r\n"));
       
   397 	// events come in as 2 split blocks but are processed one at a time.
       
   398 	iInputStream->AppendInputStringL(_L8("* 321 EXPUNGE\r\n* 12 EXPUNGE\r\n* 27 EXISTS\r\n* 100 EXPU"));
       
   399 	iInputStream->AppendInputStringL(_L8("NGE\r\n3 OK IDLE terminated\r\n"));
       
   400 		
       
   401 	iImapSession->EnterIdleL(iActiveWaiter->iStatus);
       
   402 	iActiveWaiter->WaitActive();
       
   403 	
       
   404 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   405 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)22);
       
   406 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 23);
       
   407 	ASSERT_EQUALS(selectedFolderInfo->Recent(), 3);
       
   408 	
       
   409 	selectedFolderInfo->ResetExpungedMessages();
       
   410 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 0);
       
   411 	
       
   412 	// receive the 1st expunge event.
       
   413 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   414 	iActiveWaiter->WaitActive();
       
   415 	
       
   416 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   417 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)321);
       
   418 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 22);	
       
   419 	
       
   420 	// receive the 2nd expunge event.
       
   421 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   422 	iActiveWaiter->WaitActive();
       
   423 	
       
   424 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 2);
       
   425 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)321);
       
   426 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[1], (TUint)12);
       
   427 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 21);	
       
   428 	
       
   429 	selectedFolderInfo->ResetExpungedMessages();
       
   430 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 0);
       
   431 	
       
   432 	// start listening for more data, but then cancel
       
   433 	iImapSession->WaitForIdleEvent(iActiveWaiter->iStatus);
       
   434 	iActiveWaiter->SetActiveAndCancel(*this);
       
   435 	
       
   436 		
       
   437 	iImapSession->DoneIdle(iActiveWaiter->iStatus); // possibly don't need aStatus for DoneIdle()
       
   438 	iActiveWaiter->WaitActive();
       
   439 		
       
   440 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages().Count(), 1);
       
   441 	ASSERT_EQUALS(selectedFolderInfo->ExpungedMessages()[0], (TUint)100);
       
   442 	ASSERT_EQUALS(selectedFolderInfo->Exists(), 26); // == 27 - 1
       
   443 	
       
   444 	INFO_PRINTF1(_L("Complete"));
       
   445 	}
       
   446 
       
   447 void CTestImapIdle::DoCancel()
       
   448 	{
       
   449 	if (iImapSession)
       
   450 		{
       
   451 		iImapSession->Cancel();
       
   452 		}
       
   453 	}
       
   454 
       
   455 CTestSuite* CTestImapIdle::CreateSuiteL(const TDesC& aName)
       
   456 // static
       
   457 	{
       
   458 	SUB_SUITE;
       
   459 	ADD_ASYNC_TEST_STEP(TestIdleEnterDoneL);
       
   460 	ADD_ASYNC_TEST_STEP(TestIdleEnterDoneFlatL);
       
   461 	ADD_ASYNC_TEST_STEP(TestIdleEnterWaitDoneL);
       
   462 	ADD_ASYNC_TEST_STEP(TestIdleEnterWaitCancelDoneL);
       
   463 	ADD_ASYNC_TEST_STEP(TestIdleEnterWaitCancelDataDoneL);
       
   464 	ADD_ASYNC_TEST_STEP(TestIdleSequenceL);
       
   465 	ADD_ASYNC_TEST_STEP(TestIdleSequenceWithCancelL);
       
   466 	ADD_ASYNC_TEST_STEP(TestIdleSequenceWithCancelAndFlatL);
       
   467 	END_SUITE;
       
   468 	}