windowing/windowserver/tauto/tptroffset.h
branchRCL_3
changeset 17 e375a7921169
equal deleted inserted replaced
15:7f6e7753e018 17:e375a7921169
       
     1 // Copyright (c) 2010 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  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20  */ 
       
    21 
       
    22 #ifndef TPTROFFSET_H_
       
    23 #define TPTROFFSET_H_
       
    24 
       
    25 #include <e32std.h>
       
    26 #include <e32cmn.h>
       
    27 #include "w32std.h"
       
    28 #include "../tlib/testbase.h"
       
    29 #include "AUTO.H"
       
    30 #include "AUTODLL.H"
       
    31 #include "TGraphicsHarness.h"
       
    32 
       
    33 
       
    34 class CTPointerOffsetTest;
       
    35 class CTPointerOffsetClient;
       
    36 
       
    37 /*
       
    38  * CTEvent derived class which acts as eventhandler and eventbuffer 
       
    39  * Stores the events in buffer, which is used for comparing events received from wserv.
       
    40  */ 
       
    41 class CTPointerOffsetBuffer : public CTEvent
       
    42 	{
       
    43 	enum {EEventBufferSize=40};
       
    44 public:
       
    45 	CTPointerOffsetBuffer(RWsSession *aWs, CTPointerOffsetTest *aTest, CTPointerOffsetClient* aClient);
       
    46 	~CTPointerOffsetBuffer();
       
    47 	void ConstructL();
       
    48 	void AddExpectedEvent(TWsEvent &aEvent);
       
    49 	TInt EventsRemaining();
       
    50 	void SetEventCount(TInt aCount) {iEventCount = aCount;}
       
    51 
       
    52 protected:
       
    53 	// Pure virtual from CTEventBase
       
    54 	void doRunL();
       
    55 private:
       
    56 	void TestL(TInt aTest);
       
    57 
       
    58 private:
       
    59 	CCirBuf<TWsEvent> iEventBuffer;
       
    60 	CTPointerOffsetTest* iTest;
       
    61 	TInt iEventCount;
       
    62 	CTPointerOffsetClient* iClient;
       
    63 	};
       
    64 
       
    65 /* 
       
    66  * CTClient derived class which gives Wserv client environment 
       
    67  * i,e iWs, iScreen, iGc, iGroup, iEventHandler etc...
       
    68  * Owns CTPointerOffsetBuffer and stores in iEventhandler of its base class
       
    69  * Accepts the event from test class and passes them on to buffer class
       
    70  */ 
       
    71 class CTPointerOffsetClient : public CTClient
       
    72 	{
       
    73 public:
       
    74 	CTPointerOffsetClient(CTPointerOffsetTest *aTest);
       
    75 	~CTPointerOffsetClient();
       
    76 	void ConstructL();
       
    77 	
       
    78 	inline CTBlankWindow* Win() { return iWin; }
       
    79 	inline CTPointerOffsetBuffer* EventBuffer() {return static_cast<CTPointerOffsetBuffer*>(iEventHandler);}
       
    80 	
       
    81 	void AddExpectedPointerEvent(TPointerEvent::TType aType, TPoint aPos, TUint8 aPointerNumber, TUint aHandle = 0);
       
    82 	void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0);
       
    83 
       
    84 	// Virtual from CTClient
       
    85 	void ConstructEventHandlerL();
       
    86 	
       
    87 private:
       
    88 	CTPointerOffsetTest* iTest;
       
    89 	TSize iWinSize;
       
    90 	TPoint iWinPos;
       
    91 	CTBlankWindow* iWin;
       
    92 	};
       
    93 
       
    94 
       
    95 /*
       
    96  * CTWsGraphicsBase derived class which implements RunTestCaseL pure virtual.
       
    97  * Runs all the testcases for pointer events which have offset.
       
    98  * For each test case it creates CTPointerOffsetClient object and creates a nested activescheduler
       
    99  * Calls NextSetOfEventsL() which in turn calls respective tests depending upon the testcase number
       
   100  * For each test, simulate the events and adds the same to CTPointerOffsetBuffer
       
   101  * When all the tests for a particular testcase completes, stops activescheduler.
       
   102  * Repeats the same for all testcases
       
   103  */ 
       
   104 class CTPointerOffsetTest : public CTWsGraphicsBase
       
   105 	{
       
   106 public:
       
   107 	CTPointerOffsetTest(CTestStep* aStep);
       
   108 	~CTPointerOffsetTest();
       
   109 	void ConstructL();
       
   110 	void NextSetOfEventsL();
       
   111 	void Failed();
       
   112 	
       
   113 	// Function for simulating events, which use UserSvr::AddEvent
       
   114 	void SimulatePointerEvent(TRawEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber);
       
   115 	
       
   116 	// Function for adding event, calls the client's AddExpectedPointer
       
   117 	void AddExpectedPointerEvent(TPointerEvent::TType aType, TInt aX, TInt aY, TUint8 aPointerNumber, TUint aHandle = 0);
       
   118 	void AddExpectedWsEvent(TEventCode aType, TInt aPointerNumber = 0, TUint aHandle = 0);
       
   119 	
       
   120 	// Supplementary function for tests
       
   121 	TInt GetShiftedYValue(TInt aY);
       
   122 	
       
   123 	// All tests function can come here
       
   124 	void TestYOffsetValues();
       
   125 	
       
   126 protected:
       
   127 	void RunTestCaseL(TInt aCurTestCase);
       
   128 private:
       
   129 	void RunTestsL();
       
   130 private:
       
   131 	TInt iYOffsetTop;
       
   132 	TInt iYOffsetBottom;
       
   133 	TInt iYOffsetMax;	
       
   134 	
       
   135 	TInt iEventSet;			// Set of events for one particular test case
       
   136 	TBool iFailed;
       
   137 	TSize iPhysicalScreenSize;
       
   138 	TInt iPointerNumber;
       
   139 	TInt iMaxPointerNumbers;
       
   140 	
       
   141 	CTPointerOffsetClient *iPointerOffsetClient;
       
   142 	};
       
   143 
       
   144 class CTPointerOffsetTestStep : public CTGraphicsStep
       
   145 	{
       
   146 public:
       
   147 	CTPointerOffsetTestStep();
       
   148 protected:
       
   149 	//from CTGraphicsStep
       
   150 	virtual CTGraphicsBase* CreateTestL();
       
   151 	};
       
   152 
       
   153 _LIT(KTPointerOffsetTestStep, "TPointerOffsetTest");
       
   154 
       
   155 #endif /*TPTROFFSET_H_*/