email/email/pop/src/T_VerifyPopSettings.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 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 // VerifyPopSettings
       
    16 // [Paramaters]
       
    17 // PopAccountName		:		Name of the Pop account
       
    18 // VerifyPopSettings is intended to populate the default POP and SMTP settings,
       
    19 // Load the settings of the account created with the default settings, and compare 
       
    20 // the settings objects.The test passes if all the settings objects match else it fails.
       
    21 // [APIs Used]
       
    22 // GetPopAccountL
       
    23 // LoadPopSettingsL
       
    24 // LoadPopIapSettingsL
       
    25 // 
       
    26 //
       
    27 
       
    28 
       
    29 
       
    30 /**
       
    31  @file
       
    32 */
       
    33 
       
    34 
       
    35 // User include
       
    36 #include "T_VerfiyPopSettings.h"
       
    37 #include <t_utilsreademailsettingsfromconfigfile.h>
       
    38 #include <t_utilscentralrepository.h>
       
    39 
       
    40 
       
    41 // epoc inlcudes
       
    42 #include <cemailaccounts.h>
       
    43 #include <pop3set.h>
       
    44 #include <iapprefs.h>
       
    45 #include <smtpset.h>
       
    46 
       
    47 
       
    48 // Literals used
       
    49 _LIT(KPopAccountName,"PopAccountName");
       
    50 
       
    51 
       
    52 /**
       
    53 CT_MsgVerifyPopSettings()
       
    54 Sets the teststep name to KCheckChildrenCountPop
       
    55 
       
    56 @param aSharedDataPOP
       
    57 Data shared across the POP test steps. Ex. Sessoin 
       
    58 */
       
    59 CT_MsgVerifyPopSettings::CT_MsgVerifyPopSettings(CT_MsgSharedDataPop& aSharedDataPOP)
       
    60 :	CT_MsgSyncStepPOP(aSharedDataPOP) 
       
    61 	{
       
    62 	SetTestStepName(KVerifyPopSettings);
       
    63 	}
       
    64 
       
    65 
       
    66 /**
       
    67 ~CT_MsgVerifyPopSettings()
       
    68 Destructor
       
    69 */
       
    70 CT_MsgVerifyPopSettings::~CT_MsgVerifyPopSettings()
       
    71 	{
       
    72 	}
       
    73 
       
    74 
       
    75 /**
       
    76 doTestStepL()
       
    77 Populate the default POP and SMTP settings, Load the settings of the account 
       
    78 created with the default settings, and compares the settings objects.
       
    79 The test passes if all the settings objects match else it fails.
       
    80 
       
    81 @return
       
    82 Returns the test step result
       
    83 */
       
    84 TVerdict CT_MsgVerifyPopSettings::doTestStepL()
       
    85 	{
       
    86 	INFO_PRINTF1(_L("Test Step: VerifyPopSettings"));
       
    87 	// Read the Pop account name from the ini file
       
    88 	TPtrC popAccountName;
       
    89 	if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName))
       
    90 		{
       
    91 		ERR_PRINTF1(_L("PopAccount Name is not specified"));
       
    92 		SetTestStepResult(EFail);
       
    93 		}
       
    94 	
       
    95 	else
       
    96 		{
       
    97 		// Retrieving the Pop service Id for the given Pop account
       
    98 		TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName);
       
    99 		INFO_PRINTF2(_L("Pop service id is %d"),popServiceId);
       
   100 		
       
   101 		if(popServiceId == KMsvNullIndexEntryId)
       
   102 			{
       
   103 			ERR_PRINTF1(_L("Invalid POP account name specified"));
       
   104 			SetTestStepResult(EFail);
       
   105 			}
       
   106 		else
       
   107 			{
       
   108 			CEmailAccounts* emailAccounts = CEmailAccounts::NewLC();
       
   109 	
       
   110 			CImPop3Settings* popSettings1 = new(ELeave) CImPop3Settings();
       
   111 			CleanupStack::PushL(popSettings1);
       
   112 			
       
   113 			CImIAPPreferences* popIapPrefs1 = CImIAPPreferences::NewLC();
       
   114 			
       
   115 			CImSmtpSettings* smtpSettings1 = new(ELeave) CImSmtpSettings();
       
   116 			CleanupStack::PushL(smtpSettings1);
       
   117 
       
   118 			CImIAPPreferences* smtpIapPrefs1 = CImIAPPreferences::NewLC();
       
   119 
       
   120 			emailAccounts->PopulateDefaultPopSettingsL(*popSettings1, *popIapPrefs1);
       
   121 			emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings1, *smtpIapPrefs1);
       
   122 
       
   123 			
       
   124 	
       
   125 			CImPop3Settings* popSettings2 = new(ELeave) CImPop3Settings();
       
   126 			CleanupStack::PushL(popSettings2);
       
   127 			
       
   128 			CImIAPPreferences* popIapPrefs2 = CImIAPPreferences::NewLC();
       
   129 			
       
   130 			CImSmtpSettings* smtpSettings2 = new(ELeave) CImSmtpSettings();
       
   131 			CleanupStack::PushL(smtpSettings2);
       
   132 
       
   133 			CImIAPPreferences* smtpIapPrefs2 = CImIAPPreferences::NewLC();
       
   134 
       
   135 			TPopAccount popAccount;
       
   136 			emailAccounts->GetPopAccountL(popServiceId, popAccount);
       
   137 			emailAccounts->LoadPopSettingsL(popAccount, *popSettings2);
       
   138 			emailAccounts->LoadPopIapSettingsL(popAccount, *popIapPrefs2);
       
   139 			
       
   140 			TSmtpAccount smtpAccount;
       
   141 			emailAccounts->GetSmtpAccountL(popAccount.iSmtpService, smtpAccount);
       
   142 			emailAccounts->LoadSmtpSettingsL(smtpAccount, *smtpSettings2);
       
   143 			emailAccounts->LoadSmtpIapSettingsL(smtpAccount, *smtpIapPrefs2);
       
   144 
       
   145 			TVerdict result = EPass;
       
   146 			if (!(*popSettings1 == *popSettings2))   
       
   147 				{
       
   148 				// failed
       
   149 				ERR_PRINTF1(_L("Pop3 Settings objects do not match !"));
       
   150 				result = EFail;
       
   151 				}
       
   152 			else if (!(*smtpSettings1 == *smtpSettings2))
       
   153 				{
       
   154 				// failed
       
   155 				ERR_PRINTF1(_L("SMTP Settings objects do not match !"));
       
   156 				result = EFail;
       
   157 				}
       
   158 			else if (!CT_MsgUtilsReadEmailSettingsFromConfigFile::CompareIapPrefs(*popIapPrefs1, *popIapPrefs2))
       
   159 				{
       
   160 				// failed
       
   161 				ERR_PRINTF1(_L("Pop3 IAP Preference objects do not match !"));
       
   162 				result = EFail;
       
   163 				}
       
   164 			else if (!CT_MsgUtilsReadEmailSettingsFromConfigFile::CompareIapPrefs(*smtpIapPrefs1, *smtpIapPrefs2))
       
   165 				{
       
   166 				// failed
       
   167 				ERR_PRINTF1(_L("SMTP IAP Preference objects do not match !"));
       
   168 				result = EFail;
       
   169 				}
       
   170 			SetTestStepResult(result);
       
   171 			CleanupStack::PopAndDestroy(9,emailAccounts);
       
   172 			}
       
   173 		}
       
   174 	return TestStepResult();
       
   175 	}