132
|
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 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_userdigitisertest.cpp
|
|
15 |
// Overview:
|
|
16 |
// Test the TRawEvent APIS and events associated with the Digitiser and also verify the BTRACEs (manually)
|
|
17 |
// Test HAL digitiser orientation attribute
|
|
18 |
// API Information:
|
|
19 |
// UserSvr
|
|
20 |
// Details:
|
|
21 |
// - Test the following 6 Events types
|
|
22 |
// 1. EPointerMove
|
|
23 |
// 2. EPointer3DInRange,
|
|
24 |
// 3. EPointer3DOutOfRange,
|
|
25 |
// 4. EPointer3DTilt,
|
|
26 |
// 5. EPointer3DRotation,
|
|
27 |
// 6. EPointer3DTiltAndMove,
|
|
28 |
// Platforms/Drives/Compatibility:
|
|
29 |
// All.
|
|
30 |
// Assumptions/Requirement/Pre-requisites:
|
|
31 |
// Failures and causes:
|
|
32 |
//
|
|
33 |
//
|
|
34 |
|
|
35 |
#define __E32TEST_EXTENSION__
|
|
36 |
#include <e32test.h>
|
|
37 |
#include <e32svr.h>
|
|
38 |
#include <e32cmn.h>
|
|
39 |
#include <e32cmn_private.h>
|
|
40 |
#include <hal.h>
|
|
41 |
|
|
42 |
#ifndef E32TEST_NOCAPS
|
|
43 |
LOCAL_D RTest test(_L("T_UserDigitiserTest"));
|
|
44 |
#else
|
|
45 |
LOCAL_D RTest test(_L("T_UserDigitiserNoCaps"));
|
|
46 |
#endif
|
|
47 |
|
|
48 |
class TestTRawDigitiserEvent
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
TestTRawDigitiserEvent(TRawEvent::TType aType,TInt aX,TInt aY,TInt aZ,TInt aScanCode,TInt aPhi,TInt aTheta,TInt aAlpha,TUint8 aPointerNumber,TUint8 iTip);
|
|
52 |
void TestEvents();
|
|
53 |
private:
|
|
54 |
TRawEvent::TType iType;
|
|
55 |
TInt iX;
|
|
56 |
TInt iY;
|
|
57 |
TInt iZ;
|
|
58 |
TInt iScanCode;
|
|
59 |
TInt iPhi;
|
|
60 |
TInt iTheta;
|
|
61 |
TInt iAlpha;
|
|
62 |
TUint8 iPointerNumber;
|
|
63 |
TUint8 iTip;
|
|
64 |
TRawEvent iDigitiser3DEvent;
|
|
65 |
};
|
|
66 |
|
|
67 |
|
|
68 |
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)
|
|
69 |
{}
|
|
70 |
|
|
71 |
|
|
72 |
void TestTRawDigitiserEvent::TestEvents()
|
|
73 |
{
|
|
74 |
static TInt count = 0;
|
|
75 |
count++;
|
|
76 |
test.Printf(_L("TestTRawDigitiserEvent test case %2d\n"), count);
|
|
77 |
|
|
78 |
test(iDigitiser3DEvent.Type()==0);
|
|
79 |
iDigitiser3DEvent.Set(iType);
|
|
80 |
test(iDigitiser3DEvent.Type()==iType);
|
|
81 |
iDigitiser3DEvent.SetPointerNumber(iPointerNumber);
|
|
82 |
test(iPointerNumber == iDigitiser3DEvent.PointerNumber());
|
|
83 |
iDigitiser3DEvent.Set(iType,iScanCode);
|
|
84 |
//Set the Type temporarily to get through the assertion
|
|
85 |
iDigitiser3DEvent.Set(TRawEvent::EKeyDown);
|
|
86 |
test(iScanCode==iDigitiser3DEvent.ScanCode());
|
|
87 |
iDigitiser3DEvent.Set(iType,iX,iY);
|
|
88 |
//Set the Type temporarily to get through the assertion
|
|
89 |
iDigitiser3DEvent.Set(TRawEvent::EPointerMove);
|
|
90 |
test(TPoint(iX,iY)==iDigitiser3DEvent.Pos());
|
|
91 |
iDigitiser3DEvent.Set(iType,iX,iY,iZ);
|
|
92 |
//Set the Type temporarily to get through the assertion
|
|
93 |
iDigitiser3DEvent.Set(TRawEvent::EPointerMove);
|
|
94 |
test(TPoint3D(iX,iY,iZ)==iDigitiser3DEvent.Pos3D());
|
|
95 |
iDigitiser3DEvent.SetTip(iTip);
|
|
96 |
test(TBool(iTip) == iDigitiser3DEvent.IsTip());
|
|
97 |
iDigitiser3DEvent.SetTilt(iType,iPhi,iTheta);
|
|
98 |
//Set the Type temporarily to get through the assertion
|
|
99 |
iDigitiser3DEvent.Set(TRawEvent::EPointer3DTilt);
|
|
100 |
TAngle3D rawEventAnge3D=iDigitiser3DEvent.Tilt();
|
|
101 |
test((rawEventAnge3D.iPhi==iPhi) && (rawEventAnge3D.iTheta==iTheta)) ;
|
|
102 |
|
|
103 |
|
|
104 |
iDigitiser3DEvent.SetRotation(iType,iAlpha);
|
|
105 |
//Set the Type temporarily to get through the assertion
|
|
106 |
iDigitiser3DEvent.Set(TRawEvent::EPointer3DRotation);
|
|
107 |
test(iAlpha == iDigitiser3DEvent.Rotation());
|
|
108 |
iDigitiser3DEvent.Set(iType,iX+1,iY+1,iZ+1,iPhi+1,iTheta+1,iAlpha+1);
|
|
109 |
//Set the Type temporarily to get through the assertion
|
|
110 |
iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove);
|
|
111 |
test(TPoint3D(iX+1,iY+1,iZ+1)==iDigitiser3DEvent.Pos3D());
|
|
112 |
rawEventAnge3D=iDigitiser3DEvent.Tilt();
|
|
113 |
test((rawEventAnge3D.iPhi==iPhi+1) &&(rawEventAnge3D.iTheta==iTheta+1));
|
|
114 |
test((iAlpha+1) == iDigitiser3DEvent.Rotation());
|
|
115 |
iDigitiser3DEvent.Set(iType,iX+2,iY+2,iZ+2,static_cast<TUint8>(iPointerNumber+1));
|
|
116 |
//Set the Type temporarily to get through the assertion
|
|
117 |
iDigitiser3DEvent.Set(TRawEvent::EPointer3DTiltAndMove);
|
|
118 |
test(TPoint3D(iX+2,iY+2,iZ+2)==iDigitiser3DEvent.Pos3D());
|
|
119 |
test((iPointerNumber+1) == iDigitiser3DEvent.PointerNumber());
|
|
120 |
|
|
121 |
UserSvr::AddEvent(iDigitiser3DEvent);
|
|
122 |
}
|
|
123 |
|
|
124 |
|
|
125 |
struct HalAttribute_TestCase
|
|
126 |
{
|
|
127 |
HALData::TAttribute iAttr;
|
|
128 |
TInt iValueIn;
|
|
129 |
TInt iSetRC; // Set to KMaxTInt to skip set test case
|
|
130 |
TInt iGetRC; // Set to KMaxTInt to skip get test case
|
|
131 |
|
|
132 |
};
|
|
133 |
|
|
134 |
static HalAttribute_TestCase gHalAttributeTests[] =
|
|
135 |
{
|
|
136 |
#ifndef E32TEST_NOCAPS
|
|
137 |
// Normal all pass tests
|
|
138 |
{ HALData::EDigitiserOrientation, HALData::EDigitiserOrientation_000, KErrNone, KErrNone},
|
|
139 |
{ HALData::EDigitiserOrientation, HALData::EDigitiserOrientation_090, KErrNone, KErrNone},
|
|
140 |
{ HALData::EDigitiserOrientation, HALData::EDigitiserOrientation_180, KErrNone, KErrNone},
|
|
141 |
{ HALData::EDigitiserOrientation, HALData::EDigitiserOrientation_270, KErrNone, KErrNone},
|
|
142 |
{ HALData::EDigitiserOrientation, HALData::EDigitiserOrientation_default, KErrNone, KErrNone},
|
|
143 |
|
|
144 |
// Negative tests
|
|
145 |
{ HALData::EDigitiserOrientation, -1, KErrArgument, KMaxTInt},
|
|
146 |
{ HALData::EDigitiserOrientation, 100, KErrArgument, KMaxTInt},
|
|
147 |
|
|
148 |
#else
|
|
149 |
// Platsec tests for no capabilities executable.
|
|
150 |
{ HALData::EDigitiserOrientation, HALData::EDigitiserOrientation_default, KMaxTInt, KErrNone}, // Get, No caps needed
|
|
151 |
{ HALData::EDigitiserOrientation, HALData::EDigitiserOrientation_default, KErrPermissionDenied, KMaxTInt}, // Set WDD cap needed
|
|
152 |
#endif
|
|
153 |
};
|
|
154 |
|
|
155 |
static TInt gNumHalAttributeTests = sizeof(gHalAttributeTests)/sizeof(HalAttribute_TestCase);
|
|
156 |
|
|
157 |
void DoTestDigitiserHalAttributes()
|
|
158 |
{
|
|
159 |
__UHEAP_MARK;
|
|
160 |
#ifndef E32TEST_NOCAPS
|
|
161 |
test.Start(_L("DoTestDigitiserHalAttributes tests"));
|
|
162 |
#else
|
|
163 |
test.Start(_L("DoTestDigitiserHalAttributes NO CAPS tests"));
|
|
164 |
|
|
165 |
// Skip No Caps testing for WDD caps when enforcement is not enabled on the
|
|
166 |
// platform i.e. when a emulator epoc.ini is missing.
|
|
167 |
if (!PlatSec::IsCapabilityEnforced(ECapabilityWriteDeviceData))
|
|
168 |
{
|
|
169 |
test.Printf(_L("Platform security enforcement off, skipping\n"));
|
|
170 |
test.End();
|
|
171 |
__UHEAP_MARKEND;
|
|
172 |
return;
|
|
173 |
}
|
|
174 |
#endif
|
|
175 |
|
|
176 |
TInt i = 0;
|
|
177 |
TInt origValue = -1;
|
|
178 |
TInt r = HAL::Get(HALData::EDigitiserOrientation, origValue);
|
|
179 |
if (r == KErrNotSupported)
|
|
180 |
{
|
|
181 |
test.Printf(_L("Platform doesn't support EDigitiserOrientation, skipping\n"));
|
|
182 |
test.End();
|
|
183 |
__UHEAP_MARKEND;
|
|
184 |
return;
|
|
185 |
}
|
|
186 |
test_KErrNone(r);
|
|
187 |
|
|
188 |
// Attribute supported on platform, proceed with test.
|
|
189 |
TInt value = -1;
|
|
190 |
for (i=0; i < gNumHalAttributeTests; i++)
|
|
191 |
{
|
|
192 |
test.Printf(_L("DoTestDigitiserHalAttributes - step/row %2d\n"), i+1);
|
|
193 |
|
|
194 |
if (gHalAttributeTests[i].iSetRC != KMaxTInt) // Skip set test?
|
|
195 |
{
|
|
196 |
r = HAL::Set(gHalAttributeTests[i].iAttr, gHalAttributeTests[i].iValueIn);
|
|
197 |
test_Equal( gHalAttributeTests[i].iSetRC, r);
|
|
198 |
}
|
|
199 |
|
|
200 |
if (gHalAttributeTests[i].iGetRC != KMaxTInt) // Skip get test?
|
|
201 |
{
|
|
202 |
r = HAL::Get(gHalAttributeTests[i].iAttr, value);
|
|
203 |
test_Equal(gHalAttributeTests[i].iGetRC, r);
|
|
204 |
test_Equal(gHalAttributeTests[i].iValueIn, value);
|
|
205 |
}
|
|
206 |
}
|
|
207 |
|
|
208 |
#ifndef E32TEST_NOCAPS
|
|
209 |
// Return system state back to before the test
|
|
210 |
r = HAL::Set(HALData::EDigitiserOrientation, origValue);
|
|
211 |
test_KErrNone(r);
|
|
212 |
#endif
|
|
213 |
|
|
214 |
test.Printf(_L("DoTestDigitiserHalAttributes - complete\n"));
|
|
215 |
test.End();
|
|
216 |
__UHEAP_MARKEND;
|
|
217 |
}
|
|
218 |
|
|
219 |
#ifndef E32TEST_NOCAPS
|
|
220 |
void DoTestRawDigitiserEvent()
|
|
221 |
{
|
|
222 |
__UHEAP_MARK;
|
|
223 |
test.Start(_L("DoTestRawDigitiserEvent tests"));
|
|
224 |
|
|
225 |
TestTRawDigitiserEvent digitiserEvent1(TRawEvent::EPointerMove, -890,-123, -823,455,2563,156,62,3,1);
|
|
226 |
TestTRawDigitiserEvent digitiserEvent2(TRawEvent::EPointer3DInRange, 23,45,23,1,2,6,4,2,1);
|
|
227 |
TestTRawDigitiserEvent digitiserEvent3(TRawEvent::EPointer3DOutOfRange, 23,45,23,1,2,6,4,2,0);
|
|
228 |
TestTRawDigitiserEvent digitiserEvent4(TRawEvent::EPointer3DTilt, 23,45,23,1,2,6,4,2,1);
|
|
229 |
TestTRawDigitiserEvent digitiserEvent5(TRawEvent::EPointer3DRotation, 23,45,23,1,2,6,4,2,1);
|
|
230 |
TestTRawDigitiserEvent digitiserEvent6(TRawEvent::EPointer3DTiltAndMove, 23,45,23,1,2,6,4,2,0);
|
|
231 |
|
|
232 |
digitiserEvent1.TestEvents();
|
|
233 |
digitiserEvent2.TestEvents();
|
|
234 |
digitiserEvent3.TestEvents();
|
|
235 |
digitiserEvent4.TestEvents();
|
|
236 |
digitiserEvent5.TestEvents();
|
|
237 |
digitiserEvent6.TestEvents();
|
|
238 |
|
|
239 |
test.End();
|
|
240 |
__UHEAP_MARKEND;
|
|
241 |
}
|
|
242 |
#endif
|
|
243 |
|
|
244 |
|
|
245 |
GLDEF_C TInt E32Main()
|
|
246 |
//
|
|
247 |
//
|
|
248 |
{
|
|
249 |
__UHEAP_MARK;
|
|
250 |
|
|
251 |
test.Title();
|
|
252 |
test.Start(_L("User-side Digitiser Testing Events/HAL"));
|
|
253 |
|
|
254 |
DoTestDigitiserHalAttributes();
|
|
255 |
|
|
256 |
#ifndef E32TEST_NOCAPS
|
|
257 |
DoTestRawDigitiserEvent();
|
|
258 |
#endif
|
|
259 |
|
|
260 |
test.Printf(_L("\n"));
|
|
261 |
test.End();
|
|
262 |
test.Close();
|
|
263 |
|
|
264 |
__UHEAP_MARKEND;
|
|
265 |
return KErrNone;
|
|
266 |
}
|
|
267 |
|