13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 |
|
19 #include "TGraphicsContext.h" |
18 #include <e32std.h> |
20 #include <e32std.h> |
19 #include <e32test.h> |
21 #include <e32test.h> |
20 #include <frmtlay.h> |
22 #include <frmtlay.h> |
21 #include <frmtview.h> |
23 #include <frmtview.h> |
22 #include <frmconst.h> |
24 #include <frmconst.h> |
23 #include <txtlaydc.h> |
25 #include <txtlaydc.h> |
24 #include <txtetext.h> |
26 #include <txtetext.h> |
25 #include <w32std.h> |
27 #include <w32std.h> |
26 #include "TGraphicsContext.h" |
28 |
27 #include "tcustomcharmapping.h" |
29 namespace LocalToFile |
28 |
|
29 namespace LocalToTCustomCharMapping |
|
30 { |
30 { |
|
31 |
|
32 _LIT(KTCustomCharMapping, "TCustomCharMapping"); |
|
33 const TInt KDisplayWidth = 202; |
|
34 const TInt KDisplayHeight = 100; |
|
35 const TInt KPictureCharacter = 0xFFFC; |
|
36 RTest test(KTCustomCharMapping); |
|
37 |
|
38 enum TTestNum |
|
39 { |
|
40 EDefaultBehaviourInvisible = 0, |
|
41 EDefaultBehaviourVisible = 1, |
|
42 ECustomRemappingInvisible = 2, |
|
43 ECustomRemappingVisible = 3, |
|
44 ENewTest = 4 //Test remapping with no custom remapper and some flags explicitly set to invisible |
|
45 }; |
|
46 |
|
47 |
31 class CPinkSquare : public CPicture |
48 class CPinkSquare : public CPicture |
32 { |
49 { |
33 public: |
50 public: |
34 // Size of square in twips. |
51 // Size of square in twips. |
35 // 600 is 15 pixels using the standard test graphics device at |
52 // 600 is 15 pixels using the standard test graphics device at |
246 |
263 |
247 CCustomRemapper::CCustomRemapper() |
264 CCustomRemapper::CCustomRemapper() |
248 { |
265 { |
249 } |
266 } |
250 |
267 |
251 void CTCustomCharMappingStep::DoTestL(TDes& aText, CTextLayout* /*aLayout*/, CTestGraphicsDevice* aDevice, CTextView* aView, TTestNum aTestNum) |
268 void DoTestL(TDes& aText, CTextLayout* /*aLayout*/, CTestGraphicsDevice* aDevice, CTextView* aView, TTestNum aTestNum) |
252 { |
269 { |
253 aText = KTestStrings[aTestNum][0]; |
270 aText = KTestStrings[aTestNum][0]; |
254 aDevice->LineArray().ResetLineArray(); |
271 aDevice->LineArray().ResetLineArray(); |
255 aView->HandleGlobalChangeL(); |
272 aView->HandleGlobalChangeL(); |
256 const TTestGCDisplayLine* line1 = &(aDevice->LineArray().Line(0)); |
273 const TTestGCDisplayLine* line1 = &(aDevice->LineArray().Line(0)); |
257 const TTestGCDisplayLine* line2 = aDevice->LineArray().Find(KTestStrings[aTestNum][1]); |
274 const TTestGCDisplayLine* line2 = aDevice->LineArray().Find(KTestStrings[aTestNum][1]); |
258 TEST(0 != line1); |
275 test(0 != line1); |
259 TEST(0 != line2); |
276 test(0 != line2); |
260 // Can't always do a direct comparison of lines because same string |
277 // Can't always do a direct comparison of lines because same string |
261 // may appear in more than one line, so compare contents |
278 // may appear in more than one line, so compare contents |
262 TEST(line1->iLineData.Compare(line2->iLineData) == 0); |
279 test(line1->iLineData.Compare(line2->iLineData) == 0); |
263 } |
280 } |
264 |
281 |
265 |
282 |
266 /** |
283 /** |
267 @SYMTestCaseID SYSLIB-FORM-CT-0147 |
284 @SYMTestCaseID SYSLIB-FORM-CT-0147 |
269 @SYMTestPriority High |
286 @SYMTestPriority High |
270 @SYMTestActions Test installation and deinstallation of custom remapper |
287 @SYMTestActions Test installation and deinstallation of custom remapper |
271 @SYMTestExpectedResults The test must not fail. |
288 @SYMTestExpectedResults The test must not fail. |
272 @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable |
289 @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable |
273 */ |
290 */ |
274 void CTCustomCharMappingStep::RunInstallationTestsL() |
291 void RunInstallationTestsL() |
275 { |
292 { |
276 // Note: If you need to move these heap checks any further "in" to focus |
293 // Note: If you need to move these heap checks any further "in" to focus |
277 // on a specific test then you will have to move all the setup code in as |
294 // on a specific test then you will have to move all the setup code in as |
278 // well - and still preserve the two different display widths in use |
295 // well - and still preserve the two different display widths in use |
279 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0147 ")); |
296 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0147 ")); |
280 __UHEAP_MARK; |
297 __UHEAP_MARK; |
281 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
298 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
282 CleanupStack::PushL(scheduler); |
299 CleanupStack::PushL(scheduler); |
283 CActiveScheduler::Install(scheduler); |
300 CActiveScheduler::Install(scheduler); |
284 TBuf<100> text; |
301 TBuf<100> text; |
298 |
315 |
299 // OK, let's get down to testing |
316 // OK, let's get down to testing |
300 MFormCustomInvisibleCharacterRemapper* remapper; |
317 MFormCustomInvisibleCharacterRemapper* remapper; |
301 // read what the ptr is set to - check it is null |
318 // read what the ptr is set to - check it is null |
302 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
319 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
303 INFO_PRINTF1(_L("Test uninstalled")); |
320 test.Next(_L("Test uninstalled")); |
304 TEST(remapper == NULL); |
321 test(remapper == NULL); |
305 |
322 |
306 // install a custom remapper - get the ptr - check it is set |
323 // install a custom remapper - get the ptr - check it is set |
307 MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL(); |
324 MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL(); |
308 layout->SetCustomInvisibleCharacterRemapper(customRemapper); |
325 layout->SetCustomInvisibleCharacterRemapper(customRemapper); |
309 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
326 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
310 INFO_PRINTF1(_L("Test installed")); |
327 test.Next(_L("Test installed")); |
311 TEST(remapper == customRemapper); |
328 test(remapper == customRemapper); |
312 |
329 |
313 // set the ptr back to null (deinstall) - get the ptr - check it is null |
330 // set the ptr back to null (deinstall) - get the ptr - check it is null |
314 layout->SetCustomInvisibleCharacterRemapper(NULL); |
331 layout->SetCustomInvisibleCharacterRemapper(NULL); |
315 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
332 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
316 INFO_PRINTF1(_L("Test uninstalled again")); |
333 test.Next(_L("Test uninstalled again")); |
317 TEST(remapper == NULL); |
334 test(remapper == NULL); |
318 |
335 |
319 delete customRemapper; |
336 delete customRemapper; |
320 |
337 |
321 CleanupStack::PopAndDestroy(offScreenContext); |
338 CleanupStack::PopAndDestroy(offScreenContext); |
322 CleanupStack::PopAndDestroy(view); |
339 CleanupStack::PopAndDestroy(view); |
333 @SYMTestPriority High |
350 @SYMTestPriority High |
334 @SYMTestActions Test behaviour without custom remapper installed |
351 @SYMTestActions Test behaviour without custom remapper installed |
335 @SYMTestExpectedResults The test must not fail. |
352 @SYMTestExpectedResults The test must not fail. |
336 @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable |
353 @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable |
337 */ |
354 */ |
338 void CTCustomCharMappingStep::RunDefaultBehaviourTestsL() |
355 void RunDefaultBehaviourTestsL() |
339 { |
356 { |
340 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0148 ")); |
357 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0148 ")); |
341 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
358 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
342 CleanupStack::PushL(scheduler); |
359 CleanupStack::PushL(scheduler); |
343 CActiveScheduler::Install(scheduler); |
360 CActiveScheduler::Install(scheduler); |
344 TBuf<100> text; |
361 TBuf<100> text; |
345 TDocModel docModel(text); |
362 TDocModel docModel(text); |
357 CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext); |
374 CTestTextView::SetContextForFlickerFreeRedraw(view, offScreenContext); |
358 |
375 |
359 // Start by making sure no custom remapper is installed |
376 // Start by making sure no custom remapper is installed |
360 MFormCustomInvisibleCharacterRemapper* remapper; |
377 MFormCustomInvisibleCharacterRemapper* remapper; |
361 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
378 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
362 TEST(remapper == NULL); |
379 test(remapper == NULL); |
363 |
380 |
364 // Set all invisible characters to be invisible |
381 // Set all invisible characters to be invisible |
365 TNonPrintingCharVisibility visibility; |
382 TNonPrintingCharVisibility visibility; |
366 visibility.SetNoneVisible(); |
383 visibility.SetNoneVisible(); |
367 layout->SetNonPrintingCharsVisibility(visibility); |
384 layout->SetNonPrintingCharsVisibility(visibility); |
368 |
385 |
369 // Test remapping with no custom remapper and flags set to invisible |
386 // Test remapping with no custom remapper and flags set to invisible |
370 INFO_PRINTF1(_L("Test uninstalled behaviour - flags invisible")); |
387 test.Next(_L("Test uninstalled behaviour - flags invisible")); |
371 DoTestL(text, layout, device, view, EDefaultBehaviourInvisible); |
388 DoTestL(text, layout, device, view, EDefaultBehaviourInvisible); |
372 |
389 |
373 // Now set all invisible characters to be visible |
390 // Now set all invisible characters to be visible |
374 visibility.SetAllVisible(); |
391 visibility.SetAllVisible(); |
375 layout->SetNonPrintingCharsVisibility(visibility); |
392 layout->SetNonPrintingCharsVisibility(visibility); |
376 |
393 |
377 // Test remapping with no custom remapper and flags set to visible |
394 // Test remapping with no custom remapper and flags set to visible |
378 INFO_PRINTF1(_L("Test uninstalled behaviour - flags visible")); |
395 test.Next(_L("Test uninstalled behaviour - flags visible")); |
379 DoTestL(text, layout, device, view, EDefaultBehaviourVisible); |
396 DoTestL(text, layout, device, view, EDefaultBehaviourVisible); |
380 |
397 |
381 // Test remapping with no custom remapper and some flags explicitly set to invisible |
398 // Test remapping with no custom remapper and some flags explicitly set to invisible |
382 INFO_PRINTF1(_L("Test uninstalled behaviour - some flags invisible")); |
399 test.Next(_L("Test uninstalled behaviour - some flags invisible")); |
383 //Set all invisible characters to be visible |
400 //Set all invisible characters to be visible |
384 visibility.SetAllVisible(); |
401 visibility.SetAllVisible(); |
385 //Set some attributes explicitly to be invisible |
402 //Set some attributes explicitly to be invisible |
386 visibility.SetSpacesVisible(EFalse); |
403 visibility.SetSpacesVisible(EFalse); |
387 visibility.SetTabsVisible(EFalse); |
404 visibility.SetTabsVisible(EFalse); |
409 @SYMTestPriority High |
426 @SYMTestPriority High |
410 @SYMTestActions Test behaviour with custom remapper installed |
427 @SYMTestActions Test behaviour with custom remapper installed |
411 @SYMTestExpectedResults The test must not fail. |
428 @SYMTestExpectedResults The test must not fail. |
412 @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable |
429 @SYMPREQ 1128 Placeholders for invisible characers in rich text shall be customizable |
413 */ |
430 */ |
414 void CTCustomCharMappingStep::RunCustomBehaviourTestsL() |
431 void RunCustomBehaviourTestsL() |
415 { |
432 { |
416 // Note: If you need to move these heap checks any further "in" to focus |
433 // Note: If you need to move these heap checks any further "in" to focus |
417 // on a specific test then you will have to move all the setup code in as |
434 // on a specific test then you will have to move all the setup code in as |
418 // well - and still preserve the two different display widths in use |
435 // well - and still preserve the two different display widths in use |
419 INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0149 ")); |
436 test.Next(_L(" @SYMTestCaseID:SYSLIB-FORM-CT-0149 ")); |
420 __UHEAP_MARK; |
437 __UHEAP_MARK; |
421 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
438 CActiveScheduler* scheduler = new(ELeave) CActiveScheduler; |
422 CleanupStack::PushL(scheduler); |
439 CleanupStack::PushL(scheduler); |
423 CActiveScheduler::Install(scheduler); |
440 CActiveScheduler::Install(scheduler); |
424 TBuf<100> text; |
441 TBuf<100> text; |
439 // We need to install a custom remapper |
456 // We need to install a custom remapper |
440 MFormCustomInvisibleCharacterRemapper* remapper; |
457 MFormCustomInvisibleCharacterRemapper* remapper; |
441 MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL(); |
458 MFormCustomInvisibleCharacterRemapper* customRemapper = CCustomRemapper::NewL(); |
442 layout->SetCustomInvisibleCharacterRemapper(customRemapper); |
459 layout->SetCustomInvisibleCharacterRemapper(customRemapper); |
443 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
460 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
444 TEST(remapper == customRemapper); |
461 test(remapper == customRemapper); |
445 |
462 |
446 // Set all invisible characters to be invisible |
463 // Set all invisible characters to be invisible |
447 TNonPrintingCharVisibility visibility; |
464 TNonPrintingCharVisibility visibility; |
448 visibility.SetNoneVisible(); |
465 visibility.SetNoneVisible(); |
449 layout->SetNonPrintingCharsVisibility(visibility); |
466 layout->SetNonPrintingCharsVisibility(visibility); |
450 |
467 |
451 // Test remapping with custom remapper and flags set to invisible |
468 // Test remapping with custom remapper and flags set to invisible |
452 INFO_PRINTF1(_L("Test installed behaviour - flags invisible")); |
469 test.Next(_L("Test installed behaviour - flags invisible")); |
453 DoTestL(text, layout, device, view, ECustomRemappingInvisible); |
470 DoTestL(text, layout, device, view, ECustomRemappingInvisible); |
454 |
471 |
455 // Now set all invisible characters to be visible |
472 // Now set all invisible characters to be visible |
456 visibility.SetAllVisible(); |
473 visibility.SetAllVisible(); |
457 layout->SetNonPrintingCharsVisibility(visibility); |
474 layout->SetNonPrintingCharsVisibility(visibility); |
458 |
475 |
459 // Test remapping with custom remapper and flags set to visible |
476 // Test remapping with custom remapper and flags set to visible |
460 INFO_PRINTF1(_L("Test installed behaviour - flags visible")); |
477 test.Next(_L("Test installed behaviour - flags visible")); |
461 DoTestL(text, layout, device, view, ECustomRemappingVisible); |
478 DoTestL(text, layout, device, view, ECustomRemappingVisible); |
462 |
479 |
463 // Now we are finished deinstall and delete it |
480 // Now we are finished deinstall and delete it |
464 layout->SetCustomInvisibleCharacterRemapper(NULL); |
481 layout->SetCustomInvisibleCharacterRemapper(NULL); |
465 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
482 remapper = layout->GetCustomInvisibleCharacterRemapper(); |
466 TEST(remapper == NULL); |
483 test(remapper == NULL); |
467 delete customRemapper; |
484 delete customRemapper; |
468 |
485 |
469 CleanupStack::PopAndDestroy(offScreenContext); |
486 CleanupStack::PopAndDestroy(offScreenContext); |
470 CleanupStack::PopAndDestroy(view); |
487 CleanupStack::PopAndDestroy(view); |
471 CleanupStack::PopAndDestroy(device); |
488 CleanupStack::PopAndDestroy(device); |
472 CleanupStack::PopAndDestroy(layout); |
489 CleanupStack::PopAndDestroy(layout); |
473 CleanupStack::PopAndDestroy(scheduler); |
490 CleanupStack::PopAndDestroy(scheduler); |
474 __UHEAP_MARKEND; |
491 __UHEAP_MARKEND; |
475 } |
492 } |
476 |
493 |
477 CTCustomCharMappingStep::CTCustomCharMappingStep() |
494 |
478 { |
495 TInt E32Main() |
479 |
496 { |
480 } |
497 __UHEAP_MARK; |
481 |
498 test.Title(); |
482 TVerdict CTCustomCharMappingStep::doTestStepL() |
499 static CTrapCleanup* TrapCleanup = CTrapCleanup::New(); |
483 { |
500 test.Start(_L("Test installation/deinstallatiion")); |
484 SetTestStepResult(EPass); |
501 TInt error = RFbsSession::Connect(); |
485 INFO_PRINTF1(_L("Test installation/deinstallatiion")); |
502 if (error == KErrNotFound) |
486 TInt error = RFbsSession::Connect(); |
503 { |
487 if (error == KErrNotFound) |
504 FbsStartup(); |
488 { |
505 error = RFbsSession::Connect(); |
489 FbsStartup(); |
506 } |
490 error = RFbsSession::Connect(); |
507 test(error == KErrNone); |
491 } |
508 TRAP(error, RunInstallationTestsL()); |
492 TEST(error == KErrNone); |
509 test(error == KErrNone); |
493 TRAP(error, RunInstallationTestsL()); |
510 test.Next(_L("Test uninstalled behaviour")); |
494 TEST(error == KErrNone); |
511 TRAP(error, RunDefaultBehaviourTestsL()); |
495 INFO_PRINTF1(_L("Test uninstalled behaviour")); |
512 test(error == KErrNone); |
496 TRAP(error, RunDefaultBehaviourTestsL()); |
513 test.Next(_L("Test behaviour with custom remapper installed")); |
497 TEST(error == KErrNone); |
514 TRAP(error, RunCustomBehaviourTestsL()); |
498 INFO_PRINTF1(_L("Test behaviour with custom remapper installed")); |
515 test(error == KErrNone); |
499 TRAP(error, RunCustomBehaviourTestsL()); |
516 RFbsSession::Disconnect(); |
500 TEST(error == KErrNone); |
517 test.End(); |
501 RFbsSession::Disconnect(); |
518 delete TrapCleanup; |
502 return TestStepResult(); |
519 test.Close(); |
503 } |
520 __UHEAP_MARKEND; |
|
521 User::Heap().Check(); |
|
522 return error; |
|
523 } |
|
524 |
|
525 |
|
526 #if defined(__WINS__) |
|
527 EXPORT_C TInt EntryPoint(TAny*) {return E32Main();} |
|
528 #endif |
|
529 |