os/graphics/windowing/windowserver/test/tauto/tmultiptrevent.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/tmultiptrevent.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,283 @@
     1.4 +// Copyright (c) 2008-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 TMULTIPTREVENT_H_
    1.26 +#define TMULTIPTREVENT_H_
    1.27 +
    1.28 +#include <e32std.h>
    1.29 +#include <e32cmn.h>
    1.30 +#include "w32std.h"
    1.31 +#include "../tlib/testbase.h"
    1.32 +#include "AUTO.H"
    1.33 +#include "AUTODLL.H"
    1.34 +#include "../TClick/multiptrclick.h"
    1.35 +#include "TGraphicsHarness.h"
    1.36 +
    1.37 +class CTMultiPtrEventTest;
    1.38 +class CTMultiPtrEventClient;
    1.39 +
    1.40 +/*
    1.41 + * CTEvent derived class which acts as eventhandler and eventbuffer 
    1.42 + * Stores the events in buffer, which is used for comparing events received from wserv.
    1.43 + */ 
    1.44 +class CTMultiPtrEventBuffer : public CTEvent
    1.45 +	{
    1.46 +	enum {EEventBufferSize=40, EMovePtsBuffer=10};
    1.47 +public:
    1.48 +	CTMultiPtrEventBuffer(RWsSession *aWs, CTMultiPtrEventTest *aTest, CTMultiPtrEventClient* aClient);
    1.49 +	void ConstructL();
    1.50 +	void AddExpectedEvent(TWsEvent &aEvent);
    1.51 +	void AddExpectedMovePtEvent(TPoint &aMovePt);
    1.52 +	TInt EventsRemaining();
    1.53 +	void SetEventCount(TInt aCount) {iEventCount = aCount;}
    1.54 +	void SetNestedLoopState(TBool aLoopStart) {iNestedLoopStarted = aLoopStart;}
    1.55 +	TBool NestedLoopState() {return iNestedLoopStarted;}
    1.56 +	void GetMoveBufferAndCompareL();
    1.57 +protected:
    1.58 +	// Pure virtual from CTEventBase
    1.59 +	void doRunL();
    1.60 +private:
    1.61 +	void TestL(TInt aTest);
    1.62 +	void TestL(TInt aTest, TInt aVal1, TInt aVal2,const char *oper, const char *aTestStr, 
    1.63 +	           const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine);
    1.64 +    void TestL(TInt aTest, TPoint aVal1, TPoint aVal2,const char *oper, const char *aTestStr, 
    1.65 +               const TWsEvent *aEvent, const TWsEvent *aExpected, const char *aFile, TUint aLine);
    1.66 +private:
    1.67 +	CCirBuf<TWsEvent> iEventBuffer;
    1.68 +	CCirBuf<TPoint> iMovePtsBuffer;
    1.69 +	CTMultiPtrEventTest* iTest;
    1.70 +	TInt iEventCount;
    1.71 +	CTMultiPtrEventClient* iClient;
    1.72 +	TBool iNestedLoopStarted;
    1.73 +	};
    1.74 +
    1.75 +
    1.76 +/* 
    1.77 + * CTClient derived class which gives Wserv client environment 
    1.78 + * i,e iWs, iScreen, iGc, iGroup, iEventHandler etc...
    1.79 + * Owns CTMultiPtrEventBuffer and stores in iEventhandler of its base class
    1.80 + * Accepts the event from test class and passes them on to buffer class
    1.81 + */ 
    1.82 +class CTMultiPtrEventClient : public CTClient
    1.83 +	{
    1.84 +public:
    1.85 +	CTMultiPtrEventClient(CTMultiPtrEventTest *aTest, TBool aSecondaryClient = EFalse);
    1.86 +	~CTMultiPtrEventClient();
    1.87 +	void ConstructL();
    1.88 +	
    1.89 +	inline CTBlankWindow* ParentWin() { return iParentWin; }
    1.90 +	inline CTBlankWindow* ChildWin() { return iChildWin; }
    1.91 +	inline CTMultiPtrEventBuffer* EventBuffer() {return static_cast<CTMultiPtrEventBuffer*>(iEventHandler);}
    1.92 +	inline void SetExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=ETrue;};
    1.93 +	inline void ClearExpectNonAdvancedPointerEvents() {iExpectNonAdvancedPointerEvents=EFalse;};
    1.94 +
    1.95 +	TBool IsSecondaryClient() {return iSecondaryClient;}
    1.96 +	
    1.97 +	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0);
    1.98 +	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0);
    1.99 +	void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0);
   1.100 +	void AddExpectedMovePoint(TPoint aPos);
   1.101 +	void CalculatePtrPosAndSet3Ddata(TWsEvent& aEvent, TPointerEvent::TType aType, TPoint aPos, TUint aModifiers, TInt aZ, TUint8 aPointerNumber, TUint aHandle);
   1.102 +	void ConstructGroupBlankWinL();
   1.103 +	void DeleteGroupBlankWin();
   1.104 +	TBool CheckOrdinalPosition(TInt aWinAutoFocus1);
   1.105 +	
   1.106 +	// Virtual from CTClient
   1.107 +	void ConstructEventHandlerL();
   1.108 +	
   1.109 +private:
   1.110 +	CTMultiPtrEventTest* iTest;
   1.111 +	TSize iParentWinSize;
   1.112 +	TPoint iParentWinPos;
   1.113 +	TSize iChildWinSize;
   1.114 +	TPoint iChildWinPos;
   1.115 +	CTBlankWindow* iParentWin;
   1.116 +	CTBlankWindow* iChildWin;
   1.117 +
   1.118 +	TBool iSecondaryClient;
   1.119 +	
   1.120 +	// For AutoFocus test
   1.121 +	CTWindowGroup* iGroupWinAutoFocus1;
   1.122 +	CTWindowGroup* iGroupWinAutoFocus2;
   1.123 +	CTBlankWindow* iWinAutoFocus1;
   1.124 +	CTBlankWindow* iWinAutoFocus2;
   1.125 +	
   1.126 +	TSize iWinSizeAutoFocus1;
   1.127 +	TPoint iWinPosAutoFocus1;
   1.128 +	TSize iWinSizeAutoFocus2;
   1.129 +	TPoint iWinPosAutoFocus2;
   1.130 +	TBool iExpectNonAdvancedPointerEvents;
   1.131 +	};
   1.132 +
   1.133 +class RMultiPointerAnim : public RTestAnim
   1.134 +	{
   1.135 +public:
   1.136 +	static RMultiPointerAnim* NewL(RWindowBase* aWin, RAnimDll* aDll);
   1.137 +	RMultiPointerAnim(RAnimDll* aDll) :RTestAnim(*aDll) {}
   1.138 +	TInt AddExpectedAnimPointerEvent(TRawEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TBool aEat = ETrue);
   1.139 +	};
   1.140 +
   1.141 +/*
   1.142 + * CTWsGraphicsBase derived class which implements RunTestCaseL pure virtual.
   1.143 + * Runs all the testcases for multi poniter events.
   1.144 + * For each test case it creates CTMultiPtrEventClient object and creates a nested activescheduler
   1.145 + * Calls NextSetOfEventsL() which in turn calls respective tests depending upong the testcase number
   1.146 + * For each test simulates the events and adds the same event to CTMultiPtrEventBuffer
   1.147 + * When all the tests for a particular testcase completes stops activescheduler
   1.148 + * Repeats the same for all testcases
   1.149 + */ 
   1.150 +class CTMultiPtrEventTest : public CTWsGraphicsBase
   1.151 +	{
   1.152 +public:
   1.153 +	CTMultiPtrEventTest(CTestStep* aStep);
   1.154 +	~CTMultiPtrEventTest();
   1.155 +	void ConstructL();
   1.156 +	void NextSetOfEventsL();
   1.157 +	void Failed();
   1.158 +	
   1.159 +	// Functions for simulating events, which use UserSvr::AddEvent
   1.160 +	void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber);
   1.161 +	void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber);
   1.162 +	void SimulatePointerDownUp(TInt aX, TInt aY, TInt aZ, TUint8 aPointerNumber);
   1.163 +	
   1.164 +	// Functions for adding event, calls the client's AddExpectedPointer
   1.165 +	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0);
   1.166 +	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0, TBool aSecondaryClient = EFalse);
   1.167 +	void AddExpectedPointerDownUp(TPoint aPos, TInt aZ, TUint8 aPointerNumber);
   1.168 +	void AddExpectedWsEvent(TEventCode aType, TBool aSecondaryClient = EFalse, TInt aPointerNumber = 0, TUint aHandle = 0);
   1.169 +	void AddExpectedMultiPtrClickEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle = 0);
   1.170 +	void AddExpectedMultiPtrClickOtherEvent(TPointerEvent::TType aType, TPoint aPos, TInt aZ, TUint aModifier, TUint8 aPointerNumber, TUint aHandle);
   1.171 +	
   1.172 +	void AddExpectedKey(TInt aEventCode, TInt aScanCode, TInt aCode/*=0*/, TInt aRepeats/*=0*/, TUint aModifiers/*=0*/);
   1.173 +	void AddExpectedKeyDownUp(TInt aScanCode, TInt aCode=0, TInt aRepeats=0, TUint aModifiers=0);	
   1.174 +	
   1.175 +	// Supplementary function for tests
   1.176 +	void TestDragForMultiPointer(TPoint aPtrPos, TInt aPrValue, TUint8 aPointerNumber);
   1.177 +	void SimulateAndAddLoneUpEvents(TInt aNumSimulation, TInt aNumAddition, TPoint aPos);
   1.178 +	void TestAndDisplayAnimError();
   1.179 +	void GetRemainingEventsFromSecondaryClient();
   1.180 +	void TestAndDisplayPtrClickError();
   1.181 +	void CreatePointerClickPluginL();
   1.182 +	void SetAutoFlush();
   1.183 +	void ResetFlushStopAS();
   1.184 +	void TestFilteringForMultiPointer(TBool aFiltering);
   1.185 +	void TestGrabbingForMultiPointer(TBool aGrabbing);
   1.186 +	void CreateGroupWinL();
   1.187 +	void DeleteGroupWin();
   1.188 +	void CreateGroupWinForCapturingL();
   1.189 +	void DeleteGroupWinForCapturing();
   1.190 +	void CreateAnimDllAndAnimL();
   1.191 +	void DestroyAnimDllAndAnim();
   1.192 +	void TestCloseProximityHighPressureAPIsL();
   1.193 +	void TestCapturingForMultiPointer(TBool aAllGroups);
   1.194 +	void SetThresholdValues(TInt aEnterCloseProx, TInt aExitCloseProx, TInt aEnterHighPres, TInt aExitHighPres);
   1.195 +	void NegativeTestingOfProximityPressureAPIsL();
   1.196 +	void TestErrorCodeL(TInt aExpErrCode, TInt aActualErrCode);
   1.197 +	void SimulateProximityAndPressureEvents(TInt aCloseProxEnterValue, TInt aCloseProxExitValue, TInt aHighPresEnterValue, TInt aHighPresExitValue);
   1.198 +	void SetDefaultScreenMode();
   1.199 +	TPoint GetPointerPostionOnRotatedMode(TPoint aPointerPos, CFbsBitGc::TGraphicsOrientation aRotation);
   1.200 +	void LogEventsAdded();
   1.201 +	
   1.202 +	// All tests
   1.203 +	void MultiPointerEvents();
   1.204 +	void PurgingMultiPointerEvents();
   1.205 +	void MultiPointerEventsForAnimsL();
   1.206 +	void MultiClientMultiPointerEvents();
   1.207 +	void MultiPointerEventsForPointerClickL();
   1.208 +	void MultiPointerEventsInDiffScreenModes();
   1.209 +	void FilteringMultiPointerEvents();
   1.210 +	void GrabbingMultiPointerEvents();
   1.211 +	void VirtualKeyBoardForMultiplePointers();
   1.212 +	void DoubleClickForMultiplePointers();
   1.213 +	void MultiPointerOutOfRangeEvents();
   1.214 +	void AutoForeGroundForMultiplePointersL();
   1.215 +	void EmulationRulesForMultiplePointers();
   1.216 +    void CloseProximityAndHighPressureEventsL();
   1.217 +	void OutOfBoundValueTesting();
   1.218 +	void CapturingMultiPointerEvents();
   1.219 +	void NegativeTestsForProximityPressureEventsL();
   1.220 +	void PointerRepeatEventForMultiplePointers();
   1.221 +	void SetExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse);
   1.222 +	void ClearExpectNonAdvancedPointerEvents(TBool aSecondaryClient=EFalse);
   1.223 +	
   1.224 +protected:
   1.225 +	void RunTestCaseL(TInt aCurTestCase);
   1.226 +private:
   1.227 +	void RunTestsL();
   1.228 +private:
   1.229 +	TInt iEventSet;			// Set of events for one particular test case
   1.230 +	TBool iFailed;
   1.231 +	TBool iActiveSchedulerStarted;
   1.232 +	TBool iTheClientFlush;
   1.233 +	TBool iClientFlush;
   1.234 +	TBool iSecClientFlush;
   1.235 +	TSize iPhysicalScreenSize;
   1.236 +	TRect iOrigPtrCursorArea;
   1.237 +	
   1.238 +	TUint iPointerNumber;
   1.239 +	TInt iMaxDevPointers;
   1.240 +	TInt iMaxUiPointers;
   1.241 +	TInt iMaxPressure;
   1.242 +	TInt iPressureStep;
   1.243 +	TInt iMaxProximity;
   1.244 +	TInt iProximityStep;
   1.245 +
   1.246 +	TInt iEnterCloseProximityThreshold;
   1.247 +	TInt iExitCloseProximityThreshold;
   1.248 +	TInt iEnterHighPressureThreshold;
   1.249 +	TInt iExitHighPressureThreshold;	
   1.250 +	 
   1.251 +	CTMultiPtrEventClient *iMultiPtrEventClient;
   1.252 +	CTMultiPtrEventClient *iSecMultiPtrEventClient;
   1.253 +	
   1.254 +	RAnimDll* iAnimDll;
   1.255 +	RMultiPointerAnim* iAnim;
   1.256 +	
   1.257 +	RSoundPlugIn iClick;
   1.258 +	TBool iPtrPluginLoaded;
   1.259 +	RChunk iChunk;
   1.260 +	RHeap* iHeap;
   1.261 +	TAny* iErrDesc;
   1.262 +	
   1.263 +	TInt iCurrentScreenMode;
   1.264 +	TBool iChangeScreenMode;
   1.265 +	
   1.266 +	CTWindowGroup* iGroupWinForEmul;
   1.267 +	CTBlankWindow* iWinForEmul;
   1.268 +	
   1.269 +	CTWindowGroup* iGroupWinForCapturing;
   1.270 +	CTBlankWindow* iWinForCapturing;
   1.271 +	
   1.272 +	TInt iYOffset;
   1.273 +	};
   1.274 +
   1.275 +class CTMultiPtrEventTestStep : public CTGraphicsStep
   1.276 +	{
   1.277 +public:
   1.278 +	CTMultiPtrEventTestStep();
   1.279 +protected:
   1.280 +	//from CTGraphicsStep
   1.281 +	virtual CTGraphicsBase* CreateTestL();
   1.282 +	};
   1.283 +
   1.284 +_LIT(KTMultiPtrEventTestStep, "TMultiPtrEventTest");
   1.285 +
   1.286 +#endif /*TMULTIPTREVENT_H_*/