|
1 |
|
2 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 // All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Nokia Corporation - initial contribution. |
|
11 // |
|
12 // Contributors: |
|
13 // |
|
14 // Description: |
|
15 // Name of test harness: T_pops_synchronise |
|
16 // Component: POPS |
|
17 // 0Brief description of test harness: |
|
18 // Tests the changes to POPS for small devices which permit setting a limit |
|
19 // on the number of emails downloaded at any time. |
|
20 // Detailed description of test harness: |
|
21 // Implements a range of tests for POPS testing the following |
|
22 // funtionality: |
|
23 // -Setting sychronisation limit |
|
24 // -Populating the remote mailbox with headers up to the synchronisation limit |
|
25 // -Deleting headers from the remote mailbox under the service entry |
|
26 // if message has been deleted from POP3 mailbox. |
|
27 // |
|
28 // |
|
29 |
|
30 |
|
31 |
|
32 #include "CTestPOPSynchroniseTest.h" |
|
33 #include <iapprefs.h> |
|
34 |
|
35 |
|
36 #if defined (__WINS__) |
|
37 #define PDD_NAME _L("ECDRV") |
|
38 #define LDD_NAME _L("ECOMM") |
|
39 #else |
|
40 #define PDD_NAME _L("EUART1") |
|
41 #define LDD_NAME _L("ECOMM") |
|
42 #endif |
|
43 |
|
44 _LIT(KPopsComponent,"T_POPsSynchronise"); |
|
45 _LIT(KPopTeststart, "T_POPsSynchronise - START POPS Synchronise Functionality Testing"); |
|
46 _LIT(KPopTestend, "T_POPsSynchronise - END POPS Synchronise Functionality Testing"); |
|
47 |
|
48 //_LIT(KPOPServer, "10.192.197.21"); |
|
49 |
|
50 _LIT(KPOPServer,"msexchange01.closedtest.intra"); |
|
51 _LIT8(KPOPInValidUserPass, "popsyn"); |
|
52 |
|
53 RTest test(KPopsComponent); |
|
54 |
|
55 |
|
56 CTestPOPSynchroniseTest::CTestPOPSynchroniseTest() |
|
57 { |
|
58 } |
|
59 |
|
60 CTestPOPSynchroniseTest ::~CTestPOPSynchroniseTest() |
|
61 { |
|
62 } |
|
63 |
|
64 void CTestPOPSynchroniseTest::SetupL() |
|
65 { |
|
66 _LIT(KFunction, "SetupL"); |
|
67 INFO_PRINTF1(KFunction); |
|
68 INFO_PRINTF1(KPopTeststart); |
|
69 TInt err; |
|
70 err=User::LoadPhysicalDevice(PDD_NAME); |
|
71 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
72 User::Leave(err); |
|
73 err=User::LoadLogicalDevice(LDD_NAME); |
|
74 if (err!=KErrNone && err!=KErrAlreadyExists) |
|
75 User::Leave(err); |
|
76 |
|
77 iActiveWaiter = new(ELeave)CActiveWaiter(); |
|
78 iTestUtils = CEmailTestUtils::NewL(test); |
|
79 iTestUtils->FileSession().SetSessionPath( _L( "C:\\" ) ); |
|
80 iTestUtils->ClearEmailAccountsL(); |
|
81 iTestUtils->CreateAllTestDirectories(); |
|
82 iTestUtils->CleanMessageFolderL(); |
|
83 |
|
84 iTestUtils->GoClientSideL(); |
|
85 |
|
86 if(!ipop3Service) |
|
87 ipop3Service = iTestUtils->CreatePopServiceL(); |
|
88 |
|
89 |
|
90 iaccount = CEmailAccounts::NewLC(); |
|
91 isettings = new(ELeave) CImPop3Settings(); |
|
92 |
|
93 CImIAPPreferences* imapIAP = CImIAPPreferences::NewLC(); |
|
94 iSel = new (ELeave) CMsvEntrySelection; |
|
95 |
|
96 |
|
97 iaccount->GetPopAccountL(ipop3Service, ipop3AccountId); |
|
98 iaccount->LoadPopSettingsL(ipop3AccountId, *isettings); |
|
99 |
|
100 isettings->SetServerAddressL(KPOPServer); |
|
101 isettings->SetLoginNameL(KPOPInValidUserPass /*iTestUtils->MachineName()*/); |
|
102 isettings->SetPasswordL(KPOPInValidUserPass /*iTestUtils->MachineName()*/); |
|
103 isettings->SetPort(110); |
|
104 |
|
105 iaccount->SavePopSettingsL(ipop3AccountId, *isettings); |
|
106 CleanupStack::PopAndDestroy(2, iaccount); |
|
107 |
|
108 iTestUtils->GoServerSideL(); |
|
109 iTestUtils->InstantiatePopServerMtmL(); |
|
110 iPopServerMtm=iTestUtils->iPopServerMtm; |
|
111 } |
|
112 |
|
113 void CTestPOPSynchroniseTest::TearDownL() |
|
114 { |
|
115 _LIT(KFunction, "TearDownL"); |
|
116 INFO_PRINTF1(KFunction); |
|
117 ipop3Service = NULL; |
|
118 delete isettings; |
|
119 delete iActiveWaiter; |
|
120 delete iTestUtils; |
|
121 iTestUtils = NULL; |
|
122 INFO_PRINTF1(KPopTestend); |
|
123 } |
|
124 |
|
125 void CTestPOPSynchroniseTest::TestPop3SynchroniseTestL() |
|
126 { |
|
127 |
|
128 _LIT(KFunction1, "TestNoPop3FolderMessagesL"); |
|
129 INFO_PRINTF1(KFunction1); |
|
130 |
|
131 ConnectToRemoteServerL(); |
|
132 |
|
133 TInt totalEntries=0; |
|
134 User::LeaveIfError(iTestUtils->iServerEntry->SetEntry(ipop3Service)); |
|
135 CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection; |
|
136 CleanupStack::PushL(sel); |
|
137 User::LeaveIfError(iTestUtils->iServerEntry->GetChildren(*sel)); |
|
138 totalEntries = sel->Count(); |
|
139 ASSERT_EQUALS( totalEntries, sel->Count() ); |
|
140 sel->Reset(); |
|
141 |
|
142 _LIT(KFunction2, "TestNoNewMsgL"); |
|
143 INFO_PRINTF1(KFunction2); |
|
144 |
|
145 TInt newEntries=0; |
|
146 User::LeaveIfError(iTestUtils->iServerEntry->SetEntry(ipop3Service)); |
|
147 User::LeaveIfError(iTestUtils->iServerEntry->GetChildren(*sel)); |
|
148 |
|
149 for (TInt count =0; count < sel->Count(); count++) |
|
150 { |
|
151 User::LeaveIfError(iTestUtils->iServerEntry->SetEntry(sel->At(count) ) ); |
|
152 if (iTestUtils->iServerEntry->Entry().New()) |
|
153 newEntries++; |
|
154 } |
|
155 TInt entry = newEntries; |
|
156 ASSERT_EQUALS( newEntries, entry ); |
|
157 sel->Reset(); |
|
158 |
|
159 _LIT(KFunction3, "TestNoOldMsgL"); |
|
160 INFO_PRINTF1(KFunction3); |
|
161 |
|
162 TInt oldEntries=0; |
|
163 User::LeaveIfError(iTestUtils->iServerEntry->SetEntry(ipop3Service)); |
|
164 User::LeaveIfError(iTestUtils->iServerEntry->GetChildren(*sel)); |
|
165 |
|
166 for (TInt count =0; count < sel->Count(); count++) |
|
167 { |
|
168 User::LeaveIfError(iTestUtils->iServerEntry->SetEntry(sel->At(count)) ); |
|
169 if (! iTestUtils->iServerEntry->Entry().New()) |
|
170 oldEntries++; |
|
171 } |
|
172 TInt oldentry = oldEntries; |
|
173 ASSERT_EQUALS( oldEntries, oldentry ); |
|
174 sel->Reset(); |
|
175 |
|
176 DisconnectL(); |
|
177 CleanupStack::PopAndDestroy(1, sel); |
|
178 ChangeSynchronisationLimitL(); |
|
179 ChangeDownloadModeL(); |
|
180 } |
|
181 |
|
182 void CTestPOPSynchroniseTest::ChangeSynchronisationLimitL() |
|
183 { |
|
184 // Get the settings for the POP3 service and change the synchronisation limit |
|
185 // Used after the settings have been created and set. |
|
186 |
|
187 _LIT(KFunction4, "ChangeSynchronisationLimitL"); |
|
188 INFO_PRINTF1(KFunction4); |
|
189 |
|
190 |
|
191 TInt aLimit = 2; |
|
192 iTestUtils->GoClientSideL(); |
|
193 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
194 CImPop3Settings* settings = new(ELeave) CImPop3Settings(); |
|
195 CleanupStack::PushL(settings); |
|
196 TPopAccount id; |
|
197 accounts->GetPopAccountL(ipop3Service, id); |
|
198 accounts->LoadPopSettingsL(id, *settings); |
|
199 |
|
200 settings->SetInboxSynchronisationLimit(aLimit); |
|
201 accounts->SavePopSettingsL(id, *settings); |
|
202 |
|
203 CleanupStack::PopAndDestroy(settings); |
|
204 settings = NULL; |
|
205 settings = new(ELeave) CImPop3Settings(); |
|
206 CleanupStack::PushL(settings); |
|
207 accounts->LoadPopSettingsL(id, *settings); |
|
208 TInt ret = settings->InboxSynchronisationLimit() ; |
|
209 ASSERT_EQUALS(ret , aLimit); |
|
210 |
|
211 CleanupStack::PopAndDestroy(settings); |
|
212 CleanupStack::PopAndDestroy(accounts); |
|
213 } |
|
214 |
|
215 void CTestPOPSynchroniseTest::ChangeDownloadModeL() |
|
216 { |
|
217 // Get the settings for the POP3 service and change the synchronisation limit |
|
218 // Used after the settings have been created and set. |
|
219 |
|
220 _LIT(KFunction5, "ChangeDownloadModeL"); |
|
221 INFO_PRINTF1(KFunction5); |
|
222 |
|
223 TBuf<20> downloadType; |
|
224 |
|
225 iTestUtils->GoClientSideL(); |
|
226 CEmailAccounts* accounts = CEmailAccounts::NewLC(); |
|
227 CImPop3Settings* settings = new(ELeave) CImPop3Settings(); |
|
228 CleanupStack::PushL(settings); |
|
229 TPopAccount id; |
|
230 accounts->GetPopAccountL(ipop3Service, id); |
|
231 accounts->LoadPopSettingsL(id, *settings); |
|
232 TPop3GetMailOptions aMode(EGetPop3EmailHeaders); |
|
233 settings->SetGetMailOptions(aMode); |
|
234 accounts->SavePopSettingsL(id, *settings); |
|
235 CleanupStack::PopAndDestroy(settings); |
|
236 settings = NULL; |
|
237 settings = new(ELeave) CImPop3Settings(); |
|
238 CleanupStack::PushL(settings); |
|
239 accounts->LoadPopSettingsL(id, *settings); |
|
240 TPop3GetMailOptions aMode1 = settings->GetMailOptions(); |
|
241 ASSERT_EQUALS(aMode1 , aMode); |
|
242 CleanupStack::PopAndDestroy(settings); |
|
243 CleanupStack::PopAndDestroy(accounts); |
|
244 } |
|
245 |
|
246 //Connect to tyhe Server |
|
247 void CTestPOPSynchroniseTest::ConnectToRemoteServerL() |
|
248 { |
|
249 TBuf8<128> parameter; |
|
250 iSel->AppendL(ipop3Service); |
|
251 TPop3Progress temp; |
|
252 TPckgC<TPop3Progress> paramPack(temp); |
|
253 iPopServerMtm->StartCommandL(*iSel, KPOP3MTMConnect, parameter, iActiveWaiter->iStatus); |
|
254 iActiveWaiter->WaitActive(); |
|
255 const TDesC8& progBuf = iTestUtils->iPopServerMtm->Progress(); |
|
256 paramPack.Set(progBuf); |
|
257 TPop3Progress progress=paramPack(); |
|
258 ASSERT_EQUALS( progress.iErrorCode, KErrNone ); |
|
259 } |
|
260 //Disconnecting the Connection |
|
261 void CTestPOPSynchroniseTest::DisconnectL() |
|
262 { |
|
263 TBuf8<128> parameter; |
|
264 iSel->AppendL(ipop3Service); |
|
265 iPopServerMtm->StartCommandL(*iSel,KPOP3MTMDisconnect , parameter, iActiveWaiter->iStatus); |
|
266 iActiveWaiter->WaitActive(); |
|
267 ASSERT_EQUALS( iActiveWaiter->iStatus.Int( ), KErrNone ); |
|
268 } |
|
269 |
|
270 CTestSuite* CTestPOPSynchroniseTest::CreateSuiteL(const TDesC& aName) |
|
271 { |
|
272 SUB_SUITE; |
|
273 ADD_ASYNC_TEST_STEP(TestPop3SynchroniseTestL); |
|
274 //ADD_ASYNC_TEST_STEP(ChangeSynchronisationLimitL); |
|
275 END_SUITE; |
|
276 } |
|
277 |