email/pop3andsmtpmtm/imapservermtm/test/src/T_PartialDownloadStep.cpp
changeset 25 84d9eb65b26f
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
       
     1 // Copyright (c) 2005-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 <testexecutelog.h>
       
    17 #include "t_partialdownloadstep.h"
       
    18 
       
    19 RTest test(_L("Partial Download Test"));
       
    20 const TInt KImapPort = 143;
       
    21 const TInt KEntryCount=2; 
       
    22 
       
    23 CPartialDownloadStep::~CPartialDownloadStep()
       
    24 	{
       
    25 	delete iConsole;
       
    26 	delete iSpoofServer;	
       
    27 	delete iTestUtils;
       
    28 	delete iImapClient;	
       
    29 	delete iScheduler;
       
    30 	iSession->CloseMessageServer();
       
    31 	delete iSession;
       
    32 	delete iSessionObserver;
       
    33 	}
       
    34 
       
    35 CPartialDownloadStep::CPartialDownloadStep()
       
    36 	{
       
    37 	// Call base class method to set up the human readable name for logging
       
    38 	SetTestStepName(KTestPartialDownLoad);
       
    39 	}
       
    40 
       
    41 void CPartialDownloadStep::TestComplete(TInt aErrorCode)
       
    42 	{
       
    43 	CActiveScheduler::Stop();	
       
    44 	
       
    45 	if(aErrorCode!=KErrNone && aErrorCode!=KErrEof)
       
    46 		{
       
    47 		ERR_PRINTF2(_L("Error: %d"),aErrorCode);	
       
    48 		}
       
    49 	}
       
    50 
       
    51 	
       
    52 TVerdict CPartialDownloadStep::doTestStepPreambleL()
       
    53 	{
       
    54 	SetTestStepResult(EPass);
       
    55 	iScheduler = new (ELeave) CActiveScheduler;
       
    56 	CActiveScheduler::Install(iScheduler);
       
    57 	
       
    58 	iTestUtils = CEmailTestUtils::NewL(test);
       
    59 	iTestUtils->FileSession().SetSessionPath(_L("C:\\"));
       
    60 	iTestUtils->CleanMessageFolderL();
       
    61 	iTestUtils->ClearEmailAccountsL();
       
    62 	
       
    63 	iTestUtils->GoClientSideL();	
       
    64 	//start the imap server
       
    65 	iConsole=Console::NewL(_L("IMAP UTC Parse Test"),TSize(KConsFullScreen,KConsFullScreen));
       
    66 	iSpoofServer = CSpoofServer::NewL(*this,_L("c:\\msgtest\\imap\\partialDownload.txt"));
       
    67 	iSpoofServer->StartL(KImapPort);
       
    68 	//start the imap client
       
    69 	iImapClient = CPartialDownLoadImapClient::NewL(*this,ETrue);
       
    70 	iImapClient->StartL();
       
    71 	
       
    72 	CActiveScheduler::Start();
       
    73 	return TestStepResult();
       
    74 	}
       
    75 
       
    76 TInt CPartialDownloadStep::GetEntryCountL()
       
    77 	{
       
    78 	
       
    79 	TImapAccount imapAccount=iImapClient->GetImapAccount();
       
    80 	
       
    81 	TMsvSelectionOrdering ordering;	
       
    82 
       
    83 	//open the imap service entry
       
    84 	CMsvEntry* imapService = CMsvEntry::NewL(*iSession,imapAccount.iImapService,ordering);
       
    85 	CleanupStack::PushL(imapService);
       
    86 	//get its children
       
    87 	CMsvEntrySelection* msvEntrySelection;
       
    88 	msvEntrySelection=imapService->ChildrenL();
       
    89 	//open its child inbox entry
       
    90 	CMsvEntry* inboxEntry = CMsvEntry::NewL(*iSession, (*msvEntrySelection)[0],ordering);
       
    91     CleanupStack::PushL(inboxEntry);
       
    92     
       
    93     //get the childeren of the inbox
       
    94     delete msvEntrySelection;
       
    95     msvEntrySelection=NULL;
       
    96     msvEntrySelection=inboxEntry->ChildrenL();
       
    97     //the count should be 2
       
    98     TInt count=msvEntrySelection->Count();
       
    99     
       
   100     delete msvEntrySelection;
       
   101     msvEntrySelection=NULL;	
       
   102 	CleanupStack::PopAndDestroy(2,imapService);
       
   103 	
       
   104 	return count;
       
   105 	}
       
   106 
       
   107 TVerdict CPartialDownloadStep::doTestStepL()
       
   108 	{
       
   109 	TVerdict result;
       
   110 	// Session observer. Needed to create a session
       
   111 	iSessionObserver = new (ELeave) TDummySessionObserver;
       
   112 	// Session. Needed to create a client registry.
       
   113 	iSession=CMsvSession::OpenSyncL(*iSessionObserver);
       
   114 	//get entry count
       
   115 	TInt entryCount=GetEntryCountL();
       
   116 	result = (entryCount==KEntryCount? EPass:EFail);
       
   117 	SetTestStepResult(result);
       
   118 	return TestStepResult();
       
   119 	}
       
   120 	
       
   121 
       
   122 TVerdict CPartialDownloadStep::doTestStepPostambleL()
       
   123 	{
       
   124 	return TestStepResult();
       
   125 	}
       
   126 	
       
   127 	
       
   128 
       
   129