kerneltest/e32test/digitiser/t_traweventdigitiser.cpp
branchRCL_3
changeset 38 83c58605f049
parent 31 cc88aabd867b
parent 36 bbf8bed59bcb
equal deleted inserted replaced
31:cc88aabd867b 38:83c58605f049
     1 // Copyright (c) 2008-2009 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 the License "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 // e32test\digitiser\t_traweventdigitiser.cpp
       
    15 // Overview:
       
    16 // Test the TRawEvent APIS and events associated with the Digitiser and also verify the BTRACEs (manually)
       
    17 // API Information:
       
    18 // UserSvr
       
    19 // Details:
       
    20 // - Test the following 6  Events types 
       
    21 // 1.	EPointerMove
       
    22 // 2.	EPointer3DInRange,
       
    23 // 3.	EPointer3DOutOfRange,
       
    24 // 4.	EPointer3DTilt,
       
    25 // 5.	EPointer3DRotation,
       
    26 // 6.	EPointer3DTiltAndMove,
       
    27 // Platforms/Drives/Compatibility:
       
    28 // All.
       
    29 // Assumptions/Requirement/Pre-requisites: 
       
    30 // Failures and causes:
       
    31 // 
       
    32 //
       
    33 
       
    34 #include <e32test.h>
       
    35 #include <e32svr.h>
       
    36 #include <e32cmn.h>
       
    37 #include <e32cmn_private.h>
       
    38 
       
    39 LOCAL_D RTest test(_L("t_TRawEventDigitiser"));
       
    40 
       
    41 class TestTRawDigitiserEvent
       
    42 	{
       
    43 public:
       
    44 	TestTRawDigitiserEvent(TRawEvent::TType aType,TInt aX,TInt aY,TInt aZ,TInt aScanCode,TInt aPhi,TInt aTheta,TInt aAlpha,TUint8 aPointerNumber,TUint8 iTip);
       
    45 	void TestEvents();	
       
    46 private:	
       
    47 	TRawEvent::TType iType;
       
    48 	TInt iX;
       
    49     TInt iY;
       
    50 	TInt iZ;
       
    51 	TInt iScanCode;
       
    52 	TInt iPhi;
       
    53 	TInt iTheta;
       
    54 	TInt iAlpha;
       
    55 	TUint8 iPointerNumber;
       
    56 	TUint8 iTip;
       
    57 	TRawEvent iDigitiser3DEvent;
       
    58 	};
       
    59 
       
    60 
       
    61 TestTRawDigitiserEvent::TestTRawDigitiserEvent(TRawEvent::TType aType,TInt aX,TInt aY,TInt aZ,TInt aScanCode,TInt aPhi,TInt aTheta,TInt aAlpha,TUint8 aPointerNumber,TUint8 aTip):iType(aType),iX(aX),iY(aY),iZ(aZ),iScanCode(aScanCode),iPhi(aPhi),iTheta(aTheta),iAlpha(aAlpha),iPointerNumber(aPointerNumber),iTip(aTip)
       
    62 	{}
       
    63 
       
    64 
       
    65 void TestTRawDigitiserEvent::TestEvents()
       
    66 	{
       
    67 	
       
    68 	test(iDigitiser3DEvent.Type()==0);
       
    69 	iDigitiser3DEvent.Set(iType);
       
    70 	test(iDigitiser3DEvent.Type()==iType);
       
    71 	iDigitiser3DEvent.SetPointerNumber(iPointerNumber);
       
    72 	test(iPointerNumber == iDigitiser3DEvent.PointerNumber());
       
    73 	iDigitiser3DEvent.Set(iType,iScanCode);
       
    74 	//Set the Type temporarily to get through the assertion 
       
    75 	iDigitiser3DEvent.Set(TRawEvent::EKeyDown);
       
    76     test(iScanCode==iDigitiser3DEvent.ScanCode());
       
    77 	iDigitiser3DEvent.Set(iType,iX,iY);
       
    78 	//Set the Type temporarily to get through the assertion
       
    79 	iDigitiser3DEvent.Set(TRawEvent::EPointerMove);
       
    80 	test(TPoint(iX,iY)==iDigitiser3DEvent.Pos());
       
    81 	iDigitiser3DEvent.Set(iType,iX,iY,iZ);
       
    82 	//Set the Type temporarily to get through the assertion
       
    83 	iDigitiser3DEvent.Set(TRawEvent::EPointerMove);
       
    84 	test(TPoint3D(iX,iY,iZ)==iDigitiser3DEvent.Pos3D());
       
    85 	iDigitiser3DEvent.SetTip(iTip);
       
    86 	test(TBool(iTip) == iDigitiser3DEvent.IsTip());
       
    87 	iDigitiser3DEvent.SetTilt(iType,iPhi,iTheta);
       
    88 	//Set the Type temporarily to get through the assertion
       
    89 	iDigitiser3DEvent.Set(TRawEvent::EPointer3DTilt);
       
    90 	TAngle3D rawEventAnge3D=iDigitiser3DEvent.Tilt();
       
    91 	test((rawEventAnge3D.iPhi==iPhi) && (rawEventAnge3D.iTheta==iTheta)) ;
       
    92 	
       
    93 
       
    94 	iDigitiser3DEvent.SetRotation(iType,iAlpha);
       
    95 	//Set the Type temporarily to get through the assertion
       
    96 	iDigitiser3DEvent.Set(TRawEvent::EPointer3DRotation);
       
    97 	test(iAlpha == iDigitiser3DEvent.Rotation());
       
    98 	iDigitiser3DEvent.Set(iType,iX+1,iY+1,iZ+1,iPhi+1,iTheta+1,iAlpha+1);
       
    99 	//Set the Type temporarily to get through the assertion
       
   100 	iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove);
       
   101 	test(TPoint3D(iX+1,iY+1,iZ+1)==iDigitiser3DEvent.Pos3D());
       
   102     rawEventAnge3D=iDigitiser3DEvent.Tilt();
       
   103 	test((rawEventAnge3D.iPhi==iPhi+1) &&(rawEventAnge3D.iTheta==iTheta+1));	
       
   104 	test((iAlpha+1) == iDigitiser3DEvent.Rotation());   
       
   105 	iDigitiser3DEvent.Set(iType,iX+2,iY+2,iZ+2,static_cast<TUint8>(iPointerNumber+1));
       
   106 	//Set the Type temporarily to get through the assertion
       
   107 	iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove);
       
   108   	test(TPoint3D(iX+2,iY+2,iZ+2)==iDigitiser3DEvent.Pos3D());
       
   109 	test((iPointerNumber+1) == iDigitiser3DEvent.PointerNumber());
       
   110 
       
   111 	UserSvr::AddEvent(iDigitiser3DEvent);
       
   112 	}
       
   113 
       
   114 
       
   115 GLDEF_C TInt E32Main()
       
   116 //
       
   117 //
       
   118     {
       
   119 
       
   120  	test.Title();
       
   121 	test.Start(_L("Testing Digitiser Events"));
       
   122 	
       
   123     TestTRawDigitiserEvent digitiserEvent1(TRawEvent::EPointerMove, -890,-123, -823,455,2563,156,62,3,1);
       
   124 	TestTRawDigitiserEvent digitiserEvent2(TRawEvent::EPointer3DInRange, 23,45,23,1,2,6,4,2,1);
       
   125 	TestTRawDigitiserEvent digitiserEvent3(TRawEvent::EPointer3DOutOfRange, 23,45,23,1,2,6,4,2,0);
       
   126 	TestTRawDigitiserEvent digitiserEvent4(TRawEvent::EPointer3DTilt, 23,45,23,1,2,6,4,2,1);
       
   127 	TestTRawDigitiserEvent digitiserEvent5(TRawEvent::EPointer3DRotation, 23,45,23,1,2,6,4,2,1);
       
   128 	TestTRawDigitiserEvent digitiserEvent6(TRawEvent::EPointer3DTiltAndMove, 23,45,23,1,2,6,4,2,0);
       
   129 
       
   130     digitiserEvent1.TestEvents();
       
   131 	digitiserEvent2.TestEvents();
       
   132 	digitiserEvent3.TestEvents();
       
   133 	digitiserEvent4.TestEvents();
       
   134 	digitiserEvent5.TestEvents();
       
   135 	digitiserEvent6.TestEvents();    
       
   136 	test.Printf(_L("T_TRAWEVENTDIGITISER: TEST Successfully Completed\n"));
       
   137 	test.End();
       
   138 	test.Close();
       
   139 
       
   140     return KErrNone;
       
   141 
       
   142     }
       
   143