os/graphics/windowing/windowserver/test/tauto/TPointer.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TPointer.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,167 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code
    1.23 +*/
    1.24 +
    1.25 +#ifndef __TPOINTER_H__
    1.26 +#define __TPOINTER_H__
    1.27 +
    1.28 +#include <e32std.h>
    1.29 +#include <w32std.h>
    1.30 +#include <hal.h>
    1.31 +#include "../tlib/testbase.h"
    1.32 +#include "AUTO.H"
    1.33 +#include "TGraphicsHarness.h"
    1.34 +
    1.35 +class CTPointer;
    1.36 +class CGrabWindow;
    1.37 +
    1.38 +class CPointerWindow : public CTWin
    1.39 +	{
    1.40 +	enum {KRepeatMargin=200000};	// 0.2 Seconds
    1.41 +	enum {KRepeatCount=4};
    1.42 +	enum {KRepeatIntervalIncrements=100000};
    1.43 +	enum {KRepeatRectXExtra=50};
    1.44 +	enum {KRepeatRectYExtra=50};
    1.45 +	enum {KStateWaitingForTest1,KStateFailed,KStateTesting1,
    1.46 +			KStateWaitingForTest2,KStateTesting2,
    1.47 +			KStateWaitingForTest3,KStateTesting3,
    1.48 +			KStateWaitingForTest4,KStateTesting4,
    1.49 +			KStateWaitingForTest5,KStateTesting5,
    1.50 +			KStateWaitingForTest6,KStateTesting6,
    1.51 +			KStateWaitingForTest8,KStateTesting8,
    1.52 +			KStateWaitingForTest7,KStateTesting7,
    1.53 +			KStateFinished};
    1.54 +public:
    1.55 +	CPointerWindow(CTPointer *aTest);
    1.56 +	void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
    1.57 +	void Draw();
    1.58 +	void StartNextRepeatTest();
    1.59 +	void QueueNextRepeat();
    1.60 +	void PointerL(const TPointerEvent &aPointer,const TTime&);
    1.61 +	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
    1.62 +private:
    1.63 +	void SwitchOn(const TTime &);
    1.64 +	void ResetTest(TInt aState);
    1.65 +	void SetState(TInt aState);
    1.66 +	void FinishedTests();
    1.67 +	void TestFailed(TBool aRetest=EFalse);
    1.68 +	void SendEvent();
    1.69 +private:
    1.70 +	CTPointer *iTest;
    1.71 +	TInt iRepeatCount;
    1.72 +	TInt iState;
    1.73 +	TTimeIntervalMicroSeconds32 iInterval;
    1.74 +	TTime iPrevTime;
    1.75 +	TRect iRepeatRect;
    1.76 +	TPoint iTl;
    1.77 +	TSize iSize;
    1.78 +	};
    1.79 +
    1.80 +class CGrabWindow2 : public CTWin
    1.81 +	{
    1.82 +public:
    1.83 +	CGrabWindow2(CGrabWindow *aWindow);
    1.84 +	void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
    1.85 +private:
    1.86 +	void Draw();
    1.87 +	void PointerL(const TPointerEvent &aPointer,const TTime&);
    1.88 +private:
    1.89 +	CGrabWindow *iGrabWindow;
    1.90 +	};
    1.91 +
    1.92 +class CGrabWindow : public CTWin
    1.93 +	{
    1.94 +	enum {KGrabStateWaitingForDown,KGrabStateWaitingForDragOut,KGrabStateWaitingForUp,KGrabStateFinished,
    1.95 +		KGrabStateWaitingForDown2,KGrabStateWaitingForUp2a,KGrabStateWaitingForDrag2,KGrabStateWaitingForUp2b,
    1.96 +		KGrabStateWaitingForDown3,KGrabStateWaitingForUp3a,KGrabStateWaitingForUp3b,
    1.97 +		KGrabStateWaitingForDown4,KGrabStateWaitingForUp4,
    1.98 +		KGrabStateWaitingForDown5,KGrabStateWaitingForUp5,KGrabStateWaitingForDrag5,
    1.99 +		KStateFailed};
   1.100 +public:
   1.101 +	CGrabWindow(CTPointer *aTest);
   1.102 +	void Pointer2(const TPointerEvent &aPointer);
   1.103 +	void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
   1.104 +	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
   1.105 +private:
   1.106 +	void Draw();
   1.107 +	void SetState(TInt aState);
   1.108 +	void ResetTest();
   1.109 +	void PointerL(const TPointerEvent &aPointer,const TTime&);
   1.110 +	void TestFailed();
   1.111 +	void FinishedTests();
   1.112 +	void SendEvent();
   1.113 +private:
   1.114 +	TInt iState;
   1.115 +	CTPointer *iTest;
   1.116 +	TPoint iTl;
   1.117 +	TSize iSize;
   1.118 +	};
   1.119 +
   1.120 +
   1.121 +class CTPointer : public CTWsGraphicsBase
   1.122 +	{
   1.123 +public:
   1.124 +	enum {KTimeOutAfter=20000000};	//20secs
   1.125 +public:
   1.126 +	CTPointer(CTestStep* aStep);
   1.127 +	~CTPointer();
   1.128 +	void ConstructL();
   1.129 +
   1.130 +	TBool TestFailed(TInt aCase,TBool aRetry=EFalse);
   1.131 +	void StartGrabTestL();
   1.132 +	static TInt TimeOut(TAny* aTest);
   1.133 +	void TimeOut();
   1.134 +	CGrabWindow2 *GrabWin2() const;
   1.135 +	inline TBool Digitiser() const {return !iNoDigitiser;}
   1.136 +	inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY){iTest->SimulatePointer(aType, aX, aY);}
   1.137 +	inline void SimulateEvent(TRawEvent::TType aType){iTest->SimulateEvent(aType);}
   1.138 +protected:
   1.139 +	virtual void RunTestCaseL(TInt aCurTestCase);
   1.140 +private:
   1.141 +	TInt doTestFailedL();
   1.142 +	inline TestClient* Client() {return TheClient;}
   1.143 +	TInt iState;
   1.144 +
   1.145 +private:
   1.146 +	CTimeOut* iTimeOut;
   1.147 +	TInt iTimeOutCount;
   1.148 +	CPointerWindow *iRepeatWin;
   1.149 +	CGrabWindow *iGrabWin;
   1.150 +	CGrabWindow2 *iGrabWin2;
   1.151 +	TSize iWinSize;
   1.152 +	//TInt iState;
   1.153 +	TBool iOldPointerState;
   1.154 +	TBool iNoDigitiser;
   1.155 +	};
   1.156 +
   1.157 +
   1.158 +class CTPointerStep : public CTGraphicsStep
   1.159 +	{
   1.160 +public:
   1.161 +	CTPointerStep();
   1.162 +protected:	
   1.163 +	//from CTGraphicsStep
   1.164 +	virtual CTGraphicsBase* CreateTestL();
   1.165 +	};
   1.166 +
   1.167 +_LIT(KTPointerStep,"TPointer");
   1.168 +
   1.169 +
   1.170 +#endif