messagingfw/msgtestfw/TestActions/Email/Pop3/src/CMtfTestActionComparePopSettings.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2004-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 // __ACTION_INFO_BEGIN__ 
       
    15 // [Action Name]
       
    16 // ComparePopSettings
       
    17 // [Action Parameters]
       
    18 // PopSettings1			input		CImPop4Settings
       
    19 // PopIAP1				input		CImIAPPreferences
       
    20 // SMTPSettings1		input		CImSMTPSettings
       
    21 // SmtpIAP1				input		CImIAPPreferences
       
    22 // PopSettings2			input		CImPop4Settings
       
    23 // PopIAP2				input		CImIAPPreferences
       
    24 // SMTPSettings2		input		CImSMTPSettings
       
    25 // SmtpIAP2				input		CImIAPPreferences
       
    26 // [Action Description]
       
    27 // ComparePopSettings Test Action is intended to compare the POP account settings.
       
    28 // [APIs Used]	
       
    29 // CImPop3Settings::ServerAddress
       
    30 // CImPop3Settings::LoginName
       
    31 // CImPop3Settings::Password
       
    32 // CImPop3Settings::MaxEmailSize
       
    33 // CImPop3Settings::Port
       
    34 // CImPop3Settings::InboxSynchronisationLimit
       
    35 // CImPop3Settings::UserAddress
       
    36 // CImPop3Settings::AutoSendOnConnect
       
    37 // CImPop3Settings::Apop
       
    38 // CImPop3Settings::DisconnectedUserMode
       
    39 // CImPop3Settings::DeleteEmailWhenDisconnecting
       
    40 // CImPop3Settings::AcknowledgeReceipts
       
    41 // CImPop3Settings::GetMailOptions
       
    42 // CImPop3Settings::PopulationLimit
       
    43 // CImPop3Settings::SecureSockets
       
    44 // CImPop3Settings::Version
       
    45 // CImSmtpSettings::ServerAddressL
       
    46 // CImSmtpSettings::EmailAddressL
       
    47 // CImSmtpSettings::Version
       
    48 // CImSmtpSettings::UserAddress
       
    49 // CImSmtpSettings::Port
       
    50 // CImSmtpSettings::BodyEncoding
       
    51 // CImSmtpSettings::DefaultMsgCharSet
       
    52 // CImSmtpSettings::ReceiptAddress
       
    53 // CImSmtpSettings::RequestReceipts
       
    54 // CImSmtpSettings::SendMessageOption
       
    55 // CImSmtpSettings::EmailAlias
       
    56 // CImIAPPreferences::Version
       
    57 // __ACTION_INFO_END__
       
    58 // 
       
    59 //
       
    60 
       
    61 
       
    62 #include <pop3set.h>
       
    63 #include <smtpset.h>
       
    64 #include <iapprefs.h>
       
    65 
       
    66 #include "CMtfTestActionComparePopSettings.h"
       
    67 #include "CMtfTestCase.h"
       
    68 #include "CMtfTestActionParameters.h"
       
    69 #include "CMtfTestActionUtilsPopScripts.h"
       
    70 
       
    71 
       
    72 /**
       
    73   Function : NewL
       
    74   Description : 
       
    75   @internalTechnology
       
    76   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    77   @param : aActionParams - CMtfTestActionParameters 
       
    78   @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionComparePopSettings object
       
    79   @pre none
       
    80   @post none
       
    81 */
       
    82 CMtfTestAction* CMtfTestActionComparePopSettings::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters)
       
    83 	{
       
    84 	CMtfTestActionComparePopSettings* self = new (ELeave) CMtfTestActionComparePopSettings(aTestCase);
       
    85 	CleanupStack::PushL(self);
       
    86 	self->ConstructL(aActionParameters);
       
    87 	CleanupStack::Pop(self);
       
    88 	return self;
       
    89 	}
       
    90 
       
    91 /**
       
    92   Function : CMtfTestActionComparePopSettings
       
    93   Description : Constructor
       
    94   @internalTechnology
       
    95   @param : aTestCase - CMtfTestCase for the CMtfTestAction base class
       
    96   @return : N/A
       
    97   @pre none
       
    98   @post none
       
    99 */
       
   100 CMtfTestActionComparePopSettings::CMtfTestActionComparePopSettings(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase)
       
   101 	{
       
   102 	}
       
   103 
       
   104 /**
       
   105   Function : ~CMtfTestActionComparePopSettings
       
   106   Description : Destructor
       
   107   @internalTechnology
       
   108   @param :
       
   109   @return : 
       
   110   @pre 
       
   111   @post 
       
   112 */
       
   113 CMtfTestActionComparePopSettings::~CMtfTestActionComparePopSettings()
       
   114 	{
       
   115 	}
       
   116 
       
   117 /**
       
   118   Function : ExecuteActionL
       
   119   Description : Entry point for the this test action in the test framework
       
   120   @internalTechnology
       
   121   @param : none
       
   122   @return : void
       
   123   @pre none 
       
   124   @post none
       
   125 */
       
   126 void CMtfTestActionComparePopSettings::ExecuteActionL()
       
   127 	{
       
   128 	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionComparePopSettings);
       
   129 	CImPop3Settings* popSettings1 = ObtainParameterReferenceL<CImPop3Settings>(TestCase(), ActionParameters().Parameter(0));
       
   130 	CImPop3Settings* popSettings2 = ObtainParameterReferenceL<CImPop3Settings>(TestCase(), ActionParameters().Parameter(1));
       
   131 	CImIAPPreferences* popPrefs1 = ObtainParameterReferenceL<CImIAPPreferences>(TestCase(), ActionParameters().Parameter(2));
       
   132 	CImIAPPreferences* popPrefs2 = ObtainParameterReferenceL<CImIAPPreferences>(TestCase(), ActionParameters().Parameter(3));
       
   133 	CImSmtpSettings* smtpSettings1 = ObtainParameterReferenceL<CImSmtpSettings>(TestCase(), ActionParameters().Parameter(4));
       
   134 	CImSmtpSettings* smtpSettings2 = ObtainParameterReferenceL<CImSmtpSettings>(TestCase(), ActionParameters().Parameter(5));
       
   135 	CImIAPPreferences* smtpPrefs1 = ObtainParameterReferenceL<CImIAPPreferences>(TestCase(), ActionParameters().Parameter(6));
       
   136 	CImIAPPreferences* smtpPrefs2 = ObtainParameterReferenceL<CImIAPPreferences>(TestCase(), ActionParameters().Parameter(7));
       
   137 	
       
   138 	// final param indicates whether we expect the input params to match
       
   139 	// a non-zero value indicates we expect a match
       
   140 	TInt matchExpected = ObtainValueParameterL<TInt>(TestCase(), ActionParameters().Parameter(8));
       
   141 	
       
   142 	TVerdict result = EPass;
       
   143 	if ( ! ( *popSettings1 == *popSettings2 ) )
       
   144 		{
       
   145 		// failed
       
   146 		TestCase().ERR_PRINTF1(_L("POP3 Settings objects do not match !"));
       
   147 		result = EFail;
       
   148 		}
       
   149 	else if(!(*smtpSettings1 == *smtpSettings2))
       
   150 		{
       
   151 		// failed
       
   152 		TestCase().ERR_PRINTF1(_L("SMTP Settings objects do not match !"));
       
   153 		result = EFail;
       
   154 		}
       
   155 	else if (!CompareIapPrefs(*popPrefs1, *popPrefs2))
       
   156 		{
       
   157 		// failed
       
   158 		TestCase().ERR_PRINTF1(_L("POP3 IAP Preference objects do not match !"));
       
   159 		result = EFail;
       
   160 		}
       
   161 	else if (!CompareIapPrefs(*smtpPrefs1, *smtpPrefs2))
       
   162 		{
       
   163 		// failed
       
   164 		TestCase().ERR_PRINTF1(_L("SMTP IAP Preference objects do not match !"));
       
   165 		result = EFail;
       
   166 		}
       
   167 
       
   168 	// if the parameters did not match and we expected them to then fail the test			
       
   169 	if( result == EFail && matchExpected != 0 )
       
   170 		{
       
   171 		TestCase().ERR_PRINTF1(_L("Expected to match but failed comparison"));
       
   172 		TestCase().SetTestStepResult(EFail);	
       
   173 		}
       
   174 		
       
   175 	// if the parameters matched and we didn't expected them to then fail the test
       
   176 	if( result == EPass && matchExpected == 0)
       
   177 		{
       
   178 		TestCase().ERR_PRINTF1(_L("Expected to fail comparison but matched"));
       
   179 		TestCase().SetTestStepResult(EFail);	
       
   180 		}
       
   181 	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionComparePopSettings);	
       
   182 	TestCase().ActionCompletedL(*this);
       
   183 	}
       
   184 
       
   185 TBool CMtfTestActionComparePopSettings::CompareIapPrefs(CImIAPPreferences& prefs1, CImIAPPreferences& prefs2) const
       
   186 	{
       
   187 	// Compare version
       
   188 	if (prefs1.Version() != prefs2.Version())
       
   189 		{
       
   190 		return EFalse;
       
   191 		}
       
   192 	
       
   193 	// Compare number of IAPs stored
       
   194 	TInt numIAPs1 = prefs1.NumberOfIAPs();
       
   195 	
       
   196 	if (numIAPs1 != prefs2.NumberOfIAPs())
       
   197 		{
       
   198 		return EFalse;
       
   199 		}
       
   200 	
       
   201 	// Compare individual IAPs
       
   202 	for (TInt i = 0; i < numIAPs1; i++)
       
   203 		{
       
   204 		if (prefs1.IAPPreference(i).iIAP != prefs2.IAPPreference(i).iIAP ||
       
   205 			prefs1.IAPPreference(i).iDialogPref != prefs2.IAPPreference(i).iDialogPref)
       
   206 			{
       
   207 			return EFalse;
       
   208 			}
       
   209 		}
       
   210 	
       
   211 	return ETrue;
       
   212 	}
       
   213