os/graphics/windowing/windowserver/test/tauto/TPointer.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent - Internal Symbian test code
sl@0
    20
*/
sl@0
    21
sl@0
    22
#ifndef __TPOINTER_H__
sl@0
    23
#define __TPOINTER_H__
sl@0
    24
sl@0
    25
#include <e32std.h>
sl@0
    26
#include <w32std.h>
sl@0
    27
#include <hal.h>
sl@0
    28
#include "../tlib/testbase.h"
sl@0
    29
#include "AUTO.H"
sl@0
    30
#include "TGraphicsHarness.h"
sl@0
    31
sl@0
    32
class CTPointer;
sl@0
    33
class CGrabWindow;
sl@0
    34
sl@0
    35
class CPointerWindow : public CTWin
sl@0
    36
	{
sl@0
    37
	enum {KRepeatMargin=200000};	// 0.2 Seconds
sl@0
    38
	enum {KRepeatCount=4};
sl@0
    39
	enum {KRepeatIntervalIncrements=100000};
sl@0
    40
	enum {KRepeatRectXExtra=50};
sl@0
    41
	enum {KRepeatRectYExtra=50};
sl@0
    42
	enum {KStateWaitingForTest1,KStateFailed,KStateTesting1,
sl@0
    43
			KStateWaitingForTest2,KStateTesting2,
sl@0
    44
			KStateWaitingForTest3,KStateTesting3,
sl@0
    45
			KStateWaitingForTest4,KStateTesting4,
sl@0
    46
			KStateWaitingForTest5,KStateTesting5,
sl@0
    47
			KStateWaitingForTest6,KStateTesting6,
sl@0
    48
			KStateWaitingForTest8,KStateTesting8,
sl@0
    49
			KStateWaitingForTest7,KStateTesting7,
sl@0
    50
			KStateFinished};
sl@0
    51
public:
sl@0
    52
	CPointerWindow(CTPointer *aTest);
sl@0
    53
	void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
sl@0
    54
	void Draw();
sl@0
    55
	void StartNextRepeatTest();
sl@0
    56
	void QueueNextRepeat();
sl@0
    57
	void PointerL(const TPointerEvent &aPointer,const TTime&);
sl@0
    58
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
    59
private:
sl@0
    60
	void SwitchOn(const TTime &);
sl@0
    61
	void ResetTest(TInt aState);
sl@0
    62
	void SetState(TInt aState);
sl@0
    63
	void FinishedTests();
sl@0
    64
	void TestFailed(TBool aRetest=EFalse);
sl@0
    65
	void SendEvent();
sl@0
    66
private:
sl@0
    67
	CTPointer *iTest;
sl@0
    68
	TInt iRepeatCount;
sl@0
    69
	TInt iState;
sl@0
    70
	TTimeIntervalMicroSeconds32 iInterval;
sl@0
    71
	TTime iPrevTime;
sl@0
    72
	TRect iRepeatRect;
sl@0
    73
	TPoint iTl;
sl@0
    74
	TSize iSize;
sl@0
    75
	};
sl@0
    76
sl@0
    77
class CGrabWindow2 : public CTWin
sl@0
    78
	{
sl@0
    79
public:
sl@0
    80
	CGrabWindow2(CGrabWindow *aWindow);
sl@0
    81
	void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
sl@0
    82
private:
sl@0
    83
	void Draw();
sl@0
    84
	void PointerL(const TPointerEvent &aPointer,const TTime&);
sl@0
    85
private:
sl@0
    86
	CGrabWindow *iGrabWindow;
sl@0
    87
	};
sl@0
    88
sl@0
    89
class CGrabWindow : public CTWin
sl@0
    90
	{
sl@0
    91
	enum {KGrabStateWaitingForDown,KGrabStateWaitingForDragOut,KGrabStateWaitingForUp,KGrabStateFinished,
sl@0
    92
		KGrabStateWaitingForDown2,KGrabStateWaitingForUp2a,KGrabStateWaitingForDrag2,KGrabStateWaitingForUp2b,
sl@0
    93
		KGrabStateWaitingForDown3,KGrabStateWaitingForUp3a,KGrabStateWaitingForUp3b,
sl@0
    94
		KGrabStateWaitingForDown4,KGrabStateWaitingForUp4,
sl@0
    95
		KGrabStateWaitingForDown5,KGrabStateWaitingForUp5,KGrabStateWaitingForDrag5,
sl@0
    96
		KStateFailed};
sl@0
    97
public:
sl@0
    98
	CGrabWindow(CTPointer *aTest);
sl@0
    99
	void Pointer2(const TPointerEvent &aPointer);
sl@0
   100
	void SetUpLD(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc);
sl@0
   101
	void WinKeyL(const TKeyEvent &aKey,const TTime &aTime);
sl@0
   102
private:
sl@0
   103
	void Draw();
sl@0
   104
	void SetState(TInt aState);
sl@0
   105
	void ResetTest();
sl@0
   106
	void PointerL(const TPointerEvent &aPointer,const TTime&);
sl@0
   107
	void TestFailed();
sl@0
   108
	void FinishedTests();
sl@0
   109
	void SendEvent();
sl@0
   110
private:
sl@0
   111
	TInt iState;
sl@0
   112
	CTPointer *iTest;
sl@0
   113
	TPoint iTl;
sl@0
   114
	TSize iSize;
sl@0
   115
	};
sl@0
   116
sl@0
   117
sl@0
   118
class CTPointer : public CTWsGraphicsBase
sl@0
   119
	{
sl@0
   120
public:
sl@0
   121
	enum {KTimeOutAfter=20000000};	//20secs
sl@0
   122
public:
sl@0
   123
	CTPointer(CTestStep* aStep);
sl@0
   124
	~CTPointer();
sl@0
   125
	void ConstructL();
sl@0
   126
sl@0
   127
	TBool TestFailed(TInt aCase,TBool aRetry=EFalse);
sl@0
   128
	void StartGrabTestL();
sl@0
   129
	static TInt TimeOut(TAny* aTest);
sl@0
   130
	void TimeOut();
sl@0
   131
	CGrabWindow2 *GrabWin2() const;
sl@0
   132
	inline TBool Digitiser() const {return !iNoDigitiser;}
sl@0
   133
	inline void SimulatePointer(TRawEvent::TType aType, TInt aX, TInt aY){iTest->SimulatePointer(aType, aX, aY);}
sl@0
   134
	inline void SimulateEvent(TRawEvent::TType aType){iTest->SimulateEvent(aType);}
sl@0
   135
protected:
sl@0
   136
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
   137
private:
sl@0
   138
	TInt doTestFailedL();
sl@0
   139
	inline TestClient* Client() {return TheClient;}
sl@0
   140
	TInt iState;
sl@0
   141
sl@0
   142
private:
sl@0
   143
	CTimeOut* iTimeOut;
sl@0
   144
	TInt iTimeOutCount;
sl@0
   145
	CPointerWindow *iRepeatWin;
sl@0
   146
	CGrabWindow *iGrabWin;
sl@0
   147
	CGrabWindow2 *iGrabWin2;
sl@0
   148
	TSize iWinSize;
sl@0
   149
	//TInt iState;
sl@0
   150
	TBool iOldPointerState;
sl@0
   151
	TBool iNoDigitiser;
sl@0
   152
	};
sl@0
   153
sl@0
   154
sl@0
   155
class CTPointerStep : public CTGraphicsStep
sl@0
   156
	{
sl@0
   157
public:
sl@0
   158
	CTPointerStep();
sl@0
   159
protected:	
sl@0
   160
	//from CTGraphicsStep
sl@0
   161
	virtual CTGraphicsBase* CreateTestL();
sl@0
   162
	};
sl@0
   163
sl@0
   164
_LIT(KTPointerStep,"TPointer");
sl@0
   165
sl@0
   166
sl@0
   167
#endif