commonuisupport/uikon/test/tfocus/T_FocusStep.CPP
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2005-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 // Tests border drawing using border colour & style.\n
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent - Internal Symbian test code
       
    21 */
       
    22 #include <e32keys.h>
       
    23 #include <basched.h>
       
    24 #include <gdi.h>
       
    25 #include <gulutil.h>
       
    26 #include <gulbordr.h>
       
    27 #include <coecntrl.h>
       
    28 #include <coeutils.h>
       
    29 #include <eikenv.h>
       
    30 #include <eikappui.h>
       
    31 #include <eikdef.h>
       
    32 #include <eikdoc.h>
       
    33 #include <eikapp.h>
       
    34 #include <ecom/ecom.h>
       
    35 
       
    36 
       
    37 #include "T_FocusStep.h"
       
    38 
       
    39 /**
       
    40    Destructor
       
    41  */
       
    42 CSimpleFocusControl::~CSimpleFocusControl()
       
    43 	{
       
    44 	}
       
    45 
       
    46 
       
    47 /**
       
    48    Auxiliary function for all Test Cases
       
    49   
       
    50    This method creates the user interface control on which tests are carried
       
    51    out.
       
    52    
       
    53  */
       
    54 void CSimpleFocusControl::ConstructL()
       
    55     {
       
    56     CreateWindowL();
       
    57     SetExtentToWholeScreen();
       
    58     ActivateL();
       
    59 	}
       
    60 
       
    61 
       
    62 /**
       
    63    Auxilliary function for all Test Cases
       
    64   
       
    65    This method is an override from CCoeControl. It is used to handle key
       
    66    events for the control.
       
    67   
       
    68  */
       
    69 TKeyResponse CSimpleFocusControl::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode aType)
       
    70     {
       
    71     if (aType!=EEventKey)
       
    72         return(EKeyWasNotConsumed);
       
    73         
       
    74     return(EKeyWasConsumed);
       
    75     }
       
    76 
       
    77 /**
       
    78    Auxiliary function for all Test Cases
       
    79   
       
    80    This method prepares the test step's user interface and prepares it
       
    81    to start the tests. As part of user interface it creates a control
       
    82    on which the tests are carried out.
       
    83    
       
    84  */
       
    85 void CSimpleFocusAppUi::ConstructL()
       
    86     {
       
    87     //BaseConstructL(ENoAppResourceFile);
       
    88 	CTestCoeAppUi::ConstructL();
       
    89     
       
    90 	iSimpleFocusControl=new(ELeave) CSimpleFocusControl;
       
    91     iSimpleFocusControl->ConstructL();
       
    92     AddToStackL(iSimpleFocusControl);
       
    93  
       
    94 	AutoTestManager().StartAutoTest();
       
    95    }
       
    96 
       
    97 CSimpleFocusAppUi::~CSimpleFocusAppUi()
       
    98 /**
       
    99    Destructor
       
   100  */
       
   101 	{
       
   102 	RemoveFromStack(iSimpleFocusControl);
       
   103     delete iSimpleFocusControl;
       
   104 	}
       
   105 
       
   106 /**
       
   107    Auxiliary function for all Test Cases
       
   108   
       
   109    The method is an override from CTestAppUi. The method initiates border
       
   110    drawing tests.
       
   111    
       
   112  */
       
   113 void CSimpleFocusAppUi::RunTestStepL(TInt aNextStep)
       
   114 	{
       
   115 	switch(aNextStep)
       
   116 		{
       
   117 		case 1:	
       
   118 			{
       
   119 			INFO_PRINTF1(_L("Test focus"));
       
   120 			TBool isNonFocusing = iSimpleFocusControl->IsNonFocusing();
       
   121 			TEST(!isNonFocusing);
       
   122 			if (isNonFocusing)
       
   123 				{
       
   124 				INFO_PRINTF1(_L("IsNonFocusing() returned ETrue, EFalse expected"));
       
   125 				}
       
   126 			}
       
   127 			break;
       
   128 		case 2:
       
   129 			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
   130 			break;
       
   131 		default:
       
   132 			break;
       
   133 		}
       
   134 	}
       
   135 
       
   136 //----------
       
   137 
       
   138 CTestFocusStep::CTestFocusStep()
       
   139 /**
       
   140    Constructor
       
   141  */
       
   142 	{
       
   143 	SetTestStepName(KTestFocusStep);
       
   144 	}
       
   145 	
       
   146 	
       
   147 
       
   148 CTestFocusStep::~CTestFocusStep()
       
   149 /**
       
   150    Destructor
       
   151  */
       
   152 	{
       
   153 	}
       
   154 
       
   155 /**
       
   156    Auxiliary function for all Test Cases
       
   157   
       
   158    The method creates & sets the application's user interface object.
       
   159    
       
   160  */
       
   161 void CTestFocusStep::ConstructAppL(CEikonEnv* aCoe)
       
   162     { // runs inside a TRAP harness
       
   163 	aCoe->ConstructL();
       
   164 
       
   165 	CSimpleFocusAppUi* appUi= new (ELeave) CSimpleFocusAppUi(this);
       
   166     aCoe->SetAppUi(appUi);
       
   167     appUi->ConstructL();
       
   168     }
       
   169 
       
   170 /**
       
   171    Auxiliary function for all Test Cases
       
   172   
       
   173    The method creates & sets the test step's user interface object and
       
   174    launches the test step.
       
   175    
       
   176  */
       
   177 TVerdict CTestFocusStep::doTestStepL() // main function called by E32
       
   178 	{
       
   179 	PreallocateHALBuffer();
       
   180 	__UHEAP_MARK;
       
   181 
       
   182 	CEikonEnv* coe=new CEikonEnv;
       
   183 	TRAPD(err,ConstructAppL(coe));
       
   184 
       
   185 	if (!err)
       
   186 		coe->ExecuteD();
       
   187 
       
   188 	REComSession::FinalClose();	
       
   189 	__UHEAP_MARKEND;
       
   190 
       
   191 	return TestStepResult();
       
   192 	}
       
   193 
       
   194 
       
   195 
       
   196 
       
   197