lafagnosticuifoundation/cone/tef/statecon.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2007-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  @internalComponent - Internal Symbian test code
       
    19  @test
       
    20 */
       
    21 
       
    22 #ifndef __STATECON_H__
       
    23 #define __STATECON_H__
       
    24 
       
    25 #include "COECNTRL.H"
       
    26 #include "Coemop.h"
       
    27 
       
    28 _LIT(KFontName,"Arial");
       
    29 
       
    30 class CStepStateObsEnv;
       
    31 
       
    32 
       
    33 class MStatePassOn
       
    34 	{
       
    35 /**
       
    36    An interface which allows a provider of the MCoeControlStateObserver to pass calls to
       
    37    it on to another class.
       
    38  */
       
    39 public:
       
    40 	virtual TInt ControlStateChangePassOn(CCoeControl* aControl,MCoeControlStateObserver::TCoeState aState)=0;
       
    41 	};
       
    42 
       
    43 class CStateObserverControl : public CCoeControl, public MCoeControlStateObserver, public MStatePassOn
       
    44 	{
       
    45 /**
       
    46    A control which implements the Mop framework and provides the MCoeControlStateObserver
       
    47    interface.  It also provides test functions with check if the MCoeControlStateObserver
       
    48    is called or not when it should be or not.
       
    49  */
       
    50 public:
       
    51 	enum TObserver {ENoObserver,EObserver,ECoeEnvObserver};
       
    52 public:
       
    53 	static const TFontSpec iFontSpec;
       
    54 public:
       
    55 	~CStateObserverControl();
       
    56 	void ConstructL();
       
    57 	inline void SetReturnObserver(TObserver aRetObserver) {iRetObserver=aRetObserver;}
       
    58 	void SetRecievers(TBool aControlRecieving,TBool aCoeEnvRecieving);
       
    59 	inline void SetEnv(CStepStateObsEnv* aEnv) {iEnv=aEnv;}
       
    60 	void ResetCount();
       
    61 	TInt DoTest();
       
    62 	//Pure virtual function from MCoeControlStateObserver
       
    63 	TInt HandleControlStateChange(CCoeControl* aControl,MCoeControlStateObserver::TCoeState aState);
       
    64 protected:
       
    65 	//Pure virtual function from MStatePassOn
       
    66 	TInt ControlStateChangePassOn(CCoeControl* aControl,MCoeControlStateObserver::TCoeState aState);
       
    67 	//Pure virtual function from MObjectProvider overridden in CCoeControl
       
    68 	TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
    69 	//Virtual function from CCoeControl
       
    70 	void Draw(const TRect& aRect) const;
       
    71 private:
       
    72 	void inline Flush() {iCoeEnv->WsSession().Flush();}
       
    73 	void DoSetDimmed(TBool aDimmed);
       
    74 	void Failed();
       
    75 	void DoTestStep(MCoeControlStateObserver::TCoeState aStateToChange,TBool aNewState);
       
    76 	void TestFail(TBool aNotGetting,CCoeControl* aControl
       
    77 								,MCoeControlStateObserver::TCoeState aState,TBool& aCalled);
       
    78 private:
       
    79 	TObserver iRetObserver;		//Specifies what interface should be returned by the Mop framework
       
    80 	CFbsFont* iFont;			//Font used to draw to the controls window
       
    81 	CStepStateObsEnv* iEnv;		//A control enviroment which provides the Mop interface MCoeControlStateObserver
       
    82 	TInt iTestNo;				//A test case number count
       
    83 	TInt iLastCalled;			//The test case on which the Mop interface was last called
       
    84 	TInt iFailAt;				//The first test case where there was a test failure
       
    85 	TBool iControlRecieving;	//If this control should recieve events through the Mop interface
       
    86 	TBool iCoeEnvRecieving;		//If the control enviroment should recieve events through the Mop interface
       
    87 	MCoeControlStateObserver::TCoeState iExpectedChange;	//Which state (dimmed or visibility) of the control should have just changed
       
    88 	TBool iNoChange;			//If the lasted State change call on the control caused a real change
       
    89 	TBool iShouldBeVisible;		//If the control should be visible
       
    90 	TBool iShouldBeDimmed;		//If the control should be dimmed
       
    91 	TBool iEnvCalled;			//If the Mop interface through the control has already been called
       
    92 	TBool iCntCalled;			//If the Mop interface through the enviroment has already been called
       
    93 	};
       
    94 
       
    95 #endif	//__STATECON_H__