common/tools/ats/smoketest/email/email/pop/src/T_CheckPop3AccessPoint.cpp
changeset 719 d5603c08781b
child 872 17498133d9ad
equal deleted inserted replaced
718:b18be44be852 719:d5603c08781b
       
     1 // Copyright (c) 2007-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 the License "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // [TestStep Name]
       
    15 // CheckPop3AccessPoint
       
    16 // [Paramaters]
       
    17 // PopAccountName : Name of the Pop account
       
    18 // ConfigFileName: Configuration file name to read for account settings
       
    19 // [TestStep Description]
       
    20 // Checks what access point is being used by an POP account connection
       
    21 // 
       
    22 //
       
    23 
       
    24 #include "T_CheckPop3AccessPoint.h"
       
    25 
       
    26 #include <t_utilsreademailsettingsfromconfigfile.h>
       
    27 #include <t_utilscentralrepository.h>
       
    28 #include <pop3set.h>
       
    29 #include <iapprefs.h>
       
    30 
       
    31 /* Literals Used */
       
    32 _LIT(KAccountName,"PopAccountName");
       
    33 _LIT(KConfigFileName, "PopConfigFileName");
       
    34 
       
    35 /**
       
    36 	Function : CT_MsgCheckPop3AccessPoint
       
    37 	Description : Constructor
       
    38 	@param : aSharedDataPOP		Reference to CT_MsgSharedDataPop
       
    39 	@return : N/A
       
    40 */
       
    41 CT_MsgCheckPop3AccessPoint::CT_MsgCheckPop3AccessPoint(CT_MsgSharedDataPop& aSharedDataPOP)
       
    42 :	CT_MsgSyncStepPOP(aSharedDataPOP)
       
    43 	{
       
    44 	SetTestStepName(KCheckPop3AccessPoint);
       
    45 	}
       
    46 
       
    47 /**
       
    48 	Function : ~CT_MsgCheckPop3AccessPoint
       
    49 	Description : Destructor
       
    50 	@return : N/A
       
    51 */
       
    52 CT_MsgCheckPop3AccessPoint::~CT_MsgCheckPop3AccessPoint()
       
    53 	{
       
    54 	}
       
    55 
       
    56 /**
       
    57 	Function : doTestStepL
       
    58 	Description : 
       
    59 	@return : TVerdict - Test step result
       
    60 	@leave : KMsvNullIndexEntryId	Invalid POP account name specified
       
    61 */
       
    62 TVerdict CT_MsgCheckPop3AccessPoint::doTestStepL()
       
    63 	{
       
    64 	INFO_PRINTF1(_L("Test Step : CheckPop3AccessPoint"));
       
    65 
       
    66 	TPtrC	accountName;
       
    67 	if(!GetStringFromConfig(ConfigSection(), KAccountName, accountName))
       
    68 		{
       
    69 		ERR_PRINTF1(_L("Pop Account name not specified"));
       
    70 		SetTestStepResult(EFail);
       
    71 		return TestStepResult();
       
    72 		}
       
    73 
       
    74 	TPtrC	configFileName;
       
    75 	if(!GetStringFromConfig(ConfigSection(), KConfigFileName, configFileName))
       
    76 		{
       
    77 		ERR_PRINTF1(_L("Configuration file path is not specified"));
       
    78 		SetTestStepResult(EFail);
       
    79 		return TestStepResult();
       
    80 		}
       
    81 
       
    82 	CImIAPPreferences* popPrefs = CImIAPPreferences::NewLC();
       
    83 	CImPop3Settings* popSettings = new (ELeave) CImPop3Settings;
       
    84 	CleanupStack::PushL(popSettings);
       
    85 
       
    86 	TInt expectedAccessPoint = 0;
       
    87 
       
    88 	if(configFileName.CompareF( _L("none") ) != 0 )
       
    89 		{
       
    90 		TRAPD(err, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(configFileName, *popSettings, *popPrefs));
       
    91 		if(err)
       
    92 			{
       
    93 			ERR_PRINTF2(_L("Failure while setting the POP setting parameters, failed with error %d"), err);
       
    94 			SetTestStepResult(EFail);
       
    95 			}
       
    96 		else
       
    97 			{
       
    98 			if (popPrefs->NumberOfIAPs() > 0)
       
    99 				{
       
   100 				TImIAPChoice iapChoice = popPrefs->IAPPreference(0);
       
   101 				expectedAccessPoint = iapChoice.iIAP;
       
   102 				}
       
   103 			}
       
   104 		}
       
   105 
       
   106 	CleanupStack::PopAndDestroy(2, popPrefs);
       
   107 
       
   108 	if (TestStepResult() == EPass)
       
   109 		{
       
   110 		TMsvId serviceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)accountName);
       
   111 
       
   112 		TUint32 accessPoint;
       
   113 		TInt err = iSharedDataPOP.iSession->ServiceAccessPointId(serviceId, accessPoint);
       
   114 		
       
   115 		if (err == KErrNone)
       
   116 			{
       
   117 			if (accessPoint == expectedAccessPoint)
       
   118 				{
       
   119 				INFO_PRINTF1(_L("Access points match"));
       
   120 				}
       
   121 			else
       
   122 				{
       
   123 				ERR_PRINTF3(_L("Access point %d does not match expected %d"), accessPoint, expectedAccessPoint);
       
   124 				SetTestStepResult(EFail);
       
   125 				}
       
   126 			}
       
   127 		else
       
   128 			{
       
   129 			ERR_PRINTF2(_L("Failure getting access point - %d"), err);
       
   130 			SetTestStepResult(EFail);
       
   131 			}
       
   132 		}
       
   133 
       
   134 	return TestStepResult();
       
   135 	}