sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\digitiser\t_ldddigitisertest.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "d_lddDigitisertest.h" sl@0: #include sl@0: sl@0: _LIT(KLddFileName, "D_LDDDIGITISERTEST.LDD"); sl@0: sl@0: RLddDigitiserTest gLDD; sl@0: GLDEF_D RTest test(_L("Digitiser LDD tests")); sl@0: sl@0: void DoTestOnUnregisteredDevice() sl@0: { sl@0: __UHEAP_MARK; sl@0: test.Printf(_L("DoTestOnUnregisteredDevice(): should return KErrNotSupported coz NO DEVICE IS REGISTERED !!!")); sl@0: TInt r; sl@0: TInt halApiVal; sl@0: TInt unregisteredDeviceNumber=99; // Its highly unlikely that this device number is registered sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3D,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DThetaSupported,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DPhiSupported,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DRotationSupported,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DPressureSupported,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DProximityStep,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointerMaxPointers,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DMaxPressure,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: r=HAL::Get(unregisteredDeviceNumber,HALData::EPointer3DPressureStep,halApiVal); sl@0: test(r==KErrNotSupported); sl@0: sl@0: test.Printf(_L("Successully Finished Testing the DoTestOnUnregisteredDevice\n")); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: void DoTestDerivedeAtributes() sl@0: { sl@0: __UHEAP_MARK; sl@0: TInt r; sl@0: TInt halApiVal; sl@0: TInt testDriverVal; sl@0: TInt testDeviceNumber; sl@0: sl@0: //new Values for HAL::Set sl@0: TInt halPointer3DMaxProximity=45; sl@0: TInt halPointerNumberOfPointers=5; sl@0: sl@0: // New attribute values for Driver APIs sl@0: TInt newPointer3D=0; sl@0: TInt newPointer3DMaxProximity=50; sl@0: TInt newPointer3DThetaSupported=0; sl@0: TInt newPointer3DPhiSupported=0; sl@0: TInt newPointer3DRotationSupported=0; sl@0: TInt newPointer3DPressureSupported=0; sl@0: TInt newPointer3DProximityStep=6; sl@0: TInt newPointerMaxPointers=7; sl@0: TInt newPointerNumberOfPointers=2; sl@0: TInt newPointer3DMaxPressure=501; sl@0: TInt newPointer3DPressureStep=50; sl@0: sl@0: /* sl@0: The following sequence should be followed sl@0: sl@0: a) Load the test Driver sl@0: sl@0: b) Open the channel sl@0: sl@0: c) Register Kernel Hal Handler sl@0: sl@0: d) Get the Registered Device Number sl@0: sl@0: e) Initialise HAL data sl@0: sl@0: f) Get/Set HAL Data using HAL APIS (HAL::GET, HAL::SET) sl@0: sl@0: g) Get/Set the HAL data throught the test driver APIS sl@0: sl@0: h) Compare the results and make sure that data recived are same and data set sl@0: using HAL library apis received with test driver APIS and vice versa. sl@0: sl@0: i) Do it for all the new Digitiser Attributes (11 at the moment) sl@0: sl@0: j) ..... sl@0: sl@0: k) De-register the Kernel HAL handler sl@0: sl@0: l) Unload the Driver sl@0: sl@0: m) END... sl@0: sl@0: */ sl@0: test.Printf(_L("Testing Derived Attributes using a test Driver for Digitiser\n")); sl@0: r=User::LoadLogicalDevice(KLddFileName); sl@0: test(r==KErrNone); sl@0: sl@0: r=gLDD.Open(); sl@0: test(r==KErrNone); sl@0: sl@0: r=gLDD.registerHalHandler(); sl@0: test(r==KErrNone || r==KErrNotSupported); sl@0: sl@0: testDeviceNumber=gLDD.getRegisteredDeviceNumber(); sl@0: test(testDeviceNumber != KErrNotFound); sl@0: gLDD.initialiseHalData(); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3D,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3D(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DMaxProximity(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DThetaSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DThetaSupported(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DPhiSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DPhiSupported(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DRotationSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DRotationSupported(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DPressureSupported(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DProximityStep,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DProximityStep(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointerMaxPointers,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointerMaxPointers(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointerNumberOfPointers(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxPressure,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DMaxPressure(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureStep,halApiVal); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DPressureStep(); sl@0: test(halApiVal == testDriverVal); sl@0: sl@0: // There are just 2 settable HAL Values. Set them using HAL APIs and get the same using sl@0: // Test Driver APIs. sl@0: r=HAL::Set(testDeviceNumber,HALData::EPointer3DMaxProximity,halPointer3DMaxProximity); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointer3DMaxProximity(); sl@0: test(halPointer3DMaxProximity == testDriverVal); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == halPointer3DMaxProximity); sl@0: sl@0: r=HAL::Set(testDeviceNumber,HALData::EPointerNumberOfPointers,halPointerNumberOfPointers); sl@0: test(r==KErrNone); sl@0: testDriverVal=gLDD.getPointerNumberOfPointers(); sl@0: test(halPointerNumberOfPointers == testDriverVal); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == halPointerNumberOfPointers); sl@0: sl@0: // Set the Attributes values using the Driver APis and make sure that the same is sl@0: // received with HAL::Get APis sl@0: gLDD.setPointer3D(newPointer3D); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3D,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3D); sl@0: sl@0: gLDD.setPointer3DMaxProximity(newPointer3DMaxProximity); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxProximity,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DMaxProximity); sl@0: sl@0: gLDD.setPointer3DThetaSupported(newPointer3DThetaSupported); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DThetaSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DThetaSupported); sl@0: sl@0: gLDD.setPointer3DPhiSupported(newPointer3DPhiSupported); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DPhiSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DPhiSupported); sl@0: sl@0: gLDD.setPointer3DRotationSupported(newPointer3DRotationSupported); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DRotationSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DRotationSupported); sl@0: sl@0: gLDD.setPointer3DPressureSupported(newPointer3DPressureSupported); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureSupported,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DPressureSupported); sl@0: sl@0: gLDD.setPointer3DProximityStep(newPointer3DProximityStep); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DProximityStep,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DProximityStep); sl@0: sl@0: gLDD.setPointerMaxPointers(newPointerMaxPointers); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointerMaxPointers,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointerMaxPointers); sl@0: sl@0: gLDD.setPointerNumberOfPointers(newPointerNumberOfPointers); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointerNumberOfPointers,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointerNumberOfPointers); sl@0: sl@0: gLDD.setPointer3DMaxPressure(newPointer3DMaxPressure); sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DMaxPressure,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DMaxPressure); sl@0: sl@0: gLDD.setPointer3DPressureStep(newPointer3DPressureStep); sl@0: sl@0: r=HAL::Get(testDeviceNumber,HALData::EPointer3DPressureStep,halApiVal); sl@0: test(r==KErrNone); sl@0: test(halApiVal == newPointer3DPressureStep); sl@0: sl@0: r=gLDD.removeHalHandler(); sl@0: test(r == KErrNone); sl@0: sl@0: gLDD.Close(); sl@0: sl@0: r = User::FreeLogicalDevice(KLddFileName);; sl@0: test(r==KErrNone); sl@0: User::After(100000); sl@0: sl@0: // Finished Testing Derived attributes sl@0: test.Printf(_L("Successully Finished Testing the Derived attributes\n")); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: void DoTestNonDerivedAtributes() sl@0: { sl@0: __UHEAP_MARK; sl@0: // The following 4 HAL attributes would be tested using HAL::GET,HAL:SET APIs sl@0: // 1. EPointer3DEnterHighPressureThreshold sl@0: // 2. EPointer3DExitHighPressureThreshold sl@0: // 3. EPointer3DEnterCloseProximityThreshold sl@0: // 4. EPointer3DExitCloseProximityThreshold sl@0: //////////********TEST STEPS********//////////////////// sl@0: // Step1: Get the existing/default values using HAL:GET() and save them (for restoring it at Step4) sl@0: // Step2: Set new valuee using HAL:SET() sl@0: // Step3: Make sure that the new values are set by camparing the new valuee with the values got by HAL:GET() sl@0: // Step4: Restore the orginal values( saved at Step1) sl@0: sl@0: TInt r; sl@0: TInt halGetVal; sl@0: // Save the Original Values sl@0: TInt origPointer3DEnterHighPressureThreshold; sl@0: TInt origPointer3DExitHighPressureThreshold; sl@0: TInt origPointer3DEnterCloseProximityThreshold; sl@0: TInt origPointer3DExitCloseProximityThreshold; sl@0: sl@0: // New values to be set sl@0: TInt newPointer3DEnterHighPressureThreshold = 500; sl@0: TInt newPointer3DExitHighPressureThreshold = 300; sl@0: TInt newPointer3DEnterCloseProximityThreshold = 20; sl@0: TInt newPointer3DExitCloseProximityThreshold = 35; sl@0: sl@0: test.Printf(_L("Testing Non-Derived attributes\n")); sl@0: sl@0: // Test EPointer3DEnterHighPressureThreshold sl@0: r=HAL::Get(HALData::EPointer3DEnterHighPressureThreshold,origPointer3DEnterHighPressureThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Set(HALData::EPointer3DEnterHighPressureThreshold,newPointer3DEnterHighPressureThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DEnterHighPressureThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == newPointer3DEnterHighPressureThreshold); sl@0: r=HAL::Set(HALData::EPointer3DEnterHighPressureThreshold,origPointer3DEnterHighPressureThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DEnterHighPressureThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == origPointer3DEnterHighPressureThreshold); sl@0: sl@0: // Test EPointer3DExitHighPressureThreshold sl@0: r=HAL::Get(HALData::EPointer3DExitHighPressureThreshold,origPointer3DExitHighPressureThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Set(HALData::EPointer3DExitHighPressureThreshold,newPointer3DExitHighPressureThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DExitHighPressureThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == newPointer3DExitHighPressureThreshold); sl@0: r=HAL::Set(HALData::EPointer3DExitHighPressureThreshold,origPointer3DExitHighPressureThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DExitHighPressureThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == origPointer3DExitHighPressureThreshold); sl@0: sl@0: // Test EPointer3DEnterCloseProximityThreshold sl@0: r=HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold,origPointer3DEnterCloseProximityThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Set(HALData::EPointer3DEnterCloseProximityThreshold,newPointer3DEnterCloseProximityThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == newPointer3DEnterCloseProximityThreshold); sl@0: r=HAL::Set(HALData::EPointer3DEnterCloseProximityThreshold,origPointer3DEnterCloseProximityThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == origPointer3DEnterCloseProximityThreshold); sl@0: sl@0: // Test EPointer3DExitCloseProximityThreshold sl@0: r=HAL::Get(HALData::EPointer3DExitCloseProximityThreshold,origPointer3DExitCloseProximityThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Set(HALData::EPointer3DExitCloseProximityThreshold,newPointer3DExitCloseProximityThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DExitCloseProximityThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == newPointer3DExitCloseProximityThreshold); sl@0: r=HAL::Set(HALData::EPointer3DExitCloseProximityThreshold,origPointer3DExitCloseProximityThreshold); sl@0: test(r==KErrNone); sl@0: r=HAL::Get(HALData::EPointer3DExitCloseProximityThreshold,halGetVal); sl@0: test(r==KErrNone); sl@0: test(halGetVal == origPointer3DExitCloseProximityThreshold); sl@0: sl@0: // Finished Testing non-derived attributes sl@0: test.Printf(_L("Successully Finished Testing the non-derived attributes\n")); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Test Digitiser LDD sl@0: // sl@0: { sl@0: TInt machineUid=0; sl@0: // This Testing is performed only on H4,Wins and WinEmulator, so need to get the machinUID sl@0: const TInt r = HAL::Get(HAL::EMachineUid, machineUid); sl@0: if(r==KErrNone) sl@0: { sl@0: test.Start(_L("Test Start : LDDDigitiserTest")); sl@0: // Non-Derived attributes are tested using a Test Driver for Digitiser which is supported only on H4,Wins and WinEmulator sl@0: if((machineUid == HAL::EMachineUid_OmapH4) || (machineUid == HAL::EMachineUid_Win32Emulator)) sl@0: { sl@0: DoTestNonDerivedAtributes(); sl@0: } sl@0: // Derived attributes are tested using a Test Driver for Digitiser which is supported only on H4 sl@0: if(machineUid == HAL::EMachineUid_OmapH4) sl@0: { sl@0: DoTestOnUnregisteredDevice(); sl@0: DoTestDerivedeAtributes(); sl@0: } sl@0: } sl@0: test.End(); sl@0: test.Close(); sl@0: return(KErrNone); sl@0: }