Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\digitiser\t_traweventdigitiser.cpp
16 // Test the TRawEvent APIS and events associated with the Digitiser and also verify the BTRACEs (manually)
20 // - Test the following 6 Events types
22 // 2. EPointer3DInRange,
23 // 3. EPointer3DOutOfRange,
25 // 5. EPointer3DRotation,
26 // 6. EPointer3DTiltAndMove,
27 // Platforms/Drives/Compatibility:
29 // Assumptions/Requirement/Pre-requisites:
30 // Failures and causes:
37 #include <e32cmn_private.h>
39 LOCAL_D RTest test(_L("t_TRawEventDigitiser"));
41 class TestTRawDigitiserEvent
44 TestTRawDigitiserEvent(TRawEvent::TType aType,TInt aX,TInt aY,TInt aZ,TInt aScanCode,TInt aPhi,TInt aTheta,TInt aAlpha,TUint8 aPointerNumber,TUint8 iTip);
47 TRawEvent::TType iType;
55 TUint8 iPointerNumber;
57 TRawEvent iDigitiser3DEvent;
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)
65 void TestTRawDigitiserEvent::TestEvents()
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)) ;
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());
111 UserSvr::AddEvent(iDigitiser3DEvent);
115 GLDEF_C TInt E32Main()
121 test.Start(_L("Testing Digitiser Events"));
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);
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"));