First public contribution.
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_ldddigitisertest.cpp
20 #include "d_lddDigitisertest.h"
23 _LIT(KLddFileName, "D_LDDDIGITISERTEST.LDD");
25 RLddDigitiserTest gLDD;
26 GLDEF_D RTest test(_L("Digitiser LDD tests"));
28 void DoTestOnUnregisteredDevice()
31 test.Printf(_L("DoTestOnUnregisteredDevice(): should return KErrNotSupported coz NO DEVICE IS REGISTERED !!!"));
34 TInt unregisteredDeviceNumber=99; // Its highly unlikely that this device number is registered
36 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3D,halApiVal);
37 test(r==KErrNotSupported);
39 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal);
40 test(r==KErrNotSupported);
42 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DThetaSupported,halApiVal);
43 test(r==KErrNotSupported);
45 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DPhiSupported,halApiVal);
46 test(r==KErrNotSupported);
48 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DRotationSupported,halApiVal);
49 test(r==KErrNotSupported);
51 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DPressureSupported,halApiVal);
52 test(r==KErrNotSupported);
54 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DProximityStep,halApiVal);
55 test(r==KErrNotSupported);
57 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointerMaxPointers,halApiVal);
58 test(r==KErrNotSupported);
60 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal);
61 test(r==KErrNotSupported);
63 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DMaxPressure,halApiVal);
64 test(r==KErrNotSupported);
66 r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DPressureStep,halApiVal);
67 test(r==KErrNotSupported);
69 test.Printf(_L("Successully Finished Testing the DoTestOnUnregisteredDevice\n"));
73 void DoTestDerivedeAtributes()
79 TInt testDeviceNumber;
81 //new Values for HAL::Set
82 TInt halPointer3DMaxProximity=45;
83 TInt halPointerNumberOfPointers=5;
85 // New attribute values for Driver APIs
87 TInt newPointer3DMaxProximity=50;
88 TInt newPointer3DThetaSupported=0;
89 TInt newPointer3DPhiSupported=0;
90 TInt newPointer3DRotationSupported=0;
91 TInt newPointer3DPressureSupported=0;
92 TInt newPointer3DProximityStep=6;
93 TInt newPointerMaxPointers=7;
94 TInt newPointerNumberOfPointers=2;
95 TInt newPointer3DMaxPressure=501;
96 TInt newPointer3DPressureStep=50;
99 The following sequence should be followed
101 a) Load the test Driver
105 c) Register Kernel Hal Handler
107 d) Get the Registered Device Number
109 e) Initialise HAL data
111 f) Get/Set HAL Data using HAL APIS (HAL::GET, HAL::SET)
113 g) Get/Set the HAL data throught the test driver APIS
115 h) Compare the results and make sure that data recived are same and data set
116 using HAL library apis received with test driver APIS and vice versa.
118 i) Do it for all the new Digitiser Attributes (11 at the moment)
122 k) De-register the Kernel HAL handler
129 test.Printf(_L("Testing Derived Attributes using a test Driver for Digitiser\n"));
130 r=User::LoadLogicalDevice(KLddFileName);
136 r=gLDD.registerHalHandler();
137 test(r==KErrNone || r==KErrNotSupported);
139 testDeviceNumber=gLDD.getRegisteredDeviceNumber();
140 test(testDeviceNumber != KErrNotFound);
141 gLDD.initialiseHalData();
143 r=HAL::Get(testDeviceNumber,HALData::EPointer3D,halApiVal);
145 testDriverVal=gLDD.getPointer3D();
146 test(halApiVal == testDriverVal);
148 r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal);
150 testDriverVal=gLDD.getPointer3DMaxProximity();
151 test(halApiVal == testDriverVal);
153 r=HAL::Get(testDeviceNumber,HALData::EPointer3DThetaSupported,halApiVal);
155 testDriverVal=gLDD.getPointer3DThetaSupported();
156 test(halApiVal == testDriverVal);
158 r=HAL::Get(testDeviceNumber,HALData::EPointer3DPhiSupported,halApiVal);
160 testDriverVal=gLDD.getPointer3DPhiSupported();
161 test(halApiVal == testDriverVal);
163 r=HAL::Get(testDeviceNumber,HALData::EPointer3DRotationSupported,halApiVal);
165 testDriverVal=gLDD.getPointer3DRotationSupported();
166 test(halApiVal == testDriverVal);
168 r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureSupported,halApiVal);
170 testDriverVal=gLDD.getPointer3DPressureSupported();
171 test(halApiVal == testDriverVal);
173 r=HAL::Get(testDeviceNumber,HALData::EPointer3DProximityStep,halApiVal);
175 testDriverVal=gLDD.getPointer3DProximityStep();
176 test(halApiVal == testDriverVal);
178 r=HAL::Get(testDeviceNumber,HALData::EPointerMaxPointers,halApiVal);
180 testDriverVal=gLDD.getPointerMaxPointers();
181 test(halApiVal == testDriverVal);
183 r=HAL::Get(testDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal);
185 testDriverVal=gLDD.getPointerNumberOfPointers();
186 test(halApiVal == testDriverVal);
188 r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxPressure,halApiVal);
190 testDriverVal=gLDD.getPointer3DMaxPressure();
191 test(halApiVal == testDriverVal);
193 r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureStep,halApiVal);
195 testDriverVal=gLDD.getPointer3DPressureStep();
196 test(halApiVal == testDriverVal);
198 // There are just 2 settable HAL Values. Set them using HAL APIs and get the same using
200 r=HAL::Set(testDeviceNumber,HALData::EPointer3DMaxProximity,halPointer3DMaxProximity);
202 testDriverVal=gLDD.getPointer3DMaxProximity();
203 test(halPointer3DMaxProximity == testDriverVal);
204 r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal);
206 test(halApiVal == halPointer3DMaxProximity);
208 r=HAL::Set(testDeviceNumber,HALData::EPointerNumberOfPointers,halPointerNumberOfPointers);
210 testDriverVal=gLDD.getPointerNumberOfPointers();
211 test(halPointerNumberOfPointers == testDriverVal);
212 r=HAL::Get(testDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal);
214 test(halApiVal == halPointerNumberOfPointers);
216 // Set the Attributes values using the Driver APis and make sure that the same is
217 // received with HAL::Get APis
218 gLDD.setPointer3D(newPointer3D);
219 r=HAL::Get(testDeviceNumber,HALData::EPointer3D,halApiVal);
221 test(halApiVal == newPointer3D);
223 gLDD.setPointer3DMaxProximity(newPointer3DMaxProximity);
224 r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal);
226 test(halApiVal == newPointer3DMaxProximity);
228 gLDD.setPointer3DThetaSupported(newPointer3DThetaSupported);
229 r=HAL::Get(testDeviceNumber,HALData::EPointer3DThetaSupported,halApiVal);
231 test(halApiVal == newPointer3DThetaSupported);
233 gLDD.setPointer3DPhiSupported(newPointer3DPhiSupported);
234 r=HAL::Get(testDeviceNumber,HALData::EPointer3DPhiSupported,halApiVal);
236 test(halApiVal == newPointer3DPhiSupported);
238 gLDD.setPointer3DRotationSupported(newPointer3DRotationSupported);
239 r=HAL::Get(testDeviceNumber,HALData::EPointer3DRotationSupported,halApiVal);
241 test(halApiVal == newPointer3DRotationSupported);
243 gLDD.setPointer3DPressureSupported(newPointer3DPressureSupported);
244 r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureSupported,halApiVal);
246 test(halApiVal == newPointer3DPressureSupported);
248 gLDD.setPointer3DProximityStep(newPointer3DProximityStep);
249 r=HAL::Get(testDeviceNumber,HALData::EPointer3DProximityStep,halApiVal);
251 test(halApiVal == newPointer3DProximityStep);
253 gLDD.setPointerMaxPointers(newPointerMaxPointers);
254 r=HAL::Get(testDeviceNumber,HALData::EPointerMaxPointers,halApiVal);
256 test(halApiVal == newPointerMaxPointers);
258 gLDD.setPointerNumberOfPointers(newPointerNumberOfPointers);
259 r=HAL::Get(testDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal);
261 test(halApiVal == newPointerNumberOfPointers);
263 gLDD.setPointer3DMaxPressure(newPointer3DMaxPressure);
264 r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxPressure,halApiVal);
266 test(halApiVal == newPointer3DMaxPressure);
268 gLDD.setPointer3DPressureStep(newPointer3DPressureStep);
270 r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureStep,halApiVal);
272 test(halApiVal == newPointer3DPressureStep);
274 r=gLDD.removeHalHandler();
279 r = User::FreeLogicalDevice(KLddFileName);;
283 // Finished Testing Derived attributes
284 test.Printf(_L("Successully Finished Testing the Derived attributes\n"));
288 void DoTestNonDerivedAtributes()
291 // The following 4 HAL attributes would be tested using HAL::GET,HAL:SET APIs
292 // 1. EPointer3DEnterHighPressureThreshold
293 // 2. EPointer3DExitHighPressureThreshold
294 // 3. EPointer3DEnterCloseProximityThreshold
295 // 4. EPointer3DExitCloseProximityThreshold
296 //////////********TEST STEPS********////////////////////
297 // Step1: Get the existing/default values using HAL:GET() and save them (for restoring it at Step4)
298 // Step2: Set new valuee using HAL:SET()
299 // Step3: Make sure that the new values are set by camparing the new valuee with the values got by HAL:GET()
300 // Step4: Restore the orginal values( saved at Step1)
304 // Save the Original Values
305 TInt origPointer3DEnterHighPressureThreshold;
306 TInt origPointer3DExitHighPressureThreshold;
307 TInt origPointer3DEnterCloseProximityThreshold;
308 TInt origPointer3DExitCloseProximityThreshold;
310 // New values to be set
311 TInt newPointer3DEnterHighPressureThreshold = 500;
312 TInt newPointer3DExitHighPressureThreshold = 300;
313 TInt newPointer3DEnterCloseProximityThreshold = 20;
314 TInt newPointer3DExitCloseProximityThreshold = 35;
316 test.Printf(_L("Testing Non-Derived attributes\n"));
318 // Test EPointer3DEnterHighPressureThreshold
319 r=HAL::Get(HALData::EPointer3DEnterHighPressureThreshold,origPointer3DEnterHighPressureThreshold);
321 r=HAL::Set(HALData::EPointer3DEnterHighPressureThreshold,newPointer3DEnterHighPressureThreshold);
323 r=HAL::Get(HALData::EPointer3DEnterHighPressureThreshold,halGetVal);
325 test(halGetVal == newPointer3DEnterHighPressureThreshold);
326 r=HAL::Set(HALData::EPointer3DEnterHighPressureThreshold,origPointer3DEnterHighPressureThreshold);
328 r=HAL::Get(HALData::EPointer3DEnterHighPressureThreshold,halGetVal);
330 test(halGetVal == origPointer3DEnterHighPressureThreshold);
332 // Test EPointer3DExitHighPressureThreshold
333 r=HAL::Get(HALData::EPointer3DExitHighPressureThreshold,origPointer3DExitHighPressureThreshold);
335 r=HAL::Set(HALData::EPointer3DExitHighPressureThreshold,newPointer3DExitHighPressureThreshold);
337 r=HAL::Get(HALData::EPointer3DExitHighPressureThreshold,halGetVal);
339 test(halGetVal == newPointer3DExitHighPressureThreshold);
340 r=HAL::Set(HALData::EPointer3DExitHighPressureThreshold,origPointer3DExitHighPressureThreshold);
342 r=HAL::Get(HALData::EPointer3DExitHighPressureThreshold,halGetVal);
344 test(halGetVal == origPointer3DExitHighPressureThreshold);
346 // Test EPointer3DEnterCloseProximityThreshold
347 r=HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold,origPointer3DEnterCloseProximityThreshold);
349 r=HAL::Set(HALData::EPointer3DEnterCloseProximityThreshold,newPointer3DEnterCloseProximityThreshold);
351 r=HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold,halGetVal);
353 test(halGetVal == newPointer3DEnterCloseProximityThreshold);
354 r=HAL::Set(HALData::EPointer3DEnterCloseProximityThreshold,origPointer3DEnterCloseProximityThreshold);
356 r=HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold,halGetVal);
358 test(halGetVal == origPointer3DEnterCloseProximityThreshold);
360 // Test EPointer3DExitCloseProximityThreshold
361 r=HAL::Get(HALData::EPointer3DExitCloseProximityThreshold,origPointer3DExitCloseProximityThreshold);
363 r=HAL::Set(HALData::EPointer3DExitCloseProximityThreshold,newPointer3DExitCloseProximityThreshold);
365 r=HAL::Get(HALData::EPointer3DExitCloseProximityThreshold,halGetVal);
367 test(halGetVal == newPointer3DExitCloseProximityThreshold);
368 r=HAL::Set(HALData::EPointer3DExitCloseProximityThreshold,origPointer3DExitCloseProximityThreshold);
370 r=HAL::Get(HALData::EPointer3DExitCloseProximityThreshold,halGetVal);
372 test(halGetVal == origPointer3DExitCloseProximityThreshold);
374 // Finished Testing non-derived attributes
375 test.Printf(_L("Successully Finished Testing the non-derived attributes\n"));
379 GLDEF_C TInt E32Main()
381 // Test Digitiser LDD
385 // This Testing is performed only on H4,Wins and WinEmulator, so need to get the machinUID
386 const TInt r = HAL::Get(HAL::EMachineUid, machineUid);
389 test.Start(_L("Test Start : LDDDigitiserTest"));
390 // Non-Derived attributes are tested using a Test Driver for Digitiser which is supported only on H4,Wins and WinEmulator
391 if((machineUid == HAL::EMachineUid_OmapH4) || (machineUid == HAL::EMachineUid_Win32Emulator))
393 DoTestNonDerivedAtributes();
395 // Derived attributes are tested using a Test Driver for Digitiser which is supported only on H4
396 if(machineUid == HAL::EMachineUid_OmapH4)
398 DoTestOnUnregisteredDevice();
399 DoTestDerivedeAtributes();