email/email/smtp/src/T_CheckSmtpSNAPSetting.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     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 // CheckSmtpSNAPSetting
       
    16 // [Paramaters]
       
    17 // SmtpAccountName			:Name of the Smtp account.
       
    18 // ExpectedSNAPDefinition	:ETrue => A SNAP has expected to been provisioned for the SMTP account.
       
    19 // EFalse => A SNAP has not expected to been provisioned for the SMTP account.
       
    20 // ExpectedSNAPPreference	:Expected SNAP ID (Assuming the SNAP has been defined for the SMTP a/c)
       
    21 // This parameter can be ignored if the "ExpectedSNAPDefinition" is EFalse.
       
    22 // Checks the provisioned SNAP information for the SMTP account.
       
    23 // 
       
    24 //
       
    25 
       
    26 //User includes
       
    27 #include "T_CheckSmtpSNAPSetting.h"
       
    28 #include <t_utils.h>
       
    29 #include <t_utilsenumconverter.h>
       
    30 #include <t_utilscentralrepository.h>
       
    31 
       
    32 //Epoc include
       
    33 #include <iapprefs.h>
       
    34 
       
    35 //Literals used
       
    36 _LIT(KSmtpAccountName,"SmtpAccountName");
       
    37 _LIT(KSNAPDefined,"ExpectedSNAPDefinition");
       
    38 _LIT(KSNAPPreference,"ExpectedSNAPPreference");
       
    39 
       
    40 /**
       
    41   Function : CT_MsgCheckSmtpSNAPSetting
       
    42   Description : Constructor 
       
    43   @param : aSharedDataSMTP Reference to CT_MsgSharedDataSmtp
       
    44   @return : N/A
       
    45 */
       
    46 CT_MsgCheckSmtpSNAPSetting::CT_MsgCheckSmtpSNAPSetting(CT_MsgSharedDataSmtp& aSharedDataSMTP)
       
    47 :CT_MsgSyncStepSMTP(aSharedDataSMTP)
       
    48 	{
       
    49 	SetTestStepName(KCheckSmtpSNAPSetting);
       
    50 	}
       
    51 	
       
    52 /**
       
    53   Function : ReadIni
       
    54   Description :Reads the corresponding .ini file and returns EPass or EFail if any of the inputs are missing
       
    55   @return : TBool
       
    56 */
       
    57 TBool CT_MsgCheckSmtpSNAPSetting::ReadIni()
       
    58 	{
       
    59 	TBool result = ETrue;
       
    60 	
       
    61 	if(!GetStringFromConfig(ConfigSection(), KSmtpAccountName, iSmtpAccountName))
       
    62 		{
       
    63 		ERR_PRINTF1(_L("Smtp account name is not specified"));
       
    64 		SetTestStepResult(EFail);
       
    65 		result = EFalse;
       
    66 		}
       
    67 		
       
    68 	if(!GetBoolFromConfig(ConfigSection(), KSNAPDefined, iExpectedSNAPDefinition))
       
    69 		{
       
    70 		ERR_PRINTF1(_L("An expected \"ETrue\" or \"EFalse\" boolean value is not specified for the SNAP definition"));
       
    71 		SetTestStepResult(EFail);
       
    72 		result = EFalse;
       
    73 		}
       
    74 	
       
    75 	return result;
       
    76 	}
       
    77 
       
    78 /**
       
    79   Function : doTestStepL
       
    80   Description : Checks the provisioned SNAP information for the SMTP account settings of a test case.
       
    81   @return : TVerdict - Test step result
       
    82 */		
       
    83 TVerdict CT_MsgCheckSmtpSNAPSetting::doTestStepL()
       
    84 	{
       
    85 	INFO_PRINTF1(_L("Test Step : CheckSmtpSNAPSetting"));
       
    86 	if(ReadIni())
       
    87 		{
       
    88 		CEmailAccounts* accounts = CEmailAccounts::NewL();
       
    89 		CleanupStack::PushL(accounts);
       
    90 		
       
    91 		CImIAPPreferences* smtpIapPrefs = CImIAPPreferences::NewLC();
       
    92 					
       
    93 		TSmtpAccount smtpAccountId;
       
    94 		CT_MsgUtilsCentralRepository::GetSmtpAccountL((TDes&)iSmtpAccountName,smtpAccountId);
       
    95 				
       
    96 		accounts->LoadSmtpIapSettingsL(smtpAccountId, *smtpIapPrefs);	
       
    97 		
       
    98 		TBool actualSNAPDefintion = smtpIapPrefs->SNAPDefined();
       
    99 		
       
   100 		if (actualSNAPDefintion == iExpectedSNAPDefinition)
       
   101 			{
       
   102 			if (actualSNAPDefintion)
       
   103 				{
       
   104 				TInt expectedSNAPPreference = 0;
       
   105 				if(!GetIntFromConfig(ConfigSection(), KSNAPPreference, expectedSNAPPreference))
       
   106 					{
       
   107 					ERR_PRINTF1(_L("An expected SNAP ID value is not specified"));
       
   108 					SetTestStepResult(EFail);
       
   109 					CleanupStack::PopAndDestroy(2,accounts); // smtpIapPrefs, accounts
       
   110 					return TestStepResult();
       
   111 					}
       
   112 				TInt actualSNAPPreference = smtpIapPrefs->SNAPPreference();
       
   113 				
       
   114 				if (actualSNAPPreference != expectedSNAPPreference)
       
   115 					{
       
   116 					ERR_PRINTF3(_L("Actual SNAP ID [%d] does not equal Expected SNAP ID [%d]"),actualSNAPPreference,expectedSNAPPreference);
       
   117 					SetTestStepResult(EFail);
       
   118 					}
       
   119 				else
       
   120 					{
       
   121 					INFO_PRINTF3(_L("Actual SNAP ID [%d] equals Expected SNAP ID [%d]"),actualSNAPPreference,expectedSNAPPreference);
       
   122 					}
       
   123 				}
       
   124 			}
       
   125 		else
       
   126 			{
       
   127 			ERR_PRINTF3(_L("Actual SNAP Defintion [%d] does not equal Expected SNAP Defintion [%d]"),actualSNAPDefintion,iExpectedSNAPDefinition);
       
   128 			SetTestStepResult(EFail);
       
   129 			}
       
   130 	
       
   131 		CleanupStack::PopAndDestroy(2,accounts); // smtpIapPrefs, accounts
       
   132 		}
       
   133 	return TestStepResult();
       
   134 	}