|
1 // Copyright (c) 1997-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 // The implementation of the transition validation classes upon the CMailtoSchemeHandler class methods. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @SYMCreationDate Created : 24/05/01 15:57:47 |
|
21 */ |
|
22 |
|
23 // ______________________________________________________________________________ |
|
24 // |
|
25 inline TMailtoSchemeHandler_Ctor_TransitionValidator::TMailtoSchemeHandler_Ctor_TransitionValidator(CUnitTestContext& aUTContext) |
|
26 :TTransitionValidator(aUTContext) |
|
27 { |
|
28 // Do nothing |
|
29 } |
|
30 |
|
31 inline TBool TMailtoSchemeHandler_Ctor_TransitionValidator::ValidatePreConditions() |
|
32 { |
|
33 return ETrue; |
|
34 } |
|
35 |
|
36 inline TBool TMailtoSchemeHandler_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
37 { |
|
38 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
39 return EFalse; |
|
40 return ETrue; |
|
41 } |
|
42 |
|
43 // ______________________________________________________________________________ |
|
44 // |
|
45 inline TMailtoSchemeHandler_Dtor_TransitionValidator::TMailtoSchemeHandler_Dtor_TransitionValidator(CUnitTestContext& aUTContext) |
|
46 :TTransitionValidator(aUTContext) |
|
47 { |
|
48 // Do nothing |
|
49 } |
|
50 |
|
51 inline TBool TMailtoSchemeHandler_Dtor_TransitionValidator::ValidatePreConditions() |
|
52 { |
|
53 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
54 return EFalse; |
|
55 return ETrue; |
|
56 } |
|
57 |
|
58 inline TBool TMailtoSchemeHandler_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
59 { |
|
60 return ETrue; |
|
61 } |
|
62 |
|
63 |
|
64 // ______________________________________________________________________________ |
|
65 // |
|
66 inline TMailtoSchemeHandler_ParseUrlTest1_TransitionValidator::TMailtoSchemeHandler_ParseUrlTest1_TransitionValidator(CUnitTestContext& aUTContext) |
|
67 :TTransitionValidator(aUTContext) |
|
68 { |
|
69 // Do nothing |
|
70 } |
|
71 |
|
72 inline TBool TMailtoSchemeHandler_ParseUrlTest1_TransitionValidator::ValidatePreConditions() |
|
73 { |
|
74 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
75 return EFalse; |
|
76 return ETrue; |
|
77 } |
|
78 |
|
79 inline TBool TMailtoSchemeHandler_ParseUrlTest1_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
80 { |
|
81 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
82 return EFalse; |
|
83 |
|
84 CMailtoSchemeHandler* schemeHandler = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler; |
|
85 TMailtoSchemeHandler_StateAccessor* stateAccessor = &REINTERPRET_CAST(TMailtoSchemeHandler_StateAccessor&, iUTContext.StateAccessor()); |
|
86 RArray<TPtrC> toArray = stateAccessor->GetRecipientArray(*schemeHandler); |
|
87 const TInt toCount = toArray.Count(); |
|
88 |
|
89 RArray<TPtrC> recipientCheck = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iArray; |
|
90 |
|
91 for (TInt i=0; i<toCount; ++i) |
|
92 { |
|
93 //TPtrC a(toArray[i]); |
|
94 //TPtrC b(recipientCheck[i]); |
|
95 iUTContext.DataLogger().LogInformation(toArray[i]); |
|
96 iUTContext.DataLogger().LogInformation(recipientCheck[i]); |
|
97 if (toArray[i].CompareF(recipientCheck[i]) != 0) |
|
98 { |
|
99 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
100 return EFalse; |
|
101 } |
|
102 } |
|
103 |
|
104 TPtrC& subject = stateAccessor->GetSubject(*schemeHandler); |
|
105 if (subject.Length() != 0) |
|
106 { |
|
107 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
108 iUTContext.DataLogger().LogInformation(subject); |
|
109 return EFalse; |
|
110 } |
|
111 |
|
112 TPtrC& body = stateAccessor->GetBody(*schemeHandler); |
|
113 if (body.Length() != 0) |
|
114 { |
|
115 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
116 iUTContext.DataLogger().LogInformation(body); |
|
117 return EFalse; |
|
118 } |
|
119 |
|
120 return ETrue; |
|
121 } |
|
122 |
|
123 // ______________________________________________________________________________ |
|
124 // |
|
125 inline TMailtoSchemeHandler_ParseUrlTest9_TransitionValidator::TMailtoSchemeHandler_ParseUrlTest9_TransitionValidator(CUnitTestContext& aUTContext) |
|
126 :TTransitionValidator(aUTContext) |
|
127 { |
|
128 // Do nothing |
|
129 } |
|
130 |
|
131 inline TBool TMailtoSchemeHandler_ParseUrlTest9_TransitionValidator::ValidatePreConditions() |
|
132 { |
|
133 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
134 return EFalse; |
|
135 return ETrue; |
|
136 } |
|
137 |
|
138 inline TBool TMailtoSchemeHandler_ParseUrlTest9_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
139 { |
|
140 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
141 return EFalse; |
|
142 |
|
143 CMailtoSchemeHandler* schemeHandler = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler; |
|
144 TMailtoSchemeHandler_StateAccessor* stateAccessor = &REINTERPRET_CAST(TMailtoSchemeHandler_StateAccessor&, iUTContext.StateAccessor()); |
|
145 RArray<TPtrC> toArray = stateAccessor->GetRecipientArray(*schemeHandler); |
|
146 const TInt toCount = toArray.Count(); |
|
147 |
|
148 const TDesC* subjectCheck = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iSubjectCheck; |
|
149 |
|
150 |
|
151 if (toCount != 0) |
|
152 { |
|
153 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
154 return EFalse; |
|
155 } |
|
156 |
|
157 TPtrC& subject = stateAccessor->GetSubject(*schemeHandler); |
|
158 iUTContext.DataLogger().LogInformation(subject); |
|
159 if (subject.CompareF(*subjectCheck) != 0) |
|
160 { |
|
161 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
162 return EFalse; |
|
163 } |
|
164 |
|
165 TPtrC& body = stateAccessor->GetBody(*schemeHandler); |
|
166 if (body.Length() != 0) |
|
167 { |
|
168 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
169 iUTContext.DataLogger().LogInformation(body); |
|
170 return EFalse; |
|
171 } |
|
172 |
|
173 return ETrue; |
|
174 } |
|
175 |
|
176 // ______________________________________________________________________________ |
|
177 // |
|
178 inline TMailtoSchemeHandler_ParseUrlTest12_TransitionValidator::TMailtoSchemeHandler_ParseUrlTest12_TransitionValidator(CUnitTestContext& aUTContext) |
|
179 :TTransitionValidator(aUTContext) |
|
180 { |
|
181 // Do nothing |
|
182 } |
|
183 |
|
184 inline TBool TMailtoSchemeHandler_ParseUrlTest12_TransitionValidator::ValidatePreConditions() |
|
185 { |
|
186 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
187 return EFalse; |
|
188 return ETrue; |
|
189 } |
|
190 |
|
191 inline TBool TMailtoSchemeHandler_ParseUrlTest12_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
192 { |
|
193 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
194 return EFalse; |
|
195 |
|
196 CMailtoSchemeHandler* schemeHandler = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler; |
|
197 TMailtoSchemeHandler_StateAccessor* stateAccessor = &REINTERPRET_CAST(TMailtoSchemeHandler_StateAccessor&, iUTContext.StateAccessor()); |
|
198 RArray<TPtrC> toArray = stateAccessor->GetRecipientArray(*schemeHandler); |
|
199 const TInt toCount = toArray.Count(); |
|
200 |
|
201 const TDesC* bodyCheck = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iBodyCheck; |
|
202 |
|
203 if (toCount != 0) |
|
204 { |
|
205 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
206 return EFalse; |
|
207 } |
|
208 |
|
209 TPtrC& subject = stateAccessor->GetSubject(*schemeHandler); |
|
210 if (subject.Length() != 0) |
|
211 { |
|
212 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
213 iUTContext.DataLogger().LogInformation(subject); |
|
214 return EFalse; |
|
215 } |
|
216 |
|
217 TPtrC& body = stateAccessor->GetBody(*schemeHandler); |
|
218 iUTContext.DataLogger().LogInformation(body); |
|
219 if (body.CompareF(*bodyCheck) != 0) |
|
220 { |
|
221 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
222 return EFalse; |
|
223 } |
|
224 |
|
225 return ETrue; |
|
226 } |
|
227 |
|
228 // ______________________________________________________________________________ |
|
229 // |
|
230 inline TMailtoSchemeHandler_ParseUrlTest14_TransitionValidator::TMailtoSchemeHandler_ParseUrlTest14_TransitionValidator(CUnitTestContext& aUTContext) |
|
231 :TTransitionValidator(aUTContext) |
|
232 { |
|
233 // Do nothing |
|
234 } |
|
235 |
|
236 inline TBool TMailtoSchemeHandler_ParseUrlTest14_TransitionValidator::ValidatePreConditions() |
|
237 { |
|
238 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
239 return EFalse; |
|
240 return ETrue; |
|
241 } |
|
242 |
|
243 inline TBool TMailtoSchemeHandler_ParseUrlTest14_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
244 { |
|
245 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
246 return EFalse; |
|
247 |
|
248 CMailtoSchemeHandler* schemeHandler = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler; |
|
249 TMailtoSchemeHandler_StateAccessor* stateAccessor = &REINTERPRET_CAST(TMailtoSchemeHandler_StateAccessor&, iUTContext.StateAccessor()); |
|
250 RArray<TPtrC> toArray = stateAccessor->GetRecipientArray(*schemeHandler); |
|
251 const TInt toCount = toArray.Count(); |
|
252 |
|
253 RArray<TPtrC> recipientCheck = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iArray; |
|
254 |
|
255 for (TInt i=0; i<toCount; ++i) |
|
256 { |
|
257 iUTContext.DataLogger().LogInformation(toArray[i]); |
|
258 //iUTContext.DataLogger().LogInformation(postCheckArray[i]); |
|
259 if (toArray[i].CompareF(recipientCheck[i]) != 0) |
|
260 { |
|
261 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
262 return EFalse; |
|
263 } |
|
264 } |
|
265 |
|
266 const TDesC* subjectCheck = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iSubjectCheck; |
|
267 TPtrC& subject = stateAccessor->GetSubject(*schemeHandler); |
|
268 iUTContext.DataLogger().LogInformation(subject); |
|
269 if (subject.CompareF(*subjectCheck) != 0) |
|
270 { |
|
271 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
272 return EFalse; |
|
273 } |
|
274 |
|
275 const TDesC* bodyCheck = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iBodyCheck; |
|
276 TPtrC& body = stateAccessor->GetBody(*schemeHandler); |
|
277 iUTContext.DataLogger().LogInformation(body); |
|
278 if (body.CompareF(*bodyCheck) != 0) |
|
279 { |
|
280 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
281 return EFalse; |
|
282 } |
|
283 |
|
284 return ETrue; |
|
285 } |
|
286 |
|
287 // ______________________________________________________________________________ |
|
288 // |
|
289 inline TMailtoSchemeHandler_CreateEmailL_TransitionValidator::TMailtoSchemeHandler_CreateEmailL_TransitionValidator(CUnitTestContext& aUTContext) |
|
290 :TTransitionValidator(aUTContext) |
|
291 { |
|
292 // Do nothing |
|
293 } |
|
294 |
|
295 inline TBool TMailtoSchemeHandler_CreateEmailL_TransitionValidator::ValidatePreConditions() |
|
296 { |
|
297 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
298 return EFalse; |
|
299 return ETrue; |
|
300 } |
|
301 |
|
302 inline TBool TMailtoSchemeHandler_CreateEmailL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */) |
|
303 { |
|
304 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler)) |
|
305 return EFalse; |
|
306 |
|
307 CMailtoSchemeHandler* schemeHandler = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iMailtoSchemeHandler; |
|
308 TMailtoSchemeHandler_StateAccessor* stateAccessor = &REINTERPRET_CAST(TMailtoSchemeHandler_StateAccessor&, iUTContext.StateAccessor()); |
|
309 RArray<TPtrC> recipientCheck = stateAccessor->GetRecipientArray(*schemeHandler); |
|
310 |
|
311 TPtrC bodyCheck = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iBody; |
|
312 |
|
313 TMsvId id = REINTERPRET_CAST(CMailtoSchemeHandler_UnitTestContext&,iUTContext).iId; |
|
314 if (id == 0) |
|
315 { |
|
316 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
317 return EFalse; |
|
318 } |
|
319 |
|
320 _LIT(KTest, "This is a test"); |
|
321 RTest test(KTest); |
|
322 |
|
323 CEmailTestUtils* testUtils = CEmailTestUtils::NewL(test, ETuGoClientSide); |
|
324 CleanupStack::PushL(testUtils); |
|
325 |
|
326 testUtils->TestStart(1); |
|
327 test.Start(_L("Send SMTP message")); |
|
328 |
|
329 testUtils->SetEntryL(id); |
|
330 TMsvEntry entry = testUtils->Entry(); |
|
331 |
|
332 // Check Mtm |
|
333 // |
|
334 |
|
335 TUid mtm = entry.iMtm; |
|
336 const TUid mailMtm = {0x10001028}; |
|
337 |
|
338 if (mtm != mailMtm) |
|
339 { |
|
340 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
341 return EFalse; |
|
342 } |
|
343 |
|
344 // Check Subject |
|
345 // |
|
346 |
|
347 TPtrC subject = entry.iDescription; |
|
348 iUTContext.DataLogger().LogInformation(subject); |
|
349 TPtrC& subjectCheck = stateAccessor->GetSubject(*schemeHandler); |
|
350 if (subject.CompareF(subjectCheck) != 0) |
|
351 { |
|
352 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
353 return EFalse; |
|
354 } |
|
355 |
|
356 // Check Recipient |
|
357 // |
|
358 |
|
359 CMsvStore* store = testUtils->iMsvEntry->ReadStoreL(); |
|
360 CleanupStack::PushL(store); |
|
361 CImHeader* header = CImHeader::NewLC(); |
|
362 header->RestoreL(*store); |
|
363 CDesCArray& toArray = header->ToRecipients(); |
|
364 const TInt toCount = toArray.Count(); |
|
365 for (TInt i=0; i<toCount; ++i) |
|
366 { |
|
367 iUTContext.DataLogger().LogInformation(toArray[i]); |
|
368 //iUTContext.DataLogger().LogInformation(receipientCheck[i]); |
|
369 if (toArray[i].CompareF(recipientCheck[i]) != 0) |
|
370 { |
|
371 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
372 return EFalse; |
|
373 } |
|
374 } |
|
375 |
|
376 CleanupStack::PopAndDestroy(header); |
|
377 CleanupStack::PopAndDestroy(store); |
|
378 |
|
379 // Check body |
|
380 // |
|
381 |
|
382 CParaFormatLayer* paraFormatLayer=CParaFormatLayer::NewL(); |
|
383 CleanupStack::PushL(paraFormatLayer); |
|
384 |
|
385 CCharFormatLayer* charFormatLayer=CCharFormatLayer::NewL(); |
|
386 CleanupStack::PushL(charFormatLayer); |
|
387 |
|
388 CRichText* validRichText1=CRichText::NewL(paraFormatLayer, charFormatLayer, CEditableText::EFlatStorage, 256); |
|
389 CleanupStack::PushL(validRichText1); |
|
390 |
|
391 CMsvOperationWait* iWait=CMsvOperationWait::NewLC(); |
|
392 |
|
393 CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*testUtils->iMsvEntry); |
|
394 imEmailMessage->GetBodyTextL(iWait->iStatus, id, CImEmailMessage::EThisMessageOnly, *validRichText1, *paraFormatLayer, *charFormatLayer); |
|
395 iWait->Start(); |
|
396 CActiveScheduler::Start(); |
|
397 |
|
398 TBuf<100> bufa = validRichText1->Read(0 , 21); |
|
399 TBuf<100> bufb(bodyCheck); |
|
400 iUTContext.DataLogger().LogInformation(bufa); |
|
401 //iUTContext.DataLogger().LogInformation(bufb); |
|
402 if (bufa.Compare(bufb) != 0) |
|
403 { |
|
404 iUTContext.DataLogger().LogInformation(_L("***** TEST FAILED *****")); |
|
405 return EFalse; |
|
406 } |
|
407 |
|
408 CleanupStack::PopAndDestroy(2); //imEmailMessage, iWait |
|
409 CleanupStack::PopAndDestroy(1); //validRichText1 |
|
410 CleanupStack::PopAndDestroy(2); //paraFormatLayer, charFormatLayer |
|
411 |
|
412 testUtils->TestFinish(1); |
|
413 testUtils->TestHarnessCompleted(); |
|
414 |
|
415 CleanupStack::PopAndDestroy(testUtils); |
|
416 |
|
417 test.End(); |
|
418 test.Close(); |
|
419 |
|
420 return ETrue; |
|
421 } |