|
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 // LoadPopSettings |
|
17 // [Action Parameters] |
|
18 // accountId input TPopAccount |
|
19 // [Action Description] |
|
20 // LoadPopSettings Test Action is intended to retrieve POP settings from |
|
21 // the central repository for the specified account Id. |
|
22 // [APIs Used] |
|
23 // CEmailAccounts::LoadPopSettingsL |
|
24 // __ACTION_INFO_END__ |
|
25 // |
|
26 // |
|
27 |
|
28 #include <pop3set.h> |
|
29 #include <smtpset.h> |
|
30 |
|
31 #include <cemailaccounts.h> |
|
32 #include <iapprefs.h> |
|
33 |
|
34 |
|
35 #include "CMtfTestActionLoadPopSettings.h" |
|
36 #include "CMtfTestCase.h" |
|
37 #include "CMtfTestActionParameters.h" |
|
38 |
|
39 |
|
40 /** |
|
41 Function : NewL |
|
42 Description : |
|
43 @internalTechnology |
|
44 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
45 @param : aActionParams - CMtfTestActionParameters |
|
46 @return : CMtfTestAction* - a base class pointer to the newly created CMtfTestActionLoadPopSettings object |
|
47 @pre none |
|
48 @post none |
|
49 */ |
|
50 CMtfTestAction* CMtfTestActionLoadPopSettings::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
51 { |
|
52 CMtfTestActionLoadPopSettings* self = new (ELeave) CMtfTestActionLoadPopSettings(aTestCase); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(aActionParameters); |
|
55 CleanupStack::Pop(self); |
|
56 return self; |
|
57 } |
|
58 |
|
59 /** |
|
60 Function : CMtfTestActionLoadPopSettings |
|
61 Description : Constructor |
|
62 @internalTechnology |
|
63 @param : aTestCase - CMtfTestCase for the CMtfTestAction base class |
|
64 @return : N/A |
|
65 @pre none |
|
66 @post none |
|
67 */ |
|
68 CMtfTestActionLoadPopSettings::CMtfTestActionLoadPopSettings(CMtfTestCase& aTestCase) : CMtfSynchronousTestAction(aTestCase) |
|
69 { |
|
70 } |
|
71 |
|
72 /** |
|
73 Function : ~CMtfTestActionLoadPopSettings |
|
74 Description : Destructor |
|
75 @internalTechnology |
|
76 @param : |
|
77 @return : |
|
78 @pre |
|
79 @post |
|
80 */ |
|
81 CMtfTestActionLoadPopSettings::~CMtfTestActionLoadPopSettings() |
|
82 { |
|
83 } |
|
84 |
|
85 void CMtfTestActionLoadPopSettings::LoadSettingsL(CEmailAccounts& aAccounts, const TPopAccount& aAccount, CImPop3Settings& aPopSettings, CImIAPPreferences& aPopIapSettings, CImSmtpSettings& aSmtpSettings, CImIAPPreferences& aSmtpIapSettings) |
|
86 { |
|
87 aAccounts.LoadPopSettingsL(aAccount, aPopSettings); |
|
88 aAccounts.LoadPopIapSettingsL(aAccount, aPopIapSettings); |
|
89 TSmtpAccount smtpAccount; |
|
90 aAccounts.GetSmtpAccountL(aAccount.iSmtpService, smtpAccount); |
|
91 aAccounts.LoadSmtpSettingsL(smtpAccount, aSmtpSettings); |
|
92 aAccounts.LoadSmtpIapSettingsL(smtpAccount, aSmtpIapSettings); |
|
93 } |
|
94 |
|
95 /** |
|
96 Function : ExecuteActionL |
|
97 Description : Entry point for the this test action in the test framework |
|
98 @internalTechnology |
|
99 @param : none |
|
100 @return : void |
|
101 @pre none |
|
102 @post none |
|
103 */ |
|
104 void CMtfTestActionLoadPopSettings::ExecuteActionL() |
|
105 { |
|
106 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionLoadPopSettings); |
|
107 TPopAccount accountId = ObtainValueParameterL<TPopAccount>( TestCase(),ActionParameters().Parameter(0) ); |
|
108 TInt shouldFail = ObtainValueParameterL<TInt>( TestCase(),ActionParameters().Parameter(1) ); |
|
109 |
|
110 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
111 CImIAPPreferences* smtpIapPref = CImIAPPreferences::NewLC(); |
|
112 CImSmtpSettings* smtpSet = new(ELeave) CImSmtpSettings(); |
|
113 CleanupStack::PushL(smtpSet); |
|
114 CImIAPPreferences* popIapPref = CImIAPPreferences::NewLC(); |
|
115 CImPop3Settings* popSet = new(ELeave) CImPop3Settings(); |
|
116 CleanupStack::PushL(popSet); |
|
117 |
|
118 // this will leave if an attempt is made to access non existent settings |
|
119 TRAPD( error, LoadSettingsL(*accounts, accountId, *popSet, *popIapPref, *smtpSet, *smtpIapPref) ); |
|
120 |
|
121 if( error != KErrNone ) |
|
122 { |
|
123 |
|
124 if( shouldFail == 1 && error == KErrNotFound ) |
|
125 { |
|
126 TestCase().INFO_PRINTF1(_L("LoadPOPSettingsL Failed as expected ") ); |
|
127 } |
|
128 else |
|
129 { |
|
130 TestCase().ERR_PRINTF2(_L("LoadPOPSettingsL Failed leave with code %d"), error ); |
|
131 TestCase().SetTestStepResult(EFail); |
|
132 } |
|
133 |
|
134 CleanupStack::PopAndDestroy( 5, accounts ); |
|
135 } |
|
136 else |
|
137 { |
|
138 |
|
139 // params loaded ok so we can store them |
|
140 StoreParameterL<CImPop3Settings>(TestCase(), *popSet , ActionParameters().Parameter(2) ); |
|
141 CleanupStack::Pop(popSet); |
|
142 StoreParameterL<CImIAPPreferences>(TestCase(), *popIapPref , ActionParameters().Parameter(3) ); |
|
143 CleanupStack::Pop(popIapPref); |
|
144 StoreParameterL<CImSmtpSettings>(TestCase(), *smtpSet , ActionParameters().Parameter(4) ); |
|
145 CleanupStack::Pop(smtpSet); |
|
146 StoreParameterL<CImIAPPreferences>(TestCase(), *smtpIapPref , ActionParameters().Parameter(5) ); |
|
147 CleanupStack::Pop(smtpIapPref); |
|
148 |
|
149 CleanupStack::PopAndDestroy(accounts); |
|
150 |
|
151 if( shouldFail == 1 ) |
|
152 { |
|
153 // have managed to load settings ok when we should not have |
|
154 TestCase().ERR_PRINTF1(_L("CMtfTestActionLoadPopSettings loaded settings ok when we should not have") ); |
|
155 TestCase().SetTestStepResult(EFail); |
|
156 } |
|
157 |
|
158 } |
|
159 |
|
160 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionLoadPopSettings); |
|
161 |
|
162 TestCase().ActionCompletedL(*this); |
|
163 } |
|
164 |
|
165 |