os/graphics/windowing/windowserver/test/tauto/tmultiptrevent.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) 2008-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 TMULTIPTREVENT_H_
sl@0
    23
#define TMULTIPTREVENT_H_
sl@0
    24
sl@0
    25
#include <e32std.h>
sl@0
    26
#include <e32cmn.h>
sl@0
    27
#include "w32std.h"
sl@0
    28
#include "../tlib/testbase.h"
sl@0
    29
#include "AUTO.H"
sl@0
    30
#include "AUTODLL.H"
sl@0
    31
#include "../TClick/multiptrclick.h"
sl@0
    32
#include "TGraphicsHarness.h"
sl@0
    33
sl@0
    34
class CTMultiPtrEventTest;
sl@0
    35
class CTMultiPtrEventClient;
sl@0
    36
sl@0
    37
/*
sl@0
    38
 * CTEvent derived class which acts as eventhandler and eventbuffer 
sl@0
    39
 * Stores the events in buffer, which is used for comparing events received from wserv.
sl@0
    40
 */ 
sl@0
    41
class CTMultiPtrEventBuffer : public CTEvent
sl@0
    42
	{
sl@0
    43
	enum {EEventBufferSize=40, EMovePtsBuffer=10};
sl@0
    44
public:
sl@0
    45
	CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient);
sl@0
    46
	void ConstructL();
sl@0
    47
	void AddExpectedEvent(TWsEvent &aEvent);
sl@0
    48
	void AddExpectedMovePtEvent(TPoint &aMovePt);
sl@0
    49
	TInt EventsRemaining();
sl@0
    50
	void SetEventCount(TInt aCount) {iEventCount = aCount;}
sl@0
    51
	void SetNestedLoopState(TBool aLoopStart) {iNestedLoopStarted = aLoopStart;}
sl@0
    52
	TBool NestedLoopState() {return iNestedLoopStarted;}
sl@0
    53
	void GetMoveBufferAndCompareL();
sl@0
    54
protected:
sl@0
    55
	// Pure virtual from CTEventBase
sl@0
    56
	void doRunL();
sl@0
    57
private:
sl@0
    58
	void TestL(TInt aTest);
sl@0
    59
	void TestL(TInt aTest, TInt aVal1, TInt aVal2,const char *oper, const char *aTestStr, 
sl@0
    60
	           const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine);
sl@0
    61
    void TestL(TInt aTest, TPoint aVal1, TPoint aVal2,const char *oper, const char *aTestStr, 
sl@0
    62
               const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine);
sl@0
    63
private:
sl@0
    64
	CCirBuf<TWsEvent> iEventBuffer;
sl@0
    65
	CCirBuf<TPoint> iMovePtsBuffer;
sl@0
    66
	CTMultiPtrEventTest* iTest;
sl@0
    67
	TInt iEventCount;
sl@0
    68
	CTMultiPtrEventClient* iClient;
sl@0
    69
	TBool iNestedLoopStarted;
sl@0
    70
	};
sl@0
    71
sl@0
    72
sl@0
    73
/* 
sl@0
    74
 * CTClient derived class which gives Wserv client environment 
sl@0
    75
 * i,e iWs, iScreen, iGc, iGroup, iEventHandler etc...
sl@0
    76
 * Owns CTMultiPtrEventBuffer and stores in iEventhandler of its base class
sl@0
    77
 * Accepts the event from test class and passes them on to buffer class
sl@0
    78
 */ 
sl@0
    79
class CTMultiPtrEventClient : public CTClient
sl@0
    80
	{
sl@0
    81
public:
sl@0
    82
	CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient = EFalse);
sl@0
    83
	~CTMultiPtrEventClient();
sl@0
    84
	void ConstructL();
sl@0
    85
	
sl@0
    86
	inline CTBlankWindow* ParentWin() { return iParentWin; }
sl@0
    87
	inline CTBlankWindow* ChildWin() { return iChildWin; }
sl@0
    88
	inline CTMultiPtrEventBuffer* EventBuffer() {return static_cast<CTMultiPtrEventBuffer*>(iEventHandler);}
sl@0
    89
	inline void SetExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=ETrue;};
sl@0
    90
	inline void ClearExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=EFalse;};
sl@0
    91
sl@0
    92
	TBool IsSecondaryClient() {return iSecondaryClient;}
sl@0
    93
	
sl@0
    94
	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0);
sl@0
    95
	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0);
sl@0
    96
	void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0);
sl@0
    97
	void AddExpectedMovePoint(TPoint aPos);
sl@0
    98
	void CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle);
sl@0
    99
	void ConstructGroupBlankWinL();
sl@0
   100
	void DeleteGroupBlankWin();
sl@0
   101
	TBool CheckOrdinalPosition(TInt aWinAutoFocus1);
sl@0
   102
	
sl@0
   103
	// Virtual from CTClient
sl@0
   104
	void ConstructEventHandlerL();
sl@0
   105
	
sl@0
   106
private:
sl@0
   107
	CTMultiPtrEventTest* iTest;
sl@0
   108
	TSize iParentWinSize;
sl@0
   109
	TPoint iParentWinPos;
sl@0
   110
	TSize iChildWinSize;
sl@0
   111
	TPoint iChildWinPos;
sl@0
   112
	CTBlankWindow* iParentWin;
sl@0
   113
	CTBlankWindow* iChildWin;
sl@0
   114
sl@0
   115
	TBool iSecondaryClient;
sl@0
   116
	
sl@0
   117
	// For AutoFocus test
sl@0
   118
	CTWindowGroup* iGroupWinAutoFocus1;
sl@0
   119
	CTWindowGroup* iGroupWinAutoFocus2;
sl@0
   120
	CTBlankWindow* iWinAutoFocus1;
sl@0
   121
	CTBlankWindow* iWinAutoFocus2;
sl@0
   122
	
sl@0
   123
	TSize iWinSizeAutoFocus1;
sl@0
   124
	TPoint iWinPosAutoFocus1;
sl@0
   125
	TSize iWinSizeAutoFocus2;
sl@0
   126
	TPoint iWinPosAutoFocus2;
sl@0
   127
	TBool iExpectNonAdvancedPointerEvents;
sl@0
   128
	};
sl@0
   129
sl@0
   130
class RMultiPointerAnim : public RTestAnim
sl@0
   131
	{
sl@0
   132
public:
sl@0
   133
	static RMultiPointerAnim* NewL(RWindowBase* aWin, RAnimDll* aDll);
sl@0
   134
	RMultiPointerAnim(RAnimDll* aDll) :RTestAnim(*aDll) {}
sl@0
   135
	TInt AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TBool aEat = ETrue);
sl@0
   136
	};
sl@0
   137
sl@0
   138
/*
sl@0
   139
 * CTWsGraphicsBase derived class which implements RunTestCaseL pure virtual.
sl@0
   140
 * Runs all the testcases for multi poniter events.
sl@0
   141
 * For each test case it creates CTMultiPtrEventClient object and creates a nested activescheduler
sl@0
   142
 * Calls NextSetOfEventsL() which in turn calls respective tests depending upong the testcase number
sl@0
   143
 * For each test simulates the events and adds the same event to CTMultiPtrEventBuffer
sl@0
   144
 * When all the tests for a particular testcase completes stops activescheduler
sl@0
   145
 * Repeats the same for all testcases
sl@0
   146
 */ 
sl@0
   147
class CTMultiPtrEventTest : public CTWsGraphicsBase
sl@0
   148
	{
sl@0
   149
public:
sl@0
   150
	CTMultiPtrEventTest(CTestStep* aStep);
sl@0
   151
	~CTMultiPtrEventTest();
sl@0
   152
	void ConstructL();
sl@0
   153
	void NextSetOfEventsL();
sl@0
   154
	void Failed();
sl@0
   155
	
sl@0
   156
	// Functions for simulating events, which use UserSvr::AddEvent
sl@0
   157
	void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber);
sl@0
   158
	void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber);
sl@0
   159
	void SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber);
sl@0
   160
	
sl@0
   161
	// Functions for adding event, calls the client's AddExpectedPointer
sl@0
   162
	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0);
sl@0
   163
	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0, TBool aSecondaryClient = EFalse);
sl@0
   164
	void AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber);
sl@0
   165
	void AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient = EFalse, TInt aPointerNumber = 0, TUint aHandle = 0);
sl@0
   166
	void AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0);
sl@0
   167
	void AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle);
sl@0
   168
	
sl@0
   169
	void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/);
sl@0
   170
	void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0);	
sl@0
   171
	
sl@0
   172
	// Supplementary function for tests
sl@0
   173
	void TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber);
sl@0
   174
	void SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos);
sl@0
   175
	void TestAndDisplayAnimError();
sl@0
   176
	void GetRemainingEventsFromSecondaryClient();
sl@0
   177
	void TestAndDisplayPtrClickError();
sl@0
   178
	void CreatePointerClickPluginL();
sl@0
   179
	void SetAutoFlush();
sl@0
   180
	void ResetFlushStopAS();
sl@0
   181
	void TestFilteringForMultiPointer(TBool aFiltering);
sl@0
   182
	void TestGrabbingForMultiPointer(TBool aGrabbing);
sl@0
   183
	void CreateGroupWinL();
sl@0
   184
	void DeleteGroupWin();
sl@0
   185
	void CreateGroupWinForCapturingL();
sl@0
   186
	void DeleteGroupWinForCapturing();
sl@0
   187
	void CreateAnimDllAndAnimL();
sl@0
   188
	void DestroyAnimDllAndAnim();
sl@0
   189
	void TestCloseProximityHighPressureAPIsL();
sl@0
   190
	void TestCapturingForMultiPointer(TBool aAllGroups);
sl@0
   191
	void SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres);
sl@0
   192
	void NegativeTestingOfProximityPressureAPIsL();
sl@0
   193
	void TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode);
sl@0
   194
	void SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue);
sl@0
   195
	void SetDefaultScreenMode();
sl@0
   196
	TPoint GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation);
sl@0
   197
	void LogEventsAdded();
sl@0
   198
	
sl@0
   199
	// All tests
sl@0
   200
	void MultiPointerEvents();
sl@0
   201
	void PurgingMultiPointerEvents();
sl@0
   202
	void MultiPointerEventsForAnimsL();
sl@0
   203
	void MultiClientMultiPointerEvents();
sl@0
   204
	void MultiPointerEventsForPointerClickL();
sl@0
   205
	void MultiPointerEventsInDiffScreenModes();
sl@0
   206
	void FilteringMultiPointerEvents();
sl@0
   207
	void GrabbingMultiPointerEvents();
sl@0
   208
	void VirtualKeyBoardForMultiplePointers();
sl@0
   209
	void DoubleClickForMultiplePointers();
sl@0
   210
	void MultiPointerOutOfRangeEvents();
sl@0
   211
	void AutoForeGroundForMultiplePointersL();
sl@0
   212
	void EmulationRulesForMultiplePointers();
sl@0
   213
    void CloseProximityAndHighPressureEventsL();
sl@0
   214
	void OutOfBoundValueTesting();
sl@0
   215
	void CapturingMultiPointerEvents();
sl@0
   216
	void NegativeTestsForProximityPressureEventsL();
sl@0
   217
	void PointerRepeatEventForMultiplePointers();
sl@0
   218
	void SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse);
sl@0
   219
	void ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse);
sl@0
   220
	
sl@0
   221
protected:
sl@0
   222
	void RunTestCaseL(TInt aCurTestCase);
sl@0
   223
private:
sl@0
   224
	void RunTestsL();
sl@0
   225
private:
sl@0
   226
	TInt iEventSet;			// Set of events for one particular test case
sl@0
   227
	TBool iFailed;
sl@0
   228
	TBool iActiveSchedulerStarted;
sl@0
   229
	TBool iTheClientFlush;
sl@0
   230
	TBool iClientFlush;
sl@0
   231
	TBool iSecClientFlush;
sl@0
   232
	TSize iPhysicalScreenSize;
sl@0
   233
	TRect iOrigPtrCursorArea;
sl@0
   234
	
sl@0
   235
	TUint iPointerNumber;
sl@0
   236
	TInt iMaxDevPointers;
sl@0
   237
	TInt iMaxUiPointers;
sl@0
   238
	TInt iMaxPressure;
sl@0
   239
	TInt iPressureStep;
sl@0
   240
	TInt iMaxProximity;
sl@0
   241
	TInt iProximityStep;
sl@0
   242
sl@0
   243
	TInt iEnterCloseProximityThreshold;
sl@0
   244
	TInt iExitCloseProximityThreshold;
sl@0
   245
	TInt iEnterHighPressureThreshold;
sl@0
   246
	TInt iExitHighPressureThreshold;	
sl@0
   247
	 
sl@0
   248
	CTMultiPtrEventClient *iMultiPtrEventClient;
sl@0
   249
	CTMultiPtrEventClient *iSecMultiPtrEventClient;
sl@0
   250
	
sl@0
   251
	RAnimDll* iAnimDll;
sl@0
   252
	RMultiPointerAnim* iAnim;
sl@0
   253
	
sl@0
   254
	RSoundPlugIn iClick;
sl@0
   255
	TBool iPtrPluginLoaded;
sl@0
   256
	RChunk iChunk;
sl@0
   257
	RHeap* iHeap;
sl@0
   258
	TAny* iErrDesc;
sl@0
   259
	
sl@0
   260
	TInt iCurrentScreenMode;
sl@0
   261
	TBool iChangeScreenMode;
sl@0
   262
	
sl@0
   263
	CTWindowGroup* iGroupWinForEmul;
sl@0
   264
	CTBlankWindow* iWinForEmul;
sl@0
   265
	
sl@0
   266
	CTWindowGroup* iGroupWinForCapturing;
sl@0
   267
	CTBlankWindow* iWinForCapturing;
sl@0
   268
	
sl@0
   269
	TInt iYOffset;
sl@0
   270
	};
sl@0
   271
sl@0
   272
class CTMultiPtrEventTestStep : public CTGraphicsStep
sl@0
   273
	{
sl@0
   274
public:
sl@0
   275
	CTMultiPtrEventTestStep();
sl@0
   276
protected:
sl@0
   277
	//from CTGraphicsStep
sl@0
   278
	virtual CTGraphicsBase* CreateTestL();
sl@0
   279
	};
sl@0
   280
sl@0
   281
_LIT(KTMultiPtrEventTestStep, "TMultiPtrEventTest");
sl@0
   282
sl@0
   283
#endif /*TMULTIPTREVENT_H_*/