|
1 // Copyright (c) 1998-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 // Name of test harness: T_MIUT10 |
|
15 // Component: IMCM |
|
16 // Owner: EH |
|
17 // Brief description of test harness: |
|
18 // Cachemanager tests - Automatic test that proves that the cachemanager |
|
19 // recursively prunes bodytext and attachment data. |
|
20 // Detailed description of test harness: |
|
21 // The test harness checks that each message has no child entires since, |
|
22 // prune-messages should leave message entry |
|
23 // and therefore each message should have no child entries. |
|
24 // please see function doMainL(), section commented DEF066273 |
|
25 // for further details. |
|
26 // Input files required to run test harness: |
|
27 // \MSG\IMCMTSRC\plain_text.txt <DRIVE>:\msgtest\IMCM\rfc822\plain_text.txt |
|
28 // \MSG\IMCMTSRC\html_with_attachment.txt <DRIVE>:\msgtest\IMCM\rfc822\html_with_attachment.txt |
|
29 // Intermediate files produced while running test harness: |
|
30 // <DRIVE>:\msglogs\T_MIUT10\Entry_822Headers.txt |
|
31 // <DRIVE>:\msglogs\T_MIUT10\Entry_MimeHeaders.txt |
|
32 // <DRIVE>:\msglogs\T_MIUT10\Entry_RichTextBodies.txt |
|
33 // <DRIVE>:\msglogs\T_MIUT10\Entry_Structure.txt |
|
34 // Output files produced by running test harness: |
|
35 // <DRIVE>:\msglogs\T_MIUT10.<PLATFORM>.<VARIANT>.LOG.txt |
|
36 // Description of how to build test harness: |
|
37 // cd \msg\imcm\ |
|
38 // bldmake bldfiles |
|
39 // abld test build |
|
40 // Description of how to run test harness: |
|
41 // The following instructions are the same for all platforms: |
|
42 // 1. Build T_DB test harness from COMMDB component: |
|
43 // cd \commdb\group |
|
44 // bldmake bldfiles |
|
45 // abld test build t_db |
|
46 // 2. Build the test utilities: |
|
47 // cd \msg\testutils\group\ |
|
48 // bldmake bldfiles |
|
49 // abld build |
|
50 // WINS running instructions: |
|
51 // 1. \epoc32\release\wins\<VARIANT>\T_MIUT10.exe can be used at the command prompt |
|
52 // or executable can be run from Windows Explorer. |
|
53 // All other platform running instructions: |
|
54 // 1. Copy \epoc32\release\<PLATFORM>\<VARIANT>\T_MIUT10.exe onto the other platform |
|
55 // 2. Copy \epoc32\release\<PLATFORM>\<VARIANT>\MSVTESTUTILS.DLL into |
|
56 // <DRIVE>:\system\libs on the other platform |
|
57 // 3. Copy \epoc32\release\<PLATFORM>\<VARIANT>\EMAILTESTUTILS.DLL into |
|
58 // <DRIVE>:\system\libs on the other platform |
|
59 // 4. Run T_MIUT10.exe on the other platform |
|
60 // |
|
61 // |
|
62 |
|
63 #include "emailtestutils.h" |
|
64 #include <miutlog.h> |
|
65 #include <cacheman.h> |
|
66 |
|
67 // local variables etc // |
|
68 |
|
69 // Message file names |
|
70 _LIT(K_T_MIUT10_PLAIN_MSG, "c:\\mailtest\\rfc822\\plain_text.txt"); |
|
71 _LIT(K_T_MIUT10_HTML_ATTACHMENT_MSG, "c:\\mailtest\\rfc822\\html_with_attachment.txt" ); |
|
72 |
|
73 // Logging strings |
|
74 _LIT(K_T_MIUT10_TEST_INFO, "MIUT10 - Cache Management Tests"); |
|
75 _LIT(K_T_MIUT10_DESCRIPTION, "Testing pruning of a remote service containing plain test and MHTML mails."); |
|
76 _LIT(K_T_MIUT10_PROGRESS, " Messages pruned %d/%d \n"); |
|
77 _LIT(K_T_MIUT10_MSG_NOT_PRUNED,"\nWarning email not pruned\n* BODY text or attachment data still exists!*---Message entry id: %d--"); |
|
78 _LIT(K_T_MIUT10_MSG_PRUNED,"\nSuccess: email pruned!--Message entry id: %d--"); |
|
79 |
|
80 RTest test(K_T_MIUT10_TEST_INFO); |
|
81 |
|
82 #define DONT_PRUNE_ID 0x100002 |
|
83 #define KPeriod 10000 // period of timer |
|
84 #define KErrMsgNotPruned 5601 |
|
85 LOCAL_D TMsvId pop3Service; |
|
86 |
|
87 LOCAL_D CTrapCleanup* theCleanup; |
|
88 LOCAL_D CEmailTestUtils* testUtils; |
|
89 |
|
90 class CFilteredCacheManager : public CImCacheManager |
|
91 { |
|
92 public: |
|
93 CFilteredCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus); |
|
94 static CFilteredCacheManager* NewL(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus); |
|
95 |
|
96 private: |
|
97 TBool Filter() const; |
|
98 }; |
|
99 |
|
100 CFilteredCacheManager::CFilteredCacheManager(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus) : CImCacheManager(aSession, aObserverRequestStatus) |
|
101 { |
|
102 } |
|
103 |
|
104 CFilteredCacheManager* CFilteredCacheManager::NewL(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus) |
|
105 { |
|
106 CFilteredCacheManager* self = new (ELeave) CFilteredCacheManager(aSession, aObserverRequestStatus); |
|
107 CleanupStack::PushL(self); |
|
108 self->ConstructL(); |
|
109 CleanupStack::Pop(); // self |
|
110 return self; |
|
111 } |
|
112 |
|
113 TBool CFilteredCacheManager::Filter() const |
|
114 { |
|
115 return (iCurrentEntry->Entry().Id() == DONT_PRUNE_ID) ? EFalse : ETrue; |
|
116 } |
|
117 |
|
118 |
|
119 // |
|
120 |
|
121 |
|
122 class CImCacheManager; |
|
123 class TestUiTimer : public CTimer |
|
124 { |
|
125 public: |
|
126 static TestUiTimer* NewLC(CConsoleBase* aConsole, CImCacheManager* aCacheManager); |
|
127 void RunL(); |
|
128 void DoCancel(); |
|
129 void ConstructL(); |
|
130 void IssueRequest(); |
|
131 |
|
132 CConsoleBase* iConsole; |
|
133 CImCacheManager* iCacheManager; |
|
134 TTimeIntervalMicroSeconds32 period; |
|
135 protected: |
|
136 TInt iCount; |
|
137 TBool iClosing; |
|
138 TestUiTimer(CConsoleBase* aConsole, CImCacheManager* aCacheManager); |
|
139 }; |
|
140 |
|
141 // |
|
142 // Progress timer |
|
143 // |
|
144 TestUiTimer* TestUiTimer::NewLC(CConsoleBase* aConsole, CImCacheManager* aCacheManager) |
|
145 { |
|
146 TestUiTimer* self = new(ELeave) TestUiTimer(aConsole, aCacheManager); |
|
147 CleanupStack::PushL(self); |
|
148 self->iCacheManager = aCacheManager; |
|
149 self->ConstructL(); |
|
150 return self; |
|
151 } |
|
152 |
|
153 TestUiTimer::TestUiTimer(CConsoleBase* aConsole, CImCacheManager* aCacheManager) |
|
154 : CTimer(EPriorityStandard+3), iCacheManager(aCacheManager) |
|
155 { |
|
156 // counter =0; |
|
157 iConsole = aConsole; |
|
158 period = KPeriod; |
|
159 iClosing = EFalse; |
|
160 iCount = 0; |
|
161 } |
|
162 |
|
163 void TestUiTimer::ConstructL() |
|
164 { |
|
165 CTimer::ConstructL(); |
|
166 CActiveScheduler::Add(this); |
|
167 } |
|
168 |
|
169 void TestUiTimer::IssueRequest() |
|
170 { |
|
171 After(period); |
|
172 } |
|
173 |
|
174 void TestUiTimer::DoCancel() |
|
175 { |
|
176 CTimer::DoCancel(); |
|
177 } |
|
178 |
|
179 void TestUiTimer::RunL() |
|
180 { |
|
181 // display the current progress |
|
182 TImCacheManagerProgress temp; |
|
183 TPckgC<TImCacheManagerProgress> paramPack(temp); |
|
184 |
|
185 const TDesC8& progBuf = iCacheManager->ProgressL(); |
|
186 paramPack.Set(progBuf); |
|
187 TImCacheManagerProgress progress=paramPack(); |
|
188 |
|
189 TBuf<128> strProgress; |
|
190 strProgress.Format(K_T_MIUT10_PROGRESS, progress.iMessagesProcessed, |
|
191 progress.iTotalMessages); |
|
192 |
|
193 test.Printf(strProgress); |
|
194 |
|
195 // write progress info to log file, too (to test DEF042552) |
|
196 testUtils->WriteComment(strProgress); |
|
197 |
|
198 IssueRequest(); |
|
199 }; |
|
200 |
|
201 // |
|
202 |
|
203 LOCAL_C void InitL() |
|
204 { |
|
205 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
206 CActiveScheduler::Install(scheduler); |
|
207 CleanupStack::PushL(scheduler); |
|
208 |
|
209 testUtils = CEmailTestUtils::NewLC(test); |
|
210 testUtils->CreateAllTestDirectories(); |
|
211 |
|
212 testUtils->WriteComment(K_T_MIUT10_TEST_INFO); |
|
213 |
|
214 testUtils->FileSession().SetSessionPath(_L("C:\\")); |
|
215 testUtils->CleanMessageFolderL(); |
|
216 testUtils->ClearEmailAccountsL(); |
|
217 } |
|
218 |
|
219 LOCAL_C void Closedown() |
|
220 { |
|
221 CleanupStack::PopAndDestroy(2); //testUtils, scheduler |
|
222 } |
|
223 |
|
224 LOCAL_C void doMainL() |
|
225 { |
|
226 InitL(); |
|
227 |
|
228 TInt globalError = KErrNone; |
|
229 testUtils->FileSession().SetSessionPath(_L("c:\\")); |
|
230 |
|
231 testUtils->GoClientSideL(); |
|
232 testUtils->CreateSmtpServiceL(); |
|
233 pop3Service = testUtils->CreatePopServiceL(); |
|
234 testUtils->GoServerSideL(); |
|
235 |
|
236 testUtils->CreateMessageL(K_T_MIUT10_PLAIN_MSG, pop3Service, pop3Service); |
|
237 testUtils->CreateMessageL(K_T_MIUT10_PLAIN_MSG, pop3Service, pop3Service); |
|
238 testUtils->CreateMessageL(K_T_MIUT10_HTML_ATTACHMENT_MSG, pop3Service, pop3Service); |
|
239 |
|
240 test.Printf(_L("\nPerforming Cache Management Tests\n")); |
|
241 |
|
242 testUtils->GoClientSideL(); |
|
243 |
|
244 testUtils->iMsvEntry->SetEntryL(pop3Service); |
|
245 TMsvEntry entry = testUtils->iMsvEntry->Entry(); |
|
246 entry.SetVisible(ETrue); |
|
247 testUtils->iMsvEntry->ChangeL(entry); |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 TRequestStatus observerStatus; |
|
254 CImCacheManager* cacheManager = CFilteredCacheManager::NewL(*testUtils->iMsvSession, observerStatus); |
|
255 CleanupStack::PushL(cacheManager); |
|
256 TestUiTimer* testUiTimer = TestUiTimer::NewLC(test.Console(), cacheManager); |
|
257 CTestActive* testActive = new (ELeave) CTestActive(); |
|
258 CleanupStack::PushL(testActive); |
|
259 |
|
260 testActive->StartL(); |
|
261 testUiTimer->IssueRequest(); |
|
262 |
|
263 testUtils->TestStart(0, K_T_MIUT10_DESCRIPTION); |
|
264 |
|
265 cacheManager->StartL(pop3Service, testActive->iStatus); |
|
266 |
|
267 CActiveScheduler::Start(); |
|
268 |
|
269 // DEF066273: rewrite-Messaging regression test T_MIUT10 failing consistently |
|
270 // DEF049479: is no longer valid it has therefore not been taken into consideration |
|
271 |
|
272 //ensure at correct service entry |
|
273 testUtils->iMsvEntry->SetEntryL(pop3Service); |
|
274 //store msg entires of this service |
|
275 CMsvEntrySelection* popEntrySelection; |
|
276 popEntrySelection=testUtils->iMsvEntry->ChildrenL(); |
|
277 CleanupStack::PushL(popEntrySelection); |
|
278 |
|
279 TInt count=popEntrySelection->Count(); |
|
280 TInt childEntries; |
|
281 TMsvId msgId; |
|
282 TMsvEntry msgEntry; |
|
283 TBuf<128> msgFail,msgPass; |
|
284 |
|
285 |
|
286 for(TInt i=0; i<count; ++i) |
|
287 { |
|
288 |
|
289 //ensure at correct location |
|
290 msgId=popEntrySelection->At(i); |
|
291 testUtils->iMsvEntry->SetEntryL(msgId); |
|
292 // testUtils->iMsvEntry->Entry(); |
|
293 |
|
294 //ensure that there are no more child entries |
|
295 childEntries=testUtils->iMsvEntry->Count(); |
|
296 |
|
297 if (childEntries!=0 && DONT_PRUNE_ID!=msgId) |
|
298 { |
|
299 //body text or attachments still exist |
|
300 msgFail.Format(K_T_MIUT10_MSG_NOT_PRUNED,msgId); |
|
301 testUtils->WriteComment(msgFail); |
|
302 globalError = KErrMsgNotPruned; |
|
303 |
|
304 } |
|
305 else |
|
306 { |
|
307 //email successfully-prunned header saved. |
|
308 msgPass.Format(K_T_MIUT10_MSG_PRUNED,msgId); |
|
309 testUtils->WriteComment(msgPass); |
|
310 |
|
311 } |
|
312 |
|
313 } |
|
314 |
|
315 |
|
316 testUtils->TestFinish(0, globalError); |
|
317 |
|
318 if (globalError == KErrNone) |
|
319 { |
|
320 testUtils->TestHarnessCompleted(); |
|
321 } |
|
322 else |
|
323 { |
|
324 testUtils->TestHarnessFailed(globalError); |
|
325 } |
|
326 |
|
327 CleanupStack::PopAndDestroy(4,cacheManager); // testActive, testUiTimer, cacheManager,popEntrySelection |
|
328 |
|
329 Closedown(); |
|
330 |
|
331 } |
|
332 |
|
333 GLDEF_C TInt E32Main() |
|
334 { |
|
335 __UHEAP_MARK; |
|
336 test.Start(_L("T_MIUT10 Test CImCacheManager class\n")); |
|
337 theCleanup=CTrapCleanup::New(); |
|
338 TRAPD(ret,doMainL()); |
|
339 test(ret==KErrNone); |
|
340 delete theCleanup; |
|
341 test.End(); |
|
342 test.Close(); |
|
343 __UHEAP_MARKEND; |
|
344 User::Heap().Check(); |
|
345 return(KErrNone); |
|
346 } |
|
347 |