lafagnosticuifoundation/cone/tef/TConeHelpTextStep.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2006-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 //#include <coemain.h>
       
    23 //#include <bautils.h>
       
    24 //#include <apacmdln.h> 
       
    25 //#include <fbs.h>
       
    26 //#include <imageconversion.h>
       
    27 //#include <bitmaptransforms.h>
       
    28 #include <coehelp.h>
       
    29 #include "TConeHelpTextStep.h"
       
    30 
       
    31 
       
    32 
       
    33 /**
       
    34   Single Argument Constructor for CConeHelpTextTestAppUi class.\n
       
    35 */
       
    36 CConeHelpTextTestAppUi::CConeHelpTextTestAppUi(CTmsTestStep* aStep) :
       
    37 CTestCoeAppUi(aStep)
       
    38 {}
       
    39 /**
       
    40   Destructor for CConeHelpTextTestAppUi class.\n
       
    41 */
       
    42 CConeHelpTextTestAppUi::~CConeHelpTextTestAppUi()
       
    43 {}
       
    44 
       
    45 /**
       
    46   Second phase Constructor for CConeHelpTextTestAppUi class.\n
       
    47   Invokes the base class CTestCoeAppUi second phase constructor.\n
       
    48   Executes the testcases asynchronously using Autotest Manager.\n
       
    49 */
       
    50 void CConeHelpTextTestAppUi::ConstructL()
       
    51 	{
       
    52 	CTestCoeAppUi::ConstructL();
       
    53 	
       
    54 	AutoTestManager().StartAutoTest();
       
    55 	}
       
    56 
       
    57 /**
       
    58    @SYMTestCaseID		    UIF-CONE-0016
       
    59 
       
    60    @SYMTestCaseDesc 	    Test TCoeHelpContext::IsNull() returns ETrue when TCoeHelpContext
       
    61    							has Null values, and false otherwise.
       
    62   
       
    63    @SYMTestPriority   	    Critical
       
    64    
       
    65    @SYMTestType				Unit Test
       
    66   
       
    67    @SYMTestStatus 	  	    Implemented
       
    68     
       
    69    @SYMTestActions  	    Create null TCoeHelpContext (using default constructor)
       
    70    							Test IsNull() returns true
       
    71    							Set iMajor to non null value
       
    72    							Test IsNull() returns false
       
    73    							Set iMajor back to null
       
    74    							Set iContext to null
       
    75    							Test IsNull() returns false
       
    76    
       
    77    @SYMTestExpectedResults  IsNull returns false when either iMajor or iContext is non
       
    78    							null, and true if both are null.
       
    79  */
       
    80 void CConeHelpTextTestAppUi::TestCase01()
       
    81 	{
       
    82 	INFO_PRINTF1(_L("UIF-CONE-0016 - test case start"));
       
    83 	TCoeHelpContext help;
       
    84 
       
    85 	INFO_PRINTF1(_L("Test IsNull() returns ETrue when default constructor is used."));
       
    86 	TBool ret = help.IsNull();
       
    87 	TEST(ret!=EFalse);
       
    88 
       
    89 	INFO_PRINTF1(_L("Test IsNull() returns EFalse when uid has been set."));
       
    90 	TUid testUid(TUid::Uid(0x12345678));
       
    91 	help.iMajor = testUid;
       
    92 	ret = help.IsNull();
       
    93 	TEST(ret==EFalse);
       
    94 
       
    95 	INFO_PRINTF1(_L("Test IsNull() returns EFalse when context has been set."));
       
    96 	help.iMajor = KNullUid;
       
    97 	_LIT(KTestContext,"Test Context");
       
    98 	TBuf<12> testContext(KTestContext);
       
    99 	help.iContext = testContext;
       
   100 	ret = help.IsNull();
       
   101 	TEST(ret==EFalse);
       
   102 	INFO_PRINTF1(_L("UIF-CONE-0016 - test case end"));
       
   103 	}
       
   104 
       
   105 /**
       
   106    @SYMTestCaseID		    UIF-CONE-0017
       
   107 
       
   108    @SYMTestCaseDesc 	    Test TCoeHelpContext(TUid aMajor,const TDesC& aContext) constructor
       
   109    							sets the member variables correctly.
       
   110   
       
   111    @SYMTestPriority   	    Critical
       
   112    
       
   113    @SYMTestType				Unit Test
       
   114   
       
   115    @SYMTestStatus 	  	    Implemented
       
   116     
       
   117    @SYMTestActions  	    Call the constructor with aMajor set to a uid of 0x12345678 and
       
   118    							aContext to "Test Context"
       
   119    
       
   120    @SYMTestExpectedResults  Check iMajor has been set to 0x12345678 and iContext has been
       
   121    							set to "Test Context"
       
   122  */
       
   123 void CConeHelpTextTestAppUi::TestCase02()
       
   124 	{
       
   125 	INFO_PRINTF1(_L("UIF-CONE-0017 - test case start"));
       
   126 	TUid testUid(TUid::Uid(0x12345678));
       
   127 	_LIT(KTestContext,"Test Context");
       
   128 	TBuf<12> testContext(KTestContext);
       
   129 	TCoeHelpContext help(testUid, testContext);
       
   130 	INFO_PRINTF1(_L("Test the constructor set the member variables"));
       
   131 	TEST(help.iMajor==testUid);
       
   132 	TEST(help.iContext==testContext);
       
   133 	INFO_PRINTF1(_L("UIF-CONE-0017 - test case end"));
       
   134 	}
       
   135 
       
   136 /**
       
   137    @SYMTestCaseID		    UIF-CONE-0018
       
   138 
       
   139    @SYMTestCaseDesc 	    Test TCoeHelpContext operator== reports true when two
       
   140    							TCoeHelpContexts are identical, and false otherwise.
       
   141   
       
   142    @SYMTestPriority   	    Critical
       
   143    
       
   144    @SYMTestType				Unit Test
       
   145   
       
   146    @SYMTestStatus 	  	    Implemented
       
   147     
       
   148    @SYMTestActions  	    Create two identical TCoeHelpContext with Major set to
       
   149    							0x12345678, and Contest set to "Test Context"
       
   150    							Compare using ==
       
   151    							Set iMajor to KNullUid
       
   152    							Compare
       
   153    							Set iMajor back to 0x12345678
       
   154    							Set iContext to KNullDesC
       
   155    							Compare
       
   156    							Set iMajor and iContext to null
       
   157    							Compare
       
   158    
       
   159    @SYMTestExpectedResults  Operator== returns true when both Contexts are identical, and
       
   160    							false otherwise
       
   161  */
       
   162 void CConeHelpTextTestAppUi::TestCase03()
       
   163 	{
       
   164 	INFO_PRINTF1(_L("UIF-CONE-0018 - test case start"));
       
   165 	TUid testUid(TUid::Uid(0x12345678));
       
   166 	_LIT(KTestContext,"Test Context");
       
   167 	TBuf<12> testContext(KTestContext);
       
   168 	TCoeHelpContext help1(testUid, testContext);
       
   169 	TCoeHelpContext help2(testUid, testContext);
       
   170 	INFO_PRINTF1(_L("Test operator== returns true when both help contexts are the same"));
       
   171 	TEST(help1==help2);
       
   172 	help1.iMajor=KNullUid;
       
   173 	INFO_PRINTF1(_L("Test operator== returns false when iMajor is different"));
       
   174 	TEST((help1==help2)==EFalse);
       
   175 	help1.iMajor=testUid;
       
   176 	TEST(help1==help2);
       
   177 	help1.iContext=KNullDesC;
       
   178 	INFO_PRINTF1(_L("Test operator== returns false when iContext is different"));
       
   179 	TEST((help1==help2)==EFalse);
       
   180 	help1.iMajor=KNullUid;
       
   181 	INFO_PRINTF1(_L("Test operator== returns false when both iMajor and iContext is different"));
       
   182 	TEST((help1==help2)==EFalse);
       
   183 	INFO_PRINTF1(_L("UIF-CONE-0018 - test case end"));
       
   184 	}
       
   185 
       
   186 /**
       
   187    @SYMTestCaseID		    UIF-CONE-0019
       
   188 
       
   189    @SYMTestCaseDesc 	    Test TCoeHelpContext operator!= reports false when two
       
   190    							TCoeHelpContexts are identical, and true otherwise.
       
   191   
       
   192    @SYMTestPriority   	    Critical
       
   193    
       
   194    @SYMTestType				Unit Test
       
   195   
       
   196    @SYMTestStatus 	  	    Implemented
       
   197     
       
   198    @SYMTestActions  	    Create two identical TCoeHelpContext with Major set to
       
   199    							0x12345678, and Contest set to "Test Context"
       
   200    							Compare using !=
       
   201    							Set iMajor to KNullUid
       
   202    							Compare
       
   203    							Set iMajor back to 0x12345678
       
   204    							Set iContext to KNullDesC
       
   205    							Compare
       
   206    							Set iMajor and iContext to null
       
   207    							Compare
       
   208    
       
   209    @SYMTestExpectedResults  Operator!= returns false when both Contexts are identical, and
       
   210    							true otherwise
       
   211  */
       
   212 void CConeHelpTextTestAppUi::TestCase04()
       
   213 	{
       
   214 	INFO_PRINTF1(_L("UIF-CONE-0019 - test case start"));
       
   215 	TUid testUid(TUid::Uid(0x12345678));
       
   216 	_LIT(KTestContext,"Test Context");
       
   217 	TBuf<12> testContext(KTestContext);
       
   218 	TCoeHelpContext help1(testUid, testContext);
       
   219 	TCoeHelpContext help2(testUid, testContext);
       
   220 	INFO_PRINTF1(_L("Test operator!= returns false when both help contexts are the same"));
       
   221 	TEST((help1!=help2)==EFalse);
       
   222 	help1.iMajor=KNullUid;
       
   223 	INFO_PRINTF1(_L("Test operator!= returns true when iMajor is different"));
       
   224 	TEST(help1!=help2);
       
   225 	help1.iMajor=testUid;
       
   226 	TEST(help1==help2);
       
   227 	help1.iContext=KNullDesC;
       
   228 	INFO_PRINTF1(_L("Test operator!= returns true when iContext is different"));
       
   229 	TEST(help1!=help2);
       
   230 	help1.iMajor=KNullUid;
       
   231 	INFO_PRINTF1(_L("Test operator!= returns true when both iMajor and iContext is different"));
       
   232 	TEST(help1!=help2);
       
   233 	INFO_PRINTF1(_L("UIF-CONE-0019 - test case end"));
       
   234 	}
       
   235 
       
   236 
       
   237 /**
       
   238    Auxiliary Function for all Test Cases.\n
       
   239   
       
   240    The method is an override from CTestCoeAppUi.\n
       
   241    This function is called asynchronously by RunL function of the
       
   242    AutotestManager after previous test case is executed.\n
       
   243    Generates the KeyDown event and KeyUp Events alternatively.\n
       
   244  */
       
   245  
       
   246 void CConeHelpTextTestAppUi::RunTestStepL(TInt aStepNum)
       
   247 	{
       
   248 	switch(aStepNum)
       
   249 		{
       
   250 		case 1:
       
   251 			SetTestStepID(_L("UIF-CONE-0016"));
       
   252 			TestCase01();	
       
   253 			RecordTestResultL();
       
   254 			break;
       
   255 		case 2:
       
   256 			SetTestStepID(_L("UIF-CONE-0017"));
       
   257 			TestCase02();	
       
   258 			RecordTestResultL();
       
   259 			break;
       
   260 		case 3:
       
   261 			SetTestStepID(_L("UIF-CONE-0018"));
       
   262 			TestCase03();
       
   263 			RecordTestResultL();
       
   264 			break;
       
   265 		case 4:
       
   266 			SetTestStepID(_L("UIF-CONE-0019"));
       
   267 			TestCase04();
       
   268 			RecordTestResultL();
       
   269 			CloseTMSGraphicsStep();
       
   270 			break;
       
   271 		default:
       
   272 			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
   273 			break;
       
   274 		}
       
   275 	}
       
   276 
       
   277 /**
       
   278   Completes the construction of the Control Environment(CCoeEnv object).\n
       
   279   Instantiates the CConeHelpTextTestAppUi class which serves as a AppUi class.\n
       
   280   Sets the CConeHelpTextTestAppUi object as the application's user interface object.\n
       
   281   Invokes the second phase constructor of the application's UI.\n
       
   282 */
       
   283 void CTConeHelpTextStep::ConstructAppL(CCoeEnv* aCoe)
       
   284 	{ // runs inside a TRAP harness
       
   285 	aCoe->ConstructL();
       
   286 	CConeHelpTextTestAppUi* appUi= new (ELeave) CConeHelpTextTestAppUi(this);
       
   287 	aCoe->SetAppUi(appUi);
       
   288 	appUi->ConstructL();
       
   289 	}
       
   290 /**
       
   291   Constructor for CTConeHelpTextStep class.\n
       
   292   Sets the test step name.\n
       
   293 */
       
   294 CTConeHelpTextStep::CTConeHelpTextStep()
       
   295 	{
       
   296 	SetTestStepName(KTConeHelpTextStep);
       
   297 	}
       
   298 /**
       
   299   Destructor for CTConeHelpTextStep class.\n
       
   300 */
       
   301 CTConeHelpTextStep::~CTConeHelpTextStep()
       
   302 {}
       
   303 
       
   304 /**
       
   305   Entry function for CTCone0 Test Step.\n
       
   306   Sets up the control environment.\n
       
   307   Constructs and Launches the CTCone0 Test application.\n
       
   308  
       
   309 */
       
   310 TVerdict CTConeHelpTextStep::doTestStepL() // main function called by E32
       
   311 	{
       
   312 	INFO_PRINTF1(_L("Test Started"));
       
   313 	
       
   314 	PreallocateHALBuffer();
       
   315 
       
   316 	__UHEAP_MARK;
       
   317 
       
   318 	CCoeEnv* coe=new(ELeave) CCoeEnv;
       
   319 	TRAPD(err,ConstructAppL(coe));
       
   320 
       
   321 	if (!err)
       
   322 		coe->ExecuteD();
       
   323 	else
       
   324 		{
       
   325 		SetTestStepResult(EFail);
       
   326 		delete coe;
       
   327 		}
       
   328 
       
   329 	REComSession::FinalClose();	
       
   330 
       
   331 	__UHEAP_MARKEND;
       
   332 
       
   333 	INFO_PRINTF1(_L("Test Finished"));
       
   334 	return TestStepResult();
       
   335 	}
       
   336 
       
   337