47 /** |
47 /** |
48 Second phase constructor for component control "CTestCone2".\n |
48 Second phase constructor for component control "CTestCone2".\n |
49 Creates a control's window.\n |
49 Creates a control's window.\n |
50 The created window is the child of the application's window group.\n |
50 The created window is the child of the application's window group.\n |
51 iDisplayed is set to ETrue to make the control visible.\n |
51 iDisplayed is set to ETrue to make the control visible.\n |
52 */ |
52 */ |
53 void CTestCone2Control::ConstructL() |
53 void CTestCone2Control::ConstructL() |
54 { |
54 { |
55 CreateWindowL(); |
55 CreateWindowL(); |
56 iDisplayed = ETrue; |
56 iDisplayed = ETrue; |
57 } |
57 } |
|
58 /** |
|
59 Function to give access to the CCoeControl's protected CreateWindowL function. |
|
60 This is intended for use only with Low Memory tests. |
|
61 */ |
|
62 TInt CTestCone2Control::CreateWindow() |
|
63 { |
|
64 TRAPD(err,CreateWindowL()); |
|
65 return err; |
|
66 } |
58 /** |
67 /** |
59 Sets this control as visible or invisible.\n |
68 Sets this control as visible or invisible.\n |
60 This causes the control to disappear or reappear.\n |
69 This causes the control to disappear or reappear.\n |
61 When a control is created, it is made visible by default.\n |
70 When a control is created, it is made visible by default.\n |
62 */ |
71 */ |
63 void CTestCone2Control::MakeVisible(TBool aVisible) |
72 void CTestCone2Control::MakeVisible(TBool aVisible) |
64 { |
73 { |
65 iDisplayed = aVisible; |
74 iDisplayed = aVisible; |
66 DrawNow(); |
75 DrawNow(); |
67 } |
76 } |
68 /** |
77 /** |
69 Destructor for the container control.\n |
78 Destructor for the container control.\n |
70 Deletes the component control "CTestCone2Control".\n |
79 Deletes the component control "CTestCone2Control".\n |
71 */ |
80 */ |
72 CTestContainerControl::~CTestContainerControl() |
81 CTestContainerControl::~CTestContainerControl() |
622 |
631 |
623 @SYMTestExpectedResults. The code tests the MaximumWidth property is initially 0, and that it can be set |
632 @SYMTestExpectedResults. The code tests the MaximumWidth property is initially 0, and that it can be set |
624 and retrieved correctly. |
633 and retrieved correctly. |
625 |
634 |
626 */ |
635 */ |
627 |
|
628 void CTestDriver::TestSetandGetCCoeControlAPIsL() |
636 void CTestDriver::TestSetandGetCCoeControlAPIsL() |
629 { |
637 { |
630 // Create a new CCoeControl object |
638 // Create a new CCoeControl object |
631 CCoeControl* testCtrl = new (ELeave) CCoeControl(); |
639 CCoeControl* testCtrl = new (ELeave) CCoeControl(); |
632 CleanupStack::PushL(testCtrl); |
640 CleanupStack::PushL(testCtrl); |
633 |
641 |
634 // Part 1: Check that a default value of 0 is returned when no |
642 // Part 1: Check that a default value of 0 is returned when no |
635 // max width value has been set yet. |
643 // max width value has been set yet. |
636 iStep->TEST(testCtrl->MaximumWidth() == 0); |
644 iStep->TEST(testCtrl->MaximumWidth() == 0); |
637 |
645 |
638 // Part 2: Set the maximum width to a new value. |
646 // Part 2: Set the maximum width to a new value. |
639 TInt newMaxWidth = 5; |
647 TInt newMaxWidth = 5; |
640 iStep->TEST(testCtrl->SetMaximumWidth(newMaxWidth) == KErrNone); |
648 iStep->TEST(testCtrl->SetMaximumWidth(newMaxWidth) == KErrNone); |
641 |
649 |
642 // Part 3: Access maximum width. Test that it equals the |
650 // Part 3: Access maximum width. Test that it equals the |
643 // value previously set. |
651 // value previously set. |
644 iStep->TEST(testCtrl->MaximumWidth() == newMaxWidth); |
652 iStep->TEST(testCtrl->MaximumWidth() == newMaxWidth); |
645 |
653 |
646 CleanupStack::PopAndDestroy(testCtrl); |
654 CleanupStack::PopAndDestroy(testCtrl); |
|
655 } |
|
656 |
|
657 /** |
|
658 @SYMTestCaseID UIF-TCone2Step-TestSetandGetCCoeControlAPIsL |
|
659 |
|
660 @SYMDEF ou1cimx1#261261 |
|
661 |
|
662 @SYMTestCaseDesc Tests creating a CCoeControl in low memory conditions. |
|
663 In particular it tries to trip up the RCoeDynamicDataStorage mechanism. |
|
664 |
|
665 @SYMTestPriority High |
|
666 |
|
667 @SYMTestStatus Implemented |
|
668 |
|
669 @SYMTestActions The test creates a CCoeControl object in an OOM loop with different burst values. |
|
670 And sets and reads back a property that is stored in the DynamicDataStoreage. |
|
671 Note: This test didn't actually suceed in producing the crash reported in the defect. |
|
672 I couldn't see anyway to get to the crashing line with things in a bad state. |
|
673 |
|
674 @SYMTestExpectedResults. The code doesn't crash. |
|
675 */ |
|
676 void CTestDriver::TestLowMemoryCoeControl() |
|
677 { |
|
678 CCoeControl* const parentVal=NULL; |
|
679 CTestCone2Control* cnt; |
|
680 CCoeControl* parent; |
|
681 TInt burst; |
|
682 TInt failRate; |
|
683 TInt sucesses; |
|
684 TBool sucess=EFalse; |
|
685 TInt setErr; |
|
686 TInt creErr; |
|
687 for (burst=1;burst<15;++burst) |
|
688 { |
|
689 failRate=burst>1 ? 1:0; |
|
690 sucesses=0; |
|
691 do { |
|
692 cnt=NULL; |
|
693 parent=reinterpret_cast<CCoeControl*>(KMaxTUint); |
|
694 setErr=99; |
|
695 creErr=99; |
|
696 __UHEAP_BURSTFAILNEXT(failRate,burst); |
|
697 __UHEAP_MARK; |
|
698 cnt=new CTestCone2Control(); |
|
699 if (cnt) |
|
700 { |
|
701 setErr=cnt->SetParent(parentVal); |
|
702 parent=cnt->Parent(); |
|
703 creErr=cnt->CreateWindow(); |
|
704 if (parent==parentVal && setErr==KErrNone && creErr==KErrNone) |
|
705 sucess=ETrue; |
|
706 delete cnt; |
|
707 } |
|
708 __UHEAP_MARKEND; |
|
709 __UHEAP_RESET; |
|
710 if (sucess) |
|
711 { |
|
712 ++sucesses; |
|
713 sucess=EFalse; |
|
714 } |
|
715 else |
|
716 sucesses=0; |
|
717 //Useful logging to see more details of what this code does |
|
718 //INFO_PRINTF7(_L("FR=% 2d S=% 2d C=0x%x SE=%d WCE=%d PAR=0x%x"),failRate,sucesses,cnt,setErr,creErr,parent); |
|
719 ++failRate; |
|
720 } while (sucesses<10); |
|
721 } |
647 } |
722 } |
648 |
723 |
649 /** |
724 /** |
650 Single Argument Constructor for CCone2TestAppUi class.\n |
725 Single Argument Constructor for CCone2TestAppUi class.\n |
651 */ |
726 */ |
691 6. TestColorUseAPIsL |
766 6. TestColorUseAPIsL |
692 7. TestConeAppUiSimpleAndMiscAPIsL |
767 7. TestConeAppUiSimpleAndMiscAPIsL |
693 8. TestConeInputCapabilitiesAPIs |
768 8. TestConeInputCapabilitiesAPIs |
694 9. TestSetAndGetSystemDefaultViewAPIsL |
769 9. TestSetAndGetSystemDefaultViewAPIsL |
695 10. TestSetandGetCCoeControlAPIsL |
770 10. TestSetandGetCCoeControlAPIsL |
|
771 11. TestLowMemoryCoeControl |
696 */ |
772 */ |
697 |
773 |
698 void CCone2TestAppUi::RunTestStepL(TInt aStepNum) |
774 void CCone2TestAppUi::RunTestStepL(TInt aStepNum) |
699 { |
775 { |
|
776 _LIT(KTest11Name,"UIF-TCone2Step-LowMemoryCoeControlConstruction"); |
|
777 _LIT(KTest11Desc,"Test creating CCoeControl in low memory"); |
|
778 _LIT(KReturn,"...completed with return value '%d'\n"); |
|
779 _LIT(KFinished,"Test Finished\n"); |
|
780 TInt ret; |
700 |
781 |
701 switch(aStepNum) |
782 switch(aStepNum) |
702 { |
783 { |
703 case 1: |
784 case 1: |
704 { |
785 SetTestStepID(_L("UIF-TCone2Step-TestIsDisplayingDialogAndRemoveFromStackAPIsL")); |
705 SetTestStepID(_L("UIF-TCone2Step-TestIsDisplayingDialogAndRemoveFromStackAPIsL")); |
786 INFO_PRINTF1(_L("Test IsDisplayingDialog() and RemoveFromStack() APIs")); |
706 INFO_PRINTF1(_L("Test IsDisplayingDialog() and RemoveFromStack() APIs")); |
787 TRAP(ret,iDriver->TestIsDisplayingDialogAndRemoveFromStackAPIsL()); |
707 TRAPD(ret, iDriver->TestIsDisplayingDialogAndRemoveFromStackAPIsL()); |
788 INFO_PRINTF2(KReturn,ret); |
708 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
789 TEST(ret==KErrNone); |
709 TEST(ret==KErrNone); |
790 RecordTestResultL(); |
710 RecordTestResultL(); |
791 break; |
711 break; |
792 case 2: |
712 } |
793 SetTestStepID(_L("UIF-TCone2Step-TestMakeVisibleOnChildControlsL")); |
713 case 2: |
794 INFO_PRINTF1(_L("Test makevisible on its child controls")); |
714 { |
795 TRAP(ret,iDriver->TestMakeVisibleOnChildControlsL()); |
715 SetTestStepID(_L("UIF-TCone2Step-TestMakeVisibleOnChildControlsL")); |
796 INFO_PRINTF2(KReturn,ret); |
716 INFO_PRINTF1(_L("Test makevisible on its child controls")); |
797 TEST(ret==KErrNone); |
717 TRAPD(ret, iDriver->TestMakeVisibleOnChildControlsL()); |
798 RecordTestResultL(); |
718 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
799 break; |
719 TEST(ret==KErrNone); |
800 case 3: |
720 RecordTestResultL(); |
801 SetTestStepID(_L("UIF-TCone2Step-TestAppHelpContextAPIL")); |
721 break; |
802 INFO_PRINTF1(_L("Test AppHelpContext API")); |
722 } |
803 TRAP(ret,iDriver->TestAppHelpContextAPIL()); |
723 case 3: |
804 INFO_PRINTF2(KReturn,ret); |
724 { |
805 TEST(ret==KErrNone); |
725 SetTestStepID(_L("UIF-TCone2Step-TestAppHelpContextAPIL")); |
806 RecordTestResultL(); |
726 INFO_PRINTF1(_L("Test AppHelpContext API")); |
807 break; |
727 TRAPD(ret, iDriver->TestAppHelpContextAPIL()); |
808 case 4: |
728 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
809 SetTestStepID(_L("UIF-TCone2Step-TestReadResourceAPIsL")); |
729 TEST(ret==KErrNone); |
810 INFO_PRINTF1(_L("Test ReadResource APIs")); |
730 RecordTestResultL(); |
811 TRAP(ret,iDriver->TestReadResourceAPIsL()); |
731 break; |
812 INFO_PRINTF2(KReturn,ret); |
732 } |
813 TEST(ret==KErrNone); |
733 case 4: |
814 RecordTestResultL(); |
734 { |
815 break; |
735 SetTestStepID(_L("UIF-TCone2Step-TestReadResourceAPIsL")); |
816 case 5: |
736 INFO_PRINTF1(_L("Test ReadResource APIs")); |
817 SetTestStepID(_L("UIF-TCone2Step-TestCoeControlAPIsL")); |
737 TRAPD(ret, iDriver->TestReadResourceAPIsL()); |
818 INFO_PRINTF1(_L("Test SetContainerWindow APIs")); |
738 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
819 TRAP(ret,iDriver->TestCoeControlAPIsL()); |
739 TEST(ret==KErrNone); |
820 INFO_PRINTF2(KReturn,ret); |
740 RecordTestResultL(); |
821 TEST(ret==KErrNone); |
741 break; |
822 RecordTestResultL(); |
742 } |
823 break; |
743 case 5: |
824 case 6: |
744 { |
825 SetTestStepID(_L("UIF-TCone2Step-TestColorUseAPIsL")); |
745 SetTestStepID(_L("UIF-TCone2Step-TestCoeControlAPIsL")); |
826 INFO_PRINTF1(_L("Test ColorUse APIs")); |
746 INFO_PRINTF1(_L("Test SetContainerWindow APIs")); |
827 TRAP(ret,iDriver->TestColorUseAPIsL()); |
747 TRAPD(ret, iDriver->TestCoeControlAPIsL()); |
828 INFO_PRINTF2(KReturn,ret); |
748 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
829 TEST(ret==KErrNone); |
749 TEST(ret==KErrNone); |
830 RecordTestResultL(); |
750 RecordTestResultL(); |
831 break; |
751 break; |
832 case 7: |
752 } |
833 SetTestStepID(_L("UIF-TCone2Step-TestConeAppUiSimpleAndMiscAPIsL")); |
753 case 6: |
834 INFO_PRINTF1(_L("Test Cone Misc APIs")); |
754 { |
835 TRAP(ret,iDriver->TestConeMiscAPIsL()); |
755 SetTestStepID(_L("UIF-TCone2Step-TestColorUseAPIsL")); |
836 INFO_PRINTF2(KReturn,ret); |
756 INFO_PRINTF1(_L("Test ColorUse APIs")); |
837 TEST(ret==KErrNone); |
757 TRAPD(ret, iDriver->TestColorUseAPIsL()); |
838 RecordTestResultL(); |
758 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
839 break; |
759 TEST(ret==KErrNone); |
840 case 8: |
760 RecordTestResultL(); |
841 SetTestStepID(_L("UIF-TCone2Step-TestConeInputCapabilitiesAPIs")); |
761 break; |
842 INFO_PRINTF1(_L("Test InputCapabilities APIs")); |
762 } |
843 TRAP(ret,iDriver->TestConeInputCapabilitiesAPIs()); |
763 case 7: |
844 INFO_PRINTF2(KReturn,ret); |
764 { |
845 TEST(ret==KErrNone); |
765 SetTestStepID(_L("UIF-TCone2Step-TestConeAppUiSimpleAndMiscAPIsL")); |
846 RecordTestResultL(); |
766 INFO_PRINTF1(_L("Test Cone Misc APIs")); |
847 break; |
767 TRAPD(ret, iDriver->TestConeMiscAPIsL()); |
848 case 9: |
768 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
849 SetTestStepID(_L("UIF-TCone2Step-TestSetAndGetSystemDefaultViewAPIsL")); |
769 TEST(ret==KErrNone); |
850 INFO_PRINTF1(_L("Test Set and Get system default view APIs")); |
770 RecordTestResultL(); |
851 TRAP(ret,iDriver->TestSetAndGetSystemDefaultViewAPIsL()); |
771 break; |
852 INFO_PRINTF2(KReturn,ret); |
772 } |
853 TEST(ret==KErrNone); |
773 case 8: |
854 RecordTestResultL(); |
774 { |
855 break; |
775 SetTestStepID(_L("UIF-TCone2Step-TestConeInputCapabilitiesAPIs")); |
856 case 10: |
776 INFO_PRINTF1(_L("Test InputCapabilities APIs")); |
857 SetTestStepID(_L("UIF-TCone2Step-TestSetandGetCCoeControlAPIsL")); |
777 TRAPD(ret, iDriver->TestConeInputCapabilitiesAPIs()); |
858 INFO_PRINTF1(_L("Test Set and Get APIs for CCoeControl")); |
778 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
859 TRAP(ret,iDriver->TestSetandGetCCoeControlAPIsL()); |
779 TEST(ret==KErrNone); |
860 INFO_PRINTF2(KReturn,ret); |
780 RecordTestResultL(); |
861 TEST(ret==KErrNone); |
781 break; |
862 RecordTestResultL(); |
782 } |
863 break; |
783 case 9: |
864 case 11: |
784 { |
865 SetTestStepID(KTest11Name); |
785 SetTestStepID(_L("UIF-TCone2Step-TestSetAndGetSystemDefaultViewAPIsL")); |
866 INFO_PRINTF1(KTest11Desc); |
786 INFO_PRINTF1(_L("Test Set and Get system default view APIs")); |
867 iDriver->TestLowMemoryCoeControl(); |
787 TRAPD(ret, iDriver->TestSetAndGetSystemDefaultViewAPIsL()); |
868 INFO_PRINTF1(KFinished); |
788 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
869 RecordTestResultL(); |
789 TEST(ret==KErrNone); |
870 CloseTMSGraphicsStep(); |
790 RecordTestResultL(); |
871 break; |
791 break; |
872 case 12: |
792 } |
873 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
793 case 10: |
874 break; |
794 { |
875 default: |
795 SetTestStepID(_L("UIF-TCone2Step-TestSetandGetCCoeControlAPIsL")); |
876 break; |
796 INFO_PRINTF1(_L("Test Set and Get APIs for CCoeControl")); |
|
797 TRAPD(ret, iDriver->TestSetandGetCCoeControlAPIsL()); |
|
798 INFO_PRINTF2(_L("...completed with return value '%d'\n"), ret); |
|
799 TEST(ret==KErrNone); |
|
800 RecordTestResultL(); |
|
801 CloseTMSGraphicsStep(); |
|
802 break; |
|
803 } |
|
804 case 11: |
|
805 AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass); |
|
806 break; |
|
807 default: |
|
808 break; |
|
809 } |
877 } |
810 |
|
811 } |
878 } |
812 |
879 |
813 /** |
880 /** |
814 Completes the construction of the Control Environment(CCoeEnv object).\n |
881 Completes the construction of the Control Environment(CCoeEnv object).\n |
815 Instantiates the CCone2TestAppUi class which serves as a AppUi class.\n |
882 Instantiates the CCone2TestAppUi class which serves as a AppUi class.\n |