email/pop3andsmtpmtm/popservermtm/test/src/CTestPOPs5Test.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 
       
     2 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 // All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 //
       
     9 // Initial Contributors:
       
    10 // Nokia Corporation - initial contribution.
       
    11 //
       
    12 // Contributors:
       
    13 //
       
    14 // Description:
       
    15 // Brief description of test harness:
       
    16 // Tests a wide range of POPS functionality
       
    17 // Detailed description of test harness:
       
    18 // Implements a range of tests for POPS testing the following
       
    19 // funtionality:
       
    20 // moving, copying, deleting and populating messages
       
    21 // downloading mail with badly formed headers
       
    22 // copying, moving and populating messages that are already populated
       
    23 // online operations
       
    24 // offline operations
       
    25 // 
       
    26 //
       
    27 
       
    28 #include "CTestPOPs5Test.h"
       
    29 #include <iapprefs.h>
       
    30 
       
    31 
       
    32 #if defined (__WINS__)
       
    33 	#define PDD_NAME		_L("ECDRV")
       
    34 	#define LDD_NAME		_L("ECOMM")
       
    35 #else
       
    36 	#define PDD_NAME		_L("EUART1")
       
    37 	#define LDD_NAME		_L("ECOMM")
       
    38 #endif
       
    39 
       
    40 _LIT(KPopsComponent,"T_POPs5");
       
    41 _LIT(KPopTeststart, "T_POPs5 - START POPS Functionality Testing");
       
    42 _LIT(KPopTestend, "T_POPs5 - END POPS Functionality Testing");
       
    43 
       
    44 
       
    45 _LIT(KPOPServer,"msexchange01.closedtest.intra");
       
    46 _LIT8(KPOPInValidUserPass, "popfun");
       
    47 
       
    48 RTest test(KPopsComponent);
       
    49 
       
    50 
       
    51 CTestPOPs5Test::CTestPOPs5Test()
       
    52 	{
       
    53 	}
       
    54 
       
    55 CTestPOPs5Test ::~CTestPOPs5Test()
       
    56 	{
       
    57 	}
       
    58 	
       
    59 void CTestPOPs5Test::SetupL()
       
    60 	{
       
    61 	_LIT(KFunction, "SetupL");
       
    62 	INFO_PRINTF1(KFunction);
       
    63 	INFO_PRINTF1(KPopTeststart);
       
    64 		TInt err;
       
    65 	err=User::LoadPhysicalDevice(PDD_NAME);
       
    66 	if (err!=KErrNone && err!=KErrAlreadyExists)
       
    67 		User::Leave(err);
       
    68 	err=User::LoadLogicalDevice(LDD_NAME);
       
    69 	if (err!=KErrNone && err!=KErrAlreadyExists)
       
    70 		User::Leave(err);
       
    71 	
       
    72 	iActiveWaiter = new(ELeave)CActiveWaiter();
       
    73 	iTestUtils = CEmailTestUtils::NewL(test);
       
    74 	iTestUtils->FileSession().SetSessionPath( _L( "C:\\" ) );
       
    75 	iTestUtils->ClearEmailAccountsL();
       
    76 	iTestUtils->CreateAllTestDirectories();
       
    77 	iTestUtils->CleanMessageFolderL();
       
    78 	
       
    79 	iTestUtils->GoClientSideL();	
       
    80 
       
    81 	if(!ipop3Service)
       
    82 		ipop3Service = iTestUtils->CreatePopServiceL();	
       
    83 
       
    84 
       
    85 	CEmailAccounts* account = CEmailAccounts::NewLC();
       
    86 	isettings = new(ELeave) CImPop3Settings();
       
    87 
       
    88 	
       
    89 	CImIAPPreferences* imapIAP = CImIAPPreferences::NewLC();
       
    90 	iSel = new (ELeave) CMsvEntrySelection;
       
    91 
       
    92 	TPopAccount pop3AccountId;
       
    93 	account->GetPopAccountL(ipop3Service, pop3AccountId);
       
    94   	account->LoadPopSettingsL(pop3AccountId, *isettings);
       
    95 
       
    96 	isettings->SetServerAddressL(KPOPServer);
       
    97 	isettings->SetLoginNameL(KPOPInValidUserPass /*iTestUtils->MachineName()*/);
       
    98 	isettings->SetPasswordL(KPOPInValidUserPass /*iTestUtils->MachineName()*/);
       
    99 	isettings->SetPort(110);
       
   100 
       
   101 
       
   102 	account->SavePopSettingsL(pop3AccountId, *isettings);
       
   103 	CleanupStack::PopAndDestroy(2, account);
       
   104 	
       
   105 	iTestUtils->GoServerSideL();
       
   106 	iTestUtils->InstantiatePopServerMtmL();
       
   107 	iPopServerMtm=iTestUtils->iPopServerMtm;
       
   108 	}
       
   109 
       
   110 void CTestPOPs5Test::TearDownL()
       
   111 	{
       
   112 	_LIT(KFunction, "TearDownL");
       
   113 	INFO_PRINTF1(KFunction);
       
   114 	ipop3Service = NULL;
       
   115 	_LIT(KFunction1, "After NULL");
       
   116 	INFO_PRINTF1(KFunction1);
       
   117 	delete isettings;
       
   118 	_LIT(KFunction2, "After iSettings");
       
   119 	INFO_PRINTF1(KFunction2);
       
   120 	delete iActiveWaiter;
       
   121 	_LIT(KFunction3, "After iActiveWaiter");
       
   122 	INFO_PRINTF1(KFunction3);
       
   123 	delete iTestUtils;
       
   124 	_LIT(KFunction4, "After iTestUtils");
       
   125 	INFO_PRINTF1(KFunction4);
       
   126 	iTestUtils = NULL;
       
   127 	_LIT(KFunction5, "After iTestUtils NULL");
       
   128 	INFO_PRINTF1(KFunction5);
       
   129 	INFO_PRINTF1(KPopTestend);
       
   130 	}
       
   131 
       
   132 
       
   133 void  CTestPOPs5Test::TestRunPops5CopyToLocalLTestsL()
       
   134 	{
       
   135 	//-------------------------------
       
   136 	//	Test 1 void CopyToLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus);
       
   137 	//-------------------------------
       
   138 	
       
   139 	ConnectToRemoteServerL();
       
   140 	
       
   141 	_LIT(KFunction1, "TestCopyToLocalL");
       
   142 	INFO_PRINTF1(KFunction1);
       
   143 	
       
   144 	CMsvEntrySelection* aSelection = new (ELeave) CMsvEntrySelection;
       
   145 	CleanupStack::PushL(aSelection);
       
   146 	aSelection->AppendL(ipop3Service);
       
   147 	
       
   148 	iTestUtils->iServerEntry->SetEntry(ipop3Service);
       
   149 	iTestUtils->iServerEntry->GetChildren(*aSelection);
       
   150 	
       
   151 	TRAPD(err1, iPopServerMtm->CopyToLocalL(*aSelection,ipop3Service,iActiveWaiter->iStatus));
       
   152 	iActiveWaiter->WaitActive();
       
   153 	
       
   154 	ASSERT_EQUALS( err1, KErrNone );
       
   155 
       
   156 
       
   157 	//-------------------------------
       
   158 	//	Test 2 void MoveToLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus);
       
   159 	//-------------------------------
       
   160 	
       
   161 	_LIT(KFunction2, "TestMoveToLocalL");
       
   162 	INFO_PRINTF1(KFunction2);
       
   163 
       
   164 	CMsvEntrySelection* aSelection1 = new (ELeave) CMsvEntrySelection;
       
   165 	CleanupStack::PushL(aSelection1);
       
   166 	aSelection1->AppendL(ipop3Service);
       
   167 	
       
   168 	iTestUtils->iServerEntry->SetEntry(ipop3Service);
       
   169 	iTestUtils->iServerEntry->GetChildren(*aSelection1);
       
   170 	
       
   171 	TRAPD(err11, iPopServerMtm->MoveToLocalL(*aSelection1,ipop3Service,iActiveWaiter->iStatus));
       
   172 	iActiveWaiter->WaitActive();
       
   173 	
       
   174 	ASSERT_EQUALS( err11, KErrNone );
       
   175 
       
   176 	//-------------------------------
       
   177 	//	Test 3 void CopyFromLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus);
       
   178 	//-------------------------------
       
   179 	
       
   180 	_LIT(KFunction3, "TestCopyFromLocalL");
       
   181 	INFO_PRINTF1(KFunction3);
       
   182 
       
   183 	CMsvEntrySelection* aSelection21 = new (ELeave) CMsvEntrySelection;
       
   184 	CleanupStack::PushL(aSelection21);
       
   185 	TRAPD(err21, iPopServerMtm->CopyFromLocalL(*aSelection21,KMsvGlobalInBoxIndexEntryId,iActiveWaiter->iStatus));
       
   186 	ASSERT_EQUALS( err21, KErrNotSupported );
       
   187 
       
   188 
       
   189 	//-------------------------------
       
   190 	//	Test 4 void DeleteAllL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus);
       
   191 	//-------------------------------
       
   192 
       
   193 	_LIT(KFunction4, "TestDeleteAllL");
       
   194 	INFO_PRINTF1(KFunction4);
       
   195 
       
   196 	
       
   197 	CMsvEntrySelection* aSelection12 = new (ELeave) CMsvEntrySelection;
       
   198 	CleanupStack::PushL(aSelection12);
       
   199 	aSelection12->AppendL(ipop3Service);
       
   200 	
       
   201 	iTestUtils->iServerEntry->SetEntry(ipop3Service);
       
   202 	iTestUtils->iServerEntry->GetChildren(*aSelection12);
       
   203 	
       
   204 	TRAPD(err12, iPopServerMtm->DeleteAllL(*aSelection12,iActiveWaiter->iStatus));
       
   205 	iActiveWaiter->WaitActive();
       
   206 	
       
   207 	ASSERT_EQUALS( err12, KErrNone );
       
   208 
       
   209 
       
   210 	//-------------------------------
       
   211 	//	Test 5 void CopyWithinServiceL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
       
   212 	//-------------------------------
       
   213 	
       
   214 	_LIT(KFunction5, "TestCopyWithinServiceL");
       
   215 	INFO_PRINTF1(KFunction5);
       
   216 
       
   217 	CMsvEntrySelection* aSelection13 = new (ELeave) CMsvEntrySelection;
       
   218 	CleanupStack::PushL(aSelection13);
       
   219 	TRAPD(err13, iPopServerMtm->CopyWithinServiceL(*aSelection13,KMsvGlobalInBoxIndexEntryId,iActiveWaiter->iStatus));
       
   220 	ASSERT_EQUALS( err13, KErrNotSupported );
       
   221 
       
   222 
       
   223 
       
   224 	//-------------------------------
       
   225 	//	Test 6 void void MoveFromLocalL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
       
   226 	//-------------------------------
       
   227 	
       
   228 	_LIT(KFunction6, "TestMoveFromLocalL");
       
   229 	INFO_PRINTF1(KFunction6);
       
   230 
       
   231 	CMsvEntrySelection* aSelection14 = new (ELeave) CMsvEntrySelection;
       
   232 	CleanupStack::PushL(aSelection14);
       
   233 	TRAPD(err14, iPopServerMtm->MoveFromLocalL(*aSelection14,KMsvGlobalInBoxIndexEntryId,iActiveWaiter->iStatus));
       
   234 	ASSERT_EQUALS( err14, KErrNotSupported );
       
   235 
       
   236 
       
   237 
       
   238 	//-------------------------------
       
   239 	//	Test 7 void MoveWithinServiceL(const CMsvEntrySelection& aSelection,TMsvId aDestination, TRequestStatus& aStatus);
       
   240 	//-------------------------------
       
   241 	_LIT(KFunction7, "TestMoveWithinServiceL");
       
   242 	INFO_PRINTF1(KFunction7);
       
   243 
       
   244 	CMsvEntrySelection* aSelection15 = new (ELeave) CMsvEntrySelection;
       
   245 	CleanupStack::PushL(aSelection15);
       
   246 	TRAPD(err15, iPopServerMtm->MoveWithinServiceL(*aSelection15,KMsvGlobalInBoxIndexEntryId,iActiveWaiter->iStatus));
       
   247 	ASSERT_EQUALS( err15, KErrNotSupported );
       
   248 
       
   249 	
       
   250 	//-------------------------------
       
   251 	//	Test 8 void CreateL(TMsvEntry aNewEntry, TRequestStatus& aStatus);
       
   252 	//-------------------------------
       
   253 	
       
   254 	_LIT(KFunction8, "TestCreateL");
       
   255 	INFO_PRINTF1(KFunction8);
       
   256 
       
   257 	TMsvEntry aNewEntry = iTestUtils->iServerEntry->Entry();
       
   258 	
       
   259 	TRAPD(err16, iPopServerMtm->CreateL(aNewEntry,iActiveWaiter->iStatus));
       
   260 	ASSERT_EQUALS( err16, KErrNotSupported );
       
   261 
       
   262 	DisconnectL(); 
       
   263 	CleanupStack::PopAndDestroy(7,aSelection); // aSelection
       
   264 	}
       
   265 	
       
   266 //Connect to tyhe Server 
       
   267 void CTestPOPs5Test::ConnectToRemoteServerL()
       
   268 	{
       
   269 	TBuf8<128> parameter;
       
   270 	iSel->AppendL(ipop3Service);
       
   271 	TPop3Progress temp;	
       
   272 	TPckgC<TPop3Progress> paramPack(temp);
       
   273 	iPopServerMtm->StartCommandL(*iSel, KPOP3MTMConnect, parameter, iActiveWaiter->iStatus);
       
   274 	iActiveWaiter->WaitActive();
       
   275 	const TDesC8& progBuf = iTestUtils->iPopServerMtm->Progress();	
       
   276 	paramPack.Set(progBuf);
       
   277 	TPop3Progress progress=paramPack();	
       
   278 	ASSERT_EQUALS( progress.iErrorCode, KErrNone );
       
   279 	}
       
   280 //Disconnecting the Connection
       
   281 void CTestPOPs5Test::DisconnectL()
       
   282 	{
       
   283 	TBuf8<128> parameter;
       
   284 	iSel->AppendL(ipop3Service);
       
   285 	iPopServerMtm->StartCommandL(*iSel,KPOP3MTMDisconnect , parameter, iActiveWaiter->iStatus);
       
   286 	iActiveWaiter->WaitActive();
       
   287 	ASSERT_EQUALS( iActiveWaiter->iStatus.Int( ), KErrNone );
       
   288 	}
       
   289 	
       
   290 CTestSuite* CTestPOPs5Test::CreateSuiteL(const TDesC& aName)
       
   291 	{
       
   292 	SUB_SUITE;
       
   293 	ADD_ASYNC_TEST_STEP(TestRunPops5CopyToLocalLTestsL);
       
   294 	END_SUITE;
       
   295 	}
       
   296 
       
   297