|
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 // Telephony Fax Test main test code. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #include "faxdefn.h" |
|
24 #include "fax_reversebytes.h" |
|
25 #include "FAXSET.H" |
|
26 #include "CFAX32.H" |
|
27 #include "etel.h" |
|
28 #include "etelmm.h" |
|
29 #include "faxhuff.h" |
|
30 |
|
31 #include "TE_FaxBase.h" |
|
32 #include "TE_FaxTest.h" |
|
33 |
|
34 |
|
35 // |
|
36 // Constants... |
|
37 // |
|
38 _LIT(KTEFaxTestStoreFileName, "C:\\TestStore.Fax"); |
|
39 _LIT(KTEFaxTestEncodeFileName, "C:\\TestEncode.Fax"); |
|
40 _LIT(KTEFaxTestHeaderFileName, "C:\\TestHeader.Fax"); |
|
41 _LIT(KTEFaxTSYName, "MM"); |
|
42 _LIT(KTEFaxPhoneName, "GsmPhone1"); |
|
43 _LIT(KTEFaxLineName, "Fax"); |
|
44 |
|
45 |
|
46 /** |
|
47 * Each test step initialises it's own name |
|
48 */ |
|
49 CFaxTestFaxDefinition::CFaxTestFaxDefinition() |
|
50 { |
|
51 // |
|
52 // Store the name of this test case. This is the name that is used by |
|
53 // the script file. |
|
54 // |
|
55 SetTestStepName(_L("TestFaxDefinition")); |
|
56 } // CFaxTestFaxDefinition::CFaxTestFaxDefinition |
|
57 |
|
58 |
|
59 /** |
|
60 * This tests the definition of a fax it's variables types. |
|
61 * |
|
62 * @return Test verdict for this test. |
|
63 */ |
|
64 enum TVerdict CFaxTestFaxDefinition::doTestStepL() |
|
65 { |
|
66 #ifdef __EABI__ |
|
67 // |
|
68 // Removed due to RVCT warnings!!! |
|
69 // |
|
70 INFO_PRINTF1(_L("Note: This test is not fully run on RVCT compiled platforms!")); |
|
71 #else |
|
72 TFaxClass faxClass = EClassAuto; |
|
73 faxClass = EClass1; |
|
74 |
|
75 TFaxPhase faxPhase = ENotYetStarted; |
|
76 faxPhase = ECallEstablishment; |
|
77 |
|
78 TFaxResolution faxResolution = EFaxNormal; |
|
79 faxResolution = EFaxFine; |
|
80 |
|
81 TFaxCompression faxCompression = EModifiedHuffman; |
|
82 faxCompression = EModifiedRead; |
|
83 |
|
84 TInt tmpValue; |
|
85 tmpValue = KFaxPixelsPerScanLine; |
|
86 tmpValue = KFaxBytesPerScanLine; |
|
87 tmpValue = KFaxCmPerScanLine; |
|
88 tmpValue = KFaxScanLinesPer10Cm; |
|
89 tmpValue = KFaxFineScanLinesPer10Cm; |
|
90 tmpValue = KFaxT4MaxDesLength; |
|
91 tmpValue = KFaxLinesPerBand; |
|
92 #endif |
|
93 |
|
94 TFaxBufSenderId faxBufSenderId; |
|
95 faxBufSenderId.Copy(_L8("Test")); |
|
96 |
|
97 TRawScanLine rawscanline; |
|
98 |
|
99 rawscanline.Zero(); |
|
100 rawscanline.SetMax(); |
|
101 rawscanline.FillZ(); |
|
102 |
|
103 return TestStepResult(); |
|
104 } // CFaxTestFaxDefinition::doTestStepL |
|
105 |
|
106 |
|
107 /** |
|
108 * Each test step initialises it's own name |
|
109 */ |
|
110 CFaxTestFaxStorage::CFaxTestFaxStorage() |
|
111 { |
|
112 // |
|
113 // Store the name of this test case. This is the name that is used by |
|
114 // the script file. |
|
115 // |
|
116 SetTestStepName(_L("TestFaxStorage")); |
|
117 } // CFaxTestFaxStorage::CFaxTestFaxStorage |
|
118 |
|
119 |
|
120 /** |
|
121 * This tests the definition of a fax it's variables types. |
|
122 * |
|
123 * @return Test verdict for this test. |
|
124 */ |
|
125 enum TVerdict CFaxTestFaxStorage::doTestStepL() |
|
126 { |
|
127 INFO_PRINTF1(_L("Started fax store tests")); |
|
128 |
|
129 iWriteFaxFile = CWriteFaxFile::NewL(); |
|
130 CleanupStack::PushL(iWriteFaxFile); |
|
131 iReadFaxFile = CReadFaxFile::NewL(); |
|
132 CleanupStack::PushL(iReadFaxFile); |
|
133 |
|
134 iSenderId.Copy(_L("sender's number")); |
|
135 |
|
136 TBuf8<216> scanlineBlack, scanlineWhite, scanlineAlt, scanlineCount; |
|
137 TInt index; |
|
138 |
|
139 scanlineBlack.SetLength(216); |
|
140 scanlineBlack.Fill(TChar(0)); |
|
141 scanlineWhite.SetLength(216); |
|
142 scanlineWhite.Fill(TChar(255)); |
|
143 scanlineAlt.SetLength(216); |
|
144 scanlineAlt.Fill(TChar(255)); |
|
145 |
|
146 for (index = 0; index < 216; index += 2) |
|
147 { |
|
148 scanlineAlt[index] = 0; |
|
149 } |
|
150 scanlineCount.SetLength(216); |
|
151 |
|
152 for (index = 0; index < 216; index++) |
|
153 { |
|
154 scanlineCount[index] = TUint8(index); |
|
155 } |
|
156 |
|
157 TInt numberLines, startnol(124), endnol(132); |
|
158 |
|
159 // |
|
160 // test 1 |
|
161 // |
|
162 INFO_PRINTF3(_L("Test 1 - %d to %d repeated lines"), startnol, endnol); |
|
163 |
|
164 INFO_PRINTF1(_L("All black - Resolution Fine")); |
|
165 for (numberLines=startnol; numberLines<=endnol; numberLines++) |
|
166 { |
|
167 Test1L(numberLines, scanlineBlack, EFaxFine); |
|
168 } |
|
169 |
|
170 INFO_PRINTF1(_L("All white - Resolution Fine")); |
|
171 for (numberLines=startnol; numberLines<=endnol; numberLines++) |
|
172 { |
|
173 Test1L(numberLines, scanlineWhite, EFaxFine); |
|
174 } |
|
175 |
|
176 INFO_PRINTF1(_L("Black & White - Resolution Fine")); |
|
177 for (numberLines=startnol; numberLines<=endnol; numberLines++) |
|
178 { |
|
179 Test1L(numberLines, scanlineAlt, EFaxFine); |
|
180 } |
|
181 |
|
182 INFO_PRINTF1(_L("Counting - Resolution Fine")); |
|
183 for (numberLines=startnol; numberLines<=endnol; numberLines++) |
|
184 { |
|
185 Test1L(numberLines, scanlineCount, EFaxFine); |
|
186 } |
|
187 |
|
188 INFO_PRINTF1(_L("Black & White - Resolution Normal")); |
|
189 for (numberLines=startnol; numberLines<=endnol; numberLines++) |
|
190 { |
|
191 Test1L(numberLines, scanlineAlt, EFaxNormal); |
|
192 } |
|
193 |
|
194 INFO_PRINTF1(_L("Counting - Resolution Normal")); |
|
195 for (numberLines=startnol; numberLines<=endnol; numberLines++) |
|
196 { |
|
197 Test1L(numberLines, scanlineCount, EFaxNormal); |
|
198 } |
|
199 |
|
200 // |
|
201 // test 2 |
|
202 // |
|
203 INFO_PRINTF3(_L("Test 2 - %d to %d alternated lines"), startnol, endnol); |
|
204 INFO_PRINTF1(_L("White and Black & White - Resolution Fine")); |
|
205 for (numberLines = startnol; numberLines <= endnol; numberLines++) |
|
206 { |
|
207 Test2L(numberLines, scanlineWhite, scanlineAlt, EFaxFine); |
|
208 } |
|
209 |
|
210 INFO_PRINTF1(_L("Black and Black & White - Resolution Fine")); |
|
211 for (numberLines = startnol; numberLines <= endnol; numberLines++) |
|
212 { |
|
213 Test2L(numberLines, scanlineBlack, scanlineAlt, EFaxFine); |
|
214 } |
|
215 |
|
216 INFO_PRINTF1(_L("Counting and Black & White - Resolution Fine")); |
|
217 for (numberLines = startnol; numberLines <= endnol; numberLines++) |
|
218 { |
|
219 Test2L(numberLines, scanlineCount, scanlineAlt, EFaxFine); |
|
220 } |
|
221 |
|
222 // |
|
223 // test 3 |
|
224 // |
|
225 TInt numberPages, maxNumberPages=5; |
|
226 |
|
227 INFO_PRINTF2(_L("Test 3 - 2 to %d pages"), maxNumberPages); |
|
228 for (numberPages = 2; numberPages <= maxNumberPages; numberPages++) |
|
229 { |
|
230 INFO_PRINTF2(_L("%d pages"),numberPages); |
|
231 |
|
232 for (numberLines = startnol; numberLines <= endnol; numberLines++) |
|
233 { |
|
234 Test3L(numberLines, numberPages); |
|
235 } |
|
236 } |
|
237 |
|
238 // |
|
239 // test 4 |
|
240 // |
|
241 INFO_PRINTF1(_L("Test 4 - seeking lines")); |
|
242 for (numberLines = startnol; numberLines <= startnol; numberLines++) |
|
243 { |
|
244 Test4L(numberLines); |
|
245 } |
|
246 |
|
247 // |
|
248 // test 5 |
|
249 // |
|
250 TFaxBufSenderId sd; |
|
251 |
|
252 INFO_PRINTF1(_L("Test 5 - writing and reading page info")); |
|
253 sd.Copy(_L8("+34345 4354")); |
|
254 Test5L(EFaxNormal,sd,EModifiedHuffman,TInt(2434)); |
|
255 sd.Copy(_L8("+34345 4354")); |
|
256 Test5L(EFaxFine,sd,EModifiedHuffman,TInt(0)); |
|
257 sd.Copy(_L8("")); |
|
258 Test5L(EFaxNormal,sd,EModifiedHuffman,TInt(1)); |
|
259 sd.Copy(_L8(" + 4545 9")); |
|
260 Test5L(EFaxFine,sd,EModifiedHuffman,TInt(-1)); |
|
261 |
|
262 // |
|
263 // Done! |
|
264 // |
|
265 CleanupStack::PopAndDestroy(iReadFaxFile); |
|
266 CleanupStack::PopAndDestroy(iWriteFaxFile); |
|
267 |
|
268 return TestStepResult(); |
|
269 } // CFaxTestFaxStorage::doTestStepL |
|
270 |
|
271 |
|
272 void CFaxTestFaxStorage::Test1L(TInt aNumberLines, TBuf8<216>& aScanLineWrite, |
|
273 TFaxResolution aRes) |
|
274 { |
|
275 TInt row; |
|
276 TBuf8<216> scanlineRead; |
|
277 |
|
278 iWriteFaxFile->OpenL(KTEFaxTestStoreFileName, 64); |
|
279 |
|
280 for (row = 0; row < aNumberLines; row++) |
|
281 { |
|
282 iWriteFaxFile->iWriteFaxPages->AddScanLineL(aScanLineWrite); |
|
283 } |
|
284 |
|
285 iWriteFaxFile->iWriteFaxPages->EndPageL(aRes, iSenderId); |
|
286 iWriteFaxFile->CommitL(); |
|
287 iWriteFaxFile->Close(); |
|
288 |
|
289 iReadFaxFile->OpenL(KTEFaxTestStoreFileName); |
|
290 |
|
291 for (row = 0; row < aNumberLines; row++) |
|
292 { |
|
293 iReadFaxFile->iReadFaxPages->GetScanLineL(scanlineRead); |
|
294 TESTCHECKSTR(scanlineRead, aScanLineWrite); |
|
295 } |
|
296 iReadFaxFile->Close(); |
|
297 } // CFaxTestFaxStorage::Test1L |
|
298 |
|
299 |
|
300 void CFaxTestFaxStorage::Test2L(TInt aNumberLines, TBuf8<216>& aScanLineWrite1, |
|
301 TBuf8<216>& aScanLineWrite2, TFaxResolution aRes) |
|
302 { |
|
303 TInt row; |
|
304 TBuf8<216> scanlineRead; |
|
305 |
|
306 iWriteFaxFile->OpenL(KTEFaxTestStoreFileName, 64); |
|
307 for (row = 0; row < aNumberLines; row++) |
|
308 { |
|
309 // line1 |
|
310 iWriteFaxFile->iWriteFaxPages->AddScanLineL(aScanLineWrite1); |
|
311 row++; |
|
312 if (row >= aNumberLines) |
|
313 { |
|
314 break; |
|
315 } |
|
316 |
|
317 // line2 |
|
318 iWriteFaxFile->iWriteFaxPages->AddScanLineL(aScanLineWrite2); |
|
319 } |
|
320 |
|
321 iWriteFaxFile->iWriteFaxPages->EndPageL(aRes, iSenderId); |
|
322 iWriteFaxFile->CommitL(); |
|
323 iWriteFaxFile->Close(); |
|
324 |
|
325 iReadFaxFile->OpenL(KTEFaxTestStoreFileName); |
|
326 for (row = 0; row < aNumberLines; row++) |
|
327 { |
|
328 // line1 |
|
329 iReadFaxFile->iReadFaxPages->GetScanLineL(scanlineRead); |
|
330 TESTCHECKSTR(scanlineRead, aScanLineWrite1); |
|
331 row++; |
|
332 if (row >= aNumberLines) |
|
333 { |
|
334 break; |
|
335 } |
|
336 |
|
337 // line2 |
|
338 iReadFaxFile->iReadFaxPages->GetScanLineL(scanlineRead); |
|
339 TESTCHECKSTR(scanlineRead, aScanLineWrite2); |
|
340 } |
|
341 iReadFaxFile->Close(); |
|
342 } // CFaxTestFaxStorage::Test2L |
|
343 |
|
344 |
|
345 void CFaxTestFaxStorage::Test3L(TInt aNumberLines, TInt aNumberPages) |
|
346 { |
|
347 TInt row; |
|
348 TBuf8<216> scanlineRead, scanlineWrite; |
|
349 |
|
350 scanlineWrite.SetLength(216); |
|
351 |
|
352 iWriteFaxFile->OpenL(KTEFaxTestStoreFileName, 64); |
|
353 TInt page; |
|
354 |
|
355 for (page = 0; page < aNumberPages; page++) |
|
356 { |
|
357 scanlineWrite.SetLength(216); |
|
358 scanlineWrite.Fill(TChar(255)); |
|
359 |
|
360 for (TInt t=0; t<216; t+=2) |
|
361 { |
|
362 scanlineWrite[t] = 0; |
|
363 } |
|
364 |
|
365 scanlineWrite[0] = TUint8(page); |
|
366 |
|
367 for (row = 0; row < aNumberLines; row++) |
|
368 { |
|
369 iWriteFaxFile->iWriteFaxPages->AddScanLineL(scanlineWrite); |
|
370 } |
|
371 |
|
372 iWriteFaxFile->iWriteFaxPages->EndPageL(EFaxFine, iSenderId); |
|
373 iWriteFaxFile->CommitL(); |
|
374 } |
|
375 iWriteFaxFile->Close(); |
|
376 |
|
377 iReadFaxFile->OpenL(KTEFaxTestStoreFileName); |
|
378 |
|
379 for (page = 0; page < aNumberPages; page++) |
|
380 { |
|
381 iReadFaxFile->iReadFaxPages->SetPageL(page); |
|
382 |
|
383 for (row = 0; row < aNumberLines; row++) |
|
384 { |
|
385 iReadFaxFile->iReadFaxPages->GetScanLineL(scanlineRead); |
|
386 TESTCHECK(scanlineRead[0], page); |
|
387 } |
|
388 } |
|
389 iReadFaxFile->Close(); |
|
390 } // CFaxTestFaxStorage::Test3L |
|
391 |
|
392 |
|
393 void CFaxTestFaxStorage::Test4L(TInt aNumberLines) |
|
394 { |
|
395 TInt row; |
|
396 TBuf8<216> scanlineRead, scanlineWrite; |
|
397 |
|
398 scanlineWrite.SetLength(216); |
|
399 |
|
400 iWriteFaxFile->OpenL(KTEFaxTestStoreFileName, 64); |
|
401 |
|
402 for (row = 0; row < aNumberLines; row++) |
|
403 { |
|
404 scanlineWrite[0] = TUint8(row); |
|
405 |
|
406 iWriteFaxFile->iWriteFaxPages->AddScanLineL(scanlineWrite); |
|
407 } |
|
408 |
|
409 iWriteFaxFile->iWriteFaxPages->EndPageL(EFaxFine, iSenderId); |
|
410 iWriteFaxFile->CommitL(); |
|
411 iWriteFaxFile->Close(); |
|
412 |
|
413 iReadFaxFile->OpenL(KTEFaxTestStoreFileName); |
|
414 |
|
415 for (row = 0; row < aNumberLines; row++) |
|
416 { |
|
417 iReadFaxFile->iReadFaxPages->SeekScanLineL(row); |
|
418 iReadFaxFile->iReadFaxPages->GetScanLineL(scanlineRead); |
|
419 TESTCHECK(scanlineRead[0], row); |
|
420 } |
|
421 |
|
422 for (row = aNumberLines - 1; row >= 0; row--) |
|
423 { |
|
424 iReadFaxFile->iReadFaxPages->SeekScanLineL(row); |
|
425 iReadFaxFile->iReadFaxPages->GetScanLineL(scanlineRead); |
|
426 TESTCHECK(scanlineRead[0], row); |
|
427 } |
|
428 |
|
429 iReadFaxFile->Close(); |
|
430 } // CFaxTestFaxStorage::Test4L |
|
431 |
|
432 |
|
433 void CFaxTestFaxStorage::Test5L(TFaxResolution aRes, TFaxBufSenderId& aSenderId, |
|
434 TFaxCompression aF1, TInt aF2) |
|
435 { |
|
436 TInt row; |
|
437 TBuf8<216> scanLineWrite; |
|
438 |
|
439 scanLineWrite.SetLength(216); |
|
440 |
|
441 iWriteFaxFile->OpenL(KTEFaxTestStoreFileName, 64); |
|
442 |
|
443 for (row=0; row<100; row++) |
|
444 { |
|
445 iWriteFaxFile->iWriteFaxPages->AddScanLineL(scanLineWrite); |
|
446 } |
|
447 |
|
448 iWriteFaxFile->iWriteFaxPages->EndPageL(aRes, aSenderId, aF1, aF2); |
|
449 iWriteFaxFile->CommitL(); |
|
450 iWriteFaxFile->Close(); |
|
451 |
|
452 iReadFaxFile->OpenL(KTEFaxTestStoreFileName); |
|
453 |
|
454 TFaxPageInfo info = iReadFaxFile->iReadFaxPages->CurrentPageInfo(); |
|
455 |
|
456 TESTCHECK(info.iNumScanLines, 100); |
|
457 TESTCHECK(info.iResolution, aRes); |
|
458 TESTCHECKSTR(info.iSenderId, aSenderId); |
|
459 TESTCHECK(info.iCompression, aF1); |
|
460 TESTCHECK(info.iReservedFlag2, aF2); |
|
461 |
|
462 iReadFaxFile->Close(); |
|
463 } |
|
464 |
|
465 |
|
466 /** |
|
467 * Each test step initialises it's own name |
|
468 */ |
|
469 CFaxTestFaxCoding::CFaxTestFaxCoding() |
|
470 { |
|
471 // |
|
472 // Store the name of this test case. This is the name that is used by |
|
473 // the script file. |
|
474 // |
|
475 SetTestStepName(_L("TestFaxCoding")); |
|
476 } // CFaxTestFaxCoding::CFaxTestFaxCoding |
|
477 |
|
478 |
|
479 /** |
|
480 * This tests the fax coding. |
|
481 * |
|
482 * @return Test verdict for this test. |
|
483 */ |
|
484 enum TVerdict CFaxTestFaxCoding::doTestStepL() |
|
485 { |
|
486 TInt result, pos; |
|
487 TInt blackrun; |
|
488 TBool flag(EFalse); |
|
489 RFile enFile; |
|
490 RFs fs; |
|
491 TRawScanLine rawScanLine; |
|
492 TBuf8<KFaxT4MaxDesLength> encodedScanLine; |
|
493 TBuf8<50> leftOvers; |
|
494 TRawScanLine decodedScanLine; |
|
495 TTime then; |
|
496 TTime now; |
|
497 TInt64 timetaken; |
|
498 |
|
499 CFaxT4* faxT4 = CFaxT4::NewL(); |
|
500 CleanupStack::PushL(faxT4); |
|
501 |
|
502 result = fs.Connect(); |
|
503 CleanupClosePushL(fs); |
|
504 TESTCHECKL(result, KErrNone); |
|
505 result = enFile.Replace(fs, KTEFaxTestEncodeFileName, EFileShareAny); |
|
506 CleanupClosePushL(enFile); |
|
507 TESTCHECKL(result, KErrNone); |
|
508 |
|
509 INFO_PRINTF1(_L("Testing 1D coding methods")); |
|
510 |
|
511 faxT4->PageInitialize(EFaxFine, EModifiedHuffman); |
|
512 rawScanLine.Fill(KFaxWhite, KFaxBytesPerScanLine); |
|
513 for (blackrun = 0; blackrun <= 1728; blackrun++) |
|
514 { |
|
515 Mem::Fill(&rawScanLine[0], blackrun/8, KFaxBlack); |
|
516 if (blackrun%8) |
|
517 { |
|
518 rawScanLine[(blackrun/8)] = (TUint8)(KFaxWhite << blackrun%8); |
|
519 } |
|
520 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); |
|
521 encodedScanLine.Append(0); |
|
522 encodedScanLine.Append(1); |
|
523 enFile.Write(encodedScanLine); |
|
524 } |
|
525 |
|
526 enFile.Flush(); |
|
527 CleanupStack::PopAndDestroy(&enFile); |
|
528 |
|
529 result = enFile.Open(fs, KTEFaxTestEncodeFileName, EFileShareAny); |
|
530 CleanupClosePushL(enFile); |
|
531 TESTCHECKL(result, KErrNone); |
|
532 |
|
533 // now encoded.fax contains the encoded RawScanLines from the jerry.fax file |
|
534 // and now we are going to decode them again |
|
535 |
|
536 encodedScanLine.Zero(); |
|
537 |
|
538 then.UniversalTime(); |
|
539 faxT4->PageInitialize(EFaxFine,EModifiedHuffman); |
|
540 rawScanLine.Fill(KFaxWhite, KFaxBytesPerScanLine); |
|
541 for (blackrun = 0; blackrun <= 1728; blackrun++) |
|
542 { |
|
543 pos = FindEndOfLine(encodedScanLine); |
|
544 if (pos == KErrNotFound) |
|
545 { |
|
546 flag = ETrue; |
|
547 if (encodedScanLine.Length() != 0) |
|
548 { |
|
549 leftOvers.Copy(encodedScanLine); |
|
550 enFile.Read(encodedScanLine, (encodedScanLine.MaxLength()-leftOvers.Length())); |
|
551 |
|
552 if (FindEndOfLine(encodedScanLine) == KErrNotFound) |
|
553 { |
|
554 User::Leave(KErrNotFound); |
|
555 } |
|
556 |
|
557 encodedScanLine.Insert(0, leftOvers); |
|
558 leftOvers.Zero(); |
|
559 pos = FindEndOfLine(encodedScanLine); |
|
560 flag = EFalse; |
|
561 } |
|
562 |
|
563 if (flag) |
|
564 { |
|
565 enFile.Read(encodedScanLine); |
|
566 pos = FindEndOfLine(encodedScanLine); |
|
567 } |
|
568 } |
|
569 |
|
570 result = faxT4->DecodeScanLine(decodedScanLine, encodedScanLine.Left(pos)); |
|
571 TESTCHECKL(result, KErrNone); |
|
572 |
|
573 Mem::Fill(&rawScanLine[0], blackrun/8, KFaxBlack); |
|
574 if (blackrun%8) |
|
575 { |
|
576 rawScanLine[(blackrun/8)] = (TUint8)(KFaxWhite << blackrun%8); |
|
577 } |
|
578 |
|
579 TEST(!rawScanLine.Compare(decodedScanLine)); |
|
580 encodedScanLine.Delete(0,pos+2); //2 is the length of the delimiter character. |
|
581 } |
|
582 now.UniversalTime(); |
|
583 timetaken = now.MicroSecondsFrom(then).Int64(); |
|
584 INFO_PRINTF2(_L("%dms to 1D encode all possible run lengths"), I64LOW(timetaken)/1000); |
|
585 |
|
586 enFile.Flush(); |
|
587 CleanupStack::PopAndDestroy(&enFile); |
|
588 |
|
589 // |
|
590 // Again, for this test, we'll instantiate our own CFaxT4 object and generate |
|
591 // the fax file using the raw functions - this is purely done for testing |
|
592 // and in real life we'd do a 2D fax via the StartPage() function |
|
593 // as used in test8L |
|
594 // |
|
595 result = enFile.Replace(fs, KTEFaxTestEncodeFileName, EFileShareAny); |
|
596 CleanupClosePushL(enFile); |
|
597 TESTCHECKL(result, KErrNone); |
|
598 |
|
599 INFO_PRINTF1(_L("Test 2D coding methods")); |
|
600 |
|
601 //writeFaxFile->OpenL(_L("c:\\test.fax"),64); |
|
602 |
|
603 faxT4->PageInitialize(EFaxFine, EModifiedRead); |
|
604 rawScanLine.Fill(KFaxBlack, KFaxBytesPerScanLine); // prepare a black reference line |
|
605 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); |
|
606 |
|
607 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
608 encodedScanLine.Append(0); |
|
609 encodedScanLine.Append(1); |
|
610 enFile.Write(encodedScanLine); |
|
611 |
|
612 rawScanLine[0] = KFaxWhite ; // start with a white run |
|
613 rawScanLine[KFaxBytesPerScanLine-1] = KFaxWhite ; // end with a white run |
|
614 rawScanLine[(KFaxBytesPerScanLine/2)-1] = KFaxWhite ; // with a white run halfway through |
|
615 rawScanLine[(KFaxBytesPerScanLine/2)-10] = KFaxWhite ; // and a white run 10 before the end |
|
616 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); // horizontal mode encoding |
|
617 |
|
618 |
|
619 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
620 encodedScanLine.Append(0); |
|
621 encodedScanLine.Append(1); |
|
622 enFile.Write(encodedScanLine); |
|
623 |
|
624 rawScanLine[0] = KFaxWhite; // first run identical for v0 |
|
625 rawScanLine[(KFaxBytesPerScanLine/2)-1] = 0x1c ; // 00011100 test v+3 v-2 |
|
626 rawScanLine[(KFaxBytesPerScanLine/2)-10] = 0x3e ; // 00111110 test v+2 v-1 |
|
627 rawScanLine[KFaxBytesPerScanLine-1] = 0x78 ; // 01111000 test v+1 v-3 |
|
628 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); // vertical mode encoding |
|
629 encodedScanLine.Append(0); |
|
630 encodedScanLine.Append(1); |
|
631 enFile.Write(encodedScanLine); |
|
632 |
|
633 |
|
634 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
635 rawScanLine[0] = KFaxBlack ; // for pass mode |
|
636 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); // pass mode encoding |
|
637 encodedScanLine.Append(0); |
|
638 encodedScanLine.Append(1); |
|
639 enFile.Write(encodedScanLine); |
|
640 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
641 |
|
642 // same again in opposite colours |
|
643 |
|
644 faxT4->PageInitialize(EFaxFine, EModifiedRead); |
|
645 rawScanLine.Fill(KFaxWhite, KFaxBytesPerScanLine); // prepare a white reference line |
|
646 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); |
|
647 encodedScanLine.Append(0); |
|
648 encodedScanLine.Append(1); |
|
649 enFile.Write(encodedScanLine); |
|
650 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
651 |
|
652 rawScanLine[0] = KFaxBlack ; // start with a black run |
|
653 rawScanLine[KFaxBytesPerScanLine-1] = KFaxBlack ; // end with a black run |
|
654 rawScanLine[(KFaxBytesPerScanLine/2)-1] = KFaxBlack ; // with a black run halfway through |
|
655 rawScanLine[(KFaxBytesPerScanLine/2)-10] = KFaxBlack ; // and a blacke run 10 before the end |
|
656 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); // horizontal mode encoding |
|
657 encodedScanLine.Append(0); |
|
658 encodedScanLine.Append(1); |
|
659 enFile.Write(encodedScanLine); |
|
660 |
|
661 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
662 |
|
663 rawScanLine[0] = KFaxBlack ; // first run identical for v0 |
|
664 rawScanLine[(KFaxBytesPerScanLine/2)-1] = 0xe3 ; // 11100011 test v+3 v-2 |
|
665 rawScanLine[(KFaxBytesPerScanLine/2)-10] = 0xc1 ; // 11000001 test v+2 v-1 |
|
666 rawScanLine[KFaxBytesPerScanLine-1] = 0x87 ; // 10000111 test v+1 v-3 |
|
667 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); // vertical mode encoding |
|
668 encodedScanLine.Append(0); |
|
669 encodedScanLine.Append(1); |
|
670 enFile.Write(encodedScanLine); |
|
671 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
672 |
|
673 rawScanLine[0] = KFaxWhite ; // for pass mode |
|
674 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); // pass mode encoding |
|
675 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
676 encodedScanLine.Append(0); |
|
677 encodedScanLine.Append(1); |
|
678 enFile.Write(encodedScanLine); |
|
679 |
|
680 then.UniversalTime(); |
|
681 faxT4->PageInitialize (EFaxFine, EModifiedRead); // now start again |
|
682 rawScanLine.Fill (KFaxWhite, KFaxBytesPerScanLine); |
|
683 for (blackrun=0; blackrun <= 1728 ; blackrun++) |
|
684 { |
|
685 Mem::Fill(&rawScanLine[0], blackrun/8, KFaxBlack); |
|
686 if (blackrun%8) |
|
687 { |
|
688 rawScanLine[(blackrun/8)] = (TUint8)(KFaxWhite << blackrun%8); |
|
689 } |
|
690 faxT4->EncodeScanLine(rawScanLine, encodedScanLine); |
|
691 //writeFaxFile->iWriteFaxPages->AddEncodedScanLineL(encodedScanLine); |
|
692 encodedScanLine.Append(0); |
|
693 encodedScanLine.Append(1); |
|
694 enFile.Write(encodedScanLine); |
|
695 } |
|
696 now.UniversalTime(); |
|
697 timetaken = now.MicroSecondsFrom (then).Int64 (); |
|
698 INFO_PRINTF2(_L("%dms to 2D encode all possible run lengths"), I64LOW(timetaken)/1000); |
|
699 |
|
700 enFile.Flush(); |
|
701 CleanupStack::PopAndDestroy(&enFile); |
|
702 |
|
703 /* |
|
704 writeFaxFile->iWriteFaxPages->EndPageL(EFaxFine,senderId, EModifiedRead); |
|
705 writeFaxFile->CommitL(); |
|
706 writeFaxFile->Close(); |
|
707 */ |
|
708 |
|
709 //readFaxFile->OpenL(_L("c:\\test.fax")); |
|
710 //readFaxFile->iReadFaxPages->SetPageL(0); |
|
711 //TFaxPageInfo info = readFaxFile->iReadFaxPages->CurrentPageInfo(); |
|
712 |
|
713 INFO_PRINTF1(_L("Test 2D decoding methods")); |
|
714 |
|
715 result = enFile.Open(fs, KTEFaxTestEncodeFileName, EFileShareAny); |
|
716 CleanupClosePushL(enFile); |
|
717 TESTCHECKL(result, KErrNone); |
|
718 |
|
719 rawScanLine.Fill(KFaxBlack, KFaxBytesPerScanLine); // prepare a black line as the reference line |
|
720 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
721 |
|
722 enFile.Read(encodedScanLine); |
|
723 pos = FindEndOfLine(encodedScanLine); |
|
724 |
|
725 result = faxT4->DecodeScanLine(decodedScanLine, encodedScanLine.Left(pos)); |
|
726 //err = faxT4->DecodeScanLine(decodedScanLine, encodedScanLine); |
|
727 TESTCHECKL(result, KErrNone); |
|
728 result = rawScanLine.Compare(decodedScanLine); |
|
729 TESTCHECKL(result, KErrNone); |
|
730 encodedScanLine.Delete(0,pos+2); |
|
731 |
|
732 rawScanLine[0] = KFaxWhite ; |
|
733 rawScanLine[KFaxBytesPerScanLine-1] = KFaxWhite ; |
|
734 rawScanLine[(KFaxBytesPerScanLine/2)-1] = KFaxWhite ; // test horizontal mode codec |
|
735 rawScanLine[(KFaxBytesPerScanLine/2)-10] = KFaxWhite ; // and a white run 10 before the end |
|
736 |
|
737 //enFile.Read(encodedScanLine); |
|
738 pos = FindEndOfLine(encodedScanLine); |
|
739 |
|
740 //err = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
741 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
742 |
|
743 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
744 TESTCHECKL(result, KErrNone); |
|
745 result = rawScanLine.Compare(decodedScanLine); |
|
746 TESTCHECKL(result, KErrNone); |
|
747 encodedScanLine.Delete(0,pos+2); |
|
748 |
|
749 rawScanLine[(KFaxBytesPerScanLine/2)-1] = 0x1c ; // test v+3 v-2 |
|
750 rawScanLine[(KFaxBytesPerScanLine/2)-10] = 0x3e ; // test v+2 v-1 coded |
|
751 rawScanLine[KFaxBytesPerScanLine-1] = 0x78 ; // test v+1 v-3 codec |
|
752 |
|
753 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
754 pos=FindEndOfLine(encodedScanLine); |
|
755 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
756 TESTCHECKL(result, KErrNone); |
|
757 result = rawScanLine.Compare(decodedScanLine); |
|
758 TESTCHECKL(result, KErrNone); |
|
759 encodedScanLine.Delete(0,pos+2); |
|
760 |
|
761 rawScanLine[0] = KFaxBlack ; // test pass and v0 codec |
|
762 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
763 pos=FindEndOfLine(encodedScanLine); |
|
764 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
765 TESTCHECKL(result, KErrNone); |
|
766 result = rawScanLine.Compare(decodedScanLine); |
|
767 TESTCHECKL(result, KErrNone); |
|
768 encodedScanLine.Delete(0,pos+2); |
|
769 // same again in opposite colours |
|
770 |
|
771 rawScanLine.Fill (KFaxWhite, KFaxBytesPerScanLine); // prepare a white line as the reference line |
|
772 pos=FindEndOfLine(encodedScanLine); |
|
773 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
774 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
775 TESTCHECKL(result, KErrNone); |
|
776 rawScanLine.Compare(decodedScanLine); |
|
777 TESTCHECKL(result, KErrNone); |
|
778 encodedScanLine.Delete(0,pos+2); |
|
779 |
|
780 |
|
781 rawScanLine[0] = KFaxBlack ; |
|
782 rawScanLine[KFaxBytesPerScanLine-1] = KFaxBlack ; |
|
783 rawScanLine[(KFaxBytesPerScanLine/2)-1] = KFaxBlack ; // test horizontal mode codec |
|
784 rawScanLine[(KFaxBytesPerScanLine/2)-10] = KFaxBlack ; // and a black run 10 before the end |
|
785 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
786 pos=FindEndOfLine(encodedScanLine); |
|
787 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
788 TESTCHECKL(result, KErrNone); |
|
789 result = rawScanLine.Compare(decodedScanLine); |
|
790 TESTCHECKL(result, KErrNone); |
|
791 encodedScanLine.Delete(0,pos+2); |
|
792 |
|
793 rawScanLine[(KFaxBytesPerScanLine/2)-1] = 0xe3 ; // 11100011 test v+3 v-2 |
|
794 rawScanLine[(KFaxBytesPerScanLine/2)-10] = 0xc1 ; // 11000001 test v+2 v-1 |
|
795 rawScanLine[KFaxBytesPerScanLine-1] = 0x87 ; // 10000111 test v+1 v-3 |
|
796 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
797 |
|
798 pos=FindEndOfLine(encodedScanLine); |
|
799 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
800 TESTCHECKL(result, KErrNone); |
|
801 result = rawScanLine.Compare(decodedScanLine); |
|
802 TESTCHECKL(result, KErrNone); |
|
803 encodedScanLine.Delete(0,pos+2); |
|
804 |
|
805 rawScanLine[0] = KFaxWhite ; // test pass and v0 codec |
|
806 //readFaxFile->iReadFaxPages->GetEncodedScanLineL(encodedScanLine); |
|
807 pos=FindEndOfLine(encodedScanLine); |
|
808 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
809 TESTCHECKL(result, KErrNone); |
|
810 result = rawScanLine.Compare(decodedScanLine); |
|
811 TESTCHECKL(result, KErrNone); |
|
812 encodedScanLine.Delete(0,pos+2); |
|
813 |
|
814 // now do all run lengths |
|
815 |
|
816 then.UniversalTime(); |
|
817 //faxT4->PageInitialize (info.iResolution, info.iCompression); |
|
818 // enFile.Close(); |
|
819 |
|
820 // err=enFile.Open(fs,_L("c:\\test.fax"),EFileShareAny); |
|
821 // if (err!=KErrNone) |
|
822 // User::Leave(err); |
|
823 |
|
824 // encodedScanLine.Zero(); |
|
825 flag = EFalse; |
|
826 |
|
827 |
|
828 faxT4->PageInitialize(EFaxFine,EModifiedRead); |
|
829 rawScanLine.Fill(KFaxWhite, KFaxBytesPerScanLine); |
|
830 for (blackrun=0; blackrun <= 1728; blackrun++) |
|
831 { |
|
832 pos = FindEndOfLine(encodedScanLine); |
|
833 if (pos == KErrNotFound) |
|
834 { |
|
835 flag = ETrue; |
|
836 if (encodedScanLine.Length() != 0) |
|
837 { |
|
838 leftOvers.Copy(encodedScanLine); |
|
839 enFile.Read(encodedScanLine, (encodedScanLine.MaxLength()-leftOvers.Length())); |
|
840 if (FindEndOfLine(encodedScanLine) == KErrNotFound) |
|
841 { |
|
842 User::Leave(KErrNotFound); |
|
843 } |
|
844 |
|
845 encodedScanLine.Insert(0, leftOvers); |
|
846 leftOvers.Zero(); |
|
847 pos = FindEndOfLine(encodedScanLine); |
|
848 flag = EFalse; |
|
849 } |
|
850 |
|
851 if (flag) |
|
852 { |
|
853 enFile.Read(encodedScanLine); |
|
854 pos = FindEndOfLine(encodedScanLine); |
|
855 } |
|
856 } |
|
857 |
|
858 result = faxT4->DecodeScanLine(decodedScanLine,encodedScanLine.Left(pos)); |
|
859 TESTCHECKL(result, KErrNone); |
|
860 |
|
861 Mem::Fill(&rawScanLine[0], blackrun/8, KFaxBlack); |
|
862 if (blackrun%8) |
|
863 { |
|
864 rawScanLine[(blackrun/8)] = (TUint8)(KFaxWhite << blackrun%8); |
|
865 } |
|
866 result = rawScanLine.Compare(decodedScanLine); |
|
867 TESTCHECKL(result, KErrNone); |
|
868 encodedScanLine.Delete(0,pos+2); //2 is the length of the delimiter character. |
|
869 } |
|
870 enFile.Flush(); |
|
871 |
|
872 CleanupStack::PopAndDestroy(&enFile); |
|
873 CleanupStack::PopAndDestroy(&fs); |
|
874 CleanupStack::PopAndDestroy(faxT4); |
|
875 |
|
876 return TestStepResult(); |
|
877 } // CFaxTestFaxCoding::doTestStepL |
|
878 |
|
879 |
|
880 TInt CFaxTestFaxCoding::FindEndOfLine(TDes8& aEncodedDes) |
|
881 { |
|
882 TInt maxlength; |
|
883 TUint compareWord(0); |
|
884 |
|
885 maxlength = aEncodedDes.Length(); |
|
886 if (aEncodedDes.Length() == 0) |
|
887 { |
|
888 return KErrNotFound; |
|
889 } |
|
890 |
|
891 TInt index; |
|
892 |
|
893 for (index = 0; index <= maxlength - 2; index++) |
|
894 { |
|
895 compareWord = aEncodedDes[index]; |
|
896 if (compareWord == 0) |
|
897 { |
|
898 compareWord = aEncodedDes[index + 1]; |
|
899 if (compareWord == 1) |
|
900 { |
|
901 return index; |
|
902 } |
|
903 } |
|
904 } |
|
905 |
|
906 return KErrNotFound; |
|
907 } |
|
908 |
|
909 |
|
910 /** |
|
911 * Each test step initialises it's own name |
|
912 */ |
|
913 CFaxTestFaxHeaderDefinition::CFaxTestFaxHeaderDefinition() |
|
914 { |
|
915 // |
|
916 // Store the name of this test case. This is the name that is used by |
|
917 // the script file. |
|
918 // |
|
919 SetTestStepName(_L("TestFaxHeaderDefinition")); |
|
920 } // CFaxTestFaxHeaderDefinition::CFaxTestFaxHeaderDefinition |
|
921 |
|
922 |
|
923 /** |
|
924 * This tests the fax header definition... |
|
925 * |
|
926 * @return Test verdict for this test. |
|
927 */ |
|
928 enum TVerdict CFaxTestFaxHeaderDefinition::doTestStepL() |
|
929 { |
|
930 // |
|
931 // this test is in two halves |
|
932 // |
|
933 // firstly we generate a header file - we don't do this via an Epoc print, but |
|
934 // directly using one of the test fonts in testfont.h. However, the functions |
|
935 // we need are all exercised (writing font information and writing series of |
|
936 // TRawScanLines. (Getting epoc printing to generate the correct data is not |
|
937 // part of this test.) The test function here takes a pointer to the font |
|
938 // together with its dimensions as paramters, so that fonts 1 2 and 3 bytes |
|
939 // wide can be tested out all at te same time. The fonts are in testfont.h |
|
940 // |
|
941 // secondly we use the header file we've just generate to create encoded scan lines |
|
942 // for a header, which we'll write to TEST.FAX as a fax file. Naturally, in |
|
943 // real use, we'd send our encodes scan lines as part of the T.4 image at the start |
|
944 // of each pages, but generating a fax image (which is just a series of encoded scan |
|
945 // lines) is just as good a test. So, we pass a pointer to the fax store as a parameters. |
|
946 // Again, we run this once for each font we test. |
|
947 // |
|
948 RFs fs; |
|
949 TInt result; |
|
950 RFile file; |
|
951 |
|
952 result = fs.Connect(); |
|
953 CleanupClosePushL(fs); |
|
954 TESTCHECKL(result, KErrNone); |
|
955 |
|
956 result = file.Replace(fs, KTEFaxTestHeaderFileName, EFileShareAny); |
|
957 CleanupClosePushL(file); |
|
958 TESTCHECKL(result, KErrNone); |
|
959 |
|
960 INFO_PRINTF1(_L("Generating header file using one byte wide font")); |
|
961 GenerateHeaderFileL(*font8x16, 1, 16); |
|
962 INFO_PRINTF1(_L("Writing fax header to TestHeader.Fax using current time and date")) ; |
|
963 GenerateFaxFileL(file); |
|
964 |
|
965 INFO_PRINTF1(_L("Generating header file using two bytes wide font")); |
|
966 GenerateHeaderFileL(*font16x16, 2, 16); |
|
967 INFO_PRINTF1(_L("Writing fax header to TestHeader.Fax using current time and date")); |
|
968 GenerateFaxFileL(file); |
|
969 |
|
970 INFO_PRINTF1(_L("Generating header file using three bytes wide font")) ; |
|
971 GenerateHeaderFileL(*font24x16, 3, 16); |
|
972 INFO_PRINTF1(_L("Writing fax header to TestHeader.Fax using current time and date")) ; |
|
973 GenerateFaxFileL(file); |
|
974 |
|
975 file.Flush(); |
|
976 |
|
977 CleanupStack::PopAndDestroy(&file); |
|
978 CleanupStack::PopAndDestroy(&fs); |
|
979 |
|
980 return TestStepResult(); |
|
981 } // CFaxTestFaxHeaderDefinition::doTestStepL |
|
982 |
|
983 |
|
984 void CFaxTestFaxHeaderDefinition::GenerateFaxFileL(RFile& aFile) |
|
985 { |
|
986 // use the header to generate a *.FAX file |
|
987 TFaxHeaderInfo faxHeader; |
|
988 |
|
989 CFaxT4* faxT4 = CFaxT4::NewL(); |
|
990 CleanupStack::PushL(faxT4); |
|
991 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
992 CleanupStack::PushL(testheader); |
|
993 |
|
994 testheader->ReadFaxHeaderInfoL(faxHeader); |
|
995 |
|
996 TRawScanLine headline; |
|
997 TRawScanLine fontline; |
|
998 TBuf8<KFaxT4MaxDesLength> encodedHeadLine; |
|
999 |
|
1000 TTime timeOfTransmission; |
|
1001 TBuf<12> timeText; |
|
1002 |
|
1003 timeOfTransmission.HomeTime (); |
|
1004 timeOfTransmission.FormatL(timeText, _L("%F%D%M%Y%H%T")); |
|
1005 |
|
1006 for (TInt index = 0; index < 12; index++) |
|
1007 { |
|
1008 timeText[index] -= '0'; |
|
1009 } |
|
1010 |
|
1011 // Forces 2 digit day - 2 digit month - 4 digit year - 2 digit hour - 2 digit minute |
|
1012 |
|
1013 for (TInt scanline = 0; scanline < faxHeader.iHeaderFontHeightInLines; scanline++) |
|
1014 { |
|
1015 testheader->ReadRawHeaderLineL(scanline, headline); |
|
1016 testheader->ReadRawFontLineL(scanline, fontline); |
|
1017 |
|
1018 for (TInt fontByte = 0; fontByte < faxHeader.iHeaderFontWidthInBytes; fontByte++) |
|
1019 { |
|
1020 headline[((faxHeader.iOffsetToDay) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[0] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1021 headline[((faxHeader.iOffsetToDay + 1) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[1] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1022 headline[((faxHeader.iOffsetToMonth) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[2] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1023 headline[((faxHeader.iOffsetToMonth + 1) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[3] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1024 headline[((faxHeader.iOffsetToYear) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[4] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1025 headline[((faxHeader.iOffsetToYear + 1) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[5] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1026 headline[((faxHeader.iOffsetToYear + 2) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[6] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1027 headline[((faxHeader.iOffsetToYear + 3) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[7] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1028 headline[((faxHeader.iOffsetToHour) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[8] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1029 headline[((faxHeader.iOffsetToHour + 1) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[9] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1030 headline[((faxHeader.iOffsetToMinute) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[10] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1031 headline[((faxHeader.iOffsetToMinute + 1) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(timeText[11] * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1032 |
|
1033 // put the page info in as 12/34 |
|
1034 |
|
1035 headline[((faxHeader.iOffsetToCurrentPage) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(1 * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1036 headline[((faxHeader.iOffsetToCurrentPage + 1) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(2 * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1037 headline[((faxHeader.iOffsetToTotalPages) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(3 * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1038 headline[((faxHeader.iOffsetToTotalPages + 1) * faxHeader.iHeaderFontWidthInBytes) + fontByte] = fontline[(4 * faxHeader.iHeaderFontWidthInBytes) + fontByte]; |
|
1039 } |
|
1040 |
|
1041 faxT4->EncodeScanLine(headline, encodedHeadLine); |
|
1042 aFile.Write(encodedHeadLine); |
|
1043 } |
|
1044 |
|
1045 CleanupStack::PopAndDestroy(testheader); |
|
1046 CleanupStack::PopAndDestroy(faxT4); |
|
1047 } // CFaxTestFaxHeaderDefinition::GenerateFaxFileL |
|
1048 |
|
1049 |
|
1050 void CFaxTestFaxHeaderDefinition::GenerateHeaderFileL(const TUint8* aFont, |
|
1051 TInt aWidth, TInt aHeight) |
|
1052 { |
|
1053 TFaxHeaderInfo faxHeader; |
|
1054 |
|
1055 // |
|
1056 // declare the font size |
|
1057 // |
|
1058 faxHeader.iHeaderFontWidthInBytes = aWidth; |
|
1059 faxHeader.iHeaderFontHeightInLines = aHeight; |
|
1060 |
|
1061 // |
|
1062 // Work out the number of characters we can get in the scan line, so that we can |
|
1063 // create a modifiable buffer to hold the header line and fill it with spaces |
|
1064 // |
|
1065 TInt charactersPerLine = KFaxBytesPerScanLine / faxHeader.iHeaderFontWidthInBytes; |
|
1066 HBufC8* textBuff = HBufC8::NewL(charactersPerLine); |
|
1067 CleanupStack::PushL(textBuff); |
|
1068 |
|
1069 TPtr8 textLine = textBuff->Des(); |
|
1070 textLine.Fill(0x20, charactersPerLine); |
|
1071 |
|
1072 // |
|
1073 // Work out the margin we leave on each side of the page in characters |
|
1074 // this is specified as 74 pixels in T.4 |
|
1075 // |
|
1076 TInt margin = (74 / (8 * faxHeader.iHeaderFontWidthInBytes)); |
|
1077 |
|
1078 // |
|
1079 // THE FOLLOWING LAYOUT IS PURELY FOR TEST PURPOSES AND SHOULDN'T |
|
1080 // BE TAKEN TO BE A DEFINITIVE HEADER LAYOUT |
|
1081 // |
|
1082 // assume we have the date and time on the lefthand side as dd/mm/yyyy hh:mm |
|
1083 // 0000000001111111 |
|
1084 // 1234567890123456 |
|
1085 // fill in the separators |
|
1086 textLine.Replace(margin + 3, 1, _L8 ("/")); |
|
1087 textLine.Replace(margin + 6, 1, _L8 ("/")); |
|
1088 textLine.Replace(margin + 14, 1, _L8 (":")); |
|
1089 |
|
1090 // |
|
1091 // set up the offsets to the data |
|
1092 // |
|
1093 faxHeader.iOffsetToDay = margin + 1; |
|
1094 faxHeader.iOffsetToMonth = margin + 4; |
|
1095 faxHeader.iOffsetToYear = margin + 7; |
|
1096 faxHeader.iOffsetToHour = margin + 12; |
|
1097 faxHeader.iOffsetToMinute = margin + 15; |
|
1098 |
|
1099 // |
|
1100 // assume we have the page info on the righthand side as pp/tt |
|
1101 // 54321 |
|
1102 // fill in the separator |
|
1103 // |
|
1104 textLine.Replace (charactersPerLine - margin - 3, 1, _L8 ("/")); |
|
1105 |
|
1106 // |
|
1107 // set up the offsets to the data |
|
1108 // |
|
1109 faxHeader.iOffsetToTotalPages = charactersPerLine - margin - 2; |
|
1110 faxHeader.iOffsetToCurrentPage = charactersPerLine - margin - 5; |
|
1111 |
|
1112 // |
|
1113 // read in the fax settings, because we want the fax ID and the user ID |
|
1114 // |
|
1115 TFaxSettings ourFaxSettings; |
|
1116 TBuf8<20> userName; |
|
1117 |
|
1118 ourFaxSettings.iFaxId.Copy(_L("+++01234 56789+++")); |
|
1119 userName.Copy(_L("Symbian Test Header")); |
|
1120 |
|
1121 TInt lenID = ourFaxSettings.iFaxId.Length (); |
|
1122 TInt lenUser = userName.Length (); |
|
1123 |
|
1124 // |
|
1125 // Fill the header line with appropriate information |
|
1126 // |
|
1127 textLine.Replace (faxHeader.iOffsetToMinute + 4, lenID, ourFaxSettings.iFaxId); |
|
1128 textLine.Replace (faxHeader.iOffsetToCurrentPage - lenUser -2, lenUser, userName); |
|
1129 |
|
1130 // |
|
1131 // HEADER LAYOUT NOW FINISHED |
|
1132 // |
|
1133 // now we can write the fax header info to the header info file |
|
1134 // |
|
1135 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
1136 CleanupStack::PushL(testheader); |
|
1137 testheader->WriteFaxHeaderInfoL(faxHeader); |
|
1138 |
|
1139 // |
|
1140 // Now we generate the scan line and write the header line bitmap |
|
1141 // via a loop for each rowInFont in the font |
|
1142 // |
|
1143 TInt rowInFont; |
|
1144 |
|
1145 for (rowInFont = 0; rowInFont < faxHeader.iHeaderFontHeightInLines; rowInFont++) |
|
1146 { |
|
1147 TRawScanLine image; |
|
1148 image.SetMax(); |
|
1149 image.FillZ(); |
|
1150 TInt offsetInImage = 0; |
|
1151 |
|
1152 offsetInImage = 0; |
|
1153 for (TInt characterPosition = 0; characterPosition < charactersPerLine; characterPosition++) |
|
1154 { |
|
1155 for (TInt fontByte = 0; fontByte < faxHeader.iHeaderFontWidthInBytes; fontByte++) |
|
1156 { |
|
1157 image[offsetInImage++] = (TUint8)~KReverseByte[*(aFont + ((textLine[characterPosition] - 32) * faxHeader.iHeaderFontHeightInLines * faxHeader.iHeaderFontWidthInBytes) + (rowInFont * faxHeader.iHeaderFontWidthInBytes) + fontByte)]; |
|
1158 } |
|
1159 } |
|
1160 testheader->WriteRawHeaderLineL (rowInFont, image); |
|
1161 } |
|
1162 |
|
1163 // |
|
1164 // now we replace the first ten characters in the header text line with digits |
|
1165 // |
|
1166 textLine.Replace(0, 10, _L8("0123456789")); |
|
1167 |
|
1168 // |
|
1169 // and write out the font line |
|
1170 // |
|
1171 for (rowInFont = 0; rowInFont < faxHeader.iHeaderFontHeightInLines; rowInFont++) |
|
1172 { |
|
1173 TRawScanLine image; |
|
1174 image.SetMax(); |
|
1175 image.FillZ(); |
|
1176 TInt offsetInImage = 0; |
|
1177 |
|
1178 offsetInImage = 0; |
|
1179 for (TInt characterPosition = 0; characterPosition < charactersPerLine; characterPosition++) |
|
1180 { |
|
1181 for (TInt fontByte = 0; fontByte < faxHeader.iHeaderFontWidthInBytes; fontByte++) |
|
1182 { |
|
1183 image[offsetInImage++] = (TUint8)~KReverseByte[*(aFont + ((textLine[characterPosition] - 32) * faxHeader.iHeaderFontHeightInLines * faxHeader.iHeaderFontWidthInBytes) + (rowInFont * faxHeader.iHeaderFontWidthInBytes) + fontByte)]; |
|
1184 } |
|
1185 } |
|
1186 testheader->WriteRawFontLineL (rowInFont, image); |
|
1187 // we can add the test code to generate the panic here |
|
1188 } |
|
1189 |
|
1190 CleanupStack::PopAndDestroy(testheader); |
|
1191 CleanupStack::PopAndDestroy(textBuff); |
|
1192 } // CFaxTestFaxHeaderDefinition::GenerateHeaderFileL |
|
1193 |
|
1194 |
|
1195 /** |
|
1196 * Each test step initialises it's own name |
|
1197 */ |
|
1198 CFaxTestTransmitFax01::CFaxTestTransmitFax01() |
|
1199 { |
|
1200 // |
|
1201 // Store the name of this test case. This is the name that is used by |
|
1202 // the script file. |
|
1203 // |
|
1204 SetTestStepName(_L("TestTransmitFax01")); |
|
1205 } // CFaxTestTransmitFax01::CFaxTestTransmitFax01 |
|
1206 |
|
1207 |
|
1208 /** |
|
1209 * This tests the transmission of a straight forward test fax. |
|
1210 * |
|
1211 * @return Test verdict for this test. |
|
1212 */ |
|
1213 enum TVerdict CFaxTestTransmitFax01::doTestStepL() |
|
1214 { |
|
1215 TFaxSettings faxSettings; |
|
1216 |
|
1217 // |
|
1218 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1219 // TFaxSettings to pass in to it - so our first step must always be |
|
1220 // to read the fax settings or set up suitable defaults. |
|
1221 // |
|
1222 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1223 if (leaveCode != KErrNone) |
|
1224 { |
|
1225 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1226 } |
|
1227 TESTCHECKL(leaveCode, KErrNone); |
|
1228 |
|
1229 // |
|
1230 // Set the Fax parameters... |
|
1231 // |
|
1232 faxSettings.iFaxClass = EClassAuto; |
|
1233 faxSettings.iPreferredECM = 0; |
|
1234 faxSettings.iMaxSpeed = 14400; |
|
1235 faxSettings.iMinSpeed = 2400; |
|
1236 faxSettings.iPreferredResolution = EFaxNormal; |
|
1237 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
1238 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1239 |
|
1240 // |
|
1241 // Start the Fax session... |
|
1242 // |
|
1243 CFaxTransfer* faxSession = NULL; |
|
1244 |
|
1245 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1246 TESTCHECKL(startSessionResult, KErrNone); |
|
1247 TESTL(faxSession != NULL); |
|
1248 |
|
1249 faxSession->SetMode(EDialAndTransmit); |
|
1250 |
|
1251 // |
|
1252 // Generate a Fax header for transmitting... |
|
1253 // |
|
1254 TFaxHeaderInfo faxHeader; |
|
1255 |
|
1256 faxHeader.iHeaderFontWidthInBytes = 0; |
|
1257 |
|
1258 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
1259 TRAP_IGNORE(testheader->ReadFaxHeaderInfoL(faxHeader)); |
|
1260 delete testheader; |
|
1261 |
|
1262 GenerateHeaderFileL(faxSettings, *font8x16, 1, 16); |
|
1263 |
|
1264 // |
|
1265 // Add the source file to the session... |
|
1266 // |
|
1267 faxSession->AddSourceL(_L("C:\\TEST.FAX"), Prefer1D); |
|
1268 |
|
1269 // |
|
1270 // Set the destination phone number if needed... |
|
1271 // |
|
1272 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
1273 { |
|
1274 TBuf8<32> phoneNumber; |
|
1275 |
|
1276 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
1277 faxSession->SetPhoneNumberL(phoneNumber); |
|
1278 } |
|
1279 |
|
1280 // |
|
1281 // Begin transfering the fax... |
|
1282 // |
|
1283 INFO_PRINTF1(_L("Starting fax transmission of TEST.FAX a simple test fax...")); |
|
1284 TInt transferResult = BeginFaxTransfer(faxSession); |
|
1285 INFO_PRINTF2(_L("Fax transmission completed with return code %d"), transferResult); |
|
1286 TESTCHECK(transferResult, KErrNone); |
|
1287 |
|
1288 // |
|
1289 // Clean up the Fax session... |
|
1290 // |
|
1291 faxSession->RemoveAllSources(); |
|
1292 delete faxSession; |
|
1293 faxSession = NULL; |
|
1294 |
|
1295 return TestStepResult(); |
|
1296 } // CFaxTestTransmitFax01::doTestStepL |
|
1297 |
|
1298 |
|
1299 /** |
|
1300 * Each test step initialises it's own name |
|
1301 */ |
|
1302 CFaxTestTransmitFax02::CFaxTestTransmitFax02() |
|
1303 { |
|
1304 // |
|
1305 // Store the name of this test case. This is the name that is used by |
|
1306 // the script file. |
|
1307 // |
|
1308 SetTestStepName(_L("TestTransmitFax02")); |
|
1309 } // CFaxTestTransmitFax02::CFaxTestTransmitFax02 |
|
1310 |
|
1311 |
|
1312 /** |
|
1313 * This tests the transmission of a straight forward test fax. |
|
1314 * |
|
1315 * @return Test verdict for this test. |
|
1316 */ |
|
1317 enum TVerdict CFaxTestTransmitFax02::doTestStepL() |
|
1318 { |
|
1319 TFaxSettings faxSettings; |
|
1320 |
|
1321 // |
|
1322 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1323 // TFaxSettings to pass in to it - so our first step must always be |
|
1324 // to read the fax settings or set up suitable defaults. |
|
1325 // |
|
1326 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1327 if (leaveCode != KErrNone) |
|
1328 { |
|
1329 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1330 } |
|
1331 TESTCHECKL(leaveCode, KErrNone); |
|
1332 |
|
1333 // |
|
1334 // Set the Fax parameters... |
|
1335 // |
|
1336 faxSettings.iFaxClass = EClassAuto; |
|
1337 faxSettings.iPreferredECM = 0; |
|
1338 faxSettings.iMaxSpeed = 9600; |
|
1339 faxSettings.iMinSpeed = 2400; |
|
1340 faxSettings.iPreferredResolution = EFaxFine; |
|
1341 faxSettings.iPreferredCompression = EModifiedRead; |
|
1342 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1343 |
|
1344 // |
|
1345 // Start the Fax session... |
|
1346 // |
|
1347 CFaxTransfer* faxSession = NULL; |
|
1348 |
|
1349 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1350 TESTCHECKL(startSessionResult, KErrNone); |
|
1351 TESTL(faxSession != NULL); |
|
1352 |
|
1353 faxSession->SetMode(EDialAndTransmit); // Or EImmediateTransmit |
|
1354 |
|
1355 // |
|
1356 // Generate a Fax header for transmitting... |
|
1357 // |
|
1358 TFaxHeaderInfo faxHeader; |
|
1359 |
|
1360 faxHeader.iHeaderFontWidthInBytes = 0; |
|
1361 |
|
1362 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
1363 TRAP_IGNORE(testheader->ReadFaxHeaderInfoL(faxHeader)); |
|
1364 delete testheader; |
|
1365 |
|
1366 GenerateHeaderFileL(faxSettings, *font16x16, 2, 16); |
|
1367 |
|
1368 // |
|
1369 // Add the source file to the session. "CHART4.FAX" is an ITU test chart. |
|
1370 // |
|
1371 faxSession->AddSourceL(_L("C:\\CHART4.FAX"), Prefer2D); |
|
1372 |
|
1373 // |
|
1374 // Set the destination phone number if needed... |
|
1375 // |
|
1376 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
1377 { |
|
1378 TBuf8<32> phoneNumber; |
|
1379 |
|
1380 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
1381 faxSession->SetPhoneNumberL(phoneNumber); |
|
1382 } |
|
1383 |
|
1384 // |
|
1385 // Begin transfering the fax... |
|
1386 // |
|
1387 INFO_PRINTF1(_L("Starting fax transmission of CHART4.FAX an ITU test chart...")); |
|
1388 TInt transferResult = BeginFaxTransfer(faxSession); |
|
1389 INFO_PRINTF2(_L("Fax transmission completed with return code %d"), transferResult); |
|
1390 TESTCHECK(transferResult, KErrNone); |
|
1391 |
|
1392 // |
|
1393 // Clean up the Fax session... |
|
1394 // |
|
1395 faxSession->RemoveAllSources(); |
|
1396 delete faxSession; |
|
1397 faxSession = NULL; |
|
1398 |
|
1399 return TestStepResult(); |
|
1400 } // CFaxTestTransmitFax02::doTestStepL |
|
1401 |
|
1402 |
|
1403 /** |
|
1404 * Each test step initialises it's own name |
|
1405 */ |
|
1406 CFaxTestTransmitFax03::CFaxTestTransmitFax03() |
|
1407 { |
|
1408 // |
|
1409 // Store the name of this test case. This is the name that is used by |
|
1410 // the script file. |
|
1411 // |
|
1412 SetTestStepName(_L("TestTransmitFax03")); |
|
1413 } // CFaxTestTransmitFax03::CFaxTestTransmitFax03 |
|
1414 |
|
1415 |
|
1416 /** |
|
1417 * This tests the transmission of a straight forward test fax. |
|
1418 * |
|
1419 * @return Test verdict for this test. |
|
1420 */ |
|
1421 enum TVerdict CFaxTestTransmitFax03::doTestStepL() |
|
1422 { |
|
1423 TFaxSettings faxSettings; |
|
1424 |
|
1425 // |
|
1426 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1427 // TFaxSettings to pass in to it - so our first step must always be |
|
1428 // to read the fax settings or set up suitable defaults. |
|
1429 // |
|
1430 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1431 if (leaveCode != KErrNone) |
|
1432 { |
|
1433 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1434 } |
|
1435 TESTCHECKL(leaveCode, KErrNone); |
|
1436 |
|
1437 // |
|
1438 // Set the Fax parameters... |
|
1439 // |
|
1440 faxSettings.iFaxClass = EClass2; |
|
1441 faxSettings.iMaxSpeed = 9600; |
|
1442 faxSettings.iMinSpeed = 14400; |
|
1443 faxSettings.iPreferredResolution = EFaxNormal; |
|
1444 faxSettings.iPreferredCompression = EModifiedRead; |
|
1445 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1446 |
|
1447 // |
|
1448 // Start the Fax session... |
|
1449 // |
|
1450 CFaxTransfer* faxSession = NULL; |
|
1451 |
|
1452 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1453 TESTCHECKL(startSessionResult, KErrNone); |
|
1454 TESTL(faxSession != NULL); |
|
1455 |
|
1456 faxSession->SetMode(EDialAndTransmit); // Or EImmediateTransmit |
|
1457 |
|
1458 // |
|
1459 // Generate a Fax header for transmitting... |
|
1460 // |
|
1461 TFaxHeaderInfo faxHeader; |
|
1462 |
|
1463 faxHeader.iHeaderFontWidthInBytes = 0; |
|
1464 |
|
1465 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
1466 TRAP_IGNORE(testheader->ReadFaxHeaderInfoL(faxHeader)); |
|
1467 delete testheader; |
|
1468 |
|
1469 GenerateHeaderFileL(faxSettings, *font24x16, 3, 16); |
|
1470 |
|
1471 // |
|
1472 // Add the source file to the session. The "BLANK.FAX" all-white short run |
|
1473 // length file. |
|
1474 // |
|
1475 faxSession->AddSourceL(_L("C:\\BLANK.FAX"), Prefer2D); |
|
1476 |
|
1477 // |
|
1478 // Set the destination phone number if needed... |
|
1479 // |
|
1480 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
1481 { |
|
1482 TBuf8<32> phoneNumber; |
|
1483 |
|
1484 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
1485 faxSession->SetPhoneNumberL(phoneNumber); |
|
1486 } |
|
1487 |
|
1488 // |
|
1489 // Begin transfering the fax... |
|
1490 // |
|
1491 INFO_PRINTF1(_L("Starting fax transmission of BLANK.FAX an all-white short run length file...")); |
|
1492 TInt transferResult = BeginFaxTransfer(faxSession); |
|
1493 INFO_PRINTF2(_L("Fax transmission completed with return code %d"), transferResult); |
|
1494 TESTCHECK(transferResult, KErrNone); |
|
1495 |
|
1496 // |
|
1497 // Clean up the Fax session... |
|
1498 // |
|
1499 faxSession->RemoveAllSources(); |
|
1500 delete faxSession; |
|
1501 faxSession = NULL; |
|
1502 |
|
1503 return TestStepResult(); |
|
1504 } // CFaxTestTransmitFax03::doTestStepL |
|
1505 |
|
1506 |
|
1507 /** |
|
1508 * Each test step initialises it's own name |
|
1509 */ |
|
1510 CFaxTestTransmitFax04::CFaxTestTransmitFax04() |
|
1511 { |
|
1512 // |
|
1513 // Store the name of this test case. This is the name that is used by |
|
1514 // the script file. |
|
1515 // |
|
1516 SetTestStepName(_L("TestTransmitFax04")); |
|
1517 } // CFaxTestTransmitFax04::CFaxTestTransmitFax04 |
|
1518 |
|
1519 |
|
1520 /** |
|
1521 * This tests the transmission of a straight forward test fax. |
|
1522 * |
|
1523 * @return Test verdict for this test. |
|
1524 */ |
|
1525 enum TVerdict CFaxTestTransmitFax04::doTestStepL() |
|
1526 { |
|
1527 TFaxSettings faxSettings; |
|
1528 |
|
1529 // |
|
1530 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1531 // TFaxSettings to pass in to it - so our first step must always be |
|
1532 // to read the fax settings or set up suitable defaults. |
|
1533 // |
|
1534 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1535 if (leaveCode != KErrNone) |
|
1536 { |
|
1537 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1538 } |
|
1539 TESTCHECKL(leaveCode, KErrNone); |
|
1540 |
|
1541 // |
|
1542 // Set the Fax parameters... |
|
1543 // |
|
1544 faxSettings.iFaxClass = EClass2point0; |
|
1545 faxSettings.iPreferredECM = 1; |
|
1546 faxSettings.iMaxSpeed = 2400; |
|
1547 faxSettings.iMinSpeed = 2400; |
|
1548 faxSettings.iPreferredResolution = EFaxNormal; |
|
1549 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
1550 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1551 |
|
1552 // |
|
1553 // Start the Fax session... |
|
1554 // |
|
1555 CFaxTransfer* faxSession = NULL; |
|
1556 |
|
1557 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1558 TESTCHECKL(startSessionResult, KErrNone); |
|
1559 TESTL(faxSession != NULL); |
|
1560 |
|
1561 faxSession->SetMode(EDialAndTransmit); // Or EImmediateTransmit |
|
1562 |
|
1563 // |
|
1564 // Generate a Fax header for transmitting... |
|
1565 // |
|
1566 TFaxHeaderInfo faxHeader; |
|
1567 |
|
1568 faxHeader.iHeaderFontWidthInBytes = 0; |
|
1569 |
|
1570 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
1571 TRAP_IGNORE(testheader->ReadFaxHeaderInfoL(faxHeader)); |
|
1572 delete testheader; |
|
1573 |
|
1574 GenerateHeaderFileL(faxSettings, *font8x16, 1, 16); |
|
1575 |
|
1576 // |
|
1577 // Add the source file to the session... |
|
1578 // |
|
1579 faxSession->AddSourceL(_L("C:\\TWO.FAX"), Prefer2D); |
|
1580 |
|
1581 // |
|
1582 // Set the destination phone number if needed... |
|
1583 // |
|
1584 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
1585 { |
|
1586 TBuf8<32> phoneNumber; |
|
1587 |
|
1588 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
1589 faxSession->SetPhoneNumberL(phoneNumber); |
|
1590 } |
|
1591 |
|
1592 // |
|
1593 // Begin transfering the fax... |
|
1594 // |
|
1595 INFO_PRINTF1(_L("Starting fax transmission of TWO.FAX a two page fax...")); |
|
1596 TInt transferResult = BeginFaxTransfer(faxSession); |
|
1597 INFO_PRINTF2(_L("Fax transmission completed with return code %d"), transferResult); |
|
1598 TESTCHECK(transferResult, KErrNone); |
|
1599 |
|
1600 // |
|
1601 // Clean up the Fax session... |
|
1602 // |
|
1603 faxSession->RemoveAllSources(); |
|
1604 delete faxSession; |
|
1605 faxSession = NULL; |
|
1606 |
|
1607 return TestStepResult(); |
|
1608 } // CFaxTestTransmitFax04::doTestStepL |
|
1609 |
|
1610 |
|
1611 /** |
|
1612 * Each test step initialises it's own name |
|
1613 */ |
|
1614 CFaxTestTransmitFax05::CFaxTestTransmitFax05() |
|
1615 { |
|
1616 // |
|
1617 // Store the name of this test case. This is the name that is used by |
|
1618 // the script file. |
|
1619 // |
|
1620 SetTestStepName(_L("TestTransmitFax05")); |
|
1621 } // CFaxTestTransmitFax05::CFaxTestTransmitFax05 |
|
1622 |
|
1623 |
|
1624 /** |
|
1625 * This tests the transmission of a straight forward test fax. |
|
1626 * |
|
1627 * @return Test verdict for this test. |
|
1628 */ |
|
1629 enum TVerdict CFaxTestTransmitFax05::doTestStepL() |
|
1630 { |
|
1631 TFaxSettings faxSettings; |
|
1632 |
|
1633 // |
|
1634 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1635 // TFaxSettings to pass in to it - so our first step must always be |
|
1636 // to read the fax settings or set up suitable defaults. |
|
1637 // |
|
1638 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1639 if (leaveCode != KErrNone) |
|
1640 { |
|
1641 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1642 } |
|
1643 TESTCHECKL(leaveCode, KErrNone); |
|
1644 |
|
1645 // |
|
1646 // Set the Fax parameters... |
|
1647 // |
|
1648 faxSettings.iFaxClass = EClassAuto; |
|
1649 faxSettings.iPreferredECM = 1; |
|
1650 faxSettings.iMaxSpeed = 14400; |
|
1651 faxSettings.iMinSpeed = 2400; |
|
1652 faxSettings.iPreferredResolution = EFaxNormal; |
|
1653 faxSettings.iPreferredCompression = EModifiedRead; |
|
1654 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1655 |
|
1656 // |
|
1657 // Start the Fax session... |
|
1658 // |
|
1659 CFaxTransfer* faxSession = NULL; |
|
1660 |
|
1661 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1662 TESTCHECKL(startSessionResult, KErrNone); |
|
1663 TESTL(faxSession != NULL); |
|
1664 |
|
1665 faxSession->SetMode(EDialAndTransmit); // Or EImmediateTransmit |
|
1666 |
|
1667 // |
|
1668 // Generate a Fax header for transmitting... |
|
1669 // |
|
1670 TFaxHeaderInfo faxHeader; |
|
1671 |
|
1672 faxHeader.iHeaderFontWidthInBytes = 0; |
|
1673 |
|
1674 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
1675 TRAP_IGNORE(testheader->ReadFaxHeaderInfoL(faxHeader)); |
|
1676 delete testheader; |
|
1677 |
|
1678 GenerateHeaderFileL(faxSettings, *font24x16, 3, 16); |
|
1679 |
|
1680 // |
|
1681 // Add the source files to the session. This will test out the multi page |
|
1682 // sends and also the overall sending of large complex fax images |
|
1683 // by sending whole of CHART4.FAX, pages 3 to 5 from SIX.FAX, followed by |
|
1684 // TWO.FAX starting from page 2 and followed by page 1 of BLANK.FAX. |
|
1685 // |
|
1686 faxSession->AddSourceL(_L("C:\\chart4.fax"), Prefer2D); |
|
1687 faxSession->AddSourceL(_L("C:\\SIX.FAX"), 3, 5); |
|
1688 faxSession->AddSourceL(_L("C:\\TWO.FAX"), 2); |
|
1689 faxSession->AddSourceL(_L("C:\\BLANK.FAX"), 1, 1); |
|
1690 |
|
1691 // |
|
1692 // Set the destination phone number if needed... |
|
1693 // |
|
1694 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
1695 { |
|
1696 TBuf8<32> phoneNumber; |
|
1697 |
|
1698 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
1699 faxSession->SetPhoneNumberL(phoneNumber); |
|
1700 } |
|
1701 |
|
1702 // |
|
1703 // Begin transfering the fax... |
|
1704 // |
|
1705 INFO_PRINTF1(_L("Starting fax transmission of a large complex fax set...")); |
|
1706 TInt transferResult = BeginFaxTransfer(faxSession); |
|
1707 INFO_PRINTF2(_L("Fax transmission completed with return code %d"), transferResult); |
|
1708 TESTCHECK(transferResult, KErrNone); |
|
1709 |
|
1710 // |
|
1711 // Clean up the Fax session... |
|
1712 // |
|
1713 faxSession->RemoveAllSources(); |
|
1714 delete faxSession; |
|
1715 faxSession = NULL; |
|
1716 |
|
1717 return TestStepResult(); |
|
1718 } // CFaxTestTransmitFax05::doTestStepL |
|
1719 |
|
1720 |
|
1721 /** |
|
1722 * Each test step initialises it's own name |
|
1723 */ |
|
1724 CFaxTestTransmitFax06::CFaxTestTransmitFax06() |
|
1725 { |
|
1726 // |
|
1727 // Store the name of this test case. This is the name that is used by |
|
1728 // the script file. |
|
1729 // |
|
1730 SetTestStepName(_L("TestTransmitFax06")); |
|
1731 } // CFaxTestTransmitFax06::CFaxTestTransmitFax06 |
|
1732 |
|
1733 |
|
1734 /** |
|
1735 * This tests the transmission of a straight forward test fax. |
|
1736 * |
|
1737 * @return Test verdict for this test. |
|
1738 */ |
|
1739 enum TVerdict CFaxTestTransmitFax06::doTestStepL() |
|
1740 { |
|
1741 TFaxSettings faxSettings; |
|
1742 |
|
1743 // |
|
1744 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1745 // TFaxSettings to pass in to it - so our first step must always be |
|
1746 // to read the fax settings or set up suitable defaults. |
|
1747 // |
|
1748 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1749 if (leaveCode != KErrNone) |
|
1750 { |
|
1751 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1752 } |
|
1753 TESTCHECKL(leaveCode, KErrNone); |
|
1754 |
|
1755 // |
|
1756 // Set the Fax parameters... |
|
1757 // |
|
1758 faxSettings.iFaxClass = EClassAuto; |
|
1759 faxSettings.iPreferredECM = 0; |
|
1760 faxSettings.iMaxSpeed = 14400; |
|
1761 faxSettings.iMinSpeed = 2400; |
|
1762 faxSettings.iPreferredResolution = EFaxFine; |
|
1763 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
1764 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1765 |
|
1766 // |
|
1767 // Start the Fax session... |
|
1768 // |
|
1769 CFaxTransfer* faxSession = NULL; |
|
1770 |
|
1771 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1772 TESTCHECKL(startSessionResult, KErrNone); |
|
1773 TESTL(faxSession != NULL); |
|
1774 |
|
1775 faxSession->SetMode(EDialAndTransmit); // Or EImmediateTransmit |
|
1776 |
|
1777 // |
|
1778 // Generate a Fax header for transmitting... |
|
1779 // |
|
1780 TFaxHeaderInfo faxHeader; |
|
1781 |
|
1782 faxHeader.iHeaderFontWidthInBytes = 0; |
|
1783 |
|
1784 CFaxHeaderLines* testheader = CFaxHeaderLines::NewL(); |
|
1785 TRAP_IGNORE(testheader->ReadFaxHeaderInfoL(faxHeader)); |
|
1786 delete testheader; |
|
1787 |
|
1788 GenerateHeaderFileL(faxSettings, *font24x16, 3, 16); |
|
1789 |
|
1790 // |
|
1791 // Add the source files to the session. This tests a bad page fax. |
|
1792 // |
|
1793 faxSession->AddSourceL(_L("C:\\BADPAGE.FAX"), Prefer1D); |
|
1794 |
|
1795 // |
|
1796 // Set the destination phone number if needed... |
|
1797 // |
|
1798 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
1799 { |
|
1800 TBuf8<32> phoneNumber; |
|
1801 |
|
1802 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
1803 faxSession->SetPhoneNumberL(phoneNumber); |
|
1804 } |
|
1805 |
|
1806 // |
|
1807 // Begin transfering the fax... |
|
1808 // |
|
1809 INFO_PRINTF1(_L("Starting fax transmission of a bad page fax...")); |
|
1810 TInt transferResult = BeginFaxTransfer(faxSession); |
|
1811 INFO_PRINTF2(_L("Fax transmission completed with return code %d"), transferResult); |
|
1812 TESTCHECK(transferResult, KErrNone); |
|
1813 |
|
1814 // |
|
1815 // Clean up the Fax session... |
|
1816 // |
|
1817 faxSession->RemoveAllSources(); |
|
1818 delete faxSession; |
|
1819 faxSession = NULL; |
|
1820 |
|
1821 return TestStepResult(); |
|
1822 } // CFaxTestTransmitFax06::doTestStepL |
|
1823 |
|
1824 |
|
1825 /** |
|
1826 * Each test step initialises it's own name |
|
1827 */ |
|
1828 CFaxTestReceiveFax01::CFaxTestReceiveFax01() |
|
1829 { |
|
1830 // |
|
1831 // Store the name of this test case. This is the name that is used by |
|
1832 // the script file. |
|
1833 // |
|
1834 SetTestStepName(_L("TestReceiveFax01")); |
|
1835 } // CFaxTestReceiveFax01::CFaxTestReceiveFax01 |
|
1836 |
|
1837 |
|
1838 /** |
|
1839 * This tests the reception of a straight forward test fax. |
|
1840 * |
|
1841 * @return Test verdict for this test. |
|
1842 */ |
|
1843 enum TVerdict CFaxTestReceiveFax01::doTestStepL() |
|
1844 { |
|
1845 TFaxSettings faxSettings; |
|
1846 |
|
1847 // |
|
1848 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1849 // TFaxSettings to pass in to it - so our first step must always be |
|
1850 // to read the fax settings or set up suitable defaults. |
|
1851 // |
|
1852 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1853 if (leaveCode != KErrNone) |
|
1854 { |
|
1855 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1856 } |
|
1857 TESTCHECKL(leaveCode, KErrNone); |
|
1858 |
|
1859 // |
|
1860 // Set the Fax parameters... |
|
1861 // |
|
1862 faxSettings.iFaxClass = EClassAuto; // Or EClass1, EClass2, EClass2point0 |
|
1863 if (faxSettings.iFaxClass == EClass2point0 || |
|
1864 faxSettings.iFaxClass == EClassAuto) |
|
1865 { |
|
1866 faxSettings.iPreferredECM = 0; // Or 1 |
|
1867 } |
|
1868 |
|
1869 faxSettings.iMaxSpeed = 14400; // 2400 to 14400 % 2400 |
|
1870 faxSettings.iMinSpeed = 2400; // 2400 to 14400 % 2400 |
|
1871 faxSettings.iPreferredResolution = EFaxNormal; // Or EFaxFine |
|
1872 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
1873 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1874 |
|
1875 // |
|
1876 // Start the Fax session... |
|
1877 // |
|
1878 CFaxTransfer* faxSession = NULL; |
|
1879 |
|
1880 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1881 TESTCHECKL(startSessionResult, KErrNone); |
|
1882 TESTL(faxSession != NULL); |
|
1883 |
|
1884 faxSession->SetMode(EWaitForRingAndReceive); // Or EDialAndReceiveFaxBack, EDialAndReceivePoll, EImmediateReceive |
|
1885 faxSession->SetReceiveFileName(_L("C:\\RECEIVE01.FAX")); |
|
1886 |
|
1887 // |
|
1888 // Set the destination phone number if needed... |
|
1889 // |
|
1890 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
1891 { |
|
1892 TBuf8<32> phoneNumber; |
|
1893 |
|
1894 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
1895 faxSession->SetPhoneNumberL(phoneNumber); |
|
1896 } |
|
1897 |
|
1898 // |
|
1899 // Begin transfering the fax... |
|
1900 // |
|
1901 INFO_PRINTF1(_L("Starting fax reception...")); |
|
1902 TInt transferResult = BeginFaxTransfer(faxSession); |
|
1903 INFO_PRINTF2(_L("Fax reception completed with return code %d"), transferResult); |
|
1904 TESTCHECK(transferResult, KErrNone); |
|
1905 |
|
1906 // |
|
1907 // Clean up the Fax session... |
|
1908 // |
|
1909 faxSession->RemoveAllSources(); |
|
1910 delete faxSession; |
|
1911 faxSession = NULL; |
|
1912 |
|
1913 return TestStepResult(); |
|
1914 } // CFaxTestReceiveFax01::doTestStepL |
|
1915 |
|
1916 |
|
1917 /** |
|
1918 * Each test step initialises it's own name |
|
1919 */ |
|
1920 CFaxTestReceiveFax02::CFaxTestReceiveFax02() |
|
1921 { |
|
1922 // |
|
1923 // Store the name of this test case. This is the name that is used by |
|
1924 // the script file. |
|
1925 // |
|
1926 SetTestStepName(_L("TestTransmitFax02")); |
|
1927 } // CFaxTestReceiveFax02::CFaxTestReceiveFax02 |
|
1928 |
|
1929 |
|
1930 /** |
|
1931 * This tests the reception of a fax, specifying the call object name first. |
|
1932 * |
|
1933 * @return Test verdict for this test. |
|
1934 */ |
|
1935 enum TVerdict CFaxTestReceiveFax02::doTestStepL() |
|
1936 { |
|
1937 TFaxSettings faxSettings; |
|
1938 |
|
1939 // |
|
1940 // Before instantiating CFaxTransfer we have to have a valid set of |
|
1941 // TFaxSettings to pass in to it - so our first step must always be |
|
1942 // to read the fax settings or set up suitable defaults. |
|
1943 // |
|
1944 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
1945 if (leaveCode != KErrNone) |
|
1946 { |
|
1947 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
1948 } |
|
1949 TESTCHECKL(leaveCode, KErrNone); |
|
1950 |
|
1951 // |
|
1952 // Set the Fax parameters... |
|
1953 // |
|
1954 faxSettings.iFaxClass = EClassAuto; // Or EClass1, EClass2, EClass2point0 |
|
1955 if (faxSettings.iFaxClass == EClass2point0 || |
|
1956 faxSettings.iFaxClass == EClassAuto) |
|
1957 { |
|
1958 faxSettings.iPreferredECM = 0; // Or 1 |
|
1959 } |
|
1960 |
|
1961 faxSettings.iMaxSpeed = 14400; // 2400 to 14400 % 2400 |
|
1962 faxSettings.iMinSpeed = 2400; // 2400 to 14400 % 2400 |
|
1963 faxSettings.iPreferredResolution = EFaxNormal; // Or EFaxFine |
|
1964 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
1965 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
1966 |
|
1967 // |
|
1968 // Start the Fax session... |
|
1969 // |
|
1970 CFaxTransfer* faxSession = NULL; |
|
1971 |
|
1972 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
1973 TESTCHECKL(startSessionResult, KErrNone); |
|
1974 TESTL(faxSession != NULL); |
|
1975 |
|
1976 |
|
1977 faxSession->SetMode(EWaitForRingAndReceive); // Or EDialAndReceiveFaxBack, EDialAndReceivePoll, EImmediateReceive |
|
1978 faxSession->SetReceiveFileName(_L("C:\\RECEIVE02.FAX")); |
|
1979 |
|
1980 // |
|
1981 // For this test, find the name of the incoming call and request the fax |
|
1982 // session to open that call... |
|
1983 // |
|
1984 RTelServer telServer; |
|
1985 RMobilePhone phone; |
|
1986 RLine line; |
|
1987 RCall call; |
|
1988 TName incomingCallName; |
|
1989 RCall::TStatus callStatus; |
|
1990 |
|
1991 TInt result = telServer.Connect(); |
|
1992 TESTCHECKL(result, KErrNone); |
|
1993 CleanupClosePushL(telServer); |
|
1994 |
|
1995 result = telServer.LoadPhoneModule(KTEFaxTSYName); |
|
1996 TESTCHECKL(result, KErrNone); |
|
1997 |
|
1998 result = phone.Open(telServer, KTEFaxPhoneName); |
|
1999 TESTCHECKL(result, KErrNone); |
|
2000 CleanupClosePushL(phone); |
|
2001 |
|
2002 result = line.Open(phone, KTEFaxLineName); |
|
2003 TESTCHECKL(result, KErrNone); |
|
2004 CleanupClosePushL(line); |
|
2005 |
|
2006 TRequestStatus status; |
|
2007 |
|
2008 line.NotifyIncomingCall(status, incomingCallName); |
|
2009 User::WaitForRequest(status); |
|
2010 TESTCHECKL(status.Int(), KErrNone); |
|
2011 INFO_PRINTF2(_L("Incoming fax call is \"%S\"..."), &incomingCallName); |
|
2012 |
|
2013 faxSession->SetCallObjectName(incomingCallName); |
|
2014 |
|
2015 // |
|
2016 // Open the incoming call and request a notification of state change. If |
|
2017 // the Fax Server were to open a different RCall object then this would |
|
2018 // not work - thus it is a good test of SetCallObjectName()... |
|
2019 // |
|
2020 result = call.OpenExistingCall(line, incomingCallName); |
|
2021 TESTCHECKL(result, KErrNone); |
|
2022 CleanupClosePushL(call); |
|
2023 |
|
2024 callStatus = RCall::EStatusUnknown; |
|
2025 call.NotifyStatusChange(status, callStatus); |
|
2026 TESTCHECK(status.Int(), KRequestPending); |
|
2027 |
|
2028 // |
|
2029 // Set the destination phone number if needed... |
|
2030 // |
|
2031 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
2032 { |
|
2033 TBuf8<32> phoneNumber; |
|
2034 |
|
2035 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
2036 faxSession->SetPhoneNumberL(phoneNumber); |
|
2037 } |
|
2038 |
|
2039 // |
|
2040 // Begin transfering the fax... |
|
2041 // |
|
2042 INFO_PRINTF1(_L("Starting fax reception...")); |
|
2043 TInt transferResult = BeginFaxTransfer(faxSession); |
|
2044 INFO_PRINTF2(_L("Fax reception completed with return code %d"), transferResult); |
|
2045 TESTCHECK(transferResult, KErrNone); |
|
2046 |
|
2047 // |
|
2048 // Check that the notify operation returned as the fax server answered the |
|
2049 // call... |
|
2050 // |
|
2051 User::WaitForRequest(status); |
|
2052 TESTCHECK(status.Int(), KErrNone); |
|
2053 TESTCHECK(callStatus, RCall::EStatusAnswering); |
|
2054 |
|
2055 // |
|
2056 // Clean up Etel handles... |
|
2057 // |
|
2058 CleanupStack::PopAndDestroy(&call); |
|
2059 CleanupStack::PopAndDestroy(&line); |
|
2060 CleanupStack::PopAndDestroy(&phone); |
|
2061 CleanupStack::PopAndDestroy(&telServer); |
|
2062 |
|
2063 // |
|
2064 // Clean up the Fax session... |
|
2065 // |
|
2066 faxSession->RemoveAllSources(); |
|
2067 delete faxSession; |
|
2068 faxSession = NULL; |
|
2069 |
|
2070 return TestStepResult(); |
|
2071 } // CFaxTestReceiveFax02::doTestStepL |
|
2072 |
|
2073 |
|
2074 /** |
|
2075 * Each test step initialises it's own name |
|
2076 */ |
|
2077 CFaxTestReceiveFax03::CFaxTestReceiveFax03() |
|
2078 { |
|
2079 // |
|
2080 // Store the name of this test case. This is the name that is used by |
|
2081 // the script file. |
|
2082 // |
|
2083 SetTestStepName(_L("TestReceiveFax03")); |
|
2084 } // CFaxTestReceiveFax03::CFaxTestReceiveFax03 |
|
2085 |
|
2086 |
|
2087 /** |
|
2088 * This tests the reception of a straight forward test fax. |
|
2089 * |
|
2090 * @return Test verdict for this test. |
|
2091 */ |
|
2092 enum TVerdict CFaxTestReceiveFax03::doTestStepL() |
|
2093 { |
|
2094 TFaxSettings faxSettings; |
|
2095 |
|
2096 // |
|
2097 // Before instantiating CFaxTransfer we have to have a valid set of |
|
2098 // TFaxSettings to pass in to it - so our first step must always be |
|
2099 // to read the fax settings or set up suitable defaults. |
|
2100 // |
|
2101 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
2102 if (leaveCode != KErrNone) |
|
2103 { |
|
2104 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
2105 } |
|
2106 TESTCHECKL(leaveCode, KErrNone); |
|
2107 |
|
2108 // |
|
2109 // Set the Fax parameters... |
|
2110 // |
|
2111 faxSettings.iFaxClass = EClassAuto; // Or EClass1, EClass2, EClass2point0 |
|
2112 if (faxSettings.iFaxClass == EClass2point0 || |
|
2113 faxSettings.iFaxClass == EClassAuto) |
|
2114 { |
|
2115 faxSettings.iPreferredECM = 0; // Or 1 |
|
2116 } |
|
2117 |
|
2118 faxSettings.iMaxSpeed = 14400; // 2400 to 14400 % 2400 |
|
2119 faxSettings.iMinSpeed = 2400; // 2400 to 14400 % 2400 |
|
2120 faxSettings.iPreferredResolution = EFaxNormal; // Or EFaxFine |
|
2121 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
2122 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
2123 |
|
2124 // |
|
2125 // Start the Fax session... |
|
2126 // |
|
2127 CFaxTransfer* faxSession = NULL; |
|
2128 |
|
2129 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
2130 TESTCHECKL(startSessionResult, KErrNone); |
|
2131 TESTL(faxSession != NULL); |
|
2132 |
|
2133 faxSession->SetMode(EWaitForRingAndReceive); // Or EDialAndReceiveFaxBack, EDialAndReceivePoll, EImmediateReceive |
|
2134 faxSession->SetReceiveFileName(_L("C:\\RECEIVE03.FAX")); |
|
2135 |
|
2136 // |
|
2137 // Set the destination phone number if needed... |
|
2138 // |
|
2139 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
2140 { |
|
2141 TBuf8<32> phoneNumber; |
|
2142 |
|
2143 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
2144 faxSession->SetPhoneNumberL(phoneNumber); |
|
2145 } |
|
2146 |
|
2147 // |
|
2148 // Begin transfering the fax... |
|
2149 // |
|
2150 INFO_PRINTF1(_L("Starting fax reception...")); |
|
2151 TInt transferResult = BeginFaxTransfer(faxSession); |
|
2152 INFO_PRINTF2(_L("Fax reception completed with return code %d"), transferResult); |
|
2153 TESTCHECK(transferResult, KErrNone); |
|
2154 |
|
2155 // |
|
2156 // Clean up the Fax session... |
|
2157 // |
|
2158 faxSession->RemoveAllSources(); |
|
2159 delete faxSession; |
|
2160 faxSession = NULL; |
|
2161 |
|
2162 return TestStepResult(); |
|
2163 } // CFaxTestReceiveFax03::doTestStepL |
|
2164 |
|
2165 |
|
2166 /** |
|
2167 * Each test step initialises it's own name |
|
2168 */ |
|
2169 CFaxTestReceiveFax04::CFaxTestReceiveFax04() |
|
2170 { |
|
2171 // |
|
2172 // Store the name of this test case. This is the name that is used by |
|
2173 // the script file. |
|
2174 // |
|
2175 SetTestStepName(_L("TestReceiveFax04")); |
|
2176 } // CFaxTestReceiveFax04::CFaxTestReceiveFax04 |
|
2177 |
|
2178 |
|
2179 /** |
|
2180 * This tests the reception of a straight forward test fax. |
|
2181 * |
|
2182 * @return Test verdict for this test. |
|
2183 */ |
|
2184 enum TVerdict CFaxTestReceiveFax04::doTestStepL() |
|
2185 { |
|
2186 TFaxSettings faxSettings; |
|
2187 |
|
2188 // |
|
2189 // Before instantiating CFaxTransfer we have to have a valid set of |
|
2190 // TFaxSettings to pass in to it - so our first step must always be |
|
2191 // to read the fax settings or set up suitable defaults. |
|
2192 // |
|
2193 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
2194 if (leaveCode != KErrNone) |
|
2195 { |
|
2196 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
2197 } |
|
2198 TESTCHECKL(leaveCode, KErrNone); |
|
2199 |
|
2200 // |
|
2201 // Set the Fax parameters... |
|
2202 // |
|
2203 faxSettings.iFaxClass = EClassAuto; // Or EClass1, EClass2, EClass2point0 |
|
2204 if (faxSettings.iFaxClass == EClass2point0 || |
|
2205 faxSettings.iFaxClass == EClassAuto) |
|
2206 { |
|
2207 faxSettings.iPreferredECM = 0; // Or 1 |
|
2208 } |
|
2209 |
|
2210 faxSettings.iMaxSpeed = 14400; // 2400 to 14400 % 2400 |
|
2211 faxSettings.iMinSpeed = 2400; // 2400 to 14400 % 2400 |
|
2212 faxSettings.iPreferredResolution = EFaxNormal; // Or EFaxFine |
|
2213 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
2214 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
2215 |
|
2216 // |
|
2217 // Start the Fax session... |
|
2218 // |
|
2219 CFaxTransfer* faxSession = NULL; |
|
2220 |
|
2221 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
2222 TESTCHECKL(startSessionResult, KErrNone); |
|
2223 TESTL(faxSession != NULL); |
|
2224 |
|
2225 |
|
2226 faxSession->SetMode(EWaitForRingAndReceive); // Or EDialAndReceiveFaxBack, EDialAndReceivePoll, EImmediateReceive |
|
2227 faxSession->SetReceiveFileName(_L("C:\\RECEIVE04.FAX")); |
|
2228 |
|
2229 // |
|
2230 // Set the destination phone number if needed... |
|
2231 // |
|
2232 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
2233 { |
|
2234 TBuf8<32> phoneNumber; |
|
2235 |
|
2236 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
2237 faxSession->SetPhoneNumberL(phoneNumber); |
|
2238 } |
|
2239 |
|
2240 // |
|
2241 // Begin transfering the fax... |
|
2242 // |
|
2243 INFO_PRINTF1(_L("Starting fax reception...")); |
|
2244 TInt transferResult = BeginFaxTransfer(faxSession); |
|
2245 INFO_PRINTF2(_L("Fax reception completed with return code %d"), transferResult); |
|
2246 TESTCHECK(transferResult, KErrNone); |
|
2247 |
|
2248 // |
|
2249 // Clean up the Fax session... |
|
2250 // |
|
2251 faxSession->RemoveAllSources(); |
|
2252 delete faxSession; |
|
2253 faxSession = NULL; |
|
2254 |
|
2255 return TestStepResult(); |
|
2256 } // CFaxTestReceiveFax04::doTestStepL |
|
2257 |
|
2258 |
|
2259 /** |
|
2260 * Each test step initialises it's own name |
|
2261 */ |
|
2262 CFaxTestReceiveFax05::CFaxTestReceiveFax05() |
|
2263 { |
|
2264 // |
|
2265 // Store the name of this test case. This is the name that is used by |
|
2266 // the script file. |
|
2267 // |
|
2268 SetTestStepName(_L("TestReceiveFax05")); |
|
2269 } // CFaxTestReceiveFax05::CFaxTestReceiveFax05 |
|
2270 |
|
2271 |
|
2272 /** |
|
2273 * This tests the reception of a straight forward test fax. |
|
2274 * |
|
2275 * @return Test verdict for this test. |
|
2276 */ |
|
2277 enum TVerdict CFaxTestReceiveFax05::doTestStepL() |
|
2278 { |
|
2279 TFaxSettings faxSettings; |
|
2280 |
|
2281 // |
|
2282 // Before instantiating CFaxTransfer we have to have a valid set of |
|
2283 // TFaxSettings to pass in to it - so our first step must always be |
|
2284 // to read the fax settings or set up suitable defaults. |
|
2285 // |
|
2286 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
2287 if (leaveCode != KErrNone) |
|
2288 { |
|
2289 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
2290 } |
|
2291 TESTCHECKL(leaveCode, KErrNone); |
|
2292 |
|
2293 // |
|
2294 // Set the Fax parameters... |
|
2295 // |
|
2296 faxSettings.iFaxClass = EClassAuto; // Or EClass1, EClass2, EClass2point0 |
|
2297 if (faxSettings.iFaxClass == EClass2point0 || |
|
2298 faxSettings.iFaxClass == EClassAuto) |
|
2299 { |
|
2300 faxSettings.iPreferredECM = 0; // Or 1 |
|
2301 } |
|
2302 |
|
2303 faxSettings.iMaxSpeed = 14400; // 2400 to 14400 % 2400 |
|
2304 faxSettings.iMinSpeed = 2400; // 2400 to 14400 % 2400 |
|
2305 faxSettings.iPreferredResolution = EFaxNormal; // Or EFaxFine |
|
2306 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
2307 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
2308 |
|
2309 // |
|
2310 // Start the Fax session... |
|
2311 // |
|
2312 CFaxTransfer* faxSession = NULL; |
|
2313 |
|
2314 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
2315 TESTCHECKL(startSessionResult, KErrNone); |
|
2316 TESTL(faxSession != NULL); |
|
2317 |
|
2318 |
|
2319 faxSession->SetMode(EWaitForRingAndReceive); // Or EDialAndReceiveFaxBack, EDialAndReceivePoll, EImmediateReceive |
|
2320 faxSession->SetReceiveFileName(_L("C:\\RECEIVE05.FAX")); |
|
2321 |
|
2322 // |
|
2323 // Set the destination phone number if needed... |
|
2324 // |
|
2325 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
2326 { |
|
2327 TBuf8<32> phoneNumber; |
|
2328 |
|
2329 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
2330 faxSession->SetPhoneNumberL(phoneNumber); |
|
2331 } |
|
2332 |
|
2333 // |
|
2334 // Begin transfering the fax... |
|
2335 // |
|
2336 INFO_PRINTF1(_L("Starting fax reception...")); |
|
2337 TInt transferResult = BeginFaxTransfer(faxSession); |
|
2338 INFO_PRINTF2(_L("Fax reception completed with return code %d"), transferResult); |
|
2339 TESTCHECK(transferResult, KErrNone); |
|
2340 |
|
2341 // |
|
2342 // Clean up the Fax session... |
|
2343 // |
|
2344 faxSession->RemoveAllSources(); |
|
2345 delete faxSession; |
|
2346 faxSession = NULL; |
|
2347 |
|
2348 return TestStepResult(); |
|
2349 } // CFaxTestReceiveFax05::doTestStepL |
|
2350 |
|
2351 |
|
2352 /** |
|
2353 * Each test step initialises it's own name |
|
2354 */ |
|
2355 CFaxTestReceiveFax06::CFaxTestReceiveFax06() |
|
2356 { |
|
2357 // |
|
2358 // Store the name of this test case. This is the name that is used by |
|
2359 // the script file. |
|
2360 // |
|
2361 SetTestStepName(_L("TestReceiveFax06")); |
|
2362 } // CFaxTestReceiveFax06::CFaxTestReceiveFax06 |
|
2363 |
|
2364 |
|
2365 /** |
|
2366 * This tests the reception of a straight forward test fax. |
|
2367 * |
|
2368 * @return Test verdict for this test. |
|
2369 */ |
|
2370 enum TVerdict CFaxTestReceiveFax06::doTestStepL() |
|
2371 { |
|
2372 TFaxSettings faxSettings; |
|
2373 |
|
2374 // |
|
2375 // Before instantiating CFaxTransfer we have to have a valid set of |
|
2376 // TFaxSettings to pass in to it - so our first step must always be |
|
2377 // to read the fax settings or set up suitable defaults. |
|
2378 // |
|
2379 TRAPD(leaveCode, ReadFaxCommDBSettingsL(faxSettings)); |
|
2380 if (leaveCode != KErrNone) |
|
2381 { |
|
2382 INFO_PRINTF2(_L("ReadFaxCommDBSettingsL() error %d!"), leaveCode); |
|
2383 } |
|
2384 TESTCHECKL(leaveCode, KErrNone); |
|
2385 |
|
2386 // |
|
2387 // Set the Fax parameters... |
|
2388 // |
|
2389 faxSettings.iFaxClass = EClassAuto; // Or EClass1, EClass2, EClass2point0 |
|
2390 if (faxSettings.iFaxClass == EClass2point0 || |
|
2391 faxSettings.iFaxClass == EClassAuto) |
|
2392 { |
|
2393 faxSettings.iPreferredECM = 0; // Or 1 |
|
2394 } |
|
2395 |
|
2396 faxSettings.iMaxSpeed = 14400; // 2400 to 14400 % 2400 |
|
2397 faxSettings.iMinSpeed = 2400; // 2400 to 14400 % 2400 |
|
2398 faxSettings.iPreferredResolution = EFaxNormal; // Or EFaxFine |
|
2399 faxSettings.iPreferredCompression = EModifiedHuffman; |
|
2400 faxSettings.iFaxId.Copy(_L8("+441632960000")); |
|
2401 |
|
2402 // |
|
2403 // Start the Fax session... |
|
2404 // |
|
2405 CFaxTransfer* faxSession = NULL; |
|
2406 |
|
2407 TRAPD(startSessionResult, faxSession = CFaxTransfer::NewL(faxSettings)); |
|
2408 TESTCHECKL(startSessionResult, KErrNone); |
|
2409 TESTL(faxSession != NULL); |
|
2410 |
|
2411 |
|
2412 faxSession->SetMode(EWaitForRingAndReceive); // Or EDialAndReceiveFaxBack, EDialAndReceivePoll, EImmediateReceive |
|
2413 faxSession->SetReceiveFileName(_L("C:\\RECEIVE06.FAX")); |
|
2414 |
|
2415 // |
|
2416 // Set the destination phone number if needed... |
|
2417 // |
|
2418 if ((faxSession->iMode & KFaxNoDial) == 0) |
|
2419 { |
|
2420 TBuf8<32> phoneNumber; |
|
2421 |
|
2422 ReadDestPhoneNumberFromIniFileL(phoneNumber); |
|
2423 faxSession->SetPhoneNumberL(phoneNumber); |
|
2424 } |
|
2425 |
|
2426 // |
|
2427 // Begin transfering the fax... |
|
2428 // |
|
2429 INFO_PRINTF1(_L("Starting fax reception...")); |
|
2430 TInt transferResult = BeginFaxTransfer(faxSession); |
|
2431 INFO_PRINTF2(_L("Fax reception completed with return code %d"), transferResult); |
|
2432 TESTCHECK(transferResult, KErrNone); |
|
2433 |
|
2434 // |
|
2435 // Clean up the Fax session... |
|
2436 // |
|
2437 faxSession->RemoveAllSources(); |
|
2438 delete faxSession; |
|
2439 faxSession = NULL; |
|
2440 |
|
2441 return TestStepResult(); |
|
2442 } // CFaxTestReceiveFax06::doTestStepL |
|
2443 |