|
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 // ComparePopSettings |
|
16 // [Paramaters] |
|
17 // PopAccountName : Name of the Pop account |
|
18 // ConfigFileName : Config file from which the Pop account settings are read |
|
19 // ComparePopSettings is intended to compare the Pop account settings. |
|
20 // |
|
21 // |
|
22 |
|
23 |
|
24 |
|
25 /** |
|
26 @file cexppop3mailinfo.h |
|
27 */ |
|
28 |
|
29 |
|
30 // User includes |
|
31 #include "T_ComparePopSettings.h" |
|
32 #include <t_utilsconfigfileparserutility.h> |
|
33 #include <t_utilsreademailsettingsfromconfigfile.h> |
|
34 #include <t_utilscentralrepository.h> |
|
35 |
|
36 |
|
37 // Epoc includes |
|
38 #include <cemailaccounts.h> |
|
39 #include <iapprefs.h> |
|
40 #include <pop3set.h> |
|
41 #include <smtpset.h> |
|
42 |
|
43 |
|
44 // Literals Used |
|
45 _LIT(KPopAccountName,"PopAccountName"); |
|
46 _LIT(KPopConfigFileName,"PopConfigFileName"); |
|
47 _LIT(KMatchExpected,"MatchExpected"); |
|
48 |
|
49 |
|
50 /** |
|
51 CT_MsgComparePopSettings() |
|
52 Constructor - Initializes the data members. |
|
53 |
|
54 @param aSharedDataPOP |
|
55 Data shared across the POP test steps. Ex. Session |
|
56 */ |
|
57 CT_MsgComparePopSettings::CT_MsgComparePopSettings(CT_MsgSharedDataPop& aSharedDataPOP) |
|
58 : CT_MsgSyncStepPOP(aSharedDataPOP) |
|
59 { |
|
60 SetTestStepName(KComparePopSettings); |
|
61 } |
|
62 |
|
63 |
|
64 /** |
|
65 ~CT_MsgComparePopSettings |
|
66 Destructor |
|
67 */ |
|
68 CT_MsgComparePopSettings::~CT_MsgComparePopSettings() |
|
69 { |
|
70 } |
|
71 |
|
72 |
|
73 /** |
|
74 doTestStepL() |
|
75 Reads the Pop account name and config file name from the ini file |
|
76 Compares the settings of the Imap account. |
|
77 |
|
78 @return |
|
79 Returns the test step result |
|
80 */ |
|
81 TVerdict CT_MsgComparePopSettings::doTestStepL() |
|
82 { |
|
83 INFO_PRINTF1(_L("Test Step : ComparePopSettings")); |
|
84 // Read the POP account name from the ini file |
|
85 TPtrC popAccountName; |
|
86 if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) |
|
87 { |
|
88 ERR_PRINTF1(_L("PopAccount Name is not specified")); |
|
89 SetTestStepResult(EFail); |
|
90 } |
|
91 else |
|
92 { |
|
93 // Retrieving the Pop service Id for the given Pop account |
|
94 TMsvId popServiceId = KMsvNullIndexEntryId; |
|
95 TRAPD(err,popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName)); |
|
96 INFO_PRINTF2(_L("Pop service id is %d"),popServiceId); |
|
97 |
|
98 TBool matchExpected = ETrue; |
|
99 GetBoolFromConfig(ConfigSection(), KMatchExpected, matchExpected); |
|
100 |
|
101 TVerdict result = EPass; |
|
102 TPtrC configFileName; |
|
103 |
|
104 if(popServiceId == KMsvNullIndexEntryId) |
|
105 { |
|
106 INFO_PRINTF1(_L("Invalid POP account name is specified")); |
|
107 result = EFail; |
|
108 } |
|
109 else |
|
110 { |
|
111 if(!GetStringFromConfig(ConfigSection(), KPopConfigFileName, configFileName)) |
|
112 { |
|
113 ERR_PRINTF1(_L("Configuration file path is not specified")); |
|
114 SetTestStepResult(EFail); |
|
115 } |
|
116 else |
|
117 { |
|
118 CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); |
|
119 |
|
120 // Creating the first set of settings objects |
|
121 CImPop3Settings* popSettings1 = new(ELeave) CImPop3Settings(); |
|
122 CleanupStack::PushL(popSettings1); |
|
123 |
|
124 CImIAPPreferences* popIapPrefs1 = CImIAPPreferences::NewLC(); |
|
125 |
|
126 CImSmtpSettings* smtpSettings1 = new(ELeave) CImSmtpSettings(); |
|
127 CleanupStack::PushL(smtpSettings1); |
|
128 |
|
129 CImIAPPreferences* smtpIapPrefs1 = CImIAPPreferences::NewLC(); |
|
130 |
|
131 // Creating the second set of settings objects |
|
132 CImPop3Settings* popSettings2= new(ELeave) CImPop3Settings(); |
|
133 CleanupStack::PushL(popSettings2); |
|
134 |
|
135 CImIAPPreferences* popIapPrefs2 = CImIAPPreferences::NewLC(); |
|
136 |
|
137 CImSmtpSettings* smtpSettings2 = new(ELeave) CImSmtpSettings(); |
|
138 CleanupStack::PushL(smtpSettings2); |
|
139 |
|
140 CImIAPPreferences* smtpIapPrefs2 = CImIAPPreferences::NewLC(); |
|
141 |
|
142 emailAccounts->PopulateDefaultPopSettingsL(*popSettings2, *popIapPrefs2); |
|
143 emailAccounts->PopulateDefaultSmtpSettingsL(*smtpSettings2, *smtpIapPrefs2); |
|
144 |
|
145 TPopAccount popAccount; |
|
146 emailAccounts-> GetPopAccountL(popServiceId, popAccount); |
|
147 |
|
148 TRAPD(error1, LoadAccountSettingsL(*emailAccounts,popAccount, |
|
149 *popSettings1,*popIapPrefs1,*smtpSettings1,*smtpIapPrefs1)); |
|
150 |
|
151 if(error1 != KErrNone) |
|
152 { |
|
153 ERR_PRINTF2(_L("LoadPOPPSettingsL Failed with error code %d"), error1); |
|
154 result = EFail; |
|
155 SetTestStepResult(EFail); |
|
156 } |
|
157 else |
|
158 { |
|
159 if(configFileName.CompareF(_L("none")) != 0) |
|
160 { |
|
161 TRAPD(err, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(configFileName, *popSettings2, *popIapPrefs2)); |
|
162 if(err) |
|
163 { |
|
164 ERR_PRINTF2(_L("Failure while setting the Pop setting parameters, failed with error %d"), err); |
|
165 SetTestStepResult(EFail); |
|
166 } |
|
167 else |
|
168 { |
|
169 TRAPD(error, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadSmtpSettingsFromConfigurationFileL(configFileName, *smtpSettings2, *smtpIapPrefs2)); |
|
170 if(error) |
|
171 { |
|
172 ERR_PRINTF2(_L("Failure while setting the SMTP setting parameters, failed with error %d"), error); |
|
173 SetTestStepResult(EFail); |
|
174 } |
|
175 } |
|
176 } |
|
177 if(TestStepResult() == EPass) |
|
178 { |
|
179 result = CompareSettings(*popSettings1 , *popSettings2 , |
|
180 *smtpSettings1,*smtpSettings2, |
|
181 *popIapPrefs1,*popIapPrefs2, |
|
182 *smtpIapPrefs1,*smtpIapPrefs2); |
|
183 } |
|
184 } |
|
185 CleanupStack::PopAndDestroy(9,emailAccounts); |
|
186 |
|
187 } |
|
188 } |
|
189 |
|
190 // if the parameters did not match and we expected them to then fail the test |
|
191 if(result == EPass && matchExpected) |
|
192 { |
|
193 INFO_PRINTF1(_L("*********Passed As Expected*******")); |
|
194 SetTestStepResult(EPass); |
|
195 } |
|
196 else if(result == EFail && !matchExpected) |
|
197 { |
|
198 INFO_PRINTF1(_L("*******Failed as Expected********")); |
|
199 SetTestStepResult(EPass); // This is required as some checks where it will fail, at that pt teststep might have been set to fail |
|
200 } |
|
201 else |
|
202 { |
|
203 ERR_PRINTF1(_L("Pop settings Comparison Failed")); |
|
204 SetTestStepResult(EFail); |
|
205 } |
|
206 INFO_PRINTF1(_L("ComparePopSettings completed")); |
|
207 } |
|
208 return TestStepResult(); |
|
209 } |
|
210 |
|
211 /** |
|
212 CompareSettings() |
|
213 Compares the two sets of POP settings, IAPPrefernces, and SMTP settings. |
|
214 |
|
215 @param aPopSettings1 |
|
216 An object of type CImPop3Settings |
|
217 |
|
218 @param aPopSettings2 |
|
219 An object of type CImPop3Settings |
|
220 |
|
221 @param aPopIapPrefs1 |
|
222 An object of type CImIAPPreferences |
|
223 |
|
224 @param aPopIapPrefs2 |
|
225 An object of type CImIAPPreferences |
|
226 |
|
227 @param aSmtpIapPrefs1 |
|
228 An object of type CImIAPPreferences |
|
229 |
|
230 @param aSmtpIapPrefs2 |
|
231 An object of type CImIAPPreferences |
|
232 |
|
233 @param aSmtpSettings |
|
234 An object of type CImSmtpSettings |
|
235 |
|
236 @param aSmtpIapSettings |
|
237 An object of type CImIAPPreferences |
|
238 |
|
239 @return |
|
240 Returns EPass if exactly the same for all values in the two sets of parameters. |
|
241 Returns EFail if any value is different between the two sets of parameters. |
|
242 */ |
|
243 TVerdict CT_MsgComparePopSettings::CompareSettings(CImPop3Settings& aPopSettings1, CImPop3Settings& aPopSettings2, |
|
244 CImSmtpSettings& aSmtpSettings1,CImSmtpSettings& aSmtpSettings2, CImIAPPreferences& aPopIapPrefs1, |
|
245 CImIAPPreferences& aPopIapPrefs2, CImIAPPreferences& aSmtpIapPrefs1, CImIAPPreferences& aSmtpIapPrefs2) |
|
246 { |
|
247 TVerdict result = EPass; |
|
248 if (!(aPopSettings1 == aPopSettings2)) |
|
249 { |
|
250 // failed |
|
251 ERR_PRINTF1(_L("Pop3 Settings objects do not match !")); |
|
252 result = EFail; |
|
253 } |
|
254 else if (!(aSmtpSettings1 == aSmtpSettings2)) |
|
255 { |
|
256 // failed |
|
257 ERR_PRINTF1(_L("SMTP Settings objects do not match !")); |
|
258 result = EFail; |
|
259 } |
|
260 else if (!CT_MsgUtilsReadEmailSettingsFromConfigFile::CompareIapPrefs(aPopIapPrefs1, aPopIapPrefs2)) |
|
261 { |
|
262 // failed |
|
263 ERR_PRINTF1(_L("Pop3 IAP Preference objects do not match !")); |
|
264 result = EFail; |
|
265 } |
|
266 else if (!CT_MsgUtilsReadEmailSettingsFromConfigFile::CompareIapPrefs(aSmtpIapPrefs1, aSmtpIapPrefs2)) |
|
267 { |
|
268 // failed |
|
269 ERR_PRINTF1(_L("SMTP IAP Preference objects do not match !")); |
|
270 result = EFail; |
|
271 } |
|
272 |
|
273 return result; |
|
274 } |
|
275 |
|
276 /** |
|
277 LoadAccountSettingsL() |
|
278 This function loads the IMAP and SMTP settings object from the IMAP account given |
|
279 |
|
280 @param aEmailAccount |
|
281 An object of type CEmailAccounts |
|
282 |
|
283 @param aAccount |
|
284 An object of type TPopAccount |
|
285 |
|
286 @param aPopSettings |
|
287 An object of type CImPop3Settings |
|
288 |
|
289 @param aPopIapSettings |
|
290 An object of type CImIAPPreferences |
|
291 |
|
292 @param aSmtpSettings |
|
293 An object of type CImSmtpSettings |
|
294 |
|
295 @param aSmtpIapSettings |
|
296 An object of type CImIAPPreferences |
|
297 |
|
298 @return : void |
|
299 */ |
|
300 void CT_MsgComparePopSettings::LoadAccountSettingsL(CEmailAccounts& aEmailAccount, const TPopAccount& aAccount, CImPop3Settings& aPopSettings, |
|
301 CImIAPPreferences& aPopIapSettings,CImSmtpSettings& aSmtpSettings, CImIAPPreferences& aSmtpIapSettings) |
|
302 { |
|
303 aEmailAccount.LoadPopSettingsL(aAccount, aPopSettings); |
|
304 aEmailAccount.LoadPopIapSettingsL(aAccount, aPopIapSettings); |
|
305 |
|
306 TSmtpAccount smtpAccount; |
|
307 aEmailAccount.GetSmtpAccountL(aAccount.iSmtpService, smtpAccount); |
|
308 aEmailAccount.LoadSmtpSettingsL(smtpAccount, aSmtpSettings); |
|
309 aEmailAccount.LoadSmtpIapSettingsL(smtpAccount, aSmtpIapSettings); |
|
310 } |