# HG changeset patch # User hgs # Date 1286537605 -10800 # Node ID cb32bcc88badb4ec375c9d8ef4d3a77f168acc03 # Parent d38941471f1c47ef211c9d2fb5810871cd2409b1 201039 diff -r d38941471f1c -r cb32bcc88bad accessoryservices/accessoryserver/group/bld.inf --- a/accessoryservices/accessoryserver/group/bld.inf Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/accessoryserver/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -39,7 +39,6 @@ //Accessory Control ../data/hwdevices.ini /epoc32/winscw/c/private/1020504a/hwdevices.ini -../inc/Common/accessoryservicesinternalpskeys.h |../../../inc/accessoryservicesinternalpskeys.h PRJ_MMPFILES diff -r d38941471f1c -r cb32bcc88bad accessoryservices/accessoryserver/inc/Common/accessoryservicesinternalpskeys.h --- a/accessoryservices/accessoryserver/inc/Common/accessoryservicesinternalpskeys.h Wed Sep 29 15:13:21 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Internal Publish&Subscribe definitions of the -* Accessory Services -* -*/ - - -#ifndef ACCESSORYSERVICESINTERNALPSKEYS_H -#define ACCESSORYSERVICESINTERNALPSKEYS_H - -#include - -static const TUid KPSUidAccessoryServices = { 0x10205030 }; - -// ============================================================================= -// Accessory Services Wired Connection API -// ============================================================================= -// Use TUid KPSUidAccessoryServices = { 0x10205030 } - -/** -* Notified when a wired accessory is physically connected or disconnected. -*/ -const TUint32 KAccSrvcsWiredConnection = 0x00000001; -enum TAccSrvcsWiredConnection - { - EAccSrvcsWiredConnUninitialized = 0, - EAccSrvcsWiredConnConnected, - EAccSrvcsWiredConnDisconnected - }; - - -#endif ACCESSORYSERVICESINTERNALPSKEYS_H diff -r d38941471f1c -r cb32bcc88bad accessoryservices/accessoryserver/src/Server/AccSrvWiredConnectionPublisher.cpp --- a/accessoryservices/accessoryserver/src/Server/AccSrvWiredConnectionPublisher.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/accessoryserver/src/Server/AccSrvWiredConnectionPublisher.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -16,7 +16,7 @@ */ -#include +#include #include "AccSrvWiredConnectionPublisher.h" #include "acc_debug.h" diff -r d38941471f1c -r cb32bcc88bad accessoryservices/accessoryserver/tsrc/public/basic/AccessoryTestControl/AccessoryTestControlPlugin/src/TfAccessoryTestControl.cpp --- a/accessoryservices/accessoryserver/tsrc/public/basic/AccessoryTestControl/AccessoryTestControlPlugin/src/TfAccessoryTestControl.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/accessoryserver/tsrc/public/basic/AccessoryTestControl/AccessoryTestControlPlugin/src/TfAccessoryTestControl.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4698 +1,4699 @@ -/* - * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * - */ - -// INCLUDE FILES - -#include -#include -#include -#include "siftrace.h" -#include "CtfAccessoryTestcontrol.h" -#include "CtfAccessoryTestCaseControl.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "AccClientServerMessages.h" -#include - -#include -#include - -// -// ---------------------------------------------------------------------------------- -// MTFAccessoryTestControl* GetAccessoryTestControl -// ---------------------------------------------------------------------------------- -MTFAccessoryTestControl* GetAccessoryTestControl( void ) - { - CTFStub* stub = CTFFactory::Stub( KTFStubTypeAccessoryControl ); - return STATIC_CAST( CTFAccessoryTestControl*, stub ); - } -// -// ---------------------------------------------------------------------------------- -// MTFAccessoryTestControl::MTFAccessoryTestControl -// ---------------------------------------------------------------------------------- -MTFAccessoryTestControl::MTFAccessoryTestControl( void ) - { - } -// -// ---------------------------------------------------------------------------------- -// MTFAccessoryTestControl::~MTFAccessoryTestControl -// ---------------------------------------------------------------------------------- -MTFAccessoryTestControl::~MTFAccessoryTestControl( void ) - { - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CTFAccessoryTestControl -// ---------------------------------------------------------------------------------- -CTFAccessoryTestControl::CTFAccessoryTestControl( void ) : - CTFRemoteStub( KTFStubTypeAccessoryControl ), - iStack( CTFTestControlObserver::iOffset ), iStackIter( iStack ) - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CTFAccessoryTestControl()" ) ) ); - - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CTFAccessoryTestControl() - return" ) ) ); - } - -//lint -e1740 Pointer not directly deleted by destructor -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::~CTFAccessoryTestControl -// ---------------------------------------------------------------------------------- -CTFAccessoryTestControl::~CTFAccessoryTestControl( void ) - { - - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::~CTFAccessoryTestControl()" ) ) ); - RProperty::Delete( KTFAccessoryTestProperty, KTFAccessoryMethod ); - - ResetAccessoryServices(); - - iAccessoryServer.Disconnect(); - - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::~CTFAccessoryTestControl() - Accessory Server connection closed" ) ) ); - - } -//lint +e1740 -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::InitializeL -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::InitializeL( void ) - { - - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::InitializeL( void ) - enter" ) ) ); - TInt retval( KErrNone ); - - iAccessoryConnection = NULL; - iAccessorySingleConnection = NULL; - iAccessoryControl = NULL; - iAccessorySettings = NULL; - iAccessoryMode = NULL; - iAccessoryAudioControl = NULL; - iAccessoryBTControl = NULL; - - iStreamContainer = NULL; - iTopologyContainer = NULL; - iSpeakerRightVolume = NULL; - iSpeakerLeftVolume = NULL; - iSpeakerMute = NULL; - iMicRightVolume = NULL; - iMicLeftVolume = NULL; - - TAccPolGenericID emptyInstance; - for( TInt i( 0 ); i < 10; i++ ) - { - iGenericId[i] = emptyInstance; - } - - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::InitializeL()" ) ) ); - - User::LeaveIfError( iAccessoryServer.Connect() ); - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::InitializeL() - Connected to accessory server" ) ) ); - - retval = RProperty::Define( KTFAccessoryTestProperty, - KTFAccessoryMethod, - RProperty::EByteArray ); - if( retval != KErrAlreadyExists ) - User::LeaveIfError( retval ); - //attach to property - - - RProperty systemState; - User::LeaveIfError( systemState.Attach( KPSUidStartup, KPSGlobalSystemState ) ); - TInt value( KErrNone ); - //check value - TInt err = systemState.Get( value ); - - if( err != KErrNone ) - { - err = systemState.Define( KPSUidStartup, - KPSGlobalSystemState, - RProperty::EInt ); - TInt err = systemState.Get( value ); - } - - if( value != ESwStateNormalRfOn || value != ESwStateNormalRfOff || value - != ESwStateNormalBTSap ) - { - TInt err = systemState.Set( KPSUidStartup, - KPSGlobalSystemState, - ESwStateNormalRfOn ); - } - - iInitialized = ETrue; - - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::InitializeL - return" ) ) ); - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::InitializeL( void ) - return" ) ) ); - } -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::ResetAccessoryServices -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::ResetAccessoryServices( void ) - { - ResetAccessoryServer(); - - iInitialized = EFalse; - - iAccessoryServer.Close(); - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::ResetAccessoryServer -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::ResetAccessoryServer( void ) - { - - COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::ResetAccessoryServer()" ) ) ); - - CTFTestControlObserver* observerItem; - if( !iStack.IsEmpty() ) - { - iStackIter.SetToFirst(); - - while( ( observerItem = iStackIter++ ) != NULL ) - { - observerItem->Cancel(); - User::After( 2000000 ); - iStack.Remove( *observerItem ); - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Remove Observer" ) ) ); - delete observerItem; - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Delete Observer" ) ) ); - }; - } - - iStack.Reset(); - - TAccPolGenericID emptyInstance; - - for( TInt i( 0 ); i < 10; i++ ) - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Clear instances" ) ) ); - if( KErrNotFound != iGenericId[i].UniqueID() ) - { - if( iGenericId[i].PhysicalConnectionCaps( KPCBluetooth ) ) - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- BT Found" ) ) ); - TBTDevAddr BTDevAddr( iGenericId[i].DeviceAddress() ); - if( iAccessoryBTControl != NULL ) - { - TRequestStatus status; - status = KRequestPending; - iAccessoryBTControl->DisconnectAccessory( status, BTDevAddr ); - User::WaitForRequest( status ); - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- BT Disconnected" ) ) ); - } - } - else - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Wired Found" ) ) ); - TPckgBuf buf; - buf().iMethod = ETFAsyDisc; - User::LeaveIfError( iSubscribe.Set( KTFAccessoryTestProperty, - KTFAccessoryMethod, - buf ) ); - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Wired Disconnected" ) ) ); - } - } - iGenericId[i] = emptyInstance; - } - - if( iAccessoryConnection != NULL ) - { - iAccessoryConnection->CloseSubSession(); - delete iAccessoryConnection; - iAccessoryConnection = NULL; - } - - if( iAccessorySingleConnection != NULL ) - { - iAccessorySingleConnection->CloseSubSession(); - delete iAccessorySingleConnection; - iAccessorySingleConnection = NULL; - } - if( iAccessoryControl != NULL ) - { - iAccessoryControl->CloseSubSession(); - delete iAccessoryControl; - iAccessoryControl = NULL; - } - if( iAccessorySettings != NULL ) - { - iAccessorySettings->CloseSubSession(); - delete iAccessorySettings; - iAccessorySettings = NULL; - } - if( iAccessoryMode != NULL ) - { - iAccessoryMode->CloseSubSession(); - delete iAccessoryMode; - iAccessoryMode = NULL; - } - - if( iAccessoryAudioControl != NULL ) - { - iAccessoryAudioControl->CloseSubSession(); - delete iAccessoryAudioControl; - iAccessoryAudioControl = NULL; - } - - if( iAccessoryBTControl != NULL ) - { - iAccessoryBTControl->CloseSubSession(); - delete iAccessoryBTControl; - iAccessoryBTControl = NULL; - } - - if( iSpeakerRightVolume != NULL ) - { - delete iSpeakerRightVolume; - iSpeakerRightVolume = NULL; - } - - if( iSpeakerLeftVolume != NULL ) - { - delete iSpeakerLeftVolume; - iSpeakerLeftVolume = NULL; - } - - if( iSpeakerMute != NULL ) - { - delete iSpeakerMute; - iSpeakerMute = NULL; - } - - if( iMicRightVolume != NULL ) - { - delete iMicRightVolume; - iMicRightVolume = NULL; - } - - if( iMicLeftVolume != NULL ) - { - delete iMicLeftVolume; - iMicLeftVolume = NULL; - } - - if( iStreamContainer != NULL ) - { - delete iStreamContainer; - iStreamContainer = NULL; - } - - if( iTopologyContainer != NULL ) - { - delete iTopologyContainer; - iTopologyContainer = NULL; - } - - COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::ResetAccessoryServer() - Success" ) ) ); - } -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CancelOutStandingRequest -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::CancelOutStandingRequest() - { - iObserverItem->Cancel(); - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::FillObjectL -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::FillObjectL( CAccPolAudioStreamFormatCon* aContainer, - TStreamConObjectType aobjectType, - TInt64 aNumberOfObjects ) - { - - for( TInt i = 0; i < aNumberOfObjects; i++ ) - { - switch( aobjectType ) - { - case EAccPolAudioInputStreamObject: - { - CAccPolAudioStreamFormat* stream = - CAccPolAudioStreamFormat::NewLC( aobjectType, - i, - KUidFormatPCM16, - CAccPolAudioStreamFormat::EStereo, - CAccPolAudioStreamFormat::EBitsPerSample16, - i + 200 ); - aContainer->AddL( *stream ); - CleanupStack::PopAndDestroy( stream ); - } - break; - - case EAccPolAudioOutputStreamObject: - { - - CAccPolAudioStreamFormat - * stream = - CAccPolAudioStreamFormat::NewLC( EAccPolAudioOutputStreamObject ); - - stream->SetUnitId( i ); - stream->SetAudioFormat( KUidFormatPCM16 ); - stream->SetStreamType( CAccPolAudioStreamFormat::EMono ); - stream->SetBitResolution( CAccPolAudioStreamFormat::EBitsPerSample32 ); - stream->SetSamFreq( i + 200 ); - - aContainer->AddL( *stream ); - CleanupStack::PopAndDestroy( stream ); - } - break; - - default: - { - TRACE_ASSERT_ALWAYS; - } - break; - } - } - - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CreateObjectPubSub -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::CreateObjectPubSubL( TStreamConObjectType aobjectType, - TInt64 aNumberOfObjects, - TStreamConObjectType aobjectType2, - TInt64 aNumberOfObjects2 ) - { - RProperty prop; - prop.Define( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - RProperty::EByteArray ); - - CAccPolAudioStreamFormatCon* container = - CAccPolAudioStreamFormatCon::NewLC(); - - FillObjectL( container, aobjectType, aNumberOfObjects ); - FillObjectL( container, aobjectType2, aNumberOfObjects2 ); - - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - //Externalize container to buf - RBufWriteStream wStrm; - ( void )wStrm.Open( *buf ); - wStrm.PushL(); - container->ExternalizeL( wStrm ); - wStrm.CommitL(); - wStrm.Close(); - wStrm.Pop(); - - TPtr8 ptr( buf->Ptr( 0 ) ); - - TInt retval = prop.Set( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - ptr ); - - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( container ); - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CreateObjectPubSub -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::CreateTopologyObjectsToPubSubL( - TTFAccessoryTestCaseStateControl& aParameter ) - { - RProperty prop; - prop.Define( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - RProperty::EByteArray ); - - CAccPolAudioTopologyObjectCon* aObject = - CAccPolAudioTopologyObjectCon::NewLC(); - - //Speaker - //OT-3 - CAccPolOutputTerminal* OT3 = CAccPolOutputTerminal::NewLC( 3, - CAccPolOutputTerminal::EAPTHeadphone, - 2 ); - //Connected to FU-2 - aObject->AddL( *OT3 ); - - //FU2 - CAccPolFeatureUnit* FU2 = CAccPolFeatureUnit::NewLC( 2, 8 ); - // Volume control object. - CAccPolVolumeControl* speakerRightVolume = - CAccPolVolumeControl::NewLC( KAccRightFrontChannel, 7, 5, 20, 5 ); - CAccPolVolumeControl* speakerLeftVolume = - CAccPolVolumeControl::NewLC( KAccLeftFrontChannel, 7, 5, 20, 5 ); - - CAccPolMuteControl* speakermute = - CAccPolMuteControl::NewLC( KAccMasterChannel, ETrue ); - - FU2->AddControlL( *speakerRightVolume ); - FU2->AddControlL( *speakerLeftVolume ); - FU2->AddControlL( *speakermute ); - - //Connected to MU-8 - aObject->AddL( *FU2 ); - - CAccPolMixerUnit* MU8 = CAccPolMixerUnit::NewLC( 8 ); - MU8->AddSourceIdL( 1 ); - MU8->AddSourceIdL( 7 ); - - //Connected to IT1 and FU7 - aObject->AddL( *MU8 ); - - //Choice one - //IT-1 - TUint8 aChannelCount = 2; - TUint16 aChannelConfig = 0; - aChannelConfig = aChannelConfig | KAccRightFrontChannel; - aChannelConfig = aChannelConfig | KAccLeftFrontChannel; - - CAccPolInputTerminal* IT1 = CAccPolInputTerminal::NewLC( 1, - CAccPolInputTerminal::EAPTStream, - aChannelCount, - aChannelConfig ); - aObject->AddL( *IT1 ); - - //choice two - //FU7 - CAccPolFeatureUnit* FU7 = CAccPolFeatureUnit::NewLC( 7, 5 ); //Connected to FU5 - // Volume control object. - CAccPolVolumeControl* sidetoneRightVolume = - CAccPolVolumeControl::NewLC( KAccMasterChannel, 7, 5, 20, 5 ); - CAccPolVolumeControl* sidetoneLeftVolume = - CAccPolVolumeControl::NewLC( KAccMasterChannel, 7, 5, 20, 5 ); - - FU7->AddControlL( *sidetoneRightVolume ); - FU7->AddControlL( *sidetoneLeftVolume ); - - aObject->AddL( *FU7 ); - - //Microphone - //IT-4 - - //OT-6 - CAccPolOutputTerminal* OT6 = CAccPolOutputTerminal::NewLC( 6, - CAccPolOutputTerminal::EAPTStream, - 10 ); - //Connected to SU-10 - aObject->AddL( *OT6 ); - - //SU-10 - CAccPolSelectorUnit* SU10 = CAccPolSelectorUnit::NewLC( 10, 1 ); - - // Connected to FU 5 - SU10->AddSourceIdL( 5 ); - aObject->AddL( *SU10 ); - - //FU5 - CAccPolFeatureUnit* FU5 = CAccPolFeatureUnit::NewLC( 5, 9 ); - - // Volume control object. - CAccPolVolumeControl* micRightVolume = - CAccPolVolumeControl::NewLC( KAccRightFrontChannel, 7, 5, 20, 5 ); - CAccPolVolumeControl* micLeftVolume = - CAccPolVolumeControl::NewLC( KAccLeftFrontChannel, 7, 5, 20, 5 ); - CAccPolMuteControl* micmute = CAccPolMuteControl::NewLC( KAccMasterChannel, - ETrue ); - - FU5->AddControlL( *micRightVolume ); - FU5->AddControlL( *micLeftVolume ); - FU5->AddControlL( *micmute ); - - //Connected to FU-9 - aObject->AddL( *FU5 ); - - ///FU9 - CAccPolFeatureUnit* FU9 = CAccPolFeatureUnit::NewLC( 9, 4 ); - //Connected IT-4 - aObject->AddL( *FU9 ); - - CAccPolInputTerminal* IT4 = CAccPolInputTerminal::NewLC( 4, - CAccPolInputTerminal::EAPTMicrophone, - aChannelCount, - aChannelConfig ); - aObject->AddL( *IT4 ); - - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - //Externalize container to buf - RBufWriteStream wStrm; - ( void )wStrm.Open( *buf ); - wStrm.PushL(); - aObject->ExternalizeL( wStrm ); - wStrm.CommitL(); - wStrm.Close(); - wStrm.Pop(); - TPtr8 ptr( buf->Ptr( 0 ) ); - TInt retval = prop.Set( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - ptr ); - - // Notify ASY stub - if( aParameter.iArg2 ) - { - PublishAndSubscribeL( aParameter ); - } - - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( IT4 ); - CleanupStack::PopAndDestroy( FU9 ); - CleanupStack::PopAndDestroy( micmute ); - CleanupStack::PopAndDestroy( micLeftVolume ); - CleanupStack::PopAndDestroy( micRightVolume ); - CleanupStack::PopAndDestroy( FU5 ); - CleanupStack::PopAndDestroy( SU10 ); - CleanupStack::PopAndDestroy( OT6 ); - CleanupStack::PopAndDestroy( sidetoneLeftVolume ); - CleanupStack::PopAndDestroy( sidetoneRightVolume ); - CleanupStack::PopAndDestroy( FU7 ); - CleanupStack::PopAndDestroy( IT1 ); - CleanupStack::PopAndDestroy( MU8 ); - CleanupStack::PopAndDestroy( speakermute ); - CleanupStack::PopAndDestroy( speakerLeftVolume ); - CleanupStack::PopAndDestroy( speakerRightVolume ); - CleanupStack::PopAndDestroy( FU2 ); - CleanupStack::PopAndDestroy( OT3 ); - CleanupStack::PopAndDestroy( aObject ); - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CallAccessoryFunctionL -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::CallAccessoryFunctionL( TTFAccessoryTestCaseStateControl& aParameter ) - { - - // COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CallAccessoryFunctionL(%d, %d, %d)" ), aParameter.iAccessoryFunction, aParameter.iArg1, aParameter.iArg2 ) ); - if( !iInitialized ) - { - InitializeL(); - } - - TInt retval = KTFErrAccessoryServiceMissing; - - switch( aParameter.iAccessoryFunction ) - { - case ETFAccessorySet_ObjectPubSub: - { - CreateObjectPubSubL( ( TStreamConObjectType )aParameter.iArg1, - aParameter.iArg2, - ( TStreamConObjectType )aParameter.iArg3, - aParameter.iArg4 ); - retval = KErrNone; - } - break; - - case ETFAccessorySet_TopologyObjectsPubSub: - { - CreateTopologyObjectsToPubSubL( aParameter ); - retval = KErrNone; - } - break; - - case ETFAccessorySet_PubSub: - { - RProperty prop; - prop.Define( KTFAccessoryTestProperty, - KTFAccessoryNotifierMethod, - RProperty::EInt ); - retval = prop.Set( KTFAccessoryTestProperty, - KTFAccessoryNotifierMethod, - aParameter.iArg1 ); - } - break; - - case ETFConnectWiredAccessory: - { - PublishAndSubscribeL( aParameter ); - retval = KErrNone; - } - break; - - case ETFClearStack: - { - CTFTestControlObserver* observerItem; - TInt count = 0; - if( !iStack.IsEmpty() ) - { - iStackIter.SetToFirst(); - - while( ( observerItem = iStackIter++ ) != NULL ) - { - observerItem->Cancel(); - iStack.Remove( *observerItem ); - delete observerItem; - count++; - }; - } - - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestCaseControl::ETF_Pappa - count=%d " ), count ) ); - retval = KErrNone; - } - break; - - case ETFDisconnectWiredAccessory: - { - retval = KErrNone; - PublishAndSubscribeL( aParameter ); - TAccPolGenericID emptyInstance; - iGenericId[aParameter.iGid] = emptyInstance; - } - break; - - case ETFCheckCapabilityGroup: - { - if( aParameter.iArg2 - == iGenericId[aParameter.iGid].SubblockCaps( aParameter.iArg3 ) ) - { - retval = KErrNone; - } - else - { - retval = KErrNotFound; - } - } - break; - - case ETFCheckCapability: - { - RAccessoryConnection accessoryConnectionn; - accessoryConnectionn.CreateSubSession( iAccessoryServer ); - - CAccPolSubblockNameArray* nameArrayy = - CAccPolSubblockNameArray::NewL(); - CleanupStack::PushL( nameArrayy ); - accessoryConnectionn.GetSubblockNameArrayL( iGenericId[aParameter.iGid], - *nameArrayy ); - - if( aParameter.iArg2 == nameArrayy->HasName( aParameter.iArg3 ) ) - { - retval = KErrNone; - } - else - { - retval = KErrNotFound; - } - - CleanupStack::PopAndDestroy( nameArrayy ); - accessoryConnectionn.CloseSubSession(); - } - break; - - case ETFFindAndCheckRequest: - - { - FindAndCheckRequestL(&retval, aParameter); - } - break; - - case ETFFindAndCheckObjectRequest: - { - CTFAccessoryTestCaseControl* testCase = STATIC_CAST( CTFAccessoryTestCaseControl*, CurrentTestCase()); - TRACE_ASSERT( testCase != NULL ); - if( testCase != NULL ) - { - if( !iStack.IsEmpty() ) - { - iStackIter.SetToFirst(); - - while( ( iObserverItem = iStackIter++ ) != NULL ) - { - if( iObserverItem->FindRequest( aParameter.iRequestType ) ) - { - testCase->CheckObjectRequest( iObserverItem->iStatus, - iObserverItem->iObjectValue, - iObserverItem->iCapabilityName ); - - if( !iStack.IsEmpty() ) // Check if observes are already deleted by CheckRequest() - { - if( KTFDontDeleteObserver != aParameter.iArg1 ) - { - iStack.Remove( *iObserverItem ); - delete iObserverItem; - return; - } - else - { - User::Leave( KTFDontDeleteObserver ); - } - } - else - { - retval = KErrGeneral; - } - } - } - } - else - { - retval = KErrGeneral; - } - } - - retval = KErrNone; - } - break; - - // - // Accessory Connection - // - case ETFAccessoryConnection_Open: - { - AccessoryConnectionOpenClose(ETFAccessoryConnection_Open, &retval); - } - break; - - case ETFAccessoryConnection_Close: - - { - AccessoryConnectionOpenClose(ETFAccessoryConnection_Close, &retval); - } - break; - - // - // Accessory Settings - // - case ETFAccessorySettings_Open: - { - AccessorySettingsOpenClose(ETFAccessorySettings_Open, &retval); - } - break; - - case ETFAccessorySettings_Close: - { - AccessorySettingsOpenClose(ETFAccessorySettings_Close, &retval); - } - break; - - case ETFSetHWDeviceSettings: - { - retval - = iAccessorySettings->SetHWDeviceSettingsL( aParameter.iArg1, - ( TBool )aParameter.iArg2 ); - } - break; - - case ETFGetHWDeviceSettings: - { - TUint32 aSettingsValue( 0 ); - retval = iAccessorySettings->GetHWDeviceSettings( aSettingsValue ); - - if( aSettingsValue != aParameter.iArg1 ) - { - retval = KErrArgument; - } - } - break; - - case ETFGetSupportedHWDeviceSettings: - { - TUint32 aSettingsSupportedValue( 0 ); - - retval - = iAccessorySettings->GetSupportedHWDeviceSettings( aSettingsSupportedValue ); - - if( aSettingsSupportedValue != ( aParameter.iArg1 - | aParameter.iArg2 ) ) - { - retval = KErrArgument; - } - } - break; - - case ETFSetIntAccessoryModeSetting: - { - TAccMode aAccMode = ( TAccMode )aParameter.iArg1; - TAccModeSetting aSetting; - - //Set Lights - aSetting.SetId( aParameter.iArg2 ); - aSetting.SetTInt( aParameter.iArg4 ); - - retval = iAccessorySettings->SetAccessoryModeSettingL( aAccMode, - aSetting ); - } - break; - - case ETFSetBoolAccessoryModeSetting: - { - TAccMode aAccMode = ( TAccMode )aParameter.iArg1; - TAccModeSetting aSetting; - - //Set Lights - aSetting.SetId( aParameter.iArg2 ); - aSetting.SetTBool( aParameter.iArg4 ); - - retval = iAccessorySettings->SetAccessoryModeSettingL( aAccMode, - aSetting ); - } - break; - - case ETFSetDesAccessoryModeSetting: - { - TAccMode aAccMode = ( TAccMode )aParameter.iArg1; - TAccModeSetting aSetting; - - TBuf buf; - buf.Num( aParameter.iArg3 ); - // buf.Copy( *aParameter.iArg3 ); - - aSetting.SetId( aParameter.iArg2 ); - aSetting.SetTDes( buf ); - retval = iAccessorySettings->SetAccessoryModeSettingL( aAccMode, - aSetting ); - } - break; - - case ETFGetIntAccessoryModeSetting: - { - TInt aSettingsValueInt; - - TAccMode aAccMode = ( TAccMode )aParameter.iArg1; - TAccModeSetting aSetting; - aSetting.SetId( aParameter.iArg2 ); - - retval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, - aSetting ); - - if( aSetting.Type() == EAccModeSettingInt ) - { - retval = aSetting.GetTInt( aSettingsValueInt ); - - if( retval != KErrNotFound ) - { - if( aSettingsValueInt == aParameter.iArg4 ) - { - retval = KErrNone; - } - else - { - retval = KErrArgument; - } - } - } - else - { - retval = KErrNotFound; - } - } - break; - - case ETFGetBoolAccessoryModeSetting: - { - TBool aSettingsValueBool; - - TAccMode aAccMode = ( TAccMode )aParameter.iArg1; - TAccModeSetting aSetting; - aSetting.SetId( aParameter.iArg2 ); - - retval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, - aSetting ); - - if( aSetting.Type() == EAccModeSettingBool ) - { - retval = aSetting.GetTBool( aSettingsValueBool ); - - if( retval != KErrNotFound ) - { - if( aSettingsValueBool == ( TBool )aParameter.iArg4 ) - { - retval = KErrNone; - } - else - { - retval = KErrArgument; - } - } - } - else - { - retval = KErrNotFound; - } - } - break; - - case ETFGetDesAccessoryModeSetting: - { - TBuf aSettingsValueDes; - - TAccMode aAccMode = ( TAccMode )aParameter.iArg1; - TAccModeSetting aSetting; - aSetting.SetId( aParameter.iArg2 ); - - retval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, - aSetting ); - - if( aSetting.Type() == EAccModeSettingDes ) - { - retval = aSetting.GetTDes( aSettingsValueDes ); - - if( retval != KErrNotFound ) - { - TBuf buffer; - buffer.Num( aParameter.iArg3 ); - if( KErrNone == aSettingsValueDes.Compare( buffer ) ) - { - retval = KErrNone; - } - else - { - retval = KErrArgument; - } - } - } - else - { - retval = KErrNotFound; - } - } - break; - - case ETFSetSeveralAccessoryModeSetting: - { - - TAccModeSetting accModeSettingIn; - TAccMode tAccMode = EAccModeWirelessHeadset; - TBuf aDesIn; - // Set - // setting 1 - accModeSettingIn.SetId( 11 ); // unknown TInt - accModeSettingIn.SetTInt( 1 ); - TAccModeSettingArray arrayIn; - arrayIn.AddSetting( accModeSettingIn ); - - // setting 2 - accModeSettingIn.SetId( 12 ); // unknown Des - _LIT( KAccSetting2, "012345678901234567890" ); - aDesIn.Copy( KAccSetting2 ); - accModeSettingIn.SetTDes( aDesIn ); - arrayIn.AddSetting( accModeSettingIn ); - - // setting 3 - accModeSettingIn.SetId( 13 ); // unknown TBool - accModeSettingIn.SetTBool( ETrue ); - arrayIn.AddSetting( accModeSettingIn ); - - retval = iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, - arrayIn ); - - } - break; - - case ETFGetSeveralAccessoryModeSetting: - { - - TAccModeSetting accModeSettingOut; - TAccMode tAccMode = EAccModeWirelessHeadset; - TBuf aDesOut; - TAccModeSettingArray arrayOut; - TInt intOut( 0 ); - // set input parameters for GetAccessoryModeSettings() - // setting 11 - accModeSettingOut.SetId( 11 ); - arrayOut.AddSetting( accModeSettingOut ); - - // setting 12 - accModeSettingOut.SetId( 12 ); - arrayOut.AddSetting( accModeSettingOut ); - - // setting 13 - accModeSettingOut.SetId( 13 ); - arrayOut.AddSetting( accModeSettingOut ); - - retval = iAccessorySettings->GetAccessoryModeSettings( tAccMode, - arrayOut ); - - // Check that got settings are right - - TInt count = arrayOut.GetArraySize(); - TInt foundCount( 0 ); - - for( TInt index = 0; index < count; index++ ) - { - arrayOut.GetSetting( index, accModeSettingOut ); - - if( 11 == accModeSettingOut.Id() ) - { - - accModeSettingOut.GetTInt( intOut ); - - if( 1 == intOut ) - { - foundCount++; - } - } - - if( 12 == accModeSettingOut.Id() ) - { - accModeSettingOut.GetTDes( aDesOut ); - - if( KErrNone == aDesOut.Compare( _L("012345678901234567890") ) ) - { - foundCount++; - } - - } - - if( 13 == accModeSettingOut.Id() ) - { - - accModeSettingOut.GetTBool( intOut ); - - if( intOut ) - { - foundCount++; - } - } - } - - if( foundCount != 3 ) - { - retval = KErrNotFound; - } - - // - // Reset Settings - // - TAccModeSetting accModeSettingIn; - TBuf aDesIn; - // Set - // setting 1 - accModeSettingIn.SetId( 11 ); // unknown TInt - accModeSettingIn.SetTInt( 0 ); - TAccModeSettingArray arrayIn; - arrayIn.AddSetting( accModeSettingIn ); - - // setting 2 - accModeSettingIn.SetId( 12 ); // unknown Des - _LIT( KAccSetting2, "" ); - aDesIn.Copy( KAccSetting2 ); - accModeSettingIn.SetTDes( aDesIn ); - arrayIn.AddSetting( accModeSettingIn ); - - // setting 3 - accModeSettingIn.SetId( 13 ); // unknown TBool - accModeSettingIn.SetTBool( EFalse ); - arrayIn.AddSetting( accModeSettingIn ); - - iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, arrayIn ); - } - break; - - // - // Accessory Single Connection - // - case ETFAccessorySingleConnection_Open: - { - if( iAccessorySingleConnection == NULL ) - { - iAccessorySingleConnection - = new ( ELeave ) RAccessorySingleConnection; - retval - = iAccessorySingleConnection->CreateSubSession( iAccessoryServer ); - } - else - { - retval = KErrNone; - } - } - break; - - case ETFAccessorySingleConnection_Close: - { - TRACE_ASSERT( iAccessorySingleConnection != NULL ); - - if( iAccessorySingleConnection != NULL ) - { - iAccessorySingleConnection->CloseSubSession(); - delete iAccessorySingleConnection; - iAccessorySingleConnection = NULL; - } - retval = KErrNone; - } - break; - - case ETFAccessoryNotifyNewAccessoryConnected: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyNewAccessoryConnected( iGenericId[aParameter.iGid] ); - retval = KErrNone; - } - break; - - case ETFAccessoryNotifyAccessoryDisconnected: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyAccessoryDisconnected( iGenericId[aParameter.iGid] ); - retval = KErrNone; - } - break; - - case ETFNotifyIntAccessoryValueChanged: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyIntegerAccessoryValueChanged( iGenericId[aParameter.iGid], - aParameter.iArg3 ); - retval = KErrNone; - } - break; - - case ETFNotifyBoolAccessoryValueChanged: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyBooleanAccessoryValueChanged( iGenericId[aParameter.iGid], - aParameter.iArg3 ); - retval = KErrNone; - } - break; - - case ETFNotifyObjectAccessoryValueChanged: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyObjectAccessoryValueChanged( iGenericId[aParameter.iGid], - aParameter.iArg3 ); - retval = KErrNone; - } - break; - - case ETFAccessoryIntGetValue: - { - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TAccValueTypeTInt aIntValue; - - iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], - aNameRecord, - aIntValue ); - - if( aIntValue.iValue == aParameter.iArg2 ) - { - retval = KErrNone; - } - else - { - retval = KErrArgument; - } - } - break; - - case ETFAccessoryBoolGetValue: - { - RAccessoryConnection accessoryConnection; - accessoryConnection.CreateSubSession( iAccessoryServer ); - - TAccPolNameRecord nameRecord; - nameRecord.SetNameL( aParameter.iArg3 ); - TAccValueTypeTBool boolValue; - retval - = accessoryConnection.GetValueL( iGenericId[aParameter.iGid], - nameRecord, - boolValue ); - - if( boolValue.iValue != aParameter.iArg1 ) - { - retval = KErrArgument; - } - - accessoryConnection.CloseSubSession(); - } - break; - - case ETFAccessoryDes8GetValue: - { - TBuf8<80> - worm( _L8("Malicious Worm Attach with extra long data with extra long content" )); - TBuf8<85> valueBuf; - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg1 ); - TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, valueBuf ) ); - - if( err == aParameter.iExpectedResult ) - { - - if( aParameter.iExpectedResult == KErrArgument ) - { - retval = KErrNone; - } - else - { - if( KErrNone == valueBuf.Compare( worm ) ) - { - RDebug::RawPrint( valueBuf ); - retval = KErrNone; - } - else - { - retval = KErrArgument; - } - } - } - else - { - retval = KErrArgument; - } - } - break; - - case ETFAccessoryObjectParseTopology: - { - - TInt rspeaker( KErrGeneral ); - TInt lspeaker( KErrGeneral ); - TInt rmic( KErrGeneral ); - TInt lmic( KErrGeneral ); - TInt mute( KErrGeneral ); - TInt sidetone( KErrGeneral ); - // - // Find speaker volume object in USB headset case. - // - CAccPolAudioUnitBase* audioUnit = NULL; - CAccPolAudioControlBase* audioControl = NULL; - //CAccPolOutputTerminal* ouputTerminal = NULL; - - if( iTopologyContainer->OutputTerminalL( CAccPolOutputTerminal::EAPTHeadphone, - audioUnit ) ) - { - if( audioUnit->GetNextAudioUnitL( audioUnit ) ) - { - if( audioUnit->ObjectType() - == EAccPolAudioFeatureUnitObject ) - { - if( audioUnit->GetAudioControlL( EAccPolAudioVolumeControlObject, - KAccRightFrontChannel, - audioControl ) ) - { - iSpeakerRightVolume = CAccPolVolumeControl::NewL(); - *iSpeakerRightVolume - = *reinterpret_cast ( audioControl ); - rspeaker = KErrNone; - } - if( audioUnit->GetAudioControlL( EAccPolAudioVolumeControlObject, - KAccLeftFrontChannel, - audioControl ) ) - { - iSpeakerLeftVolume = CAccPolVolumeControl::NewL(); - *iSpeakerLeftVolume - = *reinterpret_cast ( audioControl ); - lspeaker = KErrNone; - } - if( audioUnit->GetAudioControlL( EAccPolAudioMuteControlObject, - KAccMasterChannel, - audioControl ) ) - { - iSpeakerMute = CAccPolMuteControl::NewL(); - *iSpeakerMute - = *reinterpret_cast ( audioControl ); - mute = KErrNone; - } - - } - } - } - - // - // Find mic volume object in USB headset case. - // - if( iTopologyContainer->OutputTerminalL( CAccPolOutputTerminal::EAPTStream, - audioUnit ) ) - { - do - { - } - while( audioUnit->GetNextAudioUnitL( audioUnit ) - && audioUnit->ObjectType() != EAccPolAudioFeatureUnitObject ); - - RPointerArray aAudioControls; - audioUnit->GetAudioControlsL( KAccRightFrontChannel, - aAudioControls ); - - if( aAudioControls.Count() > 0 ) - { - iMicRightVolume = CAccPolVolumeControl::NewL(); - *iMicRightVolume - = *reinterpret_cast ( aAudioControls.operator[]( 0 ) ); - rmic = KErrNone; - } - aAudioControls.Reset(); - - audioUnit->GetAudioControlsL( KAccLeftFrontChannel, - aAudioControls ); - - if( aAudioControls.Count() > 0 ) - { - iMicLeftVolume = CAccPolVolumeControl::NewL(); - *iMicLeftVolume - = *reinterpret_cast ( aAudioControls.operator[]( 0 ) ); - lmic = KErrNone; - } - - // - // Find sidetone volume object in USB headset case. - // - iTopologyContainer->OutputTerminalL( CAccPolOutputTerminal::EAPTHeadphone, - audioUnit ); - - do - { - audioUnit->GetNextAudioUnitL( audioUnit ); - } - while( audioUnit->ObjectType() != EAccPolAudioMixerUnitObject ); - - if( audioUnit->SourceIdCount() > 1 ) - { - RPointerArray aAudioUnits; - audioUnit->GetAudioUnitListL( aAudioUnits ); - - for( TInt i = 0; i < aAudioUnits.Count(); i++ ) - { - if( aAudioUnits.operator[]( i )->ObjectType() - == EAccPolAudioFeatureUnitObject ) - { - audioUnit = aAudioUnits.operator[]( i ); - break; - } - } - } - - aAudioControls.Reset(); - audioUnit->GetAudioControlsL( aAudioControls ); - if( aAudioControls.Count() == 2 ) - { - sidetone = KErrNone; - } - } - - retval = ( rspeaker | lspeaker | rmic | lmic | mute | sidetone ); - - } - break; - - case ETFAccessoryGetStreamObjects: - { - if( iStreamContainer != NULL ) - { - delete iStreamContainer; - iStreamContainer = NULL; - } - iStreamContainer = CAccPolAudioStreamFormatCon::NewL(); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iStreamContainer ) ); - - if( err == aParameter.iExpectedResult ) - { - //externalize container to bufFromASY - CBufFlat* bufFromASY = - CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( bufFromASY ); - bufFromASY->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - RBufWriteStream wStrm; - ( void )wStrm.Open( *bufFromASY ); - wStrm.PushL(); - iStreamContainer->ExternalizeL( wStrm ); - wStrm.CommitL(); - wStrm.Close(); - wStrm.Pop(); - TPtr8 ptrbufFromASY( bufFromASY->Ptr( 0 ) ); - - //Read container from PubSub - RProperty prop; - RBufReadStream rStrm; - CBufFlat* bufFromPubSub = - CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( bufFromPubSub ); - bufFromPubSub->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - TPtr8 ptrBufFromPubSub( bufFromPubSub->Ptr( 0 ) ); - TInt ret = prop.Get( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - ptrBufFromPubSub ); - - TInt k = sizeof( bufFromASY ); - TInt kk = sizeof( bufFromPubSub ); - - bufFromASY->Compress(); - bufFromPubSub->Compress(); - - k = sizeof( bufFromASY ); - kk = sizeof( bufFromPubSub ); - - retval - = ( 0 - == memcompare( reinterpret_cast ( &ptrbufFromASY ), - sizeof( bufFromASY ), - reinterpret_cast ( &ptrBufFromPubSub ), - sizeof( bufFromASY ) ) ) ? KErrNone : KErrGeneral; - - CleanupStack::PopAndDestroy( bufFromPubSub ); - CleanupStack::PopAndDestroy( bufFromASY ); - } - } - break; - - case ETFAccessoryGetStreamObjectsFromPolicy: - { - if( iStreamContainer != NULL ) - { - delete iStreamContainer; - iStreamContainer = NULL; - } - iStreamContainer = CAccPolAudioStreamFormatCon::NewL(); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iStreamContainer ) ); - - RPointerArray inputStreamObjects; - RPointerArray outputStreamObjects; - - iStreamContainer->GetInputStreamFormatsL( inputStreamObjects ); - iStreamContainer->GetOutputStreamFormatsL( outputStreamObjects ); - - CAccPolAudioStreamFormat* inputStream = - inputStreamObjects.operator[]( 0 ); - CAccPolAudioStreamFormat* ouputStream = - outputStreamObjects.operator[]( 0 ); - - retval = err; - } - break; - - case ETFAccessorySetStreamObjects: - { - CAccPolAudioStreamFormatCon* setContainer = CAccPolAudioStreamFormatCon::NewLC(); - - RPointerArray inputStreamObjects; - RPointerArray outputStreamObjects; - - iStreamContainer->GetInputStreamFormatsL( inputStreamObjects ); - CAccPolAudioStreamFormat* inputStream = NULL; - for(TInt i=0; iAudioFormat() == KUidFormatPCM16 && - inputStream->UnitId() == 0 && - inputStream->StreamType() == CAccPolAudioStreamFormat::EStereo && - inputStream->BitResolution() == CAccPolAudioStreamFormat::EBitsPerSample16 && - inputStream->SamFreq() == 200 ) - { - setContainer->AddL( *inputStream ); - break; - } - } - - iStreamContainer->GetOutputStreamFormatsL( outputStreamObjects ); - CAccPolAudioStreamFormat* outputStream = NULL; - for(TInt i=0; iAudioFormat() == KUidFormatPCM16 && - outputStream->UnitId() == 0 && - outputStream->StreamType() == CAccPolAudioStreamFormat::EMono && - outputStream->BitResolution() == CAccPolAudioStreamFormat::EBitsPerSample32 && - outputStream->SamFreq() == 200 ) - { - setContainer->AddL( *outputStream ); - break; - } - } - - RBufWriteStream wStrm; - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - (void)wStrm.Open( *buf ); - wStrm.PushL(); - setContainer->ExternalizeL( wStrm ); - wStrm.Close(); - wStrm.Pop(); - TPtr8 ptr( buf->Ptr( 0 ) ); - - retval = RProperty::Set( KTFAccessoryTestProperty, KTFAccessoryObjectMethod, ptr ); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - - TRAPD( setErr, iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, *setContainer ) ); - - retval = setErr; - - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( setContainer ); - inputStreamObjects.Close(); - outputStreamObjects.Close(); - } - break; - - case ETFAccessoryGetTopologyObjects: - { - if( iTopologyContainer != NULL ) - { - delete iTopologyContainer; - iTopologyContainer = NULL; - } - - iTopologyContainer = CAccPolAudioTopologyObjectCon::NewL(); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iTopologyContainer ) ); - - if( err == aParameter.iExpectedResult ) - { - //externalize container to bufFromASY - CBufFlat* bufFromASY = - CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( bufFromASY ); - bufFromASY->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - RBufWriteStream wStrm; - ( void )wStrm.Open( *bufFromASY ); - wStrm.PushL(); - iTopologyContainer->ExternalizeL( wStrm ); - wStrm.CommitL(); - wStrm.Close(); - wStrm.Pop(); - TPtr8 ptrbufFromASY( bufFromASY->Ptr( 0 ) ); - - //Read container from PubSub - RProperty prop; - RBufReadStream rStrm; - CBufFlat* bufFromPubSub = - CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( bufFromPubSub ); - bufFromPubSub->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - TPtr8 ptrBufFromPubSub( bufFromPubSub->Ptr( 0 ) ); - TInt ret = prop.Get( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - ptrBufFromPubSub ); - - TInt k = sizeof( bufFromASY ); - TInt kk = sizeof( bufFromPubSub ); - - bufFromASY->Compress(); - bufFromPubSub->Compress(); - - k = sizeof( bufFromASY ); - kk = sizeof( bufFromPubSub ); - - retval - = ( 0 - == memcompare( reinterpret_cast ( &ptrbufFromASY ), - sizeof( bufFromASY ), - reinterpret_cast ( &ptrBufFromPubSub ), - sizeof( bufFromASY ) ) ) ? KErrNone : KErrGeneral; - - CleanupStack::PopAndDestroy( bufFromPubSub ); - CleanupStack::PopAndDestroy( bufFromASY ); - } - } - break; - - case ETFAccessoryGetVolumeControlObjects: - { - - if( iTopologyContainer != NULL ) - { - delete iTopologyContainer; - iTopologyContainer = NULL; - } - - iTopologyContainer = CAccPolAudioTopologyObjectCon::NewL(); - - iTopologyContainer->AddL( *iSpeakerRightVolume ); - iTopologyContainer->AddL( *iSpeakerLeftVolume ); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iTopologyContainer ) ); - - CAccPolVolumeControl* rightVolume; - rightVolume = ( CAccPolVolumeControl* )iTopologyContainer->AtL( 0 ); - - CAccPolVolumeControl* leftVolume; - leftVolume = ( CAccPolVolumeControl* )iTopologyContainer->AtL( 1 ); - - if( err == aParameter.iExpectedResult ) - { - retval = KErrNone; - } - } - break; - - case ETFAccessorySetVolumeControlObjects: - { - RBufWriteStream wStrm; - CAccPolAudioTopologyObjectCon* setContainer = - CAccPolAudioTopologyObjectCon::NewLC(); - - iSpeakerRightVolume->SetVolumeDb( aParameter.iArg1 ); - iSpeakerRightVolume->SetMinVolumeDb( aParameter.iArg2 ); - iSpeakerRightVolume->SetMaxVolumeDb( aParameter.iArg4 ); - iSpeakerRightVolume->SetVolumeResDb( 0x05 ); - setContainer->AddL( *iSpeakerRightVolume ); - iSpeakerLeftVolume->SetVolumeDb( aParameter.iArg1 ); - iSpeakerLeftVolume->SetMinVolumeDb( aParameter.iArg2 ); - iSpeakerLeftVolume->SetMaxVolumeDb( aParameter.iArg4 ); - iSpeakerLeftVolume->SetVolumeResDb( 0x05 ); - setContainer->AddL( *iSpeakerLeftVolume ); - - CBufFlat* buf = - CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - ( void )wStrm.Open( *buf ); - wStrm.PushL(); - setContainer->ExternalizeL( wStrm ); - wStrm.Close(); - wStrm.Pop(); - TPtr8 ptr( buf->Ptr( 0 ) ); - - retval = RProperty::Set( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - ptr ); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TRAPD( setErr, iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, *setContainer ) ); - - retval = setErr; - - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( setContainer ); - } - break; - - case ETFAccessoryGetMuteControlObjects: - { - - if( iTopologyContainer != NULL ) - { - delete iTopologyContainer; - iTopologyContainer = NULL; - } - - iTopologyContainer = CAccPolAudioTopologyObjectCon::NewL(); - - iTopologyContainer->AddL( *iSpeakerMute ); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iTopologyContainer ) ); - - CAccPolMuteControl* mute; - mute = ( CAccPolMuteControl* )iTopologyContainer->AtL( 0 ); - - if( err == aParameter.iExpectedResult ) - { - retval = KErrNone; - } - } - break; - - case ETFAccessorySetMuteControlObjects: - { - RBufWriteStream wStrm; - CAccPolAudioTopologyObjectCon* setContainer = - CAccPolAudioTopologyObjectCon::NewLC(); - - iSpeakerMute->SetMute( aParameter.iArg1 ); - setContainer->AddL( *iSpeakerMute ); - - CBufFlat* buf = - CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - ( void )wStrm.Open( *buf ); - wStrm.PushL(); - setContainer->ExternalizeL( wStrm ); - wStrm.Close(); - wStrm.Pop(); - TPtr8 ptr( buf->Ptr( 0 ) ); - - retval = RProperty::Set( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - ptr ); - - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TRAPD( setErr, iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, *setContainer ) ); - - retval = setErr; - - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( setContainer ); - } - break; - - // - // Accessory Control - // - - case ETFAccessoryControl_Open: - { - if( iAccessoryControl == NULL ) - { - iAccessoryControl = new ( ELeave ) RAccessoryControl; - retval = iAccessoryControl->CreateSubSession( iAccessoryServer ); - } - else - { - retval = KErrNone; - } - } - break; - - case ETFAccessoryControl_Close: - { - TRACE_ASSERT( iAccessoryControl != NULL ); - - if( iAccessoryControl != NULL ) - { - iAccessoryControl->CloseSubSession(); - delete iAccessoryControl; - iAccessoryControl = NULL; - } - retval = KErrNone; - } - break; - - case ETFAccessoryNotifyAccessoryConnectionStatusChanged: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyAccessoryConnectionStatusChanged( iGenericIdArray ); - retval = KErrNone; - } - break; - - case ETFSyncGetAccessoryConnectionStatus: - { - iAccessoryConnection->GetAccessoryConnectionStatus( iGenericIdArray ); - - if( iGenericIdArray.Count() != aParameter.iArg1 ) - { - retval = KErrArgument; - } - else - { - retval = KErrNone; - } - } - break; - - case ETFASyncGetAccessoryConnectionStatus: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->GetAccessoryConnectionStatus( iGenericIdArray ); - retval = KErrNone; - } - break; - - case ETFSetIntValue: - { - SetIntValue(aParameter, &retval); - } - break; - - case ETFSetBoolValue: - { - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TAccValueTypeTBool aBoolValue; - aBoolValue.iValue = aParameter.iArg1; - retval = iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], - aNameRecord, - aBoolValue ); - } - break; - - // - //Tuupaa - // - case ETFAccessoryValueChangedNotifyInt: - { - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( KAccAudioOutputType ); - TAccValueTypeTInt aIntValue; - aIntValue.iValue = EAccAudioOutPutTypePublic; - iAccessoryControl->AccessoryValueChangedNotifyL( iGenericId[aParameter.iGid], - aNameRecord, - aIntValue ); - retval = KErrNone; - } - break; - - case ETFAccessoryValueChangedNotifyBool: - { - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TAccValueTypeTBool aBoolValue; - aBoolValue.iValue = ETrue; - iAccessoryControl->AccessoryValueChangedNotifyL( iGenericId[aParameter.iGid], - aNameRecord, - aBoolValue ); - retval = KErrNone; - } - break; - - // - // BT Control - // - case ETFBTAccessoryValueChangedNotifyBool: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - TAccPolNameRecord nameRecord; - nameRecord.SetNameL( aParameter.iArg3 ); - TAccValueTypeTBool boolValue; - boolValue.iValue = aParameter.iArg4; - iAccessoryBTControl->AccessoryValueChangedNotifyL( btaddr, - nameRecord, - boolValue ); - retval = KErrNone; - } - break; - - case ETFBTAccessoryValueChangedNotifyInt: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - TAccPolNameRecord nameRecord; - nameRecord.SetNameL( aParameter.iArg3 ); - TAccValueTypeTInt intValue; - intValue.iValue = aParameter.iArg4; - iAccessoryBTControl->AccessoryValueChangedNotifyL( btaddr, - nameRecord, - intValue ); - retval = KErrNone; - } - break; - - case ETFAccessoryBtControl_Open: - { - if( iAccessoryBTControl == NULL ) - { - iAccessoryBTControl = new ( ELeave ) RAccessoryBTControl; - retval - = iAccessoryBTControl->CreateSubSession( iAccessoryServer ); - } - else - { - retval = KErrNone; - } - } - break; - - case ETFAccessoryBtControl_Close: - { - TRACE_ASSERT( iAccessoryBTControl != NULL ); - - if( iAccessoryBTControl != NULL ) - { - iAccessoryBTControl->CloseSubSession(); - delete iAccessoryBTControl; - iAccessoryBTControl = NULL; - } - retval = KErrNone; - } - break; - - case ETFAccessoryBtConnectAccessory: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->ConnectBTAccessory( btaddr ); - retval = KErrNone; - } - break; - case ETFAccessoryBtDisconnectAccessory: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - TRequestStatus status; - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->DisconnectBTAccessory( btaddr ); - retval = KErrNone; - TAccPolGenericID emptyInstance; - iGenericId[aParameter.iGid] = emptyInstance; - } - break; - - case ETFAccessoryNotifyBluetoothAudioLinkOpenReq: - { - //TRequestStatus status; - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyBluetoothAudioLinkOpenReq(); - retval = KErrNone; - } - break; - - case ETFAccessoryBluetoothAudioLinkOpenedNotify: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkOpenedNotifyL( btaddr, (TAccAudioType)aParameter.iArg3 ) ); - - if( err == aParameter.iExpectedResult ) - { - retval = KErrNone; - } - else - { - retval = KErrGeneral; - } - } - break; - - case ETFAccessoryBluetoothAudioLinkOpenResp: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - TInt response( aParameter.iArg2 ); - TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkOpenRespL( btaddr, response ) ); - - if( err == aParameter.iExpectedResult ) - { - retval = KErrNone; - } - else - { - retval = KErrGeneral; - } - } - break; - - case ETFAccessoryNotifyBluetoothAudioLinkCloseReq: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyBluetoothAudioLinkCloseReq(); - retval = KErrNone; - } - break; - - case ETFAccessoryBluetoothAudioLinkClosedNotify: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkClosedNotifyL( btaddr, ( TAccAudioType )aParameter.iArg3 ) ); - - if( err == aParameter.iExpectedResult ) - { - retval = KErrNone; - } - else - { - retval = KErrGeneral; - } - } - break; - - case ETFAccessoryBluetoothAudioLinkCloseResp: - { - TBTDevAddr btaddr( aParameter.iArg1 ); - TInt response( aParameter.iArg2 ); - TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkCloseRespL( btaddr, response ) ); - - if( err == aParameter.iExpectedResult ) - { - retval = KErrNone; - } - else - { - retval = KErrGeneral; - } - } - break; - - case ETFAccessoryBtCancelConnectAccessory: - { - TRequestStatus status; - TBTDevAddr btaddr( aParameter.iArg1 ); - iAccessoryBTControl->ConnectAccessory( status, btaddr ); - iAccessoryBTControl->CancelConnectAccessory(); - User::WaitForRequest( status ); - if( KErrCancel != status.Int() ) - { - retval = status.Int(); - } - else - { - retval = KErrNone; - } - } - break; - - case ETFAccessoryBtCancelDisconnectAccessory: - { - TRequestStatus status; - TBTDevAddr btaddr( aParameter.iArg1 ); - iAccessoryBTControl->DisconnectAccessory( status, btaddr ); - iAccessoryBTControl->CancelDisconnectAccessory(); - User::WaitForRequest( status ); - retval = status.Int(); - } - break; - - // - // Accessory Mode - // - case ETFAccessoryMode_Open: - { - if( iAccessoryMode == NULL ) - { - iAccessoryMode = new ( ELeave ) RAccessoryMode; - retval = iAccessoryMode->CreateSubSession( iAccessoryServer ); - } - else - { - retval = KErrNone; - } - } - break; - - case ETFAccessoryMode_Close: - { - TRACE_ASSERT( iAccessoryMode != NULL ); - - if( iAccessoryMode != NULL ) - { - iAccessoryMode->CloseSubSession(); - delete iAccessoryMode; - iAccessoryMode = NULL; - } - retval = KErrNone; - } - break; - - case ETFAccessoryNotifyAccessoryModeChanged: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyAccessoryModeChanged(); - retval = KErrNone; - } - break; - - case ETFAccessoryAccessoryModeSync: - { - TAccPolAccessoryMode mode; - retval = iAccessoryMode->GetAccessoryMode( mode ); - - if( retval == KErrNone ) - { - if( aParameter.iArg1 != mode.iAccessoryMode ) - { - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Unexpected Accessory Mode Parameter1 %d %d" ), aParameter.iArg1, mode.iAccessoryMode ) ); - retval = KTFErrAccessoryUnexpectedArg1; - } -#ifdef __WINS__ // Just check this in winscw - if( aParameter.iArg2 != mode.iAudioOutputStatus ) - { - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Unexpected Accessory Mode Parameter2 %d %d" ), aParameter.iArg2, mode.iAudioOutputStatus ) ); - retval = KTFErrAccessoryUnexpectedArg2; - } -#endif - } - else - { - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Getting Accessory Mode Failed %d" ), retval ) ); - } - - } - break; - - case ETFAccessoryAccessoryModeASync: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->GetAccessoryMode(); - retval = KErrNone; - } - break; - - // - // Audio Control - // - case ETFAccessoryAudioControl_Open: - { - if( iAccessoryAudioControl == NULL ) - { - iAccessoryAudioControl = new ( ELeave ) RAccessoryAudioControl; - retval - = iAccessoryAudioControl->CreateSubSession( iAccessoryServer ); - } - else - { - retval = KErrNone; - } - } - break; - - case ETFAccessoryAudioControl_Close: - { - TRACE_ASSERT( iAccessoryAudioControl != NULL ); - - if( iAccessoryAudioControl != NULL ) - { - iAccessoryAudioControl->CloseSubSession(); - delete iAccessoryAudioControl; - iAccessoryAudioControl = NULL; - } - retval = KErrNone; - } - break; - - case ETFAudioRoutingStatusNotify: - { - RAccessoryAudioControl audioControl; - audioControl.CreateSubSession( iAccessoryServer ); - - audioControl.AudioRoutingStatusNotify( aParameter.iArg1, - iGenericId[aParameter.iGid] ); - retval = KErrNone; - - audioControl.CloseSubSession(); - } - break; - - case ETFAccessoryAudioLinkOpen: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->AccessoryAudioLinkOpen( iGenericId[aParameter.iGid], - aParameter.iArg3 ); - retval = KErrNone; - } - break; - - case ETFAccessoryNotifyAccessoryAudioLinkOpened: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyAccessoryAudioLinkOpened( iGenericId[aParameter.iGid] ); - retval = KErrNone; - } - break; - - case ETFAccessoryNotifyAccessoryAudioLinkClosed: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->NotifyAccessoryAudioLinkClosed( iGenericId[aParameter.iGid] ); - retval = KErrNone; - } - break; - - case ETFAccessoryAccessoryAudioLinkClose: - { - CTFTestControlObserver* aConnectionObserver = CreateObserver(); - TRACE_ASSERT( aConnectionObserver != NULL ); - aConnectionObserver->AccessoryAudioLinkClose( iGenericId[aParameter.iGid], - aParameter.iArg3 ); - retval = KErrNone; - } - break; - - case ETFAccessoryPublishAndSubscribe: - { - PublishAndSubscribeL( aParameter ); - retval = KErrNone; - } - break; - - case ETFAccessory_Cancel: - { - CTFTestControlObserver* item; - if( !iStack.IsEmpty() ) - { - item = iStack.First(); - item->Cancel(); - } - retval = KErrNone; - } - break; - - // - // Cancels - // - case ETFCancelAccessoryAudioLinkOpen: - { - iAccessoryAudioControl->CancelAccessoryAudioLinkOpen(); - retval = KErrNone; - } - break; - - case ETFCancelAccessoryAudioLinkClose: - { - iAccessoryAudioControl->CancelAccessoryAudioLinkClose(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyAccessoryAudioLinkOpened: - { - iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkOpened(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyAccessoryAudioLinkClosed: - { - iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkClosed(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyProcessCommand: - { - TRACE_ASSERT_ALWAYS; - } - break; - - case ETFCancelConnectAccessory: - { - iAccessoryControl->CancelConnectAccessory(); - retval = KErrNone; - } - break; - - case ETFCancelDisconnectAccessory: - { - iAccessoryControl->CancelDisconnectAccessory(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyBluetoothAudioLinkOpenReq: - { - iAccessoryBTControl->CancelNotifyBluetoothAudioLinkOpenReq(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyBluetoothAudioLinkCloseReq: - { - iAccessoryBTControl->CancelNotifyBluetoothAudioLinkCloseReq(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyAccessoryConnectionStatusChanged: - { - iAccessoryConnection->CancelNotifyAccessoryConnectionStatusChanged(); - retval = KErrNone; - } - break; - - case ETFCancelGetAccessoryConnectionStatus: - { - iAccessoryConnection->CancelGetAccessoryConnectionStatus(); - retval = KErrNone; - } - break; - - case ETFCancelConnectAccessoryBT: - { - iAccessoryBTControl->CancelConnectAccessory(); - retval = KErrNone; - } - break; - - case ETFCancelDisconnectAccessoryBT: - { - iAccessoryBTControl->CancelDisconnectAccessory(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyAccessoryModeChanged: - { - iAccessoryMode->CancelNotifyAccessoryModeChanged(); - retval = KErrNone; - } - break; - - case ETFCancelGetAccessoryMode: - { - iAccessoryMode->CancelGetAccessoryMode(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyNewAccessoryConnected: - { - iAccessorySingleConnection->CancelNotifyNewAccessoryConnected(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyAccessoryDisconnected: - { - iAccessorySingleConnection->CancelNotifyAccessoryDisconnected(); - retval = KErrNone; - } - break; - - case ETFCancelNotifyAccessoryValueChanged: - { - TAccPolNameRecord nameRecord; - nameRecord.SetNameL( aParameter.iArg3 ); - iAccessorySingleConnection->CancelNotifyAccessoryValueChanged( nameRecord ); - retval = KErrNone; - } - break; - - case ETFSelectionDialogText: - { - SelectionDialog(ETFSelectionDialogText, &retval); - } - break; - - case ETFSelectionDialogCancel: - { - SelectionDialog(ETFSelectionDialogCancel, &retval); - } - break; - - case ETFNotSupportedNote: - { - TUid KAccFwUiNoteNotifierUid = - { - 0x10205061 - }; - RNotifier notifier; - notifier.Connect(); - - TInt err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, - KNullDesC8 ); - - TInt value( 0 ); - TPckg intPckg( value ); - notifier.Close(); - - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - value = 1; - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - value = value << 1; - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - value = value << 1; - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - value = value << 1; - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - value = value << 1; - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - value = value << 1; - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - value = value << 1; - notifier.Connect(); - err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); - notifier.Close(); - - retval = KErrNone; - } - break; - - case ETFValueRecordTests: - { - retval = TestValueRecordL(); - } - break; - - case ETFObjectBaseSerializationTests: - { - retval = TestBaseSerializationL(); - } - break; - - case ETFCheckConnectedAccessory: - { - CheckConnectedAccessory(&retval); - } - break; - - case ETFCallTClassMethods: - { - CallTClassMethods(&retval); \ - } - - case ETFSetHdmiObject_PubSub: - { - CreateHdmiObjectsToPubSubL( aParameter ); - retval = KErrNone; - break; - } - - case ETFGetHdmiObject: - { - TInt err = KErrNone; - TAccPolNameRecord nameRecord; - nameRecord.SetNameL( aParameter.iArg3 ); - - // Create HDMI container - CAccPolHdmiObjectCon* conFromASY = CAccPolHdmiObjectCon::NewLC(); - CAccPolHdmiObjectCon* conFromPS = CAccPolHdmiObjectCon::NewLC(); - - // Get HDMI container - TRAP( err, iAccessorySingleConnection->GetValueL( - iGenericId[aParameter.iGid], nameRecord, *conFromASY ) ); - - // Get HDMI container from P&S - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - TPtr8 bufPtr( buf->Ptr( 0 ) ); - err = RProperty::Get( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - bufPtr ); - if( err == KErrNone ) - { - RBufReadStream readStream( *buf ); - readStream.PushL(); - conFromPS->InternalizeL( readStream ); - CleanupStack::PopAndDestroy( &readStream ); - } - switch( aParameter.iArg3 ) - { - case KAccVideoHdmiAttributes: - { - // Validate object count - if( conFromASY->Count() != conFromPS->Count() ) - { - err = KErrArgument; - } - - // Validate speaker allocation - RAccPolHdmiSpeakerAllocationArray array; - CleanupClosePushL( array ); - conFromASY->GetHdmiSpeakerAllocationObjectsL( array ); - if( array.Count() ) - { - CAccPolHdmiSpeakerAllocation* speakerAllocation = array[0]; - TUint32 bits = speakerAllocation->SpeakerAllocation(); - - // Speaker allocation should be EHdmiSpeakerUnknown - if( bits != CAccPolHdmiSpeakerAllocation::EHdmiSpeakerUnknown ) - { - err = KErrArgument; - } - - // Speaker count should be zero - if( speakerAllocation->SpeakerCount() ) - { - err = KErrArgument; - } - } - CleanupStack::PopAndDestroy( &array ); - break; - } - case KAccVideoFormat: - { - // Validate object count - if( conFromASY->Count() != conFromPS->Count() ) - { - err = KErrArgument; - } - - // Validate video format - RAccPolHdmiVideoFormatArray array; - CleanupClosePushL( array ); - conFromASY->GetHdmiVideoFormatObjectsL( array ); - if( array.Count() ) - { - CAccPolHdmiVideoFormat* videoFormat = array[0]; - - // Interlaced video should be enabled - if( !videoFormat->Interlaced() ) - { - err = KErrArgument; - } - } - else - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( &array ); - break; - } - default: - { - break; - } - } - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( conFromPS ); - CleanupStack::PopAndDestroy( conFromASY ); - retval = err; - break; - } - - case ETFCheckHdmiObject: - { - TInt err = KErrNone; - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Check HDMI object %d" ), - aParameter.iArg1 ) ); - switch( aParameter.iArg1 ) - { - case EAccPolHdmiObjectCon: - { - err = CheckHdmiContainerObjectL(); - break; - } - case EAccPolHdmiSinkObject: - { - err = CheckHdmiSinkObjectL(); - break; - } - case EAccPolHdmiAudioFormatObject: - { - err = CheckHdmiAudioFormatObjectL(); - break; - } - case EAccPolHdmiLatencyObject: - { - err = CheckHdmiLatencyObjectL(); - break; - } - case EAccPolHdmiSpeakerAllocationObject: - { - err = CheckHdmiSpeakerAllocationObjectL(); - break; - } - case EAccPolHdmiVideoFormatObject: - { - err = CheckHdmiVideoFormatObjectL(); - break; - } - default: - { - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Invalid HDMI object=%d" ), - aParameter.iArg1 ) ); - err = KErrArgument; - break; - } - } - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Check HDMI object %d returned with code %d" ), - aParameter.iArg1, err ) ); - retval = err; - break; - } - - default: - TRACE_ASSERT_ALWAYS; - break; - - } - User::LeaveIfError( retval ); - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::TestValueRecordL() -// ---------------------------------------------------------------------------------- -// -TInt CTFAccessoryTestControl::TestValueRecordL() - { - TInt ret( KErrNone ); - - TAccPolValueRecord valueRecord; - TBuf8 eci; - TBuf8 check; - _LIT( Kissa, "Kissa" ); - eci.Copy( Kissa ); - - valueRecord.SetValue( eci ); - check.Copy( valueRecord.ValueRef() ); - - if( KErrNone != eci.Compare( check ) ) - { - User::Leave( KErrGeneral ); - } - - TDesC8& test( valueRecord.ValueRef() ); - if( KErrNone != eci.Compare( test ) ) - { - User::Leave( KErrGeneral ); - } - - return ret; - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::TestBaseSerializationL() -// ---------------------------------------------------------------------------------- -// -TInt CTFAccessoryTestControl::TestBaseSerializationL() - { - TInt ret( KErrNone ); - TInt err( KErrNone ); - - /*** One container *************************************************************/ - CAccPolAudioStreamFormatCon* container1 = - CAccPolAudioStreamFormatCon::NewLC(); - CAccPolAudioStreamFormatCon* container2 = - CAccPolAudioStreamFormatCon::NewLC(); - - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - //Externalize to buf - RBufWriteStream wStrm; - ( void )wStrm.Open( *buf ); - wStrm.PushL(); - container1->ExternalizeL( wStrm ); - wStrm.CommitL(); - wStrm.Close(); - wStrm.Pop(); - - //Internalize from buf - RBufReadStream rStrm; - ( void )rStrm.Open( *buf ); - rStrm.PushL(); - container2->InternalizeL( rStrm ); - rStrm.Close(); - rStrm.Pop(); - - //container1 content must equal to container2 content - err = ( 0 == memcompare( reinterpret_cast ( container1 ), - sizeof(CAccPolObjectCon), - reinterpret_cast ( container2 ), - sizeof(CAccPolObjectCon) ) ) ? KErrNone : KErrGeneral; - User::LeaveIfError( err ); - - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( container2 ); - CleanupStack::PopAndDestroy( container1 ); - container2 = NULL; - container1 = NULL; - /* end *************************************************************************/ - - //Make test again! - - CAccPolAudioStreamFormat* audioStream1 = - CAccPolAudioStreamFormat::NewLC( EAccPolAudioInputStreamObject, - 15, - KUidFormatMP3, - CAccPolAudioStreamFormat::EStereo, - CAccPolAudioStreamFormat::EBitsPerSample24, - 11 ); - - buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - //Externalize to buf - ( void )wStrm.Open( *buf ); - wStrm.PushL(); - audioStream1->ExternalizeL( wStrm ); - wStrm.CommitL(); - wStrm.Close(); - wStrm.Pop(); - - //Internalize from buf - ( void )rStrm.Open( *buf ); - rStrm.PushL(); - - TInt objectid = rStrm.ReadUint8L(); - - if( ( TStreamConObjectType )objectid == EAccPolAudioInputStreamObject ) - { - CAccPolAudioStreamFormat* audioStream2 = - CAccPolAudioStreamFormat::NewLC( EAccPolAudioInputStreamObject ); - - audioStream2->InternalizeL( rStrm ); - - //audioStream1 content must equal to audioStream2 content - err = ( 0 == memcompare( reinterpret_cast ( audioStream1 ), - sizeof(CAccPolAudioStreamFormat), - reinterpret_cast ( audioStream2 ), - sizeof(CAccPolAudioStreamFormat) ) ) ? KErrNone : KErrGeneral; - - User::LeaveIfError( err ); - - CleanupStack::PopAndDestroy( audioStream2 ); - - rStrm.Close(); - rStrm.Pop(); - - } - else - { - User::LeaveIfError( KErrGeneral ); - } - - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( audioStream1 ); - audioStream1 = NULL; - /* end *************************************************************************/ - - return ret; - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::PublishAndSubscribeL() -// ---------------------------------------------------------------------------------- -// -void CTFAccessoryTestControl::PublishAndSubscribeL( TTFAccessoryTestCaseStateControl& aParameter ) - { - TPckgBuf buf; - - buf().iTestCaseID = aParameter.iTestCaseID; - buf().iMethod = aParameter.iMethod; - buf().iParam1 = aParameter.iArg1; - buf().iTimeMs = aParameter.iArg4; - buf().iGenericID = iGenericId[aParameter.iGid]; - - // Send capability to stub(s). - - // if( aParameter.iArg3 ) - // { - buf().iParam2 = aParameter.iArg3; - // } - - /* - if( aParameter.iArg3->Compare( KNullDesC ) ) - { - buf().iParam2.Copy( *aParameter.iArg3 ); - } - - */ - User::LeaveIfError( iSubscribe.Set( KTFAccessoryTestProperty, - KTFAccessoryMethod, - buf ) ); - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CreateHdmiObjectsToPubSubL() -// ---------------------------------------------------------------------------------- -// -void CTFAccessoryTestControl::CreateHdmiObjectsToPubSubL( - TTFAccessoryTestCaseStateControl& aParameter ) - { - // Define property just in case - RProperty::Define( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - RProperty::EByteArray ); - - // Create HDMI container - CAccPolHdmiObjectCon* con = CAccPolHdmiObjectCon::NewLC(); - switch( aParameter.iArg3 ) - { - case KAccVideoHdmiAttributes: - { - // Create audio format object - CreateHdmiObjectL( *con, EAccPolHdmiAudioFormatObject ); - - // Create latency object - CreateHdmiObjectL( *con, EAccPolHdmiLatencyObject ); - - // Create sink object - CreateHdmiObjectL( *con, EAccPolHdmiSinkObject ); - - // Create speaker allocation object - CreateHdmiObjectL( *con, EAccPolHdmiSpeakerAllocationObject ); - - // Create video format object - CreateHdmiObjectL( *con, EAccPolHdmiVideoFormatObject ); - break; - } - case KAccVideoFormat: - { - // Create video format object - CreateHdmiObjectL( *con, EAccPolHdmiVideoFormatObject ); - break; - } - default: - { - break; - } - } - // Stream HDMI container to P&S - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - RBufWriteStream writeStream( *buf ); - writeStream.PushL(); - con->ExternalizeL( writeStream ); - writeStream.CommitL(); - CleanupStack::PopAndDestroy( &writeStream ); - - TPtr8 bufPtr( buf->Ptr( 0 ) ); - TInt err = RProperty::Set( KTFAccessoryTestProperty, - KTFAccessoryObjectMethod, - bufPtr ); - User::LeaveIfError( err ); - - // Check if ASY stub needs to be informed - if( aParameter.iArg2 ) - { - PublishAndSubscribeL( aParameter ); - } - - // Cleanup - CleanupStack::PopAndDestroy( buf ); - CleanupStack::PopAndDestroy( con ); - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CheckHdmiContainerObjectL -// ---------------------------------------------------------------------------------- -TInt CTFAccessoryTestControl::CheckHdmiContainerObjectL() - { - TInt err = KErrNone; - CAccPolHdmiObjectCon* con1 = NULL; - CAccPolHdmiObjectCon* con2 = NULL; - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - // NewL - con1 = CAccPolHdmiObjectCon::NewL(); - CleanupStack::PushL( con1 ); - CleanupStack::PopAndDestroy( con1 ); - - // NewLC - con1 = CAccPolHdmiObjectCon::NewLC(); - CleanupStack::PopAndDestroy( con1 ); - - // Internalize & Externalize - con1 = CAccPolHdmiObjectCon::NewLC(); - CreateHdmiObjectL( *con1, EAccPolHdmiAudioFormatObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiLatencyObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiSinkObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiSpeakerAllocationObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiVideoFormatObject ); - RBufWriteStream writeStream; - writeStream.Open( *buf ); - writeStream.PushL(); - con1->ExternalizeL( writeStream ); - writeStream.CommitL(); - CleanupStack::PopAndDestroy( &writeStream ); - - con2 = CAccPolHdmiObjectCon::NewLC(); - RBufReadStream readStream; - readStream.Open( *buf ); - readStream.PushL(); - con2->InternalizeL( readStream ); - if( con1->Count() == con2->Count() ) - { - TInt count = con1->Count(); - CAccPolObjectBase* objBase1 = NULL; - CAccPolObjectBase* objBase2 = NULL; - for( TInt i = 0; i < count; i++ ) - { - objBase1 = con1->AtL( i ); - objBase2 = con2->AtL( i ); - if( objBase1->ObjectType() != objBase2->ObjectType() ) - { - err = KErrArgument; - } - } - } - else - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( &readStream ); - CleanupStack::PopAndDestroy( con2 ); - CleanupStack::PopAndDestroy( con1 ); - - // DuplicateLC - con1 = CAccPolHdmiObjectCon::NewLC(); - CreateHdmiObjectL( *con1, EAccPolHdmiAudioFormatObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiLatencyObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiSinkObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiSpeakerAllocationObject ); - CreateHdmiObjectL( *con1, EAccPolHdmiVideoFormatObject ); - con2 = static_cast( con1->DuplicateLC() ); - if( con1->Count() == con2->Count() ) - { - TInt count = con1->Count(); - CAccPolObjectBase* objBase1 = NULL; - CAccPolObjectBase* objBase2 = NULL; - for( TInt i = 0; i < count; i++ ) - { - objBase1 = con1->AtL( i ); - objBase2 = con2->AtL( i ); - if( objBase1->ObjectType() != objBase2->ObjectType() ) - { - err = KErrArgument; - } - } - } - else - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( con2 ); - CleanupStack::PopAndDestroy( con1 ); - - // Rest of the API - con1 = CAccPolHdmiObjectCon::NewLC(); - THdmiConObjectType objectType = EAccPolHdmiObjectCon; - TBool exit = EFalse; - TInt index = 0; - TInt count = 0; - do - { - index++; - err = KErrArgument; - objectType = ( THdmiConObjectType )( index ); - CreateHdmiObjectL( *con1, objectType ); - count = con1->Count(); - CAccPolObjectBase* obj = NULL; - if( con1->Count() != index ) - { - err = KErrArgument; - break; - } - for( TInt ii = 0; ii < count; ii++ ) - { - obj = con1->AtL( ii ); - if( obj->ObjectType() == objectType ) - { - err = KErrNone; - break; - } - } - if( objectType == EAccPolHdmiVideoFormatObject ) - { - // Last object - exit = ETrue; - } - } - while( !exit && ( err == KErrNone ) ); - CleanupStack::PopAndDestroy( con1 ); - CleanupStack::PopAndDestroy( buf ); - - return err; - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CheckHdmiSinkObjectL -// ---------------------------------------------------------------------------------- -TInt CTFAccessoryTestControl::CheckHdmiSinkObjectL() - { - TInt err = KErrNone; - CAccPolHdmiSink* obj = NULL; - CAccPolHdmiSink* objDuplicate = NULL; - TUint8 objectType = 0; - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - // NewL - obj = CAccPolHdmiSink::NewL(); - CleanupStack::PushL( obj ); - CleanupStack::PopAndDestroy( obj ); - - // NewL - with params - obj = CAccPolHdmiSink::NewL( ETrue, ETrue ); - CleanupStack::PushL( obj ); - if( !obj->BasicAudioSupport() ) - { - err = KErrArgument; - } - if( !obj->HdcpSupport() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // NewLC - obj = CAccPolHdmiSink::NewLC(); - CleanupStack::PopAndDestroy( obj ); - - // NewLC - with params - obj = CAccPolHdmiSink::NewLC( ETrue, ETrue ); - if( !obj->BasicAudioSupport() ) - { - err = KErrArgument; - } - if( !obj->HdcpSupport() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // Internalize & Externalize - obj = CAccPolHdmiSink::NewLC( ETrue, ETrue ); - - RBufWriteStream writeStream; - writeStream.Open( *buf ); - writeStream.PushL(); - obj->ExternalizeL( writeStream ); - writeStream.CommitL(); - CleanupStack::PopAndDestroy( &writeStream ); - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiSink::NewLC(); - RBufReadStream readStream; - readStream.Open( *buf ); - readStream.PushL(); - objectType = readStream.ReadUint8L(); - obj->InternalizeL( readStream ); - if( objectType != EAccPolHdmiSinkObject ) - { - err = KErrArgument; - } - if( !obj->BasicAudioSupport() ) - { - err = KErrArgument; - } - if( !obj->HdcpSupport() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( &readStream ); - CleanupStack::PopAndDestroy( obj ); - - // DuplicateLC - mem compare can be used since the object does not contain - // any ponters as memebers - obj = CAccPolHdmiSink::NewLC( ETrue, ETrue ); - objDuplicate = static_cast( obj->DuplicateLC() ); - TUint8* left = reinterpret_cast( obj ); - TUint8* right = reinterpret_cast( objDuplicate ); - TInt size = sizeof( CAccPolHdmiSink ); - if( Mem::Compare( left, size, right, size ) != KErrNone ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( objDuplicate ); - CleanupStack::PopAndDestroy( obj ); - - // Rest of the API - obj = CAccPolHdmiSink::NewLC(); - obj->SetBasicAudioSupport( ETrue ); - if( !obj->BasicAudioSupport() ) - { - err = KErrArgument; - } - obj->SetHdcpSupport( ETrue ); - if( !obj->HdcpSupport() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - CleanupStack::PopAndDestroy( buf ); - return err; - } - -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CheckHdmiAudioFormatObjectL -// ---------------------------------------------------------------------------------- -TInt CTFAccessoryTestControl::CheckHdmiAudioFormatObjectL() - { - TInt err = KErrNone; - CAccPolHdmiAudioFormat* obj = NULL; - CAccPolHdmiAudioFormat* objDuplicate = NULL; - TUint8 objectType = 0; - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - // NewL - obj = CAccPolHdmiAudioFormat::NewL(); - CleanupStack::PushL( obj ); - CleanupStack::PopAndDestroy( obj ); - - // NewL - with params - obj = CAccPolHdmiAudioFormat::NewL( HdmiAudioFormat::KUidFormatPCM16, - 1, - 1, - 1, - 1, - 1 ); - if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatPCM16 ) - { - err = KErrArgument; - } - if( obj->ChannelCount() != 1 ) - { - err = KErrArgument; - } - if( obj->BitResolution() != 1 ) - { - err = KErrArgument; - } - if( obj->MaxBitResolution() != 1 ) - { - err = KErrArgument; - } - if( obj->SamFreq() != 1 ) - { - err = KErrArgument; - } - if( obj->FormatDependentValue() != 1 ) - { - err = KErrArgument; - } - CleanupStack::PushL( obj ); - CleanupStack::PopAndDestroy( obj ); - - // NewLC - obj = CAccPolHdmiAudioFormat::NewLC(); - CleanupStack::PopAndDestroy( obj ); - - // NewLC - with params - obj = CAccPolHdmiAudioFormat::NewLC( HdmiAudioFormat::KUidFormatPCM16, - 1, - 1, - 1, - 1, - 1 ); - if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatPCM16 ) - { - err = KErrArgument; - } - if( obj->ChannelCount() != 1 ) - { - err = KErrArgument; - } - if( obj->BitResolution() != 1 ) - { - err = KErrArgument; - } - if( obj->MaxBitResolution() != 1 ) - { - err = KErrArgument; - } - if( obj->SamFreq() != 1 ) - { - err = KErrArgument; - } - if( obj->FormatDependentValue() != 1 ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // Internalize & Externalize - obj = CAccPolHdmiAudioFormat::NewLC( HdmiAudioFormat::KUidFormatPCM16, - 1, - 1, - 1, - 1, - 1 ); - RBufWriteStream writeStream; - writeStream.Open( *buf ); - writeStream.PushL(); - obj->ExternalizeL( writeStream ); - writeStream.CommitL(); - CleanupStack::PopAndDestroy( &writeStream ); - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiAudioFormat::NewLC(); - RBufReadStream readStream; - readStream.Open( *buf ); - readStream.PushL(); - objectType = readStream.ReadUint8L(); - obj->InternalizeL( readStream ); - if( objectType != EAccPolHdmiAudioFormatObject ) - { - err = KErrArgument; - } - if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatPCM16 ) - { - err = KErrArgument; - } - if( obj->ChannelCount() != 1 ) - { - err = KErrArgument; - } - if( obj->BitResolution() != 1 ) - { - err = KErrArgument; - } - if( obj->MaxBitResolution() != 1 ) - { - err = KErrArgument; - } - if( obj->SamFreq() != 1 ) - { - err = KErrArgument; - } - if( obj->FormatDependentValue() != 1 ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( &readStream ); - CleanupStack::PopAndDestroy( obj ); - - // DuplicateLC - mem compare can be used since the object does not contain - // any ponters as memebers - obj = CAccPolHdmiAudioFormat::NewLC( HdmiAudioFormat::KUidFormatPCM16, - 1, - 1, - 1, - 1, - 1 ); - objDuplicate = static_cast( obj->DuplicateLC() ); - TUint8* left = reinterpret_cast( obj ); - TUint8* right = reinterpret_cast( objDuplicate ); - TInt size = sizeof( CAccPolHdmiSink ); - if( Mem::Compare( left, size, right, size ) != KErrNone ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( objDuplicate ); - CleanupStack::PopAndDestroy( obj ); - - // Rest of the API - obj = CAccPolHdmiAudioFormat::NewLC(); - obj->SetAudioFormat( HdmiAudioFormat::KUidFormatEAC3 ); - if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatEAC3 ) - { - err = KErrArgument; - } - obj->SetChannelCount( 2 ); - if( obj->ChannelCount() != 2 ) - { - err = KErrArgument; - } - obj->SetBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample20 ); - if( !( obj->BitResolution() & CAccPolHdmiAudioFormat::EBitsPerSample20 ) ) - { - err = KErrArgument; - } - obj->SetMaxBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample24 ); - if( obj->MaxBitResolution() != CAccPolHdmiAudioFormat::EBitsPerSample24 ) - { - err = KErrArgument; - } - obj->SetSamFreq( CAccPolHdmiAudioFormat::ESamplingFreq192KHz ); - if( !( obj->SamFreq() & CAccPolHdmiAudioFormat::ESamplingFreq192KHz ) ) - { - err = KErrArgument; - } - obj->SetFormatDependentValue( CAccPolHdmiAudioFormat::EBitsPerSample16 ); - if( !( obj->FormatDependentValue() & CAccPolHdmiAudioFormat::EBitsPerSample16 ) ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - CleanupStack::PopAndDestroy( buf ); - - return err; - } - -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CheckHdmiLatencyObjectL -// ---------------------------------------------------------------------------------- -TInt CTFAccessoryTestControl::CheckHdmiLatencyObjectL() - { - TInt err = KErrNone; - CAccPolHdmiLatency* obj = NULL; - CAccPolHdmiLatency* objDuplicate = NULL; - TUint8 objectType = 0; - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - // NewL - obj = CAccPolHdmiLatency::NewL(); - CleanupStack::PushL( obj ); - CleanupStack::PopAndDestroy( obj ); - - // NewL - with params - obj = CAccPolHdmiLatency::NewL( HdmiLatency::KUidLatency, 100, 200 ); - CleanupStack::PushL( obj ); - if( obj->LatencyType() != HdmiLatency::KUidLatency ) - { - err = KErrArgument; - } - if( obj->AudioLatency() != 100 ) - { - err = KErrArgument; - } - if( obj->VideoLatency() != 200 ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // NewLC - obj = CAccPolHdmiLatency::NewLC(); - CleanupStack::PopAndDestroy( obj ); - - // NewLC - with params - obj = CAccPolHdmiLatency::NewLC( HdmiLatency::KUidLatency, 100, 200 ); - if( obj->LatencyType() != HdmiLatency::KUidLatency ) - { - err = KErrArgument; - } - if( obj->AudioLatency() != 100 ) - { - err = KErrArgument; - } - if( obj->VideoLatency() != 200 ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // Internalize & Externalize - obj = CAccPolHdmiLatency::NewLC( HdmiLatency::KUidLatency, 100, 200 ); - RBufWriteStream writeStream; - writeStream.Open( *buf ); - writeStream.PushL(); - obj->ExternalizeL( writeStream ); - writeStream.CommitL(); - CleanupStack::PopAndDestroy( &writeStream ); - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiLatency::NewLC(); - RBufReadStream readStream; - readStream.Open( *buf ); - readStream.PushL(); - objectType = readStream.ReadUint8L(); - obj->InternalizeL( readStream ); - if( objectType != EAccPolHdmiLatencyObject ) - { - err = KErrArgument; - } - if( obj->LatencyType() != HdmiLatency::KUidLatency ) - { - err = KErrArgument; - } - if( obj->AudioLatency() != 100 ) - { - err = KErrArgument; - } - if( obj->VideoLatency() != 200 ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( &readStream ); - CleanupStack::PopAndDestroy( obj ); - - // DuplicateLC - mem compare can be used since the object does not contain - // any ponters as memebers - obj = CAccPolHdmiLatency::NewLC( HdmiLatency::KUidLatency, 100, 200 ); - objDuplicate = static_cast( obj->DuplicateLC() ); - TUint8* left = reinterpret_cast( obj ); - TUint8* right = reinterpret_cast( objDuplicate ); - TInt size = sizeof( CAccPolHdmiLatency ); - if( Mem::Compare( left, size, right, size ) != KErrNone ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( objDuplicate ); - CleanupStack::PopAndDestroy( obj ); - - // Rest of the API - obj = CAccPolHdmiLatency::NewLC(); - obj->SetLatencyType( HdmiLatency::KUidLatency ); - if( obj->LatencyType() != HdmiLatency::KUidLatency ) - { - err = KErrArgument; - } - obj->SetAudioLatency( 100 ); - if( obj->AudioLatency() != 100 ) - { - err = KErrArgument; - } - obj->SetVideoLatency( 200 ); - if( obj->VideoLatency() != 200 ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - CleanupStack::PopAndDestroy( buf ); - - return err; - } - -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CheckHdmiSpeakerAllocationObjectL -// ---------------------------------------------------------------------------------- -TInt CTFAccessoryTestControl::CheckHdmiSpeakerAllocationObjectL() - { - TInt err = KErrNone; - CAccPolHdmiSpeakerAllocation* obj = NULL; - CAccPolHdmiSpeakerAllocation* objDuplicate = NULL; - TUint8 objectType = 0; - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - TUint32 bits = 0x0; - - // NewL - obj = CAccPolHdmiSpeakerAllocation::NewL(); - CleanupStack::PushL( obj ); - CleanupStack::PopAndDestroy( obj ); - - // NewLC - obj = CAccPolHdmiSpeakerAllocation::NewLC(); - CleanupStack::PopAndDestroy( obj ); - - // NewL - with params - bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | - CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; - obj = CAccPolHdmiSpeakerAllocation::NewL( bits ); - CleanupStack::PushL( obj ); - if( !obj->FrontCenter() ) - { - err = KErrArgument; - } - if( !obj->RearCenter() ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiSpeakerAllocation::NewL( EFalse, - EFalse, - EFalse, - ETrue, - EFalse, - EFalse, - ETrue, - EFalse, - EFalse, - EFalse, - EFalse ); - CleanupStack::PushL( obj ); - if( !obj->FrontCenter() ) - { - err = KErrArgument; - } - if( !obj->RearCenter() ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // NewLC - with params - bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | - CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; - obj = CAccPolHdmiSpeakerAllocation::NewLC( bits ); - if( !obj->FrontCenter() ) - { - err = KErrArgument; - } - if( !obj->RearCenter() ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiSpeakerAllocation::NewLC( EFalse, - EFalse, - EFalse, - ETrue, - EFalse, - EFalse, - ETrue, - EFalse, - EFalse, - EFalse, - EFalse ); - if( !obj->FrontCenter() ) - { - err = KErrArgument; - } - if( !obj->RearCenter() ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // Internalize & Externalize - bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | - CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; - obj = CAccPolHdmiSpeakerAllocation::NewLC( bits ); - RBufWriteStream writeStream; - writeStream.Open( *buf ); - writeStream.PushL(); - obj->ExternalizeL( writeStream ); - writeStream.CommitL(); - CleanupStack::PopAndDestroy( &writeStream ); - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiSpeakerAllocation::NewLC(); - RBufReadStream readStream; - readStream.Open( *buf ); - readStream.PushL(); - objectType = readStream.ReadUint8L(); - obj->InternalizeL( readStream ); - if( objectType != EAccPolHdmiSpeakerAllocationObject ) - { - err = KErrArgument; - } - if( !obj->FrontCenter() ) - { - err = KErrArgument; - } - if( !obj->RearCenter() ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( &readStream ); - CleanupStack::PopAndDestroy( obj ); - - // DuplicateLC - mem compare can be used since the object does not contain - // any ponters as memebers - bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | - CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; - obj = CAccPolHdmiSpeakerAllocation::NewLC( bits ); - objDuplicate = static_cast( obj->DuplicateLC() ); - TUint8* left = reinterpret_cast( obj ); - TUint8* right = reinterpret_cast( objDuplicate ); - TInt size = sizeof( CAccPolHdmiSpeakerAllocation ); - if( Mem::Compare( left, size, right, size ) != KErrNone ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( objDuplicate ); - CleanupStack::PopAndDestroy( obj ); - - // Rest of the API - bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | - CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter | - CAccPolHdmiSpeakerAllocation::EHdmiSpeakerTopCenter; - obj = CAccPolHdmiSpeakerAllocation::NewLC(); - obj->SetSpeakerAllocation( bits ); - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) - { - err = KErrArgument; - } - if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerTopCenter ) ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiSpeakerAllocation::NewLC(); - obj->SetFrontSpeakers( ETrue ); - if( !obj->FrontSpeakers() || obj->SpeakerCount() != 2 ) - { - err = KErrArgument; - } - obj->SetFrontSpeakers( EFalse ); - if( obj->FrontSpeakers() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetRearSpeakers( ETrue ); - if( !obj->RearSpeakers() || obj->SpeakerCount() != 2 ) - { - err = KErrArgument; - } - obj->SetRearSpeakers( EFalse ); - if( obj->RearSpeakers() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetLowFrequencyEffect( ETrue ); - if( !obj->LowFrequencyEffect() || obj->SpeakerCount() != 1 ) - { - err = KErrArgument; - } - obj->SetLowFrequencyEffect( EFalse ); - if( obj->LowFrequencyEffect() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetFrontCenter( ETrue ); - if( !obj->FrontCenter() || obj->SpeakerCount() != 1 ) - { - err = KErrArgument; - } - obj->SetFrontCenter( EFalse ); - if( obj->FrontCenter() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetFrontCenterHigh( ETrue ); - if( !obj->FrontCenterHigh() || obj->SpeakerCount() != 1 ) - { - err = KErrArgument; - } - obj->SetFrontCenterHigh( EFalse ); - if( obj->FrontCenterHigh() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetTopCenter( ETrue ); - if( !obj->TopCenter() || obj->SpeakerCount() != 1 ) - { - err = KErrArgument; - } - obj->SetTopCenter( EFalse ); - if( obj->TopCenter() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetRearCenter( ETrue ); - if( !obj->RearCenter() || obj->SpeakerCount() != 1 ) - { - err = KErrArgument; - } - obj->SetRearCenter( EFalse ); - if( obj->RearCenter() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetFrontLeftRightCenter( ETrue ); - if( !obj->FrontLeftRightCenter() || obj->SpeakerCount() != 2 ) - { - err = KErrArgument; - } - obj->SetFrontLeftRightCenter( EFalse ); - if( obj->FrontLeftRightCenter() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetRearLeftRightCenter( ETrue ); - if( !obj->RearLeftRightCenter() || obj->SpeakerCount() != 2 ) - { - err = KErrArgument; - } - obj->SetRearLeftRightCenter( EFalse ); - if( obj->RearLeftRightCenter() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetFrontWideSpeakers( ETrue ); - if( !obj->FrontWideSpeakers() || obj->SpeakerCount() != 2 ) - { - err = KErrArgument; - } - obj->SetFrontWideSpeakers( EFalse ); - if( obj->FrontWideSpeakers() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - obj->SetFrontHighSpeakers( ETrue ); - if( !obj->FrontHighSpeakers() || obj->SpeakerCount() != 2 ) - { - err = KErrArgument; - } - obj->SetFrontHighSpeakers( EFalse ); - if( obj->FrontHighSpeakers() || obj->SpeakerCount() != 0 ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - CleanupStack::PopAndDestroy( buf ); - - return err; - } - -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CheckHdmiVideoFormatObjectL -// ---------------------------------------------------------------------------------- -TInt CTFAccessoryTestControl::CheckHdmiVideoFormatObjectL() - { - TInt err = KErrNone; - CAccPolHdmiVideoFormat* obj = NULL; - CAccPolHdmiVideoFormat* objDuplicate = NULL; - TUint8 objectType = 0; - CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); - CleanupStack::PushL( buf ); - buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); - - // NewL - obj = CAccPolHdmiVideoFormat::NewL(); - CleanupStack::PushL( obj ); - CleanupStack::PopAndDestroy( obj ); - - // NewLC - obj = CAccPolHdmiVideoFormat::NewLC(); - CleanupStack::PopAndDestroy( obj ); - - // NewL - with params - obj = CAccPolHdmiVideoFormat::NewL( E640x480p59_94d60Hz4d3, - E640x350p85HzRB, - 1, - ETrue ); - CleanupStack::PushL( obj ); - if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) - { - err = KErrArgument; - } - if( obj->DmtFixedMode() != E640x350p85HzRB ) - { - err = KErrArgument; - } - if( obj->PixelRepeat() != 1 ) - { - err = KErrArgument; - } - if( !obj->Interlaced() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // NewLC - with params - obj = CAccPolHdmiVideoFormat::NewLC( E640x480p59_94d60Hz4d3, - E640x350p85HzRB, - 1, - ETrue ); - if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) - { - err = KErrArgument; - } - if( obj->DmtFixedMode() != E640x350p85HzRB ) - { - err = KErrArgument; - } - if( obj->PixelRepeat() != 1 ) - { - err = KErrArgument; - } - if( !obj->Interlaced() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - - // Internalize & Externalize - obj = CAccPolHdmiVideoFormat::NewLC( E640x480p59_94d60Hz4d3, - E640x350p85HzRB, - 1, - ETrue ); - RBufWriteStream writeStream; - writeStream.Open( *buf ); - writeStream.PushL(); - obj->ExternalizeL( writeStream ); - writeStream.CommitL(); - CleanupStack::PopAndDestroy( &writeStream ); - CleanupStack::PopAndDestroy( obj ); - - obj = CAccPolHdmiVideoFormat::NewLC(); - RBufReadStream readStream; - readStream.Open( *buf ); - readStream.PushL(); - objectType = readStream.ReadUint8L(); - obj->InternalizeL( readStream ); - if( objectType != EAccPolHdmiVideoFormatObject ) - { - err = KErrArgument; - } - if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) - { - err = KErrArgument; - } - if( obj->DmtFixedMode() != E640x350p85HzRB ) - { - err = KErrArgument; - } - if( obj->PixelRepeat() != 1 ) - { - err = KErrArgument; - } - if( !obj->Interlaced() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( &readStream ); - CleanupStack::PopAndDestroy( obj ); - - // DuplicateLC - mem compare can be used since the object does not contain - // any ponters as memebers - obj = CAccPolHdmiVideoFormat::NewLC( E640x480p59_94d60Hz4d3, - E640x350p85HzRB, - 1, - ETrue ); - objDuplicate = static_cast( obj->DuplicateLC() ); - TUint8* left = reinterpret_cast( obj ); - TUint8* right = reinterpret_cast( objDuplicate ); - TInt size = sizeof( CAccPolHdmiVideoFormat ); - if( Mem::Compare( left, size, right, size ) != KErrNone ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( objDuplicate ); - CleanupStack::PopAndDestroy( obj ); - - // Rest of the API - obj = CAccPolHdmiVideoFormat::NewLC(); - obj->SetCeaFixedMode( E640x480p59_94d60Hz4d3 ); - if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) - { - err = KErrArgument; - } - obj->SetDmtFixedMode( E640x350p85HzRB ); - if( obj->DmtFixedMode() != E640x350p85HzRB ) - { - err = KErrArgument; - } - obj->SetPixelRepeat( 4 ); - if( obj->PixelRepeat() != 4 ) - { - err = KErrArgument; - } - obj->SetInterlaced( ETrue ); - if( !obj->Interlaced() ) - { - err = KErrArgument; - } - CleanupStack::PopAndDestroy( obj ); - CleanupStack::PopAndDestroy( buf ); - - return err; - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver* CTFAccessoryTestControl::CreateObserver() -// ---------------------------------------------------------------------------------- -CTFTestControlObserver* CTFAccessoryTestControl::CreateObserver() - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CreateObserver()" ) ) ); - iStack.AddFirst/*AddLast*/( *CTFTestControlObserver::NewL( *this ) ); - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CreateObserver() return" ) ) ); - return iStack.First/*Last*/(); - } - -// Not used at this point. -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::ProcessMessageAndCompleteL -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::ProcessMessageAndCompleteL( const RMessage2& aMessage ) - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ProcessMessageAndCompleteL enter" ) ) ); - aMessage.Complete( KErrNone ); - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ProcessMessageAndCompleteL return" ) ) ); - } -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::MessageCompleteL -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::MessageCompleteL( TInt /*aResult*/) - { - - } - -// -// ---------------------------------------------------------------------------------- -// CTFAccessoryTestControl::CreateHdmiObjectL -// ---------------------------------------------------------------------------------- -void CTFAccessoryTestControl::CreateHdmiObjectL( CAccPolObjectCon& aCon, - THdmiConObjectType aType ) - { - switch( aType ) - { - case EAccPolHdmiSinkObject: - { - CAccPolHdmiSink* sink = CAccPolHdmiSink::NewLC(); - sink->SetBasicAudioSupport( ETrue ); - sink->SetHdcpSupport( ETrue ); - aCon.AddL( *sink ); - CleanupStack::PopAndDestroy( sink ); - break; - } - case EAccPolHdmiAudioFormatObject: - { - CAccPolHdmiAudioFormat* audioFormat = CAccPolHdmiAudioFormat::NewLC(); - audioFormat->SetAudioFormat( HdmiAudioFormat::KUidFormatPCM16 ); - audioFormat->SetChannelCount( 2 ); - audioFormat->SetBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample16 ); - audioFormat->SetMaxBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample16 ); - audioFormat->SetFormatDependentValue( CAccPolHdmiAudioFormat::EBitsPerSample16 ); - audioFormat->SamFreq( CAccPolHdmiAudioFormat::ESamplingFreq32KHz ); - aCon.AddL( *audioFormat ); - CleanupStack::PopAndDestroy( audioFormat ); - break; - } - case EAccPolHdmiLatencyObject: - { - CAccPolHdmiLatency* latency = CAccPolHdmiLatency::NewLC(); - latency->SetLatencyType( HdmiLatency::KUidLatency ); - latency->SetAudioLatency( 100 ); - latency->SetVideoLatency( 200 ); - aCon.AddL( *latency ); - CleanupStack::PopAndDestroy( latency ); - break; - } - case EAccPolHdmiSpeakerAllocationObject: - { - CAccPolHdmiSpeakerAllocation* speakerAllocation = - CAccPolHdmiSpeakerAllocation::NewLC(); - speakerAllocation->SetFrontSpeakers( ETrue ); - speakerAllocation->SetRearSpeakers( ETrue ); - speakerAllocation->SetLowFrequencyEffect( ETrue ); - speakerAllocation->SetFrontCenter( ETrue ); - speakerAllocation->SetFrontCenterHigh( ETrue ); - speakerAllocation->SetTopCenter( ETrue ); - speakerAllocation->SetRearCenter( ETrue ); - speakerAllocation->SetFrontLeftRightCenter( ETrue ); - speakerAllocation->SetRearLeftRightCenter( ETrue ); - speakerAllocation->SetFrontWideSpeakers( ETrue ); - speakerAllocation->SetFrontHighSpeakers( ETrue ); - aCon.AddL( *speakerAllocation ); - CleanupStack::PopAndDestroy( speakerAllocation ); - break; - } - case EAccPolHdmiVideoFormatObject: - { - CAccPolHdmiVideoFormat* videoFormat = CAccPolHdmiVideoFormat::NewLC(); - videoFormat->SetCeaFixedMode( E640x480p59_94d60Hz4d3 ); - videoFormat->SetDmtFixedMode( E640x480p85HzRB ); - videoFormat->SetInterlaced( EFalse ); - aCon.AddL( *videoFormat ); - CleanupStack::PopAndDestroy( videoFormat ); - break; - } - default: - { - break; - } - } - } - - -void CTFAccessoryTestControl::AccessoryConnectionOpenClose(TTFAccessoryFunction aCase, TInt* aRetval) - { - switch(aCase) - { - case ETFAccessoryConnection_Open: - { - if ( iAccessoryConnection == NULL ) - { - iAccessoryConnection = new ( ELeave ) RAccessoryConnection; - *aRetval = iAccessoryConnection->CreateSubSession( iAccessoryServer ); - COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL(TTFAccessoryTestCaseStateControl& aParameter) - ETFAccessoryConnection_Open - Sub session created - (%d)" ), *aRetval ) ); - } - else - { - *aRetval = KErrNone; - COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL(TTFAccessoryTestCaseStateControl& aParameter) - ETFAccessoryConnection_Open - Sub session not created - (%d)" ), *aRetval ) ); - } - } - break; - - case ETFAccessoryConnection_Close: - { - TRACE_ASSERT( iAccessoryConnection != NULL ); - - if ( iAccessoryConnection != NULL ) - { - iAccessoryConnection->CloseSubSession(); - delete iAccessoryConnection; - iAccessoryConnection = NULL; - COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL(TTFAccessoryTestCaseStateControl& aParameter) - ETFAccessoryConnection_Close - Sub session closed" ) ) ); - } - *aRetval = KErrNone; - } - break; - - default: - break; - } - - } - -void CTFAccessoryTestControl::FindAndCheckRequestL( TInt* aRetval, TTFAccessoryTestCaseStateControl& aParameter ) - { - CTFAccessoryTestCaseControl* testCase = STATIC_CAST( CTFAccessoryTestCaseControl*, CurrentTestCase()); - TInt errVal = 0; - - TRACE_ASSERT( testCase != NULL ); - if ( testCase != NULL ) - { - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::FindAndCheckRequest() - inside if ( testCase != NULL )" ) ) ); - if(!iStack.IsEmpty()) - { - iStackIter.SetToFirst(); - - while ( ( iObserverItem = iStackIter++ ) != NULL ) - { - if(iObserverItem->FindRequest(aParameter.iRequestType)) - { - testCase->CheckRequest( iObserverItem->iStatus, - iObserverItem->iValue, - iObserverItem->iCapabilityName, - &errVal ); - - if(errVal == KTFDontDeleteObserver) - { - aParameter.iArg1 = KTFDontDeleteObserver; - } - - - if ( !iStack.IsEmpty() ) // Check if observes are already deleted by CheckRequest() - { - if( KTFDontDeleteObserver != aParameter.iArg1 ) - { - if (iObserverItem->iStatus == KRequestPending ) - { - User::WaitForRequest(iObserverItem->iStatus); - } - iStack.Remove( *iObserverItem ); - delete iObserverItem; - } - else - { - User::Leave( KTFDontDeleteObserver ); - } - } - else - { - *aRetval = KErrGeneral; - } - } - } - } - else - { - *aRetval = KErrGeneral; - } - } - - TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::FindAndCheckRequest() returning and setting *aRetval = KErrNone )" ) ) ); - *aRetval = KErrNone; - } - - -void CTFAccessoryTestControl::AccessorySettingsOpenClose( TTFAccessoryFunction aCase, TInt* aRetval ) - { - switch(aCase) - { - case ETFAccessorySettings_Open: - { - if ( iAccessorySettings == NULL ) - { - iAccessorySettings = new ( ELeave ) RAccessorySettings; - *aRetval = iAccessorySettings->CreateSubSession( iAccessoryServer ); - } - else - *aRetval = KErrNone; - } - break; - - case ETFAccessorySettings_Close: - { - TRACE_ASSERT( iAccessorySettings != NULL ); - - if ( iAccessorySettings != NULL ) - { - iAccessorySettings->CloseSubSession(); - delete iAccessorySettings; - iAccessorySettings = NULL; - } - *aRetval = KErrNone; - } - break; - - default: - break; - - } - } - -void CTFAccessoryTestControl::SetSeveralAccessoryModeSetting( TInt* aRetval ) - { - TAccModeSetting accModeSettingIn; - TAccMode tAccMode = EAccModeWirelessHeadset; - TBuf< KMaxAccModeSetting > aDesIn; - // Set - // setting 1 - accModeSettingIn.SetId( 11 ); // unknown TInt - accModeSettingIn.SetTInt( 1 ); - TAccModeSettingArray arrayIn; - arrayIn.AddSetting( accModeSettingIn ); - - // setting 2 - accModeSettingIn.SetId( 12 ); // unknown Des - _LIT( KAccSetting2, "012345678901234567890" ); - aDesIn.Copy( KAccSetting2 ); - accModeSettingIn.SetTDes( aDesIn ); - arrayIn.AddSetting( accModeSettingIn ); - - // setting 3 - accModeSettingIn.SetId( 13 ); // unknown TBool - accModeSettingIn.SetTBool( ETrue ); - arrayIn.AddSetting( accModeSettingIn ); - - *aRetval = iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, arrayIn ); - } - -void CTFAccessoryTestControl::GetSeveralAccessoryModeSetting( TInt* aRetval ) - { - TAccModeSetting accModeSettingOut; - TAccMode tAccMode = EAccModeWirelessHeadset; - TBuf< KMaxAccModeSetting > aDesOut; - TAccModeSettingArray arrayOut; - TInt intOut( 0 ); - // set input parameters for GetAccessoryModeSettings() - // setting 11 - accModeSettingOut.SetId( 11 ); - arrayOut.AddSetting( accModeSettingOut ); - - // setting 12 - accModeSettingOut.SetId( 12 ); - arrayOut.AddSetting( accModeSettingOut ); - - // setting 13 - accModeSettingOut.SetId( 13 ); - arrayOut.AddSetting( accModeSettingOut ); - - *aRetval = iAccessorySettings->GetAccessoryModeSettings( tAccMode, arrayOut ); - - // Check that got settings are right - - TInt count = arrayOut.GetArraySize(); - TInt foundCount(0); - - for( TInt index = 0; index < count; index++ ) - { - arrayOut.GetSetting( index, accModeSettingOut ); - - if( 11 == accModeSettingOut.Id() ) - { - - accModeSettingOut.GetTInt( intOut); - - if( 1 == intOut ) - { - foundCount++; - } - } - - - if( 12 == accModeSettingOut.Id() ) - { - accModeSettingOut.GetTDes( aDesOut ); - - if( KErrNone == aDesOut.Compare( _L("012345678901234567890") ) ) - { - foundCount++; - } - - } - - if( 13 == accModeSettingOut.Id() ) - { - - accModeSettingOut.GetTBool( intOut ); - - if( intOut ) - { - foundCount++; - } - } - } - - if(foundCount != 3) - { - *aRetval = KErrNotFound; - } - - // - // Reset Settings - // - TAccModeSetting accModeSettingIn; - TBuf< KMaxAccModeSetting > aDesIn; - // Set - // setting 1 - accModeSettingIn.SetId( 11 ); // unknown TInt - accModeSettingIn.SetTInt( 0 ); - TAccModeSettingArray arrayIn; - arrayIn.AddSetting( accModeSettingIn ); - - // setting 2 - accModeSettingIn.SetId( 12 ); // unknown Des - _LIT( KAccSetting2, "" ); - aDesIn.Copy( KAccSetting2 ); - accModeSettingIn.SetTDes( aDesIn ); - arrayIn.AddSetting( accModeSettingIn ); - - // setting 3 - accModeSettingIn.SetId( 13 ); // unknown TBool - accModeSettingIn.SetTBool( EFalse ); - arrayIn.AddSetting( accModeSettingIn ); - - iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, arrayIn ); - - } - -void CTFAccessoryTestControl::SetIntValue( TTFAccessoryTestCaseStateControl& aParameter, TInt *aRetval ) - { - switch( aParameter.iArg3 ) - { - case KAccSetVolumeLevel: - { - //AccPolCommonNameValuePairs.h contains following example code - RAccessoryControl accessoryControl; - accessoryControl.CreateSubSession( iAccessoryServer ); - - CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL(); - CleanupStack::PushL( nameArray ); - accessoryControl.GetSubblockNameArrayL( iGenericId[aParameter.iGid], *nameArray ); - - TAccPolNameRecord nameRecord; - nameRecord.SetNameL( KAccSetVolumeLevel ); - TAccValueTypeTInt value; - - if( nameArray->HasName( KAccSetVolumeLevel ) ) - { - accessoryControl.GetValueL( iGenericId[aParameter.iGid], nameRecord, value ); - value.iValue = value.iValue | aParameter.iArg1; - accessoryControl.AccessoryValueChangedNotifyL( iGenericId[aParameter.iGid], nameRecord, value ); - } - - CleanupStack::PopAndDestroy( nameArray ); - accessoryControl.CloseSubSession(); - *aRetval = KErrNone; - } - break; - - default: - { - TAccPolNameRecord aNameRecord; - aNameRecord.SetNameL( aParameter.iArg3 ); - TAccValueTypeTInt aIntValue; - aIntValue.iValue = aParameter.iArg1; - *aRetval = iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, aIntValue ); - } - break; - } - - } - -void CTFAccessoryTestControl::SelectionDialog( TTFAccessoryFunction aCase, TInt* aRetval ) - { - switch(aCase) - { - case ETFSelectionDialogText: - { - const TUid KAccFwUiDialogNotifierUid = { 0x10205062 }; - - RNotifier notifier; - notifier.Connect(); - - TInt selectionListBitmask = 255; - TInt reply = 0; - - TPckg replyPck( reply); - TPckg selectionBitmaskPackage( selectionListBitmask); - - //activate active object - TRequestStatus status; - status = KRequestPending; - - //open ui - notifier.StartNotifierAndGetResponse( status, KAccFwUiDialogNotifierUid, selectionBitmaskPackage, replyPck); - - User::WaitForRequest( status); - - - notifier.Close(); - - *aRetval = KErrNone; - } - - case ETFSelectionDialogCancel: - { - const TUid KAccFwUiDialogNotifierUid = { 0x10205062 }; - - RNotifier notifier; - notifier.Connect(); - - TInt selectionListBitmask = 7; - TInt reply = 0; - - TPckg replyPck( reply); - TPckg selectionBitmaskPackage( selectionListBitmask); - - //activate active object - TRequestStatus status; - - //open ui - notifier.StartNotifierAndGetResponse( status, KAccFwUiDialogNotifierUid, selectionBitmaskPackage, replyPck); - User::After( 2500000); - notifier.CancelNotifier( KAccFwUiDialogNotifierUid); - - // Implementation of the dialog is changed. Request is completed every time - User::WaitForRequest( status ); - - notifier.Close(); - - *aRetval = KErrNone; - } - - default: - break; - - } - - } - -void CTFAccessoryTestControl::CheckConnectedAccessory( TInt* aRetval ) - { - *aRetval = KErrNone; - - TAccPolGenericID genID; // TGeneric ID that should be connected - TAccPolGenericID genIDConnected; // TGeneric ID that is connected - TAccPolGIDHeader iGenericIDHeader; // Header of the GID that should be connected - TAccPolGIDHeader iGenericIDHeaderConnected; // Header of the connected GID - TAccPolGenericIDArray genericIdArray; // Array of connected generic ID's - CAccConGenericID* aGenericID = CAccConGenericID::NewL(); // This might be needed for capabilities - CAccPolSubblockNameArray* nameArrayConnected = CAccPolSubblockNameArray::NewL(); - - CleanupStack::PushL( aGenericID ); - CleanupStack::PushL( nameArrayConnected ); - - TAccPolGenericID genericID = aGenericID->GenericID(); - - TBuf hwModelID(_L("headset")); - // Set GenericID header - iGenericIDHeader.iAccessoryDeviceType = KDTHeadset; - iGenericIDHeader.iPhysicalConnection = KPCWired; - iGenericIDHeader.iApplicationProtocol = 0x0; - - iGenericIDHeader.iCapabilitiesSubblocks = KSBAudioSubblock; - - iGenericIDHeader.iHWModelID = hwModelID; - iGenericIDHeader.iHWDeviceID = 0x0; - iGenericIDHeader.iDBID = 0x0; - - RAccessoryConnection* accessoryConnection = new ( ELeave ) RAccessoryConnection(); - CleanupStack::PushL( accessoryConnection ); - accessoryConnection->CreateSubSession( iAccessoryServer ); - accessoryConnection->GetAccessoryConnectionStatus( genericIdArray ); - CleanupStack::PopAndDestroy( accessoryConnection ); - - genIDConnected = genericIdArray.GetGenericIDL( 0 ); - - RAccessorySingleConnection singleConnect;// = new ( ELeave ) RAccessoryConnectionBase(); - singleConnect.CreateSubSession( iAccessoryServer ); - singleConnect.GetSubblockNameArrayL( genIDConnected, *nameArrayConnected ); - - singleConnect.CloseSubSession(); - - iGenericIDHeaderConnected.iAccessoryDeviceType = genIDConnected.DeviceTypeCaps(); - iGenericIDHeaderConnected.iPhysicalConnection = genIDConnected.PhysicalConnectionCaps(); - iGenericIDHeaderConnected.iApplicationProtocol = genIDConnected.ApplicationProtocolCaps(); - iGenericIDHeaderConnected.iCapabilitiesSubblocks = genIDConnected.SubblockCaps(); - iGenericIDHeaderConnected.iHWModelID = genIDConnected.HWModelID(); - iGenericIDHeaderConnected.iHWDeviceID = genIDConnected.HWDeviceID(); - iGenericIDHeaderConnected.iDBID = 0x0; - - //Check GenericID header - if( iGenericIDHeader.iAccessoryDeviceType != iGenericIDHeaderConnected.iAccessoryDeviceType ) - { - *aRetval = EFalse; - } - if( iGenericIDHeader.iPhysicalConnection != iGenericIDHeaderConnected.iPhysicalConnection ) - { - *aRetval = EFalse; - } - if( iGenericIDHeader.iApplicationProtocol != iGenericIDHeaderConnected.iApplicationProtocol ) - { - *aRetval = EFalse; - } - if( iGenericIDHeader.iCapabilitiesSubblocks != iGenericIDHeaderConnected.iCapabilitiesSubblocks ) - { - *aRetval = EFalse; - } - if( iGenericIDHeader.iHWModelID != iGenericIDHeaderConnected.iHWModelID ) - { - *aRetval = EFalse; - } - if( iGenericIDHeader.iHWDeviceID != iGenericIDHeaderConnected.iHWDeviceID ) - { - *aRetval = EFalse; - } - if( !( nameArrayConnected->HasName( KAccStereoAudio ) ) ) - { - *aRetval = EFalse; - } - - if( !( nameArrayConnected->HasName( KAccAudioOutConnector ) ) ) - { - *aRetval = EFalse; - } - - if( !( nameArrayConnected->HasName( KAccAudioOutputType ) ) ) - { - *aRetval = EFalse; - } - //CleanupStack::PopAndDestroy( nameValueArray ); - CleanupStack::PopAndDestroy( nameArrayConnected ); - CleanupStack::PopAndDestroy( aGenericID ); - - } - - -void CTFAccessoryTestControl::CallTClassMethods( TInt* aRetval ) - { - // Settings(); - Policy(); - *aRetval = KErrNone; - } - -void CTFAccessoryTestControl::Settings() - { - TAccModeSettingArray array; - array.Reset(); - TInt ret = array.GetMaxArraySize(); - TAccModeSetting setting; - TUint32 settingId( 1 ); - setting.SetId( settingId ); - array.AddSetting( setting ); - TAccModeSetting setting2; - ret = array.GetSetting( 0, setting2 ); - ret = array.GetArraySize(); - } - -void CTFAccessoryTestControl::Policy() - { - TInt valueInt( 1 ); - TUint32 valueUInt( 1 ); - TDesC8 des( _L8( "timo" ) ); - //TDes8 valueDesc = des; - TAccPolNameRecord nameRecord; - TAccPolValueRecord valRec( des, EAPVPolicy ); - TAccPolNameValueRecord nameValRec; - TAccPolNameValueRecord nameValRec1( nameRecord, valRec ); - TAccPolNameValueRecord nameValRec2( valueUInt, valueInt, EAPVInt, EAPVPolicy ); - TAccPolNameValueRecord nameValRec3( valueUInt, des, EAPVPolicy ); - TAccPolNameValueRecord nameValRec4( valueUInt ); - //TDesC8 valueToGet; - valRec.GetValueL( des ); - valRec.SetValue( des ); - //valRec.SetValue( valueToGet ); - TAccPolValueRecord valRec1( valueInt, EAPVInt, EAPVPolicy ); - valRec1.SetValue( valueInt ); - valRec1.SetLocation( EAPVPolicy ); - valRec1.SetL( valueInt, EAPVInt, EAPVPolicy ); - } - -void CTFAccessoryTestControl::GetBoolAccessoryModeSetting( TTFAccessoryTestCaseStateControl& aParameter, TInt* aRetval ) - { - TBool aSettingsValueBool; - - TAccMode aAccMode = (TAccMode)aParameter.iArg1; - TAccModeSetting aSetting; - aSetting.SetId(aParameter.iArg2); - - *aRetval = iAccessorySettings->GetAccessoryModeSetting(aAccMode, aSetting); - - if( aSetting.Type() == EAccModeSettingBool) - { - *aRetval = aSetting.GetTBool(aSettingsValueBool); - - if(*aRetval != KErrNotFound) - { - if(aSettingsValueBool == (TBool)aParameter.iArg4) - { - *aRetval = KErrNone; - } - else - { - *aRetval = KErrArgument; - } - } - } - else - { - *aRetval = KErrNotFound; - } - } - -void CTFAccessoryTestControl::GetIntAccessoryModeSetting( TTFAccessoryTestCaseStateControl& aParameter, TInt* aRetval ) - { - TInt aSettingsValueInt; - - TAccMode aAccMode = (TAccMode)aParameter.iArg1; - TAccModeSetting aSetting; - aSetting.SetId(aParameter.iArg2); - - *aRetval = iAccessorySettings->GetAccessoryModeSetting(aAccMode, aSetting); - - if(aSetting.Type() == EAccModeSettingInt) - { - *aRetval = aSetting.GetTInt(aSettingsValueInt); - - if(*aRetval != KErrNotFound) - { - if( aSettingsValueInt == aParameter.iArg4 ) - { - *aRetval = KErrNone; - } - else - { - *aRetval = KErrArgument; - } - } - } - else - { - *aRetval = KErrNotFound; - } - } - -void CTFAccessoryTestControl::GetDesAccessoryModeSetting( TTFAccessoryTestCaseStateControl& aParameter, TInt* aRetval ) - { - TBuf aSettingsValueDes; - - TAccMode aAccMode = (TAccMode)aParameter.iArg1; - TAccModeSetting aSetting; - aSetting.SetId( aParameter.iArg2 ); - - *aRetval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, aSetting ); - - if( aSetting.Type() == EAccModeSettingDes ) - { - *aRetval = aSetting.GetTDes( aSettingsValueDes ); - - if(*aRetval != KErrNotFound) - { - TBuf buffer; - buffer.Num( aParameter.iArg3 ); - if( KErrNone == aSettingsValueDes.Compare( buffer ) ) - { - *aRetval = KErrNone; - } - else - { - *aRetval = KErrArgument; - } - } - } - else - { - *aRetval = KErrNotFound; - } - } - -// End of file +/* + * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +// INCLUDE FILES + +#include +#include +#include +#include "siftrace.h" +#include "CtfAccessoryTestcontrol.h" +#include "CtfAccessoryTestCaseControl.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include "AccClientServerMessages.h" +#include + +#include +#include + +// +// ---------------------------------------------------------------------------------- +// MTFAccessoryTestControl* GetAccessoryTestControl +// ---------------------------------------------------------------------------------- +MTFAccessoryTestControl* GetAccessoryTestControl( void ) + { + CTFStub* stub = CTFFactory::Stub( KTFStubTypeAccessoryControl ); + return STATIC_CAST( CTFAccessoryTestControl*, stub ); + } +// +// ---------------------------------------------------------------------------------- +// MTFAccessoryTestControl::MTFAccessoryTestControl +// ---------------------------------------------------------------------------------- +MTFAccessoryTestControl::MTFAccessoryTestControl( void ) + { + } +// +// ---------------------------------------------------------------------------------- +// MTFAccessoryTestControl::~MTFAccessoryTestControl +// ---------------------------------------------------------------------------------- +MTFAccessoryTestControl::~MTFAccessoryTestControl( void ) + { + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CTFAccessoryTestControl +// ---------------------------------------------------------------------------------- +CTFAccessoryTestControl::CTFAccessoryTestControl( void ) : + CTFRemoteStub( KTFStubTypeAccessoryControl ), + iStack( CTFTestControlObserver::iOffset ), iStackIter( iStack ) + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CTFAccessoryTestControl()" ) ) ); + + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CTFAccessoryTestControl() - return" ) ) ); + } + +//lint -e1740 Pointer not directly deleted by destructor +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::~CTFAccessoryTestControl +// ---------------------------------------------------------------------------------- +CTFAccessoryTestControl::~CTFAccessoryTestControl( void ) + { + + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::~CTFAccessoryTestControl()" ) ) ); + RProperty::Delete( KTFAccessoryTestProperty, KTFAccessoryMethod ); + + ResetAccessoryServices(); + + iAccessoryServer.Disconnect(); + + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::~CTFAccessoryTestControl() - Accessory Server connection closed" ) ) ); + + } +//lint +e1740 +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::InitializeL +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::InitializeL( void ) + { + + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::InitializeL( void ) - enter" ) ) ); + TInt retval( KErrNone ); + + iAccessoryConnection = NULL; + iAccessorySingleConnection = NULL; + iAccessoryControl = NULL; + iAccessorySettings = NULL; + iAccessoryMode = NULL; + iAccessoryAudioControl = NULL; + iAccessoryBTControl = NULL; + + iStreamContainer = NULL; + iTopologyContainer = NULL; + iSpeakerRightVolume = NULL; + iSpeakerLeftVolume = NULL; + iSpeakerMute = NULL; + iMicRightVolume = NULL; + iMicLeftVolume = NULL; + + TAccPolGenericID emptyInstance; + for( TInt i( 0 ); i < 10; i++ ) + { + iGenericId[i] = emptyInstance; + } + + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::InitializeL()" ) ) ); + + User::LeaveIfError( iAccessoryServer.Connect() ); + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::InitializeL() - Connected to accessory server" ) ) ); + + retval = RProperty::Define( KTFAccessoryTestProperty, + KTFAccessoryMethod, + RProperty::EByteArray ); + if( retval != KErrAlreadyExists ) + User::LeaveIfError( retval ); + //attach to property + + + RProperty systemState; + User::LeaveIfError( systemState.Attach( KPSUidStartup, KPSGlobalSystemState ) ); + TInt value( KErrNone ); + //check value + TInt err = systemState.Get( value ); + + if( err != KErrNone ) + { + err = systemState.Define( KPSUidStartup, + KPSGlobalSystemState, + RProperty::EInt ); + TInt err = systemState.Get( value ); + } + + if( value != ESwStateNormalRfOn || value != ESwStateNormalRfOff || value + != ESwStateNormalBTSap ) + { + TInt err = systemState.Set( KPSUidStartup, + KPSGlobalSystemState, + ESwStateNormalRfOn ); + } + + iInitialized = ETrue; + + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::InitializeL - return" ) ) ); + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::InitializeL( void ) - return" ) ) ); + } +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::ResetAccessoryServices +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::ResetAccessoryServices( void ) + { + ResetAccessoryServer(); + + iInitialized = EFalse; + + iAccessoryServer.Close(); + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::ResetAccessoryServer +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::ResetAccessoryServer( void ) + { + + COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::ResetAccessoryServer()" ) ) ); + + CTFTestControlObserver* observerItem; + if( !iStack.IsEmpty() ) + { + iStackIter.SetToFirst(); + + while( ( observerItem = iStackIter++ ) != NULL ) + { + observerItem->Cancel(); + User::After( 2000000 ); + iStack.Remove( *observerItem ); + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Remove Observer" ) ) ); + delete observerItem; + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Delete Observer" ) ) ); + }; + } + + iStack.Reset(); + + TAccPolGenericID emptyInstance; + + for( TInt i( 0 ); i < 10; i++ ) + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Clear instances" ) ) ); + if( KErrNotFound != iGenericId[i].UniqueID() ) + { + if( iGenericId[i].PhysicalConnectionCaps( KPCBluetooth ) ) + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- BT Found" ) ) ); + TBTDevAddr BTDevAddr( iGenericId[i].DeviceAddress() ); + if( iAccessoryBTControl != NULL ) + { + TRequestStatus status; + status = KRequestPending; + iAccessoryBTControl->DisconnectAccessory( status, BTDevAddr ); + User::WaitForRequest( status ); + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- BT Disconnected" ) ) ); + } + } + else + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Wired Found" ) ) ); + TPckgBuf buf; + buf().iMethod = ETFAsyDisc; + User::LeaveIfError( iSubscribe.Set( KTFAccessoryTestProperty, + KTFAccessoryMethod, + buf ) ); + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ResetAccessoryServer -- Wired Disconnected" ) ) ); + } + } + iGenericId[i] = emptyInstance; + } + + if( iAccessoryConnection != NULL ) + { + iAccessoryConnection->CloseSubSession(); + delete iAccessoryConnection; + iAccessoryConnection = NULL; + } + + if( iAccessorySingleConnection != NULL ) + { + iAccessorySingleConnection->CloseSubSession(); + delete iAccessorySingleConnection; + iAccessorySingleConnection = NULL; + } + if( iAccessoryControl != NULL ) + { + iAccessoryControl->CloseSubSession(); + delete iAccessoryControl; + iAccessoryControl = NULL; + } + if( iAccessorySettings != NULL ) + { + iAccessorySettings->CloseSubSession(); + delete iAccessorySettings; + iAccessorySettings = NULL; + } + if( iAccessoryMode != NULL ) + { + iAccessoryMode->CloseSubSession(); + delete iAccessoryMode; + iAccessoryMode = NULL; + } + + if( iAccessoryAudioControl != NULL ) + { + iAccessoryAudioControl->CloseSubSession(); + delete iAccessoryAudioControl; + iAccessoryAudioControl = NULL; + } + + if( iAccessoryBTControl != NULL ) + { + iAccessoryBTControl->CloseSubSession(); + delete iAccessoryBTControl; + iAccessoryBTControl = NULL; + } + + if( iSpeakerRightVolume != NULL ) + { + delete iSpeakerRightVolume; + iSpeakerRightVolume = NULL; + } + + if( iSpeakerLeftVolume != NULL ) + { + delete iSpeakerLeftVolume; + iSpeakerLeftVolume = NULL; + } + + if( iSpeakerMute != NULL ) + { + delete iSpeakerMute; + iSpeakerMute = NULL; + } + + if( iMicRightVolume != NULL ) + { + delete iMicRightVolume; + iMicRightVolume = NULL; + } + + if( iMicLeftVolume != NULL ) + { + delete iMicLeftVolume; + iMicLeftVolume = NULL; + } + + if( iStreamContainer != NULL ) + { + delete iStreamContainer; + iStreamContainer = NULL; + } + + if( iTopologyContainer != NULL ) + { + delete iTopologyContainer; + iTopologyContainer = NULL; + } + + COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::ResetAccessoryServer() - Success" ) ) ); + } +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CancelOutStandingRequest +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::CancelOutStandingRequest() + { + iObserverItem->Cancel(); + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::FillObjectL +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::FillObjectL( CAccPolAudioStreamFormatCon* aContainer, + TStreamConObjectType aobjectType, + TInt64 aNumberOfObjects ) + { + + for( TInt i = 0; i < aNumberOfObjects; i++ ) + { + switch( aobjectType ) + { + case EAccPolAudioInputStreamObject: + { + CAccPolAudioStreamFormat* stream = + CAccPolAudioStreamFormat::NewLC( aobjectType, + i, + KUidFormatPCM16, + CAccPolAudioStreamFormat::EStereo, + CAccPolAudioStreamFormat::EBitsPerSample16, + i + 200 ); + aContainer->AddL( *stream ); + CleanupStack::PopAndDestroy( stream ); + } + break; + + case EAccPolAudioOutputStreamObject: + { + + CAccPolAudioStreamFormat + * stream = + CAccPolAudioStreamFormat::NewLC( EAccPolAudioOutputStreamObject ); + + stream->SetUnitId( i ); + stream->SetAudioFormat( KUidFormatPCM16 ); + stream->SetStreamType( CAccPolAudioStreamFormat::EMono ); + stream->SetBitResolution( CAccPolAudioStreamFormat::EBitsPerSample32 ); + stream->SetSamFreq( i + 200 ); + + aContainer->AddL( *stream ); + CleanupStack::PopAndDestroy( stream ); + } + break; + + default: + { + TRACE_ASSERT_ALWAYS; + } + break; + } + } + + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CreateObjectPubSub +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::CreateObjectPubSubL( TStreamConObjectType aobjectType, + TInt64 aNumberOfObjects, + TStreamConObjectType aobjectType2, + TInt64 aNumberOfObjects2 ) + { + RProperty prop; + prop.Define( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + RProperty::EByteArray ); + + CAccPolAudioStreamFormatCon* container = + CAccPolAudioStreamFormatCon::NewLC(); + + FillObjectL( container, aobjectType, aNumberOfObjects ); + FillObjectL( container, aobjectType2, aNumberOfObjects2 ); + + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + //Externalize container to buf + RBufWriteStream wStrm; + ( void )wStrm.Open( *buf ); + wStrm.PushL(); + container->ExternalizeL( wStrm ); + wStrm.CommitL(); + wStrm.Close(); + wStrm.Pop(); + + TPtr8 ptr( buf->Ptr( 0 ) ); + + TInt retval = prop.Set( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + ptr ); + + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( container ); + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CreateObjectPubSub +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::CreateTopologyObjectsToPubSubL( + TTFAccessoryTestCaseStateControl& aParameter ) + { + RProperty prop; + prop.Define( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + RProperty::EByteArray ); + + CAccPolAudioTopologyObjectCon* aObject = + CAccPolAudioTopologyObjectCon::NewLC(); + + //Speaker + //OT-3 + CAccPolOutputTerminal* OT3 = CAccPolOutputTerminal::NewLC( 3, + CAccPolOutputTerminal::EAPTHeadphone, + 2 ); + //Connected to FU-2 + aObject->AddL( *OT3 ); + + //FU2 + CAccPolFeatureUnit* FU2 = CAccPolFeatureUnit::NewLC( 2, 8 ); + // Volume control object. + CAccPolVolumeControl* speakerRightVolume = + CAccPolVolumeControl::NewLC( KAccRightFrontChannel, 7, 5, 20, 5 ); + CAccPolVolumeControl* speakerLeftVolume = + CAccPolVolumeControl::NewLC( KAccLeftFrontChannel, 7, 5, 20, 5 ); + + CAccPolMuteControl* speakermute = + CAccPolMuteControl::NewLC( KAccMasterChannel, ETrue ); + + FU2->AddControlL( *speakerRightVolume ); + FU2->AddControlL( *speakerLeftVolume ); + FU2->AddControlL( *speakermute ); + + //Connected to MU-8 + aObject->AddL( *FU2 ); + + CAccPolMixerUnit* MU8 = CAccPolMixerUnit::NewLC( 8 ); + MU8->AddSourceIdL( 1 ); + MU8->AddSourceIdL( 7 ); + + //Connected to IT1 and FU7 + aObject->AddL( *MU8 ); + + //Choice one + //IT-1 + TUint8 aChannelCount = 2; + TUint16 aChannelConfig = 0; + aChannelConfig = aChannelConfig | KAccRightFrontChannel; + aChannelConfig = aChannelConfig | KAccLeftFrontChannel; + + CAccPolInputTerminal* IT1 = CAccPolInputTerminal::NewLC( 1, + CAccPolInputTerminal::EAPTStream, + aChannelCount, + aChannelConfig ); + aObject->AddL( *IT1 ); + + //choice two + //FU7 + CAccPolFeatureUnit* FU7 = CAccPolFeatureUnit::NewLC( 7, 5 ); //Connected to FU5 + // Volume control object. + CAccPolVolumeControl* sidetoneRightVolume = + CAccPolVolumeControl::NewLC( KAccMasterChannel, 7, 5, 20, 5 ); + CAccPolVolumeControl* sidetoneLeftVolume = + CAccPolVolumeControl::NewLC( KAccMasterChannel, 7, 5, 20, 5 ); + + FU7->AddControlL( *sidetoneRightVolume ); + FU7->AddControlL( *sidetoneLeftVolume ); + + aObject->AddL( *FU7 ); + + //Microphone + //IT-4 + + //OT-6 + CAccPolOutputTerminal* OT6 = CAccPolOutputTerminal::NewLC( 6, + CAccPolOutputTerminal::EAPTStream, + 10 ); + //Connected to SU-10 + aObject->AddL( *OT6 ); + + //SU-10 + CAccPolSelectorUnit* SU10 = CAccPolSelectorUnit::NewLC( 10, 1 ); + + // Connected to FU 5 + SU10->AddSourceIdL( 5 ); + aObject->AddL( *SU10 ); + + //FU5 + CAccPolFeatureUnit* FU5 = CAccPolFeatureUnit::NewLC( 5, 9 ); + + // Volume control object. + CAccPolVolumeControl* micRightVolume = + CAccPolVolumeControl::NewLC( KAccRightFrontChannel, 7, 5, 20, 5 ); + CAccPolVolumeControl* micLeftVolume = + CAccPolVolumeControl::NewLC( KAccLeftFrontChannel, 7, 5, 20, 5 ); + CAccPolMuteControl* micmute = CAccPolMuteControl::NewLC( KAccMasterChannel, + ETrue ); + + FU5->AddControlL( *micRightVolume ); + FU5->AddControlL( *micLeftVolume ); + FU5->AddControlL( *micmute ); + + //Connected to FU-9 + aObject->AddL( *FU5 ); + + ///FU9 + CAccPolFeatureUnit* FU9 = CAccPolFeatureUnit::NewLC( 9, 4 ); + //Connected IT-4 + aObject->AddL( *FU9 ); + + CAccPolInputTerminal* IT4 = CAccPolInputTerminal::NewLC( 4, + CAccPolInputTerminal::EAPTMicrophone, + aChannelCount, + aChannelConfig ); + aObject->AddL( *IT4 ); + + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + //Externalize container to buf + RBufWriteStream wStrm; + ( void )wStrm.Open( *buf ); + wStrm.PushL(); + aObject->ExternalizeL( wStrm ); + wStrm.CommitL(); + wStrm.Close(); + wStrm.Pop(); + TPtr8 ptr( buf->Ptr( 0 ) ); + TInt retval = prop.Set( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + ptr ); + + // Notify ASY stub + if( aParameter.iArg2 ) + { + PublishAndSubscribeL( aParameter ); + } + + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( IT4 ); + CleanupStack::PopAndDestroy( FU9 ); + CleanupStack::PopAndDestroy( micmute ); + CleanupStack::PopAndDestroy( micLeftVolume ); + CleanupStack::PopAndDestroy( micRightVolume ); + CleanupStack::PopAndDestroy( FU5 ); + CleanupStack::PopAndDestroy( SU10 ); + CleanupStack::PopAndDestroy( OT6 ); + CleanupStack::PopAndDestroy( sidetoneLeftVolume ); + CleanupStack::PopAndDestroy( sidetoneRightVolume ); + CleanupStack::PopAndDestroy( FU7 ); + CleanupStack::PopAndDestroy( IT1 ); + CleanupStack::PopAndDestroy( MU8 ); + CleanupStack::PopAndDestroy( speakermute ); + CleanupStack::PopAndDestroy( speakerLeftVolume ); + CleanupStack::PopAndDestroy( speakerRightVolume ); + CleanupStack::PopAndDestroy( FU2 ); + CleanupStack::PopAndDestroy( OT3 ); + CleanupStack::PopAndDestroy( aObject ); + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CallAccessoryFunctionL +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::CallAccessoryFunctionL( TTFAccessoryTestCaseStateControl& aParameter ) + { + + // COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CallAccessoryFunctionL(%d, %d, %d)" ), aParameter.iAccessoryFunction, aParameter.iArg1, aParameter.iArg2 ) ); + if( !iInitialized ) + { + InitializeL(); + } + + TInt retval = KTFErrAccessoryServiceMissing; + + switch( aParameter.iAccessoryFunction ) + { + case ETFAccessorySet_ObjectPubSub: + { + CreateObjectPubSubL( ( TStreamConObjectType )aParameter.iArg1, + aParameter.iArg2, + ( TStreamConObjectType )aParameter.iArg3, + aParameter.iArg4 ); + retval = KErrNone; + } + break; + + case ETFAccessorySet_TopologyObjectsPubSub: + { + CreateTopologyObjectsToPubSubL( aParameter ); + retval = KErrNone; + } + break; + + case ETFAccessorySet_PubSub: + { + RProperty prop; + prop.Define( KTFAccessoryTestProperty, + KTFAccessoryNotifierMethod, + RProperty::EInt ); + retval = prop.Set( KTFAccessoryTestProperty, + KTFAccessoryNotifierMethod, + aParameter.iArg1 ); + } + break; + + case ETFConnectWiredAccessory: + { + PublishAndSubscribeL( aParameter ); + retval = KErrNone; + } + break; + + case ETFClearStack: + { + CTFTestControlObserver* observerItem; + TInt count = 0; + if( !iStack.IsEmpty() ) + { + iStackIter.SetToFirst(); + + while( ( observerItem = iStackIter++ ) != NULL ) + { + observerItem->Cancel(); + iStack.Remove( *observerItem ); + delete observerItem; + count++; + }; + } + + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestCaseControl::ETF_Pappa - count=%d " ), count ) ); + retval = KErrNone; + } + break; + + case ETFDisconnectWiredAccessory: + { + retval = KErrNone; + PublishAndSubscribeL( aParameter ); + TAccPolGenericID emptyInstance; + iGenericId[aParameter.iGid] = emptyInstance; + } + break; + + case ETFCheckCapabilityGroup: + { + if( aParameter.iArg2 + == iGenericId[aParameter.iGid].SubblockCaps( aParameter.iArg3 ) ) + { + retval = KErrNone; + } + else + { + retval = KErrNotFound; + } + } + break; + + case ETFCheckCapability: + { + RAccessoryConnection accessoryConnectionn; + accessoryConnectionn.CreateSubSession( iAccessoryServer ); + + CAccPolSubblockNameArray* nameArrayy = + CAccPolSubblockNameArray::NewL(); + CleanupStack::PushL( nameArrayy ); + accessoryConnectionn.GetSubblockNameArrayL( iGenericId[aParameter.iGid], + *nameArrayy ); + + if( aParameter.iArg2 == nameArrayy->HasName( aParameter.iArg3 ) ) + { + retval = KErrNone; + } + else + { + retval = KErrNotFound; + } + + CleanupStack::PopAndDestroy( nameArrayy ); + accessoryConnectionn.CloseSubSession(); + } + break; + + case ETFFindAndCheckRequest: + + { + FindAndCheckRequestL(&retval, aParameter); + } + break; + + case ETFFindAndCheckObjectRequest: + { + CTFAccessoryTestCaseControl* testCase = STATIC_CAST( CTFAccessoryTestCaseControl*, CurrentTestCase()); + TRACE_ASSERT( testCase != NULL ); + if( testCase != NULL ) + { + if( !iStack.IsEmpty() ) + { + iStackIter.SetToFirst(); + + while( ( iObserverItem = iStackIter++ ) != NULL ) + { + if( iObserverItem->FindRequest( aParameter.iRequestType ) ) + { + testCase->CheckObjectRequest( iObserverItem->iStatus, + iObserverItem->iObjectValue, + iObserverItem->iCapabilityName ); + + if( !iStack.IsEmpty() ) // Check if observes are already deleted by CheckRequest() + { + if( KTFDontDeleteObserver != aParameter.iArg1 ) + { + iStack.Remove( *iObserverItem ); + delete iObserverItem; + return; + } + else + { + User::Leave( KTFDontDeleteObserver ); + } + } + else + { + retval = KErrGeneral; + } + } + } + } + else + { + retval = KErrGeneral; + } + } + + retval = KErrNone; + } + break; + + // + // Accessory Connection + // + case ETFAccessoryConnection_Open: + { + AccessoryConnectionOpenClose(ETFAccessoryConnection_Open, &retval); + } + break; + + case ETFAccessoryConnection_Close: + + { + AccessoryConnectionOpenClose(ETFAccessoryConnection_Close, &retval); + } + break; + + // + // Accessory Settings + // + case ETFAccessorySettings_Open: + { + AccessorySettingsOpenClose(ETFAccessorySettings_Open, &retval); + } + break; + + case ETFAccessorySettings_Close: + { + AccessorySettingsOpenClose(ETFAccessorySettings_Close, &retval); + } + break; + + case ETFSetHWDeviceSettings: + { + retval + = iAccessorySettings->SetHWDeviceSettingsL( aParameter.iArg1, + ( TBool )aParameter.iArg2 ); + } + break; + + case ETFGetHWDeviceSettings: + { + TUint32 aSettingsValue( 0 ); + retval = iAccessorySettings->GetHWDeviceSettings( aSettingsValue ); + + if( aSettingsValue != aParameter.iArg1 ) + { + retval = KErrArgument; + } + } + break; + + case ETFGetSupportedHWDeviceSettings: + { + TUint32 aSettingsSupportedValue( 0 ); + + retval + = iAccessorySettings->GetSupportedHWDeviceSettings( aSettingsSupportedValue ); + + if( aSettingsSupportedValue != ( aParameter.iArg1 + | aParameter.iArg2 ) ) + { + retval = KErrArgument; + } + } + break; + + case ETFSetIntAccessoryModeSetting: + { + TAccMode aAccMode = ( TAccMode )aParameter.iArg1; + TAccModeSetting aSetting; + + //Set Lights + aSetting.SetId( aParameter.iArg2 ); + aSetting.SetTInt( aParameter.iArg4 ); + + retval = iAccessorySettings->SetAccessoryModeSettingL( aAccMode, + aSetting ); + } + break; + + case ETFSetBoolAccessoryModeSetting: + { + TAccMode aAccMode = ( TAccMode )aParameter.iArg1; + TAccModeSetting aSetting; + + //Set Lights + aSetting.SetId( aParameter.iArg2 ); + aSetting.SetTBool( aParameter.iArg4 ); + + retval = iAccessorySettings->SetAccessoryModeSettingL( aAccMode, + aSetting ); + } + break; + + case ETFSetDesAccessoryModeSetting: + { + TAccMode aAccMode = ( TAccMode )aParameter.iArg1; + TAccModeSetting aSetting; + + TBuf buf; + buf.Num( aParameter.iArg3 ); + // buf.Copy( *aParameter.iArg3 ); + + aSetting.SetId( aParameter.iArg2 ); + aSetting.SetTDes( buf ); + retval = iAccessorySettings->SetAccessoryModeSettingL( aAccMode, + aSetting ); + } + break; + + case ETFGetIntAccessoryModeSetting: + { + TInt aSettingsValueInt; + + TAccMode aAccMode = ( TAccMode )aParameter.iArg1; + TAccModeSetting aSetting; + aSetting.SetId( aParameter.iArg2 ); + + retval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, + aSetting ); + + if( aSetting.Type() == EAccModeSettingInt ) + { + retval = aSetting.GetTInt( aSettingsValueInt ); + + if( retval != KErrNotFound ) + { + if( aSettingsValueInt == aParameter.iArg4 ) + { + retval = KErrNone; + } + else + { + retval = KErrArgument; + } + } + } + else + { + retval = KErrNotFound; + } + } + break; + + case ETFGetBoolAccessoryModeSetting: + { + TBool aSettingsValueBool; + + TAccMode aAccMode = ( TAccMode )aParameter.iArg1; + TAccModeSetting aSetting; + aSetting.SetId( aParameter.iArg2 ); + + retval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, + aSetting ); + + if( aSetting.Type() == EAccModeSettingBool ) + { + retval = aSetting.GetTBool( aSettingsValueBool ); + + if( retval != KErrNotFound ) + { + if( aSettingsValueBool == ( TBool )aParameter.iArg4 ) + { + retval = KErrNone; + } + else + { + retval = KErrArgument; + } + } + } + else + { + retval = KErrNotFound; + } + } + break; + + case ETFGetDesAccessoryModeSetting: + { + TBuf aSettingsValueDes; + + TAccMode aAccMode = ( TAccMode )aParameter.iArg1; + TAccModeSetting aSetting; + aSetting.SetId( aParameter.iArg2 ); + + retval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, + aSetting ); + + if( aSetting.Type() == EAccModeSettingDes ) + { + retval = aSetting.GetTDes( aSettingsValueDes ); + + if( retval != KErrNotFound ) + { + TBuf buffer; + buffer.Num( aParameter.iArg3 ); + if( KErrNone == aSettingsValueDes.Compare( buffer ) ) + { + retval = KErrNone; + } + else + { + retval = KErrArgument; + } + } + } + else + { + retval = KErrNotFound; + } + } + break; + + case ETFSetSeveralAccessoryModeSetting: + { + + TAccModeSetting accModeSettingIn; + TAccMode tAccMode = EAccModeWirelessHeadset; + TBuf aDesIn; + // Set + // setting 1 + accModeSettingIn.SetId( 11 ); // unknown TInt + accModeSettingIn.SetTInt( 1 ); + TAccModeSettingArray arrayIn; + arrayIn.AddSetting( accModeSettingIn ); + + // setting 2 + accModeSettingIn.SetId( 12 ); // unknown Des + _LIT( KAccSetting2, "012345678901234567890" ); + aDesIn.Copy( KAccSetting2 ); + accModeSettingIn.SetTDes( aDesIn ); + arrayIn.AddSetting( accModeSettingIn ); + + // setting 3 + accModeSettingIn.SetId( 13 ); // unknown TBool + accModeSettingIn.SetTBool( ETrue ); + arrayIn.AddSetting( accModeSettingIn ); + + retval = iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, + arrayIn ); + + } + break; + + case ETFGetSeveralAccessoryModeSetting: + { + + TAccModeSetting accModeSettingOut; + TAccMode tAccMode = EAccModeWirelessHeadset; + TBuf aDesOut; + TAccModeSettingArray arrayOut; + TInt intOut( 0 ); + // set input parameters for GetAccessoryModeSettings() + // setting 11 + accModeSettingOut.SetId( 11 ); + arrayOut.AddSetting( accModeSettingOut ); + + // setting 12 + accModeSettingOut.SetId( 12 ); + arrayOut.AddSetting( accModeSettingOut ); + + // setting 13 + accModeSettingOut.SetId( 13 ); + arrayOut.AddSetting( accModeSettingOut ); + + retval = iAccessorySettings->GetAccessoryModeSettings( tAccMode, + arrayOut ); + + // Check that got settings are right + + TInt count = arrayOut.GetArraySize(); + TInt foundCount( 0 ); + + for( TInt index = 0; index < count; index++ ) + { + arrayOut.GetSetting( index, accModeSettingOut ); + + if( 11 == accModeSettingOut.Id() ) + { + + accModeSettingOut.GetTInt( intOut ); + + if( 1 == intOut ) + { + foundCount++; + } + } + + if( 12 == accModeSettingOut.Id() ) + { + accModeSettingOut.GetTDes( aDesOut ); + + if( KErrNone == aDesOut.Compare( _L("012345678901234567890") ) ) + { + foundCount++; + } + + } + + if( 13 == accModeSettingOut.Id() ) + { + + accModeSettingOut.GetTBool( intOut ); + + if( intOut ) + { + foundCount++; + } + } + } + + if( foundCount != 3 ) + { + retval = KErrNotFound; + } + + // + // Reset Settings + // + TAccModeSetting accModeSettingIn; + TBuf aDesIn; + // Set + // setting 1 + accModeSettingIn.SetId( 11 ); // unknown TInt + accModeSettingIn.SetTInt( 0 ); + TAccModeSettingArray arrayIn; + arrayIn.AddSetting( accModeSettingIn ); + + // setting 2 + accModeSettingIn.SetId( 12 ); // unknown Des + _LIT( KAccSetting2, "" ); + aDesIn.Copy( KAccSetting2 ); + accModeSettingIn.SetTDes( aDesIn ); + arrayIn.AddSetting( accModeSettingIn ); + + // setting 3 + accModeSettingIn.SetId( 13 ); // unknown TBool + accModeSettingIn.SetTBool( EFalse ); + arrayIn.AddSetting( accModeSettingIn ); + + iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, arrayIn ); + } + break; + + // + // Accessory Single Connection + // + case ETFAccessorySingleConnection_Open: + { + if( iAccessorySingleConnection == NULL ) + { + iAccessorySingleConnection + = new ( ELeave ) RAccessorySingleConnection; + retval + = iAccessorySingleConnection->CreateSubSession( iAccessoryServer ); + } + else + { + retval = KErrNone; + } + } + break; + + case ETFAccessorySingleConnection_Close: + { + TRACE_ASSERT( iAccessorySingleConnection != NULL ); + + if( iAccessorySingleConnection != NULL ) + { + iAccessorySingleConnection->CloseSubSession(); + delete iAccessorySingleConnection; + iAccessorySingleConnection = NULL; + } + retval = KErrNone; + } + break; + + case ETFAccessoryNotifyNewAccessoryConnected: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyNewAccessoryConnected( iGenericId[aParameter.iGid] ); + retval = KErrNone; + } + break; + + case ETFAccessoryNotifyAccessoryDisconnected: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyAccessoryDisconnected( iGenericId[aParameter.iGid] ); + retval = KErrNone; + } + break; + + case ETFNotifyIntAccessoryValueChanged: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyIntegerAccessoryValueChanged( iGenericId[aParameter.iGid], + aParameter.iArg3 ); + retval = KErrNone; + } + break; + + case ETFNotifyBoolAccessoryValueChanged: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyBooleanAccessoryValueChanged( iGenericId[aParameter.iGid], + aParameter.iArg3 ); + retval = KErrNone; + } + break; + + case ETFNotifyObjectAccessoryValueChanged: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyObjectAccessoryValueChanged( iGenericId[aParameter.iGid], + aParameter.iArg3 ); + retval = KErrNone; + } + break; + + case ETFAccessoryIntGetValue: + { + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TAccValueTypeTInt aIntValue; + + iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], + aNameRecord, + aIntValue ); + + if( aIntValue.iValue == aParameter.iArg2 ) + { + retval = KErrNone; + } + else + { + retval = KErrArgument; + } + } + break; + + case ETFAccessoryBoolGetValue: + { + RAccessoryConnection accessoryConnection; + accessoryConnection.CreateSubSession( iAccessoryServer ); + + TAccPolNameRecord nameRecord; + nameRecord.SetNameL( aParameter.iArg3 ); + TAccValueTypeTBool boolValue; + retval + = accessoryConnection.GetValueL( iGenericId[aParameter.iGid], + nameRecord, + boolValue ); + + if( boolValue.iValue != aParameter.iArg1 ) + { + retval = KErrArgument; + } + + accessoryConnection.CloseSubSession(); + } + break; + + case ETFAccessoryDes8GetValue: + { + TBuf8<80> + worm( _L8("Malicious Worm Attach with extra long data with extra long content" )); + TBuf8<85> valueBuf; + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg1 ); + TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, valueBuf ) ); + + if( err == aParameter.iExpectedResult ) + { + + if( aParameter.iExpectedResult == KErrArgument ) + { + retval = KErrNone; + } + else + { + if( KErrNone == valueBuf.Compare( worm ) ) + { + RDebug::RawPrint( valueBuf ); + retval = KErrNone; + } + else + { + retval = KErrArgument; + } + } + } + else + { + retval = KErrArgument; + } + } + break; + + case ETFAccessoryObjectParseTopology: + { + + TInt rspeaker( KErrGeneral ); + TInt lspeaker( KErrGeneral ); + TInt rmic( KErrGeneral ); + TInt lmic( KErrGeneral ); + TInt mute( KErrGeneral ); + TInt sidetone( KErrGeneral ); + // + // Find speaker volume object in USB headset case. + // + CAccPolAudioUnitBase* audioUnit = NULL; + CAccPolAudioControlBase* audioControl = NULL; + //CAccPolOutputTerminal* ouputTerminal = NULL; + + if( iTopologyContainer->OutputTerminalL( CAccPolOutputTerminal::EAPTHeadphone, + audioUnit ) ) + { + if( audioUnit->GetNextAudioUnitL( audioUnit ) ) + { + if( audioUnit->ObjectType() + == EAccPolAudioFeatureUnitObject ) + { + if( audioUnit->GetAudioControlL( EAccPolAudioVolumeControlObject, + KAccRightFrontChannel, + audioControl ) ) + { + iSpeakerRightVolume = CAccPolVolumeControl::NewL(); + *iSpeakerRightVolume + = *reinterpret_cast ( audioControl ); + rspeaker = KErrNone; + } + if( audioUnit->GetAudioControlL( EAccPolAudioVolumeControlObject, + KAccLeftFrontChannel, + audioControl ) ) + { + iSpeakerLeftVolume = CAccPolVolumeControl::NewL(); + *iSpeakerLeftVolume + = *reinterpret_cast ( audioControl ); + lspeaker = KErrNone; + } + if( audioUnit->GetAudioControlL( EAccPolAudioMuteControlObject, + KAccMasterChannel, + audioControl ) ) + { + iSpeakerMute = CAccPolMuteControl::NewL(); + *iSpeakerMute + = *reinterpret_cast ( audioControl ); + mute = KErrNone; + } + + } + } + } + + // + // Find mic volume object in USB headset case. + // + if( iTopologyContainer->OutputTerminalL( CAccPolOutputTerminal::EAPTStream, + audioUnit ) ) + { + do + { + } + while( audioUnit->GetNextAudioUnitL( audioUnit ) + && audioUnit->ObjectType() != EAccPolAudioFeatureUnitObject ); + + RPointerArray aAudioControls; + audioUnit->GetAudioControlsL( KAccRightFrontChannel, + aAudioControls ); + + if( aAudioControls.Count() > 0 ) + { + iMicRightVolume = CAccPolVolumeControl::NewL(); + *iMicRightVolume + = *reinterpret_cast ( aAudioControls.operator[]( 0 ) ); + rmic = KErrNone; + } + aAudioControls.Reset(); + + audioUnit->GetAudioControlsL( KAccLeftFrontChannel, + aAudioControls ); + + if( aAudioControls.Count() > 0 ) + { + iMicLeftVolume = CAccPolVolumeControl::NewL(); + *iMicLeftVolume + = *reinterpret_cast ( aAudioControls.operator[]( 0 ) ); + lmic = KErrNone; + } + + // + // Find sidetone volume object in USB headset case. + // + iTopologyContainer->OutputTerminalL( CAccPolOutputTerminal::EAPTHeadphone, + audioUnit ); + + do + { + audioUnit->GetNextAudioUnitL( audioUnit ); + } + while( audioUnit->ObjectType() != EAccPolAudioMixerUnitObject ); + + if( audioUnit->SourceIdCount() > 1 ) + { + RPointerArray aAudioUnits; + audioUnit->GetAudioUnitListL( aAudioUnits ); + + for( TInt i = 0; i < aAudioUnits.Count(); i++ ) + { + if( aAudioUnits.operator[]( i )->ObjectType() + == EAccPolAudioFeatureUnitObject ) + { + audioUnit = aAudioUnits.operator[]( i ); + break; + } + } + } + + aAudioControls.Reset(); + audioUnit->GetAudioControlsL( aAudioControls ); + if( aAudioControls.Count() == 2 ) + { + sidetone = KErrNone; + } + } + + retval = ( rspeaker | lspeaker | rmic | lmic | mute | sidetone ); + + } + break; + + case ETFAccessoryGetStreamObjects: + { + if( iStreamContainer != NULL ) + { + delete iStreamContainer; + iStreamContainer = NULL; + } + iStreamContainer = CAccPolAudioStreamFormatCon::NewL(); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iStreamContainer ) ); + + if( err == aParameter.iExpectedResult ) + { + //externalize container to bufFromASY + CBufFlat* bufFromASY = + CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( bufFromASY ); + bufFromASY->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + RBufWriteStream wStrm; + ( void )wStrm.Open( *bufFromASY ); + wStrm.PushL(); + iStreamContainer->ExternalizeL( wStrm ); + wStrm.CommitL(); + wStrm.Close(); + wStrm.Pop(); + TPtr8 ptrbufFromASY( bufFromASY->Ptr( 0 ) ); + + //Read container from PubSub + RProperty prop; + RBufReadStream rStrm; + CBufFlat* bufFromPubSub = + CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( bufFromPubSub ); + bufFromPubSub->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + TPtr8 ptrBufFromPubSub( bufFromPubSub->Ptr( 0 ) ); + TInt ret = prop.Get( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + ptrBufFromPubSub ); + + TInt k = sizeof( bufFromASY ); + TInt kk = sizeof( bufFromPubSub ); + + bufFromASY->Compress(); + bufFromPubSub->Compress(); + + k = sizeof( bufFromASY ); + kk = sizeof( bufFromPubSub ); + + retval + = ( 0 + == memcompare( reinterpret_cast ( &ptrbufFromASY ), + sizeof( bufFromASY ), + reinterpret_cast ( &ptrBufFromPubSub ), + sizeof( bufFromASY ) ) ) ? KErrNone : KErrGeneral; + + CleanupStack::PopAndDestroy( bufFromPubSub ); + CleanupStack::PopAndDestroy( bufFromASY ); + } + } + break; + + case ETFAccessoryGetStreamObjectsFromPolicy: + { + if( iStreamContainer != NULL ) + { + delete iStreamContainer; + iStreamContainer = NULL; + } + iStreamContainer = CAccPolAudioStreamFormatCon::NewL(); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iStreamContainer ) ); + + RPointerArray inputStreamObjects; + RPointerArray outputStreamObjects; + + iStreamContainer->GetInputStreamFormatsL( inputStreamObjects ); + iStreamContainer->GetOutputStreamFormatsL( outputStreamObjects ); + + CAccPolAudioStreamFormat* inputStream = + inputStreamObjects.operator[]( 0 ); + CAccPolAudioStreamFormat* ouputStream = + outputStreamObjects.operator[]( 0 ); + + retval = err; + } + break; + + case ETFAccessorySetStreamObjects: + { + CAccPolAudioStreamFormatCon* setContainer = CAccPolAudioStreamFormatCon::NewLC(); + + RPointerArray inputStreamObjects; + RPointerArray outputStreamObjects; + + iStreamContainer->GetInputStreamFormatsL( inputStreamObjects ); + CAccPolAudioStreamFormat* inputStream = NULL; + for(TInt i=0; iAudioFormat() == KUidFormatPCM16 && + inputStream->UnitId() == 0 && + inputStream->StreamType() == CAccPolAudioStreamFormat::EStereo && + inputStream->BitResolution() == CAccPolAudioStreamFormat::EBitsPerSample16 && + inputStream->SamFreq() == 200 ) + { + setContainer->AddL( *inputStream ); + break; + } + } + + iStreamContainer->GetOutputStreamFormatsL( outputStreamObjects ); + CAccPolAudioStreamFormat* outputStream = NULL; + for(TInt i=0; iAudioFormat() == KUidFormatPCM16 && + outputStream->UnitId() == 0 && + outputStream->StreamType() == CAccPolAudioStreamFormat::EMono && + outputStream->BitResolution() == CAccPolAudioStreamFormat::EBitsPerSample32 && + outputStream->SamFreq() == 200 ) + { + setContainer->AddL( *outputStream ); + break; + } + } + + RBufWriteStream wStrm; + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + (void)wStrm.Open( *buf ); + wStrm.PushL(); + setContainer->ExternalizeL( wStrm ); + wStrm.Close(); + wStrm.Pop(); + TPtr8 ptr( buf->Ptr( 0 ) ); + + retval = RProperty::Set( KTFAccessoryTestProperty, KTFAccessoryObjectMethod, ptr ); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + + TRAPD( setErr, iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, *setContainer ) ); + + retval = setErr; + + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( setContainer ); + inputStreamObjects.Close(); + outputStreamObjects.Close(); + } + break; + + case ETFAccessoryGetTopologyObjects: + { + if( iTopologyContainer != NULL ) + { + delete iTopologyContainer; + iTopologyContainer = NULL; + } + + iTopologyContainer = CAccPolAudioTopologyObjectCon::NewL(); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iTopologyContainer ) ); + + if( err == aParameter.iExpectedResult ) + { + //externalize container to bufFromASY + CBufFlat* bufFromASY = + CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( bufFromASY ); + bufFromASY->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + RBufWriteStream wStrm; + ( void )wStrm.Open( *bufFromASY ); + wStrm.PushL(); + iTopologyContainer->ExternalizeL( wStrm ); + wStrm.CommitL(); + wStrm.Close(); + wStrm.Pop(); + TPtr8 ptrbufFromASY( bufFromASY->Ptr( 0 ) ); + + //Read container from PubSub + RProperty prop; + RBufReadStream rStrm; + CBufFlat* bufFromPubSub = + CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( bufFromPubSub ); + bufFromPubSub->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + TPtr8 ptrBufFromPubSub( bufFromPubSub->Ptr( 0 ) ); + TInt ret = prop.Get( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + ptrBufFromPubSub ); + + TInt k = sizeof( bufFromASY ); + TInt kk = sizeof( bufFromPubSub ); + + bufFromASY->Compress(); + bufFromPubSub->Compress(); + + k = sizeof( bufFromASY ); + kk = sizeof( bufFromPubSub ); + + retval + = ( 0 + == memcompare( reinterpret_cast ( &ptrbufFromASY ), + sizeof( bufFromASY ), + reinterpret_cast ( &ptrBufFromPubSub ), + sizeof( bufFromASY ) ) ) ? KErrNone : KErrGeneral; + + CleanupStack::PopAndDestroy( bufFromPubSub ); + CleanupStack::PopAndDestroy( bufFromASY ); + } + } + break; + + case ETFAccessoryGetVolumeControlObjects: + { + + if( iTopologyContainer != NULL ) + { + delete iTopologyContainer; + iTopologyContainer = NULL; + } + + iTopologyContainer = CAccPolAudioTopologyObjectCon::NewL(); + + iTopologyContainer->AddL( *iSpeakerRightVolume ); + iTopologyContainer->AddL( *iSpeakerLeftVolume ); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iTopologyContainer ) ); + + CAccPolVolumeControl* rightVolume; + rightVolume = ( CAccPolVolumeControl* )iTopologyContainer->AtL( 0 ); + + CAccPolVolumeControl* leftVolume; + leftVolume = ( CAccPolVolumeControl* )iTopologyContainer->AtL( 1 ); + + if( err == aParameter.iExpectedResult ) + { + retval = KErrNone; + } + } + break; + + case ETFAccessorySetVolumeControlObjects: + { + RBufWriteStream wStrm; + CAccPolAudioTopologyObjectCon* setContainer = + CAccPolAudioTopologyObjectCon::NewLC(); + + iSpeakerRightVolume->SetVolumeDb( aParameter.iArg1 ); + iSpeakerRightVolume->SetMinVolumeDb( aParameter.iArg2 ); + iSpeakerRightVolume->SetMaxVolumeDb( aParameter.iArg4 ); + iSpeakerRightVolume->SetVolumeResDb( 0x05 ); + setContainer->AddL( *iSpeakerRightVolume ); + iSpeakerLeftVolume->SetVolumeDb( aParameter.iArg1 ); + iSpeakerLeftVolume->SetMinVolumeDb( aParameter.iArg2 ); + iSpeakerLeftVolume->SetMaxVolumeDb( aParameter.iArg4 ); + iSpeakerLeftVolume->SetVolumeResDb( 0x05 ); + setContainer->AddL( *iSpeakerLeftVolume ); + + CBufFlat* buf = + CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + ( void )wStrm.Open( *buf ); + wStrm.PushL(); + setContainer->ExternalizeL( wStrm ); + wStrm.Close(); + wStrm.Pop(); + TPtr8 ptr( buf->Ptr( 0 ) ); + + retval = RProperty::Set( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + ptr ); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TRAPD( setErr, iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, *setContainer ) ); + + retval = setErr; + + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( setContainer ); + } + break; + + case ETFAccessoryGetMuteControlObjects: + { + + if( iTopologyContainer != NULL ) + { + delete iTopologyContainer; + iTopologyContainer = NULL; + } + + iTopologyContainer = CAccPolAudioTopologyObjectCon::NewL(); + + iTopologyContainer->AddL( *iSpeakerMute ); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TRAPD( err, iAccessorySingleConnection->GetValueL( iGenericId[aParameter.iGid], aNameRecord, *iTopologyContainer ) ); + + CAccPolMuteControl* mute; + mute = ( CAccPolMuteControl* )iTopologyContainer->AtL( 0 ); + + if( err == aParameter.iExpectedResult ) + { + retval = KErrNone; + } + } + break; + + case ETFAccessorySetMuteControlObjects: + { + RBufWriteStream wStrm; + CAccPolAudioTopologyObjectCon* setContainer = + CAccPolAudioTopologyObjectCon::NewLC(); + + iSpeakerMute->SetMute( aParameter.iArg1 ); + setContainer->AddL( *iSpeakerMute ); + + CBufFlat* buf = + CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + ( void )wStrm.Open( *buf ); + wStrm.PushL(); + setContainer->ExternalizeL( wStrm ); + wStrm.Close(); + wStrm.Pop(); + TPtr8 ptr( buf->Ptr( 0 ) ); + + retval = RProperty::Set( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + ptr ); + + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TRAPD( setErr, iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, *setContainer ) ); + + retval = setErr; + + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( setContainer ); + } + break; + + // + // Accessory Control + // + + case ETFAccessoryControl_Open: + { + if( iAccessoryControl == NULL ) + { + iAccessoryControl = new ( ELeave ) RAccessoryControl; + retval = iAccessoryControl->CreateSubSession( iAccessoryServer ); + } + else + { + retval = KErrNone; + } + } + break; + + case ETFAccessoryControl_Close: + { + TRACE_ASSERT( iAccessoryControl != NULL ); + + if( iAccessoryControl != NULL ) + { + iAccessoryControl->CloseSubSession(); + delete iAccessoryControl; + iAccessoryControl = NULL; + } + retval = KErrNone; + } + break; + + case ETFAccessoryNotifyAccessoryConnectionStatusChanged: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyAccessoryConnectionStatusChanged( iGenericIdArray ); + retval = KErrNone; + } + break; + + case ETFSyncGetAccessoryConnectionStatus: + { + iAccessoryConnection->GetAccessoryConnectionStatus( iGenericIdArray ); + + if( iGenericIdArray.Count() != aParameter.iArg1 ) + { + retval = KErrArgument; + } + else + { + retval = KErrNone; + } + } + break; + + case ETFASyncGetAccessoryConnectionStatus: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->GetAccessoryConnectionStatus( iGenericIdArray ); + retval = KErrNone; + } + break; + + case ETFSetIntValue: + { + SetIntValue(aParameter, &retval); + } + break; + + case ETFSetBoolValue: + { + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TAccValueTypeTBool aBoolValue; + aBoolValue.iValue = aParameter.iArg1; + retval = iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], + aNameRecord, + aBoolValue ); + } + break; + + // + //Tuupaa + // + case ETFAccessoryValueChangedNotifyInt: + { + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( KAccAudioOutputType ); + TAccValueTypeTInt aIntValue; + aIntValue.iValue = EAccAudioOutPutTypePublic; + iAccessoryControl->AccessoryValueChangedNotifyL( iGenericId[aParameter.iGid], + aNameRecord, + aIntValue ); + retval = KErrNone; + } + break; + + case ETFAccessoryValueChangedNotifyBool: + { + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TAccValueTypeTBool aBoolValue; + aBoolValue.iValue = ETrue; + iAccessoryControl->AccessoryValueChangedNotifyL( iGenericId[aParameter.iGid], + aNameRecord, + aBoolValue ); + retval = KErrNone; + } + break; + + // + // BT Control + // + case ETFBTAccessoryValueChangedNotifyBool: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + TAccPolNameRecord nameRecord; + nameRecord.SetNameL( aParameter.iArg3 ); + TAccValueTypeTBool boolValue; + boolValue.iValue = aParameter.iArg4; + iAccessoryBTControl->AccessoryValueChangedNotifyL( btaddr, + nameRecord, + boolValue ); + retval = KErrNone; + } + break; + + case ETFBTAccessoryValueChangedNotifyInt: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + TAccPolNameRecord nameRecord; + nameRecord.SetNameL( aParameter.iArg3 ); + TAccValueTypeTInt intValue; + intValue.iValue = aParameter.iArg4; + iAccessoryBTControl->AccessoryValueChangedNotifyL( btaddr, + nameRecord, + intValue ); + retval = KErrNone; + } + break; + + case ETFAccessoryBtControl_Open: + { + if( iAccessoryBTControl == NULL ) + { + iAccessoryBTControl = new ( ELeave ) RAccessoryBTControl; + retval + = iAccessoryBTControl->CreateSubSession( iAccessoryServer ); + } + else + { + retval = KErrNone; + } + } + break; + + case ETFAccessoryBtControl_Close: + { + TRACE_ASSERT( iAccessoryBTControl != NULL ); + + if( iAccessoryBTControl != NULL ) + { + iAccessoryBTControl->CloseSubSession(); + delete iAccessoryBTControl; + iAccessoryBTControl = NULL; + } + retval = KErrNone; + } + break; + + case ETFAccessoryBtConnectAccessory: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->ConnectBTAccessory( btaddr ); + retval = KErrNone; + } + break; + case ETFAccessoryBtDisconnectAccessory: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + TRequestStatus status; + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->DisconnectBTAccessory( btaddr ); + retval = KErrNone; + TAccPolGenericID emptyInstance; + iGenericId[aParameter.iGid] = emptyInstance; + } + break; + + case ETFAccessoryNotifyBluetoothAudioLinkOpenReq: + { + //TRequestStatus status; + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyBluetoothAudioLinkOpenReq(); + retval = KErrNone; + } + break; + + case ETFAccessoryBluetoothAudioLinkOpenedNotify: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkOpenedNotifyL( btaddr, (TAccAudioType)aParameter.iArg3 ) ); + + if( err == aParameter.iExpectedResult ) + { + retval = KErrNone; + } + else + { + retval = KErrGeneral; + } + } + break; + + case ETFAccessoryBluetoothAudioLinkOpenResp: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + TInt response( aParameter.iArg2 ); + TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkOpenRespL( btaddr, response ) ); + + if( err == aParameter.iExpectedResult ) + { + retval = KErrNone; + } + else + { + retval = KErrGeneral; + } + } + break; + + case ETFAccessoryNotifyBluetoothAudioLinkCloseReq: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyBluetoothAudioLinkCloseReq(); + retval = KErrNone; + } + break; + + case ETFAccessoryBluetoothAudioLinkClosedNotify: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkClosedNotifyL( btaddr, ( TAccAudioType )aParameter.iArg3 ) ); + + if( err == aParameter.iExpectedResult ) + { + retval = KErrNone; + } + else + { + retval = KErrGeneral; + } + } + break; + + case ETFAccessoryBluetoothAudioLinkCloseResp: + { + TBTDevAddr btaddr( aParameter.iArg1 ); + TInt response( aParameter.iArg2 ); + TRAPD( err, iAccessoryBTControl->BluetoothAudioLinkCloseRespL( btaddr, response ) ); + + if( err == aParameter.iExpectedResult ) + { + retval = KErrNone; + } + else + { + retval = KErrGeneral; + } + } + break; + + case ETFAccessoryBtCancelConnectAccessory: + { + TRequestStatus status; + TBTDevAddr btaddr( aParameter.iArg1 ); + iAccessoryBTControl->ConnectAccessory( status, btaddr ); + iAccessoryBTControl->CancelConnectAccessory(); + User::WaitForRequest( status ); + if( KErrCancel != status.Int() ) + { + retval = status.Int(); + } + else + { + retval = KErrNone; + } + } + break; + + case ETFAccessoryBtCancelDisconnectAccessory: + { + TRequestStatus status; + TBTDevAddr btaddr( aParameter.iArg1 ); + iAccessoryBTControl->DisconnectAccessory( status, btaddr ); + iAccessoryBTControl->CancelDisconnectAccessory(); + User::WaitForRequest( status ); + retval = status.Int(); + } + break; + + // + // Accessory Mode + // + case ETFAccessoryMode_Open: + { + if( iAccessoryMode == NULL ) + { + iAccessoryMode = new ( ELeave ) RAccessoryMode; + retval = iAccessoryMode->CreateSubSession( iAccessoryServer ); + } + else + { + retval = KErrNone; + } + } + break; + + case ETFAccessoryMode_Close: + { + TRACE_ASSERT( iAccessoryMode != NULL ); + + if( iAccessoryMode != NULL ) + { + iAccessoryMode->CloseSubSession(); + delete iAccessoryMode; + iAccessoryMode = NULL; + } + retval = KErrNone; + } + break; + + case ETFAccessoryNotifyAccessoryModeChanged: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyAccessoryModeChanged(); + retval = KErrNone; + } + break; + + case ETFAccessoryAccessoryModeSync: + { + TAccPolAccessoryMode mode; + retval = iAccessoryMode->GetAccessoryMode( mode ); + + if( retval == KErrNone ) + { + if( aParameter.iArg1 != mode.iAccessoryMode ) + { + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Unexpected Accessory Mode Parameter1 %d %d" ), aParameter.iArg1, mode.iAccessoryMode ) ); + retval = KTFErrAccessoryUnexpectedArg1; + } +#ifdef __WINS__ // Just check this in winscw + if( aParameter.iArg2 != mode.iAudioOutputStatus ) + { + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Unexpected Accessory Mode Parameter2 %d %d" ), aParameter.iArg2, mode.iAudioOutputStatus ) ); + retval = KTFErrAccessoryUnexpectedArg2; + } +#endif + } + else + { + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Getting Accessory Mode Failed %d" ), retval ) ); + } + + } + break; + + case ETFAccessoryAccessoryModeASync: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->GetAccessoryMode(); + retval = KErrNone; + } + break; + + // + // Audio Control + // + case ETFAccessoryAudioControl_Open: + { + if( iAccessoryAudioControl == NULL ) + { + iAccessoryAudioControl = new ( ELeave ) RAccessoryAudioControl; + retval + = iAccessoryAudioControl->CreateSubSession( iAccessoryServer ); + } + else + { + retval = KErrNone; + } + } + break; + + case ETFAccessoryAudioControl_Close: + { + TRACE_ASSERT( iAccessoryAudioControl != NULL ); + + if( iAccessoryAudioControl != NULL ) + { + iAccessoryAudioControl->CloseSubSession(); + delete iAccessoryAudioControl; + iAccessoryAudioControl = NULL; + } + retval = KErrNone; + } + break; + + case ETFAudioRoutingStatusNotify: + { + RAccessoryAudioControl audioControl; + audioControl.CreateSubSession( iAccessoryServer ); + + audioControl.AudioRoutingStatusNotify( aParameter.iArg1, + iGenericId[aParameter.iGid] ); + retval = KErrNone; + + audioControl.CloseSubSession(); + } + break; + + case ETFAccessoryAudioLinkOpen: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->AccessoryAudioLinkOpen( iGenericId[aParameter.iGid], + aParameter.iArg3 ); + retval = KErrNone; + } + break; + + case ETFAccessoryNotifyAccessoryAudioLinkOpened: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyAccessoryAudioLinkOpened( iGenericId[aParameter.iGid] ); + retval = KErrNone; + } + break; + + case ETFAccessoryNotifyAccessoryAudioLinkClosed: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->NotifyAccessoryAudioLinkClosed( iGenericId[aParameter.iGid] ); + retval = KErrNone; + } + break; + + case ETFAccessoryAccessoryAudioLinkClose: + { + CTFTestControlObserver* aConnectionObserver = CreateObserver(); + TRACE_ASSERT( aConnectionObserver != NULL ); + aConnectionObserver->AccessoryAudioLinkClose( iGenericId[aParameter.iGid], + aParameter.iArg3 ); + retval = KErrNone; + } + break; + + case ETFAccessoryPublishAndSubscribe: + { + PublishAndSubscribeL( aParameter ); + retval = KErrNone; + } + break; + + case ETFAccessory_Cancel: + { + CTFTestControlObserver* item; + if( !iStack.IsEmpty() ) + { + item = iStack.First(); + item->Cancel(); + } + retval = KErrNone; + } + break; + + // + // Cancels + // + case ETFCancelAccessoryAudioLinkOpen: + { + iAccessoryAudioControl->CancelAccessoryAudioLinkOpen(); + retval = KErrNone; + } + break; + + case ETFCancelAccessoryAudioLinkClose: + { + iAccessoryAudioControl->CancelAccessoryAudioLinkClose(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyAccessoryAudioLinkOpened: + { + iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkOpened(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyAccessoryAudioLinkClosed: + { + iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkClosed(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyProcessCommand: + { + TRACE_ASSERT_ALWAYS; + } + break; + + case ETFCancelConnectAccessory: + { + iAccessoryControl->CancelConnectAccessory(); + retval = KErrNone; + } + break; + + case ETFCancelDisconnectAccessory: + { + iAccessoryControl->CancelDisconnectAccessory(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyBluetoothAudioLinkOpenReq: + { + iAccessoryBTControl->CancelNotifyBluetoothAudioLinkOpenReq(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyBluetoothAudioLinkCloseReq: + { + iAccessoryBTControl->CancelNotifyBluetoothAudioLinkCloseReq(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyAccessoryConnectionStatusChanged: + { + iAccessoryConnection->CancelNotifyAccessoryConnectionStatusChanged(); + retval = KErrNone; + } + break; + + case ETFCancelGetAccessoryConnectionStatus: + { + iAccessoryConnection->CancelGetAccessoryConnectionStatus(); + retval = KErrNone; + } + break; + + case ETFCancelConnectAccessoryBT: + { + iAccessoryBTControl->CancelConnectAccessory(); + retval = KErrNone; + } + break; + + case ETFCancelDisconnectAccessoryBT: + { + iAccessoryBTControl->CancelDisconnectAccessory(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyAccessoryModeChanged: + { + iAccessoryMode->CancelNotifyAccessoryModeChanged(); + retval = KErrNone; + } + break; + + case ETFCancelGetAccessoryMode: + { + iAccessoryMode->CancelGetAccessoryMode(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyNewAccessoryConnected: + { + iAccessorySingleConnection->CancelNotifyNewAccessoryConnected(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyAccessoryDisconnected: + { + iAccessorySingleConnection->CancelNotifyAccessoryDisconnected(); + retval = KErrNone; + } + break; + + case ETFCancelNotifyAccessoryValueChanged: + { + TAccPolNameRecord nameRecord; + nameRecord.SetNameL( aParameter.iArg3 ); + iAccessorySingleConnection->CancelNotifyAccessoryValueChanged( nameRecord ); + retval = KErrNone; + } + break; + + case ETFSelectionDialogText: + { + SelectionDialog(ETFSelectionDialogText, &retval); + } + break; + + case ETFSelectionDialogCancel: + { + SelectionDialog(ETFSelectionDialogCancel, &retval); + } + break; + + case ETFNotSupportedNote: + { + TUid KAccFwUiNoteNotifierUid = + { + 0x10205061 + }; + RNotifier notifier; + notifier.Connect(); + + TInt err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, + KNullDesC8 ); + + TInt value( 0 ); + TPckg intPckg( value ); + notifier.Close(); + + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + value = 1; + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + value = value << 1; + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + value = value << 1; + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + value = value << 1; + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + value = value << 1; + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + value = value << 1; + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + value = value << 1; + notifier.Connect(); + err = notifier.StartNotifier( KAccFwUiNoteNotifierUid, intPckg ); + notifier.Close(); + + retval = KErrNone; + } + break; + + case ETFValueRecordTests: + { + retval = TestValueRecordL(); + } + break; + + case ETFObjectBaseSerializationTests: + { + retval = TestBaseSerializationL(); + } + break; + + case ETFCheckConnectedAccessory: + { + CheckConnectedAccessory(&retval); + } + break; + + case ETFCallTClassMethods: + { + CallTClassMethods(&retval); \ + } + + case ETFSetHdmiObject_PubSub: + { + CreateHdmiObjectsToPubSubL( aParameter ); + retval = KErrNone; + break; + } + + case ETFGetHdmiObject: + { + TInt err = KErrNone; + TAccPolNameRecord nameRecord; + nameRecord.SetNameL( aParameter.iArg3 ); + + // Create HDMI container + CAccPolHdmiObjectCon* conFromASY = CAccPolHdmiObjectCon::NewLC(); + CAccPolHdmiObjectCon* conFromPS = CAccPolHdmiObjectCon::NewLC(); + + // Get HDMI container + TRAP( err, iAccessorySingleConnection->GetValueL( + iGenericId[aParameter.iGid], nameRecord, *conFromASY ) ); + + // Get HDMI container from P&S + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + TPtr8 bufPtr( buf->Ptr( 0 ) ); + err = RProperty::Get( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + bufPtr ); + if( err == KErrNone ) + { + RBufReadStream readStream( *buf ); + readStream.PushL(); + conFromPS->InternalizeL( readStream ); + CleanupStack::PopAndDestroy( &readStream ); + } + switch( aParameter.iArg3 ) + { + case KAccVideoHdmiAttributes: + { + // Validate object count + if( conFromASY->Count() != conFromPS->Count() ) + { + err = KErrArgument; + } + + // Validate speaker allocation + RAccPolHdmiSpeakerAllocationArray array; + CleanupClosePushL( array ); + conFromASY->GetHdmiSpeakerAllocationObjectsL( array ); + if( array.Count() ) + { + CAccPolHdmiSpeakerAllocation* speakerAllocation = array[0]; + TUint32 bits = speakerAllocation->SpeakerAllocation(); + + // Speaker allocation should be EHdmiSpeakerUnknown + if( bits != CAccPolHdmiSpeakerAllocation::EHdmiSpeakerUnknown ) + { + err = KErrArgument; + } + + // Speaker count should be zero + if( speakerAllocation->SpeakerCount() ) + { + err = KErrArgument; + } + } + CleanupStack::PopAndDestroy( &array ); + break; + } + case KAccVideoFormat: + { + // Validate object count + if( conFromASY->Count() != conFromPS->Count() ) + { + err = KErrArgument; + } + + // Validate video format + RAccPolHdmiVideoFormatArray array; + CleanupClosePushL( array ); + conFromASY->GetHdmiVideoFormatObjectsL( array ); + if( array.Count() ) + { + CAccPolHdmiVideoFormat* videoFormat = array[0]; + + // Interlaced video should be enabled + if( !videoFormat->Interlaced() ) + { + err = KErrArgument; + } + } + else + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( &array ); + break; + } + default: + { + break; + } + } + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( conFromPS ); + CleanupStack::PopAndDestroy( conFromASY ); + retval = err; + break; + } + + case ETFCheckHdmiObject: + { + TInt err = KErrNone; + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Check HDMI object %d" ), + aParameter.iArg1 ) ); + switch( aParameter.iArg1 ) + { + case EAccPolHdmiObjectCon: + { + err = CheckHdmiContainerObjectL(); + break; + } + case EAccPolHdmiSinkObject: + { + err = CheckHdmiSinkObjectL(); + break; + } + case EAccPolHdmiAudioFormatObject: + { + err = CheckHdmiAudioFormatObjectL(); + break; + } + case EAccPolHdmiLatencyObject: + { + err = CheckHdmiLatencyObjectL(); + break; + } + case EAccPolHdmiSpeakerAllocationObject: + { + err = CheckHdmiSpeakerAllocationObjectL(); + break; + } + case EAccPolHdmiVideoFormatObject: + { + err = CheckHdmiVideoFormatObjectL(); + break; + } + default: + { + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Invalid HDMI object=%d" ), + aParameter.iArg1 ) ); + err = KErrArgument; + break; + } + } + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL: Check HDMI object %d returned with code %d" ), + aParameter.iArg1, err ) ); + retval = err; + break; + } + + default: + TRACE_ASSERT_ALWAYS; + break; + + } + User::LeaveIfError( retval ); + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::TestValueRecordL() +// ---------------------------------------------------------------------------------- +// +TInt CTFAccessoryTestControl::TestValueRecordL() + { + TInt ret( KErrNone ); + + TAccPolValueRecord valueRecord; + TBuf8 eci; + TBuf8 check; + _LIT( Kissa, "Kissa" ); + eci.Copy( Kissa ); + + valueRecord.SetValue( eci ); + check.Copy( valueRecord.ValueRef() ); + + if( KErrNone != eci.Compare( check ) ) + { + User::Leave( KErrGeneral ); + } + + TDesC8& test( valueRecord.ValueRef() ); + if( KErrNone != eci.Compare( test ) ) + { + User::Leave( KErrGeneral ); + } + + return ret; + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::TestBaseSerializationL() +// ---------------------------------------------------------------------------------- +// +TInt CTFAccessoryTestControl::TestBaseSerializationL() + { + TInt ret( KErrNone ); + TInt err( KErrNone ); + + /*** One container *************************************************************/ + CAccPolAudioStreamFormatCon* container1 = + CAccPolAudioStreamFormatCon::NewLC(); + CAccPolAudioStreamFormatCon* container2 = + CAccPolAudioStreamFormatCon::NewLC(); + + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + //Externalize to buf + RBufWriteStream wStrm; + ( void )wStrm.Open( *buf ); + wStrm.PushL(); + container1->ExternalizeL( wStrm ); + wStrm.CommitL(); + wStrm.Close(); + wStrm.Pop(); + + //Internalize from buf + RBufReadStream rStrm; + ( void )rStrm.Open( *buf ); + rStrm.PushL(); + container2->InternalizeL( rStrm ); + rStrm.Close(); + rStrm.Pop(); + + //container1 content must equal to container2 content + err = ( 0 == memcompare( reinterpret_cast ( container1 ), + sizeof(CAccPolObjectCon), + reinterpret_cast ( container2 ), + sizeof(CAccPolObjectCon) ) ) ? KErrNone : KErrGeneral; + User::LeaveIfError( err ); + + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( container2 ); + CleanupStack::PopAndDestroy( container1 ); + container2 = NULL; + container1 = NULL; + /* end *************************************************************************/ + + //Make test again! + + CAccPolAudioStreamFormat* audioStream1 = + CAccPolAudioStreamFormat::NewLC( EAccPolAudioInputStreamObject, + 15, + KUidFormatMP3, + CAccPolAudioStreamFormat::EStereo, + CAccPolAudioStreamFormat::EBitsPerSample24, + 11 ); + + buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + //Externalize to buf + ( void )wStrm.Open( *buf ); + wStrm.PushL(); + audioStream1->ExternalizeL( wStrm ); + wStrm.CommitL(); + wStrm.Close(); + wStrm.Pop(); + + //Internalize from buf + ( void )rStrm.Open( *buf ); + rStrm.PushL(); + + TInt objectid = rStrm.ReadUint8L(); + + if( ( TStreamConObjectType )objectid == EAccPolAudioInputStreamObject ) + { + CAccPolAudioStreamFormat* audioStream2 = + CAccPolAudioStreamFormat::NewLC( EAccPolAudioInputStreamObject ); + + audioStream2->InternalizeL( rStrm ); + + //audioStream1 content must equal to audioStream2 content + err = ( 0 == memcompare( reinterpret_cast ( audioStream1 ), + sizeof(CAccPolAudioStreamFormat), + reinterpret_cast ( audioStream2 ), + sizeof(CAccPolAudioStreamFormat) ) ) ? KErrNone : KErrGeneral; + + User::LeaveIfError( err ); + + CleanupStack::PopAndDestroy( audioStream2 ); + + rStrm.Close(); + rStrm.Pop(); + + } + else + { + User::LeaveIfError( KErrGeneral ); + } + + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( audioStream1 ); + audioStream1 = NULL; + /* end *************************************************************************/ + + return ret; + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::PublishAndSubscribeL() +// ---------------------------------------------------------------------------------- +// +void CTFAccessoryTestControl::PublishAndSubscribeL( TTFAccessoryTestCaseStateControl& aParameter ) + { + TPckgBuf buf; + + buf().iTestCaseID = aParameter.iTestCaseID; + buf().iMethod = aParameter.iMethod; + buf().iParam1 = aParameter.iArg1; + buf().iTimeMs = aParameter.iArg4; + buf().iGenericID = iGenericId[aParameter.iGid]; + + // Send capability to stub(s). + + // if( aParameter.iArg3 ) + // { + buf().iParam2 = aParameter.iArg3; + // } + + /* + if( aParameter.iArg3->Compare( KNullDesC ) ) + { + buf().iParam2.Copy( *aParameter.iArg3 ); + } + + */ + User::LeaveIfError( iSubscribe.Set( KTFAccessoryTestProperty, + KTFAccessoryMethod, + buf ) ); + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CreateHdmiObjectsToPubSubL() +// ---------------------------------------------------------------------------------- +// +void CTFAccessoryTestControl::CreateHdmiObjectsToPubSubL( + TTFAccessoryTestCaseStateControl& aParameter ) + { + // Define property just in case + RProperty::Define( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + RProperty::EByteArray ); + + // Create HDMI container + CAccPolHdmiObjectCon* con = CAccPolHdmiObjectCon::NewLC(); + switch( aParameter.iArg3 ) + { + case KAccVideoHdmiAttributes: + { + // Create audio format object + CreateHdmiObjectL( *con, EAccPolHdmiAudioFormatObject ); + + // Create latency object + CreateHdmiObjectL( *con, EAccPolHdmiLatencyObject ); + + // Create sink object + CreateHdmiObjectL( *con, EAccPolHdmiSinkObject ); + + // Create speaker allocation object + CreateHdmiObjectL( *con, EAccPolHdmiSpeakerAllocationObject ); + + // Create video format object + CreateHdmiObjectL( *con, EAccPolHdmiVideoFormatObject ); + break; + } + case KAccVideoFormat: + { + // Create video format object + CreateHdmiObjectL( *con, EAccPolHdmiVideoFormatObject ); + break; + } + default: + { + break; + } + } + // Stream HDMI container to P&S + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + RBufWriteStream writeStream( *buf ); + writeStream.PushL(); + con->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + TPtr8 bufPtr( buf->Ptr( 0 ) ); + TInt err = RProperty::Set( KTFAccessoryTestProperty, + KTFAccessoryObjectMethod, + bufPtr ); + User::LeaveIfError( err ); + + // Check if ASY stub needs to be informed + if( aParameter.iArg2 ) + { + PublishAndSubscribeL( aParameter ); + } + + // Cleanup + CleanupStack::PopAndDestroy( buf ); + CleanupStack::PopAndDestroy( con ); + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CheckHdmiContainerObjectL +// ---------------------------------------------------------------------------------- +TInt CTFAccessoryTestControl::CheckHdmiContainerObjectL() + { + TInt err = KErrNone; + CAccPolHdmiObjectCon* con1 = NULL; + CAccPolHdmiObjectCon* con2 = NULL; + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + // NewL + con1 = CAccPolHdmiObjectCon::NewL(); + CleanupStack::PushL( con1 ); + CleanupStack::PopAndDestroy( con1 ); + + // NewLC + con1 = CAccPolHdmiObjectCon::NewLC(); + CleanupStack::PopAndDestroy( con1 ); + + // Internalize & Externalize + con1 = CAccPolHdmiObjectCon::NewLC(); + CreateHdmiObjectL( *con1, EAccPolHdmiAudioFormatObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiLatencyObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiSinkObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiSpeakerAllocationObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiVideoFormatObject ); + RBufWriteStream writeStream; + writeStream.Open( *buf ); + writeStream.PushL(); + con1->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + + con2 = CAccPolHdmiObjectCon::NewLC(); + RBufReadStream readStream; + readStream.Open( *buf ); + readStream.PushL(); + con2->InternalizeL( readStream ); + if( con1->Count() == con2->Count() ) + { + TInt count = con1->Count(); + CAccPolObjectBase* objBase1 = NULL; + CAccPolObjectBase* objBase2 = NULL; + for( TInt i = 0; i < count; i++ ) + { + objBase1 = con1->AtL( i ); + objBase2 = con2->AtL( i ); + if( objBase1->ObjectType() != objBase2->ObjectType() ) + { + err = KErrArgument; + } + } + } + else + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( &readStream ); + CleanupStack::PopAndDestroy( con2 ); + CleanupStack::PopAndDestroy( con1 ); + + // DuplicateLC + con1 = CAccPolHdmiObjectCon::NewLC(); + CreateHdmiObjectL( *con1, EAccPolHdmiAudioFormatObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiLatencyObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiSinkObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiSpeakerAllocationObject ); + CreateHdmiObjectL( *con1, EAccPolHdmiVideoFormatObject ); + con2 = static_cast( con1->DuplicateLC() ); + if( con1->Count() == con2->Count() ) + { + TInt count = con1->Count(); + CAccPolObjectBase* objBase1 = NULL; + CAccPolObjectBase* objBase2 = NULL; + for( TInt i = 0; i < count; i++ ) + { + objBase1 = con1->AtL( i ); + objBase2 = con2->AtL( i ); + if( objBase1->ObjectType() != objBase2->ObjectType() ) + { + err = KErrArgument; + } + } + } + else + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( con2 ); + CleanupStack::PopAndDestroy( con1 ); + + // Rest of the API + con1 = CAccPolHdmiObjectCon::NewLC(); + THdmiConObjectType objectType = EAccPolHdmiObjectCon; + TBool exit = EFalse; + TInt index = 0; + TInt count = 0; + do + { + index++; + err = KErrArgument; + objectType = ( THdmiConObjectType )( index ); + CreateHdmiObjectL( *con1, objectType ); + count = con1->Count(); + CAccPolObjectBase* obj = NULL; + if( con1->Count() != index ) + { + err = KErrArgument; + break; + } + for( TInt ii = 0; ii < count; ii++ ) + { + obj = con1->AtL( ii ); + if( obj->ObjectType() == objectType ) + { + err = KErrNone; + break; + } + } + if( objectType == EAccPolHdmiVideoFormatObject ) + { + // Last object + exit = ETrue; + } + } + while( !exit && ( err == KErrNone ) ); + CleanupStack::PopAndDestroy( con1 ); + CleanupStack::PopAndDestroy( buf ); + + return err; + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CheckHdmiSinkObjectL +// ---------------------------------------------------------------------------------- +TInt CTFAccessoryTestControl::CheckHdmiSinkObjectL() + { + TInt err = KErrNone; + CAccPolHdmiSink* obj = NULL; + CAccPolHdmiSink* objDuplicate = NULL; + TUint8 objectType = 0; + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + // NewL + obj = CAccPolHdmiSink::NewL(); + CleanupStack::PushL( obj ); + CleanupStack::PopAndDestroy( obj ); + + // NewL - with params + obj = CAccPolHdmiSink::NewL( ETrue, ETrue ); + CleanupStack::PushL( obj ); + if( !obj->BasicAudioSupport() ) + { + err = KErrArgument; + } + if( !obj->HdcpSupport() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // NewLC + obj = CAccPolHdmiSink::NewLC(); + CleanupStack::PopAndDestroy( obj ); + + // NewLC - with params + obj = CAccPolHdmiSink::NewLC( ETrue, ETrue ); + if( !obj->BasicAudioSupport() ) + { + err = KErrArgument; + } + if( !obj->HdcpSupport() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // Internalize & Externalize + obj = CAccPolHdmiSink::NewLC( ETrue, ETrue ); + + RBufWriteStream writeStream; + writeStream.Open( *buf ); + writeStream.PushL(); + obj->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiSink::NewLC(); + RBufReadStream readStream; + readStream.Open( *buf ); + readStream.PushL(); + objectType = readStream.ReadUint8L(); + obj->InternalizeL( readStream ); + if( objectType != EAccPolHdmiSinkObject ) + { + err = KErrArgument; + } + if( !obj->BasicAudioSupport() ) + { + err = KErrArgument; + } + if( !obj->HdcpSupport() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( &readStream ); + CleanupStack::PopAndDestroy( obj ); + + // DuplicateLC - mem compare can be used since the object does not contain + // any ponters as memebers + obj = CAccPolHdmiSink::NewLC( ETrue, ETrue ); + objDuplicate = static_cast( obj->DuplicateLC() ); + TUint8* left = reinterpret_cast( obj ); + TUint8* right = reinterpret_cast( objDuplicate ); + TInt size = sizeof( CAccPolHdmiSink ); + if( Mem::Compare( left, size, right, size ) != KErrNone ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( objDuplicate ); + CleanupStack::PopAndDestroy( obj ); + + // Rest of the API + obj = CAccPolHdmiSink::NewLC(); + obj->SetBasicAudioSupport( ETrue ); + if( !obj->BasicAudioSupport() ) + { + err = KErrArgument; + } + obj->SetHdcpSupport( ETrue ); + if( !obj->HdcpSupport() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + CleanupStack::PopAndDestroy( buf ); + return err; + } + +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CheckHdmiAudioFormatObjectL +// ---------------------------------------------------------------------------------- +TInt CTFAccessoryTestControl::CheckHdmiAudioFormatObjectL() + { + TInt err = KErrNone; + CAccPolHdmiAudioFormat* obj = NULL; + CAccPolHdmiAudioFormat* objDuplicate = NULL; + TUint8 objectType = 0; + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + // NewL + obj = CAccPolHdmiAudioFormat::NewL(); + CleanupStack::PushL( obj ); + CleanupStack::PopAndDestroy( obj ); + + // NewL - with params + obj = CAccPolHdmiAudioFormat::NewL( HdmiAudioFormat::KUidFormatPCM16, + 1, + 1, + 1, + 1, + 1 ); + if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatPCM16 ) + { + err = KErrArgument; + } + if( obj->ChannelCount() != 1 ) + { + err = KErrArgument; + } + if( obj->BitResolution() != 1 ) + { + err = KErrArgument; + } + if( obj->MaxBitResolution() != 1 ) + { + err = KErrArgument; + } + if( obj->SamFreq() != 1 ) + { + err = KErrArgument; + } + if( obj->FormatDependentValue() != 1 ) + { + err = KErrArgument; + } + CleanupStack::PushL( obj ); + CleanupStack::PopAndDestroy( obj ); + + // NewLC + obj = CAccPolHdmiAudioFormat::NewLC(); + CleanupStack::PopAndDestroy( obj ); + + // NewLC - with params + obj = CAccPolHdmiAudioFormat::NewLC( HdmiAudioFormat::KUidFormatPCM16, + 1, + 1, + 1, + 1, + 1 ); + if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatPCM16 ) + { + err = KErrArgument; + } + if( obj->ChannelCount() != 1 ) + { + err = KErrArgument; + } + if( obj->BitResolution() != 1 ) + { + err = KErrArgument; + } + if( obj->MaxBitResolution() != 1 ) + { + err = KErrArgument; + } + if( obj->SamFreq() != 1 ) + { + err = KErrArgument; + } + if( obj->FormatDependentValue() != 1 ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // Internalize & Externalize + obj = CAccPolHdmiAudioFormat::NewLC( HdmiAudioFormat::KUidFormatPCM16, + 1, + 1, + 1, + 1, + 1 ); + RBufWriteStream writeStream; + writeStream.Open( *buf ); + writeStream.PushL(); + obj->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiAudioFormat::NewLC(); + RBufReadStream readStream; + readStream.Open( *buf ); + readStream.PushL(); + objectType = readStream.ReadUint8L(); + obj->InternalizeL( readStream ); + if( objectType != EAccPolHdmiAudioFormatObject ) + { + err = KErrArgument; + } + if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatPCM16 ) + { + err = KErrArgument; + } + if( obj->ChannelCount() != 1 ) + { + err = KErrArgument; + } + if( obj->BitResolution() != 1 ) + { + err = KErrArgument; + } + if( obj->MaxBitResolution() != 1 ) + { + err = KErrArgument; + } + if( obj->SamFreq() != 1 ) + { + err = KErrArgument; + } + if( obj->FormatDependentValue() != 1 ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( &readStream ); + CleanupStack::PopAndDestroy( obj ); + + // DuplicateLC - mem compare can be used since the object does not contain + // any ponters as memebers + obj = CAccPolHdmiAudioFormat::NewLC( HdmiAudioFormat::KUidFormatPCM16, + 1, + 1, + 1, + 1, + 1 ); + objDuplicate = static_cast( obj->DuplicateLC() ); + TUint8* left = reinterpret_cast( obj ); + TUint8* right = reinterpret_cast( objDuplicate ); + TInt size = sizeof( CAccPolHdmiSink ); + if( Mem::Compare( left, size, right, size ) != KErrNone ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( objDuplicate ); + CleanupStack::PopAndDestroy( obj ); + + // Rest of the API + obj = CAccPolHdmiAudioFormat::NewLC(); + obj->SetAudioFormat( HdmiAudioFormat::KUidFormatEAC3 ); + if( obj->AudioFormat() != HdmiAudioFormat::KUidFormatEAC3 ) + { + err = KErrArgument; + } + obj->SetChannelCount( 2 ); + if( obj->ChannelCount() != 2 ) + { + err = KErrArgument; + } + obj->SetBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample20 ); + if( !( obj->BitResolution() & CAccPolHdmiAudioFormat::EBitsPerSample20 ) ) + { + err = KErrArgument; + } + obj->SetMaxBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample24 ); + if( obj->MaxBitResolution() != CAccPolHdmiAudioFormat::EBitsPerSample24 ) + { + err = KErrArgument; + } + obj->SetSamFreq( CAccPolHdmiAudioFormat::ESamplingFreq192KHz ); + if( !( obj->SamFreq() & CAccPolHdmiAudioFormat::ESamplingFreq192KHz ) ) + { + err = KErrArgument; + } + obj->SetFormatDependentValue( CAccPolHdmiAudioFormat::EBitsPerSample16 ); + if( !( obj->FormatDependentValue() & CAccPolHdmiAudioFormat::EBitsPerSample16 ) ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + CleanupStack::PopAndDestroy( buf ); + + return err; + } + +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CheckHdmiLatencyObjectL +// ---------------------------------------------------------------------------------- +TInt CTFAccessoryTestControl::CheckHdmiLatencyObjectL() + { + TInt err = KErrNone; + CAccPolHdmiLatency* obj = NULL; + CAccPolHdmiLatency* objDuplicate = NULL; + TUint8 objectType = 0; + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + // NewL + obj = CAccPolHdmiLatency::NewL(); + CleanupStack::PushL( obj ); + CleanupStack::PopAndDestroy( obj ); + + // NewL - with params + obj = CAccPolHdmiLatency::NewL( HdmiLatency::KUidLatency, 100, 200 ); + CleanupStack::PushL( obj ); + if( obj->LatencyType() != HdmiLatency::KUidLatency ) + { + err = KErrArgument; + } + if( obj->AudioLatency() != 100 ) + { + err = KErrArgument; + } + if( obj->VideoLatency() != 200 ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // NewLC + obj = CAccPolHdmiLatency::NewLC(); + CleanupStack::PopAndDestroy( obj ); + + // NewLC - with params + obj = CAccPolHdmiLatency::NewLC( HdmiLatency::KUidLatency, 100, 200 ); + if( obj->LatencyType() != HdmiLatency::KUidLatency ) + { + err = KErrArgument; + } + if( obj->AudioLatency() != 100 ) + { + err = KErrArgument; + } + if( obj->VideoLatency() != 200 ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // Internalize & Externalize + obj = CAccPolHdmiLatency::NewLC( HdmiLatency::KUidLatency, 100, 200 ); + RBufWriteStream writeStream; + writeStream.Open( *buf ); + writeStream.PushL(); + obj->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiLatency::NewLC(); + RBufReadStream readStream; + readStream.Open( *buf ); + readStream.PushL(); + objectType = readStream.ReadUint8L(); + obj->InternalizeL( readStream ); + if( objectType != EAccPolHdmiLatencyObject ) + { + err = KErrArgument; + } + if( obj->LatencyType() != HdmiLatency::KUidLatency ) + { + err = KErrArgument; + } + if( obj->AudioLatency() != 100 ) + { + err = KErrArgument; + } + if( obj->VideoLatency() != 200 ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( &readStream ); + CleanupStack::PopAndDestroy( obj ); + + // DuplicateLC - mem compare can be used since the object does not contain + // any ponters as memebers + obj = CAccPolHdmiLatency::NewLC( HdmiLatency::KUidLatency, 100, 200 ); + objDuplicate = static_cast( obj->DuplicateLC() ); + TUint8* left = reinterpret_cast( obj ); + TUint8* right = reinterpret_cast( objDuplicate ); + TInt size = sizeof( CAccPolHdmiLatency ); + if( Mem::Compare( left, size, right, size ) != KErrNone ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( objDuplicate ); + CleanupStack::PopAndDestroy( obj ); + + // Rest of the API + obj = CAccPolHdmiLatency::NewLC(); + obj->SetLatencyType( HdmiLatency::KUidLatency ); + if( obj->LatencyType() != HdmiLatency::KUidLatency ) + { + err = KErrArgument; + } + obj->SetAudioLatency( 100 ); + if( obj->AudioLatency() != 100 ) + { + err = KErrArgument; + } + obj->SetVideoLatency( 200 ); + if( obj->VideoLatency() != 200 ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + CleanupStack::PopAndDestroy( buf ); + + return err; + } + +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CheckHdmiSpeakerAllocationObjectL +// ---------------------------------------------------------------------------------- +TInt CTFAccessoryTestControl::CheckHdmiSpeakerAllocationObjectL() + { + TInt err = KErrNone; + CAccPolHdmiSpeakerAllocation* obj = NULL; + CAccPolHdmiSpeakerAllocation* objDuplicate = NULL; + TUint8 objectType = 0; + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + TUint32 bits = 0x0; + + // NewL + obj = CAccPolHdmiSpeakerAllocation::NewL(); + CleanupStack::PushL( obj ); + CleanupStack::PopAndDestroy( obj ); + + // NewLC + obj = CAccPolHdmiSpeakerAllocation::NewLC(); + CleanupStack::PopAndDestroy( obj ); + + // NewL - with params + bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | + CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; + obj = CAccPolHdmiSpeakerAllocation::NewL( bits ); + CleanupStack::PushL( obj ); + if( !obj->FrontCenter() ) + { + err = KErrArgument; + } + if( !obj->RearCenter() ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiSpeakerAllocation::NewL( EFalse, + EFalse, + EFalse, + ETrue, + EFalse, + EFalse, + ETrue, + EFalse, + EFalse, + EFalse, + EFalse ); + CleanupStack::PushL( obj ); + if( !obj->FrontCenter() ) + { + err = KErrArgument; + } + if( !obj->RearCenter() ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // NewLC - with params + bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | + CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; + obj = CAccPolHdmiSpeakerAllocation::NewLC( bits ); + if( !obj->FrontCenter() ) + { + err = KErrArgument; + } + if( !obj->RearCenter() ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiSpeakerAllocation::NewLC( EFalse, + EFalse, + EFalse, + ETrue, + EFalse, + EFalse, + ETrue, + EFalse, + EFalse, + EFalse, + EFalse ); + if( !obj->FrontCenter() ) + { + err = KErrArgument; + } + if( !obj->RearCenter() ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // Internalize & Externalize + bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | + CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; + obj = CAccPolHdmiSpeakerAllocation::NewLC( bits ); + RBufWriteStream writeStream; + writeStream.Open( *buf ); + writeStream.PushL(); + obj->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiSpeakerAllocation::NewLC(); + RBufReadStream readStream; + readStream.Open( *buf ); + readStream.PushL(); + objectType = readStream.ReadUint8L(); + obj->InternalizeL( readStream ); + if( objectType != EAccPolHdmiSpeakerAllocationObject ) + { + err = KErrArgument; + } + if( !obj->FrontCenter() ) + { + err = KErrArgument; + } + if( !obj->RearCenter() ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( &readStream ); + CleanupStack::PopAndDestroy( obj ); + + // DuplicateLC - mem compare can be used since the object does not contain + // any ponters as memebers + bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | + CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter; + obj = CAccPolHdmiSpeakerAllocation::NewLC( bits ); + objDuplicate = static_cast( obj->DuplicateLC() ); + TUint8* left = reinterpret_cast( obj ); + TUint8* right = reinterpret_cast( objDuplicate ); + TInt size = sizeof( CAccPolHdmiSpeakerAllocation ); + if( Mem::Compare( left, size, right, size ) != KErrNone ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( objDuplicate ); + CleanupStack::PopAndDestroy( obj ); + + // Rest of the API + bits = CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter | + CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter | + CAccPolHdmiSpeakerAllocation::EHdmiSpeakerTopCenter; + obj = CAccPolHdmiSpeakerAllocation::NewLC(); + obj->SetSpeakerAllocation( bits ); + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerFrontCenter ) ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerRearCenter ) ) + { + err = KErrArgument; + } + if( !( obj->SpeakerAllocation() & CAccPolHdmiSpeakerAllocation::EHdmiSpeakerTopCenter ) ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiSpeakerAllocation::NewLC(); + obj->SetFrontSpeakers( ETrue ); + if( !obj->FrontSpeakers() || obj->SpeakerCount() != 2 ) + { + err = KErrArgument; + } + obj->SetFrontSpeakers( EFalse ); + if( obj->FrontSpeakers() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetRearSpeakers( ETrue ); + if( !obj->RearSpeakers() || obj->SpeakerCount() != 2 ) + { + err = KErrArgument; + } + obj->SetRearSpeakers( EFalse ); + if( obj->RearSpeakers() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetLowFrequencyEffect( ETrue ); + if( !obj->LowFrequencyEffect() || obj->SpeakerCount() != 1 ) + { + err = KErrArgument; + } + obj->SetLowFrequencyEffect( EFalse ); + if( obj->LowFrequencyEffect() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetFrontCenter( ETrue ); + if( !obj->FrontCenter() || obj->SpeakerCount() != 1 ) + { + err = KErrArgument; + } + obj->SetFrontCenter( EFalse ); + if( obj->FrontCenter() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetFrontCenterHigh( ETrue ); + if( !obj->FrontCenterHigh() || obj->SpeakerCount() != 1 ) + { + err = KErrArgument; + } + obj->SetFrontCenterHigh( EFalse ); + if( obj->FrontCenterHigh() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetTopCenter( ETrue ); + if( !obj->TopCenter() || obj->SpeakerCount() != 1 ) + { + err = KErrArgument; + } + obj->SetTopCenter( EFalse ); + if( obj->TopCenter() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetRearCenter( ETrue ); + if( !obj->RearCenter() || obj->SpeakerCount() != 1 ) + { + err = KErrArgument; + } + obj->SetRearCenter( EFalse ); + if( obj->RearCenter() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetFrontLeftRightCenter( ETrue ); + if( !obj->FrontLeftRightCenter() || obj->SpeakerCount() != 2 ) + { + err = KErrArgument; + } + obj->SetFrontLeftRightCenter( EFalse ); + if( obj->FrontLeftRightCenter() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetRearLeftRightCenter( ETrue ); + if( !obj->RearLeftRightCenter() || obj->SpeakerCount() != 2 ) + { + err = KErrArgument; + } + obj->SetRearLeftRightCenter( EFalse ); + if( obj->RearLeftRightCenter() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetFrontWideSpeakers( ETrue ); + if( !obj->FrontWideSpeakers() || obj->SpeakerCount() != 2 ) + { + err = KErrArgument; + } + obj->SetFrontWideSpeakers( EFalse ); + if( obj->FrontWideSpeakers() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + obj->SetFrontHighSpeakers( ETrue ); + if( !obj->FrontHighSpeakers() || obj->SpeakerCount() != 2 ) + { + err = KErrArgument; + } + obj->SetFrontHighSpeakers( EFalse ); + if( obj->FrontHighSpeakers() || obj->SpeakerCount() != 0 ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + CleanupStack::PopAndDestroy( buf ); + + return err; + } + +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CheckHdmiVideoFormatObjectL +// ---------------------------------------------------------------------------------- +TInt CTFAccessoryTestControl::CheckHdmiVideoFormatObjectL() + { + TInt err = KErrNone; + CAccPolHdmiVideoFormat* obj = NULL; + CAccPolHdmiVideoFormat* objDuplicate = NULL; + TUint8 objectType = 0; + CBufFlat* buf = CBufFlat::NewL( KAccSrvObjectBaseStreamBufGranularity ); + CleanupStack::PushL( buf ); + buf->ResizeL( KAccSrvObjectBaseStreamBufMaxSize ); + + // NewL + obj = CAccPolHdmiVideoFormat::NewL(); + CleanupStack::PushL( obj ); + CleanupStack::PopAndDestroy( obj ); + + // NewLC + obj = CAccPolHdmiVideoFormat::NewLC(); + CleanupStack::PopAndDestroy( obj ); + + // NewL - with params + obj = CAccPolHdmiVideoFormat::NewL( E640x480p59_94d60Hz4d3, + E640x350p85HzRB, + 1, + ETrue ); + CleanupStack::PushL( obj ); + if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) + { + err = KErrArgument; + } + if( obj->DmtFixedMode() != E640x350p85HzRB ) + { + err = KErrArgument; + } + if( obj->PixelRepeat() != 1 ) + { + err = KErrArgument; + } + if( !obj->Interlaced() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // NewLC - with params + obj = CAccPolHdmiVideoFormat::NewLC( E640x480p59_94d60Hz4d3, + E640x350p85HzRB, + 1, + ETrue ); + if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) + { + err = KErrArgument; + } + if( obj->DmtFixedMode() != E640x350p85HzRB ) + { + err = KErrArgument; + } + if( obj->PixelRepeat() != 1 ) + { + err = KErrArgument; + } + if( !obj->Interlaced() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + + // Internalize & Externalize + obj = CAccPolHdmiVideoFormat::NewLC( E640x480p59_94d60Hz4d3, + E640x350p85HzRB, + 1, + ETrue ); + RBufWriteStream writeStream; + writeStream.Open( *buf ); + writeStream.PushL(); + obj->ExternalizeL( writeStream ); + writeStream.CommitL(); + CleanupStack::PopAndDestroy( &writeStream ); + CleanupStack::PopAndDestroy( obj ); + + obj = CAccPolHdmiVideoFormat::NewLC(); + RBufReadStream readStream; + readStream.Open( *buf ); + readStream.PushL(); + objectType = readStream.ReadUint8L(); + obj->InternalizeL( readStream ); + if( objectType != EAccPolHdmiVideoFormatObject ) + { + err = KErrArgument; + } + if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) + { + err = KErrArgument; + } + if( obj->DmtFixedMode() != E640x350p85HzRB ) + { + err = KErrArgument; + } + if( obj->PixelRepeat() != 1 ) + { + err = KErrArgument; + } + if( !obj->Interlaced() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( &readStream ); + CleanupStack::PopAndDestroy( obj ); + + // DuplicateLC - mem compare can be used since the object does not contain + // any ponters as memebers + obj = CAccPolHdmiVideoFormat::NewLC( E640x480p59_94d60Hz4d3, + E640x350p85HzRB, + 1, + ETrue ); + objDuplicate = static_cast( obj->DuplicateLC() ); + TUint8* left = reinterpret_cast( obj ); + TUint8* right = reinterpret_cast( objDuplicate ); + TInt size = sizeof( CAccPolHdmiVideoFormat ); + if( Mem::Compare( left, size, right, size ) != KErrNone ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( objDuplicate ); + CleanupStack::PopAndDestroy( obj ); + + // Rest of the API + obj = CAccPolHdmiVideoFormat::NewLC(); + obj->SetCeaFixedMode( E640x480p59_94d60Hz4d3 ); + if( obj->CeaFixedMode() != E640x480p59_94d60Hz4d3 ) + { + err = KErrArgument; + } + obj->SetDmtFixedMode( E640x350p85HzRB ); + if( obj->DmtFixedMode() != E640x350p85HzRB ) + { + err = KErrArgument; + } + obj->SetPixelRepeat( 4 ); + if( obj->PixelRepeat() != 4 ) + { + err = KErrArgument; + } + obj->SetInterlaced( ETrue ); + if( !obj->Interlaced() ) + { + err = KErrArgument; + } + CleanupStack::PopAndDestroy( obj ); + CleanupStack::PopAndDestroy( buf ); + + return err; + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver* CTFAccessoryTestControl::CreateObserver() +// ---------------------------------------------------------------------------------- +CTFTestControlObserver* CTFAccessoryTestControl::CreateObserver() + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CreateObserver()" ) ) ); + iStack.AddFirst/*AddLast*/( *CTFTestControlObserver::NewL( *this ) ); + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::CreateObserver() return" ) ) ); + return iStack.First/*Last*/(); + } + +// Not used at this point. +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::ProcessMessageAndCompleteL +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::ProcessMessageAndCompleteL( const RMessage2& aMessage ) + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ProcessMessageAndCompleteL enter" ) ) ); + aMessage.Complete( KErrNone ); + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFAccessoryTestControl::ProcessMessageAndCompleteL return" ) ) ); + } +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::MessageCompleteL +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::MessageCompleteL( TInt /*aResult*/) + { + + } + +// +// ---------------------------------------------------------------------------------- +// CTFAccessoryTestControl::CreateHdmiObjectL +// ---------------------------------------------------------------------------------- +void CTFAccessoryTestControl::CreateHdmiObjectL( CAccPolObjectCon& aCon, + THdmiConObjectType aType ) + { + switch( aType ) + { + case EAccPolHdmiSinkObject: + { + CAccPolHdmiSink* sink = CAccPolHdmiSink::NewLC(); + sink->SetBasicAudioSupport( ETrue ); + sink->SetHdcpSupport( ETrue ); + aCon.AddL( *sink ); + CleanupStack::PopAndDestroy( sink ); + break; + } + case EAccPolHdmiAudioFormatObject: + { + CAccPolHdmiAudioFormat* audioFormat = CAccPolHdmiAudioFormat::NewLC(); + audioFormat->SetAudioFormat( HdmiAudioFormat::KUidFormatPCM16 ); + audioFormat->SetChannelCount( 2 ); + audioFormat->SetBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample16 ); + audioFormat->SetMaxBitResolution( CAccPolHdmiAudioFormat::EBitsPerSample16 ); + audioFormat->SetFormatDependentValue( CAccPolHdmiAudioFormat::EBitsPerSample16 ); + audioFormat->SamFreq( CAccPolHdmiAudioFormat::ESamplingFreq32KHz ); + aCon.AddL( *audioFormat ); + CleanupStack::PopAndDestroy( audioFormat ); + break; + } + case EAccPolHdmiLatencyObject: + { + CAccPolHdmiLatency* latency = CAccPolHdmiLatency::NewLC(); + latency->SetLatencyType( HdmiLatency::KUidLatency ); + latency->SetAudioLatency( 100 ); + latency->SetVideoLatency( 200 ); + aCon.AddL( *latency ); + CleanupStack::PopAndDestroy( latency ); + break; + } + case EAccPolHdmiSpeakerAllocationObject: + { + CAccPolHdmiSpeakerAllocation* speakerAllocation = + CAccPolHdmiSpeakerAllocation::NewLC(); + speakerAllocation->SetFrontSpeakers( ETrue ); + speakerAllocation->SetRearSpeakers( ETrue ); + speakerAllocation->SetLowFrequencyEffect( ETrue ); + speakerAllocation->SetFrontCenter( ETrue ); + speakerAllocation->SetFrontCenterHigh( ETrue ); + speakerAllocation->SetTopCenter( ETrue ); + speakerAllocation->SetRearCenter( ETrue ); + speakerAllocation->SetFrontLeftRightCenter( ETrue ); + speakerAllocation->SetRearLeftRightCenter( ETrue ); + speakerAllocation->SetFrontWideSpeakers( ETrue ); + speakerAllocation->SetFrontHighSpeakers( ETrue ); + aCon.AddL( *speakerAllocation ); + CleanupStack::PopAndDestroy( speakerAllocation ); + break; + } + case EAccPolHdmiVideoFormatObject: + { + CAccPolHdmiVideoFormat* videoFormat = CAccPolHdmiVideoFormat::NewLC(); + videoFormat->SetCeaFixedMode( E640x480p59_94d60Hz4d3 ); + videoFormat->SetDmtFixedMode( E640x480p85HzRB ); + videoFormat->SetInterlaced( EFalse ); + aCon.AddL( *videoFormat ); + CleanupStack::PopAndDestroy( videoFormat ); + break; + } + default: + { + break; + } + } + } + + +void CTFAccessoryTestControl::AccessoryConnectionOpenClose(TTFAccessoryFunction aCase, TInt* aRetval) + { + switch(aCase) + { + case ETFAccessoryConnection_Open: + { + if ( iAccessoryConnection == NULL ) + { + iAccessoryConnection = new ( ELeave ) RAccessoryConnection; + *aRetval = iAccessoryConnection->CreateSubSession( iAccessoryServer ); + COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL(TTFAccessoryTestCaseStateControl& aParameter) - ETFAccessoryConnection_Open - Sub session created - (%d)" ), *aRetval ) ); + } + else + { + *aRetval = KErrNone; + COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL(TTFAccessoryTestCaseStateControl& aParameter) - ETFAccessoryConnection_Open - Sub session not created - (%d)" ), *aRetval ) ); + } + } + break; + + case ETFAccessoryConnection_Close: + { + TRACE_ASSERT( iAccessoryConnection != NULL ); + + if ( iAccessoryConnection != NULL ) + { + iAccessoryConnection->CloseSubSession(); + delete iAccessoryConnection; + iAccessoryConnection = NULL; + COMPONENT_TRACE( ( _L( "CTFAccessoryTestControl::CallAccessoryFunctionL(TTFAccessoryTestCaseStateControl& aParameter) - ETFAccessoryConnection_Close - Sub session closed" ) ) ); + } + *aRetval = KErrNone; + } + break; + + default: + break; + } + + } + +void CTFAccessoryTestControl::FindAndCheckRequestL( TInt* aRetval, TTFAccessoryTestCaseStateControl& aParameter ) + { + CTFAccessoryTestCaseControl* testCase = STATIC_CAST( CTFAccessoryTestCaseControl*, CurrentTestCase()); + TInt errVal = 0; + + TRACE_ASSERT( testCase != NULL ); + if ( testCase != NULL ) + { + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::FindAndCheckRequest() - inside if ( testCase != NULL )" ) ) ); + if(!iStack.IsEmpty()) + { + iStackIter.SetToFirst(); + + while ( ( iObserverItem = iStackIter++ ) != NULL ) + { + if(iObserverItem->FindRequest(aParameter.iRequestType)) + { + testCase->CheckRequest( iObserverItem->iStatus, + iObserverItem->iValue, + iObserverItem->iCapabilityName, + &errVal ); + + if(errVal == KTFDontDeleteObserver) + { + aParameter.iArg1 = KTFDontDeleteObserver; + } + + + if ( !iStack.IsEmpty() ) // Check if observes are already deleted by CheckRequest() + { + if( KTFDontDeleteObserver != aParameter.iArg1 ) + { + if (iObserverItem->iStatus == KRequestPending ) + { + User::WaitForRequest(iObserverItem->iStatus); + } + iStack.Remove( *iObserverItem ); + delete iObserverItem; + } + else + { + User::Leave( KTFDontDeleteObserver ); + } + } + else + { + *aRetval = KErrGeneral; + } + } + } + } + else + { + *aRetval = KErrGeneral; + } + } + + TEST_CASE_TRACE( ( _L( "CTFAccessoryTestControl::FindAndCheckRequest() returning and setting *aRetval = KErrNone )" ) ) ); + *aRetval = KErrNone; + } + + +void CTFAccessoryTestControl::AccessorySettingsOpenClose( TTFAccessoryFunction aCase, TInt* aRetval ) + { + switch(aCase) + { + case ETFAccessorySettings_Open: + { + if ( iAccessorySettings == NULL ) + { + iAccessorySettings = new ( ELeave ) RAccessorySettings; + *aRetval = iAccessorySettings->CreateSubSession( iAccessoryServer ); + } + else + *aRetval = KErrNone; + } + break; + + case ETFAccessorySettings_Close: + { + TRACE_ASSERT( iAccessorySettings != NULL ); + + if ( iAccessorySettings != NULL ) + { + iAccessorySettings->CloseSubSession(); + delete iAccessorySettings; + iAccessorySettings = NULL; + } + *aRetval = KErrNone; + } + break; + + default: + break; + + } + } + +void CTFAccessoryTestControl::SetSeveralAccessoryModeSetting( TInt* aRetval ) + { + TAccModeSetting accModeSettingIn; + TAccMode tAccMode = EAccModeWirelessHeadset; + TBuf< KMaxAccModeSetting > aDesIn; + // Set + // setting 1 + accModeSettingIn.SetId( 11 ); // unknown TInt + accModeSettingIn.SetTInt( 1 ); + TAccModeSettingArray arrayIn; + arrayIn.AddSetting( accModeSettingIn ); + + // setting 2 + accModeSettingIn.SetId( 12 ); // unknown Des + _LIT( KAccSetting2, "012345678901234567890" ); + aDesIn.Copy( KAccSetting2 ); + accModeSettingIn.SetTDes( aDesIn ); + arrayIn.AddSetting( accModeSettingIn ); + + // setting 3 + accModeSettingIn.SetId( 13 ); // unknown TBool + accModeSettingIn.SetTBool( ETrue ); + arrayIn.AddSetting( accModeSettingIn ); + + *aRetval = iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, arrayIn ); + } + +void CTFAccessoryTestControl::GetSeveralAccessoryModeSetting( TInt* aRetval ) + { + TAccModeSetting accModeSettingOut; + TAccMode tAccMode = EAccModeWirelessHeadset; + TBuf< KMaxAccModeSetting > aDesOut; + TAccModeSettingArray arrayOut; + TInt intOut( 0 ); + // set input parameters for GetAccessoryModeSettings() + // setting 11 + accModeSettingOut.SetId( 11 ); + arrayOut.AddSetting( accModeSettingOut ); + + // setting 12 + accModeSettingOut.SetId( 12 ); + arrayOut.AddSetting( accModeSettingOut ); + + // setting 13 + accModeSettingOut.SetId( 13 ); + arrayOut.AddSetting( accModeSettingOut ); + + *aRetval = iAccessorySettings->GetAccessoryModeSettings( tAccMode, arrayOut ); + + // Check that got settings are right + + TInt count = arrayOut.GetArraySize(); + TInt foundCount(0); + + for( TInt index = 0; index < count; index++ ) + { + arrayOut.GetSetting( index, accModeSettingOut ); + + if( 11 == accModeSettingOut.Id() ) + { + + accModeSettingOut.GetTInt( intOut); + + if( 1 == intOut ) + { + foundCount++; + } + } + + + if( 12 == accModeSettingOut.Id() ) + { + accModeSettingOut.GetTDes( aDesOut ); + + if( KErrNone == aDesOut.Compare( _L("012345678901234567890") ) ) + { + foundCount++; + } + + } + + if( 13 == accModeSettingOut.Id() ) + { + + accModeSettingOut.GetTBool( intOut ); + + if( intOut ) + { + foundCount++; + } + } + } + + if(foundCount != 3) + { + *aRetval = KErrNotFound; + } + + // + // Reset Settings + // + TAccModeSetting accModeSettingIn; + TBuf< KMaxAccModeSetting > aDesIn; + // Set + // setting 1 + accModeSettingIn.SetId( 11 ); // unknown TInt + accModeSettingIn.SetTInt( 0 ); + TAccModeSettingArray arrayIn; + arrayIn.AddSetting( accModeSettingIn ); + + // setting 2 + accModeSettingIn.SetId( 12 ); // unknown Des + _LIT( KAccSetting2, "" ); + aDesIn.Copy( KAccSetting2 ); + accModeSettingIn.SetTDes( aDesIn ); + arrayIn.AddSetting( accModeSettingIn ); + + // setting 3 + accModeSettingIn.SetId( 13 ); // unknown TBool + accModeSettingIn.SetTBool( EFalse ); + arrayIn.AddSetting( accModeSettingIn ); + + iAccessorySettings->SetAccessoryModeSettingsL( tAccMode, arrayIn ); + + } + +void CTFAccessoryTestControl::SetIntValue( TTFAccessoryTestCaseStateControl& aParameter, TInt *aRetval ) + { + switch( aParameter.iArg3 ) + { + case KAccSetVolumeLevel: + { + //AccPolCommonNameValuePairs.h contains following example code + RAccessoryControl accessoryControl; + accessoryControl.CreateSubSession( iAccessoryServer ); + + CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL(); + CleanupStack::PushL( nameArray ); + accessoryControl.GetSubblockNameArrayL( iGenericId[aParameter.iGid], *nameArray ); + + TAccPolNameRecord nameRecord; + nameRecord.SetNameL( KAccSetVolumeLevel ); + TAccValueTypeTInt value; + + if( nameArray->HasName( KAccSetVolumeLevel ) ) + { + accessoryControl.GetValueL( iGenericId[aParameter.iGid], nameRecord, value ); + value.iValue = value.iValue | aParameter.iArg1; + accessoryControl.AccessoryValueChangedNotifyL( iGenericId[aParameter.iGid], nameRecord, value ); + } + + CleanupStack::PopAndDestroy( nameArray ); + accessoryControl.CloseSubSession(); + *aRetval = KErrNone; + } + break; + + default: + { + TAccPolNameRecord aNameRecord; + aNameRecord.SetNameL( aParameter.iArg3 ); + TAccValueTypeTInt aIntValue; + aIntValue.iValue = aParameter.iArg1; + *aRetval = iAccessoryControl->SetValueL( iGenericId[aParameter.iGid], aNameRecord, aIntValue ); + } + break; + } + + } + +void CTFAccessoryTestControl::SelectionDialog( TTFAccessoryFunction aCase, TInt* aRetval ) + { + switch(aCase) + { + case ETFSelectionDialogText: + { + const TUid KAccFwUiDialogNotifierUid = { 0x10205062 }; + + RNotifier notifier; + notifier.Connect(); + + TInt selectionListBitmask = 255; + TInt reply = 0; + + TPckg replyPck( reply); + TPckg selectionBitmaskPackage( selectionListBitmask); + + //activate active object + TRequestStatus status; + status = KRequestPending; + + //open ui + notifier.StartNotifierAndGetResponse( status, KAccFwUiDialogNotifierUid, selectionBitmaskPackage, replyPck); + + User::WaitForRequest( status); + + + notifier.Close(); + + *aRetval = KErrNone; + } + + case ETFSelectionDialogCancel: + { + const TUid KAccFwUiDialogNotifierUid = { 0x10205062 }; + + RNotifier notifier; + notifier.Connect(); + + TInt selectionListBitmask = 7; + TInt reply = 0; + + TPckg replyPck( reply); + TPckg selectionBitmaskPackage( selectionListBitmask); + + //activate active object + TRequestStatus status; + + //open ui + notifier.StartNotifierAndGetResponse( status, KAccFwUiDialogNotifierUid, selectionBitmaskPackage, replyPck); + User::After( 2500000); + notifier.CancelNotifier( KAccFwUiDialogNotifierUid); + + // Implementation of the dialog is changed. Request is completed every time + User::WaitForRequest( status ); + + notifier.Close(); + + *aRetval = KErrNone; + } + + default: + break; + + } + + } + +void CTFAccessoryTestControl::CheckConnectedAccessory( TInt* aRetval ) + { + *aRetval = KErrNone; + + TAccPolGenericID genID; // TGeneric ID that should be connected + TAccPolGenericID genIDConnected; // TGeneric ID that is connected + TAccPolGIDHeader iGenericIDHeader; // Header of the GID that should be connected + TAccPolGIDHeader iGenericIDHeaderConnected; // Header of the connected GID + TAccPolGenericIDArray genericIdArray; // Array of connected generic ID's + CAccConGenericID* aGenericID = CAccConGenericID::NewL(); // This might be needed for capabilities + + CleanupStack::PushL( aGenericID ); + CAccPolSubblockNameArray* nameArrayConnected = CAccPolSubblockNameArray::NewL(); + + CleanupStack::PushL( nameArrayConnected ); + + TAccPolGenericID genericID = aGenericID->GenericID(); + + TBuf hwModelID(_L("headset")); + // Set GenericID header + iGenericIDHeader.iAccessoryDeviceType = KDTHeadset; + iGenericIDHeader.iPhysicalConnection = KPCWired; + iGenericIDHeader.iApplicationProtocol = 0x0; + + iGenericIDHeader.iCapabilitiesSubblocks = KSBAudioSubblock; + + iGenericIDHeader.iHWModelID = hwModelID; + iGenericIDHeader.iHWDeviceID = 0x0; + iGenericIDHeader.iDBID = 0x0; + + RAccessoryConnection* accessoryConnection = new ( ELeave ) RAccessoryConnection(); + CleanupStack::PushL( accessoryConnection ); + accessoryConnection->CreateSubSession( iAccessoryServer ); + accessoryConnection->GetAccessoryConnectionStatus( genericIdArray ); + CleanupStack::PopAndDestroy( accessoryConnection ); + + genIDConnected = genericIdArray.GetGenericIDL( 0 ); + + RAccessorySingleConnection singleConnect;// = new ( ELeave ) RAccessoryConnectionBase(); + singleConnect.CreateSubSession( iAccessoryServer ); + singleConnect.GetSubblockNameArrayL( genIDConnected, *nameArrayConnected ); + + singleConnect.CloseSubSession(); + + iGenericIDHeaderConnected.iAccessoryDeviceType = genIDConnected.DeviceTypeCaps(); + iGenericIDHeaderConnected.iPhysicalConnection = genIDConnected.PhysicalConnectionCaps(); + iGenericIDHeaderConnected.iApplicationProtocol = genIDConnected.ApplicationProtocolCaps(); + iGenericIDHeaderConnected.iCapabilitiesSubblocks = genIDConnected.SubblockCaps(); + iGenericIDHeaderConnected.iHWModelID = genIDConnected.HWModelID(); + iGenericIDHeaderConnected.iHWDeviceID = genIDConnected.HWDeviceID(); + iGenericIDHeaderConnected.iDBID = 0x0; + + //Check GenericID header + if( iGenericIDHeader.iAccessoryDeviceType != iGenericIDHeaderConnected.iAccessoryDeviceType ) + { + *aRetval = EFalse; + } + if( iGenericIDHeader.iPhysicalConnection != iGenericIDHeaderConnected.iPhysicalConnection ) + { + *aRetval = EFalse; + } + if( iGenericIDHeader.iApplicationProtocol != iGenericIDHeaderConnected.iApplicationProtocol ) + { + *aRetval = EFalse; + } + if( iGenericIDHeader.iCapabilitiesSubblocks != iGenericIDHeaderConnected.iCapabilitiesSubblocks ) + { + *aRetval = EFalse; + } + if( iGenericIDHeader.iHWModelID != iGenericIDHeaderConnected.iHWModelID ) + { + *aRetval = EFalse; + } + if( iGenericIDHeader.iHWDeviceID != iGenericIDHeaderConnected.iHWDeviceID ) + { + *aRetval = EFalse; + } + if( !( nameArrayConnected->HasName( KAccStereoAudio ) ) ) + { + *aRetval = EFalse; + } + + if( !( nameArrayConnected->HasName( KAccAudioOutConnector ) ) ) + { + *aRetval = EFalse; + } + + if( !( nameArrayConnected->HasName( KAccAudioOutputType ) ) ) + { + *aRetval = EFalse; + } + //CleanupStack::PopAndDestroy( nameValueArray ); + CleanupStack::PopAndDestroy( nameArrayConnected ); + CleanupStack::PopAndDestroy( aGenericID ); + + } + + +void CTFAccessoryTestControl::CallTClassMethods( TInt* aRetval ) + { + // Settings(); + Policy(); + *aRetval = KErrNone; + } + +void CTFAccessoryTestControl::Settings() + { + TAccModeSettingArray array; + array.Reset(); + TInt ret = array.GetMaxArraySize(); + TAccModeSetting setting; + TUint32 settingId( 1 ); + setting.SetId( settingId ); + array.AddSetting( setting ); + TAccModeSetting setting2; + ret = array.GetSetting( 0, setting2 ); + ret = array.GetArraySize(); + } + +void CTFAccessoryTestControl::Policy() + { + TInt valueInt( 1 ); + TUint32 valueUInt( 1 ); + TDesC8 des( _L8( "timo" ) ); + //TDes8 valueDesc = des; + TAccPolNameRecord nameRecord; + TAccPolValueRecord valRec( des, EAPVPolicy ); + TAccPolNameValueRecord nameValRec; + TAccPolNameValueRecord nameValRec1( nameRecord, valRec ); + TAccPolNameValueRecord nameValRec2( valueUInt, valueInt, EAPVInt, EAPVPolicy ); + TAccPolNameValueRecord nameValRec3( valueUInt, des, EAPVPolicy ); + TAccPolNameValueRecord nameValRec4( valueUInt ); + //TDesC8 valueToGet; + valRec.GetValueL( des ); + valRec.SetValue( des ); + //valRec.SetValue( valueToGet ); + TAccPolValueRecord valRec1( valueInt, EAPVInt, EAPVPolicy ); + valRec1.SetValue( valueInt ); + valRec1.SetLocation( EAPVPolicy ); + valRec1.SetL( valueInt, EAPVInt, EAPVPolicy ); + } + +void CTFAccessoryTestControl::GetBoolAccessoryModeSetting( TTFAccessoryTestCaseStateControl& aParameter, TInt* aRetval ) + { + TBool aSettingsValueBool; + + TAccMode aAccMode = (TAccMode)aParameter.iArg1; + TAccModeSetting aSetting; + aSetting.SetId(aParameter.iArg2); + + *aRetval = iAccessorySettings->GetAccessoryModeSetting(aAccMode, aSetting); + + if( aSetting.Type() == EAccModeSettingBool) + { + *aRetval = aSetting.GetTBool(aSettingsValueBool); + + if(*aRetval != KErrNotFound) + { + if(aSettingsValueBool == (TBool)aParameter.iArg4) + { + *aRetval = KErrNone; + } + else + { + *aRetval = KErrArgument; + } + } + } + else + { + *aRetval = KErrNotFound; + } + } + +void CTFAccessoryTestControl::GetIntAccessoryModeSetting( TTFAccessoryTestCaseStateControl& aParameter, TInt* aRetval ) + { + TInt aSettingsValueInt; + + TAccMode aAccMode = (TAccMode)aParameter.iArg1; + TAccModeSetting aSetting; + aSetting.SetId(aParameter.iArg2); + + *aRetval = iAccessorySettings->GetAccessoryModeSetting(aAccMode, aSetting); + + if(aSetting.Type() == EAccModeSettingInt) + { + *aRetval = aSetting.GetTInt(aSettingsValueInt); + + if(*aRetval != KErrNotFound) + { + if( aSettingsValueInt == aParameter.iArg4 ) + { + *aRetval = KErrNone; + } + else + { + *aRetval = KErrArgument; + } + } + } + else + { + *aRetval = KErrNotFound; + } + } + +void CTFAccessoryTestControl::GetDesAccessoryModeSetting( TTFAccessoryTestCaseStateControl& aParameter, TInt* aRetval ) + { + TBuf aSettingsValueDes; + + TAccMode aAccMode = (TAccMode)aParameter.iArg1; + TAccModeSetting aSetting; + aSetting.SetId( aParameter.iArg2 ); + + *aRetval = iAccessorySettings->GetAccessoryModeSetting( aAccMode, aSetting ); + + if( aSetting.Type() == EAccModeSettingDes ) + { + *aRetval = aSetting.GetTDes( aSettingsValueDes ); + + if(*aRetval != KErrNotFound) + { + TBuf buffer; + buffer.Num( aParameter.iArg3 ); + if( KErrNone == aSettingsValueDes.Compare( buffer ) ) + { + *aRetval = KErrNone; + } + else + { + *aRetval = KErrArgument; + } + } + } + else + { + *aRetval = KErrNotFound; + } + } + +// End of file diff -r d38941471f1c -r cb32bcc88bad accessoryservices/accessoryserver/tsrc/public/basic/AccessoryTestControl/AccessoryTestControlPlugin/src/TfTestControlObserver.cpp --- a/accessoryservices/accessoryserver/tsrc/public/basic/AccessoryTestControl/AccessoryTestControlPlugin/src/TfTestControlObserver.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/accessoryserver/tsrc/public/basic/AccessoryTestControl/AccessoryTestControlPlugin/src/TfTestControlObserver.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,753 +1,755 @@ -/* - * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. - * This component and the accompanying materials are made available - * under the terms of "Eclipse Public License v1.0" - * which accompanies this distribution, and is available - * at the URL "http://www.eclipse.org/legal/epl-v10.html". - * - * Initial Contributors: - * Nokia Corporation - initial contribution. - * - * Contributors: - * - * Description: - * - */ - -// INCLUDE FILES -#include -#include "siftrace.h" -#include "CtfTestControlObserver.h" -#include - -const TInt CTFTestControlObserver::iOffset = _FOFF(CTFTestControlObserver,iSlink); - -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver* CTFTestControlObserver::NewL() -// ---------------------------------------------------------------------------------- -CTFTestControlObserver* CTFTestControlObserver::NewL( CTFAccessoryTestControl& aTestControl ) - { - CTFTestControlObserver* result = - new ( ELeave ) CTFTestControlObserver( aTestControl ); - result->iObjectValueBuf = HBufC8::NewL( 256 ); - result->iObjectValue.iValue.Set( result->iObjectValueBuf->Des() ); - CleanupStack::PushL( result ); - CleanupStack::Pop(); - return result; - } - -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::CTFTestControlObserver() -// ---------------------------------------------------------------------------------- -CTFTestControlObserver::CTFTestControlObserver( CTFAccessoryTestControl& aTestControl ) : - CActive( CActive::EPriorityHigh ), - iAccessoryTestControl( aTestControl ), - iObjectValue( TPtr8( NULL, 0, 0 ) ) - { - - iRequestCompleted = ReqAccRequestNone; - iCapabilityName = 0; - - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::CTFTestControlObserver()" ) ) ); - CActiveScheduler::Add( this ); - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::CTFTestControlObserver - return" ) ) ); - } -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::~CTFTestControlObserver() -// ---------------------------------------------------------------------------------- -CTFTestControlObserver::~CTFTestControlObserver() - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::~CTFTestControlObserver - %d" ), iRequestType ) ); - delete iObjectValueBuf; - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::~CTFTestControlObserver - succesful" ) ) ); - } -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::RunL() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::RunL() - { - - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL - enter" ) ) ); - - switch( iRequestType ) - { - - case ReqDisconnectBtAccessory: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqDisconnectBtAccessory" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqConnectBtAccessory: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqConnectBtAccessory" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqNotifyNewAccessoryConnected: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyNewAccessoryConnected" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqNotifyAccessoryDisconnected: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryDisconnected" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqNotifyAccessoryConnectionStatusChanged: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryConnectionStatusChanged" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqNotifyAccessoryModeChanged: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryModeChanged" ) ) ); - iRequestCompleted = iRequestType; - iValue = iAccMode.iAccessoryMode; - } - break; - - case ReqGetAccessoryMode: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqGetAccessoryMode" ) ) ); - iRequestCompleted = iRequestType; - iValue = iAccMode.iAccessoryMode; - } - break; - - case ReqNotifyAccessoryAudioLinkOpened: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqConnectBtAccessory" ) ) ); - iRequestCompleted = iRequestType; - iValue = iAudioType; - } - break; - - case ReqAccessoryAudioLinkOpen: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqConnectBtAccessory" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqNotifyBluetoothAudioLinkOpenReq: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyBluetoothAudioLinkOpenReq" ) ) ); - iRequestCompleted = iRequestType; - iValue = iAudioType; - } - break; - - case ReqNotifyAccessoryAudioLinkClosed: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryAudioLinkClosed" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqAccessoryAudioLinkClose: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqAccessoryAudioLinkClose" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqNotifyBluetoothAudioLinkCloseReq: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyBluetoothAudioLinkCloseReq" ) ) ); - iRequestCompleted = iRequestType; - iValue = iAudioType; - } - break; - - case ReqNotifyIntegerAccessoryValueChanged: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyIntegerAccessoryValueChanged" ) ) ); - iCapabilityName = 0; - iRequestCompleted = iRequestType; - iValue = iIntegerValue.iValue; - } - break; - - case ReqNotifyBooleanAccessoryValueChanged: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyBooleanAccessoryValueChanged" ) ) ); - iCapabilityName = 0; - iRequestCompleted = iRequestType; - iValue = ( TInt )iBooleanValue.iValue; - } - break; - - case ReqNotifyObjectAccessoryValueChanged: - { - iCapabilityName = 0; - iRequestCompleted = iRequestType; - } - break; - - case ReqAccessoryConnection: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqAccessoryConnection" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqAccessoryDisconnection: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqAccessoryDisconnection" ) ) ); - iRequestCompleted = iRequestType; - } - break; - - case ReqGetAccessoryConnectionStatus: - { - COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqGetAccessoryConnectionStatus" ) ) ); - iRequestCompleted = iRequestType; - iValue = iAccessoryTestControl.iGenericIdArray.Count(); - } - break; - - default: - TRACE_ASSERT_ALWAYS; - break; - } - - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL - return" ) ) ); - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::RunError() -// ---------------------------------------------------------------------------------- -TInt CTFTestControlObserver::RunError( TInt aError ) - { - return aError; - } -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::DoCancel() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::DoCancel() - { - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DoCancel - enter" ) ) ); - - switch( iRequestType ) - { - - case ReqDisconnectBtAccessory: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryBTControl->CancelDisconnectAccessory(); - } - } - break; - - case ReqConnectBtAccessory: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryBTControl->CancelConnectAccessory(); - } - } - break; - - case ReqNotifyNewAccessoryConnected: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessorySingleConnection->CancelNotifyNewAccessoryConnected(); - } - } - break; - - case ReqNotifyAccessoryDisconnected: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessorySingleConnection->CancelNotifyAccessoryDisconnected(); - } - } - break; - - case ReqNotifyAccessoryConnectionStatusChanged: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryConnection->CancelNotifyAccessoryConnectionStatusChanged(); - } - } - break; - - case ReqNotifyAccessoryModeChanged: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryMode->CancelNotifyAccessoryModeChanged(); - } - } - break; - - case ReqNotifyAccessoryAudioLinkOpened: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkOpened(); - } - } - break; - - case ReqAccessoryAudioLinkOpen: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryAudioControl->CancelAccessoryAudioLinkOpen(); - } - } - break; - - case ReqNotifyBluetoothAudioLinkOpenReq: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryBTControl->CancelNotifyBluetoothAudioLinkOpenReq(); - } - } - break; - - case ReqNotifyAccessoryAudioLinkClosed: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkClosed(); - } - } - break; - - case ReqAccessoryAudioLinkClose: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryAudioControl->CancelAccessoryAudioLinkClose(); - } - } - break; - - case ReqNotifyBluetoothAudioLinkCloseReq: - { - if( IsActive() ) - { - iAccessoryTestControl.iAccessoryBTControl->CancelNotifyBluetoothAudioLinkCloseReq(); - } - } - break; - - case ReqGetAccessoryConnectionStatus: - { - //if(IsActive()) - //{ - //iAccessoryTestControl.iAccessoryConnection.CancelGetAccessoryConnectionStatus(); - // } - } - break; - - default: - TRACE_ASSERT_ALWAYS; - break; - } - - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DoCancel - Leave" ) ) ); - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyNewAccessoryConnected -// ---------------------------------------------------------------------------------- - -void CTFTestControlObserver::NotifyNewAccessoryConnected( TAccPolGenericID& aGenericId ) - { - - if( !IsActive() ) - { - SetRequestType( ReqNotifyNewAccessoryConnected ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessorySingleConnection->NotifyNewAccessoryConnected( iStatus, - aGenericId ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyNewAccessoryConnected outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyAccessoryDisconnected -// ---------------------------------------------------------------------------------- - -void CTFTestControlObserver::NotifyAccessoryDisconnected( TAccPolGenericID& aGenericId ) - { - if( !IsActive() ) - { - SetRequestType( ReqNotifyAccessoryDisconnected ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryDisconnected( iStatus, - aGenericId ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryDisconnected outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyAccessoryModeChanged -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyAccessoryModeChanged() - { - if( !IsActive() ) - { - SetRequestType( ReqNotifyAccessoryModeChanged ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryMode->NotifyAccessoryModeChanged( iStatus, - iAccMode ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryModeChanged outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyAccessoryConnectionStatusChanged -// ---------------------------------------------------------------------------------- - -void CTFTestControlObserver::NotifyAccessoryConnectionStatusChanged( TAccPolGenericIDArray& aGenericIdArray ) - { - if( !IsActive() ) - { - SetRequestType( ReqNotifyAccessoryConnectionStatusChanged ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryConnection->NotifyAccessoryConnectionStatusChanged( iStatus, - aGenericIdArray ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryConnectionStatusChanged outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::AccessoryAudioLinkOpen() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::AccessoryAudioLinkOpen( TAccPolGenericID& aGenericId, - TUint32 aAudioType ) - { - if( !IsActive() ) - { - SetRequestType( ReqAccessoryAudioLinkOpen ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryAudioControl->AccessoryAudioLinkOpen( iStatus, - aGenericId, - ( TAccAudioType )aAudioType ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::AccessoryAudioLinkOpen outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyAccessoryAudioLinkOpened -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyAccessoryAudioLinkOpened( TAccPolGenericID& aGenericId ) - { - if( !IsActive() ) - { - SetRequestType( ReqNotifyAccessoryAudioLinkOpened ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryAudioControl->NotifyAccessoryAudioLinkOpened( iStatus, - aGenericId, - iAudioType ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryAudioLinkOpened outstanding" ) ) ); - } - } -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyAccessoryAudioLinkClosed -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyAccessoryAudioLinkClosed( TAccPolGenericID& aGenericId ) - { - if( !IsActive() ) - { - SetRequestType( ReqNotifyAccessoryAudioLinkClosed ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryAudioControl->NotifyAccessoryAudioLinkClosed( iStatus, - aGenericId, - iAudioType ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryAudioLinkClosed outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::AccessoryAudioLinkClose -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::AccessoryAudioLinkClose( TAccPolGenericID& aGenericId, - TUint32 aAudioType ) - { - if( !IsActive() ) - { - SetRequestType( ReqAccessoryAudioLinkClose ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryAudioControl->AccessoryAudioLinkClose( iStatus, - aGenericId, - ( TAccAudioType )aAudioType ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::AccessoryAudioLinkClose outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyBluetoothAudioLinkOpenReq -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyBluetoothAudioLinkOpenReq() - { - if( !IsActive() ) - { - SetRequestType( ReqNotifyBluetoothAudioLinkOpenReq ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryBTControl->NotifyBluetoothAudioLinkOpenReq( iStatus, - iBTaddr, - iAudioType ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyBluetoothAudioLinkOpenReq outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyBluetoothAudioLinkCloseReq -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyBluetoothAudioLinkCloseReq() - { - if( !IsActive() ) - { - SetRequestType( ReqNotifyBluetoothAudioLinkCloseReq ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryBTControl->NotifyBluetoothAudioLinkCloseReq( iStatus, - iBTaddr, - iAudioType ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyBluetoothAudioLinkCloseReq outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::ConnectBTAccessory() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::ConnectBTAccessory( TBTDevAddr& btaddr ) - { - if( !IsActive() ) - { - SetRequestType( ReqConnectBtAccessory ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryBTControl->ConnectAccessory( iStatus, - btaddr ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::ConnectBTAccessory outstanding" ) ) ); - } - - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::DisconnectBTAccessory() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::DisconnectBTAccessory( TBTDevAddr& btaddr ) - { - if( !IsActive() ) - { - SetRequestType( ReqDisconnectBtAccessory ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryBTControl->DisconnectAccessory( iStatus, - btaddr ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DisconnectBTAccessory outstanding" ) ) ); - } - - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyBooleanAccessoryValueChanged() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyBooleanAccessoryValueChanged( TAccPolGenericID& aGenericId, - const TUint32& aName ) - { - if( !IsActive() ) - { - TAccPolNameRecord nameRecord; - iCapabilityName = aName; - nameRecord.SetNameL( aName ); - SetRequestType( ReqNotifyBooleanAccessoryValueChanged ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryValueChanged( iStatus, - aGenericId, - nameRecord, - iBooleanValue ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyBooleanAccessoryValueChanged outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyIntegerAccessoryValueChanged() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyIntegerAccessoryValueChanged( TAccPolGenericID& aGenericId, - const TUint32& aName ) - { - if( !IsActive() ) - { - TAccPolNameRecord nameRecord; - iCapabilityName = aName; - nameRecord.SetNameL( aName ); - SetRequestType( ReqNotifyIntegerAccessoryValueChanged ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryValueChanged( iStatus, - aGenericId, - nameRecord, - iIntegerValue ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyIntegerAccessoryValueChanged outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::NotifyIntegerAccessoryValueChanged() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::NotifyObjectAccessoryValueChanged( TAccPolGenericID& aGenericId, - const TUint32& aName ) - { - if( !IsActive() ) - { - // Cleanup old data - iObjectValue.iValue.Zero(); - - TAccPolNameRecord nameRecord; - iCapabilityName = aName; - nameRecord.SetNameL( aName ); - SetRequestType( ReqNotifyObjectAccessoryValueChanged ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryValueChanged( iStatus, - aGenericId, - nameRecord, - iObjectValue ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyIntegerAccessoryValueChanged outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::GetAccessoryConnectionStatus() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::GetAccessoryConnectionStatus( TAccPolGenericIDArray& aGenericIdArray ) - { - if( !IsActive() ) - { - SetRequestType( ReqGetAccessoryConnectionStatus ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryConnection->GetAccessoryConnectionStatus( iStatus, - aGenericIdArray ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::GetAccessoryConnectionStatus outstanding" ) ) ); - } - - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::ConnectAccessory() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::ConnectAccessory( TAccPolGenericID& aGenericId, - TUint64 aHWDeviceID ) - { - CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); - - TBuf aHWModelID; - aHWModelID.Num( aHWDeviceID ); - - accConfigFileParser->FindL( aGenericId, aHWDeviceID, aHWModelID ); - - if( !IsActive() ) - { - SetRequestType( ReqAccessoryConnection ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryControl->ConnectAccessory( iStatus, - aGenericId ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::ConnectAccessory outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::DisconnectAccessory() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::DisconnectAccessory( TAccPolGenericID& aGenericId ) - { - if( !IsActive() ) - { - SetRequestType( ReqAccessoryDisconnection ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryControl->DisconnectAccessory( iStatus, - aGenericId ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DisconnectAccessory outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// CTFTestControlObserver::GetAccessoryMode() -// ---------------------------------------------------------------------------------- -void CTFTestControlObserver::GetAccessoryMode() - { - if( !IsActive() ) - { - SetRequestType( ReqGetAccessoryMode ); - iStatus = KRequestPending; - iAccessoryTestControl.iAccessoryMode->GetAccessoryMode( iStatus, - iAccMode ); - SetActive(); - TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::GetAccessoryMode outstanding" ) ) ); - } - } - -// -// ---------------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------------- -TBool CTFTestControlObserver::FindRequest( TTFRequestType aRequest ) - { - TBool bFound = EFalse; - - if( aRequest == iRequestType ) - { - bFound = ETrue; - } - return bFound; - } - +/* + * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ + +// INCLUDE FILES +#include +#include "siftrace.h" +#include "CtfTestControlObserver.h" +#include + +const TInt CTFTestControlObserver::iOffset = _FOFF(CTFTestControlObserver,iSlink); + +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver* CTFTestControlObserver::NewL() +// ---------------------------------------------------------------------------------- +CTFTestControlObserver* CTFTestControlObserver::NewL( CTFAccessoryTestControl& aTestControl ) + { + CTFTestControlObserver* result = + new ( ELeave ) CTFTestControlObserver( aTestControl ); + result->iObjectValueBuf = HBufC8::NewL( 256 ); + result->iObjectValue.iValue.Set( result->iObjectValueBuf->Des() ); + CleanupStack::PushL( result ); + CleanupStack::Pop(); + return result; + } + +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::CTFTestControlObserver() +// ---------------------------------------------------------------------------------- +CTFTestControlObserver::CTFTestControlObserver( CTFAccessoryTestControl& aTestControl ) : + CActive( CActive::EPriorityHigh ), + iAccessoryTestControl( aTestControl ), + iObjectValue( TPtr8( NULL, 0, 0 ) ) + { + + iRequestCompleted = ReqAccRequestNone; + iCapabilityName = 0; + + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::CTFTestControlObserver()" ) ) ); + CActiveScheduler::Add( this ); + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::CTFTestControlObserver - return" ) ) ); + } +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::~CTFTestControlObserver() +// ---------------------------------------------------------------------------------- +CTFTestControlObserver::~CTFTestControlObserver() + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::~CTFTestControlObserver - %d" ), iRequestType ) ); + delete iObjectValueBuf; + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::~CTFTestControlObserver - succesful" ) ) ); + } +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::RunL() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::RunL() + { + + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL - enter" ) ) ); + + switch( iRequestType ) + { + + case ReqDisconnectBtAccessory: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqDisconnectBtAccessory" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqConnectBtAccessory: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqConnectBtAccessory" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqNotifyNewAccessoryConnected: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyNewAccessoryConnected" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqNotifyAccessoryDisconnected: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryDisconnected" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqNotifyAccessoryConnectionStatusChanged: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryConnectionStatusChanged" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqNotifyAccessoryModeChanged: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryModeChanged" ) ) ); + iRequestCompleted = iRequestType; + iValue = iAccMode.iAccessoryMode; + } + break; + + case ReqGetAccessoryMode: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqGetAccessoryMode" ) ) ); + iRequestCompleted = iRequestType; + iValue = iAccMode.iAccessoryMode; + } + break; + + case ReqNotifyAccessoryAudioLinkOpened: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqConnectBtAccessory" ) ) ); + iRequestCompleted = iRequestType; + iValue = iAudioType; + } + break; + + case ReqAccessoryAudioLinkOpen: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqConnectBtAccessory" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqNotifyBluetoothAudioLinkOpenReq: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyBluetoothAudioLinkOpenReq" ) ) ); + iRequestCompleted = iRequestType; + iValue = iAudioType; + } + break; + + case ReqNotifyAccessoryAudioLinkClosed: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyAccessoryAudioLinkClosed" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqAccessoryAudioLinkClose: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqAccessoryAudioLinkClose" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqNotifyBluetoothAudioLinkCloseReq: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyBluetoothAudioLinkCloseReq" ) ) ); + iRequestCompleted = iRequestType; + iValue = iAudioType; + } + break; + + case ReqNotifyIntegerAccessoryValueChanged: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyIntegerAccessoryValueChanged" ) ) ); + iCapabilityName = 0; + iRequestCompleted = iRequestType; + iValue = iIntegerValue.iValue; + } + break; + + case ReqNotifyBooleanAccessoryValueChanged: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqNotifyBooleanAccessoryValueChanged" ) ) ); + iCapabilityName = 0; + iRequestCompleted = iRequestType; + iValue = ( TInt )iBooleanValue.iValue; + } + break; + + case ReqNotifyObjectAccessoryValueChanged: + { + iCapabilityName = 0; + iRequestCompleted = iRequestType; + } + break; + + case ReqAccessoryConnection: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqAccessoryConnection" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqAccessoryDisconnection: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqAccessoryDisconnection" ) ) ); + iRequestCompleted = iRequestType; + } + break; + + case ReqGetAccessoryConnectionStatus: + { + COMPONENT_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL() - ReqGetAccessoryConnectionStatus" ) ) ); + iRequestCompleted = iRequestType; + iValue = iAccessoryTestControl.iGenericIdArray.Count(); + } + break; + + default: + TRACE_ASSERT_ALWAYS; + break; + } + + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::RunL - return" ) ) ); + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::RunError() +// ---------------------------------------------------------------------------------- +TInt CTFTestControlObserver::RunError( TInt aError ) + { + return aError; + } +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::DoCancel() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::DoCancel() + { + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DoCancel - enter" ) ) ); + + switch( iRequestType ) + { + + case ReqDisconnectBtAccessory: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryBTControl->CancelDisconnectAccessory(); + } + } + break; + + case ReqConnectBtAccessory: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryBTControl->CancelConnectAccessory(); + } + } + break; + + case ReqNotifyNewAccessoryConnected: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessorySingleConnection->CancelNotifyNewAccessoryConnected(); + } + } + break; + + case ReqNotifyAccessoryDisconnected: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessorySingleConnection->CancelNotifyAccessoryDisconnected(); + } + } + break; + + case ReqNotifyAccessoryConnectionStatusChanged: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryConnection->CancelNotifyAccessoryConnectionStatusChanged(); + } + } + break; + + case ReqNotifyAccessoryModeChanged: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryMode->CancelNotifyAccessoryModeChanged(); + } + } + break; + + case ReqNotifyAccessoryAudioLinkOpened: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkOpened(); + } + } + break; + + case ReqAccessoryAudioLinkOpen: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryAudioControl->CancelAccessoryAudioLinkOpen(); + } + } + break; + + case ReqNotifyBluetoothAudioLinkOpenReq: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryBTControl->CancelNotifyBluetoothAudioLinkOpenReq(); + } + } + break; + + case ReqNotifyAccessoryAudioLinkClosed: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryAudioControl->CancelNotifyAccessoryAudioLinkClosed(); + } + } + break; + + case ReqAccessoryAudioLinkClose: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryAudioControl->CancelAccessoryAudioLinkClose(); + } + } + break; + + case ReqNotifyBluetoothAudioLinkCloseReq: + { + if( IsActive() ) + { + iAccessoryTestControl.iAccessoryBTControl->CancelNotifyBluetoothAudioLinkCloseReq(); + } + } + break; + + case ReqGetAccessoryConnectionStatus: + { + //if(IsActive()) + //{ + //iAccessoryTestControl.iAccessoryConnection.CancelGetAccessoryConnectionStatus(); + // } + } + break; + + default: + TRACE_ASSERT_ALWAYS; + break; + } + + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DoCancel - Leave" ) ) ); + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyNewAccessoryConnected +// ---------------------------------------------------------------------------------- + +void CTFTestControlObserver::NotifyNewAccessoryConnected( TAccPolGenericID& aGenericId ) + { + + if( !IsActive() ) + { + SetRequestType( ReqNotifyNewAccessoryConnected ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessorySingleConnection->NotifyNewAccessoryConnected( iStatus, + aGenericId ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyNewAccessoryConnected outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyAccessoryDisconnected +// ---------------------------------------------------------------------------------- + +void CTFTestControlObserver::NotifyAccessoryDisconnected( TAccPolGenericID& aGenericId ) + { + if( !IsActive() ) + { + SetRequestType( ReqNotifyAccessoryDisconnected ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryDisconnected( iStatus, + aGenericId ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryDisconnected outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyAccessoryModeChanged +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyAccessoryModeChanged() + { + if( !IsActive() ) + { + SetRequestType( ReqNotifyAccessoryModeChanged ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryMode->NotifyAccessoryModeChanged( iStatus, + iAccMode ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryModeChanged outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyAccessoryConnectionStatusChanged +// ---------------------------------------------------------------------------------- + +void CTFTestControlObserver::NotifyAccessoryConnectionStatusChanged( TAccPolGenericIDArray& aGenericIdArray ) + { + if( !IsActive() ) + { + SetRequestType( ReqNotifyAccessoryConnectionStatusChanged ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryConnection->NotifyAccessoryConnectionStatusChanged( iStatus, + aGenericIdArray ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryConnectionStatusChanged outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::AccessoryAudioLinkOpen() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::AccessoryAudioLinkOpen( TAccPolGenericID& aGenericId, + TUint32 aAudioType ) + { + if( !IsActive() ) + { + SetRequestType( ReqAccessoryAudioLinkOpen ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryAudioControl->AccessoryAudioLinkOpen( iStatus, + aGenericId, + ( TAccAudioType )aAudioType ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::AccessoryAudioLinkOpen outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyAccessoryAudioLinkOpened +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyAccessoryAudioLinkOpened( TAccPolGenericID& aGenericId ) + { + if( !IsActive() ) + { + SetRequestType( ReqNotifyAccessoryAudioLinkOpened ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryAudioControl->NotifyAccessoryAudioLinkOpened( iStatus, + aGenericId, + iAudioType ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryAudioLinkOpened outstanding" ) ) ); + } + } +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyAccessoryAudioLinkClosed +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyAccessoryAudioLinkClosed( TAccPolGenericID& aGenericId ) + { + if( !IsActive() ) + { + SetRequestType( ReqNotifyAccessoryAudioLinkClosed ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryAudioControl->NotifyAccessoryAudioLinkClosed( iStatus, + aGenericId, + iAudioType ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyAccessoryAudioLinkClosed outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::AccessoryAudioLinkClose +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::AccessoryAudioLinkClose( TAccPolGenericID& aGenericId, + TUint32 aAudioType ) + { + if( !IsActive() ) + { + SetRequestType( ReqAccessoryAudioLinkClose ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryAudioControl->AccessoryAudioLinkClose( iStatus, + aGenericId, + ( TAccAudioType )aAudioType ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::AccessoryAudioLinkClose outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyBluetoothAudioLinkOpenReq +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyBluetoothAudioLinkOpenReq() + { + if( !IsActive() ) + { + SetRequestType( ReqNotifyBluetoothAudioLinkOpenReq ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryBTControl->NotifyBluetoothAudioLinkOpenReq( iStatus, + iBTaddr, + iAudioType ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyBluetoothAudioLinkOpenReq outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyBluetoothAudioLinkCloseReq +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyBluetoothAudioLinkCloseReq() + { + if( !IsActive() ) + { + SetRequestType( ReqNotifyBluetoothAudioLinkCloseReq ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryBTControl->NotifyBluetoothAudioLinkCloseReq( iStatus, + iBTaddr, + iAudioType ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyBluetoothAudioLinkCloseReq outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::ConnectBTAccessory() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::ConnectBTAccessory( TBTDevAddr& btaddr ) + { + if( !IsActive() ) + { + SetRequestType( ReqConnectBtAccessory ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryBTControl->ConnectAccessory( iStatus, + btaddr ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::ConnectBTAccessory outstanding" ) ) ); + } + + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::DisconnectBTAccessory() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::DisconnectBTAccessory( TBTDevAddr& btaddr ) + { + if( !IsActive() ) + { + SetRequestType( ReqDisconnectBtAccessory ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryBTControl->DisconnectAccessory( iStatus, + btaddr ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DisconnectBTAccessory outstanding" ) ) ); + } + + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyBooleanAccessoryValueChanged() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyBooleanAccessoryValueChanged( TAccPolGenericID& aGenericId, + const TUint32& aName ) + { + if( !IsActive() ) + { + TAccPolNameRecord nameRecord; + iCapabilityName = aName; + nameRecord.SetNameL( aName ); + SetRequestType( ReqNotifyBooleanAccessoryValueChanged ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryValueChanged( iStatus, + aGenericId, + nameRecord, + iBooleanValue ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyBooleanAccessoryValueChanged outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyIntegerAccessoryValueChanged() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyIntegerAccessoryValueChanged( TAccPolGenericID& aGenericId, + const TUint32& aName ) + { + if( !IsActive() ) + { + TAccPolNameRecord nameRecord; + iCapabilityName = aName; + nameRecord.SetNameL( aName ); + SetRequestType( ReqNotifyIntegerAccessoryValueChanged ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryValueChanged( iStatus, + aGenericId, + nameRecord, + iIntegerValue ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyIntegerAccessoryValueChanged outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::NotifyIntegerAccessoryValueChanged() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::NotifyObjectAccessoryValueChanged( TAccPolGenericID& aGenericId, + const TUint32& aName ) + { + if( !IsActive() ) + { + // Cleanup old data + iObjectValue.iValue.Zero(); + + TAccPolNameRecord nameRecord; + iCapabilityName = aName; + nameRecord.SetNameL( aName ); + SetRequestType( ReqNotifyObjectAccessoryValueChanged ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessorySingleConnection->NotifyAccessoryValueChanged( iStatus, + aGenericId, + nameRecord, + iObjectValue ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::NotifyIntegerAccessoryValueChanged outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::GetAccessoryConnectionStatus() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::GetAccessoryConnectionStatus( TAccPolGenericIDArray& aGenericIdArray ) + { + if( !IsActive() ) + { + SetRequestType( ReqGetAccessoryConnectionStatus ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryConnection->GetAccessoryConnectionStatus( iStatus, + aGenericIdArray ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::GetAccessoryConnectionStatus outstanding" ) ) ); + } + + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::ConnectAccessory() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::ConnectAccessory( TAccPolGenericID& aGenericId, + TUint64 aHWDeviceID ) + { + CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + + TBuf aHWModelID; + aHWModelID.Num( aHWDeviceID ); + + CleanupStack::PushL( accConfigFileParser ); + accConfigFileParser->FindL( aGenericId, aHWDeviceID, aHWModelID ); + CleanupStack::Pop( accConfigFileParser ); + + if( !IsActive() ) + { + SetRequestType( ReqAccessoryConnection ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryControl->ConnectAccessory( iStatus, + aGenericId ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::ConnectAccessory outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::DisconnectAccessory() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::DisconnectAccessory( TAccPolGenericID& aGenericId ) + { + if( !IsActive() ) + { + SetRequestType( ReqAccessoryDisconnection ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryControl->DisconnectAccessory( iStatus, + aGenericId ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::DisconnectAccessory outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// CTFTestControlObserver::GetAccessoryMode() +// ---------------------------------------------------------------------------------- +void CTFTestControlObserver::GetAccessoryMode() + { + if( !IsActive() ) + { + SetRequestType( ReqGetAccessoryMode ); + iStatus = KRequestPending; + iAccessoryTestControl.iAccessoryMode->GetAccessoryMode( iStatus, + iAccMode ); + SetActive(); + TEST_CASE_TRACE( ( _L( "ACCESSORYTESTCONTROL - CTFTestControlObserver::GetAccessoryMode outstanding" ) ) ); + } + } + +// +// ---------------------------------------------------------------------------------- +// +// ---------------------------------------------------------------------------------- +TBool CTFTestControlObserver::FindRequest( TTFRequestType aRequest ) + { + TBool bFound = EFalse; + + if( aRequest == iRequestType ) + { + bFound = ETrue; + } + return bFound; + } + diff -r d38941471f1c -r cb32bcc88bad accessoryservices/accessoryserver/tsrc/public/basic/Stubs/AsyStub/src/AsyStubCmdHandlerBase.cpp --- a/accessoryservices/accessoryserver/tsrc/public/basic/Stubs/AsyStub/src/AsyStubCmdHandlerBase.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/accessoryserver/tsrc/public/basic/Stubs/AsyStub/src/AsyStubCmdHandlerBase.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -249,6 +249,7 @@ //get capabilities CAccPolSubblockNameArray* iNameArray = CAccPolSubblockNameArray::NewL(); + CleanupStack::PushL( iNameArray ); RAccessoryServer server; server.Connect(); @@ -281,7 +282,7 @@ connectionBase.CloseSubSession(); server.Close(); - delete iNameArray; + CleanupStack::PopAndDestroy( iNameArray ); // If everything is ok if( everyThing ) diff -r d38941471f1c -r cb32bcc88bad accessoryservices/accessoryserver/tsrc/public/basic/Stubs/AsyStub/src/AsyStubService.cpp --- a/accessoryservices/accessoryserver/tsrc/public/basic/Stubs/AsyStub/src/AsyStubService.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/accessoryserver/tsrc/public/basic/Stubs/AsyStub/src/AsyStubService.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -27,7 +27,7 @@ #include #include #include -#include +#include #ifdef FF_AUTOMOTIVESTACK #include #endif @@ -107,6 +107,7 @@ TBuf<12> HWModelID; HWModelID.Num( aParam1 ); + CleanupStack::PushL( accConfigFileParser ); __UHEAP_MARK; CAccConGenericID* genericID = CAccConGenericID::NewL(); CleanupStack::PushL( genericID ); @@ -121,7 +122,7 @@ iGenericId = genericID->GenericID(); CleanupStack::PopAndDestroy( genericID ); __UHEAP_MARKEND; - delete accConfigFileParser; + CleanupStack::PopAndDestroy( accConfigFileParser ); __UHEAP_MARKEND; } break; @@ -137,7 +138,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -183,12 +186,11 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Connect status %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); } break; @@ -198,7 +200,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -262,12 +266,11 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Update status %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); } break; @@ -277,7 +280,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -324,12 +329,11 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Update status %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); } break; @@ -339,7 +343,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -390,12 +396,11 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Update status %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); } break; @@ -405,7 +410,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -475,12 +482,11 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Update status %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); } break; @@ -596,7 +602,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -664,12 +672,11 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Update status for USB %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); } ; break; @@ -680,7 +687,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -773,15 +782,14 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Update status for USB %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( audioStream2 );// CleanupStack::PopAndDestroy( audioStream1 );// CleanupStack::PopAndDestroy( stream );// CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); } ; break; @@ -791,7 +799,9 @@ CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file") ); + CleanupStack::PushL( accConfigFileParser ); CAccConGenericID* genericID = CAccConGenericID::NewL(); + CleanupStack::PushL( genericID ); RArray nameValueArray; CleanupClosePushL( nameValueArray ); @@ -845,12 +855,11 @@ TInt retval = status.Int(); COMPONENT_TRACE( ( _L( "ASYSTUB - CASYStubService::Service - Update status %d" ), retval) ); - delete accConfigFileParser; iGenericId = genericID->GenericID(); - delete genericID; CleanupStack::PopAndDestroy( &nameValueArray );//nameValueArray.Close() is called; + CleanupStack::PopAndDestroy( 2, accConfigFileParser ); break; } diff -r d38941471f1c -r cb32bcc88bad accessoryservices/autoaudioasy/src/cautoaudioasymainservicebase.cpp --- a/accessoryservices/autoaudioasy/src/cautoaudioasymainservicebase.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/autoaudioasy/src/cautoaudioasymainservicebase.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -15,7 +15,7 @@ * */ // global headers -#include +#include #include // local headers diff -r d38941471f1c -r cb32bcc88bad accessoryservices/autoaudioasy/src/cautoaudioasyservice.cpp --- a/accessoryservices/autoaudioasy/src/cautoaudioasyservice.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/accessoryservices/autoaudioasy/src/cautoaudioasyservice.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include "cautoaudioasyservice.h" diff -r d38941471f1c -r cb32bcc88bad devicesrv_plat/common_accessory_plugin_api/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/devicesrv_plat/common_accessory_plugin_api/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Exports the files of Automotive Audio Plugin API. +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../inc/accessoryservicespskeys.h OS_LAYER_PLATFORM_EXPORT_PATH(accessoryservicespskeys.h) diff -r d38941471f1c -r cb32bcc88bad devicesrv_plat/common_accessory_plugin_api/inc/accessoryservicespskeys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/devicesrv_plat/common_accessory_plugin_api/inc/accessoryservicespskeys.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Publish&Subscribe definitions of the +* Accessory Services +* +*/ + + +#ifndef ACCESSORYSERVICESPSKEYS_H +#define ACCESSORYSERVICESPSKEYS_H + +#include + +static const TUid KPSUidAccessoryServices = { 0x10205030 }; + +// ============================================================================= +// Accessory Services Wired Connection API +// ============================================================================= +// Use TUid KPSUidAccessoryServices = { 0x10205030 } + +/** +* Notified when a wired accessory is physically connected or disconnected. +*/ +const TUint32 KAccSrvcsWiredConnection = 0x00000001; +enum TAccSrvcsWiredConnection + { + EAccSrvcsWiredConnUninitialized = 0, + EAccSrvcsWiredConnConnected, + EAccSrvcsWiredConnDisconnected + }; + + +#endif ACCESSORYSERVICESPSKEYS_H diff -r d38941471f1c -r cb32bcc88bad devicesrv_plat/group/bld.inf --- a/devicesrv_plat/group/bld.inf Wed Sep 29 15:13:21 2010 +0300 +++ b/devicesrv_plat/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -68,6 +68,7 @@ #include "../sensor_data_compensator_plugin_api/group/bld.inf" #include "../ddc_access_api/group/bld.inf" #include "../tv_out_behaviour_api/group/bld.inf" +#include "../common_accessory_plugin_api/group/bld.inf" #ifdef FF_AUTOMOTIVESTACK #include "../autoaudio_plugin_api/group/bld.inf" #endif diff -r d38941471f1c -r cb32bcc88bad devicesrv_pub/sensor_channel_api/tsrc/sensor/src/SensrvTestBlocks.cpp --- a/devicesrv_pub/sensor_channel_api/tsrc/sensor/src/SensrvTestBlocks.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/devicesrv_pub/sensor_channel_api/tsrc/sensor/src/SensrvTestBlocks.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1224,7 +1224,8 @@ ESensrvOperatorLessThanOrEquals, 3, dataBufX); - + + CleanupStack::PushL(testCondition); TPckgBuf getBuf; User::LeaveIfError(testCondition->GetConditionValue(getBuf)); TSensrvAccelerometerAxisData getItem1 = getBuf(); @@ -1298,6 +1299,8 @@ RDebug::Print( _L("CSensrvTestCases::ConditionUnitTestL - Overall time for %d ConditionValue %d microseconds"), i, overallTime2.Int64() ); RDebug::Print( _L("CSensrvTest::ConditionUnitTestL - Completed: %d"), err ); + + CleanupStack::PopAndDestroy(testCondition); return err; } diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Build definition. +* +*/ + + +#include + +PRJ_MMPFILES +hapticstest.mmp + +PRJ_EXPORTS +../rom/hapticstest.iby CORE_APP_LAYER_IBY_EXPORT_PATH(hapticstest.iby) + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/group/hapticstest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/group/hapticstest.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: MMP-file for the hapticstest application. +* +*/ + + +#include + +CAPABILITY ReadDeviceData + +VENDORID VID_DEFAULT + + +#ifdef __UI_FRAMEWORKS_V2__ +TARGETPATH /sys/bin +#if defined(EKA2) || !defined(WINS) +TARGET hapticstest.exe +TARGETTYPE exe +#else // EKA1 WINS +TARGET hapticstest.app +TARGETTYPE exedll +deffile /epoc32/release/wins/hapticstest.def +#endif +#else // __UI_FRAMEWORKS_V2__ +TARGET hapticstest.app +TARGETPATH /system/apps/hapticstest +TARGETTYPE app +#endif + +UID 0x100039CE 0x0AD0595A + +LANG SC + +SOURCEPATH ../src +SOURCE hapticstest.cpp +SOURCE hapticstestapplication.cpp +SOURCE hapticstestappview.cpp +SOURCE hapticstestappUi.cpp +SOURCE hapticstestdocument.cpp +SOURCE hapticstesteffectdatahandler.cpp +SOURCE hapticstestasyncplaysender.cpp + +SOURCEPATH ../group + + +USERINCLUDE ../inc +APP_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY avkon.lib +LIBRARY eikcoctl.lib +LIBRARY eikctl.lib +LIBRARY etext.lib +LIBRARY ws32.lib +LIBRARY gdi.lib +LIBRARY egul.lib +LIBRARY efsrv.lib +LIBRARY hwrmhapticsclient.lib +LIBRARY charconv.lib // CnvUtfConverter + + +#ifdef __UI_FRAMEWORKS_V2__ +START RESOURCE hapticstest.RSS +HEADER +targetpath /resource/apps +lang sc +end +#else +RESOURCE hapticstest.RSS +#endif + +#ifdef __UI_FRAMEWORKS_V2__ +sourcepath . +START RESOURCE hapticstest_reg.rss +TARGETPATH /private/10003a3f/import/apps +END + +start resource hapticstest_loc.RSS +targetpath /resource/apps +lang sc +end +#endif + +SMPSAFE + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/group/hapticstest.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/group/hapticstest.rss Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,694 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Application resource file. +* +*/ + + +NAME HAPT + +#include +#include +#include +#include + +#include "hapticstest.hrh" + + +// --------------------------------------------------------- +// +// Define the resource file signature +// This resource should be empty. +// +// --------------------------------------------------------- +// +RESOURCE RSS_SIGNATURE { } + +// --------------------------------------------------------- +// +// Default Document Name +// +// --------------------------------------------------------- +// +RESOURCE TBUF r_default_document_name { buf=""; } + +// --------------------------------------------------------- +// +// Define default menu and CBA key. +// +// --------------------------------------------------------- +// +RESOURCE EIK_APP_INFO + { + menubar = r_hapticstest_menubar; + cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_menubar +// Menubar for hapticstest example +// +// --------------------------------------------------------- +// +RESOURCE MENU_BAR r_hapticstest_menubar + { + titles = + { + MENU_TITLE {menu_pane = r_hapticstest_menu;} + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_menu +// Menu for "Options" +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_menu + { + items = + { + MENU_ITEM {cascade = r_hapticstest_init_submenu; command = EHapticsTestInit; txt = "Initialize";}, + MENU_ITEM {cascade = r_hapticstest_reserve_submenu; command = EHapticsTestReserve; txt = "Reserve/Release";}, + MENU_ITEM {cascade = r_hapticstest_ivtfiles_submenu; command = EHapticsTestLoadIVTFile; txt = "Load IVT-file";}, + MENU_ITEM {cascade = r_hapticstest_generalplay_submenu; command = EHapticsTestGeneralPlayEffect; txt = "Play Effect";}, + MENU_ITEM {cascade = r_hapticstest_changestate_submenu; command = EHapticsTestChangeState; txt = "Pause/Resume/Stop";}, + MENU_ITEM {cascade = r_hapticstest_modify_submenu; command = EHapticsTestModifyEffect; txt = "Modify Effect";}, + MENU_ITEM {cascade = r_hapticstest_deleteivtdata_submenu; command = EHapticsTestDeleteIVTData; txt = "Delete IVT data";}, + MENU_ITEM {cascade = r_hapticstest_toggle_submenu; command = EHapticsToggle; txt = "Toggle conf";}, + MENU_ITEM {cascade = r_hapticstest_properties_submenu; command=EHapticsTestPropertiesSubmenu; txt = "Properties";}, + MENU_ITEM {cascade = r_hapticstest_capabilities_submenu; command=EHapticsTestCapabilitiesSubmenu; txt = "Capabilities";}, + MENU_ITEM {command = EHapticsTestGetStatus; txt = "Print haptics status";}, + MENU_ITEM {command = EHapticsTestStreaming; txt = "Start streaming";}, + MENU_ITEM {command = EHapticsTestPlayStreamSample; txt = "Play sample";}, + MENU_ITEM {command = EHapticsTestNextStreamSample; txt = "Next sample";}, + MENU_ITEM {command = EHapticsTestPlayAllSamples; txt = "Play whole effect";}, + MENU_ITEM {command = EHapticsTestStopStreaming; txt = "Stop streaming";}, + MENU_ITEM {command = EHapticsTestDeleteAllIVTData; txt = "Delete all IVT data";}, + MENU_ITEM {command = EHapticsTestConstGetters; txt = "Const getters";}, + MENU_ITEM {command = EHapticsTestClearOutput; txt = "Clear output";}, + MENU_ITEM {command = EHapticsTestPanic; txt = "Panic!";}, + MENU_ITEM {command = EAknSoftkeyExit; txt = "Exit";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_init_submenu +// Submenu for initializing haptics. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_init_submenu + { + items = + { + MENU_ITEM {cascade = r_hapticstest_openclose_submenu; txt = "Open/Close";}, + MENU_ITEM {cascade = r_hapticstest_actuators_submenu; command = EHapticsTestOpenActuator; txt = "Open Actuator";}, + MENU_ITEM {command = EHapticsTestSupportedActuators; txt = "Supported Actuators";}, + MENU_ITEM {command = EHapticsTestAutoInit; txt = "AutoInit";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_openclose_submenu +// Submenu for opening and closing a haptics client. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_openclose_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestOpenHaptics; txt = "Open client";}, + MENU_ITEM {command = EHapticsTestCloseHaptics; txt = "Close client";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_actuators_submenu +// Submenu for opening an actuator. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_actuators_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestOpenActuatorAny; txt = "Any";}, + MENU_ITEM {command = EHapticsTestOpenActuatorDevice; txt = "Device";}, + MENU_ITEM {command = EHapticsTestOpenActuatorPrimaryDisplay; txt = "Primary Display";}, + MENU_ITEM {command = EHapticsTestOpenActuatorSecondaryDisplay; txt = "Secondary Display";}, + MENU_ITEM {command = EHapticsTestOpenActuatorGame; txt = "Game";}, + MENU_ITEM {command = EHapticsTestOpenActuatorGameLeft; txt = "Game Left";}, + MENU_ITEM {command = EHapticsTestOpenActuatorGameRight; txt = "Game Right";}, + MENU_ITEM {command = EHapticsTestOpenActuatorExternalVibra; txt = "External Vibra";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_ivtfiles_submenu +// Submenu for loading an ivt-file. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_ivtfiles_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestLoadIVTFileNoneFound; txt = "";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_deleteivtdata_submenu +// Submenu for deleting loaded ivt-files from haptics +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_deleteivtdata_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestDeleteIVTDataNoneFound; txt = "";} + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_generalplay_submenu +// Submenu for playing effects (ivt, repeat, manual). +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_generalplay_submenu + { + items = + { + MENU_ITEM {cascade = r_hapticstest_playeffect_submenu; command = EHapticsTestPlayEffect; txt = "Play";}, + MENU_ITEM {cascade = r_hapticstest_playeffectrepeat_submenu; command = EHapticsTestPlayEffectRepeat; txt = "Repeat";}, + MENU_ITEM {cascade = r_hapticstest_playeffectdef_submenu; command = EHapticsTestPlayEffectManual; txt = "Manual";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_playeffect_submenu +// Submenu for playing an effect using IVT-data. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_playeffect_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestPlayEffectNoneFound; txt = "";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_repeateffect_submenu +// Submenu for repeating an effect using IVT-data. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_playeffectrepeat_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestPlayEffectRepeatNoneFound; txt = "";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_playeffectdef_submenu +// Submenu for playing manual effect (magsweep/periodic/repeat). +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_playeffectdef_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestPlayEffectManualMagSweep; txt = "MagSweep (1 sec)";}, + MENU_ITEM {command = EHapticsTestPlayEffectManualMagSweepInf; txt = "MagSweep (inf)";}, + MENU_ITEM {command = EHapticsTestPlayEffectManualMagSweepInfMod; txt = "MagSweep (mod)";}, + MENU_ITEM {command = EHapticsTestPlayEffectManualPeriodic; txt = "Periodic (1 sec)";}, + MENU_ITEM {command = EHapticsTestPlayEffectManualPeriodicInf; txt = "Periodic (inf)";}, + MENU_ITEM {command = EHapticsTestPlayEffectManualPeriodicInfMod; txt = "Periodic (mod)";}, + MENU_ITEM {command = EHapticsTestPlayEffectManualRepeat; txt = "Repeat";} + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_changestate_submenu +// Submenu for pause, resume and stop effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_changestate_submenu + { + items = + { + MENU_ITEM {cascade = r_hapticstest_pause_submenu; txt = "Pause";}, + MENU_ITEM {cascade = r_hapticstest_resume_submenu; txt = "Resume";}, + MENU_ITEM {cascade = r_hapticstest_stop_submenu; txt = "Stop";}, + MENU_ITEM {command = EHapticsTestChangeStateStopAll; txt = "Stop all effects";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_pause_submenu +// Submenu for pause. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_pause_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestChangeStateNoneFound; txt = "";} + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_resume_submenu +// Submenu for resume. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_resume_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestChangeStateNoneFound; txt = "";} + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_stop_submenu +// Submenu for stop. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_stop_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestChangeStateNoneFound; txt = "";} + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_modify_submenu +// Submenu for modifying an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modify_submenu + { + items = + { + MENU_ITEM {cascade = r_hapticstest_modifyduration_submenu; txt = "Duration";}, + MENU_ITEM {cascade = r_hapticstest_modifymagnitude_submenu; txt = "Magnitude";}, + MENU_ITEM {cascade = r_hapticstest_modifystyle_submenu; txt = "Style";}, + MENU_ITEM {cascade = r_hapticstest_modifyattack_submenu; txt = "Attack level";}, + MENU_ITEM {cascade = r_hapticstest_modifyfade_submenu; txt = "Fade level";}, + MENU_ITEM {cascade = r_hapticstest_modifyattacktime_submenu; txt = "Attack time";}, + MENU_ITEM {cascade = r_hapticstest_modifyfadetime_submenu; txt = "Fade time";}, + MENU_ITEM {cascade = r_hapticstest_modifyperiod_submenu; txt = "Period";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifyduration_submenu +// Submenu for modifying duration of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifyduration_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectDuration1; txt = "1s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectDuration5; txt = "5s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectDuration10; txt = "10s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectDuration30; txt = "30s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectDuration60; txt = "60s"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifymagnitude_submenu +// Submenu for modifying magnitude of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifymagnitude_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectMagnitudeMin; txt = "Min"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectMagnitude25; txt = "25%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectMagnitude50; txt = "50%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectMagnitude75; txt = "75%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectMagnitudeMax; txt = "Max"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifystyle_submenu +// Submenu for modifying the style of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifystyle_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectStyleSmooth; txt = "Smooth"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectStyleStrong; txt = "Strong"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectStyleSharp; txt = "Sharp"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifyattack_submenu +// Submenu for modifying attack level of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifyattack_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectAttackMin; txt = "Min"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttack25; txt = "25%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttack50; txt = "50%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttack75; txt = "75%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttackMax; txt = "Max"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifyfade_submenu +// Submenu for modifying fadelevel of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifyfade_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectFadeMin; txt = "Min"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFade25; txt = "25%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFade50; txt = "50%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFade75; txt = "75%"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFadeMax; txt = "Max"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifyattacktime_submenu +// Submenu for modifying attack time of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifyattacktime_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectAttackTime02; txt = "0.2s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttackTime1; txt = "1s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttackTime5; txt = "5s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttackTime10; txt = "10s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttackTime30; txt = "30s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectAttackTime60; txt = "60s"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifyfadetime_submenu +// Submenu for modifying fade time of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifyfadetime_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectFadeTime02; txt = "0.2s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFadeTime1; txt = "1s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFadeTime5; txt = "5s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFadeTime10; txt = "10s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFadeTime30; txt = "30s"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectFadeTime60; txt = "60s"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_modifyperiod_submenu +// Submenu for modifying period of an effect. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_modifyperiod_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestModifyEffectPeriod50; txt = "50ms"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectPeriod100; txt = "100ms"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectPeriod300; txt = "300ms"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectPeriod600; txt = "600ms"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectPeriod1000; txt = "1000ms"; flags = EEikMenuItemCheckBox;}, + MENU_ITEM {command = EHapticsTestModifyEffectPeriod3000; txt = "3000ms"; flags = EEikMenuItemCheckBox;} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_reserve_submenu +// Submenu for reserving haptics. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_reserve_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestReserveNotTrusted; txt = "Reserve untrusted";}, + MENU_ITEM {command = EHapticsTestReserveTrusted; txt = "Reserve trusted";}, + MENU_ITEM {command = EHapticsTestRelease; txt = "Release haptics"; }, + MENU_ITEM {command = EHapticsTestReserveNotTrustedTemp; txt = "Reserve temporary";}, + MENU_ITEM {command = EHapticsTestReleaseTemp; txt = "Release temporary"; } + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_toggle_submenu +// Submenu for toggling configuration. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_toggle_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestSynchronousCalls; txt = "Synchronous methods";}, + MENU_ITEM {command = EHapticsTestAsynchronousCalls; txt = "Asynchronous methods";}, + MENU_ITEM {command = EHapticsTestUsingFileHandle; txt = "Use file handle";}, + MENU_ITEM {command = EHapticsTestNotUsingFileHandle; txt = "Use data buffer";}, + MENU_ITEM {command = EHapticsTestShowEffectInfo; txt = "Show played effect info";}, + MENU_ITEM {command = EHapticsTestHideEffectInfo; txt = "Don't show effect info";} + }; + } + + +// --------------------------------------------------------- +// +// r_hapticstest_properties_submenu +// Submenu for properties. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_properties_submenu + { + items = + { + //getters + MENU_ITEM {command = EHapticsTestGetPropertyPriority; txt = "Get Priority";}, + MENU_ITEM {command = EHapticsTestGetPropertyDisableEffects; txt = "Check Disable effects";}, + MENU_ITEM {command = EHapticsTestGetPropertyStrength; txt = "Get Strength";}, + //setters + MENU_ITEM {cascade = r_hapticstest_properties_set__priority_submenu; txt = "Priority";}, + MENU_ITEM {cascade = r_hapticstest_properties_set__disableeffects_submenu; txt = "DisableEffects";}, + MENU_ITEM {cascade = r_hapticstest_properties_set__strength_submenu; txt = "Strength";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_properties_set__priority_submenu +// Submenu for setting priority property +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_properties_set__priority_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestSetPropertyPriorityMin; txt = "Min";}, + MENU_ITEM {command = EHapticsTestSetPropertyPriorityDefault; txt = "Default";}, + MENU_ITEM {command = EHapticsTestSetPropertyPriorityMax; txt = "Max";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_properties_set__disableeffects_submenu +// Submenu for setting disable effects property. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_properties_set__disableeffects_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestSetPropertyDisableEffectsTrue; txt = "True";}, + MENU_ITEM {command = EHapticsTestSetPropertyDisableEffectsFalse; txt = "False";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_properties_set__strength_submenu +// Submenu for setting strength property. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_properties_set__strength_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestSetPropertyStrengthMute; txt = "Mute";}, + MENU_ITEM {command = EHapticsTestSetPropertyStrengthHalf; txt = "Half";}, + MENU_ITEM {command = EHapticsTestSetPropertyStrengthFull; txt = "Full";} + }; + } + +// --------------------------------------------------------- +// +// r_hapticstest_getcapabilities_submenu +// Submenu for capabilities. +// +// --------------------------------------------------------- +// +RESOURCE MENU_PANE r_hapticstest_capabilities_submenu + { + items = + { + MENU_ITEM {command = EHapticsTestGetCapabilityDeviceCategory; txt = "Device Category";}, + MENU_ITEM {command = EHapticsTestGetCapabilityMaxNestedRepeats; txt = "Max nested actuators";}, + MENU_ITEM {command = EHapticsTestGetCapabilityNumActuators; txt = "Number of actuators";}, + MENU_ITEM {command = EHapticsTestGetCapabilityActuatorType; txt = "Actuator type";}, + MENU_ITEM {command = EHapticsTestGetCapabilityNumEffectSlots; txt = "Effect slots";}, + MENU_ITEM {command = EHapticsTestGetCapabilityNumEffectStyles; txt = "Effect styles";}, + MENU_ITEM {command = EHapticsTestGetCapabilityMinPeriod; txt = "Min period";}, + MENU_ITEM {command = EHapticsTestGetCapabilityMaxPeriod; txt = "Max period";}, + MENU_ITEM {command = EHapticsTestGetCapabilityMaxEffectDuration; txt = "Max effectt duration";}, + MENU_ITEM {command = EHapticsTestGetCapabilitySupportedEffects; txt = "Supported effects";}, + MENU_ITEM {command = EHapticsTestGetCapabilityDeviceName; txt = "Device Name";}, + MENU_ITEM {command = EHapticsTestGetCapabilityAPIVersionNumber;txt = "API version number";}, + MENU_ITEM {command = EHapticsTestGetCapabilityMaxIVTSize;txt = "Max IVT file size";} + }; + } + +// --------------------------------------------------------- +// +// Array of selections for number of repeats in "repeat effect" +// cases.. +// +// --------------------------------------------------------- +// +RESOURCE ARRAY r_haptics_repeateffect_repeats_list + { + items = + { + LBUF {txt = "0 repeats"; }, + LBUF {txt = "1 repeat"; }, + LBUF {txt = "2 repeats"; }, + LBUF {txt = "3 repeats"; }, + LBUF {txt = "7 repeats"; }, + LBUF {txt = "Inf repeats"; } + }; + } + +// --------------------------------------------------------- +// +// List query resource for number of repeats in "repeat effect" +// cases.. +// +// --------------------------------------------------------- +// +RESOURCE AVKON_LIST_QUERY r_haptics_repeateffect_repeats_query + { + softkeys = R_AVKON_SOFTKEYS_OK_CANCEL; + + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control = AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_haptics_repeateffect_repeats_list; + }; + heading = "Repeats"; + }; + } + }; + } + + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/group/hapticstest_loc.rls --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/group/hapticstest_loc.rls Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Localization file. +* +*/ + + +//rls_string STRING_r_hapticstest_icon_path "z:\\resource\\apps\\hapticstesticon.mbm" +rls_string STRING_short_caption "hapticstest" +rls_string STRING_r_hapticstest_caption "hapticstest" + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/group/hapticstest_loc.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/group/hapticstest_loc.rss Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Localization resource file. +* +*/ + + +#include +#include "hapticstest_loc.rls" + +RESOURCE LOCALISABLE_APP_INFO + { + short_caption = STRING_short_caption; + caption_and_icon = + { + CAPTION_AND_ICON_INFO + { + caption=STRING_r_hapticstest_caption; + //number_of_icons=3; + //icon_file=STRING_r_hapticstest_icon_path; + } + }; + } + + + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/group/hapticstest_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/group/hapticstest_reg.rss Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Application registration file. +* +*/ + + +//hapticstest application's registration resource file + +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0x0AD0595A + +RESOURCE APP_REGISTRATION_INFO + { + app_file="hapticstest"; + // + localisable_resource_file="\\resource\\apps\\hapticstest_loc"; + // + } diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstest.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstest.hrh Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Defines options menu commands. +* +*/ + + +#ifndef __hapticstest_HRH__ +#define __hapticstest_HRH__ + +/** hapticstest enumerate command codes */ +enum THapticsTestIds + { + EHapticsTestOpenHaptics = 1, // start value must not be 0 + EHapticsTestAutoInit, + EHapticsTestSupportedActuators, + EHapticsTestOpenActuator, // for submenu + EHapticsTestOpenActuatorAny, + EHapticsTestOpenActuatorDevice, + EHapticsTestOpenActuatorPrimaryDisplay, + EHapticsTestOpenActuatorSecondaryDisplay, + EHapticsTestOpenActuatorGame, + EHapticsTestOpenActuatorGameLeft, + EHapticsTestOpenActuatorGameRight, + EHapticsTestOpenActuatorExternalVibra, + EHapticsTestLoadIVTFile, // for submenu + EHapticsTestLoadIVTFileNoneFound, + EHapticsTestLoadIVTFileSelected, + EHapticsTestGeneralPlayEffect, // for submenu + EHapticsTestPlayEffect, // for submenu + EHapticsTestPlayEffectNoneFound, + EHapticsTestPlayEffectSelected, + EHapticsTestPlayEffectRepeat, // for submenu + EHapticsTestPlayEffectRepeatNoneFound, + EHapticsTestPlayEffectRepeatSelected, + EHapticsTestPlayEffectManual, // for submenu + EHapticsTestPlayEffectManualMagSweep, + EHapticsTestPlayEffectManualMagSweepInf, + EHapticsTestPlayEffectManualMagSweepInfMod, + EHapticsTestPlayEffectManualPeriodic, + EHapticsTestPlayEffectManualPeriodicInf, + EHapticsTestPlayEffectManualPeriodicInfMod, + EHapticsTestPlayEffectManualRepeat, + EHapticsTestChangeState, // submenu + EHapticsTestChangeStateNoneFound, + EHapticsTestChangeStatePause, + EHapticsTestChangeStateResume, + EHapticsTestChangeStateStop, + EHapticsTestChangeStateStopAll, + EHapticsTestModifyEffect, // submenu + EHapticsTestModifyEffectDuration1, + EHapticsTestModifyEffectDuration5, + EHapticsTestModifyEffectDuration10, + EHapticsTestModifyEffectDuration30, + EHapticsTestModifyEffectDuration60, + EHapticsTestModifyEffectMagnitudeMin, + EHapticsTestModifyEffectMagnitude25, + EHapticsTestModifyEffectMagnitude50, + EHapticsTestModifyEffectMagnitude75, + EHapticsTestModifyEffectMagnitudeMax, + EHapticsTestModifyEffectStyleSmooth, + EHapticsTestModifyEffectStyleStrong, + EHapticsTestModifyEffectStyleSharp, + EHapticsTestModifyEffectAttackMin, + EHapticsTestModifyEffectAttack25, + EHapticsTestModifyEffectAttack50, + EHapticsTestModifyEffectAttack75, + EHapticsTestModifyEffectAttackMax, + EHapticsTestModifyEffectFadeMin, + EHapticsTestModifyEffectFade25, + EHapticsTestModifyEffectFade50, + EHapticsTestModifyEffectFade75, + EHapticsTestModifyEffectFadeMax, + EHapticsTestModifyEffectAttackTime02, + EHapticsTestModifyEffectAttackTime1, + EHapticsTestModifyEffectAttackTime5, + EHapticsTestModifyEffectAttackTime10, + EHapticsTestModifyEffectAttackTime30, + EHapticsTestModifyEffectAttackTime60, + EHapticsTestModifyEffectFadeTime02, + EHapticsTestModifyEffectFadeTime1, + EHapticsTestModifyEffectFadeTime5, + EHapticsTestModifyEffectFadeTime10, + EHapticsTestModifyEffectFadeTime30, + EHapticsTestModifyEffectFadeTime60, + EHapticsTestModifyEffectPeriod50, + EHapticsTestModifyEffectPeriod100, + EHapticsTestModifyEffectPeriod300, + EHapticsTestModifyEffectPeriod600, + EHapticsTestModifyEffectPeriod1000, + EHapticsTestModifyEffectPeriod3000, + EHapticsTestSynchronousCalls, + EHapticsTestAsynchronousCalls, + EHapticsTestUsingFileHandle, + EHapticsTestNotUsingFileHandle, + EHapticsTestShowEffectInfo, + EHapticsTestHideEffectInfo, + EHapticsTestDeleteIVTData, // for submenu + EHapticsTestDeleteIVTDataNoneFound, + EHapticsTestDeleteIVTDataSelected, + EHapticsTestDeleteAllIVTData, + EHapticsTestReserve, + EHapticsTestReserveNotTrusted, + EHapticsTestReserveTrusted, + EHapticsTestReserveNotTrustedTemp, + EHapticsTestRelease, + EHapticsTestReleaseTemp, + EHapticsTestCloseHaptics, + EHapticsTestClearOutput, + EHapticsTestConstGetters, + EHapticsTestGetStatus, + + EHapticsTestPropertiesSubmenu, + EHapticsTestCapabilitiesSubmenu, + + EHapticsTestSetPropertyPriorityMin, + EHapticsTestSetPropertyPriorityDefault, + EHapticsTestSetPropertyPriorityMax, + EHapticsTestSetPropertyDisableEffectsTrue, + EHapticsTestSetPropertyDisableEffectsFalse, + EHapticsTestSetPropertyStrengthMute, + EHapticsTestSetPropertyStrengthHalf, + EHapticsTestSetPropertyStrengthFull, + + + EHapticsTestGetPropertyPriority, + EHapticsTestGetPropertyDisableEffects, + EHapticsTestGetPropertyStrength, + + EHapticsTestGetCapabilityDeviceCategory, + EHapticsTestGetCapabilityMaxNestedRepeats, + EHapticsTestGetCapabilityNumActuators, + EHapticsTestGetCapabilityActuatorType, + EHapticsTestGetCapabilityNumEffectSlots, + EHapticsTestGetCapabilityNumEffectStyles, + EHapticsTestGetCapabilityMinPeriod, + EHapticsTestGetCapabilityMaxPeriod, + EHapticsTestGetCapabilityMaxEffectDuration, + EHapticsTestGetCapabilitySupportedEffects, + EHapticsTestGetCapabilityDeviceName, + EHapticsTestGetCapabilityMaxEnvelopeTime, + EHapticsTestGetCapabilityAPIVersionNumber, + EHapticsTestGetCapabilityMaxIVTSize, + EHapticsTestPanic, + + EHapticsTestInit, + EHapticsToggle, + EHapticsTestStreaming, + EHapticsTestPlayStreamSample, + EHapticsTestNextStreamSample, + EHapticsTestPlayAllSamples, + EHapticsTestStopStreaming + }; + +#endif // __hapticstest_HRH__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstest.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstest.pan Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Panic code definitions. +* +*/ + + +#ifndef __HAPTICSTEST_PAN__ +#define __HAPTICSTEST_PAN__ + +/** hapticstest application panic codes */ +enum THapticsTestPanics + { + EHapticsTestBasicUi = 1 + // add further panics here + }; + +inline void Panic(THapticsTestPanics aReason) + { + _LIT(applicationName,"hapticstest"); + User::Panic(applicationName, aReason); + } + +#endif // __HAPTICSTEST_PAN__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstestapplication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstestapplication.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Application class definition. +* +*/ + + +#ifndef __HAPTICSTEST_APPLICATION_H__ +#define __HAPTICSTEST_APPLICATION_H__ + +#include + +/** + * An instance of CHapticsTestApplication is the application part of the AVKON + * application framework for the hapticstest example application + */ +class CHapticsTestApplication : public CAknApplication + { +public: // from CAknApplication + + /** + * + * Returns the application DLL UID value + * @return the UID of this Application/Dll + */ + TUid AppDllUid() const; + +protected: // from CAknApplication + + /** + * Create a CApaDocument object and return a pointer to it + * @return a pointer to the created document + */ + CApaDocument* CreateDocumentL(); + }; + +#endif // __HAPTICSTEST_APPLICATION_H__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstestappui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstestappui.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,619 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: AppUi class definition. +* +*/ + + +#ifndef __HAPTICSTEST_APPUI_H__ +#define __HAPTICSTEST_APPUI_H__ + +#include +#include +#include +#include "hapticstestasyncplaysender.h" + +// Forward reference +class CHapticsTestAppView; +class CHWRMHaptics; +class CHapticsTestEffectDataHandler; +class CHapticsTestAsyncPlaySender; + +/** + * @class CHapticsTestAppUi + * + * An instance of class ChapticstestAppUi is the UserInterface part of the AVKON + * application framework for the hapticstest example application + */ +class CHapticsTestAppUi : public CAknAppUi, + public MHWRMHapticsObserver, + public MHWRMHapticsActuatorObserver + { +public: + + /** + * Perform the second phase construction of a ChapticstestAppUi object + * this needs to be public due to the way the framework constructs the AppUi + */ + void ConstructL(); + + /** + * Perform the first phase of two phase construction. + * This needs to be public due to the way the framework constructs the AppUi + */ + CHapticsTestAppUi(); + + /** + * Destroy the object and release all memory objects + */ + ~CHapticsTestAppUi(); + +public: // from CAknAppUi + + /** + * Handle user menu selections + * + * @param aCommand the enumerated code for the option selected + */ + void HandleCommandL(TInt aCommand); + + void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination); + +public: // from MEikMenuObserver + + /** + * @see MEikMenuObserver + * + * Manages the options menu contents based on user actions and data. + */ + virtual void DynInitMenuPaneL( TInt aResourceId, + CEikMenuPane* aMenuPane ); + +public: // from MHWRMHapticsObserver + + /** + * @see MHWRMHapticsObserver + * + * Outputs received status values onto the screen. + */ + virtual void HapticsStatusChangedL( THWRMHapticsStatus aStatus ); + + /** + * @see MHWRMHapticsObserver + * + * Future use --> empty implementation. + */ + virtual void EffectCompletedL( TInt aError, TInt aEffectHandle ); + +public: + + /** + * @see MHWRMHapticsActuatorObserver + * + * Outputs received actuator events onto the screen. + */ + virtual void ActuatorEventL( THWRMActuatorEvents aEvent, + THWRMLogicalActuators aActuator ); + +private: + + /** + * Creates haptics client instance. + */ + void OpenHapticsL(); + + /** + * Deletes haptics client instance, and resets member variables + * so that options-menu is updated accordingly; i.e. actions, which + * require usage of haptics client become hidden. + */ + void CloseHaptics(); + + /** + * Fetches the supported actuators from haptics server, and stores + * the mask to iSupportedActuators. + */ + void FetchSupportedActuators(); + + /** + * Prints the supported actuators to the UI according to + * the value in iSupportedActuators. + */ + void PrintSupportedActuators(); + + /** + * Attemps to open the given actuator. Prints the result + * of the attemp to the UI. + * + * @param aActuator The logical actuator type to open. + */ + void OpenActuator( THWRMLogicalActuators aActuator ); + + /** + * Reserves haptics for this application. + * + * @param aHaptics Haptics client instance, which should be used to + * make the reservation. + * @param aForceNoCoe If true, forces for haptics not to do automatic + * reserve/release on focus gain/lost (in this case this application + * must be trusted, otherwise the reservation call will end to + * KErrAccessDenied). If false, haptics will use automatic reserve/release + * on focus gain/lost (default). + */ + void ReserveHaptics( CHWRMHaptics* aHaptics, TBool aForceNoCoe ); + + /** + * Searches for IVT-files in the filesystem, and writes + * them to iIVTFileArray. + */ + void FindIVTFiles(); + + /** + * Loads IVT data from the given file to haptics. + * + * @param aFile File where the IVT-data is stored. + */ + void LoadIVTDataL( TFileName& aFile ); + + /** + * Plays the effect of the given index in the currently + * loaded IVT-file using its filehandle or IVT-data. + * + * @param aIndex Index of the effect in the IVT-file. + */ + void PlayEffect( TInt aIndex ); + + /** + * Plays the effect of the given index in the currently + * loaded IVT-file repeatedly using its filehandle or IVT-data. + * + * @param aIndex Index of the effect in the IVT-file. + * @param aRepeat Number of times the effect is to be repeated. + */ + void RepeatEffect( TInt aIndex, TInt aRepeats ); + + /** + * Plays a magsweep effect using manual definition. + * + * @param aInfinite Whether or not the effect should last infinitely. + * @param aModifiable Whether or not the effect should stored to member + * variables as the current modifiable effect. + */ + void PlayMagSweepL( TBool aInfinite = EFalse, TBool aModifiable = EFalse ); + + /** + * Plays a periodic effect using manual definition. + * + * @param aInfinite Whether or not the effect should last infinitely. + * @param aModifiable Whether or not the effect should stored to member + * variables as the current modifiable effect. + */ + void PlayPeriodicL( TBool aInfinite = EFalse, TBool aModifiable = EFalse ); + + /** + * Repeats a timeline effect using manual definition. + * + * @param aRepeat Number of times the effect is to be repeated. + */ + void PlayRepeatL( TInt aRepeat ); + + /** + * Pauses the effect of the given index in the effect history data. + * + * @param aIndex Index of the effect in the effect history data. + */ + void PauseEffect( TInt aIndex ); + + /** + * Resumes the effect of the given index in the effect history data. + * + * @param aIndex Index of the effect in the effect history data. + */ + void ResumeEffect( TInt aIndex ); + + /** + * Stops the effect of the given index in the effect history data. + * + * @param aIndex Index of the effect in the effect history data. + */ + void StopEffect( TInt aIndex ); + + /** + * Deletes loaded IVT data. + * + * @param aIndex Array index to the loaded IVT file array item + * (defined below) that is to be deleted. + */ + void DeleteLoadedIVTData( TInt aIndex ); + + /** + * Deletes all loaded IVT datas. + */ + void DeleteAllLoadedIVTData(); + + /** + * Fetches the current state of the last played effect + * (iEffectHandle), and prints the result to the UI. + */ + void GetCurrentEffectState(); + + /** + * Prints the status of a "play effect". + * + * @param aErrorCode Return code from playing an effect. + */ + void PrintPlayEffectStatus( TInt aErrorCode ) const; + + /** + * Gets the number of repeats from user in case of + * "play effect repeatedly" cases. + * In practice opens a list query where user may choose + * one of the available repeats values. + * + * @returns Number of repeats (one of 0,1,2,3,7,255), + * where 255 represents infinite value in vibra player. + */ + TInt GetNumberOfRepeats(); + + /** + * Creates all submenu items for a play effect submenu. + * Fetches all the names of the effects from currently + * loaded IVT-data. + * + * @param aMenuPane Menu object to which menu items are added. + * @param aCommandId Id of an options menu command to be used + * for all items. + * @param aDimCommand Id of a command, which needs to be dimmed, + * when the submenu contains items. + */ + void CreatePlayEffectSubmenuL( CEikMenuPane* aMenuPane, + TInt aCommandId, + TInt aDimCommandId ); + + /** + * Counts the actual effect index (within an IVT file) based + * on the index of the selected item in effects submenu. + * Also sets the iIVTFileHandle and iIVTDataBuffer members + * based on the file containing the selected effect. + * + * @param aSubmenuIndex Index from the submenu that contains + * all currently loaded effects (i.e., + * that contains all effects in all + * currently loaded IVT files). + * + * @returns Effect index. + */ + TInt CountFileHandleAndEffectIndex( TInt aSubmenuIndex ); + + /** + * Prints effect information got from getter functions. + * + * @param aIndex Index of the effect in the IVT-file. + */ + void PrintEffectInfo( TInt aIndex ); + + /** + * Prints the given status onto the screen. + * + * @param aStatus Status value to be printed. + */ + void PrintStatusInfo( MHWRMHapticsObserver::THWRMHapticsStatus aStatus ) const; + + /** + * Runs test for all getter methods for constants + * and prints out the results. + */ + void ConstGetters() const; + + /** + * Modifies an effect using the values set for iModifyEffect. + */ + void ModifyEffect(); + + /** + * Sets property Priority to min + */ + void SetPropertyPriorityMin(); + + /** + * Sets property Priority to default + */ + void SetPropertyPriorityDefault(); + + /** + * Sets property Priority to max + */ + void SetPropertyPriorityMax(); + + /** + * Sets property Disable effects to ETrue + */ + void SetPropertyDisableEffectsTrue(); + + /** + * Sets property Disable effects to EFalse + */ + void SetPropertyDisableEffectsFalse(); + + /** + * Sets property Strength to Min level + */ + void SetPropertyStrengthMin(); + + /** + * Sets property Strength to middle level + */ + void SetPropertyStrengthMiddle(); + + /** + * Sets property Strength to Max level + */ + void SetPropertyStrengthMax(); + + /** + * Gets Priority property value + */ + void GetPropertyPriority(); + + /** + * Gets Disable Effects property value + */ + void GetPropertyDisableEffects(); + + /** + * Gets Strength property value + */ + void GetPropertyStrength(); + + /** + * Gets device category capability. + */ + void GetCapabilityDeviceCategory(); + + /** + * Gets max nested repeats.. + */ + void GetCapabilityMaxNestedRepeats(); + + /** + * Gets number of actuators capability. + */ + void GetCapabilityNumActuators(); + + /** + * Gets actuator type capability. + */ + void GetCapabilityActuatorType(); + + /** + * Gets number of effect slots. + */ + void GetCapabilityNumEffectSlots(); + + /** + * Gets number of effect styles. + */ + void GetCapabilityNumEffectStyles(); + + /** + * Gets minimum period of periodic effects. + */ + void GetCapabilityMinPeriod(); + + /** + * Gets maximum period of periodic effects. + */ + void GetCapabilityMaxPeriod(); + + /** + * Gets maximum effect duration.. + */ + void GetCapabilityMaxEffectDuration(); + + /** + * Gets supported effect types.. + */ + void GetCapabilitySupportedEffects(); + + /** + * Gets device name capability. + */ + void GetCapabilityDeviceName(); + + /** + * Gets max envelope type. + */ + void GetCapabilityMaxEnvelopeTime(); + + /** + * Gets API version number. + */ + void GetCapabilityAPIVersionNumber(); + + /** + * Gets max size of IVT file. + */ + void GetCapabilityMaxIVTSize(); + + /** + * Callback method for CPeriodic timer for modifying a certain effect + * after each time period. + * + * @param aPtr Pointer to a TModifyEffect data used for the modification. + * @return System wide error code. + */ + static TInt ModifyPlayingEffect( TAny* aPtr ); + + /** + * Enables streaming mode. + */ + void StartStreaming(); + + /** + * Plays one streaming sample from KStreamArray. + * + * @param aSampleId Index to KStreamArray. + */ + void PlayStreamingSample( TInt aSampleId ); + + /** + * Disables streaming mode. + */ + void StopStreaming(); + +private: + + /** + * Internal struct for IVT files that contain file name, + * file handle (received from haptics) and IVT data + * as data buffer. + */ + struct TLoadedIVTFileItem + { + TFileName iFileName; + TInt iFileHandle; + HBufC8* iDataBuffer; // owns + + // ctor + TLoadedIVTFileItem() : iFileHandle( 0 ), iDataBuffer ( NULL ) + { + // empty + } + + // static matcher method used in checking whether the + // given file (name) is already in the loaded IVT + // files storage. + static TBool Match( const TLoadedIVTFileItem& a, const TLoadedIVTFileItem& b ) + { + TBool retVal = EFalse; + if ( 0 == a.iFileName.CompareF( b.iFileName ) ) + { + retVal = ETrue; + } + return retVal; + } + }; + +private: + + /** + * Menu pane pointer received in DynInitMenuPaneL() used + * in handling dynamic submenus (in HandleCommandL()). + * Not owned. + */ + CEikMenuPane* iMenuPane; + + /** + * Application view instance. Owned. + */ + CHapticsTestAppView* iAppView; + + /** + * Haptics client instance. Owned. + */ + CHWRMHaptics* iHaptics; + + /** + * Second haptics client instance used for making reservations, + * which cause iHaptics unable to use play-commands. Owned. + */ + CHWRMHaptics* iTempHaptics; + + /** + * Holds the information which logical actuators are supported + * by the haptics system. In the options menu, this value is used + * in construction of the actuator opening submenu. + */ + TUint32 iSupportedActuators; + + /** + * Constains the names of the IVT-files found in the + * filesystem, when the application was launched. + */ + RArray iIVTFileArray; + + /** + * Array that contains above defined items that represent + * currently loaded IVT files. + */ + RArray iLoadedIVTFileArray; + + /** + * Whether or not an actuator has been successfully opened. + */ + TBool iActuatorOpened; + + /** + * Filehandle to loaded IVT-data. + */ + TInt iIVTFileHandle; + + /** + * Buffer containing latest loaded IVT-data. + */ + HBufC8* iIVTDataBuffer; // not owned + + /** + * Effect handle to the last played effect. + */ + TInt iEffectHandle; + + /** + * Whether or not to use synchronous calls to haptics by defualt. + */ + TBool iSynchronous; + + /** + * Whether or not to use fileHandle when calling "play" Haptics API + * methods. + */ + TBool iUseHandle; + + /** + * Whether or not files are read from mem card (if not, they're + * read from phone memory). + */ + TBool iUsesMemCard; + + /** + * Is effect information showed or not + */ + TBool iShowEffectInfo; + + /** + * Objects used for storaging effect related history data and + * modifiable effect data. + */ + CHapticsTestEffectDataHandler* iEffectData; + + /** + * Is effect streaming on or not + */ + TBool iStreaming; + + /** + * played stream sample number + */ + TInt iCurrentSample; + + /** + * Active object for sending async play commands + */ + CHapticsTestAsyncPlaySender* iAsyncPlaySender; + friend class CHapticsTestAsyncPlaySender; + }; + + +#endif // __HAPTICSTEST_APPUI_H__ + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstestappview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstestappview.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: AppView class definition. +* +*/ + + +#ifndef __HAPTICSTEST_APPVIEW_H__ +#define __HAPTICSTEST_APPVIEW_H__ + +#include + +class CRichText; +class CParaFormatLayer; +class CCharFormatLayer; +class CEikRichTextEditor; + +/** + * An instance of the Application View object for the hapticstest + * example application + */ +class CHapticsTestAppView : public CCoeControl + { +public: + + /** + * Create a ChapticstestAppView object, which will draw itself to aRect + * + * @param aRect the rectangle this view will be drawn to + * @return a pointer to the created instance of ChapticstestAppView + */ + static CHapticsTestAppView* NewL( const TRect& aRect ); + + /** + * Create a ChapticstestAppView object, which will draw itself to aRect + * + * @param aRect the rectangle this view will be drawn to + * @return a pointer to the created instance of ChapticstestAppView + */ + static CHapticsTestAppView* NewLC( const TRect& aRect ); + + /** + * Destroy the object and release all memory objects + */ + ~CHapticsTestAppView(); + + /** + * Output the given line of text to the user. + * + * @param aOutputLine Text to be added to the end of the output. + * @param aLineBreak Whether or not to add line break to the end + * of the print. By default the break is inserted. + */ + void InsertOutput( const TDesC& aOutputLine, + TBool aLineBreak = ETrue ) const; + + /** + * Clears the output view. + */ + void ClearOutput() const; + +public: // from CCoeControl + + /** + * Draw this ChapticstestAppView to the screen + * + * @param aRect the rectangle of this view that needs updating + */ + void Draw(const TRect& aRect) const; + + /** + * @see CCoeControl + */ + virtual void SizeChanged(); + +private: + + /** + * Perform the second phase construction of a ChapticstestAppView object + * + * @param aRect the rectangle this view will be drawn to + */ + void ConstructL(const TRect& aRect); + + /** + * Perform the first phase of two phase construction + */ + CHapticsTestAppView(); + +private: + + CParaFormatLayer* iParaFormat; + CCharFormatLayer* iCharFormat; + CRichText* iRichText; + CEikRichTextEditor* iOutputWindow; + }; + + +#endif // __HAPTICSTEST_APPVIEW_H__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstestasyncplaysender.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstestasyncplaysender.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Definition for asynchronous play commands sender object. +* +*/ + + +#ifndef __HAPTICSTEST_ASYNCPLAYSENDER_H__ +#define __HAPTICSTEST_ASYNCPLAYSENDER_H__ + +#include +class CHapticsTestAppView; +class CHapticsTestAppUi; + +/** + * Active Object for sending async play methods + */ +class CHapticsTestAsyncPlaySender : public CActive + { +public: + + /** + * Constructor + * + * @param aUi Pointer to the test appl UI object. + */ + CHapticsTestAsyncPlaySender( CHapticsTestAppUi* aUi ); + + /** + * Destructor + */ + virtual ~CHapticsTestAsyncPlaySender(); + + /** + * Method for fileHandle type playing of effects repeatedly in asynch mode + * + * @param aHaptics Pointer to the haptics interface object. + * @param aFileHandle Handle for the effect data buffer from which to + * play the effects. + * @param aEffectIndex Index of the effect that is being played. + * @param aRepeat Number of repeats. + * @param aEffectHandle Out-parameter to which the handle for the played + * effect is returned. + */ + void PlayRepeat( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TUint8 aRepeat, + TInt& aEffectHandle ); + + /** + * Method for fileHandle type playing of effects in asynch mode + * + * @param aHaptics Pointer to the haptics interface object. + * @param aFileHandle Handle for the effect data buffer from which to + * play the effects. + * @param aEffectIndex Index of the effect that is being played. + * @param aEffectHandle Out-parameter to which the handle for the played + * effect is returned. + */ + void Play( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TInt& aEffectHandle ); + +public: + + /** + * From CActive + */ + virtual void RunL(); + + /** + * From CActive + */ + virtual void DoCancel(); + + /** + * From CActive + */ + virtual TInt RunError( TInt aError ); + +private: + + /** + * Pointer to the application UI object. + * Not owned. + */ + CHapticsTestAppUi* iUi; + + /** + * Index of the effect for which the play request was made. + */ + TInt iIndex; + }; + +#endif // __HAPTICSTEST_ASYNCPLAYSENDER_H__ + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstestdocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstestdocument.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Document class definition. +* +*/ + + +#ifndef __HAPTICSTEST_DOCUMENT_H__ +#define __HAPTICSTEST_DOCUMENT_H__ + +#include + +// Forward references +class CHapticsTestAppUi; +class CEikApplication; + + +/** + * An instance of class ChapticstestDocument is the Document part of the AVKON + * application framework for the hapticstest example application + */ +class CHapticsTestDocument : public CAknDocument + { +public: + + /** + * Construct a ChapticstestDocument for the AVKON application aApp + * using two phase construction, and return a pointer to the created object + * + * @param aApp application creating this document + * @return a pointer to the created instance of ChapticstestDocument + */ + static CHapticsTestDocument* NewL(CEikApplication& aApp); + + /** + * Construct a ChapticstestDocument for the AVKON application aApp + * using two phase construction, and return a pointer to the created object + * + * @param aApp application creating this document + * @return a pointer to the created instance of ChapticstestDocument + */ + static CHapticsTestDocument* NewLC(CEikApplication& aApp); + + /** + * Destroy the object and release all memory objects + */ + ~CHapticsTestDocument(); + +public: // from CAknDocument + + /** + * Create a ChapticstestAppUi object and return a pointer to it + * + * @return a pointer to the created instance of the AppUi created + */ + CEikAppUi* CreateAppUiL(); + +private: + + /** + * Perform the second phase construction of a ChapticstestDocument object + */ + void ConstructL(); + + /** + * Perform the first phase of two phase construction + * + * @param application creating this document + */ + CHapticsTestDocument(CEikApplication& aApp); + + }; + + +#endif // __HAPTICSTEST_DOCUMENT_H__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/inc/hapticstesteffectdatahandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/inc/hapticstesteffectdatahandler.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,486 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Handles and stores effect related data. +* +*/ + + +#ifndef __HAPTICSTEST_EFFECTDATAHANDLER_H__ +#define __HAPTICSTEST_EFFECTDATAHANDLER_H__ + +#include +#include + +// values used for modifying effects +const TInt KEffectMagnitude25 = 0.25 * KHWRMHapticsMaxMagnitude; +const TInt KEffectMagnitude50 = 0.50 * KHWRMHapticsMaxMagnitude; +const TInt KEffectMagnitude75 = 0.75 * KHWRMHapticsMaxMagnitude; +const TInt KEffectDuration1 = 1000; +const TInt KEffectDuration5 = 5000; +const TInt KEffectDuration10 = 10000; +const TInt KEffectDuration30 = 30000; +const TInt KEffectDuration60 = 60000; +const TInt KEffectAttackTime02 = 200; +const TInt KEffectAttackTime1 = 1000; +const TInt KEffectAttackTime5 = 5000; +const TInt KEffectAttackTime10 = 10000; +const TInt KEffectAttackTime30 = 30000; +const TInt KEffectAttackTime60 = 60000; +const TInt KEffectFadeTime02 = 200; +const TInt KEffectFadeTime1 = 1000; +const TInt KEffectFadeTime5 = 5000; +const TInt KEffectFadeTime10 = 10000; +const TInt KEffectFadeTime30 = 30000; +const TInt KEffectFadeTime60 = 60000; +const TInt KEffectPeriod50 = 50; +const TInt KEffectPeriod100 = 100; +const TInt KEffectPeriod300 = 300; +const TInt KEffectPeriod600 = 600; +const TInt KEffectPeriod1000 = 1000; +const TInt KEffectPeriod3000 = 3000; + +/** + * Handles effect data storage of both history data of + * played effects (array) and single effect data of the + * effect, which can be modified during runtime. + */ +class CHapticsTestEffectDataHandler : public CBase + { +public: + + /** + * Symbian two-phased construction. + * + * @return Pointer to the created instance. + */ + static CHapticsTestEffectDataHandler* NewL(); + + /** + * Symbian two-phased construction. Leaves the pointer + * onto the cleanupstack. + * + * @return Pointer to the created instance. + */ + static CHapticsTestEffectDataHandler* NewLC(); + + /** + * Destructor. + */ + virtual ~CHapticsTestEffectDataHandler(); + +public: // effect history array related + + /** + * Adds effect data to effect history array. + * + * @param aEffectHandle Handle to the effect just played. + * @param aFileHandle Handle to IVT-file used for the effect. The + * default value KErrNotFound indicates that an IVT-file was not used. + * @param aIndex Index of the effect in the effect file. The default + * value KErrNotFound indicates that an IVT-file was not used. + */ + void AddEffectInfo( TInt aEffectHandle, + TInt aFileHandle = KErrNotFound, + TInt aIndex = KErrNotFound ); + + /** + * Deletest all effect info items from the list that have the + * given filehandle in their data. This method is used, when deleting + * IVT-data, i.e. that data is no longer available. + * + * @param aFileHandle Handle to IVT-file used for the effect. + */ + void DeleteEffectInfo( TInt aFileHandle ); + + /** + * Returns the amount of effect data stored in the history data array. + */ + TInt Count() const; + + /** + * Returns the effect handle of the given effect data item. + * + * @param aIndex Index of the effect data in the history array. + * @return The effect handle of the effect. + */ + TInt EffectHandle( TInt aIndex ) const; + + /** + * Returns the file handle of the given effect data item. + * + * @param aIndex Index of the effect data in the history array. + * @return The file handle of the effect. + */ + TInt FileHandle( TInt aIndex ) const; + + /** + * Returns the effect index of the given effect data item. + * + * @param aIndex Index of the effect data in the history array. + * @return The effect index of the effect. + */ + TInt EffectIndex( TInt aIndex ) const; + +public: // modifiable effect related + + /** + * Resets the modifiable effect data with the data received in the + * given magsweep effect. + * + * @param aMagSweep MagSweep effect data. + * @param aEffectHandle Effect handle to this effect. + * @param aHaptics Haptics client instance. + */ + void ResetModifiableMagSweepEffectL( const CHWRMHaptics::THWRMHapticsMagSweepEffect& aMagSweep, + TInt aEffectHandle, + CHWRMHaptics* aHaptics ); + + /** + * Resets the modifiable effect data with the data received in the + * given periodic effect. + * + * @param aPeriodic Periodic effect data. + * @param aEffectHandle Effect handle to this effect. + * @param aHaptics Haptics client instance. + */ + void ResetModifiablePeriodicEffectL( const CHWRMHaptics::THWRMHapticsPeriodicEffect& aPeriodic, + TInt aEffectHandle, + CHWRMHaptics* aHaptics ); + + /** + * Starts the timer, which calls the ModifyPlayingEffect() callback + * after a certain time period for modifying the last stored effect + * using ResetModifiableEffectL(). + * + * @param aFunction Callback method for the started timer. + */ + void StartModifiableEffectTimerL( TInt (*aFunction)(TAny* aPtr) ); + + /** + * Stops and deletes the auto-modifiable effect timer. + */ + void ResetModifiableEffectTimer(); + + /** + * Returns whether or not a modifiable effect exists. + */ + TBool ModifiableEffectExists() const; + + /** + * Returns whether or not the currently stored effect is a + * magsweep effect. + */ + TBool ModifiableEffectIsMagSweep() const; + + /** + * Returns whether or not the currently stored effect is a + * periodic effect. + */ + TBool ModifiableEffectIsPeriodic() const; + + /** + * Returns the effect handle of the modifiable effect. + */ + TInt ModifiableEffectHandle() const; + + /** + * Returns the amount of times the current modifiable effect + * has been modified already. + */ + TInt ModifyCount() const; + + /** + * Returns the pointer to the haptics client instance, which + * has been set to the effect modification data. + */ + CHWRMHaptics* Haptics() const; + + /** + * Fills in default magsweep effect data into the given structure. + * + * @param aMagSweep MagSweep effect data structure for the method to fill. + * @param aInfinite Whether or not the duration should be infinite. + * @param aAutoModifiable Whether or not the created data is used + * for automatic modification using a timer. + * @param aHaptics Haptics client instance. + */ + void FillDefaultMagSweepData( CHWRMHaptics::THWRMHapticsMagSweepEffect& aMagSweep, + TBool aInfinite, TBool aAutoModifiable, + CHWRMHaptics* aHaptics ) const; + + /** + * Fills in default periodic effect data into the given structure. + * + * @param aPeriodic Periodic effect data structure for the method to fill. + * @param aInfinite Whether or not the duration should be infinite. + * @param aAutoModifiable Whether or not the created data is used + * for automatic modification using a timer. + * @param aHaptics Haptics client instance. + */ + void FillDefaultPeriodicData( CHWRMHaptics::THWRMHapticsPeriodicEffect& aPeriodic, + TBool aInfinite, TBool aAutoModifiable, + CHWRMHaptics* aHaptics ) const; + + /** + * Fills in the modifiable effect data into the given magsweep structure. + * + * @param aMagSweep MagSweep effect data structure for the method to fill. + */ + void FillModifiableMagSweepData( CHWRMHaptics::THWRMHapticsMagSweepEffect& aMagSweep ) const; + + /** + * Fills in the modifiable effect data into the given periodic structure. + * + * @param aPeriodic Periodic effect data structure for the method to fill. + */ + void FillModifiablePeriodicData( CHWRMHaptics::THWRMHapticsPeriodicEffect& aPeriodic ) const; + + /** + * Sets the modifiable effect's modify count. + */ + void SetModifyCount( TInt aModifyCount ); + + /** + * Sets the modifiable effect's duration value. + */ + void SetDuration( TInt aDuration ); + + /** + * Sets the modifiable effect's magnitude value. + */ + void SetMagnitude( TInt aMagnitude ); + + /** + * Sets the modifiable effect's style value. + */ + void SetStyle( CHWRMHaptics::THWRMHapticsEffectStyles aStyle ); + + /** + * Sets the modifiable effect's attack level value. + */ + void SetAttackLevel( TInt aAttackLevel ); + + /** + * Sets the modifiable effect's fade level value. + */ + void SetFadeLevel( TInt aFadeLevel ); + + /** + * Sets the modifiable effect's attack time value. + */ + void SetAttackTime( TInt aAttackTime ); + + /** + * Sets the modifiable effect's fade time value. + */ + void SetFadeTime( TInt aFadeTime ); + + /** + * Sets the modifiable effect's period value. + */ + void SetPeriod( TInt aPeriod ); + +public: // submenu handling for effect data related submenus + + /** + * Creates all submenu items for a change effect state submenu + * (pause, resume, stop). Fetches all the names of the effects + * from currently loaded IVT-data. + * + * @param aMenuPane Menu object to which menu items are added. + * @param aCommandId Id of an options menu command to be used + * for all items. + * @param aHaptics Haptics client instance used for fetching effect names. + */ + void DynInitChangeEffectStateSubmenuL( CEikMenuPane* aMenuPane, + TInt aCommandId, + CHWRMHaptics* aHaptics ); + + /** + * Creates the checkmark to the duration, which is currently in use + * in the duration modification submenu. + */ + void DynInitDurationSubmenu( CEikMenuPane* aMenuPane ) const; + + /** + * Creates the checkmark to the magnitude, which is currently in use + * in the magnitude modification submenu. + */ + void DynInitMagnitudeSubmenu( CEikMenuPane* aMenuPane ) const; + + /** + * Creates the checkmark to the style, which is currently in use + * in the style modification submenu. + */ + void DynInitStyleSubmenu( CEikMenuPane* aMenuPane ) const; + + /** + * Creates the checkmark to the attack level, which is currently in use + * in the attack level modification submenu. + */ + void DynInitAttackLevelSubmenu( CEikMenuPane* aMenuPane ) const; + + /** + * Creates the checkmark to the fade level, which is currently in use + * in the fade level modification submenu. + */ + void DynInitFadeLevelSubmenu( CEikMenuPane* aMenuPane ) const; + + /** + * Creates the checkmark to the attack time, which is currently in use + * in the attack time modification submenu. + */ + void DynInitAttackTimeSubmenu( CEikMenuPane* aMenuPane ) const; + + /** + * Creates the checkmark to the fade time, which is currently in use + * in the fade time modification submenu. + */ + void DynInitFadeTimeSubmenu( CEikMenuPane* aMenuPane ) const; + + /** + * Creates the checkmark to the period, which is currently in use + * in the period modification submenu. + */ + void DynInitPeriodSubmenu( CEikMenuPane* aMenuPane ) const; + +private: + + /** + * Internal structure for maintaining information about played + * effect. The data is used, when pausing, stopping and resuming + * effect play. + */ + struct TPlayedEffect + { + /** + * Handle to IVT-data file, from which the effect has been played. + * Needed for fetching effect related information. + */ + TInt iFileHandle; + + /** + * Index of the effect in the effect file. Needed for fetching + * effect related information. + */ + TInt iEffectIndex; + + /** + * Handle to the effect itself. + */ + TInt iEffectHandle; + }; + + /** + * Internal structure for maintaining information about an effect, + * which can be modified during application execution. + */ + struct TModifyEffect + { + /** + * Haptics client instance. Not owned. + * The pointer is included in this data so that the + * timer callback method is able to access haptics. + */ + CHWRMHaptics* iHaptics; + + /** + * Type of the effect being modified. + */ + CHWRMHaptics::THWRMHapticsEffectTypes iEffectType; + + /** + * Handle to the effect itself. + */ + TInt iEffectHandle; + + /** + * Keeps track on how many modifications have been done. + */ + TInt iModifyCount; + + /** + * Duration value used for the effect. + */ + TInt iDuration; + + /** + * Magnitude value used for the effect. + */ + TInt iMagnitude; + + /** + * Style of the effect. + */ + TInt iStyle; + + /** + * Attack level value used for the effect. + */ + TInt iAttackLevel; + + /** + * Fade level value used for the effect. + */ + TInt iFadeLevel; + + /** + * Attack time value used for the effect. + */ + TInt iAttackTime; + + /** + * Fade time value used for the effect. + */ + TInt iFadeTime; + + /** + * Period value used for the (periodic) effect. + */ + TInt iPeriod; + }; + +private: + + /** + * C++ constructor. + */ + CHapticsTestEffectDataHandler(); + + /** + * Second phase construction. + */ + void ConstructL(); + +private: + + /** + * Array containing history data of effect play. Used for + * pausing, resuming and stopping effects. + */ + RArray iPlayedEffectArray; + + /** + * Timer used for constant modification of an effect. + */ + CPeriodic* iModifyTimer; + + /** + * Effect data stored for effect modification. + */ + TModifyEffect* iModifyEffect; + }; + + +#endif // __HAPTICSTEST_EFFECTDATAHANDLER_H__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/rom/hapticstest.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/rom/hapticstest.iby Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: IBY file for Haptics client test application +* +*/ + + +#ifndef __HAPTICSTEST_IBY__ +#define __HAPTICSTEST_IBY__ + +#include + +file=ABI_DIR\BUILD_DIR\hapticstest.exe PROGRAMS_DIR\hapticstest.exe +data=DATAZ_\APP_RESOURCE_DIR\hapticstest.rsc APP_RESOURCE_DIR\hapticstest.rsc +data=DATAZ_\private\10003a3f\import\apps\hapticstest_reg.rsc \private\10003a3f\import\apps\hapticstest_reg.rsc + +#endif // __HAPTICSTEST_IBY__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/sis/createandsign.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/sis/createandsign.cmd Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,22 @@ +@echo off +REM Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +REM All rights reserved. +REM This component and the accompanying materials are made available +REM under the terms of the License "Symbian Foundation License v1.0" +REM which accompanies this distribution, and is available +REM at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +REM +REM Initial Contributors: +REM Nokia Corporation - initial contribution. +REM +REM Contributors: +REM +REM Description: ?Description +REM +REM +@echo on + + +del /q hapticstest.sis* +makesis hapticstest.pkg +signsis hapticstest.sis hapticstest.sisx rdtest_02.der rdtest_02.key \ No newline at end of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/sis/hapticstest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/sis/hapticstest.pkg Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,22 @@ +; hapticstest.pkg +; +;Language - standard language definitions +&EN + +; standard SIS file header +#{"hapticstest"},(0x0AD0595A),1,0,0 + +;Supports Series 60 v 3.0 +[0x101F7961],0,0,0,{"Series60ProductID"} + +;Localized Vendor Name +%{"My Test EN"} + +;Unique Vendor name +:"Vendor" + +; Files to copy +"\epoc32\release\armv5\urel\hapticstest.exe"-"!:\sys\bin\hapticstest.exe" +"\epoc32\data\z\private\10003a3f\import\apps\hapticstest_reg.rsc"-"!:\private\10003a3f\import\apps\hapticstest_reg.rsc" +"\epoc32\data\z\resource\apps\hapticstest_loc.Rsc"-"!:\resource\apps\hapticstest_loc.Rsc" +"\epoc32\data\z\resource\apps\hapticstest.Rsc"-"!:\resource\apps\hapticstest.Rsc" diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/sis/rdtest_02.der Binary file hwrmhaptics/examples/hapticstestapp/sis/rdtest_02.der has changed diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/sis/rdtest_02.key --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/sis/rdtest_02.key Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQC/TDP7KKIaf5+uW4OD2iVZuUMC2a+SeQTjf6srlKcOm+CpPNXn +uLNm/8fdEnyOIuRXPRKmqhs1n0JkxEGHynELWMTuKXbQx9SRAGUXzyneGn+IJNnO +vOKHWgKCouX2hfI8rtkdqJpqmO460gGsMgw+lsbeyWyW9lnfLxq+ZC7sqQIDAQAB +AoGBALmUWZE8GBaQ3P4u9WUCSd3DJkkrmXIFSULSZeH/chlwCwDjbbhArHothVzo +REE3hEFFlERvHbplZ+mNouzy7boduvgUzbksGrbGMLJ2qO1GzWWVwV+GzOWKd3ss +/98Gwoy5R8pjnkqUE2wP1iJFw0FjvUTKcYv/z6t3LLJ0CsoBAkEA+c7ixvsviQ3J +s0INytCKU2bf8fqFQJi1VI82ukxNsujGTQ9upVSjuvqPvWyDvvTdrUBHqO+3qPut +sEh01Q8aiQJBAMQKDJPVRu4ud3mwUfEavzL5EjqwG1k9VCNGYsT4FwtrHcxu1oP/ +pk6M3rIZukqomoEEnHWPMwhrK3fhBqi0OSECQQDr40VXege4FnH5OI2Hj4afHMyp +VdQQXGMWFyopnzXblFz0lXb43cTCIiorR9XcMqNFHybLypkWE5o+lRzlt55pAkBQ +P/zeF5Sts//cpL0mgdh7OVKpC6ZmZaCnwAx2rUhhuDu+kDDoYCLoTOps5fNI1LRK +1GRoC3LMo3Jr5IYhUYWBAkBpCpN6k4JU/mszq98EojHerQNxk8sPqvQKUzTutohT +1gLX9yepGayB/TtT2EEJDkWOlnTy/dvN6W3vzbJYz97x +-----END RSA PRIVATE KEY----- diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/src/hapticstest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/src/hapticstest.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "hapticstestapplication.h" +#include + +#ifdef __UI_FRAMEWORKS_V2__ + +// --------------------------------------------------------- +// Create an application, and return a pointer to it +// --------------------------------------------------------- +// +CApaApplication* NewApplication() + { + return new CHapticsTestApplication; + } + +// --------------------------------------------------------- +// Main entry-point. +// --------------------------------------------------------- +// +TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + +/////////////////////////////////////////////////////////////////////////////// +// +// The following is required for wins on EKA1 (using the exedll target) +// +#if defined(__WINS__) && !defined(EKA2) +EXPORT_C TInt WinsMain(TDesC* aCmdLine) + { + return EikStart::RunApplication(NewApplication, aCmdLine); + } + +TInt E32Dll(TDllReason) + { + return KErrNone; + } +#endif + +#else // __UI_FRAMEWORKS_V2__ + +// Create an application, and return a pointer to it +EXPORT_C CApaApplication* NewApplication() + { + return new ChapticstestApplication; + } + +// DLL entry point, return that everything is ok +GLDEF_C TInt E32Dll(TDllReason) + { + return KErrNone; + } + +#endif // __UI_FRAMEWORKS_V2__ + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/src/hapticstestapplication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/src/hapticstestapplication.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Application class implementation. +* +*/ + + +#include "hapticstestdocument.h" +#include "hapticstestapplication.h" + +// UID for the application, this should correspond to the uid defined in the mmp file +static const TUid KUidhapticstestApp = {0x0AD0595A}; + +// --------------------------------------------------------- +// Creates the document component of the application. +// --------------------------------------------------------- +// +CApaDocument* CHapticsTestApplication::CreateDocumentL() + { + // Create an hapticstest document, and return a pointer to it + CApaDocument* document = CHapticsTestDocument::NewL(*this); + return document; + } + +// --------------------------------------------------------- +// Returns application uid. +// --------------------------------------------------------- +// +TUid CHapticsTestApplication::AppDllUid() const + { + // Return the UID for the hapticstest application + return KUidhapticstestApp; + } + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/src/hapticstestappui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/src/hapticstestappui.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,3369 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: AppUi class implementation. +* +*/ + + +#include +#include +#include +#include +#include +#include + +#include "hapticstest.pan" +#include "hapticstestappui.h" +#include "hapticstestappview.h" +#include "hapticstesteffectdatahandler.h" +#include "hapticstest.hrh" + +_LIT( KSessionPathMem, "C:\\Data\\Others\\" ); +_LIT( KSessionPathCrd, "E:\\Others\\" ); +_LIT( KIVTFileType, "*.ivt" ); + +const TInt KSampleCount = 8; + +static const TUint8 KStreamArray[KSampleCount][10] = + { + 0x00, 0x00, 0x20, 0x13, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0x41, + 0x29, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42, + 0x51, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0xc1, + 0x65, 0x00, 0x20, 0x07, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0xd1, + 0x7a, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42, + 0x8e, 0x00, 0x20, 0x16, 0x00, 0x00, 0x7f, 0x01, 0x5d, 0x01, + 0xa2, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42, + 0x06, 0x00, 0x20, 0x08, 0x00, 0x00, 0x7f, 0xc1, 0x4d, 0x42 + }; + + + + +// --------------------------------------------------------- +// ConstructL is called by the application framework +// --------------------------------------------------------- +// +void CHapticsTestAppUi::ConstructL() + { + BaseConstructL(); + + // create appview + iAppView = CHapticsTestAppView::NewL( ClientRect() ); + AddToStackL( iAppView ); + + // create effect data handler + iEffectData = CHapticsTestEffectDataHandler::NewL(); + + // create async play sender + iAsyncPlaySender = new ( ELeave ) CHapticsTestAsyncPlaySender( this ); + + FindIVTFiles(); + + iAppView->InsertOutput( _L("Haptics usage from options menu.") ); + } + +// --------------------------------------------------------- +// Constructor. +// --------------------------------------------------------- +// +CHapticsTestAppUi::CHapticsTestAppUi() + : iSynchronous( ETrue ), iUseHandle( EFalse ), iUsesMemCard( EFalse ) + { + // no implementation required + } + +// --------------------------------------------------------- +// Destructor. +// --------------------------------------------------------- +// +CHapticsTestAppUi::~CHapticsTestAppUi() + { + if (iAppView) + { + RemoveFromStack( iAppView ); + delete iAppView; + iAppView = NULL; + } + + if( iHaptics ) + { + delete iHaptics; + iHaptics = NULL; + } + + if ( iTempHaptics ) + { + delete iTempHaptics; + iTempHaptics = NULL; + } + + delete iEffectData; + + iIVTFileArray.Close(); + + while ( iLoadedIVTFileArray.Count() ) + { + delete iLoadedIVTFileArray[0].iDataBuffer; + iLoadedIVTFileArray.Remove( 0 ); + } + + iLoadedIVTFileArray.Close(); + + if ( iAsyncPlaySender ) + { + iAsyncPlaySender->Cancel(); + delete iAsyncPlaySender; + iAsyncPlaySender = NULL; + } + } + +// --------------------------------------------------------- +// handle any menu commands +// --------------------------------------------------------- +// +void CHapticsTestAppUi::HandleCommandL( TInt aCommand ) + { + switch( aCommand ) + { + case EEikCmdExit: + case EAknSoftkeyExit: + Exit(); + break; + + case EHapticsTestOpenHaptics: + { + OpenHapticsL(); + } + break; + + case EHapticsTestAutoInit: + { + // automatically create haptics instance, fetch supported + // actuators, and open Any-actuator + OpenHapticsL(); + FetchSupportedActuators(); + OpenActuator( EHWRMLogicalActuatorAny ); + } + break; + + case EHapticsTestSupportedActuators: + { + FetchSupportedActuators(); + } + break; + + case EHapticsTestOpenActuator: + case EHapticsTestOpenActuatorAny: + { + OpenActuator( EHWRMLogicalActuatorAny ); + } + break; + case EHapticsTestOpenActuatorDevice: + { + OpenActuator( EHWRMLogicalActuatorDevice ); + } + break; + case EHapticsTestOpenActuatorPrimaryDisplay: + { + OpenActuator( EHWRMLogicalActuatorPrimaryDisplay ); + } + break; + case EHapticsTestOpenActuatorSecondaryDisplay: + { + OpenActuator( EHWRMLogicalActuatorSecondaryDisplay ); + } + break; + case EHapticsTestOpenActuatorGame: + { + OpenActuator( EHWRMLogicalActuatorGame ); + } + break; + case EHapticsTestOpenActuatorGameLeft: + { + OpenActuator( EHWRMLogicalActuatorGameLeft ); + } + break; + case EHapticsTestOpenActuatorGameRight: + { + OpenActuator( EHWRMLogicalActuatorGameRight ); + } + break; + case EHapticsTestOpenActuatorExternalVibra: + { + OpenActuator( EHWRMLogicalActuatorExternalVibra ); + } + break; + + case EHapticsTestLoadIVTFile: + case EHapticsTestLoadIVTFileNoneFound: + { + // nothing to do + } + break; + case EHapticsTestLoadIVTFileSelected: + { + // open selected file + TInt index = iMenuPane->SelectedItem(); + LoadIVTDataL( iIVTFileArray[index] ); + } + break; + + case EHapticsTestPlayEffect: + case EHapticsTestPlayEffectNoneFound: + { + // nothing to do + } + break; + case EHapticsTestPlayEffectSelected: + { + // play selected effect + TInt index = CountFileHandleAndEffectIndex( iMenuPane->SelectedItem() ); + PlayEffect( index ); + PrintEffectInfo( index ); + } + break; + case EHapticsTestPlayEffectRepeat: + case EHapticsTestPlayEffectRepeatNoneFound: + { + // nothing to do + } + break; + case EHapticsTestPlayEffectRepeatSelected: + { + // play selected effect repeatedly + TInt index = CountFileHandleAndEffectIndex( iMenuPane->SelectedItem() ); + RepeatEffect( index, GetNumberOfRepeats() ); + PrintEffectInfo( index ); + } + break; + + case EHapticsTestPlayEffectManual: + { + // nothing to do + } + break; + case EHapticsTestPlayEffectManualMagSweep: + { + PlayMagSweepL(); + } + break; + case EHapticsTestPlayEffectManualMagSweepInf: + { + PlayMagSweepL( ETrue ); + } + break; + case EHapticsTestPlayEffectManualMagSweepInfMod: + { + PlayMagSweepL( ETrue, ETrue ); + } + break; + case EHapticsTestPlayEffectManualPeriodic: + { + PlayPeriodicL(); + } + break; + case EHapticsTestPlayEffectManualPeriodicInf: + { + PlayPeriodicL( ETrue ); + } + break; + case EHapticsTestPlayEffectManualPeriodicInfMod: + { + PlayPeriodicL( ETrue, ETrue ); + } + break; + case EHapticsTestPlayEffectManualRepeat: + { + PlayRepeatL( GetNumberOfRepeats() ); + } + break; + + case EHapticsTestChangeState: + case EHapticsTestChangeStateNoneFound: + { + // nothing to do + } + break; + + case EHapticsTestChangeStatePause: + { + // get itemindex and pause effect + TInt itemIndex = iMenuPane->SelectedItem(); + PauseEffect( itemIndex ); + } + break; + + case EHapticsTestChangeStateResume: + { + // get itemindex and resume effect + TInt itemIndex = iMenuPane->SelectedItem(); + ResumeEffect( itemIndex ); + } + break; + + case EHapticsTestChangeStateStop: + { + // get itemindex and stop effect + TInt itemIndex = iMenuPane->SelectedItem(); + StopEffect( itemIndex ); + } + break; + + case EHapticsTestChangeStateStopAll: + { + TInt err = iHaptics->StopAllPlayingEffects(); + if ( err ) + { + TBuf<8> errBuf; + errBuf.AppendNum( err ); + iAppView->InsertOutput( _L("Stopping all effects failed, err = "), EFalse ); + iAppView->InsertOutput( errBuf ); + } + else + { + iAppView->InsertOutput( _L("Stopping all effects succeeded.") ); + + // reset the auto-modification + iEffectData->ResetModifiableEffectTimer(); + } + } + break; + + case EHapticsTestModifyEffect: + { + // nothing to do + } + break; + case EHapticsTestModifyEffectDuration1: + { + iEffectData->SetDuration( KEffectDuration1 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectDuration5: + { + iEffectData->SetDuration( KEffectDuration5 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectDuration10: + { + iEffectData->SetDuration( KEffectDuration10 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectDuration30: + { + iEffectData->SetDuration( KEffectDuration30 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectDuration60: + { + iEffectData->SetDuration( KEffectDuration60 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectMagnitudeMin: + { + iEffectData->SetMagnitude( KHWRMHapticsMinMagnitude ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectMagnitude25: + { + iEffectData->SetMagnitude( KEffectMagnitude25 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectMagnitude50: + { + iEffectData->SetMagnitude( KEffectMagnitude50 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectMagnitude75: + { + iEffectData->SetMagnitude( KEffectMagnitude75 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectMagnitudeMax: + { + iEffectData->SetMagnitude( KHWRMHapticsMaxMagnitude ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectStyleSmooth: + { + iEffectData->SetStyle( CHWRMHaptics::EHWRMHapticsStyleSmooth ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectStyleStrong: + { + iEffectData->SetStyle( CHWRMHaptics::EHWRMHapticsStyleStrong ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectStyleSharp: + { + iEffectData->SetStyle( CHWRMHaptics::EHWRMHapticsStyleSharp ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackMin: + { + iEffectData->SetAttackLevel( KHWRMHapticsMinMagnitude ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttack25: + { + iEffectData->SetAttackLevel( KEffectMagnitude25 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttack50: + { + iEffectData->SetAttackLevel( KEffectMagnitude50 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttack75: + { + iEffectData->SetAttackLevel( KEffectMagnitude75 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackMax: + { + iEffectData->SetAttackLevel( KHWRMHapticsMaxMagnitude ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeMin: + { + iEffectData->SetFadeLevel( KHWRMHapticsMinMagnitude ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFade25: + { + iEffectData->SetFadeLevel( KEffectMagnitude25 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFade50: + { + iEffectData->SetFadeLevel( KEffectMagnitude50 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFade75: + { + iEffectData->SetFadeLevel( KEffectMagnitude75 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeMax: + { + iEffectData->SetFadeLevel( KHWRMHapticsMaxMagnitude ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackTime02: + { + iEffectData->SetAttackTime( KEffectAttackTime02 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackTime1: + { + iEffectData->SetAttackTime( KEffectAttackTime1 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackTime5: + { + iEffectData->SetAttackTime( KEffectAttackTime5 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackTime10: + { + iEffectData->SetAttackTime( KEffectAttackTime10 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackTime30: + { + iEffectData->SetAttackTime( KEffectAttackTime30 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectAttackTime60: + { + iEffectData->SetAttackTime( KEffectAttackTime60 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeTime02: + { + iEffectData->SetFadeTime( KEffectFadeTime02 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeTime1: + { + iEffectData->SetFadeTime( KEffectFadeTime1 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeTime5: + { + iEffectData->SetFadeTime( KEffectFadeTime5 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeTime10: + { + iEffectData->SetFadeTime( KEffectFadeTime10 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeTime30: + { + iEffectData->SetFadeTime( KEffectFadeTime30 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectFadeTime60: + { + iEffectData->SetFadeTime( KEffectFadeTime60 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectPeriod50: + { + iEffectData->SetPeriod( KEffectPeriod50 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectPeriod100: + { + iEffectData->SetPeriod( KEffectPeriod100 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectPeriod300: + { + iEffectData->SetPeriod( KEffectPeriod300 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectPeriod600: + { + iEffectData->SetPeriod( KEffectPeriod600 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectPeriod1000: + { + iEffectData->SetPeriod( KEffectPeriod1000 ); + ModifyEffect(); + } + break; + case EHapticsTestModifyEffectPeriod3000: + { + iEffectData->SetPeriod( KEffectPeriod3000 ); + ModifyEffect(); + } + break; + + case EHapticsTestCloseHaptics: + { + CloseHaptics(); + } + break; + + case EHapticsTestSynchronousCalls: + { + iSynchronous = ETrue; + iAppView->InsertOutput( _L("Using synchronous methods.") ); + } + break; + + case EHapticsTestAsynchronousCalls: + { + iSynchronous = EFalse; + iAppView->InsertOutput( _L("Using asynchronous methods.") ); + } + break; + + case EHapticsTestUsingFileHandle: + { + iUseHandle = ETrue; + iAppView->InsertOutput( _L("Using file handle in play methods.") ); + } + break; + + case EHapticsTestNotUsingFileHandle: + { + iUseHandle = EFalse; + iAppView->InsertOutput( _L("Using data buffer in play methods.") ); + } + break; + + case EHapticsTestShowEffectInfo: + { + iShowEffectInfo = ETrue; + iAppView->InsertOutput( _L("Shows information of played effect.") ); + } + break; + + case EHapticsTestHideEffectInfo: + { + iShowEffectInfo = EFalse; + iAppView->InsertOutput( _L("Stops showing information of played effect.") ); + } + break; + + case EHapticsTestDeleteIVTData: + case EHapticsTestDeleteIVTDataNoneFound: + { + // nothing to do + } + break; + + case EHapticsTestDeleteIVTDataSelected: + { + // delete selected loaded IVT file + TInt index = iMenuPane->SelectedItem(); + DeleteLoadedIVTData( index ); + } + break; + + case EHapticsTestDeleteAllIVTData: + { + // delete all loaded IVT files + DeleteAllLoadedIVTData(); + } + break; + + case EHapticsTestReserve: + { + // nothing to do + } + case EHapticsTestReserveNotTrusted: + { + ReserveHaptics( iHaptics, EFalse ); + } + break; + case EHapticsTestReserveTrusted: + { + ReserveHaptics( iHaptics, ETrue ); + } + break; + case EHapticsTestReserveNotTrustedTemp: + { + // create the temp haptics client, if it does not exist + if ( !iTempHaptics ) + { + iTempHaptics = CHWRMHaptics::NewL( NULL, NULL ); + } + + ReserveHaptics( iTempHaptics, EFalse ); + } + break; + case EHapticsTestRelease: + { + iHaptics->ReleaseHaptics(); + iAppView->InsertOutput( _L("Reservation released.") ); + } + break; + case EHapticsTestReleaseTemp: + { + if ( iTempHaptics ) + { + iTempHaptics->ReleaseHaptics(); + iAppView->InsertOutput( _L("Temp client's reservation released.") ); + + delete iTempHaptics; + iTempHaptics = NULL; + } + else + { + iAppView->InsertOutput( _L("Temp client not created/reserved.") ); + } + } + break; + + case EHapticsTestConstGetters: + { + ConstGetters(); + } + break; + + case EHapticsTestGetStatus: + { + // fetch haptics status, and print it + MHWRMHapticsObserver::THWRMHapticsStatus status = + iHaptics->HapticsStatus(); + + if ( iTempHaptics ) + { + iAppView->InsertOutput( _L("[Haptics client] - "), EFalse ); + PrintStatusInfo( status ); + + status = iTempHaptics->HapticsStatus(); + iAppView->InsertOutput( _L("[Temporary client] - "), EFalse ); + PrintStatusInfo( status ); + } + else + { + PrintStatusInfo( status ); + } + + } + break; + + case EHapticsTestSetPropertyPriorityMin: + { + SetPropertyPriorityMin(); + } + break; + + case EHapticsTestSetPropertyPriorityDefault: + { + SetPropertyPriorityDefault(); + } + break; + + case EHapticsTestSetPropertyPriorityMax: + { + SetPropertyPriorityMax(); + } + break; + + case EHapticsTestSetPropertyDisableEffectsTrue: + { + SetPropertyDisableEffectsTrue(); + } + break; + + case EHapticsTestSetPropertyDisableEffectsFalse: + { + SetPropertyDisableEffectsFalse(); + } + break; + + case EHapticsTestSetPropertyStrengthMute: + { + SetPropertyStrengthMin(); + } + break; + + case EHapticsTestSetPropertyStrengthHalf: + { + SetPropertyStrengthMiddle(); + } + break; + + case EHapticsTestSetPropertyStrengthFull: + { + SetPropertyStrengthMax(); + } + break; + + case EHapticsTestGetPropertyPriority: + { + GetPropertyPriority(); + } + break; + + case EHapticsTestGetPropertyDisableEffects: + { + GetPropertyDisableEffects(); + } + break; + + case EHapticsTestGetPropertyStrength: + { + GetPropertyStrength(); + } + break; + + + case EHapticsTestGetCapabilityDeviceCategory: + { + GetCapabilityDeviceCategory(); + } + break; + + case EHapticsTestGetCapabilityMaxNestedRepeats: + { + GetCapabilityMaxNestedRepeats(); + } + break; + + + case EHapticsTestGetCapabilityNumActuators: + { + GetCapabilityNumActuators(); + } + break; + + + case EHapticsTestGetCapabilityActuatorType: + { + GetCapabilityActuatorType(); + } + break; + + + case EHapticsTestGetCapabilityNumEffectSlots: + { + GetCapabilityNumEffectSlots(); + } + break; + + case EHapticsTestGetCapabilityNumEffectStyles: + { + GetCapabilityNumEffectStyles(); + } + break; + + case EHapticsTestGetCapabilityMinPeriod: + { + GetCapabilityMinPeriod(); + } + break; + + case EHapticsTestGetCapabilityMaxPeriod: + { + GetCapabilityMaxPeriod(); + } + break; + + case EHapticsTestGetCapabilityMaxEffectDuration: + { + GetCapabilityMaxEffectDuration(); + } + break; + + case EHapticsTestGetCapabilitySupportedEffects: + { + GetCapabilitySupportedEffects(); + } + break; + + case EHapticsTestGetCapabilityDeviceName: + { + GetCapabilityDeviceName(); + } + break; + + case EHapticsTestGetCapabilityMaxEnvelopeTime: + { + GetCapabilityMaxEnvelopeTime(); + } + break; + + case EHapticsTestGetCapabilityAPIVersionNumber: + { + GetCapabilityAPIVersionNumber(); + } + break; + + case EHapticsTestGetCapabilityMaxIVTSize: + { + GetCapabilityMaxIVTSize(); + } + break; + + case EHapticsTestClearOutput: + { + iAppView->ClearOutput(); + } + break; + + case EHapticsTestStreaming: + { + StartStreaming(); + } + break; + + case EHapticsTestPlayStreamSample: + case EHapticsTestNextStreamSample: + { + PlayStreamingSample( iCurrentSample ); + iCurrentSample >= KSampleCount ? iCurrentSample = 0 : iCurrentSample++; + } + break; + + case EHapticsTestPlayAllSamples: + { + for ( TInt n = 0; n < 8; n++ ) + { + PlayStreamingSample( n ); + User::After( 300000 ); + } + } + break; + + case EHapticsTestStopStreaming: + { + StopStreaming(); + } + break; + + case EHapticsTestPanic: + default: + Panic( EHapticsTestBasicUi ); + break; + } + } + +// --------------------------------------------------------- +// Manages the options menu contents based on user actions and data. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::DynInitMenuPaneL( TInt aResourceId, + CEikMenuPane* aMenuPane ) + { + CAknAppUi::DynInitMenuPaneL( aResourceId, aMenuPane ); + + // store menupane to be used in HandleCommandL() + iMenuPane = aMenuPane; + + if ( aResourceId == R_HAPTICSTEST_MENU ) + { + if ( !iHaptics ) + { + // haptics client not created, hide commands using it + aMenuPane->SetItemDimmed( EHapticsTestReserve, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestConstGetters, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestGetStatus, ETrue ); + } + if ( !iActuatorOpened ) + { + // Actuator has not been opened yet, hide ivt-file loading + // submenu and general play-submenu + aMenuPane->SetItemDimmed( EHapticsTestGeneralPlayEffect, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestLoadIVTFile, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestPropertiesSubmenu, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestCapabilitiesSubmenu, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestStreaming, ETrue ); + } + if ( 0 == iLoadedIVTFileArray.Count() ) + { + // also hide the deleteIVT data related menu items + aMenuPane->SetItemDimmed( EHapticsTestDeleteIVTData, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestDeleteAllIVTData, ETrue ); + } + if ( !iEffectData->Count() ) + { + // hide the pause/resume/stop submenu + aMenuPane->SetItemDimmed( EHapticsTestChangeState, ETrue ); + } + if ( !iEffectData->ModifiableEffectExists() ) + { + aMenuPane->SetItemDimmed( EHapticsTestModifyEffect, ETrue ); + } + if ( iStreaming ) + { + aMenuPane->SetItemDimmed( EHapticsTestStreaming, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestReserve, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestLoadIVTFile, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestGeneralPlayEffect, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestChangeState, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestModifyEffect, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestDeleteIVTData, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestPropertiesSubmenu, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestCapabilitiesSubmenu, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestDeleteAllIVTData, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestGetStatus, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestConstGetters, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestClearOutput, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestPanic, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestInit, ETrue ); + aMenuPane->SetItemDimmed( EHapticsToggle, ETrue ); + aMenuPane->SetItemDimmed( EAknSoftkeyExit, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestPlayStreamSample, iCurrentSample ); + aMenuPane->SetItemDimmed( EHapticsTestNextStreamSample, !iCurrentSample ); + } + else + { + aMenuPane->SetItemDimmed( EHapticsTestPlayAllSamples, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestPlayStreamSample, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestNextStreamSample, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestStopStreaming, ETrue ); + } + } + else if ( aResourceId == R_HAPTICSTEST_INIT_SUBMENU ) + { + if ( !iHaptics ) + { + // haptics client not created, hide commands using it + aMenuPane->SetItemDimmed( EHapticsTestSupportedActuators, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestOpenActuator, ETrue ); + } + if ( !iSupportedActuators ) + { + // either there are no supported actuators, or they have not + // been fethed yet --> hide actuator opening submenu + aMenuPane->SetItemDimmed( EHapticsTestOpenActuator, ETrue ); + } + } + else if ( aResourceId == R_HAPTICSTEST_GENERALPLAY_SUBMENU ) + { + if ( !iActuatorOpened ) + { + // Actuator has not been opened yet, hide the manual effect + // play submenu + aMenuPane->SetItemDimmed( EHapticsTestPlayEffectManual, ETrue ); + } + if ( 0 == iLoadedIVTFileArray.Count() ) + { + // IVT-data has not been loaded, hide the effect submenu + aMenuPane->SetItemDimmed( EHapticsTestPlayEffect, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestPlayEffectRepeat, ETrue ); + } + } + else if ( aResourceId == R_HAPTICSTEST_TOGGLE_SUBMENU ) + { + if ( iSynchronous ) + { + // synchronous calls in ON, hide synchronous call selection + aMenuPane->SetItemDimmed( EHapticsTestSynchronousCalls, ETrue ); + } + else + { + // asynchronous calls in ON, hide asynchronous call selection + aMenuPane->SetItemDimmed( EHapticsTestAsynchronousCalls, ETrue ); + } + if ( iUseHandle ) + { + aMenuPane->SetItemDimmed( EHapticsTestUsingFileHandle, ETrue ); + if ( iShowEffectInfo ) + { + aMenuPane->SetItemDimmed( EHapticsTestShowEffectInfo, ETrue ); + } + else + { + aMenuPane->SetItemDimmed( EHapticsTestHideEffectInfo, ETrue ); + } + } + else + { + aMenuPane->SetItemDimmed( EHapticsTestNotUsingFileHandle, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestShowEffectInfo, ETrue ); + aMenuPane->SetItemDimmed( EHapticsTestHideEffectInfo, ETrue ); + } + } + else if ( aResourceId == R_HAPTICSTEST_ACTUATORS_SUBMENU ) + { + if ( !(EHWRMLogicalActuatorAny & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorAny, ETrue ); + } + if ( !(EHWRMLogicalActuatorDevice & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorDevice, ETrue ); + } + if ( !(EHWRMLogicalActuatorPrimaryDisplay & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorPrimaryDisplay, ETrue ); + } + if ( !(EHWRMLogicalActuatorSecondaryDisplay & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorSecondaryDisplay, ETrue ); + } + if ( !(EHWRMLogicalActuatorGame & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorGame, ETrue ); + } + if ( !(EHWRMLogicalActuatorGameLeft & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorGameLeft, ETrue ); + } + if ( !(EHWRMLogicalActuatorGameRight & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorGameRight, ETrue ); + } + if ( !(EHWRMLogicalActuatorExternalVibra & iSupportedActuators) ) + { + aMenuPane->SetItemDimmed( EHapticsTestOpenActuatorExternalVibra, ETrue ); + } + } + else if ( aResourceId == R_HAPTICSTEST_IVTFILES_SUBMENU ) + { + if ( iIVTFileArray.Count() ) + { + // ivt-files present, hide the "no files" -item + aMenuPane->SetItemDimmed( EHapticsTestLoadIVTFileNoneFound, ETrue ); + + // make file names visible in the submenu + CEikMenuPaneItem::SData data; + for ( TInt i = 0; i < iIVTFileArray.Count(); ++i ) + { + data.iText.Copy( iIVTFileArray[i] ); + data.iCommandId = EHapticsTestLoadIVTFileSelected; + data.iCascadeId = 0; + data.iFlags = 0; + data.iExtraText = KNullDesC; + + aMenuPane->AddMenuItemL( data ); + } + } + } + else if ( aResourceId == R_HAPTICSTEST_PLAYEFFECT_SUBMENU ) + { + CreatePlayEffectSubmenuL( aMenuPane, + EHapticsTestPlayEffectSelected, + EHapticsTestPlayEffectNoneFound ); + } + else if ( aResourceId == R_HAPTICSTEST_PLAYEFFECTREPEAT_SUBMENU ) + { + CreatePlayEffectSubmenuL( aMenuPane, + EHapticsTestPlayEffectRepeatSelected, + EHapticsTestPlayEffectRepeatNoneFound ); + } + else if ( aResourceId == R_HAPTICSTEST_DELETEIVTDATA_SUBMENU ) + { + if ( iLoadedIVTFileArray.Count() ) + { + // loaded ivt-files present, hide the "no files" -item + aMenuPane->SetItemDimmed( EHapticsTestDeleteIVTDataNoneFound, ETrue ); + + // make loaded ivt-files visible in the submenu + CEikMenuPaneItem::SData data; + for ( TInt i = 0; i < iLoadedIVTFileArray.Count(); ++i ) + { + data.iText.Copy( iLoadedIVTFileArray[i].iFileName ); + data.iCommandId = EHapticsTestDeleteIVTDataSelected; + data.iCascadeId = 0; + data.iFlags = 0; + data.iExtraText = KNullDesC; + + aMenuPane->AddMenuItemL( data ); + } + } + } + else if ( aResourceId == R_HAPTICSTEST_PAUSE_SUBMENU ) + { + // fill effect history data to pause submenu + iEffectData->DynInitChangeEffectStateSubmenuL( + aMenuPane, EHapticsTestChangeStatePause, iHaptics ); + } + else if ( aResourceId == R_HAPTICSTEST_RESUME_SUBMENU ) + { + // fill effect history data to resume submenu + iEffectData->DynInitChangeEffectStateSubmenuL( + aMenuPane, EHapticsTestChangeStateResume, iHaptics ); + } + else if ( aResourceId == R_HAPTICSTEST_STOP_SUBMENU ) + { + // fill effect history data to stop submenu + iEffectData->DynInitChangeEffectStateSubmenuL( + aMenuPane, EHapticsTestChangeStateStop, iHaptics ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYDURATION_SUBMENU ) + { + iEffectData->DynInitDurationSubmenu( aMenuPane ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYMAGNITUDE_SUBMENU ) + { + iEffectData->DynInitMagnitudeSubmenu( aMenuPane ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYSTYLE_SUBMENU ) + { + iEffectData->DynInitStyleSubmenu( aMenuPane ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYATTACK_SUBMENU ) + { + iEffectData->DynInitAttackLevelSubmenu( aMenuPane ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYFADE_SUBMENU ) + { + iEffectData->DynInitFadeLevelSubmenu( aMenuPane ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYATTACKTIME_SUBMENU ) + { + iEffectData->DynInitAttackTimeSubmenu( aMenuPane ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYFADETIME_SUBMENU ) + { + iEffectData->DynInitFadeTimeSubmenu( aMenuPane ); + } + else if ( aResourceId == R_HAPTICSTEST_MODIFYPERIOD_SUBMENU ) + { + iEffectData->DynInitPeriodSubmenu( aMenuPane ); + } + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CHapticsTestAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination) + { + CAknAppUi::HandleWsEventL(aEvent, aDestination); + + TInt eventType = aEvent.Type(); + if (eventType == EEventKeyUp) + { + TKeyEvent key = *(aEvent.Key()); + GetAliasKeyCodeL(key.iCode, key, EEventKey); + TUint code = key.iScanCode; + + if (code == '5' && !iActuatorOpened ) + { + HandleCommandL(EHapticsTestOpenHaptics); // open client + HandleCommandL(EHapticsTestSupportedActuators); // ask supported actuators + HandleCommandL(EHapticsTestOpenActuatorAny); // open any actuator + + HandleCommandL(EHapticsTestGetCapabilityDeviceName); + } + } + } + +// --------------------------------------------------------- +// Prints received haptics status notifications onto +// the screen. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::HapticsStatusChangedL( THWRMHapticsStatus aStatus ) + { + PrintStatusInfo( aStatus ); + } + +// --------------------------------------------------------- +// Empty implementation. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::EffectCompletedL( TInt /*aError*/, + TInt /*aEffectHandle*/ ) + { + } + +// --------------------------------------------------------- +// Outputs received actuator events onto the screen. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::ActuatorEventL( THWRMActuatorEvents aEvent, + THWRMLogicalActuators aActuator ) + { + // actuator name + TBuf<64> actuator; + switch( aActuator ) + { + case EHWRMLogicalActuatorAny: + actuator.Append( _L("Any") ); + break; + case EHWRMLogicalActuatorDevice: + actuator.Append( _L("Device") ); + break; + case EHWRMLogicalActuatorPrimaryDisplay: + actuator.Append( _L("PrimaryDisplay") ); + break; + case EHWRMLogicalActuatorSecondaryDisplay: + actuator.Append( _L("SecondaryDisplay") ); + break; + case EHWRMLogicalActuatorGame: + actuator.Append( _L("Game") ); + break; + case EHWRMLogicalActuatorGameLeft: + actuator.Append( _L("GameLeft") ); + break; + case EHWRMLogicalActuatorGameRight: + actuator.Append( _L("GameRight") ); + break; + case EHWRMLogicalActuatorExternalVibra: + actuator.Append( _L("ExternalVibra") ); + break; + default: + actuator.Append( _L("") ); + break; + } + + iAppView->InsertOutput( _L("Received actuator event: "), EFalse ); + iAppView->InsertOutput( actuator, EFalse ); + + switch( aEvent ) + { + case MHWRMHapticsActuatorObserver::EHWRMActuatorAttached: + { + iAppView->InsertOutput( _L(" Attached.") ); + break; + } + case MHWRMHapticsActuatorObserver::EHWRMActuatorDetached: + { + iAppView->InsertOutput( _L(" Deattached.") ); + break; + } + case MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled: + { + iAppView->InsertOutput( _L(" Enabled.") ); + break; + } + case MHWRMHapticsActuatorObserver::EHWRMActuatorDisabled: + { + iAppView->InsertOutput( _L(" Disabled.") ); + break; + } + default: + { + iAppView->InsertOutput( _L(" ") ); + break; + } + } + } + +// --------------------------------------------------------- +// Creates haptics client instance. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::OpenHapticsL() + { + if ( iHaptics ) + { + iAppView->InsertOutput( _L("Already created.") ); + } + else + { + // Create haptics client + if ( iSynchronous ) + { + iHaptics = CHWRMHaptics::NewL( this, this ); + } + else + { + // asynchronous creation + TRequestStatus status; + iHaptics = CHWRMHaptics::NewL( this, this, status ); + User::WaitForRequest( status ); + User::LeaveIfError( status.Int() ); + } + + if ( iHaptics ) + { + iAppView->InsertOutput( _L("Haptics client created.") ); + } + else + { + iAppView->InsertOutput( _L("Error: Creation failed.") ); + } + } + } + +// --------------------------------------------------------- +// Deletes haptics client instance, and resets member variables +// so that options-menu is updated accordingly. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::CloseHaptics() + { + if( iHaptics ) + { + delete iHaptics; + iHaptics = NULL; + iAppView->InsertOutput( _L("Haptics client deleted.") ); + + // uninit members + iSupportedActuators = 0; + iActuatorOpened = EFalse; + iIVTFileHandle = 0; + + while ( iLoadedIVTFileArray.Count() ) + { + if ( iLoadedIVTFileArray[0].iDataBuffer ) + { + delete iLoadedIVTFileArray[0].iDataBuffer; + iLoadedIVTFileArray[0].iDataBuffer = NULL; + } + iLoadedIVTFileArray.Remove( 0 ); + } + + iIVTDataBuffer = NULL; + } + else + { + iAppView->InsertOutput( _L("Error: Haptics client doesn\'t exist.") ); + } + } + +// --------------------------------------------------------- +// Fetches the supported actuators from haptics server, +// and stores the mask to iSupportedActuators. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::FetchSupportedActuators() + { + TInt err = iHaptics->SupportedActuators( iSupportedActuators ); + + if ( err ) + { + iAppView->InsertOutput( _L("Error: Getting supported actuators failed.") ); + } + else + { + PrintSupportedActuators(); + } + } + +// --------------------------------------------------------- +// Prints the given supported actuators to the UI. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PrintSupportedActuators() + { + iAppView->InsertOutput( _L("Supported actuators:") ); + + if( EHWRMLogicalActuatorAny & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorAny") ); + } + if( EHWRMLogicalActuatorDevice & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorDevice") ); + } + if( EHWRMLogicalActuatorPrimaryDisplay & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorPrimaryDisplay") ); + } + if( EHWRMLogicalActuatorSecondaryDisplay & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorSecondaryDisplay") ); + } + if( EHWRMLogicalActuatorGame & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorGame") ); + } + if( EHWRMLogicalActuatorGameLeft & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorGameLeft") ); + } + if( EHWRMLogicalActuatorGameRight & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorGameRight") ); + } + if( EHWRMLogicalActuatorExternalVibra & iSupportedActuators ) + { + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorExternalVibra") ); + } + if( EHWRMLogicalActuatorLast & iSupportedActuators ) + { + // ????? + iAppView->InsertOutput( _L(" EHWRMLogicalActuatorLast") ); + } + } + +// --------------------------------------------------------- +// Attemps to open the given actuator. Prints the result +// of the attemp to the UI. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::OpenActuator( THWRMLogicalActuators aActuator ) + { + TRAPD( err, iHaptics->OpenActuatorL( aActuator ) ); + TBuf<100> buf; + if ( err ) + { + buf.Append( _L("Error: Opening actuator failed; ") ); + buf.AppendNum( err ); + iAppView->InsertOutput( buf ); + + iActuatorOpened = EFalse; + } + else + { + iAppView->InsertOutput( _L("Actuator opened successfully.") ); + + iActuatorOpened = ETrue; + + TInt err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsLicensekey, + KNullDesC8() ); + if (err) + { + buf.Append( _L("Error: Setting licensefailed: ") ); + buf.AppendNum( err ); + iAppView->InsertOutput( buf ); + + iActuatorOpened = EFalse; + return; + } + iAppView->InsertOutput( _L("License is set.") ); + + err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + + } + } + +// --------------------------------------------------------- +// Reserves haptics for this application. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::ReserveHaptics( CHWRMHaptics* aHaptics, + TBool aForceNoCoe ) + { + TInt err = KErrNone; + TBuf<24> forceNoCoe; + + if ( aForceNoCoe ) + { + forceNoCoe.Append( _L("(trusted).") ); + TRAP( err, aHaptics->ReserveHapticsL( ETrue ) ); + } + else + { + forceNoCoe.Append( _L("(not trusted).") ); + TRAP( err, aHaptics->ReserveHapticsL() ); + } + + if ( err ) + { + TBuf<8> errorCode; + errorCode.AppendNum( err ); + + iAppView->InsertOutput( _L("Reserving haptics failed err = "), EFalse ); + iAppView->InsertOutput( errorCode ); + } + else + { + iAppView->InsertOutput( _L("Reserved haptics "), EFalse ); + iAppView->InsertOutput( forceNoCoe ); + } + } + +// --------------------------------------------------------- +// Searches for IVT-files in the filesystem, and writes +// them to iIVTFileArray. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::FindIVTFiles() + { + iAppView->InsertOutput( _L("Searching IVT-files...") ); + + // open file server session + RFs rfs; + TInt err = rfs.Connect(); + + if ( err ) + { + iAppView->InsertOutput( _L("Error occured while opening fileserver session!") ); + return; + } + + // set path where to search files + CDir* dirList = 0; + TInt memCrdUsageErr = KErrNone; + +#ifdef __MARM_ARMV5__ + // first, try to use mem card.. (in ARMV5 builds) + memCrdUsageErr = rfs.SetSessionPath( KSessionPathCrd ); + + if ( !memCrdUsageErr ) + { + memCrdUsageErr = rfs.GetDir( KIVTFileType, KEntryAttMaskSupported, + ESortByName, dirList ); + } + if ( !memCrdUsageErr && dirList ) + { + iUsesMemCard = ETrue; + } +#endif + + if ( !iUsesMemCard ) + { + // secondly, try to use phone mem.. (actually first in non-ARMV5 builds) + err = rfs.SetSessionPath( KSessionPathMem ); + + if ( err ) + { + iAppView->InsertOutput( _L("Setting path for fileserver failed!") ); + return; + } + + // get directory file listing of IVT-files + err = rfs.GetDir( KIVTFileType, KEntryAttMaskSupported, + ESortByName, dirList ); + + if ( err || !dirList ) + { + iAppView->InsertOutput( _L("Fetching folder content failed!") ); + return; + } + } + + // file server session not needed anymore, close it + rfs.Close(); + + // go through all found ivt-files and read directory + // entries to filenamearray + for( TInt i = 0; i < dirList->Count(); i++ ) + { + iIVTFileArray.Append( (*dirList)[i].iName ); + + // print findings to the UI + iAppView->InsertOutput( _L(" "), EFalse ); + iAppView->InsertOutput( (*dirList)[i].iName ); + } + + delete dirList; + dirList = NULL; + } + +// --------------------------------------------------------- +// Loads IVT data from the given file to haptics. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::LoadIVTDataL( TFileName& aFile ) + { + // open file server session + RFs rfs; + if ( rfs.Connect() ) + { + iAppView->InsertOutput( _L("Error occured while opening fileserver session!") ); + return; + } + + // set path where to search files +#ifdef __MARM_ARMV5__ + if ( iUsesMemCard ) + { + rfs.SetSessionPath( KSessionPathCrd ); + } + else + { +#endif + + rfs.SetSessionPath( KSessionPathMem ); + +#ifdef __MARM_ARMV5__ + } +#endif + + RFile effectFile; + TInt fileSize( 0 ); + + User::LeaveIfError( effectFile.Open( rfs, aFile, EFileRead ) ); + + effectFile.Size( fileSize ); + + // create buffer for the IVT-data + HBufC8* IVTDataBuffer = HBufC8::NewLC( fileSize ); + TPtr8 dataBufPtr = IVTDataBuffer->Des(); + + // read the data from file to buffer + effectFile.Read( dataBufPtr ); + + // close file handle and file server session + effectFile.Close(); + rfs.Close(); + + // load data to haptics + TInt IVTFileHandle = 0; + TInt err = iHaptics->LoadEffectData( *IVTDataBuffer, IVTFileHandle ); + + if ( err ) + { + CleanupStack::PopAndDestroy( IVTDataBuffer ); + + if ( err == KErrAlreadyExists ) + { + iAppView->InsertOutput( _L("IVT-data already loaded!") ); + } + else + { + iAppView->InsertOutput( _L("Error loading IVT-data!") ); + } + } + else + { + TInt count; + iHaptics->GetEffectCount( IVTFileHandle, count ); + + TLoadedIVTFileItem newItem; + newItem.iFileName.Copy( aFile ); + newItem.iFileHandle = IVTFileHandle; + newItem.iDataBuffer = IVTDataBuffer; + if ( KErrNotFound == iLoadedIVTFileArray.Find( newItem, TIdentityRelation( TLoadedIVTFileItem::Match ) ) ) + { + iLoadedIVTFileArray.AppendL( newItem ); + CleanupStack::Pop( IVTDataBuffer ); // ownership now in the array + TBuf<24> handleBuf; + handleBuf.AppendNum( IVTFileHandle ); + iAppView->InsertOutput( _L("IVT-data loaded succesfully!") ); + iAppView->InsertOutput( _L(" File: "), EFalse ); + iAppView->InsertOutput( aFile ); + iAppView->InsertOutput( _L(" FileHandle: "), EFalse ); + iAppView->InsertOutput( handleBuf, EFalse ); + } + else + { + CleanupStack::PopAndDestroy( IVTDataBuffer ); + iAppView->InsertOutput( _L("IVT-data already loaded!") ); + iAppView->InsertOutput( _L(" File: "), EFalse ); + iAppView->InsertOutput( aFile ); + } + iAppView->InsertOutput( _L(" Effect count: "), EFalse ); + TBuf<5> countBuf; + countBuf.AppendNum( count ); + iAppView->InsertOutput( countBuf ); + } + } + +// --------------------------------------------------------- +// Plays the effect of the given index in the currently +// loaded IVT-file. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PlayEffect( TInt aIndex ) + { + TInt err = KErrNone; + iEffectHandle = KErrNotFound; + TBool usingAsyncSender( EFalse ); + + if ( iSynchronous ) + { + iAppView->InsertOutput( _L("Playing effect synchronously...") ); + if ( iUseHandle ) + { + err = iHaptics->PlayEffect( iIVTFileHandle, + aIndex, iEffectHandle ); + } + else + { + err = iHaptics->PlayEffect( *iIVTDataBuffer, + aIndex, iEffectHandle ); + } + } + else + { + iAppView->InsertOutput( _L("Playing effect asynchronously...") ); + + if ( iUseHandle ) + { + usingAsyncSender = ETrue; + iAsyncPlaySender->Play( iHaptics, iIVTFileHandle, + aIndex, iEffectHandle ); + } + else + { + TRequestStatus status; + iHaptics->PlayEffect( *iIVTDataBuffer, + aIndex, iEffectHandle, status ); + User::WaitForRequest( status ); + err = status.Int(); + } + } + + if ( !usingAsyncSender ) + { + // print error/success + PrintPlayEffectStatus( err ); + GetCurrentEffectState(); + + // if effect played successfully, add history data + if ( !err ) + { + iEffectData->AddEffectInfo( iEffectHandle, iIVTFileHandle, aIndex ); + } + } + } + +// --------------------------------------------------------- +// Plays the effect of the given index in the currently +// loaded IVT-file repeatedly +// --------------------------------------------------------- +// +void CHapticsTestAppUi::RepeatEffect( TInt aIndex, TInt aRepeats ) + { + TInt err = KErrNone; + iEffectHandle = KErrNotFound; + TBool usingAsyncSender( EFalse ); + + if ( iSynchronous ) + { + _LIT( KInsertedText, "Playing Repeat %d times synchronously..." ); + TBuf<50> buf; + buf.Format( KInsertedText, aRepeats ); + iAppView->InsertOutput( buf ); + + if ( iUseHandle ) + { + err = iHaptics->PlayEffectRepeat( iIVTFileHandle, + aIndex, aRepeats, iEffectHandle ); + } + else + { + err = iHaptics->PlayEffectRepeat( *iIVTDataBuffer, + aIndex, aRepeats, iEffectHandle ); + } + } + else + { + _LIT( KInsertedText, "Playing Repeat %d times asynchronously..." ); + TBuf<50> buf; + buf.Format( KInsertedText, aRepeats ); + iAppView->InsertOutput( buf ); + + if ( iUseHandle ) + { + usingAsyncSender = ETrue; + iAsyncPlaySender->PlayRepeat( iHaptics, + iIVTFileHandle, + aIndex, + aRepeats, + iEffectHandle ); + } + else + { + TRequestStatus status; + iHaptics->PlayEffectRepeat( *iIVTDataBuffer, + aIndex, aRepeats, iEffectHandle, status ); + User::WaitForRequest( status ); + err = status.Int(); + } + } + + if ( !usingAsyncSender ) + { + // print error/success + PrintPlayEffectStatus( err ); + GetCurrentEffectState(); + + // if effect played successfully, add history data + if ( !err ) + { + iEffectData->AddEffectInfo( iEffectHandle, iIVTFileHandle, aIndex ); + } + } + } + +// --------------------------------------------------------- +// Plays a magsweep effect using manual definition. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PlayMagSweepL( TBool aInfinite, TBool aModifiable ) + { + // construct default magsweep data + CHWRMHaptics::THWRMHapticsMagSweepEffect magsweep; + iEffectData->FillDefaultMagSweepData( magsweep, aInfinite, + aModifiable, iHaptics ); + + TInt err = KErrNone; + iEffectHandle = KErrNotFound; + + if ( iSynchronous ) + { + iAppView->InsertOutput( _L("Playing MagSweep synchronously...") ); + + // synchronous call + err = iHaptics->PlayMagSweepEffect( magsweep, iEffectHandle ); + } + else + { + iAppView->InsertOutput( _L("Playing MagSweep asynchronously...") ); + + // asynchronous call + TRequestStatus status; + iHaptics->PlayMagSweepEffect( magsweep, iEffectHandle, + status ); + User::WaitForRequest( status ); + err = status.Int(); + } + + // print error/success + PrintPlayEffectStatus( err ); + GetCurrentEffectState(); + + // if effect played successfully, add history data + if ( !err ) + { + iEffectData->AddEffectInfo( iEffectHandle ); + iEffectData->ResetModifiableMagSweepEffectL( magsweep, iEffectHandle, + iHaptics ); + + // if this effect should be auto-modifiable, reset modification timer + if ( aModifiable ) + { + iEffectData->StartModifiableEffectTimerL( ModifyPlayingEffect ); + } + } + } + +// --------------------------------------------------------- +// Plays a periodic effect using manual definition. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PlayPeriodicL( TBool aInfinite, TBool aModifiable ) + { + // construct default periodic data + CHWRMHaptics::THWRMHapticsPeriodicEffect periodic; + iEffectData->FillDefaultPeriodicData( periodic, aInfinite, + aModifiable, iHaptics ); + + TInt err = KErrNone; + iEffectHandle = KErrNotFound; + + if ( iSynchronous ) + { + iAppView->InsertOutput( _L("Playing Periodic synchronously...") ); + + // synchronous call + err = iHaptics->PlayPeriodicEffect( periodic, iEffectHandle ); + } + else + { + iAppView->InsertOutput( _L("Playing Periodic asynchronously...") ); + + // asynchronous call + TRequestStatus status; + iHaptics->PlayPeriodicEffect( periodic, iEffectHandle, + status ); + User::WaitForRequest( status ); + err = status.Int(); + } + + // print error/success + PrintPlayEffectStatus( err ); + GetCurrentEffectState(); + + // if effect played successfully, add history data + if ( !err ) + { + iEffectData->AddEffectInfo( iEffectHandle ); + iEffectData->ResetModifiablePeriodicEffectL( periodic, iEffectHandle, + iHaptics ); + + // if this effect should be auto-modifiable, reset modification timer + if ( aModifiable ) + { + iEffectData->StartModifiableEffectTimerL( ModifyPlayingEffect ); + } + } + } + +// --------------------------------------------------------- +// Plays repeatedly a timeline effect using manual definition. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PlayRepeatL( TInt aRepeats ) + { + TInt err = KErrNone; + iEffectHandle = KErrNotFound; + + // This is a simple effect (just plays magsweep type thingie for a second) + // produced from VibeStudio (export to C-file functionality there..) + static const TUint8 simpleTimelineEffect[] = + { + 0x01, 0x00, 0x02, 0x00, 0x1c, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x07, 0x00, 0xf1, 0xe0, 0x01, 0xe2, 0x00, 0x00, 0xff, 0x30, + 0xc8, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, + 0x00, 0x5f, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x12, 0x00, + 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6c, 0x00, + 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x00, 0x00, 0x4d, 0x00, + 0x61, 0x00, 0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, + 0x65, 0x00, 0x70, 0x00, 0x00, 0x00 + }; + + RBuf8 effectBuffer; + CleanupClosePushL( effectBuffer ); + effectBuffer.ReAlloc( sizeof( simpleTimelineEffect ) ); + TUint8* tmpPtr = const_cast( effectBuffer.Ptr() ); + memcpy( tmpPtr, simpleTimelineEffect, sizeof ( simpleTimelineEffect ) ); + effectBuffer.SetLength( sizeof ( simpleTimelineEffect ) ); + + if ( iSynchronous ) + { + _LIT( KInsertedText, "Playing Repeat %d times synchronously..." ); + TBuf<50> buf; + buf.Format( KInsertedText, aRepeats ); + iAppView->InsertOutput( buf ); + + err = iHaptics->PlayEffectRepeat( effectBuffer, 0, aRepeats, iEffectHandle ); + } + else + { + _LIT( KInsertedText, "Playing Repeat %d times asynchronously..." ); + TBuf<50> buf; + buf.Format( KInsertedText, aRepeats ); + iAppView->InsertOutput( buf ); + + TRequestStatus status; + iHaptics->PlayEffectRepeat( effectBuffer, 0, aRepeats, iEffectHandle, status ); + User::WaitForRequest( status ); + err = status.Int(); + } + + CleanupStack::PopAndDestroy(); // effectBuffer (closed here..) + + // print error/success + PrintPlayEffectStatus( err ); + GetCurrentEffectState(); + + // if effect played successfully, add history data + if ( !err ) + { + iEffectData->AddEffectInfo( iEffectHandle ); + } + } + +// --------------------------------------------------------- +// Pauses the effect of the given index in the effect +// history data. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PauseEffect( TInt aIndex ) + { + // get effect handle + TInt effectHandle = iEffectData->EffectHandle(aIndex); + + // pause effect + TInt err = iHaptics->PausePlayingEffect( effectHandle ); + + if ( err ) + { + TBuf<8> errBuf; + errBuf.AppendNum( err ); + iAppView->InsertOutput( _L("Pausing effect failed, err = "), EFalse ); + iAppView->InsertOutput( errBuf ); + } + else + { + iAppView->InsertOutput( _L("Pausing effect succeeded.") ); + } + } + +// --------------------------------------------------------- +// Resumes the effect of the given index in the effect +// history data. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::ResumeEffect( TInt aIndex ) + { + // get effect handle + TInt effectHandle = iEffectData->EffectHandle(aIndex); + + // resume effect + TInt err = iHaptics->ResumePausedEffect( effectHandle ); + + if ( err ) + { + TBuf<8> errBuf; + errBuf.AppendNum( err ); + iAppView->InsertOutput( _L("Resuming effect failed, err = "), EFalse ); + iAppView->InsertOutput( errBuf ); + } + else + { + iAppView->InsertOutput( _L("Resuming effect succeeded.") ); + } + } + +// --------------------------------------------------------- +// Stops the effect of the given index in the effect +// history data. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::StopEffect( TInt aIndex ) + { + // get effect handle + TInt effectHandle = iEffectData->EffectHandle(aIndex); + + // stop effect + TInt err = iHaptics->StopPlayingEffect( effectHandle ); + + if ( err ) + { + TBuf<8> errBuf; + errBuf.AppendNum( err ); + iAppView->InsertOutput( _L("Stopping effect failed, err = "), EFalse ); + iAppView->InsertOutput( errBuf ); + } + else + { + iAppView->InsertOutput( _L("Stopping effect succeeded.") ); + } + + // stop auto-modify effect, if it is on + iEffectData->ResetModifiableEffectTimer(); + } + +// --------------------------------------------------------- +// Deletes loaded IVT data +// --------------------------------------------------------- +// +void CHapticsTestAppUi::DeleteLoadedIVTData( TInt aIndex ) + { + if ( 0 > aIndex || aIndex >= iLoadedIVTFileArray.Count() ) + { + iAppView->InsertOutput( _L("Error: Delete index mismatch!") ); + return; + } + + TInt err = iHaptics->DeleteEffectData( iLoadedIVTFileArray[aIndex].iFileHandle ); + if ( KErrNone == err ) + { + // delete effect history + iEffectData->DeleteEffectInfo( iLoadedIVTFileArray[aIndex].iFileHandle ); + + // delete ivt-data item + if ( iLoadedIVTFileArray[aIndex].iDataBuffer ) + { + delete iLoadedIVTFileArray[aIndex].iDataBuffer; + } + + iLoadedIVTFileArray.Remove( aIndex ); + + iAppView->InsertOutput( _L("IVT data deletion succeeded") ); + } + else + { + _LIT( KInsertedText, "IVT data deletion failed: %d" ); + TBuf<80> buf; + buf.Format( KInsertedText, err ); + iAppView->InsertOutput( buf ); + } + } + +// --------------------------------------------------------- +// Deletes all loaded IVT datas +// --------------------------------------------------------- +// +void CHapticsTestAppUi::DeleteAllLoadedIVTData() + { + iAppView->InsertOutput( _L("Deleting all loaded IVT datas.") ); + + TInt err = iHaptics->DeleteAllEffectData(); + + if ( KErrNone == err ) + { + iAppView->InsertOutput( _L("All IVT data deletion succeeded") ); + + while ( iLoadedIVTFileArray.Count() ) + { + // delete effect history + iEffectData->DeleteEffectInfo( iLoadedIVTFileArray[0].iFileHandle ); + + // delete ivt-data item + if ( iLoadedIVTFileArray[0].iDataBuffer ) + { + delete iLoadedIVTFileArray[0].iDataBuffer; + } + + iLoadedIVTFileArray.Remove( 0 ); + } + } + else + { + _LIT( KInsertedText, "All IVT data deletion failed: %d" ); + TBuf<80> buf; + buf.Format( KInsertedText, err ); + iAppView->InsertOutput( buf ); + } + } + + +// --------------------------------------------------------- +// Fetches the current state of the last played effect +// (iEffectHandle), and prints the result to the UI. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::GetCurrentEffectState() + { + TInt effectState = KErrNotFound; + TInt err = iHaptics->GetEffectState( iEffectHandle, effectState ); + + if ( err ) + { + TBuf<16> errCode; + errCode.AppendNum( err ); + iAppView->InsertOutput( _L(" Fetching effect state failed! Err: "), EFalse ); + iAppView->InsertOutput( errCode ); + } + else + { + TBuf<16> stateBuf; + + switch ( effectState ) + { + case CHWRMHaptics::EHWRMHapticsEffectNotPlaying: + stateBuf.Append( _L("Not playing.") ); + break; + case CHWRMHaptics::EHWRMHapticsEffectPlaying: + stateBuf.Append( _L("Playing.") ); + break; + case CHWRMHaptics::EHWRMHapticsEffectPaused: + stateBuf.Append( _L("Paused.") ); + break; + default: + stateBuf.Append( _L("Unknown!") ); + break; + } + + iAppView->InsertOutput( _L(" Effect state: "), EFalse ); + iAppView->InsertOutput( stateBuf ); + } + } + +// --------------------------------------------------------- +// Prints the status of a "play effect". +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PrintPlayEffectStatus( TInt aErrorCode ) const + { + if ( aErrorCode ) + { + TBuf<16> errCode; + errCode.AppendNum( aErrorCode ); + iAppView->InsertOutput( _L("Playing effect failed! Err: "), EFalse ); + iAppView->InsertOutput( errCode ); + } + else + { + TBuf<16> handleBuf; + handleBuf.AppendNum( iEffectHandle ); + iAppView->InsertOutput( _L("Played effect successfully!") ); + iAppView->InsertOutput( _L(" Effect handle: "), EFalse ); + iAppView->InsertOutput( handleBuf ); + } + } + +// --------------------------------------------------------- +// Queries user how many repeats to have in case of playing +// some effect repeatedly. +// --------------------------------------------------------- +// +TInt CHapticsTestAppUi::GetNumberOfRepeats() + { + TInt repeatsIndex; + TInt retVal = 2; // default is 2 repeats + + // Uses non-leavable new for CAknListQueryDialog construction + CAknListQueryDialog* query = new CAknListQueryDialog( &repeatsIndex ); + + if ( query ) + { + query->PrepareLC( R_HAPTICS_REPEATEFFECT_REPEATS_QUERY ); + + if ( query->RunLD() ) + { + switch ( repeatsIndex ) + { + case 0: + retVal = 0; + break; + case 1: + retVal = 1; + break; + case 2: + retVal = 2; + break; + case 3: + retVal = 3; + break; + case 4: + retVal = 7; + break; + case 5: + retVal = iHaptics->InfiniteRepeat(); + break; + default: + break; // uses default (2) as return value + }; + } + } + return retVal; + } + +// --------------------------------------------------------- +// Calculates the effect index from the submenu index. +// --------------------------------------------------------- +// +TInt CHapticsTestAppUi::CountFileHandleAndEffectIndex(TInt aSubmenuIndex) + { + TInt effectFileCount = iLoadedIVTFileArray.Count(); + TInt retVal = 0xFFFFFFFF; + TInt totalRunningEffectCount = 0; + TInt effectCountAfterPreviousFile = 0; + + for ( TInt i = 0; i < effectFileCount; ++i ) + { + TInt effectsInThisFile = 0; + iHaptics->GetEffectCount( iLoadedIVTFileArray[i].iFileHandle, effectsInThisFile ); + effectCountAfterPreviousFile = totalRunningEffectCount; + totalRunningEffectCount += effectsInThisFile; + if ( aSubmenuIndex < totalRunningEffectCount ) + { + iIVTFileHandle = iLoadedIVTFileArray[i].iFileHandle; + iIVTDataBuffer = iLoadedIVTFileArray[i].iDataBuffer; + retVal = aSubmenuIndex - effectCountAfterPreviousFile; + break; + } + } + return retVal; + } + +// --------------------------------------------------------- +// Creates all submenu items for a play effect submenu. +// Fetches all the names of the effects from currently +// loaded IVT-data. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::CreatePlayEffectSubmenuL( CEikMenuPane* aMenuPane, + TInt aCommandId, + TInt aDimCommandId ) + { + TInt loadedIVTFileCount = iLoadedIVTFileArray.Count(); + TBool dimmingNeeded = EFalse; + + if ( loadedIVTFileCount ) + { + // make all effect names (in all loaded files) visible in the submenu + CEikMenuPaneItem::SData data; + for ( TInt j = 0; j < loadedIVTFileCount; ++j) + { + if ( iLoadedIVTFileArray[j].iDataBuffer ) + { + TInt effectCount = 0; + iHaptics->GetEffectCount( iLoadedIVTFileArray[j].iFileHandle, effectCount ); + HBufC8* tempBuf8 = HBufC8::New( iHaptics->MaxEffectNameLength() ); + TPtr8 effectName = tempBuf8->Des(); + for ( TInt i = 0; i < effectCount; ++i ) + { + // fetch effect name + iHaptics->GetEffectName( iLoadedIVTFileArray[j].iFileHandle, i, effectName ); + + data.iText.Copy( effectName ); + data.iCommandId = aCommandId; + data.iCascadeId = 0; + data.iFlags = 0; + data.iExtraText = KNullDesC; + + aMenuPane->AddMenuItemL( data ); + dimmingNeeded = ETrue; + } + delete tempBuf8; + } + } + } + if ( dimmingNeeded ) + { + // effects found in IVT-data, hide the "no effects" -item + aMenuPane->SetItemDimmed( aDimCommandId, ETrue ); + } + } + +// --------------------------------------------------------- +// Prints effect information got from getter functions +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PrintEffectInfo( TInt aIndex ) + { + if ( iUseHandle && iShowEffectInfo ) + { + TInt duration; + iHaptics->GetEffectDuration( iIVTFileHandle, + aIndex, + duration ); + + HBufC8* tempBuf8 = HBufC8::New( iHaptics->MaxEffectNameLength() ); + TPtr8 effectName = tempBuf8->Des(); + + iHaptics->GetEffectName( iIVTFileHandle, aIndex, effectName ); + + TInt effectIndex; + iHaptics->GetEffectIndexFromName( iIVTFileHandle, + effectName, + effectIndex ); + + TInt type; + iHaptics->GetEffectType( iIVTFileHandle, aIndex, type ); + + + HBufC* tempBuf16 = HBufC::New( iHaptics->MaxEffectNameLength() ); + TPtr buf = tempBuf16->Des(); + + iAppView->InsertOutput( _L(" Effect name: "), EFalse ); + buf.Copy( effectName ); + iAppView->InsertOutput( buf, EFalse ); + + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( effectIndex ); + iAppView->InsertOutput( _L(" Idx: "), EFalse ); + iAppView->InsertOutput( buf ); + + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( duration ); + iAppView->InsertOutput( _L(" Effect duration: "), EFalse ); + iAppView->InsertOutput( buf ); + + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( type ); + iAppView->InsertOutput( _L(" Effect type: "), EFalse ); + iAppView->InsertOutput( buf ); + + if ( type == CHWRMHaptics::EHWRMHapticsTypeMagSweep ) + { + CHWRMHaptics::THWRMHapticsMagSweepEffect def; + iHaptics->GetMagSweepEffectDefinition( iIVTFileHandle, + aIndex, + def ); + iAppView->InsertOutput( _L(" MagSweep definition -> Duration:"), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iDuration ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" MagSweep definition -> Magnitude: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iMagnitude ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" MagSweep definition -> Style: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iStyle ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" MagSweep definition -> Attack time: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iAttackTime ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" MagSweep definition -> Attack level: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iAttackLevel ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" MagSweep definition -> Fade time: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iFadeTime ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" MagSweep definition -> Fade level: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iFadeLevel ); + iAppView->InsertOutput( buf ); + } + else if ( type == CHWRMHaptics::EHWRMHapticsTypePeriodic ) + { + CHWRMHaptics::THWRMHapticsPeriodicEffect def; + iHaptics->GetPeriodicEffectDefinition( iIVTFileHandle, + aIndex, + def ); + iAppView->InsertOutput( _L(" Periodic definition -> Duration: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iDuration ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Periodic definition -> Magnitude: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iMagnitude ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Periodic definition -> Period: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iPeriod ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Periodic definition -> Style: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iStyle ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Periodic definition -> Attack time: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iAttackTime ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Periodic definition -> Attack level: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iAttackLevel ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Periodic definition -> Fade time: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iFadeTime ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Periodic definition -> Attack level: "), EFalse ); + buf.Delete( 0, buf.MaxLength() ); + buf.AppendNum( def.iFadeLevel ); + iAppView->InsertOutput( buf ); + } + delete tempBuf8; + delete tempBuf16; + } + } + +// --------------------------------------------------------- +// Prints the given status onto the screen. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::PrintStatusInfo( + MHWRMHapticsObserver::THWRMHapticsStatus aStatus ) const + { + iAppView->InsertOutput( _L("Received status: "), EFalse ); + + switch( aStatus ) + { + case MHWRMHapticsObserver::EHWRMHapticsStatusAvailable: + { + iAppView->InsertOutput( _L("Available.") ); + break; + } + case MHWRMHapticsObserver::EHWRMHapticsStatusReserved: + { + iAppView->InsertOutput( _L("Reserved.") ); + break; + } + case MHWRMHapticsObserver::EHWRMHapticsStatusSuspended: + { + iAppView->InsertOutput( _L("Suspended.") ); + break; + } + default: + { + iAppView->InsertOutput( _L("") ); + break; + } + } + } + +// --------------------------------------------------------- +// Calls the getter methods for system constants +// and prints out the results. +// --------------------------------------------------------- +// +void CHapticsTestAppUi::ConstGetters() const + { + _LIT( KNumFormat, "%d" ); + TBuf<50> buf; + iAppView->InsertOutput( _L(" Infinite repeats: "), EFalse ); + buf.Format( KNumFormat, iHaptics->InfiniteRepeat() ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Infinite duration: "), EFalse ); + buf.Format( KNumFormat, iHaptics->InfiniteDuration() ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Max effect name length: "), EFalse ); + buf.Format( KNumFormat, iHaptics->MaxEffectNameLength() ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Max device name length: "), EFalse ); + buf.Format( KNumFormat, iHaptics->MaxDeviceNameLength() ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Max capability string length: "), EFalse ); + buf.Format( KNumFormat, iHaptics->MaxCapabilityStringLength() ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Max property string length: "), EFalse ); + buf.Format( KNumFormat, iHaptics->MaxPropertyStringLength() ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Max streaming sample size: "), EFalse ); + buf.Format( KNumFormat, iHaptics->MaxStreamingSampleSize() ); + iAppView->InsertOutput( buf ); + iAppView->InsertOutput( _L(" Default device priority: "), EFalse ); + buf.Format( KNumFormat, iHaptics->DefaultDevicePriority() ); + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// Modifies an effect using the values set for iModifyEffect. +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::ModifyEffect() + { + if ( !iEffectData->ModifiableEffectExists() ) + { + return; + } + + TInt err = KErrNone; + TInt effectHandle = iEffectData->ModifiableEffectHandle(); + + if ( iEffectData->ModifiableEffectIsMagSweep() ) + { + // fill magsweep data + CHWRMHaptics::THWRMHapticsMagSweepEffect magsweep; + iEffectData->FillModifiableMagSweepData( magsweep ); + + // execute modification + if ( iSynchronous ) + { + err = iHaptics->ModifyPlayingMagSweepEffect( effectHandle, magsweep ); + } + else + { + TRequestStatus status; + iHaptics->ModifyPlayingMagSweepEffect( effectHandle, magsweep, status ); + User::WaitForRequest( status ); + err = status.Int(); + } + } + else if ( iEffectData->ModifiableEffectIsPeriodic() ) + { + // fill periodic data + CHWRMHaptics::THWRMHapticsPeriodicEffect periodic; + iEffectData->FillModifiablePeriodicData( periodic ); + + // execute modification + if ( iSynchronous ) + { + err = iHaptics->ModifyPlayingPeriodicEffect( effectHandle, periodic ); + } + else + { + TRequestStatus status; + iHaptics->ModifyPlayingPeriodicEffect( effectHandle, periodic, status ); + User::WaitForRequest( status ); + err = status.Int(); + } + } + + if ( err ) + { + TBuf<8> errBuf; + errBuf.AppendNum( err ); + iAppView->InsertOutput( _L("Modifying effect failed, err = "), EFalse ); + iAppView->InsertOutput( errBuf ); + } + else + { + iAppView->InsertOutput( _L("Modifying effect succeeded.") ); + } + } + +// --------------------------------------------------------------------------- +// Static callback method from a periodic timer used for +// continuous effect modification (magnitude/period). +// --------------------------------------------------------------------------- +// +TInt CHapticsTestAppUi::ModifyPlayingEffect( TAny* aPtr ) + { + CHapticsTestEffectDataHandler* effectData = + static_cast( aPtr ); + + // hundred modifications to get to KPi (up and down with magnitude) + TReal stepLengthRad = KPi/100 * effectData->ModifyCount(); + + // calculate absolute sin value + TReal sinValue = 0; + TInt errSin = Math::Sin( sinValue, stepLengthRad ); + sinValue = Abs( sinValue ); + + // increase the amount of modifications done + effectData->SetModifyCount( effectData->ModifyCount() + 1 ); + + TInt err = KErrNone; + TInt effectHandle = effectData->ModifiableEffectHandle(); + + if ( effectData->ModifiableEffectIsMagSweep() ) + { + // modify magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect magsweep; + effectData->FillModifiableMagSweepData( magsweep ); + + // new magnitude value according to sin value + magsweep.iMagnitude = KHWRMHapticsMaxMagnitude * sinValue; + + // modify effect + err = effectData->Haptics()->ModifyPlayingMagSweepEffect( + effectHandle, magsweep ); + } + else if ( effectData->ModifiableEffectIsPeriodic() ) + { + // modify periodic effect + CHWRMHaptics::THWRMHapticsPeriodicEffect periodic; + effectData->FillModifiablePeriodicData( periodic ); + + // period getting smaller when magnitude getting higher + periodic.iPeriod = 20 + (1-sinValue)*200; + + // modify effect + err = effectData->Haptics()->ModifyPlayingPeriodicEffect( + effectHandle, periodic ); + } + + if ( err ) + { + CEikonEnv::Static()->InfoMsg( _L("Modify failed!") ); + } + + return KErrNone; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityDeviceCategory() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Device category: "), EFalse ); + TInt retValue( CHWRMHaptics::EHWRMHapticsEmbedded ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsDeviceCategory, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + switch ( retValue ) + { + case CHWRMHaptics::EHWRMHapticsVirtual: + buf.Append( _L("Virtual") ); + break; + case CHWRMHaptics::EHWRMHapticsEmbedded: + buf.Append( _L("Embedded") ); + break; + default: + buf.Append( _L("Unknown") ); + break; + } + } + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityMaxNestedRepeats() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Max nested repeats: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsMaxNestedRepeats, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityNumActuators() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Number of actuators: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsNumActuators, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityActuatorType() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Actuator type: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsActuatorType, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + switch (retValue) + { + case CHWRMHaptics::EHWRMHapticsTypeERM: + buf.Append( _L("EHWRMHapticsTypeERM") ); + break; + case CHWRMHaptics::EHWRMHapticsTypeLRA: + buf.Append( _L("EHWRMHapticsTypeLRA") ); + break; + default: + buf.Append( _L("Unknown") ); + break; + } + } + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityNumEffectSlots() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Number of effect slots: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsNumEffectSlots, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityNumEffectStyles() + { + TBuf<150> buf; + iAppView->InsertOutput( _L(" Effect styles: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsSupportedStyles, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + if ( retValue & CHWRMHaptics::EHWRMHapticsSupportSmooth ) + { + buf.Append( _L(" EHWRMHapticsSupportSmooth") ); + } + + if ( retValue & CHWRMHaptics::EHWRMHapticsSupportStrong ) + { + buf.Append( _L(" EHWRMHapticsSupportStrong") ); + } + + if ( retValue & CHWRMHaptics::EHWRMHapticsSupportSharp ) + { + buf.Append( _L(" EHWRMHapticsSupportSharp") ); + } + } + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityMinPeriod() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Minimum period for periodic effects: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsMinPeriod, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityMaxPeriod() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Maximum period for periodic effects: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsMaxPeriod, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityMaxEffectDuration() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Maximum effect duration: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsMaxEffectDuration, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilitySupportedEffects() + { + TBuf<150> buf; + iAppView->InsertOutput( _L(" Supported effect types: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsSupportedEffects, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + if ( retValue & CHWRMHaptics::EHWRMHapticsSupportPeriodic ) + { + buf.Append( _L(" EHWRMHapticsSupportPeriodic") ); + } + + if ( retValue & CHWRMHaptics::EHWRMHapticsSupportMagSweep ) + { + buf.Append( _L(" EHWRMHapticsSupportMagSweep") ); + } + + if ( retValue & CHWRMHaptics::EHWRMHapticsSupportTimeline ) + { + buf.Append( _L(" EHWRMHapticsSupportTimeline") ); + } + + if ( retValue & CHWRMHaptics::EHWRMHapticsSupportStreaming ) + { + buf.Append( _L(" EHWRMHapticsSupportStreaming") ); + } + } + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityDeviceName() + { + TBuf<100> buf; + iAppView->InsertOutput( _L(" Device name: "), EFalse ); + TBuf8<100> retValue; + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsDeviceName, retValue ) ); + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + CnvUtfConverter::ConvertToUnicodeFromUtf8( buf, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityMaxEnvelopeTime() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Maximum envelop time: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsMaxEnvelopeTime, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityAPIVersionNumber() + { + TBuf<50> buf; + TInt retValue( 0 ); + iAppView->InsertOutput( _L(" API version: "), EFalse ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsAPIVersionNumber, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetCapabilityMaxIVTSize() + { + TBuf<50> buf; + iAppView->InsertOutput( _L(" Maximum size of IVT file: "), EFalse ); + TInt retValue( 0 ); + TInt err( iHaptics->GetDeviceCapability( + CHWRMHaptics::EHWRMHapticsMaxEffectDataSize, retValue ) ); + + if ( err ) + { + _LIT( KFailedFormat, "GetDeviceCapability failed (%d)!" ); + buf.Format( KFailedFormat, err ); + } + else + { + _LIT( KNumFormat, "%d" ); + buf.Format( KNumFormat, retValue ); + } + + iAppView->InsertOutput( buf, ETrue ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyPriorityMin() + { + iAppView->InsertOutput( _L(" Setting priority to minimum"), ETrue ); + TInt value(KHWRMHapticsMinDevicePriority); + TRAPD( err, iHaptics->SetDeviceProperty(CHWRMHaptics::EHWRMHapticsPriority, value)); + if ( err ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyPriorityDefault() + { + iAppView->InsertOutput( _L(" Setting priority to default" ), ETrue ); + TInt value( KHWRMHapticsMinDevicePriority ); + + TRAPD( err1, value = iHaptics->DefaultDevicePriority() ); + if ( err1 ) + { + CEikonEnv::Static()->InfoMsg( _L( "DefaultDevicePriority() failed!" ) ); + return; + } + + TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, value ) ); + if ( err2 ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyPriorityMax() + { + iAppView->InsertOutput( _L(" Setting priority to maximum"), ETrue ); + TInt value(KHWRMHapticsMaxDevicePriority); + TRAPD( err, iHaptics->SetDeviceProperty(CHWRMHaptics::EHWRMHapticsPriority, value)); + if ( err ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetPropertyPriority() + { + _LIT( KNumFormat, "%d" ); + TBuf<50> buf; + iAppView->InsertOutput( _L(" Device priority: "), EFalse ); + TInt retValue(0); + TRAPD( err, iHaptics->GetDeviceProperty(CHWRMHaptics::EHWRMHapticsPriority, retValue)); + if ( err ) + { + CEikonEnv::Static()->InfoMsg( _L("GetDeviceProperty failed!") ); + } + + buf.Format( KNumFormat, retValue ); + iAppView->InsertOutput( buf, ETrue ); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyDisableEffectsTrue() + { + iAppView->InsertOutput( _L(" Disabling effects" ), ETrue ); + TBool value( ETrue ); + TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, value ) ); + if ( err2 ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyDisableEffectsFalse() + { + iAppView->InsertOutput( _L(" Enabling effects" ), ETrue ); + TBool value( EFalse ); + TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, value ) ); + if ( err2 ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetPropertyDisableEffects() + { + iAppView->InsertOutput( _L(" Effects disabled: "), EFalse ); + TInt retValue( EFalse ); + TRAPD( err, iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, retValue ) ); + if ( err ) + { + CEikonEnv::Static()->InfoMsg( _L("GetDeviceProperty failed!") ); + } + else + { + if ( retValue ) + { + iAppView->InsertOutput( _L("TRUE"), ETrue ); + } + else + { + iAppView->InsertOutput( _L("FALSE"), ETrue ); + } + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyStrengthMin() + { + iAppView->InsertOutput( _L(" Setting strength to mininum" ), ETrue ); + TBool value( KHWRMHapticsMinStrength ); + TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, value ) ); + if ( err2 ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyStrengthMiddle() + { + iAppView->InsertOutput( _L(" Setting strength to middle" ), ETrue ); + TBool value( ( KHWRMHapticsMaxStrength - KHWRMHapticsMinStrength ) / 2 ); + TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, value ) ); + if ( err2 ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::SetPropertyStrengthMax() + { + iAppView->InsertOutput( _L(" Setting strength to max" ), ETrue ); + TBool value( KHWRMHapticsMaxStrength ); + TRAPD( err2, iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, value ) ); + if ( err2 ) + { + CEikonEnv::Static()->InfoMsg( _L("SetDeviceProperty failed!") ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::GetPropertyStrength() + { + _LIT( KNumFormat, "%d" ); + TBuf<50> buf; + iAppView->InsertOutput( _L(" Strength level: "), EFalse ); + TInt retValue(0); + TRAPD( err, iHaptics->GetDeviceProperty(CHWRMHaptics::EHWRMHapticsStrength, retValue)); + if ( err ) + { + CEikonEnv::Static()->InfoMsg( _L("GetDeviceProperty failed!") ); + } + + buf.Format( KNumFormat, retValue ); + iAppView->InsertOutput( buf, ETrue ); + } + + +// --------------------------------------------------------------------------- +// Enables streaming mode. +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::StartStreaming() + { + iCurrentSample = 0; + iEffectHandle = KErrNotFound; + TInt err = iHaptics->CreateStreamingEffect( iEffectHandle ); + + if ( err ) + { + TBuf<16> errCode; + errCode.AppendNum( err ); + iAppView->InsertOutput( _L("Create streaming effect failed! Err: "), EFalse ); + iAppView->InsertOutput( errCode ); + } + else + { + TBuf<16> handleBuf; + handleBuf.AppendNum( iEffectHandle ); + iAppView->InsertOutput( _L("Streaming effect created successfully!") ); + iAppView->InsertOutput( _L(" Effect handle: "), EFalse ); + iAppView->InsertOutput( handleBuf ); + + iStreaming = ETrue; + } + } + + +// --------------------------------------------------------------------------- +// Plays one streaming sample from KStreamArray. +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::PlayStreamingSample( TInt aSampleId ) + { + RBuf8 sampleBuffer; + sampleBuffer.ReAlloc( sizeof( KStreamArray[aSampleId] ) ); + TUint8* tmpPtr = const_cast( sampleBuffer.Ptr() ); + memcpy( tmpPtr, KStreamArray[aSampleId], sizeof( KStreamArray[aSampleId] ) ); + sampleBuffer.SetLength( sizeof( KStreamArray[aSampleId] ) ); + + iHaptics->PlayStreamingSample( iEffectHandle, sampleBuffer ); + + sampleBuffer.Close(); + } + + +// --------------------------------------------------------------------------- +// Disables streaming mode. +// --------------------------------------------------------------------------- +// +void CHapticsTestAppUi::StopStreaming() + { + iStreaming = EFalse; + + TInt err = iHaptics->DestroyStreamingEffect( iEffectHandle ); + if ( err ) + { + TBuf<16> errCode; + errCode.AppendNum( err ); + iAppView->InsertOutput( _L("Destoy streaming effect failed! Err: "), EFalse ); + iAppView->InsertOutput( errCode ); + } + else + { + TBuf<16> handleBuf; + handleBuf.AppendNum( iEffectHandle ); + iAppView->InsertOutput( _L("Streaming effect destroyed successfully!") ); + } + } + +// End of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/src/hapticstestappview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/src/hapticstestappview.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,202 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: AppView class implementation. +* +*/ + + +#include +#include +#include +#include +#include + +#include "hapticstestappview.h" + +const TInt KTestSmallerFontTwips = 65; + +// --------------------------------------------------------- +// Standard construction sequence +// --------------------------------------------------------- +// +CHapticsTestAppView* CHapticsTestAppView::NewL(const TRect& aRect) + { + CHapticsTestAppView* self = CHapticsTestAppView::NewLC(aRect); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------- +// Static constructor. Leaves the created instance onto the +// cleanup stack. +// --------------------------------------------------------- +// +CHapticsTestAppView* CHapticsTestAppView::NewLC(const TRect& aRect) + { + CHapticsTestAppView* self = new (ELeave) CHapticsTestAppView; + CleanupStack::PushL(self); + self->ConstructL(aRect); + return self; + } + +// --------------------------------------------------------- +// Constructor. +// --------------------------------------------------------- +// +CHapticsTestAppView::CHapticsTestAppView() + { + // no implementation required + } + +// --------------------------------------------------------- +// Destructor. +// --------------------------------------------------------- +// +CHapticsTestAppView::~CHapticsTestAppView() + { + delete iParaFormat; + iParaFormat = NULL; + + delete iCharFormat; + iCharFormat = NULL; + + delete iOutputWindow; + iOutputWindow = NULL; + + delete iRichText; + iRichText = NULL; + } + +// --------------------------------------------------------- +// Construct the view using a rich text editor. +// --------------------------------------------------------- +// +void CHapticsTestAppView::ConstructL(const TRect& aRect) + { + // Create a window for this application view + CreateWindowL(); + + // get normal font + const CFont* font = CEikonEnv::Static()->NormalFont(); + TFontSpec fontspec = font->FontSpecInTwips(); + + TCharFormat defaultCharFormat( fontspec.iTypeface.iName, + fontspec.iHeight - KTestSmallerFontTwips ); + TCharFormatMask defaultCharFormatMask; + defaultCharFormatMask.SetAttrib( EAttFontTypeface ); + defaultCharFormatMask.SetAttrib( EAttFontHeight ); + + // paragraph and char format layers + iParaFormat = CParaFormatLayer::NewL(); + iCharFormat = CCharFormatLayer::NewL( defaultCharFormat, + defaultCharFormatMask ); + + iRichText = CRichText::NewL( iParaFormat, iCharFormat ); + + //Create bordered edit windows. + iOutputWindow = new (ELeave) CEikRichTextEditor( TGulBorder( TGulBorder::EShallowRaised ) ); + iOutputWindow->SetContainerWindowL( *this ); + + // Create scrollbar + iOutputWindow->CreateScrollBarFrameL(); + iOutputWindow->ScrollBarFrame()->SetScrollBarVisibilityL( + CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); + + iOutputWindow->ConstructL( this, 0, 0, + EEikEdwinOwnsWindow|EEikEdwinInclusiveSizeFixed| + EEikEdwinKeepDocument|EEikEdwinUserSuppliedText| + EEikEdwinLineCursor|EEikEdwinAlwaysShowSelection ); + + TRect outputRect( Rect() ); + TInt outputWidthOffset = iOutputWindow->ScrollBarFrame()->ScrollBarBreadth( CEikScrollBar::EVertical ); + outputRect.iBr.iX -= outputWidthOffset; + + iOutputWindow->SetDocumentContentL( *iRichText, CEikEdwin::EUseText ); + iOutputWindow->SetRect( outputRect ); + iOutputWindow->ActivateL(); + iOutputWindow->SetFocus( ETrue ); + + // Set the windows size + SetRect( aRect ); + + // Activate the window, which makes it ready to be drawn + ActivateL(); + } + +// --------------------------------------------------------- +// Insert the given text to the end of the outputted text. +// Adds line break to the end of the text. +// --------------------------------------------------------- +// +void CHapticsTestAppView::InsertOutput( const TDesC& aOutputLine, + TBool aLineBreak ) const + { + TRAPD( err, iRichText->InsertL( iOutputWindow->TextLength(), + aOutputLine ) ); + + // insert line break if requested + if ( aLineBreak ) + { + TRAP( err, iRichText->InsertL( iOutputWindow->TextLength(), + (TChar)CEditableText::ELineBreak ) ); + } + + TRAP( err, iOutputWindow->ForceScrollBarUpdateL() ); + TRAP( err, iOutputWindow->SetCursorPosL( iOutputWindow->TextLength(), + EFalse) ); + } + +// --------------------------------------------------------- +// Clears the output view. +// --------------------------------------------------------- +// +void CHapticsTestAppView::ClearOutput() const + { + iRichText->Reset(); + TRAPD( err, iOutputWindow->HandleTextChangedL()); + err = err; // just to escape warning message for ARM + iOutputWindow->SetCursorPosL( 0, EFalse ); + } + +// --------------------------------------------------------- +// Draw this application's view to the screen +// --------------------------------------------------------- +// +void CHapticsTestAppView::Draw( const TRect& /*aRect*/ ) const + { + // Get the standard graphics context + CWindowGc& gc = SystemGc(); + + // Gets the control's extent + TRect rect = Rect(); + + // Clears the screen + gc.Clear( rect ); + } + +// --------------------------------------------------------- +// Called by framework when the view size is changed +// --------------------------------------------------------- +// +void CHapticsTestAppView::SizeChanged() + { + // decrease the width of the scrollbar from the width of the editor rect + TInt outputWidthOffset = iOutputWindow->ScrollBarFrame()->ScrollBarBreadth( CEikScrollBar::EVertical ); + TRect outputRect( Rect() ); + outputRect.iBr.iX -= outputWidthOffset; + iOutputWindow->SetRect( outputRect ); + iOutputWindow->SetFocus( ETrue ); + } + + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/src/hapticstestasyncplaysender.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/src/hapticstestasyncplaysender.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Implementation for asynchronous play commands sender object. +* +*/ + + +#include "hapticstestappview.h" +#include "hapticstestappui.h" +#include "hapticstestasyncplaysender.h" +#include "hapticstesteffectdatahandler.h" + +// --------------------------------------------------------------------------- +// Simple constructor. +// --------------------------------------------------------------------------- +// +CHapticsTestAsyncPlaySender::CHapticsTestAsyncPlaySender( + CHapticsTestAppUi* aUi ) + : CActive( EPriorityStandard ), iUi( aUi ) + { + CActiveScheduler::Add( this ); + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CHapticsTestAsyncPlaySender::~CHapticsTestAsyncPlaySender() + { + Cancel(); + } + +// --------------------------------------------------------------------------- +// Method for requesting the playing of an effect repeatedly. +// --------------------------------------------------------------------------- +// +void CHapticsTestAsyncPlaySender::PlayRepeat( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TUint8 aRepeat, + TInt& aEffectHandle ) + { + iIndex = aEffectIndex; + aHaptics->PlayEffectRepeat( aFileHandle, + aEffectIndex, + aRepeat, + aEffectHandle, + iStatus ); + SetActive(); + } + +// --------------------------------------------------------------------------- +// Method for requesting the playing of an effect. +// --------------------------------------------------------------------------- +// +void CHapticsTestAsyncPlaySender::Play( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TInt& aEffectHandle ) + { + iIndex = aEffectIndex; + aHaptics->PlayEffect( aFileHandle, + aEffectIndex, + aEffectHandle, + iStatus ); + SetActive(); + } + +// --------------------------------------------------------------------------- +// This active object's RunL. +// --------------------------------------------------------------------------- +// +void CHapticsTestAsyncPlaySender::RunL() + { + TInt status = iStatus.Int(); + iUi->PrintPlayEffectStatus( status ); + iUi->GetCurrentEffectState(); + if ( !status ) + { + iUi->iEffectData->AddEffectInfo( + iUi->iEffectHandle, iUi->iIVTFileHandle, iIndex ); + } + } + +// --------------------------------------------------------------------------- +// Dummy DoCancel(). Required due to inheritance from CActive. +// --------------------------------------------------------------------------- +// +void CHapticsTestAsyncPlaySender::DoCancel() + { + } + +// --------------------------------------------------------------------------- +// Dummy RunError(). Required due to inheritance from CActive. +// --------------------------------------------------------------------------- +// +TInt CHapticsTestAsyncPlaySender::RunError( TInt /* aError */ ) + { + return KErrNone; + } + +// end of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/src/hapticstestdocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/src/hapticstestdocument.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Document class implementation. +* +*/ + + +#include "hapticstestappui.h" +#include "hapticstestdocument.h" + +// --------------------------------------------------------- +// Standard Symbian OS construction sequence +// --------------------------------------------------------- +// +CHapticsTestDocument* CHapticsTestDocument::NewL(CEikApplication& aApp) + { + CHapticsTestDocument* self = NewLC(aApp); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------- +// Standard Symbian OS construction sequence +// --------------------------------------------------------- +// +CHapticsTestDocument* CHapticsTestDocument::NewLC(CEikApplication& aApp) + { + CHapticsTestDocument* self = new (ELeave) CHapticsTestDocument(aApp); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// --------------------------------------------------------- +// Second phase construction. +// --------------------------------------------------------- +// +void CHapticsTestDocument::ConstructL() + { + // no implementation required + } + +// --------------------------------------------------------- +// Constructor. +// --------------------------------------------------------- +// +CHapticsTestDocument::CHapticsTestDocument(CEikApplication& aApp) + : CAknDocument(aApp) + { + // no implementation required + } + +// --------------------------------------------------------- +// Destructor. +// --------------------------------------------------------- +// +CHapticsTestDocument::~CHapticsTestDocument() + { + // no implementation required + } + +// --------------------------------------------------------- +// Creates AppUi component. +// --------------------------------------------------------- +// +CEikAppUi* CHapticsTestDocument::CreateAppUiL() + { + // Create the application user interface, and return a pointer to it, + // the framework takes ownership of this object + CEikAppUi* appUi = new (ELeave) CHapticsTestAppUi; + return appUi; + } + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/examples/hapticstestapp/src/hapticstesteffectdatahandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/examples/hapticstestapp/src/hapticstesteffectdatahandler.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,904 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Active object listening waiting for async haptics completion. +* +*/ + + +#include +#include + +#include "hapticstest.hrh" +#include "hapticstesteffectdatahandler.h" + + +_LIT( KManualEffectName, "manual" ); + +const TInt KEffectModificationInterval = 50000; // microseconds +const TInt KMaxEffectHistorySize = 25; +const TInt KDefaultNonInfiniteDuration = 1000; // milliseconds + +// default values for manual effects +const TInt KDefaultEffectMagnitude = KHWRMHapticsMaxMagnitude; +const TInt KDefaultEffectAttackLevel = KHWRMHapticsMaxMagnitude * 0.5; +const TInt KDefaultEffectFadeLevel = KHWRMHapticsMaxMagnitude * 0.5; +const TInt KDefaultEffectAttackTime = 200; // milliseconds +const TInt KDefaultEffectFadeTime = 200; // milliseconds +const TInt KDefaultEffectPeriod = 300; // milliseconds +const CHWRMHaptics::THWRMHapticsEffectStyles KDefaultEffectStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + + +// --------------------------------------------------------------------------- +// Symbian two-phased constructor. +// --------------------------------------------------------------------------- +// +CHapticsTestEffectDataHandler* CHapticsTestEffectDataHandler::NewL() + { + CHapticsTestEffectDataHandler* self = + CHapticsTestEffectDataHandler::NewLC(); + + CleanupStack::Pop( self ); + + return self; + } + +// --------------------------------------------------------------------------- +// Symbian two-phased constructor. +// --------------------------------------------------------------------------- +// +CHapticsTestEffectDataHandler* CHapticsTestEffectDataHandler::NewLC() + { + CHapticsTestEffectDataHandler* self = + new ( ELeave ) CHapticsTestEffectDataHandler(); + CleanupStack::PushL( self ); + + self->ConstructL(); + + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CHapticsTestEffectDataHandler::~CHapticsTestEffectDataHandler() + { + ResetModifiableEffectTimer(); + + if ( iModifyEffect ) + { + delete iModifyEffect; + iModifyEffect = NULL; + } + + iPlayedEffectArray.Close(); + } + +// --------------------------------------------------------------------------- +// Adds effect data to effect history array. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::AddEffectInfo( TInt aEffectHandle, + TInt aFileHandle, + TInt aIndex ) + { + TPlayedEffect newEffect; + newEffect.iEffectHandle = aEffectHandle; + newEffect.iFileHandle = aFileHandle; + newEffect.iEffectIndex = aIndex; + + // add item to the beginning of the array, ignore possible error + iPlayedEffectArray.Insert( newEffect, 0 ); + + // if there are too many items, remove the last one + TInt count = iPlayedEffectArray.Count(); + if ( count > KMaxEffectHistorySize ) + { + iPlayedEffectArray.Remove( count - 1 ); + } + } + +// --------------------------------------------------------------------------- +// Deletest all effect info items from the list that have +// the given filehandle in their data. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DeleteEffectInfo( TInt aFileHandle ) + { + for ( TInt i = iPlayedEffectArray.Count() - 1; i >= 0 ; --i ) + { + if ( iPlayedEffectArray[i].iFileHandle == aFileHandle ) + { + iPlayedEffectArray.Remove( i ); + } + } + } + +// --------------------------------------------------------------------------- +// Returns the amount of effect data stored in the history data array. +// --------------------------------------------------------------------------- +// +TInt CHapticsTestEffectDataHandler::Count() const + { + return iPlayedEffectArray.Count(); + } + +// --------------------------------------------------------------------------- +// Returns the effect handle of the given effect data item. +// --------------------------------------------------------------------------- +// +TInt CHapticsTestEffectDataHandler::EffectHandle( TInt aIndex ) const + { + return iPlayedEffectArray[aIndex].iEffectHandle; + } + +// --------------------------------------------------------------------------- +// Returns the file handle of the given effect data item. +// --------------------------------------------------------------------------- +// +TInt CHapticsTestEffectDataHandler::FileHandle( TInt aIndex ) const + { + return iPlayedEffectArray[aIndex].iFileHandle; + } + +// --------------------------------------------------------------------------- +// Returns the effect index of the given effect data item. +// --------------------------------------------------------------------------- +// +TInt CHapticsTestEffectDataHandler::EffectIndex( TInt aIndex ) const + { + return iPlayedEffectArray[aIndex].iEffectIndex; + } + +// --------------------------------------------------------------------------- +// Resets the modifiable effect data with the data received in the +// given magsweep effect. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::ResetModifiableMagSweepEffectL( + const CHWRMHaptics::THWRMHapticsMagSweepEffect& aMagSweep, + TInt aEffectHandle, CHWRMHaptics* aHaptics ) + { + // reset effect data + if ( iModifyEffect ) + { + delete iModifyEffect; + iModifyEffect = NULL; + } + + // create new effect data + iModifyEffect = new (ELeave) TModifyEffect(); + iModifyEffect->iHaptics = aHaptics; + iModifyEffect->iEffectType = CHWRMHaptics::EHWRMHapticsTypeMagSweep; + iModifyEffect->iEffectHandle = aEffectHandle; + iModifyEffect->iModifyCount = 0; + + // store default effect values + iModifyEffect->iDuration = aMagSweep.iDuration; + iModifyEffect->iMagnitude = aMagSweep.iMagnitude; + iModifyEffect->iStyle = aMagSweep.iStyle; + iModifyEffect->iAttackLevel = aMagSweep.iAttackLevel; + iModifyEffect->iFadeLevel = aMagSweep.iFadeLevel; + iModifyEffect->iAttackTime = aMagSweep.iAttackTime; + iModifyEffect->iFadeTime = aMagSweep.iFadeTime; + + // no period for magsweep, use default value + iModifyEffect->iPeriod = KDefaultEffectPeriod; + } + +// --------------------------------------------------------------------------- +// Resets the modifiable effect data with the data received in the +// given periodic effect. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::ResetModifiablePeriodicEffectL( + const CHWRMHaptics::THWRMHapticsPeriodicEffect& aPeriodic, + TInt aEffectHandle, CHWRMHaptics* aHaptics ) + { + // reset effect data + if ( iModifyEffect ) + { + delete iModifyEffect; + iModifyEffect = NULL; + } + + // create new effect data + iModifyEffect = new (ELeave) TModifyEffect(); + iModifyEffect->iHaptics = aHaptics; + iModifyEffect->iEffectType = CHWRMHaptics::EHWRMHapticsTypePeriodic; + iModifyEffect->iEffectHandle = aEffectHandle; + iModifyEffect->iModifyCount = 0; + + // store default effect values + iModifyEffect->iDuration = aPeriodic.iDuration; + iModifyEffect->iMagnitude = aPeriodic.iMagnitude; + iModifyEffect->iStyle = aPeriodic.iStyle; + iModifyEffect->iAttackLevel = aPeriodic.iAttackLevel; + iModifyEffect->iFadeLevel = aPeriodic.iFadeLevel; + iModifyEffect->iAttackTime = aPeriodic.iAttackTime; + iModifyEffect->iFadeTime = aPeriodic.iFadeTime; + iModifyEffect->iPeriod = aPeriodic.iPeriod; + } + +// --------------------------------------------------------------------------- +// Starts the timer for constantly modifying an effect. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::StartModifiableEffectTimerL( TInt (*aFunction)(TAny* aPtr) ) + { + ResetModifiableEffectTimer(); + + // create and start periodic timer + iModifyTimer = CPeriodic::NewL( CActive::EPriorityStandard ); + iModifyTimer->Start( KEffectModificationInterval, + KEffectModificationInterval, + TCallBack( aFunction, this ) ); + } + +// --------------------------------------------------------------------------- +// Cancels and deletes the timer. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::ResetModifiableEffectTimer() + { + // reset timer + if ( iModifyTimer ) + { + iModifyTimer->Cancel(); + delete iModifyTimer; + iModifyTimer = NULL; + } + } + +// --------------------------------------------------------------------------- +// Returns whether or not a modifiable effect exists. +// --------------------------------------------------------------------------- +// +TBool CHapticsTestEffectDataHandler::ModifiableEffectExists() const + { + return iModifyEffect ? ETrue : EFalse; + } + +// --------------------------------------------------------------------------- +// Returns whether or not the currently stored effect is a magsweep effect. +// --------------------------------------------------------------------------- +// +TBool CHapticsTestEffectDataHandler::ModifiableEffectIsMagSweep() const + { + return ( iModifyEffect->iEffectType == CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + } + +// --------------------------------------------------------------------------- +// Returns whether or not the currently stored effect is a periodic effect. +// --------------------------------------------------------------------------- +// +TBool CHapticsTestEffectDataHandler::ModifiableEffectIsPeriodic() const + { + return ( iModifyEffect->iEffectType == CHWRMHaptics::EHWRMHapticsTypePeriodic ); + } + +// --------------------------------------------------------------------------- +// Returns the effect handle of the modifiable effect. +// --------------------------------------------------------------------------- +// +TInt CHapticsTestEffectDataHandler::ModifiableEffectHandle() const + { + return iModifyEffect->iEffectHandle; + } + +// --------------------------------------------------------------------------- +// Returns the amount of times the current modifiable effect +// has been modified already. +// --------------------------------------------------------------------------- +// +TInt CHapticsTestEffectDataHandler::ModifyCount() const + { + return iModifyEffect->iModifyCount; + } + +// --------------------------------------------------------------------------- +// Returns the pointer to the haptics client instance, which +// has been set to the effect modification data. +// --------------------------------------------------------------------------- +// +CHWRMHaptics* CHapticsTestEffectDataHandler::Haptics() const + { + return iModifyEffect->iHaptics; + } + +// --------------------------------------------------------------------------- +// Fills in default magsweep effect data into the given structure. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::FillDefaultMagSweepData( + CHWRMHaptics::THWRMHapticsMagSweepEffect& aMagSweep, + TBool aInfinite, TBool aAutoModifiable, + CHWRMHaptics* aHaptics ) const + { + if ( aInfinite ) + { + aMagSweep.iDuration = aHaptics->InfiniteDuration(); + } + else + { + aMagSweep.iDuration = KDefaultNonInfiniteDuration; + } + + if ( aAutoModifiable ) + { + // start modifiable effect from minimum magnitude + aMagSweep.iMagnitude = KHWRMHapticsMinMagnitude; + aMagSweep.iAttackLevel = KHWRMHapticsMinMagnitude; + aMagSweep.iFadeLevel = KHWRMHapticsMinMagnitude; + } + else + { + // non-modifiable effect + aMagSweep.iMagnitude = KDefaultEffectMagnitude; + aMagSweep.iAttackLevel = KDefaultEffectAttackLevel; + aMagSweep.iFadeLevel = KDefaultEffectFadeLevel; + } + + aMagSweep.iStyle = KDefaultEffectStyle; + aMagSweep.iAttackTime = KDefaultEffectAttackTime; + aMagSweep.iFadeTime = KDefaultEffectFadeTime; + } + +// --------------------------------------------------------------------------- +// Fills in default periodic effect data into the given structure. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::FillDefaultPeriodicData( + CHWRMHaptics::THWRMHapticsPeriodicEffect& aPeriodic, + TBool aInfinite, TBool /*aAutoModifiable*/, + CHWRMHaptics* aHaptics ) const + { + if ( aInfinite ) + { + aPeriodic.iDuration = aHaptics->InfiniteDuration(); + } + else + { + aPeriodic.iDuration = KDefaultNonInfiniteDuration; + } + + aPeriodic.iMagnitude = KDefaultEffectMagnitude; + aPeriodic.iAttackLevel = KDefaultEffectAttackLevel; + aPeriodic.iFadeLevel = KDefaultEffectFadeLevel; + + aPeriodic.iPeriod = KDefaultEffectPeriod; + aPeriodic.iStyle = KDefaultEffectStyle; + aPeriodic.iAttackTime = KDefaultEffectAttackTime; + aPeriodic.iFadeTime = KDefaultEffectFadeTime; + } + +// --------------------------------------------------------------------------- +// Fills in the modifiable effect data into the given magsweep structure. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::FillModifiableMagSweepData( + CHWRMHaptics::THWRMHapticsMagSweepEffect& aMagSweep ) const + { + aMagSweep.iDuration = iModifyEffect->iDuration; + aMagSweep.iStyle = iModifyEffect->iStyle; + aMagSweep.iAttackTime = iModifyEffect->iAttackTime; + aMagSweep.iFadeTime = iModifyEffect->iFadeTime; + aMagSweep.iMagnitude = iModifyEffect->iMagnitude; + aMagSweep.iAttackLevel = iModifyEffect->iAttackLevel; + aMagSweep.iFadeLevel = iModifyEffect->iFadeLevel; + } + +// --------------------------------------------------------------------------- +// Fills in the modifiable effect data into the given periodic structure. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::FillModifiablePeriodicData( + CHWRMHaptics::THWRMHapticsPeriodicEffect& aPeriodic ) const + { + aPeriodic.iDuration = iModifyEffect->iDuration; + aPeriodic.iStyle = iModifyEffect->iStyle; + aPeriodic.iAttackTime = iModifyEffect->iAttackTime; + aPeriodic.iFadeTime = iModifyEffect->iFadeTime; + aPeriodic.iMagnitude = iModifyEffect->iMagnitude; + aPeriodic.iAttackLevel = iModifyEffect->iAttackLevel; + aPeriodic.iFadeLevel = iModifyEffect->iFadeLevel; + aPeriodic.iPeriod = iModifyEffect->iPeriod; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's modify count. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetModifyCount( TInt aModifyCount ) + { + iModifyEffect->iModifyCount = aModifyCount; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's duration value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetDuration( TInt aDuration ) + { + iModifyEffect->iDuration = aDuration; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's magnitude value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetMagnitude( TInt aMagnitude ) + { + iModifyEffect->iMagnitude = aMagnitude; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's style value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetStyle( + CHWRMHaptics::THWRMHapticsEffectStyles aStyle ) + { + iModifyEffect->iStyle = aStyle; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's attack level value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetAttackLevel( TInt aAttackLevel ) + { + iModifyEffect->iAttackLevel = aAttackLevel; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's fade level value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetFadeLevel( TInt aFadeLevel ) + { + iModifyEffect->iFadeLevel = aFadeLevel; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's attack time value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetAttackTime( TInt aAttackTime ) + { + iModifyEffect->iAttackTime = aAttackTime; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's fade time value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetFadeTime( TInt aFadeTime ) + { + iModifyEffect->iFadeTime = aFadeTime; + } + +// --------------------------------------------------------------------------- +// Sets the modifiable effect's period value. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::SetPeriod( TInt aPeriod ) + { + iModifyEffect->iPeriod = aPeriod; + } + +// --------------------------------------------------------------------------- +// Creates all submenu items for a change effect state submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitChangeEffectStateSubmenuL( + CEikMenuPane* aMenuPane, + TInt aCommandId, + CHWRMHaptics* aHaptics ) + { + // get effect count + TInt effectCount = iPlayedEffectArray.Count(); + + // fill effect history data to submenu, if any data available + if ( effectCount ) + { + // there is data, hide "none found" + aMenuPane->SetItemDimmed( EHapticsTestChangeStateNoneFound, ETrue ); + + // make played effects visible in the submenu + CEikMenuPaneItem::SData data; + for ( TInt i = 0; i < effectCount; ++i ) + { + // buffer for effect name + HBufC8* effectName = HBufC8::NewL( aHaptics->MaxEffectNameLength() ); + TPtr8 namePtr = effectName->Des(); + + // effect name + if ( iPlayedEffectArray[i].iFileHandle > 0 && + iPlayedEffectArray[i].iEffectIndex > 0 ) + { + aHaptics->GetEffectName( iPlayedEffectArray[i].iFileHandle, + iPlayedEffectArray[i].iEffectIndex, + namePtr ); + } + else + { + namePtr.Append( KManualEffectName ); + } + + // insert data to submenu item + data.iText.Copy( *effectName ); + data.iCommandId = aCommandId; + data.iCascadeId = 0; + data.iFlags = 0; + data.iExtraText = KNullDesC; + + delete effectName; + + aMenuPane->AddMenuItemL( data ); + } + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the duration, which is currently in use +// in the duration modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitDurationSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct duration value + if ( iModifyEffect->iDuration == KEffectDuration1 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectDuration1, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iDuration == KEffectDuration5 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectDuration5, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iDuration == KEffectDuration10 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectDuration10, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iDuration == KEffectDuration30 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectDuration30, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iDuration == KEffectDuration60 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectDuration60, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the magnitude, which is currently in use +// in the magnitude modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitMagnitudeSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct magnitude value + if ( iModifyEffect->iMagnitude == KHWRMHapticsMinMagnitude ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectMagnitudeMin, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iMagnitude == KEffectMagnitude25 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectMagnitude25, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iMagnitude == KEffectMagnitude50 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectMagnitude50, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iMagnitude == KEffectMagnitude75 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectMagnitude75, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iMagnitude == KHWRMHapticsMaxMagnitude ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectMagnitudeMax, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the style, which is currently in use +// in the style modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitStyleSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct style value + if ( iModifyEffect->iStyle == CHWRMHaptics::EHWRMHapticsStyleSmooth ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectStyleSmooth, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iStyle == CHWRMHaptics::EHWRMHapticsStyleStrong ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectStyleStrong, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iStyle == CHWRMHaptics::EHWRMHapticsStyleSharp ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectStyleSharp, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the attack level, which is currently in use +// in the attack level modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitAttackLevelSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct attack level value + if ( iModifyEffect->iAttackLevel == KHWRMHapticsMinMagnitude ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackMin, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackLevel == KEffectMagnitude25 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttack25, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackLevel == KEffectMagnitude50 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttack50, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackLevel == KEffectMagnitude75 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttack75, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackLevel == KHWRMHapticsMaxMagnitude ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackMax, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the fade level, which is currently in use +// in the fade level modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitFadeLevelSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct fade level value + if ( iModifyEffect->iFadeLevel == KHWRMHapticsMinMagnitude ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeMin, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeLevel == KEffectMagnitude25 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFade25, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeLevel == KEffectMagnitude50 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFade50, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeLevel == KEffectMagnitude75 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFade75, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeLevel == KHWRMHapticsMaxMagnitude ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeMax, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the attack time, which is currently in use +// in the attack time modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitAttackTimeSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct attack time value + if ( iModifyEffect->iAttackTime == KEffectAttackTime02 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackTime02, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackTime == KEffectAttackTime1 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackTime1, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackTime == KEffectAttackTime5 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackTime5, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackTime == KEffectAttackTime10 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackTime10, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackTime == KEffectAttackTime30 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackTime30, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iAttackTime == KEffectAttackTime60 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectAttackTime60, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the fade time, which is currently in use +// in the fade time modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitFadeTimeSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct fade time value + if ( iModifyEffect->iFadeTime == KEffectFadeTime02 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeTime02, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeTime == KEffectFadeTime1 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeTime1, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeTime == KEffectFadeTime5 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeTime5, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeTime == KEffectFadeTime10 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeTime10, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeTime == KEffectFadeTime30 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeTime30, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iFadeTime == KEffectFadeTime60 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectFadeTime60, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// Creates the checkmark to the period, which is currently in use +// in the period modification submenu. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::DynInitPeriodSubmenu( + CEikMenuPane* aMenuPane ) const + { + // set check mark to correct period value + if ( iModifyEffect->iPeriod == KEffectPeriod50 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectPeriod50, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iPeriod == KEffectPeriod100 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectPeriod100, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iPeriod == KEffectPeriod300 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectPeriod300, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iPeriod == KEffectPeriod600 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectPeriod600, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iPeriod == KEffectPeriod1000 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectPeriod1000, + EEikMenuItemSymbolOn ); + } + else if ( iModifyEffect->iPeriod == KEffectPeriod3000 ) + { + aMenuPane->SetItemButtonState( + EHapticsTestModifyEffectPeriod3000, + EEikMenuItemSymbolOn ); + } + } + +// --------------------------------------------------------------------------- +// C++ constructor +// --------------------------------------------------------------------------- +// +CHapticsTestEffectDataHandler::CHapticsTestEffectDataHandler() + { + } + +// --------------------------------------------------------------------------- +// Second phase construction. +// --------------------------------------------------------------------------- +// +void CHapticsTestEffectDataHandler::ConstructL() + { + } + +// End of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/bwins/mt_hapticsclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/bwins/mt_hapticsclientu.def Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,2 @@ +EXPORTS + ?CreateTestSuiteL@@YAPAVMEUnitTest@@XZ @ 1 NONAME ; class MEUnitTest * __cdecl CreateTestSuiteL(void) diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/data/hwrmhapticsuid.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/data/hwrmhapticsuid.ini Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,8 @@ +// This file contains VIDs/SIDs which are allowed to use haptics license key auto setting. +// If SID is found from this list then related VID is omitted. +// For example, assuming SID 0x12345678 is allowed, add row (without slash signs): +//+ SID 0x12345678 + ++ VID 0x101FB657 //Nokia VID ++ SID 0x10003B20 //Window server ++ VID 0x70000013 //EUnit \ No newline at end of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/eabi/mt_hapticsclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/eabi/mt_hapticsclientu.def Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z16CreateTestSuiteLv @ 1 NONAME + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_PLATFORMS +ARMV5 WINSCW + +PRJ_EXPORTS +../data/hwrmhapticsuid.ini /epoc32/release/winscw/udeb/z/private/200184b9/hwrmhapticsuid.ini + +PRJ_MMPFILES +MT_HapticsClient.mmp + +// End of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/group/mt_hapticsclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/group/mt_hapticsclient.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +TARGET MT_HapticsClient.dll +TARGETTYPE dll +UID 0x1000af5a 0x01700000 + +CAPABILITY ALL -TCB -DRM +VENDORID VID_DEFAULT + + +// Sources required by the test suite +SOURCEPATH ../MT_HapticsClient +SOURCE mt_hapticsclient.cpp +SOURCE MT_HapticsClient_DllMain.cpp + +USERINCLUDE ../MT_HapticsClient + +OS_LAYER_LIBC_SYSTEMINCLUDE +OS_LAYER_SYSTEMINCLUDE + +LIBRARY EUnit.lib +LIBRARY EUnitUtil.lib +LIBRARY euser.lib +LIBRARY hwrmhapticsclient.lib + +SMPSAFE diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/group/mt_hapticslicense.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/group/mt_hapticslicense.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +TARGET MT_HapticsLicense.dll +TARGETTYPE dll +UID 0x1000af5a 0x01700000 + +CAPABILITY ALL -TCB -DRM +VENDORID VID_DEFAULT + + +// Sources required by the test suite + +SOURCEPATH ../MT_HapticsLicenseKey +SOURCE mt_hapticslicensekey.cpp +SOURCE MT_HapticsLicenseKey_DllMain.cpp + +USERINCLUDE ../MT_HapticsLicenseKey + +OS_LAYER_LIBC_SYSTEMINCLUDE +OS_LAYER_SYSTEMINCLUDE + +LIBRARY EUnit.lib +LIBRARY EUnitUtil.lib +LIBRARY euser.lib +LIBRARY hwrmhapticsclient.lib +LIBRARY hwrmhapticslicense.lib + +SMPSAFE diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/mt_hapticsclient/mt_hapticsclient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/mt_hapticsclient/mt_hapticsclient.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,5034 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "MT_HapticsClient.h" +#include +#include +#include + +// +// EUnit test log: \epoc32\winscw\c\shared\EUnit\Logs\EUnit_log.xml +// + +// --------------------------------------------------------- +// Couple of static TUint8 arrays containing bytes for simple +// timeline and magsweep effects (that are used in PlayEffect +// and PlayEffectRepeat method related tests below). +// These are obtained using VibeTonz Studio's export to C-file +// functionality. +// --------------------------------------------------------- +static const TUint8 Timeline4HapticsMT_ivt[] = +{ + 0x01, 0x00, 0x02, 0x00, 0x1c, 0x00, 0x28, 0x00, 0x00, 0x00, 0x07, 0x00, 0xf1, 0xe0, 0x01, 0xe2, + 0x00, 0x00, 0xff, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, + 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x12, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, + 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x67, 0x00, + 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x00, 0x00 +}; + +static const TUint8 Magsweep4HapticsMT_ivt[] = +{ + 0x01, 0x00, 0x01, 0x00, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x81, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, + 0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x00, 0x00 +}; + +static const TUint8 Periodic4HapticsMT_ivt[] = +{ + 0x01, 0x00, 0x01, 0x00, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, + 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x00, 0x00 +}; + +// | Object name | Type | Duration | Magnitude | Period | +//-------------------------------------------------------------- +// 1. | Timeline1 | Timeline | 3915 | | | +// 2. | Timeline2 | Timeline | 5806 | | | +// 3. | Periodic1 | Periodic | 1000 | 7480 | 100 | +// 4. | Periodic2 | Periodic | 2000 | 7480 | 100 | +// 5. | MagSweep1 | MagSweep | 3000 | 7480 | | +// 6. | MagSweep2 | MagSweep | 4000 | 7480 | | +// ------------------------------------------------------------- +static const TUint8 EffectSetMT_ivt[] = +{ + 0x01, 0x00, 0x06, 0x00, 0x66, 0x00, 0x84, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x1a, 0x00, 0x2a, 0x00, + 0x3a, 0x00, 0x4a, 0x00, 0xf1, 0xe0, 0x02, 0xe2, 0x00, 0x00, 0xf1, 0xe0, 0x04, 0xe2, 0x03, 0x93, + 0xff, 0xf1, 0xe0, 0x03, 0xe2, 0x00, 0x00, 0xf1, 0xe0, 0x05, 0xe2, 0x07, 0x0e, 0xff, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x7d, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x01, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0xbb, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x81, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0xfa, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x14, 0x00, 0x28, 0x00, 0x3c, 0x00, 0x50, 0x00, 0x64, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, + 0x65, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x31, 0x00, 0x00, 0x00, 0x54, 0x00, + 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x32, 0x00, + 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, + 0x63, 0x00, 0x31, 0x00, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, + 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x32, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x67, 0x00, + 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x31, 0x00, 0x00, 0x00, 0x4d, 0x00, + 0x61, 0x00, 0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x32, 0x00, + 0x00, 0x00 +}; + +static const TUint8 CorruptedMT_ivt[] = +{ + 0x00, 0x01, 0x01, 0x01, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, + 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x00, 0x00 +}; + +//offset value for +const TInt KEventOffset = 1000; + +// imaginary license key +_LIT8( KPlainKey, "73JJNDJ38EKDKD983783JDJD84U48DJ4" ); + +// --------------------------------------------------------- +// VibeStatus to S60 status mappings are tested by sending these +// special repeat values to server (calling PlayEffectRepeat). +// The test plugin will acknowledge these special values and +// returns corresponding VibeStatus error code.. +// --------------------------------------------------------- +// +enum repeat_values_4_vibestatustests + { + SUCCESS_TEST = 100, + ALREADY_INITIALIZED_TEST, + NOT_INITIALIZED_TEST, + INVALID_ARGUMENT_TEST, + FAIL_TEST, + INCOMPATIBLE_EFFECT_TYPE_TEST, + INCOMPATIBLE_CAPABILITY_TYPE_TEST, + INCOMPATIBLE_PROPERTY_TYPE_TEST, + DEVICE_NEEDS_LICENSE_TEST, + NOT_ENOUGH_MEMORY_TEST, + SERVICE_NOT_RUNNING_TEST, + INSUFFICIENT_PRIORITY_TEST, + SERVICE_BUSY_TEST, + WRN_NOT_PLAYING_TEST, + WRN_INSUFFICIENT_PRIORITY_TEST + }; + + +// - Haptics status callback implementation --------------------------------- +THapticsStatusCallback::THapticsStatusCallback( MT_HapticsClient* aMTCallback ) + : iHapticsStatus( MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + iMTCallback( aMTCallback ) + { + } + +THapticsStatusCallback::~THapticsStatusCallback() + { + } + +MHWRMHapticsObserver::THWRMHapticsStatus THapticsStatusCallback::Status() + { + return iHapticsStatus; + } + +// --------------------------------------------------------- +// from MHWRMHapticsObserver. Method which is called +// by the haptics client, when the haptics status of +// that client changes. +// --------------------------------------------------------- +// +void THapticsStatusCallback::HapticsStatusChangedL( THWRMHapticsStatus aStatus ) + { + iHapticsStatus = aStatus; + + // inform callback of new value + iMTCallback->HapticsStatusReceived(); + } + +// --------------------------------------------------------- +// from MHWRMHapticsObserver. Method is for future use, +// hence the empty implementation. +// --------------------------------------------------------- +// +void THapticsStatusCallback::EffectCompletedL( TInt /*aError*/, TInt /*aEffectHandle*/ ) + { + } + + +// - Actuator status callback implementation --------------------------------- +TActuatorStatusCallback::TActuatorStatusCallback( MT_HapticsClient* aMTCallback ) : iMTCallback( aMTCallback ) + { + } + +TActuatorStatusCallback::~TActuatorStatusCallback() + { + iActuatorStatus.Close(); + } + +MHWRMHapticsActuatorObserver::THWRMActuatorEvents TActuatorStatusCallback::Status( THWRMLogicalActuators aActuator ) + { + TInt index = iActuatorStatus.Find( aActuator ); + if ( index == KErrNotFound ) + { + return (MHWRMHapticsActuatorObserver::THWRMActuatorEvents)0; + } + return (MHWRMHapticsActuatorObserver::THWRMActuatorEvents)(iActuatorStatus[index+1]-KEventOffset); + } + +// --------------------------------------------------------- +// from MHWRMHapticsObserver. Method which is called +// by the haptics client, when the haptics status of +// that client changes. +// --------------------------------------------------------- +// +void TActuatorStatusCallback::ActuatorEventL( THWRMActuatorEvents aEvent, + THWRMLogicalActuators aActuator ) + { + TInt index = iActuatorStatus.Find( aActuator ); + if ( index == KErrNotFound ) + { + iActuatorStatus.Append( aActuator ); + iActuatorStatus.Append( aEvent + KEventOffset ); + } + else + { + iActuatorStatus.Remove( index ); + iActuatorStatus.Remove( index ); + iActuatorStatus.Append( aActuator ); + iActuatorStatus.Append( aEvent + KEventOffset ); + } + + // inform callback of new value + iMTCallback->HapticsStatusReceived(); + } + +// --------------------------------------------------------- +// MT_HapticsTestAsyncPlaySender methods +// --------------------------------------------------------- +// +MT_HapticsTestAsyncPlaySender::MT_HapticsTestAsyncPlaySender( + MT_HapticsClient* aMTCallback ) + : CActive( EPriorityStandard ), iMTCallback( aMTCallback ) + { + CActiveScheduler::Add( this ); + } + +MT_HapticsTestAsyncPlaySender::~MT_HapticsTestAsyncPlaySender() + { + } + +void MT_HapticsTestAsyncPlaySender::PlayRepeat( + CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TUint8 aRepeat, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ) + { + aClientStatus = KRequestPending; + iClientStatus = &aClientStatus; + aHaptics->PlayEffectRepeat( aFileHandle, + aEffectIndex, + aRepeat, + aEffectHandle, + iStatus ); + SetActive(); + } + +void MT_HapticsTestAsyncPlaySender::Play( + CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ) + { + aClientStatus = KRequestPending; + iClientStatus = &aClientStatus; + aHaptics->PlayEffect( aFileHandle, + aEffectIndex, + aEffectHandle, + iStatus ); + SetActive(); + } + +void MT_HapticsTestAsyncPlaySender::RunL() + { + *iClientStatus = iStatus.Int(); + iMTCallback->HapticsStatusReceived(); + } + +void MT_HapticsTestAsyncPlaySender::DoCancel() + { + } + +TInt MT_HapticsTestAsyncPlaySender::RunError( TInt /* aError */ ) + { + return KErrNone; + } + +// - Construction ----------------------------------------------------------- + +MT_HapticsClient* MT_HapticsClient::NewL() + { + MT_HapticsClient* self = MT_HapticsClient::NewLC(); + CleanupStack::Pop(); + return self; + } + +MT_HapticsClient* MT_HapticsClient::NewLC() + { + MT_HapticsClient* self = new( ELeave ) MT_HapticsClient(); + CleanupStack::PushL( self ); + self->ConstructL(); + return self; + } + +MT_HapticsClient::~MT_HapticsClient() + { + delete iSender; + } + +// --------------------------------------------------------- +// Method, which is called by the status callback, when a status +// has been received. Stops the wait loop waiting for a new status. +// --------------------------------------------------------- +// +void MT_HapticsClient::HapticsStatusReceived() + { + iWait.AsyncStop(); + } + +MT_HapticsClient::MT_HapticsClient() + { + } + +void MT_HapticsClient::ConstructL() + { + CEUnitTestSuiteClass::ConstructL(); + iSender = new ( ELeave ) MT_HapticsTestAsyncPlaySender( this ); + } + +// - Test methods ----------------------------------------------------------- + +// --------------------------------------------------------- +// Default test env construction +// --------------------------------------------------------- +// +void MT_HapticsClient::SetupL() + { + iHaptics = CHWRMHaptics::NewL( NULL, NULL ); + } + +// --------------------------------------------------------- +// Default test env destruction +// --------------------------------------------------------- +// +void MT_HapticsClient::Teardown() + { + if( iHaptics ) + { + delete iHaptics; + iHaptics = NULL; + } + } + +// --------------------------------------------------------- +// Empty method to be used in test case definition, when +// there is not need to do anything in setup and/or +// teardown. +// --------------------------------------------------------- +// +void MT_HapticsClient::Dummy() + { + // nothing done here + } + +// --------------------------------------------------------- +// Helper methods for creating various effects +// --------------------------------------------------------- +// +void MT_HapticsClient::CreateMagSweepEffect( CHWRMHaptics::THWRMHapticsMagSweepEffect& aEffect ) + { + aEffect.iDuration = 1000; + aEffect.iMagnitude = 5000; + aEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleSharp; + aEffect.iAttackTime = 0; + aEffect.iAttackLevel = 0; + aEffect.iFadeTime = 0; + aEffect.iFadeLevel = 0; + } + +void MT_HapticsClient::CreatePeriodicEffect( CHWRMHaptics::THWRMHapticsPeriodicEffect& aEffect ) + { + aEffect.iDuration = 1000; + aEffect.iMagnitude = 5000; + aEffect.iPeriod = 100; + aEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleSharp; + aEffect.iAttackTime = 0; + aEffect.iAttackLevel = 0; + aEffect.iFadeTime = 0; + aEffect.iFadeLevel = 0; + } + +void MT_HapticsClient::CreateIVTEffect( RBuf8& aBuffer, CHWRMHaptics::THWRMHapticsEffectTypes aType) + { + // Note: only magsweep and timeline IVT effects supported so far.. + switch ( aType ) + { + case CHWRMHaptics::EHWRMHapticsTypePeriodic: + { + aBuffer.ReAlloc( sizeof( Periodic4HapticsMT_ivt ) ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memcpy( tmpPtr, Periodic4HapticsMT_ivt, sizeof( Periodic4HapticsMT_ivt ) ); + aBuffer.SetLength( sizeof( Periodic4HapticsMT_ivt ) ); + break; + } + case CHWRMHaptics::EHWRMHapticsTypeMagSweep: + { + aBuffer.ReAlloc( sizeof( Magsweep4HapticsMT_ivt ) ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memcpy( tmpPtr, Magsweep4HapticsMT_ivt, sizeof( Magsweep4HapticsMT_ivt ) ); + aBuffer.SetLength( sizeof( Magsweep4HapticsMT_ivt ) ); + break; + } + case CHWRMHaptics::EHWRMHapticsTypeTimeline: + { + aBuffer.ReAlloc( sizeof( Timeline4HapticsMT_ivt ) ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memcpy( tmpPtr, Timeline4HapticsMT_ivt, sizeof( Timeline4HapticsMT_ivt ) ); + aBuffer.SetLength( sizeof( Timeline4HapticsMT_ivt ) ); + break; + } + default: + break; // no support for other types at the moment + } + } + + +void MT_HapticsClient::CreateDummyStreamSample( TInt aSize, RBuf8& aBuffer ) + { + aBuffer.ReAlloc( aSize ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memset( tmpPtr, 0x00, aSize ); + aBuffer.SetLength( aSize ); + } + +// --------------------------------------------------------- +// Open and close haptics client-server session, i.e. +// create and delete haptics client. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_CreateAndDeleteL() + { + // create iHaptics instance without observers + iHaptics = CHWRMHaptics::NewL( NULL, NULL ); + + // the connection has been opened successfully, if iHaptics is valid + EUNIT_ASSERT_DESC( iHaptics, "Haptics client creation failed!"); + + // the connection is closed, when iHaptics is deleted + delete iHaptics; + iHaptics = NULL; + } + +// --------------------------------------------------------- +// Create several simultaneous sessions to haptics server. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_SeveralSessionsL() + { + // create haptics instances without observers. This creates + // client-server sessions (session instances in the server) + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); //remove once CHWRMHaptics::NewLC() is used + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); //remove once CHWRMHaptics::NewLC() is used + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics3 ); //remove once CHWRMHaptics::NewLC() is used + + // the connection has been opened successfully, if instances are valid + EUNIT_ASSERT_DESC( haptics1, "First haptics client creation failed!"); + EUNIT_ASSERT_DESC( haptics2, "Second haptics client creation failed!"); + EUNIT_ASSERT_DESC( haptics3, "Third haptics client creation failed!"); + + // delete haptics instances. This removes the sessions from + // haptics server, and closes the server, when the last session + // is closed + CleanupStack::PopAndDestroy(3,haptics1); + //delete haptics1; haptics1 = NULL; + //delete haptics2; haptics2 = NULL; + //delete haptics3; haptics3 = NULL; + } + +// --------------------------------------------------------- +// Create several consecutive sessions to haptics server. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ConsecutiveSessionsL() + { + // Do create and delete three times in a row + T_CreateAndDeleteL(); + T_CreateAndDeleteL(); + T_CreateAndDeleteL(); + } + +// --------------------------------------------------------- +// Requests the supported actuators from haptics. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_SupportedActuators() + { + TUint32 actuators = 0; + TInt err = KErrNone; + err = iHaptics->SupportedActuators( actuators ); + + EUNIT_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" ); + EUNIT_ASSERT_DESC( actuators, "Actuators empty!"); + } + +// --------------------------------------------------------- +// Opens an actuator, which is supported by haptics. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_OpenSupportedActuator() + { + TUint32 actuators = 0; + TInt err = iHaptics->SupportedActuators( actuators ); + + // Open using first supported logical actuator type + if( EHWRMLogicalActuatorAny & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + } + else if( EHWRMLogicalActuatorDevice & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + } + else if( EHWRMLogicalActuatorPrimaryDisplay & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type PrimaryDisplay failed!" ); + } + else if( EHWRMLogicalActuatorSecondaryDisplay & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type SecondaryDisplay failed!" ); + } + else if( EHWRMLogicalActuatorGame & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Game failed!" ); + } + else if( EHWRMLogicalActuatorGameLeft & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type GameLeft failed!" ); + } + else if( EHWRMLogicalActuatorGameRight & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type GameRight failed!" ); + } + else if( EHWRMLogicalActuatorExternalVibra & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type ExternalVibra failed!" ); + } + } + +// --------------------------------------------------------- +// Attemps to open an actuator, which is NOT supported +// by haptics. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_OpenNotSupportedActuator() + { + TUint32 actuators = 0; + TInt err = iHaptics->SupportedActuators( actuators ); + + EUNIT_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" ); + + // Open using first NOT supported logical actuator type + if( !( EHWRMLogicalActuatorAny & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + } + else if( !( EHWRMLogicalActuatorDevice & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + } + else if( !( EHWRMLogicalActuatorPrimaryDisplay & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) ); + } + else if( !( EHWRMLogicalActuatorSecondaryDisplay & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) ); + } + else if( !( EHWRMLogicalActuatorGame & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) ); + } + else if( !( EHWRMLogicalActuatorGameLeft & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) ); + } + else if( !( EHWRMLogicalActuatorGameRight & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) ); + } + else if( !( EHWRMLogicalActuatorExternalVibra & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) ); + } + + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Invalid error code value!" ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Opening unsupported actuator succeeded!" ); + } + +// --------------------------------------------------------- +// Attemps to open actuators, using all available logical +// actuator types. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_OpenAllActuators() + { + TInt actuatorMask = EHWRMLogicalActuatorPrimaryDisplay | EHWRMLogicalActuatorSecondaryDisplay; + + TRAPD( err, iHaptics->OpenActuatorL( (THWRMLogicalActuators)actuatorMask ) ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Opening actuator with several type mask succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type PrimaryDisplay succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type SecondaryDisplay succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type Game succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type GameLeft succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type GameRight succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + EUNIT_ASSERT_DESC( (err == KErrAlreadyExists), "Opening actuator with type Any; wrong error code" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Opening actuator with type Device; wrong error code" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Opening actuator with type ExternalVibra; wrong error code!" ); + } + +// --------------------------------------------------------- +// Creates a couple of haptic client instances, and opens +// actuators in both of them. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_SeveralClientsWithOpenActuatorsL() + { + // create first haptics client instance + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + // create second haptics client instance + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + // fetch supported actuator types + TUint32 actuators = 0; + TInt err = haptics1->SupportedActuators( actuators ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" ); + + // open actuators for both instances using supported types + if( EHWRMLogicalActuatorAny & actuators ) + { + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + } + else + { + EUNIT_ASSERT_DESC( EFalse, "Actuator type Any not supported!" ); + } + + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Plays a magsweep effect using synchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayMagSweepEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effect; + CreateMagSweepEffect( effect ); + + // play effect + TInt effectHandle; + TInt err = iHaptics->PlayMagSweepEffect( effect, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect synchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing magsweep effect synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect synchronously failed! (StopAllPlayingEffects)" ); + } + + +// --------------------------------------------------------- +// Plays a magsweep effect using asynchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayMagSweepEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effect; + CreateMagSweepEffect( effect ); + + // play effect + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayMagSweepEffect( effect, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing magsweep effect asynchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing magsweep effect asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + TInt err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect asynchronously failed! (StopAllPlayingEffects)" ); + + } + + +// --------------------------------------------------------- +// Plays a periodic effect using synchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayPeriodicEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsPeriodicEffect effect; + CreatePeriodicEffect( effect ); + + // play effect + TInt effectHandle; + TInt err = iHaptics->PlayPeriodicEffect( effect, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing periodic effect synchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing periodic effect returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing periodic effect synchronously failed! (StopAllPlayingEffects)" ); + } + +// --------------------------------------------------------- +// Plays a periodic effect using synchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayPeriodicEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsPeriodicEffect effect; + CreatePeriodicEffect( effect ); + + // play effect + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayPeriodicEffect( effect, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing periodic effect asynchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing periodic effect asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + TInt err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing periodic effect asynchronously failed! (StopAllPlayingEffects)" ); + + } + + +// --------------------------------------------------------- +// Plays an IVT effect using synchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectWithDirectDataSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect + TInt effectHandle; + TInt err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playingeffect IVT synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" ); + + } + +// --------------------------------------------------------- +// Plays an IVT effect using asynchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectWithDirectDataAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play effect + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffect( effBuf, 0, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect asynchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" ); + + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using synchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectRepeatWithDirectDataSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play the effect (repeat 2 times) + TInt effectHandle; + TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" ); + + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using asynchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectRepeatWithDirectDataAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play effect (repeat 2 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect repeatedly asynchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + + } + +// --------------------------------------------------------- +// Gets the effect state while an effect: +// a) is being played +// b) has been paused +// c) has been completed (i.e., is not playing any more) +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetEffectState() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effect; + CreateMagSweepEffect( effect ); + + // play effect + TInt effectHandle; + TInt err = iHaptics->PlayMagSweepEffect( effect, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (playing returned error)" ); + EUNIT_ASSERT_DESC( effectHandle, "GetEffectState failed! (empty effect handle)" ); + + // get state + TInt effectState; + err = iHaptics->GetEffectState( effectHandle, effectState ); + EUNIT_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (1st call)" ); + EUNIT_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectPlaying), "GetEffectState failed! (1st call - wrong state)" ); + + // pause the effect and get state + err = iHaptics->PausePlayingEffect( effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (Pause)" ); + + err = iHaptics->GetEffectState( effectHandle, effectState ); + EUNIT_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (2nd call)" ); + EUNIT_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectPaused), "GetEffectState failed! (2nd call - wrong state)" ); + + // stop the effect and get state again + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (StopAllPlayingEffects)" ); + + err = iHaptics->GetEffectState( effectHandle, effectState ); + EUNIT_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (3rd call)" ); + EUNIT_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectNotPlaying), "GetEffectState failed! (3rd call - wrong state)" ); + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using synchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// Since the effect in question is not a timeline effect (in +// this test we use magsweep effect instead), the effect is +// played only once. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect (try to repeat 2 times.. in practice will only repeat once + // due to the effect being non timeline effect) + TInt effectHandle; + TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly synchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect (non-timeline) repeatedly synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly synchronously failed! (StopAllPlayingEffects)" ); + + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using asynchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// Since the effect in question is not a timeline effect (in +// this test we use magsweep effect instead), the effect is +// played only once. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect (try to repeat 2 times.. in practice will only repeat once + // due to the effect being non timeline effect) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect (non-timeline) repeatedly asynchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect (non-timeline) repeatedly asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + + } + +void MT_HapticsClient::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play the effect (repeat 0 times) + TInt effectHandle; + TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) synchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly (zero repeats) synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) synchronously failed! (StopAllPlayingEffects)" ); + + } + + +void MT_HapticsClient::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play effect (repeat 0 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 0, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect repeatedly (zero repeats) asynchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly (zero repeats) asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) asynchronously failed! (StopAllPlayingEffects)" ); + + } + + +// --------------------------------------------------------- +// Loading IVT data +// --------------------------------------------------------- +// +TInt MT_HapticsClient::LoadIVTDataInternal( TInt& aFileHandle, + CHWRMHaptics::THWRMHapticsEffectTypes aType, + TBool aOpenActuator ) + { + // NOTE: we can use the same IVT data as was used in previous "call PlayXXXEffect() + // with direct data cases (i.e., there's no need e.g. to read data from file..) + + // open actuator.. + if ( aOpenActuator ) + { + T_OpenSupportedActuator(); + } + + // read effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, aType ); + + TInt retVal = iHaptics->LoadEffectData( effBuf, aFileHandle ); + + CleanupStack::PopAndDestroy(); // effBuf + return retVal; + } + +TInt MT_HapticsClient::LoadIVTDataInternal( TInt& aFileHandle, + const TUint8 aIvtData[], + TInt aIvtDataSize, + TBool aOpenActuator ) + { + // open actuator.. + if ( aOpenActuator ) + { + T_OpenSupportedActuator(); + } + + // read effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + effBuf.ReAlloc( aIvtDataSize ); + TUint8* tmpPtr = const_cast( effBuf.Ptr() ); + memcpy( tmpPtr, aIvtData, aIvtDataSize ); + effBuf.SetLength( aIvtDataSize ); + + TInt retVal = iHaptics->LoadEffectData( effBuf, aFileHandle ); + + CleanupStack::PopAndDestroy(); // effBuf + return retVal; + } + +void MT_HapticsClient::T_LoadIVTData() + { + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (LoadIVTData case)" ); + } + + +// --------------------------------------------------------- +// Deleting previously loaded IVT data by calling DeleteIVTData +// --------------------------------------------------------- +// +void MT_HapticsClient::T_DeleteIVTData() + { + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (DeleteIVTData case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (DeleteIVTData case)!" ); + + err = iHaptics->DeleteEffectData( fileHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + } + + +// --------------------------------------------------------- +// Deleting previously loaded IVT data by calling DeleteAllIVTData +// instead of DeleteIVTData +// --------------------------------------------------------- +// +void MT_HapticsClient::T_DeleteAllIVTData() + { + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (DeleteAllIVTData case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (DeleteAllIVTData case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_LoadAndDeleteIVTData() + { + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // delete each IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle1 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + err = iHaptics->DeleteEffectData( fileHandle2 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + err = iHaptics->DeleteEffectData( fileHandle3 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // reload IVT-data + fileHandle1 = KErrNotFound; + fileHandle2 = KErrNotFound; + fileHandle3 = KErrNotFound; + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data (mixed order). +// --------------------------------------------------------- +// +void MT_HapticsClient::T_LoadAndDeleteIVTDataMixed() + { + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // delete second IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle2 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // load third IVT-data once more (filehandle should not change) + TInt newHandle = KErrNotFound; + err3 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + EUNIT_ASSERT_DESC( (fileHandle3 == newHandle), "Received incorrect filehandle!" ); + + // load second IVT-data once more (filehandle should change) + newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + fileHandle1 = KErrNotFound; + fileHandle2 = KErrNotFound; + fileHandle3 = KErrNotFound; + + // reload IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the synchronous play-method. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_LoadDeletePlaySync() + { + TInt effectHandle = 0; + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + TInt err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete second IVT-data + err = iHaptics->DeleteEffectData( fileHandle2 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the asynchronous play-method. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_LoadDeletePlayAsync() + { + TRequestStatus status1 = KRequestPending; + TRequestStatus status2 = KRequestPending; + TRequestStatus status3 = KRequestPending; + + TInt effectHandle = 0; + + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + // iHaptics->PlayEffect( fileHandle1, 0, effectHandle, status1 ); + // LoopForCompletion( status1 ); + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status1 == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete second IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle2 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + status2 = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status1.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status3.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the synchronous PlayRepeat-method. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_LoadDeletePlayRepeatSync() + { + TInt effectHandle = 0; + TInt repeat = 2; + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + TInt err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete second IVT-data + err = iHaptics->DeleteEffectData( fileHandle2 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the asynchronous PlayRepeat-method. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_LoadDeletePlayRepeatAsync() + { + TRequestStatus status1 = KRequestPending; + TRequestStatus status2 = KRequestPending; + TRequestStatus status3 = KRequestPending; + + TInt effectHandle = 0; + TInt repeat = 7; + + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete second IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle2 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + status2 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status1.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status3.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + EUNIT_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + EUNIT_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + EUNIT_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + EUNIT_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + } + + +// --------------------------------------------------------- +// Playing the previously loaded IVT data (synchronous version) +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectWithLoadedDataSynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // play the effect.. + TInt effectHandle; + err = iHaptics->PlayEffect( fileHandle, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" ); + + } + + +// --------------------------------------------------------- +// Playing the previously loaded IVT data (asynchronous version) +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectWithLoadedDataAsynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" ); + + // play the effect.. + TInt effectHandle; + TRequestStatus status = KRequestPending; + iSender->Play( iHaptics, fileHandle, 0, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing asynchronously case))" ); + + } + + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (synchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectRepeatWithLoadedDataSynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" ); + + // play the effect repeatedly (repeated 3 times) + TInt effectHandle; + err = iHaptics->PlayEffectRepeat( fileHandle, 0, 3, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT synchronously case))" ); + + } + + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (asynchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectRepeatWithLoadedDataAsynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" ); + + // play the effect (repeated 5 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, 5, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT asynchronously case))" ); + + } + +// --------------------------------------------------------- +// VibeStatus to S60 status conversions +// --------------------------------------------------------- +// +void MT_HapticsClient::T_VibeStatusToS60StatusConversions() + { + // this is a bit ugly, i.e., we're using special repeat + // values and then the test adaptation stub acknowledges + // these special value and repeats accordingly with some + // (Vibe-error) status + + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Status conversion case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Status conversion case)!" ); + + // the actual status conversion cases (done with special repeat values + // using PlayIVTEffectRepeat) + TInt dummyEffectHandle; // we're not interested about this in these cases + // first the synch cases.. + err = iHaptics->PlayEffectRepeat( fileHandle, 0, SUCCESS_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Status conversion subcase SUCCESS_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, ALREADY_INITIALIZED_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrAlreadyExists), "Status conversion subcase ALREADY_INITIALIZED_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, NOT_INITIALIZED_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNotReady), "Status conversion subcase NOT_INITIALIZED_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INVALID_ARGUMENT_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Status conversion subcase INVALID_ARGUMENT_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, FAIL_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrGeneral), "Status conversion subcase FAIL_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_EFFECT_TYPE_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_EFFECT_TYPE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_CAPABILITY_TYPE_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_CAPABILITY_TYPE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_PROPERTY_TYPE_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_PROPERTY_TYPE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, DEVICE_NEEDS_LICENSE_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrAccessDenied), "Status conversion subcase DEVICE_NEEDS_LICENSE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, NOT_ENOUGH_MEMORY_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNoMemory), "Status conversion subcase NOT_ENOUGH_MEMORY_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, SERVICE_NOT_RUNNING_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNotReady), "Status conversion subcase SERVICE_NOT_RUNNING_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrAccessDenied), "Status conversion subcase INSUFFICIENT_PRIORITY_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, SERVICE_BUSY_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Status conversion subcase SERVICE_BUSY_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, WRN_NOT_PLAYING_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Status conversion subcase WRN_NOT_PLAYING_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, WRN_INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Status conversion subcase WRN_INSUFFICIENT_PRIORITY_TEST failed (synch)!" ); + + // then the asycnh cases + TRequestStatus status; + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, SUCCESS_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Status conversion subcase SUCCESS_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, ALREADY_INITIALIZED_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrAlreadyExists), "Status conversion subcase ALREADY_INITIALIZED_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, NOT_INITIALIZED_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNotReady), "Status conversion subcase NOT_INITIALIZED_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INVALID_ARGUMENT_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrArgument), "Status conversion subcase INVALID_ARGUMENT_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, FAIL_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrGeneral), "Status conversion subcase FAIL_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_EFFECT_TYPE_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_EFFECT_TYPE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_CAPABILITY_TYPE_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_CAPABILITY_TYPE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_PROPERTY_TYPE_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_PROPERTY_TYPE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, DEVICE_NEEDS_LICENSE_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrAccessDenied), "Status conversion subcase DEVICE_NEEDS_LICENSE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, NOT_ENOUGH_MEMORY_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNoMemory), "Status conversion subcase NOT_ENOUGH_MEMORY_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, SERVICE_NOT_RUNNING_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNotReady), "Status conversion subcase SERVICE_NOT_RUNNING_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrAccessDenied), "Status conversion subcase INSUFFICIENT_PRIORITY_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, SERVICE_BUSY_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse), "Status conversion subcase SERVICE_BUSY_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, WRN_NOT_PLAYING_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrArgument), "Status conversion subcase WRN_NOT_PLAYING_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, WRN_INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Status conversion subcase WRN_INSUFFICIENT_PRIORITY_TEST failed (asynch)!" ); + } + +// --------------------------------------------------------- +// Load multiple IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_LoadMultipleIVTData() + { + TInt fileHandle; + TInt prevFileHandle; + + // load the IVT data + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Load multiple IVT-data case)!" ); + prevFileHandle = fileHandle; + + // load the IVT data + fileHandle = 0; + err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline ,EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" ); + EUNIT_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Load multiple IVT-data case)!" ); + EUNIT_ASSERT_DESC( fileHandle!=prevFileHandle, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // try to load the same IVT data as before + fileHandle = 0; + err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" ); + EUNIT_ASSERT_DESC( fileHandle == prevFileHandle, "Loading IVT data failed, wrong fileHandle (Load multiple IVT-data case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" ); + } + +// --------------------------------------------------------- +// Playing from multiple IVT data (synchronous version) +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectsFromMultipleIVTDataSynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // play the effect.. + TInt effectHandle; + err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect.. + effectHandle = 0; + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect.. + effectHandle = 0; + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect.. + effectHandle = 0; + TInt unknownFileHandle = 3; + err = iHaptics->PlayEffect( unknownFileHandle, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing loaded IVT data failed, not bad handle (synch)!" ); + EUNIT_ASSERT_DESC( !effectHandle, "Playing loaded IVT data failed, not empty effectHandle (synch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" ); + + } + +// --------------------------------------------------------- +// Playing the previously loaded IVT data (asynchronous version) +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectsFromMultipleIVTDataAsynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" ); + + // play the effect.. + TInt effectHandle; + TRequestStatus status = KRequestPending; + + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect.. + effectHandle = 0; + status = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect.. + effectHandle = 0; + status = KRequestPending; + TInt unknownFileHandle = 3; + iSender->Play( iHaptics, unknownFileHandle, 0, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrBadHandle), "Playing loaded IVT data failed, not bad handle (asynch)!" ); + EUNIT_ASSERT_DESC( !effectHandle, "Playing loaded IVT data failed, not empty effectHandle (asynch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing asynchronously case))" ); + + } + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (synchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" ); + + // play the effect repeatedly (repeated 3 times) + TInt effectHandle; + err = iHaptics->PlayEffectRepeat( fileHandle1, 0, 3, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect repeatedly (repeated 3 times) + effectHandle = 0; + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, 3, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect repeatedly (repeated 3 times) + effectHandle = 0; + TInt unknownFileHandle = 3; + err = iHaptics->PlayEffectRepeat( unknownFileHandle, 0, 3, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Playing repeatedly loaded IVT data failed, not bad handle (synch)!" ); + EUNIT_ASSERT_DESC( !effectHandle, "Playing repeatedly loaded IVT data failed, not empty effectHandle (synch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT synchronously case))" ); + + } + + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (asynchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" ); + + // play the effect (repeated 5 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + + iSender->PlayRepeat( iHaptics, fileHandle1, 0, 5, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect (repeated 5 times) + effectHandle = 0; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, 5, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect (repeated 5 times) + effectHandle = 0; + status = KRequestPending; + TInt unknownFileHandle = 3; + iSender->PlayRepeat( iHaptics, unknownFileHandle, 0, 5, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrBadHandle), "Playing repeatedly loaded IVT data failed, not bad handle (asynch)!" ); + EUNIT_ASSERT_DESC( !effectHandle, "Playing repeatedly loaded IVT data failed, not empty effectHandle (asynch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT asynchronously case))" ); + } + +// --------------------------------------------------------- +// Releasing previously reserved haptics +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ReserveAndReleaseHaptics() + { + // reserve + TRAPD( err, iHaptics->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Release haptics case failed (ReserveHapticsL leaves)!" ); + + // release (does not return an error code) + iHaptics->ReleaseHaptics(); + } + +// --------------------------------------------------------- +// Reserving haptics several (in this case three) times +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ReserveHapticsSeveralTimes() + { + TRAPD( err, iHaptics->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics (1st call) failed!" ); + TRAP( err, iHaptics->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics (2nd call) failed!" ); + TRAP( err, iHaptics->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics (3rd call) failed!" ); + } + +// --------------------------------------------------------- +// Reserving haptics +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ReserveHapticsNoReleaseL() + { + // create first haptics instance + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + // reserve + TRAPD( err, haptics1->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // create second haptics instance and open actuator + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // play an effect using second client (should fail because + // of reservation) + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TInt effectHandle = 0; + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although server reserved!" ); + + // destroy first client --> should release reservation + CleanupStack::PopAndDestroy( haptics1 ); + + // play an effect using second client (should succeed, since no + // reservation) + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed (no reservation)!" ); + + // cleanup + effBuf.Close(); + delete haptics2; + } + +// --------------------------------------------------------- +// Releasing haptics when it has not been previously reserved +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ReleaseHapticsWithoutReservingFirst() + { + // no return values nor leave to check, just execute + iHaptics->ReleaseHaptics(); + } + +// --------------------------------------------------------- +// Tries to reserve haptics with forceNoCoeEnv flag on. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ReserveNoAutomaticFocusNotTrusted() + { + TRAPD( err, iHaptics->ReserveHapticsL( ETrue ) ); + EUNIT_ASSERT_DESC( (err == KErrAccessDenied), "Reservation succeeded although not a trusted client!" ); + } + +// --------------------------------------------------------- +// Tries to reserve haptics, when it has already been +// reserved for another client with higher priority. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ReserveAlreadyReservedHigherL() + { + // create haptics instances and open actuators + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set first client priority (max) + haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + + // reserve + TRAP( err, haptics1->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // set second client priority (min) + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + + // reserve + TRAP( err, haptics2->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // play effect using the second client + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TInt effectHandle = 0; + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release first client's reservation + haptics1->ReleaseHaptics(); + + // play effect using the second client + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release second client's reservation + haptics2->ReleaseHaptics(); + + // cleanup + effBuf.Close(); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Tries to reserve haptics, when it has already been +// reserved for another client with lower priority. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ReserveAlreadyReservedLowerL() + { + // create haptics instances and open actuators + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set first client priority (min) + haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + + // reserve + TRAP( err, haptics1->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // set second client priority (max) + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + + // reserve + TRAP( err, haptics2->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // play effect using first client + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TInt effectHandle = 0; + err = haptics1->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // play effect using second client + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release second client + haptics2->ReleaseHaptics(); + + // play effect using first client + err = haptics1->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // play effect using second client + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release first client + haptics1->ReleaseHaptics(); + + // cleanup + effBuf.Close(); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Tries to play effects, when haptics has been reserved +// for a higher priority client. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayWhenReservedL() + { + // create haptics instances and open actuators + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set first client priority (max) + haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + + // reserve for first client + TRAP( err, haptics1->ReserveHapticsL() ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // set second client priority (min) + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + + // play effects using second client, when reserved for the first + // ---> + + // create effect data for playing effect directly using IVT-data + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // load the IVT data for playing effects using filehandle + TInt fileHandle = 0; + err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed!" ); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect magSweepEffect; + CreateMagSweepEffect( magSweepEffect ); + + // create a periodic effect + CHWRMHaptics::THWRMHapticsPeriodicEffect periodicEffect; + CreatePeriodicEffect( periodicEffect ); + + TInt effectHandle = 0; + TRequestStatus status = KRequestPending; + + // synchronous play with data + err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous play-repeat with data + err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play with data + status = KRequestPending; + iHaptics->PlayEffect( effBuf, 0, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play-repeat with data + status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous play with filehandle + err = iHaptics->PlayEffect( fileHandle, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous play-repeat with filehandle + err = iHaptics->PlayEffectRepeat( fileHandle, 0, 2, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play with filehandle + status = KRequestPending; + iSender->Play( iHaptics, fileHandle, 0, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play-repeat with filehandle + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, 2, effectHandle, status ); + iWait.Start(); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous manual magsweep + err = iHaptics->PlayMagSweepEffect( magSweepEffect, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous manual periodic + err = iHaptics->PlayPeriodicEffect( periodicEffect, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous manual magsweep + status = KRequestPending; + iHaptics->PlayMagSweepEffect( magSweepEffect, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous manual periodic + status = KRequestPending; + iHaptics->PlayPeriodicEffect( periodicEffect, effectHandle, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // <--- + + // cleanup + effBuf.Close(); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Getting effect count from preloaded IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetIVTEffectCount() + { + TInt fileHandle1; + TInt fileHandle2; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" ); + EUNIT_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" ); + + // load the IVT effect set 2 + err = LoadIVTDataInternal( fileHandle2, Magsweep4HapticsMT_ivt, + sizeof( Magsweep4HapticsMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" ); + EUNIT_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" ); + + + TInt effectCount; + // get effect count from IVT-data 1 + err = iHaptics->GetEffectCount( fileHandle1, effectCount ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect count failed (GetIVTEffectCount case)!" ); + EUNIT_ASSERT_DESC( (effectCount == 6), "Wrong effect count (GetIVTEffectCount case)!" ); + + // get effect count from corrupted IVT-data + err = iHaptics->GetEffectCount( corruptedFile, effectCount ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Get count from corrupted IVT-data, incorrect error code (GetIVTEffectCount case)!" ); + + // get effect count from IVT-data 2 + err = iHaptics->GetEffectCount( fileHandle2, effectCount ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect count failed (GetIVTEffectCount case)!" ); + EUNIT_ASSERT_DESC( (effectCount == 1), "Wrong effect count (GetIVTEffectCount case)!" ); + + // get effect count using unknown file handle + err = iHaptics->GetEffectCount( unknownFileHandle, effectCount ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectCount case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectCount case))" ); + } + +// --------------------------------------------------------- +// Getting effect duration from preloaded IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetIVTEffectDuration() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectDuration case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + EUNIT_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectDuration case)!" ); + + TInt effectDuration; + // duration of the last effect + TInt index = 5; + err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get duration failed (GetIVTEffectDuration case)!" ); + EUNIT_ASSERT_DESC( (effectDuration == 4000), "Wrong duration (GetIVTEffectDuration case)!" ); + + // get duration using effect index out of bounds + index = 6; + err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get duration succeeded (GetIVTEffectDuration case)!" ); + + // get duration from corrupted IVT-data + index = 0; err = KErrNone; + err = iHaptics->GetEffectDuration( corruptedFile, index, effectDuration ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Get duration from corrupted data, incorrect error code (GetIVTEffectDuration case)!" ); + + // duration of the first effect + index = 0; + err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get duration failed (GetIVTEffectDuration case)!" ); + EUNIT_ASSERT_DESC( (effectDuration == 3915), "Wrong duration (GetIVTEffectDuration case)!" ); + + // get duration using unknown file handle + index = 0; + err = iHaptics->GetEffectDuration( unknownFileHandle, index, effectDuration ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectDuration case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectDuration case))" ); + } + +// --------------------------------------------------------- +// Getting effect index from preloaded IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetIVTEffectIndexFromName() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetEffectIndexFromName case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetEffectIndexFromName case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetEffectIndexFromName case)!" ); + EUNIT_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetEffectIndexFromName case)!" ); + + + TInt effectIndex; + _LIT8( KFirstName, "Timeline1" ); + _LIT8( KLastName, "MagSweep2" ); + _LIT8( KUnknownName, "Tiline1" ); + TBuf8<128> effectName; + + // get index of the first name + effectName = KFirstName; + err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect index failed (GetEffectIndexFromName case)!" ); + EUNIT_ASSERT_DESC( (effectIndex == 0), "Wrong effect index (GetEffectIndexFromName case)!" ); + + // get index of the last name + effectName = KLastName; + err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect index failed (GetEffectIndexFromName case)!" ); + EUNIT_ASSERT_DESC( (effectIndex == 5), "Wrong effect index (GetEffectIndexFromName case)!" ); + + // get index from corrupted IVT-data + effectName = KFirstName; + err = iHaptics->GetEffectIndexFromName( corruptedFile, effectName, effectIndex ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Get effect index from corrupted data, incorrect error code (GetEffectIndexFromName case)!" ); + + // get index using unknown name + effectName = KUnknownName; + err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get effect succeeded (GetEffectIndexFromName case)!" ); + + // get index using unknown file handle + effectName = KUnknownName; + err = iHaptics->GetEffectIndexFromName( unknownFileHandle, effectName, effectIndex ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetEffectIndexFromName case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetEffectIndexFromName case))" ); + } + + +// --------------------------------------------------------- +// Getting effect type from preloaded IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetIVTEffectType() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectType case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectType case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectType case)!" ); + EUNIT_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectType case)!" ); + + + // get type of the first effect + TInt effectType; + TInt effectIndex = 0; + err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect type failed (GetIVTEffectType case)!" ); + EUNIT_ASSERT_DESC( (effectType == CHWRMHaptics::EHWRMHapticsTypeTimeline), "Wrong effect type (GetIVTEffectType case)!" ); + + // get type from corrupted IVT-data + effectIndex = 5; + err = iHaptics->GetEffectType( corruptedFile, effectIndex, effectType ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Get effect type from corrupted data, incorrect error code (GetIVTEffectType case)!" ); + + // get type of the last effect + effectIndex = 5; + err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect type failed (GetIVTEffectType case)!" ); + EUNIT_ASSERT_DESC( (effectType == CHWRMHaptics::EHWRMHapticsTypeMagSweep), "Wrong effect type (GetIVTEffectType case)!" ); + + // get type using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get effect type succeeded (GetIVTEffectType case)!" ); + + // get type using unknown file handle + effectIndex = 6; + err = iHaptics->GetEffectType( unknownFileHandle, effectIndex, effectType ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectType case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectType case))" ); + } + +// --------------------------------------------------------- +// Getting effect name from preloaded IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetIVTEffectName() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectName case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + EUNIT_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectName case)!" ); + + + // get name of the first effect + TBuf8<128> effectName; + TInt effectIndex = 0; + _LIT8( KTimeline1, "Timeline1" ); + _LIT8( KMagSweep2, "MagSweep2" ); + err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect name failed (GetIVTEffectName case)!" ); + EUNIT_ASSERT_DESC( (effectName == KTimeline1), "Wrong effect name (GetIVTEffectName case)!" ); + + // get name from corrupted IVT-data + effectIndex = 0; + err = iHaptics->GetEffectName( corruptedFile, effectIndex, effectName ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Get effect name from corrupted data, incorrect error code (GetIVTEffectName case)!" ); + + // get name of the last effect + effectIndex = 5; + err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect name failed (GetIVTEffectName case)!" ); + EUNIT_ASSERT_DESC( (effectName == KMagSweep2), "Wrong effect name (GetIVTEffectType case)!" ); + + // get name using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get effect name succeeded (GetIVTEffectName case)!" ); + + // get name using unknown file handle + effectIndex = 0; + err = iHaptics->GetEffectName( unknownFileHandle, effectIndex, effectName ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectName case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectName case))" ); + } + +// --------------------------------------------------------- +// Getting MagSweep effect definition from preloaded IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetIVTMagSweepEffectDefinition() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTMagSweepEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTMagSweepEffectDefinition case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTMagSweepEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTMagSweepEffectDefinition case)!" ); + + + // get definition of the first MagSweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effectDefinition; + TInt effectIndex = 4; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTMagSweepEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( (effectDefinition.iDuration == 3000), "Wrong effect definition (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition from corrupted IVT-data + effectIndex = 0; + err = iHaptics->GetMagSweepEffectDefinition( corruptedFile, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Get effect definition from corrupted data, incorrect error code (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition of the last MagSweep effect + effectIndex = 5; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTMagSweepEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( (effectDefinition.iDuration == 4000), "Wrong effect definition (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition using effect index not pointing to MagSweep effect + effectIndex = 2; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition using unknown file handle + effectIndex = 0; + err = iHaptics->GetMagSweepEffectDefinition( unknownFileHandle, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTMagSweepEffectDefinition case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTMagSweepEffectDefinition case))" ); + } + +// --------------------------------------------------------- +// Getting Periodic effect definition from preloaded IVT-data +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetIVTPeriodicEffectDefinition() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTPeriodicEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTPeriodicEffectDefinition case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTPeriodicEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTPeriodicEffectDefinition case)!" ); + + + // get definition of the first Periodic effect + CHWRMHaptics::THWRMHapticsPeriodicEffect effectDefinition; + TInt effectIndex = 2; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTPeriodicEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( (effectDefinition.iDuration == 1000), "Wrong effect definition (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition from corrupted IVT-data + effectIndex = 0; + err = iHaptics->GetPeriodicEffectDefinition( corruptedFile, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Get effect definition from corrupted data, incorrect error code (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition of the last Periodic effect + effectIndex = 3; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTPeriodicEffectDefinition case)!" ); + EUNIT_ASSERT_DESC( (effectDefinition.iDuration == 2000), "Wrong effect definition (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition using effect index not pointing to Periodic effect + effectIndex = 5; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition using unknown file handle + effectIndex = 0; + err = iHaptics->GetPeriodicEffectDefinition( unknownFileHandle, effectIndex, effectDefinition ); + EUNIT_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTPeriodicEffectDefinition case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + EUNIT_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTPeriodicEffectDefinition case))" ); + } + +// --------------------------------------------------------- +// Open asynchronously and close haptics client-server session, i.e. +// create and delete haptics client. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_CreateAndDeleteAsynchronousL() + { + // create iHaptics instance without observers + TRequestStatus status; + iHaptics = CHWRMHaptics::NewL( NULL, NULL, status ); + User::WaitForRequest( status ); + + // the connection has been opened successfully, if iHaptics is valid and + // error code is not returned + EUNIT_ASSERT_DESC( status == KErrNone, "Haptics client creation failed!"); + EUNIT_ASSERT_DESC( iHaptics, "Haptics client creation failed!"); + + // the connection is closed, when iHaptics is deleted + delete iHaptics; + iHaptics = NULL; + } + +// --------------------------------------------------------- +// Create several simultaneous sessions to haptics server +// asynchronously. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_SeveralSessionsAsynchronousL() + { + // create haptics instances without observers. This creates + // client-server sessions (session instances in the server) + TRequestStatus status1; + TRequestStatus status2; + TRequestStatus status3; + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL, status1 ); + CleanupStack::PushL( haptics1 ); //remove once CHWRMHaptics::NewLC() is used + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL, status2 ); + CleanupStack::PushL( haptics2 ); //remove once CHWRMHaptics::NewLC() is used + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL, status3 ); + CleanupStack::PushL( haptics3 ); //remove once CHWRMHaptics::NewLC() is used + User::WaitForRequest( status1 ); + User::WaitForRequest( status2 ); + User::WaitForRequest( status3 ); + + // the connection has been opened successfully, if instances are valid and + // error code is not returned + EUNIT_ASSERT_DESC( status1 == KErrNone, "First haptics client creation failed!"); + EUNIT_ASSERT_DESC( status2 == KErrNone, "Second haptics client creation failed!"); + EUNIT_ASSERT_DESC( status3 == KErrNone, "Third haptics client creation failed!"); + EUNIT_ASSERT_DESC( haptics1, "First haptics client creation failed!"); + EUNIT_ASSERT_DESC( haptics2, "Second haptics client creation failed!"); + EUNIT_ASSERT_DESC( haptics3, "Third haptics client creation failed!"); + + // delete haptics instances. This removes the sessions from + // haptics server, and closes the server, when the last session + // is closed + CleanupStack::PopAndDestroy(3, haptics1); + //delete haptics1; haptics1 = NULL; + //delete haptics2; haptics2 = NULL; + //delete haptics3; haptics3 = NULL; + } + +// --------------------------------------------------------- +// Create several consecutive sessions asynchronously +// to haptics server. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ConsecutiveSessionsAsynchronousL() + { + // Do create and delete three times in a row + T_CreateAndDeleteAsynchronousL(); + T_CreateAndDeleteAsynchronousL(); + T_CreateAndDeleteAsynchronousL(); + } + +// --------------------------------------------------------- +// Attemps to pause an effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PauseEffect() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // pause effect testing + TInt err = iHaptics->PausePlayingEffect( 0 ); + EUNIT_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle 0 failed!"); + err = iHaptics->PausePlayingEffect( INT_MIN ); + EUNIT_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle INT_MIN failed!"); + err = iHaptics->PausePlayingEffect( INT_MAX ); + EUNIT_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle INT_MAX failed!"); + } + +// --------------------------------------------------------- +// Attemps to resume an effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ResumeEffect() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // resume effect testing + TInt err = iHaptics->ResumePausedEffect( 0 ); + EUNIT_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle 0 failed!"); + err = iHaptics->ResumePausedEffect( INT_MIN ); + EUNIT_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle INT_MIN failed!"); + err = iHaptics->ResumePausedEffect( INT_MAX ); + EUNIT_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle INT_MAX failed!"); + } + +// --------------------------------------------------------- +// Attemps to stop an effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_StopEffect() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // stop effect testing + TInt err = iHaptics->StopPlayingEffect( 0 ); + EUNIT_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle 0 failed!"); + err = iHaptics->StopPlayingEffect( INT_MIN ); + EUNIT_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle INT_MIN failed!"); + err = iHaptics->StopPlayingEffect( INT_MAX ); + EUNIT_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle INT_MAX failed!"); + } + +// --------------------------------------------------------- +// Attemps to stop all effects. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_StopAllEffects() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // resume effect testing + TInt err = iHaptics->StopAllPlayingEffects(); + EUNIT_ASSERT_DESC( err == KErrNone, "Stopping all effects failed!"); + } + +// --------------------------------------------------------- +// Executes sequence: play effect, pause, resume, stop. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayPauseResumeStop() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect + TInt effectHandle = 0; + TInt err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Playing IVT effect synchronously returned empty effect handle!" ); + + // cleanup buffer + CleanupStack::PopAndDestroy( &effBuf ); + + // pause the effect + err = iHaptics->PausePlayingEffect( effectHandle ); + EUNIT_ASSERT_DESC( err == KErrNone, "Pausing the effect failed!"); + + // resume the effect + err = iHaptics->ResumePausedEffect( effectHandle ); + EUNIT_ASSERT_DESC( err == KErrNone, "Resuming the effect failed!"); + + // stop the effect + err = iHaptics->StopPlayingEffect( effectHandle ); + EUNIT_ASSERT_DESC( err == KErrNone, "Stopping the effect failed!"); + } + +// --------------------------------------------------------- +// Constant getters testing. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ConstantGetters() + { + const TInt expectedInfRepeat = 255; // VIBE_REPEAT_COUNT_INFINITE + const TInt expectedInfDuration = INT_MAX; // VIBE_TIME_INFINITE; + const TInt expectedMaxEffNameLen = 128; // VIBE_MAX_EFFECT_NAME_LENGTH + const TInt expectedMaxDevNameLen = 64; // VIBE_MAX_DEVICE_NAME_LENGTH + const TInt expectedMaxCapaStrLen = 64; // VIBE_MAX_CAPABILITY_STRING_LENGTH + const TInt expectedMaxPropStrLen = 64; // VIBE_MAX_PROPERTY_STRING_LENGTH + const TInt expectedMaxStrmSampleLen = 255; // VIBE_MAX_STREAMING_SAMPLE_SIZE + const TInt expectedDefaultDevPriority = 0; // VIBE_DEVPRIORITY_DEFAULT + + TInt infRepeat = iHaptics->InfiniteRepeat(); + EUNIT_ASSERT_DESC( KErrNotReady == infRepeat, "InfiniteRepeat() wrong error code" ); + TInt infDuration = iHaptics->InfiniteDuration(); + EUNIT_ASSERT_DESC( KErrNotReady == infDuration, "InfiniteDuration() wrong error code" ); + TInt maxEffNameLen = iHaptics->MaxEffectNameLength(); + EUNIT_ASSERT_DESC( KErrNotReady == maxEffNameLen, "MaxEffectNameLength() wrong error code" ); + TInt maxDevNameLen = iHaptics->MaxDeviceNameLength(); + EUNIT_ASSERT_DESC( KErrNotReady == maxDevNameLen, "MaxDeviceNameLength() wrong error code" ); + TInt maxCapaStrLen = iHaptics->MaxCapabilityStringLength(); + EUNIT_ASSERT_DESC( KErrNotReady == maxCapaStrLen, "MaxCapabilityStringLength() wrong error code" ); + TInt maxPropStrLen = iHaptics->MaxPropertyStringLength(); + EUNIT_ASSERT_DESC( KErrNotReady == maxPropStrLen, "MaxPropertyStringLength() wrong error code" ); + TInt maxStrmSampleLen = iHaptics->MaxStreamingSampleSize(); + EUNIT_ASSERT_DESC( KErrNotReady == maxStrmSampleLen, "MaxStreamingSampleSize() wrong error code" ); + TInt defaultDevPriority = iHaptics->DefaultDevicePriority(); + EUNIT_ASSERT_DESC( KErrNotReady == defaultDevPriority, "DefaultDevicePriority() wrong error code" ); + + // open a supported actuator + T_OpenSupportedActuator(); + + infRepeat = iHaptics->InfiniteRepeat(); + EUNIT_ASSERT_DESC( expectedInfRepeat == infRepeat, "InfiniteRepeat() failed" ); + infDuration = iHaptics->InfiniteDuration(); + EUNIT_ASSERT_DESC( expectedInfDuration == infDuration, "InfiniteDuration() failed" ); + maxEffNameLen = iHaptics->MaxEffectNameLength(); + EUNIT_ASSERT_DESC( expectedMaxEffNameLen == maxEffNameLen, "MaxEffectNameLength() failed" ); + maxDevNameLen = iHaptics->MaxDeviceNameLength(); + EUNIT_ASSERT_DESC( expectedMaxDevNameLen == maxDevNameLen, "MaxDeviceNameLength() failed" ); + maxCapaStrLen = iHaptics->MaxCapabilityStringLength(); + EUNIT_ASSERT_DESC( expectedMaxCapaStrLen == maxCapaStrLen, "MaxCapabilityStringLength() failed" ); + maxPropStrLen = iHaptics->MaxPropertyStringLength(); + EUNIT_ASSERT_DESC( expectedMaxPropStrLen == maxPropStrLen, "MaxPropertyStringLength() failed" ); + maxStrmSampleLen = iHaptics->MaxStreamingSampleSize(); + EUNIT_ASSERT_DESC( expectedMaxStrmSampleLen == maxStrmSampleLen, "MaxStreamingSampleSize() failed" ); + defaultDevPriority = iHaptics->DefaultDevicePriority(); + EUNIT_ASSERT_DESC( expectedDefaultDevPriority == defaultDevPriority, "DefaultDevicePriority() failed" ); + } + + +// --------------------------------------------------------- +// Modifies playing magsweep effect using synchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ModifyMagSweepEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsMagSweepEffect modifiedEffect; + modifiedEffect.iDuration = 3030; + modifiedEffect.iMagnitude = 7070; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TInt err = iHaptics->ModifyPlayingMagSweepEffect( 0, modifiedEffect ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle 0 failed!" ); + + err = iHaptics->ModifyPlayingMagSweepEffect( INT_MIN, modifiedEffect ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle INT_MIN failed!" ); + + err = iHaptics->ModifyPlayingMagSweepEffect( INT_MAX, modifiedEffect ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle INT_MAX failed!" ); + } + + +// --------------------------------------------------------- +// Modifies playing magsweep effect using asynchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ModifyMagSweepEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsMagSweepEffect modifiedEffect; + modifiedEffect.iDuration = 5050; + modifiedEffect.iMagnitude = 1010; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TRequestStatus status = KRequestPending; + iHaptics->ModifyPlayingMagSweepEffect( 0, modifiedEffect, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle 0 failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingMagSweepEffect( INT_MIN, modifiedEffect, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle INT_MIN failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingMagSweepEffect( INT_MAX, modifiedEffect, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle INT_MAX failed!" ); + } + + +// --------------------------------------------------------- +// Modifies playing periodic effect using synchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ModifyPeriodicEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsPeriodicEffect modifiedEffect; + modifiedEffect.iDuration = 6060; + modifiedEffect.iMagnitude = 2020; + modifiedEffect.iPeriod = 200; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TInt err = iHaptics->ModifyPlayingPeriodicEffect( 0, modifiedEffect ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle 0 failed!" ); + + err = iHaptics->ModifyPlayingPeriodicEffect( INT_MIN, modifiedEffect ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle INT_MIN failed!" ); + + err = iHaptics->ModifyPlayingPeriodicEffect( INT_MAX, modifiedEffect ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle INT_MAX failed!" ); + } + + +// --------------------------------------------------------- +// Modifies playing periodic effect using asynchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ModifyPeriodicEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsPeriodicEffect modifiedEffect; + modifiedEffect.iDuration = 4040; + modifiedEffect.iMagnitude = 6060; + modifiedEffect.iPeriod = 200; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TRequestStatus status = KRequestPending; + iHaptics->ModifyPlayingPeriodicEffect( 0, modifiedEffect, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle 0 failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingPeriodicEffect( INT_MIN, modifiedEffect, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle INT_MIN failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingPeriodicEffect( INT_MAX, modifiedEffect, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle INT_MAX failed!" ); + } + +// --------------------------------------------------------- +// Gets device TInt property +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetDeviceProperty_TInt_TInt() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get the same value 1 + TInt retValue (0); + TInt err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, retValue ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Getting device property (Strength) failed(1)!" ); + + err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, retValue ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Getting device property (disableEffects) failed(1)!" ); + } + +// --------------------------------------------------------- +// Gets device TDesC property +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetDeviceProperty_TInt_TDesC() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get property + TBuf8<100> retValue; + TInt err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsLicensekey, retValue ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Setting device property (EHWRMHapticsLicensekey) failed!" ); + } + +// --------------------------------------------------------- +// Sets device TInt property +// --------------------------------------------------------- +// +void MT_HapticsClient::T_SetDeviceProperty_TInt_TInt() + { + const TInt KSomeValue = 50; + // open actuator.. + T_OpenSupportedActuator(); + + // set property + TInt err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, KSomeValue ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Setting device property (Strength) failed!" ); + + err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, 0 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Setting device property (disableEffects) failed!" ); + } + +// --------------------------------------------------------- +// Sets device TDesC property +// --------------------------------------------------------- +// +void MT_HapticsClient::T_SetDeviceProperty_TInt_TDesC() + { + // open actuator.. + T_OpenSupportedActuator(); + + // set property + TInt err = iHaptics->SetDeviceProperty( + CHWRMHaptics::EHWRMHapticsLicensekey, + KNullDesC8 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Setting device property (NULL license key) failed!" ); + + err = iHaptics->SetDeviceProperty( + CHWRMHaptics::EHWRMHapticsLicensekey, + KPlainKey ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Setting device property (license key) failed!" ); + } + +// --------------------------------------------------------- +// Gets device TInt capability +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetDeviceCapability_TInt_TInt() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get the value + TInt retValue (0); + TInt expectedValue (1); // from testplugin's stubresponse.txt + TInt err = iHaptics->GetDeviceCapability( CHWRMHaptics::EHWRMHapticsMaxNestedRepeats, retValue ); + EUNIT_ASSERT_DESC( (err == KErrNone), + "Getting device property (MaxNestedRepeats) failed!" ); + EUNIT_ASSERT_DESC( expectedValue == retValue, + "Getting device property (MaxNestedRepeats) failed, wrong value!") + } + +// --------------------------------------------------------- +// Gets device TDesC capability +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetDeviceCapability_TInt_TDesC() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get the same value + TBuf8<100> retValue; + retValue.FillZ(); // sets length, important here.. + TInt err = iHaptics->GetDeviceCapability( CHWRMHaptics::EHWRMHapticsDeviceName, retValue ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Getting device property (DevName) failed!" ); + // the following are based on what the testplugin retunrs (i.e., bytes + // containing the ASCII character values for "S","T","U" and "B") + const TInt expectedSize( 4 ); + EUNIT_ASSERT_DESC( expectedSize == retValue.Size(), + "Getting device property (DevName) failed, wrong length!" ); + const TUint8 ascii4S( 0x53 ); + const TUint8 ascii4T( 0x54 ); + const TUint8 ascii4U( 0x55 ); + const TUint8 ascii4B( 0x42 ); + EUNIT_ASSERT_DESC( ascii4S == retValue[0] && ascii4T == retValue[1] && + ascii4U == retValue[2] && ascii4B == retValue[3], + "Getting device property (DevName) failed, wrong data!" ); + } + +// --------------------------------------------------------- +// Fetches the haptics status using the getter method. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetHapticsStatus() + { + MHWRMHapticsObserver::THWRMHapticsStatus status = iHaptics->HapticsStatus(); + EUNIT_ASSERT_DESC( (status == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable), + "Invalid haptics status received!" ); + } + +// --------------------------------------------------------- +// Fetches the haptics status using the observer. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ObserveHapticsStatus() + { + // create callback instance + THapticsStatusCallback callback( this ); + + // create haptics client with observer + CHWRMHaptics* haptics = CHWRMHaptics::NewL( &callback, NULL ); + + // wait for the callback to be called + iWait.Start(); + + // check status (since execution of this method continues, the status + // has been updated in the callback) + EUNIT_ASSERT_DESC( (callback.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable), + "Invalid haptics status received!" ); + + // cleanup + delete haptics; + } + +// --------------------------------------------------------- +// Fetches status values, when one client is reserving +// haptics. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetHapticsStatusWithReservations() + { + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + // make reservation using the first client + haptics1->ReserveHapticsL(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation + haptics1->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Status value observing, when one client is reserving +// haptics. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ObserveHapticsStatusWithReservations() + { + // create callback instances + THapticsStatusCallback callback1( this ); + THapticsStatusCallback callback2( this ); + + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL ); + CleanupStack::PushL( haptics2 ); + + // wait for the initial notifications to arrive + iWait.Start(); + iWait.Start(); + + // make reservation using the first client + haptics1->ReserveHapticsL(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation + haptics1->ReleaseHaptics(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + status2 = callback2.Status(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Haptics status, when several clients are making +// reservations with equal priorities. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetHapticsStatusWithSeveralReservations() + { + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + // make reservation using both clients (second should become suspended) + haptics1->ReserveHapticsL(); + haptics2->ReserveHapticsL(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), + "Invalid haptics status received!" ); + + // release reservation of the first client + haptics1->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // release reservation of the second client + haptics2->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Haptics status using observation, when several clients +// are making reservations with equal priorities. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ObserveHapticsStatusWithSeveralReservations() + { + // create callback instances + THapticsStatusCallback callback1( this ); + THapticsStatusCallback callback2( this ); + + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL ); + CleanupStack::PushL( haptics2 ); + + // wait for the initial notifications to arrive + iWait.Start(); + iWait.Start(); + + // make reservation using the first client + haptics1->ReserveHapticsL(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // make reservation using the second client + haptics2->ReserveHapticsL(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + status2 = callback2.Status(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), + "Invalid haptics status received!" ); + + // release first client's reservation + haptics1->ReleaseHaptics(); + + // wait for the callback to be called (both clients should + // receive new status) + iWait.Start(); + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = callback1.Status(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + status2 = callback2.Status(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // release second client's reservation + haptics2->ReleaseHaptics(); + + // wait for the callback to be called (only first client + // should receive notification) + iWait.Start(); + + // check client status values + status1 = callback1.Status(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Several clients with one making a reservation --> tests +// that all other clients become "reserved". +// --------------------------------------------------------- +// +void MT_HapticsClient::T_GetHapticsStatusWithSeveralClientsOneReservation() + { + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics3 ); + + // reservation using first client + haptics1->ReserveHapticsL(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status3 = haptics3->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation + haptics1->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status3 = haptics3->HapticsStatus(); + EUNIT_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics3 ); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Several clients with one making a reservation --> tests +// that all other clients become "reserved" using observers. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ObserveHapticsStatusWithSeveralClientsOneReservations() + { + // create callback instances + THapticsStatusCallback callback1( this ); + THapticsStatusCallback callback2( this ); + THapticsStatusCallback callback3( this ); + + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL ); + CleanupStack::PushL( haptics2 ); + + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( &callback3, NULL ); + CleanupStack::PushL( haptics3 ); + + // wait for the initial notifications to arrive + iWait.Start(); + iWait.Start(); + iWait.Start(); + + // reservation using first client + haptics1->ReserveHapticsL(); + + // wait for the notifications for client2 and client3 + iWait.Start(); + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status3 = callback3.Status(); + EUNIT_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation using first client + haptics1->ReleaseHaptics(); + + // wait for the notifications for client2 and client3 + iWait.Start(); + iWait.Start(); + + // check client status values + status2 = callback2.Status(); + EUNIT_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status3 = callback3.Status(); + EUNIT_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics3 ); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +// --------------------------------------------------------- +// Creates streaming effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_CreateStreamingEffect() + { + // open actuator.. + T_OpenSupportedActuator(); + + TInt effectHandle; + TInt err = iHaptics->CreateStreamingEffect( effectHandle ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Creating streaming effect failed!" ); + EUNIT_ASSERT_DESC( effectHandle, "Creating streaming effect returned empty effect handle!" ); + } + +// --------------------------------------------------------- +// Plays streaming sample using synchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayStreamingSample() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // valid sized sample 0 handle 0 offset + TInt err = iHaptics->PlayStreamingSample( 0, validStreamSample ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" ); + + // normal sample MIN handle MIN offset + err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" ); + + // normal sample MAX handle MAX offset + err = iHaptics->PlayStreamingSample( INT_MAX, validStreamSample ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + err = iHaptics->PlayStreamingSample( INT_MAX, tooBigStreamSample ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Play streaming sample (over sized sample), wrong error code" ); + + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample ); + EUNIT_ASSERT_DESC( ( err == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + } + +// --------------------------------------------------------- +// Plays streaming sample using asynchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayStreamingSampleAsync() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // normal sample 0 handle 0 offset + TRequestStatus status = KRequestPending; + iHaptics->PlayStreamingSample( 0, validStreamSample, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" ); + + // normal sample MIN handle MIN offset + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" ); + + // normal sample MAX handle MAX offset + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MAX, validStreamSample, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MAX, tooBigStreamSample, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrArgument ), "Play streaming sample (over sized sample), wrong error code" ); + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + } + +// --------------------------------------------------------- +// Plays streaming sample with offset using +// synchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayStreamingSampleWithOffset() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // valid sized sample 0 handle 0 offset + TInt err = iHaptics->PlayStreamingSampleWithOffset( 0, validStreamSample, 0 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" ); + + // normal sample MIN handle MIN offset + err = iHaptics->PlayStreamingSampleWithOffset( INT_MIN, validStreamSample, INT_MIN ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" ); + + // normal sample MAX handle MAX offset + err = iHaptics->PlayStreamingSampleWithOffset( INT_MAX, validStreamSample, INT_MAX ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + err = iHaptics->PlayStreamingSampleWithOffset( INT_MAX, tooBigStreamSample, INT_MAX ); + EUNIT_ASSERT_DESC( (err == KErrArgument), "Play streaming sample with offset (over sized sample), wrong error code" ); + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample ); + EUNIT_ASSERT_DESC( ( err == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + } + +// --------------------------------------------------------- +// Plays streaming sample with offset using +// asynchronous API call. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_PlayStreamingSampleWithOffsetAsync() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // normal sample 0 handle 0 offset + TRequestStatus status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( 0, validStreamSample, 0, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" ); + + // normal sample MIN handle MIN offset + status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( INT_MIN, validStreamSample, INT_MIN, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" ); + + // normal sample MAX handle MAX offset + status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( INT_MAX, validStreamSample, INT_MAX, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( INT_MAX, tooBigStreamSample, INT_MAX, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrArgument ), "Play streaming sample with offset (over sized sample), wrong error code" ); + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status ); + User::WaitForRequest( status ); + EUNIT_ASSERT_DESC( (status.Int() == KErrInUse ), "Play streaming sample with offset (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + } + +// --------------------------------------------------------- +// Destroys streaming effect. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_DestroyStreamingEffect() + { + // open actuator.. + T_OpenSupportedActuator(); + + // zero handle + TInt err = iHaptics->DestroyStreamingEffect( 0 ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle 0 failed!" ); + + // minimum handle value + err = iHaptics->DestroyStreamingEffect( INT_MIN ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle INT_MIN failed!" ); + + // maximum handle value + err = iHaptics->DestroyStreamingEffect( INT_MAX ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle INT_MAX failed!" ); + } + + +// --------------------------------------------------------- +// Fetches actuator state using the observer. +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ObserveActuatorStatus() + { + // Create 2 actuator status observer instances + TActuatorStatusCallback callback1( this ); + TActuatorStatusCallback callback2( this ); + + // create 1st haptics client with actuator observer + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, &callback1 ); + CleanupStack::PushL( haptics1 ); + + //Open actuator + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + // wait for the callback to be called + iWait.Start(); + + // check actuator state (since execution of this method continues, the state + // has been updated in the callback) + EUNIT_ASSERT_DESC( (callback1.Status(EHWRMLogicalActuatorAny) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator state received!" ); + + // create 2nd haptics client with actuator observer + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, &callback2 ); + CleanupStack::PushL( haptics2 ); + + //Open actuator + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + + // wait for the callback to be called + iWait.Start(); + + // check actuator state (since execution of this method continues, the state + // has been updated in the callback) + EUNIT_ASSERT_DESC( (callback2.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator state received!" ); + + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void MT_HapticsClient::T_ObserveActuatorStatusAndHapticsStatus() + { + // Create 3 actuator status observers. + TActuatorStatusCallback actuatorCallback1( this ); + TActuatorStatusCallback actuatorCallback2( this ); + TActuatorStatusCallback actuatorCallback3( this ); + + // Create 3 haptics status observers. + THapticsStatusCallback hapticsCallback1( this ); + THapticsStatusCallback hapticsCallback2( this ); + THapticsStatusCallback hapticsCallback3( this ); + + // create 1st haptics client with observers + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &hapticsCallback1, &actuatorCallback1 ); + CleanupStack::PushL( haptics1 ); + + //Open actuator + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + + // wait for the haptics status callback to be called + iWait.Start(); + // wait for the actuator status callback to be called + iWait.Start(); + + // check actuator status (since execution of this method continues, the status + // has been updated in the callback) + EUNIT_ASSERT_DESC( (actuatorCallback1.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator status received!" ); + // check haptics status + EUNIT_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + haptics1->ReserveHapticsL(); + + + // create 2nd and 3rd haptics clients with observers + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &hapticsCallback2, &actuatorCallback2 ); + CleanupStack::PushL( haptics2 ); + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( &hapticsCallback3, &actuatorCallback3 ); + CleanupStack::PushL( haptics3 ); + + // reserve haptics for 2nd client + haptics2->ReserveHapticsL(); + + //Open actuator + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + TRAP( err, haptics3->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + EUNIT_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + + // wait for the haptics status callback to be called + iWait.Start(); + iWait.Start(); + iWait.Start(); + // wait for the actuator status callback to be called + iWait.Start(); + iWait.Start(); + + // check haptics status (since execution of this method continues, the status + // has been updated in the callback) + EUNIT_ASSERT_DESC( ( hapticsCallback2.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), + "Invalid haptics status received!" ); + EUNIT_ASSERT_DESC( ( hapticsCallback3.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + // check actuator status + EUNIT_ASSERT_DESC( (actuatorCallback2.Status(EHWRMLogicalActuatorAny) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator status received!" ); + EUNIT_ASSERT_DESC( (actuatorCallback3.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator status received!" ); + + // release haptics + haptics1->ReleaseHaptics(); + + // wait for the haptics status callback to be called + iWait.Start(); + iWait.Start(); + + EUNIT_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + EUNIT_ASSERT_DESC( ( hapticsCallback2.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + + // release haptics + haptics2->ReleaseHaptics(); + + // wait for the haptics status callback to be called + iWait.Start(); + iWait.Start(); + + EUNIT_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + EUNIT_ASSERT_DESC( ( hapticsCallback3.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics3 ); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + } + +void MT_HapticsClient::T_PluginMgrTransTimerExpires() + { + // open actuator.. + T_OpenSupportedActuator(); + + _LIT8 ( KTestPluginMgrTransTimerExpires, "KTestPluginMgrTransTimerExpires" ); + // set property with the TestCase ID string, so that the test plug-in doesn't send the response for the current + // transaction, till the Plug-in manager Transction timer expires. + // Out-come: Plug-in manager should hanlde this scenario and send cancel transaction command to test plug-in. + TInt err = iHaptics->SetDeviceProperty( + CHWRMHaptics::EHWRMHapticsLicensekey, + KTestPluginMgrTransTimerExpires ); + EUNIT_ASSERT_DESC( (err == KErrTimedOut), "Setting device property (license key) failed!" ); + } + + + +// - EUnit test table ------------------------------------------------------- + +EUNIT_BEGIN_TEST_TABLE( + MT_HapticsClient, + "Haptics Client Module Tests", + "MODULE" ) + +// 1,01 +EUNIT_TEST( + "Create and destroy", + "HapticsClient", + "NewL", + "FUNCTIONALITY", + Dummy, T_CreateAndDeleteL, Dummy) + +// 1,02 +EUNIT_TEST( + "Several sessions", + "HapticsClient", + "NewL", + "FUNCTIONALITY", + Dummy, T_SeveralSessionsL, Dummy) + +// 1,03 +EUNIT_TEST( + "Consecutive sessions", + "HapticsClient", + "NewL", + "FUNCTIONALITY", + Dummy, T_ConsecutiveSessionsL, Dummy) + +// 1,04 +EUNIT_TEST( + "Supported actuators", + "HapticsClient", + "SupportedActuators", + "FUNCTIONALITY", + SetupL, T_SupportedActuators, Teardown) + +// 1,05 +EUNIT_TEST( + "Open supported actuator", + "HapticsClient", + "OpenActuatorL", + "FUNCTIONALITY", + SetupL, T_OpenSupportedActuator, Teardown) + +// 1,06 +EUNIT_TEST( + "Open unsupported actuator", + "HapticsClient", + "OpenActuatorL", + "FUNCTIONALITY", + SetupL, T_OpenNotSupportedActuator, Teardown) + +// 1,07 +EUNIT_TEST( + "Open all actuators", + "HapticsClient", + "OpenActuatorL", + "FUNCTIONALITY", + SetupL, T_OpenAllActuators, Teardown) + +// 1,08 +EUNIT_TEST( + "2 clients open actuators", + "HapticsClient", + "OpenActuatorL", + "FUNCTIONALITY", + Dummy, T_SeveralClientsWithOpenActuatorsL, Dummy) + +// 1,09 +EUNIT_TEST( + "Play MagSweep synch (data)", + "HapticsClient", + "PlayMagSweepEffect", + "FUNCTIONALITY", + SetupL, T_PlayMagSweepEffectSynchronous, Teardown) + +// 1,10 +EUNIT_TEST( + "Play MagSweep asynch (data)", + "HapticsClient", + "PlayMagSweepEffect", + "FUNCTIONALITY", + SetupL, T_PlayMagSweepEffectAsynchronous, Teardown) + +// 1,11 +EUNIT_TEST( + "Play Periodic synch (data)", + "HapticsClient", + "PlayPeriodicEffect", + "FUNCTIONALITY", + SetupL, T_PlayPeriodicEffectSynchronous, Teardown) + +// 1,12 +EUNIT_TEST( + "Play Periodic asynch (data)", + "HapticsClient", + "PlayPeriodicEffect", + "FUNCTIONALITY", + SetupL, T_PlayPeriodicEffectAsynchronous, Teardown) + +// 1,13 +EUNIT_TEST( + "Play IVT synch (data)", + "HapticsClient", + "PlayEffect", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectWithDirectDataSynchronous, Teardown) + +// 1,14 +EUNIT_TEST( + "Play IVT asynch (data)", + "HapticsClient", + "PlayEffect", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectWithDirectDataAsynchronous, Teardown) + +// 1,15 +EUNIT_TEST( + "Repeat IVT synch (data)", + "HapticsClient", + "PlayEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatWithDirectDataSynchronous, Teardown) + +// 1,16 +EUNIT_TEST( + "Repeat IVT asynch (data)", + "HapticsClient", + "PlayEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatWithDirectDataAsynchronous, Teardown) + +// 1,17 +EUNIT_TEST( + "Get effect state", + "HapticsClient", + "GetEffectState", + "FUNCTIONALITY", + SetupL, T_GetEffectState, Teardown) + +// 1,18 +EUNIT_TEST( + "Repeat IVT synch (data - non-timeline)", + "HapticsClient", + "PlayEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous, Teardown) + +// 1,19 +EUNIT_TEST( + "Repeat IVT asynch (data - non-timeline)", + "HapticsClient", + "PlayEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous, Teardown) + +// 1,20 +EUNIT_TEST( + "Zero-repeat IVT synch (data)", + "HapticsClient", + "PlayEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous, Teardown) + +// 1,21 +EUNIT_TEST( + "Zero-repeat IVT asynch (data)", + "HapticsClient", + "PlayEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous, Teardown) + +// 1,22 +EUNIT_TEST( + "Load IVT data", + "HapticsClient", + "LoadData", + "FUNCTIONALITY", + SetupL, T_LoadIVTData, Teardown) + +// 1,23 +EUNIT_TEST( + "Delete IVT data", + "HapticsClient", + "DeleteEffectData", + "FUNCTIONALITY", + SetupL, T_DeleteIVTData, Teardown) + +// 1,24 +EUNIT_TEST( + "Delete All IVT data", + "HapticsClient", + "DeleteAllEffectData", + "FUNCTIONALITY", + SetupL, T_DeleteAllIVTData, Teardown) + +// 1,35 +EUNIT_TEST( + "Load and delete multiple", + "HapticsClient", + "LoadAndDeleteEffectData", + "FUNCTIONALITY", + SetupL, T_LoadAndDeleteIVTData, Teardown) + +// 1,36 +EUNIT_TEST( + "Load and delete mixed", + "HapticsClient", + "LoadAndDeleteEffectDataMixed", + "FUNCTIONALITY", + SetupL, T_LoadAndDeleteIVTDataMixed, Teardown) + +// 1,37 +EUNIT_TEST( + "Load, Del, Play sync", + "HapticsClient", + "LoadDeletePlaySync", + "FUNCTIONALITY", + SetupL, T_LoadDeletePlaySync, Teardown) + +// 1,38 +EUNIT_TEST( + "Load, Del, Play async", + "HapticsClient", + "LoadDeletePlayAsync", + "FUNCTIONALITY", + SetupL, T_LoadDeletePlayAsync, Teardown) + +// 1,39 +EUNIT_TEST( + "Load, Del, Repeat sync", + "HapticsClient", + "LoadDeletePlayRepeatSync", + "FUNCTIONALITY", + SetupL, T_LoadDeletePlayRepeatSync, Teardown) + +// 1,40 +EUNIT_TEST( + "Load, Del, Repeat async", + "HapticsClient", + "LoadDeletePlayRepeatAsync", + "FUNCTIONALITY", + SetupL, T_LoadDeletePlayRepeatAsync, Teardown) + +// 1,25 +EUNIT_TEST( + "Play loaded IVT synch", + "HapticsClient", + "PlayIVTEffect", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectWithLoadedDataSynchronous, Teardown) + +// 1,26 +EUNIT_TEST( + "Play loaded IVT asynch", + "HapticsClient", + "PlayIVTEffect", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectWithLoadedDataAsynchronous, Teardown) + +// 1,27 +EUNIT_TEST( + "Repeat loaded IVT synch", + "HapticsClient", + "PlayIVTEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatWithLoadedDataSynchronous, Teardown) + +// 1,28 +EUNIT_TEST( + "Repeat loaded IVT asynch", + "HapticsClient", + "PlayIVTEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatWithLoadedDataAsynchronous, Teardown) + +// 1,29 +EUNIT_TEST( + "Load multiple IVT-data", + "HapticsClient", + "LoadIVTData", + "FUNCTIONALITY", + SetupL, T_LoadMultipleIVTData, Teardown) + +// 1,30 +EUNIT_TEST( + "Play from multiple IVT-data", + "HapticsClient", + "PlayIVTEffect", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectsFromMultipleIVTDataSynchronous, Teardown) + +// 1,31 +EUNIT_TEST( + "Play from multiple IVT-data", + "HapticsClient", + "PlayIVTEffect", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectsFromMultipleIVTDataAsynchronous, Teardown) + +// 1,32 +EUNIT_TEST( + "Play repeat from multiple IVT-data", + "HapticsClient", + "PlayIVTEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous, Teardown) + +// 1,33 +EUNIT_TEST( + "Play repeat from multiple IVT-data", + "HapticsClient", + "PlayIVTEffectRepeat", + "FUNCTIONALITY", + SetupL, T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous, Teardown) + +// 1,34 +EUNIT_TEST( + "Status conversions", + "HapticsClient", + "PlayIVTEffectRepeat", + "FUNCTIONALITY", + SetupL, T_VibeStatusToS60StatusConversions, Teardown) + +// 1,48 +EUNIT_TEST( + "Reserve and release", + "HapticsClient", + "ReserveHapticsL", + "FUNCTIONALITY", + SetupL, T_ReserveAndReleaseHaptics, Teardown) + +// 1,49 +EUNIT_TEST( + "Reserve several times", + "HapticsClient", + "ReserveHapticsL", + "FUNCTIONALITY", + SetupL, T_ReserveHapticsSeveralTimes, Teardown) + +// 1,50 +EUNIT_TEST( + "Reserve, no release", + "HapticsClient", + "ReleaseHaptics", + "FUNCTIONALITY", + Dummy, T_ReserveHapticsNoReleaseL, Dummy) + +// 1,51 +EUNIT_TEST( + "Release, no reserve", + "HapticsClient", + "ReleaseHaptics", + "FUNCTIONALITY", + SetupL, T_ReleaseHapticsWithoutReservingFirst, Teardown) + +// 1,52 +EUNIT_TEST( + "Reserve forceNoCoe", + "HapticsClient", + "ReserveHapticsL", + "FUNCTIONALITY", + SetupL, T_ReserveNoAutomaticFocusNotTrusted, Teardown) + +// 1,53 +EUNIT_TEST( + "Reserve reserved higher", + "HapticsClient", + "ReserveHapticsL", + "FUNCTIONALITY", + Dummy, T_ReserveAlreadyReservedHigherL, Dummy) + +// 1,54 +EUNIT_TEST( + "Reserve reserved lower", + "HapticsClient", + "ReserveHapticsL", + "FUNCTIONALITY", + Dummy, T_ReserveAlreadyReservedLowerL, Dummy) + +// 1,55 +EUNIT_TEST( + "Play when reserved", + "HapticsClient", + "ReserveHapticsL", + "FUNCTIONALITY", + SetupL, T_PlayWhenReservedL, Teardown) + +// 1,41 +EUNIT_TEST( + "Get effect count", + "HapticsClient", + "GetIVTEffectCount", + "FUNCTIONALITY", + SetupL, T_GetIVTEffectCount, Teardown) + +// 1,42 +EUNIT_TEST( + "Get effect duration", + "HapticsClient", + "GetIVTEffectDuration", + "FUNCTIONALITY", + SetupL, T_GetIVTEffectDuration, Teardown) + +// 1,43 +EUNIT_TEST( + "Get effect index from name", + "HapticsClient", + "GetEffectIndexFromName", + "FUNCTIONALITY", + SetupL, T_GetIVTEffectIndexFromName, Teardown) + +// 1,44 +EUNIT_TEST( + "Get effect type", + "HapticsClient", + "GetEffectType", + "FUNCTIONALITY", + SetupL, T_GetIVTEffectType, Teardown) + +// 1,45 +EUNIT_TEST( + "Get effect name", + "HapticsClient", + "GetEffectName", + "FUNCTIONALITY", + SetupL, T_GetIVTEffectName, Teardown) + +// 1,46 +EUNIT_TEST( + "Get MagSweep effect definition", + "HapticsClient", + "GetMagSweepEffectDefinition", + "FUNCTIONALITY", + SetupL, T_GetIVTMagSweepEffectDefinition, Teardown) + +// 1,47 +EUNIT_TEST( + "Get Periodic effect definition", + "HapticsClient", + "GetPeriodicEffectDefinition", + "FUNCTIONALITY", + SetupL, T_GetIVTPeriodicEffectDefinition, Teardown) + +// 1,56 +EUNIT_TEST( + "Create and destroy asynchronous", + "HapticsClient", + "NewL", + "FUNCTIONALITY", + Dummy, T_CreateAndDeleteAsynchronousL, Dummy) + +// 1,57 +EUNIT_TEST( + "Several sessions asynchronous", + "HapticsClient", + "NewL", + "FUNCTIONALITY", + Dummy, T_SeveralSessionsAsynchronousL, Dummy) + +// 1,58 +EUNIT_TEST( + "Consecutive sessions asynchronous", + "HapticsClient", + "NewL", + "FUNCTIONALITY", + Dummy, T_ConsecutiveSessionsAsynchronousL, Dummy) + +// 1,59 +EUNIT_TEST( + "Constant getters", + "HapticsClient", + "InfiniteRepeat", // and others.. + "FUNCTIONALITY", + SetupL, T_ConstantGetters, Teardown) + +// 1,60 +EUNIT_TEST( + "Pause effect", + "HapticsClient", + "PausePlayingEffect", + "FUNCTIONALITY", + SetupL, T_PauseEffect, Teardown) + +// 1,61 +EUNIT_TEST( + "Resume effect", + "HapticsClient", + "ResumePausedEffect", + "FUNCTIONALITY", + SetupL, T_ResumeEffect, Teardown) + +// 1,62 +EUNIT_TEST( + "Stop effect", + "HapticsClient", + "StopPlayingEffect", + "FUNCTIONALITY", + SetupL, T_StopEffect, Teardown) + +// 1,63 +EUNIT_TEST( + "Stop all effects", + "HapticsClient", + "StopAllPlayingEffects", + "FUNCTIONALITY", + SetupL, T_StopAllEffects, Teardown) + +// 1,64 +EUNIT_TEST( + "Play, pause, resume, stop", + "HapticsClient", + "StopPlayingEffect", + "FUNCTIONALITY", + SetupL, T_PlayPauseResumeStop, Teardown) + +// 1,65 +EUNIT_TEST( + "Modify playing magsweep effect synchronous", + "HapticsClient", + "ModifyPlayingMagSweepEffect", + "FUNCTIONALITY", + SetupL, T_ModifyMagSweepEffectSynchronous, Teardown) + +// 1,66 +EUNIT_TEST( + "Modify playing magsweep effect asynchronous", + "HapticsClient", + "ModifyPlayingMagSweepEffect", + "FUNCTIONALITY", + SetupL, T_ModifyMagSweepEffectAsynchronous, Teardown) + +// 1,67 +EUNIT_TEST( + "Modify playing periodic effect synchronous", + "HapticsClient", + "ModifyPlayingPeriodicEffect", + "FUNCTIONALITY", + SetupL, T_ModifyPeriodicEffectSynchronous, Teardown) + +// 1,68 +EUNIT_TEST( + "Modify playing periodic effect asynchronous", + "HapticsClient", + "ModifyPlayingPeriodicEffect", + "FUNCTIONALITY", + SetupL, T_ModifyPeriodicEffectAsynchronous, Teardown) + +// 1,69 +EUNIT_TEST( + "Get device property of TInt value", + "HapticsClient", + "GetDeviceProperty_TInt_TInt", + "FUNCTIONALITY", + SetupL, T_GetDeviceProperty_TInt_TInt, Teardown) + +// 1,70 +EUNIT_TEST( + "Get device property of TDesC value", + "HapticsClient", + "GetDeviceProperty_TInt_TDesC", + "FUNCTIONALITY", + SetupL, T_GetDeviceProperty_TInt_TDesC, Teardown) + +// 1,71 +EUNIT_TEST( + "Set device property of TInt value", + "HapticsClient", + "SetDeviceProperty_TInt_TInt", + "FUNCTIONALITY", + SetupL, T_SetDeviceProperty_TInt_TInt, Teardown) + +// 1,72 +EUNIT_TEST( + "Set device property of TDesC value", + "HapticsClient", + "SetDeviceProperty_TInt_TDesC", + "FUNCTIONALITY", + SetupL, T_SetDeviceProperty_TInt_TDesC, Teardown) + +// 1,73 +EUNIT_TEST( + "Get device capability of TInt value", + "HapticsClient", + "GetDeviceCapability_TInt_TInt", + "FUNCTIONALITY", + SetupL, T_GetDeviceCapability_TInt_TInt, Teardown) + +// 1,74 +EUNIT_TEST( + "Get device capability of TDesC value", + "HapticsClient", + "GetDeviceCapability_TInt_TDesC", + "FUNCTIONALITY", + SetupL, T_GetDeviceCapability_TInt_TDesC, Teardown) + +// 1,75 +EUNIT_TEST( + "Fetch status", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + SetupL, T_GetHapticsStatus, Teardown) + +// 1,76 +EUNIT_TEST( + "Observe status", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + Dummy, T_ObserveHapticsStatus, Dummy) + +// 1,77 +EUNIT_TEST( + "Status, reservation", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + Dummy, T_GetHapticsStatusWithReservations, Dummy) + +// 1,78 +EUNIT_TEST( + "Status, observe, reservation", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + Dummy, T_ObserveHapticsStatusWithReservations, Dummy) + +// 1,79 +EUNIT_TEST( + "Status, 2 reservations", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + Dummy, T_GetHapticsStatusWithSeveralReservations, Dummy) + +// 1,80 +EUNIT_TEST( + "Status, observe, 2 reservation", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + Dummy, T_ObserveHapticsStatusWithSeveralReservations, Dummy) + +// 1,81 +EUNIT_TEST( + "Status, many clients", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + Dummy, T_GetHapticsStatusWithSeveralClientsOneReservation, Dummy) + +// 1,82 +EUNIT_TEST( + "Status, observer, many clients", + "HapticsClient", + "HapticsStatus", + "FUNCTIONALITY", + Dummy, T_ObserveHapticsStatusWithSeveralClientsOneReservations, Dummy) + + +// 1,83 +EUNIT_TEST( + "Create streaming effect", + "HapticsClient", + "CreateStreamingEffect", + "FUNCTIONALITY", + SetupL, T_CreateStreamingEffect, Teardown) + +// 1,84 +EUNIT_TEST( + "Play streaming sample", + "HapticsClient", + "PlayStreamingSample", + "FUNCTIONALITY", + SetupL, T_PlayStreamingSample, Teardown) + +// 1,85 +EUNIT_TEST( + "Play streaming sample, async", + "HapticsClient", + "PlayStreamingSample", + "FUNCTIONALITY", + SetupL, T_PlayStreamingSampleAsync, Teardown) + +// 1,86 +EUNIT_TEST( + "Play streaming sample with offset", + "HapticsClient", + "PlayStreamingSampleWithOffset", + "FUNCTIONALITY", + SetupL, T_PlayStreamingSampleWithOffset, Teardown) + +// 1,87 +EUNIT_TEST( + "Play streaming sample with offset, async", + "HapticsClient", + "PlayStreamingSampleWithOffset", + "FUNCTIONALITY", + SetupL, T_PlayStreamingSampleWithOffsetAsync, Teardown) + +// 1,88 +EUNIT_TEST( + "Destroy streaming effect", + "HapticsClient", + "DestroyStreamingEffect", + "FUNCTIONALITY", + SetupL, T_DestroyStreamingEffect, Teardown) + +// 1,89 +EUNIT_TEST( + "Actuator status", + "HapticsClient", + "ActuatorStatus", + "FUNCTIONALITY", + SetupL, T_ObserveActuatorStatus, Teardown) + +// 1,89 +EUNIT_TEST( + "Actuator/Haptics status", + "HapticsClient", + "ActuatorStatus", + "FUNCTIONALITY", + SetupL, T_ObserveActuatorStatusAndHapticsStatus, Teardown) + +// 1,90 +EUNIT_TEST( + "Plugin Manager Timer Expires", + "HapticsClient", + "ActuatorStatus", + "FUNCTIONALITY", + SetupL, T_PluginMgrTransTimerExpires, Teardown) + + +#if 0 +// Copy this as basis for new ones.. +EUNIT_TEST( + "", + "HapticsClient", + "", + "FUNCTIONALITY", + SetupL, Dummy, Teardown) +#endif + + +EUNIT_END_TEST_TABLE diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/mt_hapticsclient/mt_hapticsclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/mt_hapticsclient/mt_hapticsclient.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,400 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef __MT_HAPTICSCLIENT_H__ +#define __MT_HAPTICSCLIENT_H__ + +// INCLUDES +#include +#include +#include + +class MT_HapticsClient; + +/** + * Callback class for haptics status observation. + */ +NONSHARABLE_CLASS( THapticsStatusCallback ) : public MHWRMHapticsObserver + { +public: + + /** + * C++ constructor. + */ + THapticsStatusCallback( MT_HapticsClient* aMTCallback ); + + /** + * Destructor. + */ + ~THapticsStatusCallback(); + + /** + * Returns the last received status. + * + * @return Last status value. + */ + MHWRMHapticsObserver::THWRMHapticsStatus Status(); + + /** + * Starts a new wait loop under the current active scheduler. + * This method can be used in module tests to wait for the + * notification to be received. When the notification is + * received (i.e. callback is called by haptics), the waiting + * is stopped and the execution continues whereever this method + * was called. + */ + void WaitForNotification(); + +public: // from MHWRMHapticsObserver + + virtual void HapticsStatusChangedL( THWRMHapticsStatus aStatus ); + virtual void EffectCompletedL( TInt aError, TInt aEffectHandle ); + +private: + + /** + * Last received haptics status through status observation. + */ + MHWRMHapticsObserver::THWRMHapticsStatus iHapticsStatus; + + /** + * Callback which is notified, when a status has been received. + */ + MT_HapticsClient* iMTCallback; + }; + + +/** + * Callback class for actuator status observation. + */ +NONSHARABLE_CLASS( TActuatorStatusCallback ) : public MHWRMHapticsActuatorObserver + { +public: + + /** + * C++ constructor. + */ + TActuatorStatusCallback( MT_HapticsClient* aMTCallback ); + + /** + * Destructor. + */ + ~TActuatorStatusCallback(); + + /** + * Returns the last received state. + * + * @return Last status value. + */ + MHWRMHapticsActuatorObserver::THWRMActuatorEvents Status( THWRMLogicalActuators aActuator ); + + /** + * Starts a new wait loop under the current active scheduler. + * This method can be used in module tests to wait for the + * notification to be received. When the notification is + * received (i.e. callback is called by haptics), the waiting + * is stopped and the execution continues whereever this method + * was called. + */ + void WaitForNotification(); + +public: // from MHWRMHapticsActuatorObserver + + virtual void ActuatorEventL( THWRMActuatorEvents aEvent, + THWRMLogicalActuators aActuator ); + +private: + + /** + * Last received actuator status through state observation. + */ + RArray iActuatorStatus; + + /** + * Callback which is notified, when a state has been received. + */ + MT_HapticsClient* iMTCallback; + }; + +/** + * Class for making async play-with-filehandle calls on behalf of the + * MT_HapticsClient + */ +NONSHARABLE_CLASS( MT_HapticsTestAsyncPlaySender ) : public CActive + { +public: + + /** + * Constructor + * + * @param aUi Pointer to the test appl UI object. + */ + MT_HapticsTestAsyncPlaySender( MT_HapticsClient* aMTCallback ); + + /** + * Destructor + */ + virtual ~MT_HapticsTestAsyncPlaySender(); + + /** + * Method for fileHandle type playing of effects repeatedly in asynch mode + * + * @param aHaptics Pointer to the haptics interface object. + * @param aFileHandle Handle for the effect data buffer from which to + * play the effects. + * @param aEffectIndex Index of the effect that is being played. + * @param aRepeat Number of repeats. + * @param aEffectHandle Out-parameter to which the handle for the played + * effect is returned. + */ + void PlayRepeat( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TUint8 aRepeat, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ); + + /** + * Method for fileHandle type playing of effects in asynch mode + * + * @param aHaptics Pointer to the haptics interface object. + * @param aFileHandle Handle for the effect data buffer from which to + * play the effects. + * @param aEffectIndex Index of the effect that is being played. + * @param aEffectHandle Out-parameter to which the handle for the played + * effect is returned. + */ + void Play( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ); + +public: + + /** + * From CActive + */ + virtual void RunL(); + + /** + * From CActive + */ + virtual void DoCancel(); + + /** + * From CActive + */ + virtual TInt RunError( TInt aError ); + +private: + + /** + * Pointer to the MT_HapticsClient. + * Not owned. + */ + MT_HapticsClient* iMTCallback; + + TRequestStatus* iClientStatus; + }; + +/** + * Generated EUnit test suite class. + */ +NONSHARABLE_CLASS( MT_HapticsClient ) : public CEUnitTestSuiteClass + { +public: // Constructors and destructor + + static MT_HapticsClient* NewL(); + static MT_HapticsClient* NewLC(); + ~MT_HapticsClient(); + + /** + * Method, which is called by the status callback, when a status + * has been received. Stops the wait loop waiting for a new status. + */ + void HapticsStatusReceived(); + +private: // Constructors + + MT_HapticsClient(); + void ConstructL(); + +private: // New methods + + /** + * Test construction; Creates haptics client instance. + */ + void SetupL(); + + /** + * Test teardown; Deletes haptics client instance. + */ + void Teardown(); + + /** + * Empty method to be used as setup() and teardown() in test + * cases, where all test code is in the actual test method. + */ + void Dummy(); + + /** + * Helpers for creating effects + */ + void CreateMagSweepEffect( CHWRMHaptics::THWRMHapticsMagSweepEffect& aEffect ); + void CreatePeriodicEffect( CHWRMHaptics::THWRMHapticsPeriodicEffect& aEffect ); + void CreateIVTEffect( RBuf8& aBuffer, CHWRMHaptics::THWRMHapticsEffectTypes aType ); + + /** + * Helper for such cases where it is first needed to load IVT data + */ + TInt LoadIVTDataInternal( TInt& aFileHandle, CHWRMHaptics::THWRMHapticsEffectTypes aType, + TBool aOpenActuator = ETrue ); + + /** + * Helper for such cases where it is first needed to load IVT data + */ + TInt LoadIVTDataInternal( TInt& aFileHandle, + const TUint8 aIvtData[], + TInt aIvtDataSize, + TBool aOpenActuator = ETrue ); + + /** + * Helper for such cases where contents of stream sample + * is not relevant. + */ + void CreateDummyStreamSample( TInt aSize, RBuf8& aBuffer ); + + void T_CreateAndDeleteL(); + void T_SeveralSessionsL(); + void T_ConsecutiveSessionsL(); + void T_SupportedActuators(); + void T_OpenSupportedActuator(); + void T_OpenNotSupportedActuator(); + void T_OpenAllActuators(); + void T_SeveralClientsWithOpenActuatorsL(); + void T_PlayMagSweepEffectSynchronous(); + void T_PlayMagSweepEffectAsynchronous(); + void T_PlayPeriodicEffectSynchronous(); + void T_PlayPeriodicEffectAsynchronous(); + void T_PlayIVTEffectWithDirectDataSynchronous(); + void T_PlayIVTEffectWithDirectDataAsynchronous(); + void T_PlayIVTEffectRepeatWithDirectDataSynchronous(); + void T_PlayIVTEffectRepeatWithDirectDataAsynchronous(); + void T_GetEffectState(); + void T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous(); + void T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous(); + void T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous(); + void T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous(); + void T_LoadMultipleIVTData(); + void T_PlayIVTEffectsFromMultipleIVTDataSynchronous(); + void T_PlayIVTEffectsFromMultipleIVTDataAsynchronous(); + void T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous(); + void T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous(); + void T_LoadIVTData(); + void T_DeleteIVTData(); + void T_DeleteAllIVTData(); + void T_LoadAndDeleteIVTData(); + void T_LoadAndDeleteIVTDataMixed(); + void T_LoadDeletePlaySync(); + void T_LoadDeletePlayAsync(); + void T_LoadDeletePlayRepeatSync(); + void T_LoadDeletePlayRepeatAsync(); + void T_PlayIVTEffectWithLoadedDataSynchronous(); + void T_PlayIVTEffectWithLoadedDataAsynchronous(); + void T_PlayIVTEffectRepeatWithLoadedDataSynchronous(); + void T_PlayIVTEffectRepeatWithLoadedDataAsynchronous(); + void T_ReserveAndReleaseHaptics(); + void T_ReserveHapticsSeveralTimes(); + void T_ReserveHapticsNoReleaseL(); + void T_ReleaseHapticsWithoutReservingFirst(); + void T_ReserveNoAutomaticFocusNotTrusted(); + void T_ReserveAlreadyReservedHigherL(); + void T_ReserveAlreadyReservedLowerL(); + void T_PlayWhenReservedL(); + void T_GetIVTEffectCount(); + void T_GetIVTEffectDuration(); + void T_GetIVTEffectIndexFromName(); + void T_GetIVTEffectType(); + void T_GetIVTEffectName(); + void T_GetIVTMagSweepEffectDefinition(); + void T_GetIVTPeriodicEffectDefinition(); + void T_CreateAndDeleteAsynchronousL(); + void T_SeveralSessionsAsynchronousL(); + void T_ConsecutiveSessionsAsynchronousL(); + void T_PauseEffect(); + void T_ResumeEffect(); + void T_StopEffect(); + void T_StopAllEffects(); + void T_PlayPauseResumeStop(); + void T_ConstantGetters(); + void T_ModifyMagSweepEffectSynchronous(); + void T_ModifyMagSweepEffectAsynchronous(); + void T_ModifyPeriodicEffectSynchronous(); + void T_ModifyPeriodicEffectAsynchronous(); + + void T_VibeStatusToS60StatusConversions(); + + void T_GetDeviceProperty_TInt_TInt(); + void T_GetDeviceProperty_TInt_TDesC(); + void T_SetDeviceProperty_TInt_TInt(); + void T_SetDeviceProperty_TInt_TDesC(); + void T_GetDeviceCapability_TInt_TInt(); + void T_GetDeviceCapability_TInt_TDesC(); + + void T_GetHapticsStatus(); + void T_ObserveHapticsStatus(); + void T_GetHapticsStatusWithReservations(); + void T_ObserveHapticsStatusWithReservations(); + void T_GetHapticsStatusWithSeveralReservations(); + void T_ObserveHapticsStatusWithSeveralReservations(); + void T_GetHapticsStatusWithSeveralClientsOneReservation(); + void T_ObserveHapticsStatusWithSeveralClientsOneReservations(); + void T_CreateStreamingEffect(); + void T_PlayStreamingSample(); + void T_PlayStreamingSampleAsync(); + void T_PlayStreamingSampleWithOffset(); + void T_PlayStreamingSampleWithOffsetAsync(); + void T_DestroyStreamingEffect(); + void T_ObserveActuatorStatus(); + void T_ObserveActuatorStatusAndHapticsStatus(); + void T_PluginMgrTransTimerExpires(); + +private: // Data + + /** + * Haptics client instance. Owned. + */ + CHWRMHaptics* iHaptics; + + /** + * Used to control tests, which are observing haptics status using + * status callback. + */ + CActiveSchedulerWait iWait; + + /** + * Async play-with-handle methods sender. + * Owned. + */ + MT_HapticsTestAsyncPlaySender* iSender; + + EUNIT_DECLARE_TEST_TABLE; + }; + +#endif // __MT_HAPTICSCLIENT_H__ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/mt_hapticsclient/mt_hapticsclient_dllmain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/mt_hapticsclient/mt_hapticsclient_dllmain.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "MT_HapticsClient.h" +#include + +EXPORT_C MEUnitTest* CreateTestSuiteL() + { + return MT_HapticsClient::NewL(); + } diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/sis/createsis.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/sis/createsis.cmd Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,26 @@ +@echo off +REM Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +REM All rights reserved. +REM This component and the accompanying materials are made available +REM under the terms of the License "Symbian Foundation License v1.0" +REM which accompanies this distribution, and is available +REM at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +REM +REM Initial Contributors: +REM Nokia Corporation - initial contribution. +REM +REM Contributors: +REM +REM Description: ?Description +REM +REM +@echo on + + +copy %EPOCROOT%epoc32\release\armv5\urel\mt_hapticsclient.dll . + +echo. +call makesis mt_hapticsclient.pkg mt_hapticsclient.sis +call signsis mt_hapticsclient.sis mt_hapticsclient.sisx rd.cer rdkey.pem + +del MT_HapticsClient.dll /Q diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/sis/mt_hapticsclient.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/sis/mt_hapticsclient.pkg Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,18 @@ + +;Languages +&EN + +;Header +#{"EUnit: MT_HapticsClient"},(0x01700000),1,0,0 + +(0x101F7961), 0, 0, 0, {"Series60ProductID"} + +;Localised Vendor name +%{"SysOpen Digia Plc"} + +;Unique vendor name +:"SysOpen Digia" + +;Files + +"MT_HapticsClient.dll"-"!:\sys\bin\MT_HapticsClient.dll" diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/sis/rd.cer --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/sis/rd.cer Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICzDCCAjWgAwIBAgIBADANBgkqhkiG9w0BAQUFADArMRAwDgYDVQQKEwdSRCBD +ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZTAeFw0wNDExMTUxMjQyMDZaFw0z +NzA5MjMxMjQyMDZaMCsxEDAOBgNVBAoTB1JEIENlcnQxFzAVBgNVBAMTDlJEIENl +cnRpZmljYXRlMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDLRF+r1FGGkCwT +rb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW46Y+LWaA8HMlDdoHRB0FgASisYcFa +gwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh7W7Dt9F5FZij8F7/9Pi6+FhhxZFI +f1DD+yry9D7+Sp+BgdNALe4XOpf25QIBA6OCAQAwgf0wDAYDVR0TBAUwAwEB/zAL +BgNVHQ8EBAMCAoQwHQYDVR0OBBYEFFi/kuGzxhVpjGxe9ZwlxC3fH9jFMFMGA1Ud +IwRMMEqAFFi/kuGzxhVpjGxe9ZwlxC3fH9jFoS+kLTArMRAwDgYDVQQKEwdSRCBD +ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZYIBADBsBgNVHSAEZTBjMGEGBFUd +IAAwWTATBggrBgEFBQcCARYHaHR0cDovLzBCBggrBgEFBQcCAjA2GjRGb3IgUiZE +IHVzYWdlIG9ubHkuIFRoaXMgY2VydGlmaWNhdGUgaXMgbm90IHRydXN0ZWQuMA0G +CSqGSIb3DQEBBQUAA4GBAHGB4RQMAgBdeT2hxfOr6f2nA/dZm+M5yX5daUtZnET9 +Ed0A9sazLawfN2G1KFQT9kxEParAyoAkpbMAsRrnRz/9cM3OHgFm/NiKRnf50DpT +7oCx0I/65mVD2kt+xXE62/Ii5KPnTufIkPi2uLvURCia1tTS8JmJ8dtxDGyQt8BR +-----END CERTIFICATE----- diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/sis/rdkey.pem --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/sis/rdkey.pem Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQDLRF+r1FGGkCwTrb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW4 +6Y+LWaA8HMlDdoHRB0FgASisYcFagwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh +7W7Dt9F5FZij8F7/9Pi6+FhhxZFIf1DD+yry9D7+Sp+BgdNALe4XOpf25QIBAwKB +gQCHgupyjYuvCsgNHn7PNtnvVxInrB5MQNoPli+O+uNJWUK/Q+57Rl+yO8AoEzDX +pFaLWiuVVhsdloDnAgabT/FXzYncs6uOHyEUV+dSXb78vtLPJqAX+Fg2i3hOXreB +yskcZ13/OsKVOu5wgrJkx2baZufkqMwOSytf5y9nwjEIKwJBAP+inobagVNrN62j +KQva3cC+UN/6XnKdTc0CA6bHyLOaJoH1xiMwG/VS2PGjHI0tiSMNtLn/QPpHJ003 +iabGhdUCQQDLjp/9UjFT6K6CF66Chqf30pZXhx+GTSQZmv/gvZiMly7X9fX9BGX3 +2MbJohBC4yI21XKTbisWywkF73Hwh+TRAkEAqmxprzxWN5zPyRdwspHpKymLP/w+ +9xOJM1atGdqFzRFvAU6EF3Vn+OHl9my9s3OwwgkjJqorUYTE3iUGby8D4wJBAIe0 +aqjhdjfwdFa6dFcEb/qMZDpaFQQzbWZnVUB+ZbMPdI/5TqitmU/l2dvBYCyXbCSO +TGJJcg8yBgP09qBamIsCQFL7j1tM0XPVQJQ89WpKCld7O9ORxRGVj1eG0tWijrH8 +mGbYh8SGCVoWV3vrKSS8GBrFVgQnqUaHuEdtM7tpCAQ= +-----END RSA PRIVATE KEY----- diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_eunit/update.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_eunit/update.bat Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,2 @@ +copy \epoc32\release\winscw\udeb\ut_*.dll \epoc32\release\winscw\udeb\z\sys\bin\ +copy \epoc32\release\winscw\udeb\mt_*.dll \epoc32\release\winscw\udeb\z\sys\bin\ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/bwins/hapticsclienttestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/bwins/hapticsclienttestu.def Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCHapticsClientTest@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CHapticsClientTest * LibEntryL(class CTestModuleIf &) + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/conf/hapticsclienttest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/conf/hapticsclienttest.cfg Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,1127 @@ +[Define] +// Add general definitions here +ETrue 1 +EFalse 0 +[Enddefine] + +[StifSettings] +// Add stif settings here +CheckHeapBalance= on +[EndStifSettings] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 001: Create and destroy +create hapticsclienttest testClass +print STEP 1 : Create and destroy +testClass CreateAndDestroy +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 002: Several sessions +create hapticsclienttest testClass +print STEP 1 : Several sessions +testClass SeveralSessions +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 003: Consecutive sessions +create hapticsclienttest testClass +print STEP 1 : Consecutive sessions +testClass ConsecutiveSessions +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 004: Supported actuators +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Supported actuators +testClass SupportedActuators +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 005: Open supported actuator +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Open supported actuator +testClass OpenSupportedActuator +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 006: Open unsupported actuator +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Open unsupported actuator +testClass OpenUnsupportedActuator +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 007: Open all actuators +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Open all actuators +testClass OpenAllActuators +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 008: 2 clients open actuators +create hapticsclienttest testClass +print STEP 1 : 2 clients open actuators +testClass 2ClientsOpenActuators +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 009: Play MagSweep synch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play MagSweep synch (data) +testClass PlayMagSweepSynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 010: Play MagSweep asynch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play MagSweep asynch (data) +testClass PlayMagSweepAsynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 011: Play Periodic synch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play Periodic synch (data) +testClass PlayPeriodicSynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 012: Play Periodic asynch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play Periodic asynch (data) +testClass PlayPeriodicAsynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 013: Play IVT synch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play IVT synch (data) +testClass PlayIVTSynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 014: Play IVT asynch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play IVT asynch (data) +testClass PlayIVTAsynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 015: Repeat IVT synch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Repeat IVT synch (data) +testClass RepeatIVTSynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 016: Repeat IVT asynch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Repeat IVT asynch (data) +testClass RepeatIVTAsynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 017: Get effect state +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get effect state +testClass GetEffectState +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 018: Repeat IVT synch (data - non-timeline) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Repeat IVT synch (data - non-timeline) +testClass RepeatIVTSynchDataNonTimeline +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 019: Repeat IVT asynch (data - non-timeline) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Repeat IVT asynch (data - non-timeline) +testClass RepeatIVTAsynchDataNonTimeline +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 020: Zero-repeat IVT synch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Zero-repeat IVT synch (data) +testClass Zero-repeatIVTSynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 021: Zero-repeat IVT asynch (data) +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Zero-repeat IVT asynch (data) +testClass Zero-repeatIVTAsynchData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 022: Load IVT data +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load IVT data +testClass LoadIVTData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + + +//------------------------------------------------------------------------------ +[Test] +title Test case # 023: Delete IVT data +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Delete IVT data +testClass DeleteIVTData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 024: Delete All IVT data +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Delete All IVT data +testClass DeleteAllIVTData +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 025: Load and delete multiple +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load and delete multiple +testClass LoadAndDeleteMultiple +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 026: Load and delete mixed +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load and delete mixed +testClass LoadAndDeleteMixed +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 027: Load, Del, Play sync +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load, Del, Play sync +testClass LoadDeletePlaySync +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 028: Load, Del, Play async +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load, Del, Play async +testClass LoadDeletePlayAsync +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 029: Load, Del, Repeat sync +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load, Del, Repeat sync +testClass LoadDeletePlayRepeatSync +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 030: Load, Del, Repeat async +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load, Del, Repeat async +testClass LoadDeletePlayRepeatAsync +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 031: Play loaded IVT synch +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play loaded IVT synch +testClass PlayLoadedIVTSynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 032: Play loaded IVT asynch +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play loaded IVT asynch +testClass PlayLoadedIVTAsynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 033: Repeat loaded IVT synch +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Repeat loaded IVT synch +testClass RepeatLoadedIVTSynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 034: Repeat loaded IVT asynch +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Repeat loaded IVT asynch +testClass RepeatLoadedIVTAsynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 035: Load multiple IVT-data +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Load multiple IVT-data +testClass LoadMultipleIVT-data +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 036: Play from multiple IVT-data synch +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play from multiple IVT-data synch +testClass PlayFromMultipleIVT-dataSynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 037: Play from multiple IVT-data asynch +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play from multiple IVT-data asynch +testClass PlayFromMultipleIVT-dataAsynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 038: Play repeat from multiple IVT-data +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play repeat from multiple IVT-data synch +testClass PlayRepeatFromMultipleIVT-dataSynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 039: Play repeat from multiple IVT-data +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play repeat from multiple IVT-data asynch +testClass PlayRepeatFromMultipleIVT-dataAsynch +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 040: Status conversions +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Status conversions +testClass StatusConversions +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 041: Reserve and release +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Reserve and release +testClass ReserveAndRelease +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 042: Reserve several times +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Reserve several times +testClass ReserveSeveralTimes +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 043: Reserve, no release +create hapticsclienttest testClass +print STEP 1 : Reserve, no release +testClass ReserveNoRelease +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 044: Release, no reserve +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Release, no reserve +testClass ReleaseNoReserve +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 045: Reserve forceNoCoe +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Reserve forceNoCoe +testClass ReserveForceNoCoe +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 046: Reserve reserved higher +create hapticsclienttest testClass +print STEP 1 : Reserve reserved higher +testClass ReserveReservedHigher +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 047: Reserve reserved lower +create hapticsclienttest testClass +print STEP 1 : Reserve reserved lower +testClass ReserveReservedLower +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 048: Play when reserved +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play when reserved +testClass PlayWhenReserved +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + + +//------------------------------------------------------------------------------ +[Test] +title Test case # 049: Get effect count +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get effect count +testClass GetEffectCount +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 050: Get effect duration +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get effect duration +testClass GetEffectDuration +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 051: Get effect index from name +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get effect index from name +testClass GetEffectIndexFromName +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 052: Get effect type +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get effect type +testClass GetEffectType +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 053: Get effect name +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get effect name +testClass GetEffectName +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 054: Get MagSweep effect definition +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get MagSweep effect definition +testClass GetMagSweepEffectDefinition +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 055: Get Periodic effect definition +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get Periodic effect definition +testClass GetPeriodicEffectDefinition +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 056: Create and destroy asynchronous +create hapticsclienttest testClass +print STEP 1 : Create and destroy asynchronous +testClass CreateAndDestroyAsynchronous +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 057: Several sessions asynchronous +create hapticsclienttest testClass +print STEP 1 : Several sessions asynchronous +testClass SeveralSessionsAsynchronous +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 058: Consecutive sessions asynchronous +create hapticsclienttest testClass +print STEP 1 : Consecutive sessions asynchronous +testClass ConsecutiveSessionsAsynchronous +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 059: Constant getters +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Constant getters +testClass ConstantGetters +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 060: Pause effect +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Pause effect +testClass PauseEffect +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 061: Resume effect +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Resume effect +testClass ResumeEffect +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 062: Stop effect +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Stop effect +testClass StopEffect +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 063: Stop all effects +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Stop all effects +testClass StopAllEffects +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 064: Play, pause, resume, stop +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play, pause, resume, stop +testClass PlayPauseResumeStop +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 065: Modify playing magsweep effect synchronous +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Modify playing magsweep effect synchronous +testClass ModifyPlayingMagsweepEffectSynchronous +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 066: Modify playing magsweep effect asynchronous +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Modify playing magsweep effect asynchronous +testClass ModifyPlayingMagsweepEffectAsynchronous +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 067: Modify playing periodic effect synchronous +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Modify playing periodic effect synchronous +testClass ModifyPlayingPeriodicEffectSynchronous +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 068: Modify playing periodic effect asynchronous +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Modify playing periodic effect asynchronous +testClass ModifyPlayingPeriodicEffectAsynchronous +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 069: Get device property of TInt value +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get device property of TInt value +testClass GetDevicePropertyOfTIntValue +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 070: Get device property of TDesC value +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get device property of TDesC value +testClass GetDevicePropertyOfTDesCValue +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 071: Set device property of TInt value +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Set device property of TInt value +testClass SetDevicePropertyOfTIntValue +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 072: Set device property of TDesC value +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Set device property of TDesC value +testClass SetDevicePropertyOfTDesCValue +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 073: Get device capability of TInt value +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get device capability of TInt value +testClass GetDeviceCapabilityOfTIntValue +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 074: Get device capability of TDesC value +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Get device capability of TDesC value +testClass GetDeviceCapabilityOfTDesCValue +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 075: Fetch status +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Fetch status +testClass FetchStatus +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 076: Observe status +create hapticsclienttest testClass +print STEP 1 : Observe status +testClass ObserveStatus +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 077: Status, reservation +create hapticsclienttest testClass +print STEP 1 : Status, reservation +testClass StatusReservation +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 078: Status, observe, reservation +create hapticsclienttest testClass +print STEP 1 : Status, observe, reservation +testClass StatusObserveReservation +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 079: Status, 2 reservations +create hapticsclienttest testClass +print STEP 1 : Status, 2 reservations +testClass Status2Reservations +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 080: Status, observe, 2 reservation +create hapticsclienttest testClass +print STEP 1 : Status, observe, 2 reservation +testClass StatusObserve2Reservation +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 081: Status, many clients +create hapticsclienttest testClass +print STEP 1 : Status, many clients +testClass StatusManyClients +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 082: Status, observer, many clients +create hapticsclienttest testClass +print STEP 1 : Status, observer, many clients +testClass StatusObserverManyClients +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 083: Create streaming effect +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Create streaming effect +testClass CreateStreamingEffect +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 084: Play streaming sample +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play streaming sample +testClass PlayStreamingSample +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 085: Play streaming sample, async +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play streaming sample, async +testClass PlayStreamingSampleAsync +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 086: Play streaming sample with offset +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play streaming sample with offset +testClass PlayStreamingSampleWithOffset +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 087: Play streaming sample with offset, async +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Play streaming sample with offset, async +testClass PlayStreamingSampleWithOffsetAsync +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 088: Destroy streaming effect +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Destroy streaming effect +testClass DestroyStreamingEffect +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 089: Actuator status +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Actuator status +testClass ActuatorStatus +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 090: Actuator/Haptics status +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Actuator/Haptics status +testClass ActuatorOrHapticsStatus +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] + +//------------------------------------------------------------------------------ +[Test] +title Test case # 091: Plugin Manager Timer Expires +create hapticsclienttest testClass +print STEP 1 : Setup +testClass Setup +print STEP 2 : Plugin Manager Transction response Timer Expires +testClass PluginMgrTransTimerExpires +print STEP 3 : Teardown +testClass Teardown +delete testClass +[Endtest] diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/eabi/hapticsclienttestu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/eabi/hapticsclienttestu.def Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLR13CTestModuleIf @ 1 NONAME + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../init/hwrmhapticsuid.ini /epoc32/release/winscw/udeb/z/private/200184b9/hwrmhapticsuid.ini +../init/hwrmhapticsuid.ini /epoc32/data/z/private/200184b9/hwrmhapticsuid.ini +../init/hapticsclienttest.ini /epoc32/winscw/c/TestFramework/hapticsclienttest.ini +../conf/hapticsclienttest.cfg /epoc32/winscw/c/TestFramework/hapticsclienttest.cfg + + +PRJ_MMPFILES +hapticsclienttest.mmp + +// End of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/createsis.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/createsis.cmd Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,21 @@ +@echo off +REM Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +REM All rights reserved. +REM This component and the accompanying materials are made available +REM under the terms of the License "Symbian Foundation License v1.0" +REM which accompanies this distribution, and is available +REM at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +REM +REM Initial Contributors: +REM Nokia Corporation - initial contribution. +REM +REM Contributors: +REM +REM Description: ?Description +REM +REM +@echo on + +echo. +call makesis hapticsclienttest.pkg hapticsclienttest.sis +call signsis hapticsclienttest.sis hapticsclienttest.sisx rd.cer rdkey.pem diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/envrecall.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/envrecall.cmd Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,47 @@ +@echo off +REM Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +REM All rights reserved. +REM This component and the accompanying materials are made available +REM under the terms of "Eclipse Public License v1.0" +REM which accompanies this distribution, and is available +REM at the URL "http://www.eclipse.org/legal/epl-v10.html". +REM +REM Initial Contributors: +REM Nokia Corporation - initial contribution. +REM +REM Contributors: +REM +REM Description: ?Description +REM +REM +@echo on + + +@echo Cleaning Haptics Test stubs... +pushd ..\..\hapticstestplugins\group\ +call sbs -c armv5.test reallyclean +call sbs -c winscw.test reallyclean +popd +@echo Cleaning Haptics Test stubs... Finished + + +@echoBuild Haptics SystemSW Adaptation Stub plugins... +pushd \sf\adaptation\stubs\systemswstubs\hwrmhapticsstubplugin\group +call sbs -c winscw +popd +@echo Build Haptics SystemSW Adaptation Stub plugins... Finished + + +@echo Build Haptics NCP Adaptation plugins... +pushd \ncp_sw\corecom\modemadaptation_ext\adaptationlayer_ext\hapticsadaptation\group +call sbs -c armv5 +call sbs -c armv5.atlantis +call sbs -c armv5.atlantis102 +call sbs -c armv5.atlantisry21x +call sbs -c armv5.gekko79 +call sbs -c armv5.platsim79 +call sbs -c armv5.tasmania +call sbs -c armv5.vasco +REM NOTE!! Please keep updating the above list as per the variant's available in the Product SDK +popd +@echo Build Haptics NCP Adaptation plugins... Finished diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/envsetup.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/envsetup.cmd Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,49 @@ +@echo off +REM Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +REM All rights reserved. +REM This component and the accompanying materials are made available +REM under the terms of "Eclipse Public License v1.0" +REM which accompanies this distribution, and is available +REM at the URL "http://www.eclipse.org/legal/epl-v10.html". +REM +REM Initial Contributors: +REM Nokia Corporation - initial contribution. +REM +REM Contributors: +REM +REM Description: ?Description +REM +REM +@echo on + + +@echo Cleaning Haptics NCP Adaptation plugins... +pushd \ncp_sw\corecom\modemadaptation_ext\adaptationlayer_ext\hapticsadaptation\group +call sbs -c armv5 reallyclean +call sbs -c armv5.atlantis reallyclean +call sbs -c armv5.atlantis102 reallyclean +call sbs -c armv5.atlantisry21x reallyclean +call sbs -c armv5.gekko79 reallyclean +call sbs -c armv5.platsim79 reallyclean +call sbs -c armv5.tasmania reallyclean +call sbs -c armv5.vasco reallyclean +REM NOTE!! Please keep updating the above list as per the variant's available in the Product SDK +popd +@echo Cleaning Haptics NCP Adaptation plugins... Finished + + +@echo Cleaning Haptics SystemSW Adaptation Stub plugins... +pushd \sf\adaptation\stubs\systemswstubs\hwrmhapticsstubplugin\group +call sbs -c winscw reallyclean +popd +@echo Cleaning Haptics SystemSW Adaptation Stub plugins... Finished + + +@echo Setting up Haptics Test stubs... +pushd ..\..\hapticstestplugins\group\ +call sbs -c armv5.test reallyclean +call sbs -c winscw.test reallyclean +call sbs -c armv5.test +call sbs -c winscw.test +popd +@echo Setting up Haptics Test stubs... Finished diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/hapticsclienttest.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/hapticsclienttest.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +TARGET hapticsclienttest.dll +TARGETTYPE dll +UID 0x1000af5a 0x101FB3E7 + +CAPABILITY ALL -TCB +VENDORID VID_DEFAULT + +// Sources required by the test suite +SOURCEPATH ../src +SOURCE hapticsclienttest_main.cpp +SOURCE hapticsclienttest.cpp + +USERINCLUDE ../inc + +OS_LAYER_LIBC_SYSTEMINCLUDE +OS_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY hwrmhapticsclient.lib + +LANG SC + +EPOCALLOWDLLDATA + +/* +START WINS +?wins_specific_information +END + +START MARM +?marm_specific_information +END +*/ +// Other possible keywords: + +// DOCUMENT ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes) +/* +START BITMAP ?target +TARGETPATH ?emulated_path_on_target_machine +HEADER +SOURCE ?color_depth ?source_bitmap +END +*/ +// DEFFILE ?filename +// AIF ?filename + +SMPSAFE + +// End of File diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/hapticsclienttest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/hapticsclienttest.pkg Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,34 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of the License "Symbian Foundation License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +; + + +;Languages +&EN + +#{"hapticstestcontrol"},(0x101FB3E7),1,0,0,TYPE=SA + +;Localised Vendor name +%{"hapticstestcontrol EN"} + +; Vendor name +: "hapticstestcontrol" + +"\epoc32\release\armv5\urel\hapticsclienttest.dll"-"c:\sys\bin\hapticsclienttest.dll" + +"..\conf\hapticsclienttest.cfg"-"c:\testframework\hapticsclienttest.cfg" +"..\init\hapticsclienttest.ini"-"c:\testframework\hapticsclienttest.ini" + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/mt_hapticslicense.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/mt_hapticslicense.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include + +TARGET MT_HapticsLicense.dll +TARGETTYPE dll +UID 0x1000af5a 0x01700000 + +CAPABILITY ALL -TCB -DRM +VENDORID VID_DEFAULT + + +// Sources required by the test suite + +SOURCEPATH ../MT_HapticsLicenseKey +SOURCE mt_hapticslicensekey.cpp +SOURCE MT_HapticsLicenseKey_DllMain.cpp + +USERINCLUDE ../MT_HapticsLicenseKey + +OS_LAYER_LIBC_SYSTEMINCLUDE +OS_LAYER_SYSTEMINCLUDE + +LIBRARY EUnit.lib +LIBRARY EUnitUtil.lib +LIBRARY euser.lib +LIBRARY hwrmhapticsclient.lib +LIBRARY hwrmhapticslicense.lib + +SMPSAFE diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/rd.cer --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/rd.cer Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE----- +MIICzDCCAjWgAwIBAgIBADANBgkqhkiG9w0BAQUFADArMRAwDgYDVQQKEwdSRCBD +ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZTAeFw0wNDExMTUxMjQyMDZaFw0z +NzA5MjMxMjQyMDZaMCsxEDAOBgNVBAoTB1JEIENlcnQxFzAVBgNVBAMTDlJEIENl +cnRpZmljYXRlMIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDLRF+r1FGGkCwT +rb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW46Y+LWaA8HMlDdoHRB0FgASisYcFa +gwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh7W7Dt9F5FZij8F7/9Pi6+FhhxZFI +f1DD+yry9D7+Sp+BgdNALe4XOpf25QIBA6OCAQAwgf0wDAYDVR0TBAUwAwEB/zAL +BgNVHQ8EBAMCAoQwHQYDVR0OBBYEFFi/kuGzxhVpjGxe9ZwlxC3fH9jFMFMGA1Ud +IwRMMEqAFFi/kuGzxhVpjGxe9ZwlxC3fH9jFoS+kLTArMRAwDgYDVQQKEwdSRCBD +ZXJ0MRcwFQYDVQQDEw5SRCBDZXJ0aWZpY2F0ZYIBADBsBgNVHSAEZTBjMGEGBFUd +IAAwWTATBggrBgEFBQcCARYHaHR0cDovLzBCBggrBgEFBQcCAjA2GjRGb3IgUiZE +IHVzYWdlIG9ubHkuIFRoaXMgY2VydGlmaWNhdGUgaXMgbm90IHRydXN0ZWQuMA0G +CSqGSIb3DQEBBQUAA4GBAHGB4RQMAgBdeT2hxfOr6f2nA/dZm+M5yX5daUtZnET9 +Ed0A9sazLawfN2G1KFQT9kxEParAyoAkpbMAsRrnRz/9cM3OHgFm/NiKRnf50DpT +7oCx0I/65mVD2kt+xXE62/Ii5KPnTufIkPi2uLvURCia1tTS8JmJ8dtxDGyQt8BR +-----END CERTIFICATE----- diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/group/rdkey.pem --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/group/rdkey.pem Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQDLRF+r1FGGkCwTrb420kbnAps7gi1yYUcXYUdWeFTuBeQe5eW4 +6Y+LWaA8HMlDdoHRB0FgASisYcFagwno9+oFf4AJka4H1gWEs5XTGwAA1s0d8XGh +7W7Dt9F5FZij8F7/9Pi6+FhhxZFIf1DD+yry9D7+Sp+BgdNALe4XOpf25QIBAwKB +gQCHgupyjYuvCsgNHn7PNtnvVxInrB5MQNoPli+O+uNJWUK/Q+57Rl+yO8AoEzDX +pFaLWiuVVhsdloDnAgabT/FXzYncs6uOHyEUV+dSXb78vtLPJqAX+Fg2i3hOXreB +yskcZ13/OsKVOu5wgrJkx2baZufkqMwOSytf5y9nwjEIKwJBAP+inobagVNrN62j +KQva3cC+UN/6XnKdTc0CA6bHyLOaJoH1xiMwG/VS2PGjHI0tiSMNtLn/QPpHJ003 +iabGhdUCQQDLjp/9UjFT6K6CF66Chqf30pZXhx+GTSQZmv/gvZiMly7X9fX9BGX3 +2MbJohBC4yI21XKTbisWywkF73Hwh+TRAkEAqmxprzxWN5zPyRdwspHpKymLP/w+ +9xOJM1atGdqFzRFvAU6EF3Vn+OHl9my9s3OwwgkjJqorUYTE3iUGby8D4wJBAIe0 +aqjhdjfwdFa6dFcEb/qMZDpaFQQzbWZnVUB+ZbMPdI/5TqitmU/l2dvBYCyXbCSO +TGJJcg8yBgP09qBamIsCQFL7j1tM0XPVQJQ89WpKCld7O9ORxRGVj1eG0tWijrH8 +mGbYh8SGCVoWV3vrKSS8GBrFVgQnqUaHuEdtM7tpCAQ= +-----END RSA PRIVATE KEY----- diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/inc/hapticsclienttest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/inc/hapticsclienttest.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,215 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef HAPTICSCLIENTTEST_H +#define HAPTICSCLIENTTEST_H + +// INCLUDES +#include +#include "hapticsclienttest_main.h" + + +/** + * Callback class for haptics status observation. + */ +NONSHARABLE_CLASS( THapticsStatusCallback ) : public MHWRMHapticsObserver + { +public: + + /** + * C++ constructor. + */ + THapticsStatusCallback( CHapticsClientTest* aMTCallback ); + + /** + * Destructor. + */ + ~THapticsStatusCallback(); + + /** + * Returns the last received status. + * + * @return Last status value. + */ + MHWRMHapticsObserver::THWRMHapticsStatus Status(); + + /** + * Starts a new wait loop under the current active scheduler. + * This method can be used in module tests to wait for the + * notification to be received. When the notification is + * received (i.e. callback is called by haptics), the waiting + * is stopped and the execution continues whereever this method + * was called. + */ + void WaitForNotification(); + +public: // from MHWRMHapticsObserver + + virtual void HapticsStatusChangedL( THWRMHapticsStatus aStatus ); + virtual void EffectCompletedL( TInt aError, TInt aEffectHandle ); + +private: + + /** + * Last received haptics status through status observation. + */ + MHWRMHapticsObserver::THWRMHapticsStatus iHapticsStatus; + + /** + * Callback which is notified, when a status has been received. + */ + CHapticsClientTest* iMTCallback; + }; + + +/** + * Callback class for actuator status observation. + */ +NONSHARABLE_CLASS( TActuatorStatusCallback ) : public MHWRMHapticsActuatorObserver + { +public: + + /** + * C++ constructor. + */ + TActuatorStatusCallback( CHapticsClientTest* aMTCallback ); + + /** + * Destructor. + */ + ~TActuatorStatusCallback(); + + /** + * Returns the last received state. + * + * @return Last status value. + */ + MHWRMHapticsActuatorObserver::THWRMActuatorEvents Status( THWRMLogicalActuators aActuator ); + + /** + * Starts a new wait loop under the current active scheduler. + * This method can be used in module tests to wait for the + * notification to be received. When the notification is + * received (i.e. callback is called by haptics), the waiting + * is stopped and the execution continues whereever this method + * was called. + */ + void WaitForNotification(); + +public: // from MHWRMHapticsActuatorObserver + + virtual void ActuatorEventL( THWRMActuatorEvents aEvent, + THWRMLogicalActuators aActuator ); + +private: + + /** + * Last received actuator status through state observation. + */ + RArray iActuatorStatus; + + /** + * Callback which is notified, when a state has been received. + */ + CHapticsClientTest* iMTCallback; + }; + +/** + * Class for making async play-with-filehandle calls on behalf of the + * CHapticsClientTest + */ +NONSHARABLE_CLASS( MT_HapticsTestAsyncPlaySender ) : public CActive + { +public: + + /** + * Constructor + * + * @param aUi Pointer to the test appl UI object. + */ + MT_HapticsTestAsyncPlaySender( CHapticsClientTest* aMTCallback ); + + /** + * Destructor + */ + virtual ~MT_HapticsTestAsyncPlaySender(); + + /** + * Method for fileHandle type playing of effects repeatedly in asynch mode + * + * @param aHaptics Pointer to the haptics interface object. + * @param aFileHandle Handle for the effect data buffer from which to + * play the effects. + * @param aEffectIndex Index of the effect that is being played. + * @param aRepeat Number of repeats. + * @param aEffectHandle Out-parameter to which the handle for the played + * effect is returned. + */ + void PlayRepeat( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TUint8 aRepeat, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ); + + /** + * Method for fileHandle type playing of effects in asynch mode + * + * @param aHaptics Pointer to the haptics interface object. + * @param aFileHandle Handle for the effect data buffer from which to + * play the effects. + * @param aEffectIndex Index of the effect that is being played. + * @param aEffectHandle Out-parameter to which the handle for the played + * effect is returned. + */ + void Play( CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ); + +public: + + /** + * From CActive + */ + virtual void RunL(); + + /** + * From CActive + */ + virtual void DoCancel(); + + /** + * From CActive + */ + virtual TInt RunError( TInt aError ); + +private: + + /** + * Pointer to the CHapticsClientTest. + * Not owned. + */ + CHapticsClientTest* iMTCallback; + + TRequestStatus* iClientStatus; + }; + + +#endif // HAPTICSCLIENTTEST_H diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/inc/hapticsclienttest_main.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/inc/hapticsclienttest_main.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,289 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +#ifndef HAPTICSCLIENTTESTMAIN_H +#define HAPTICSCLIENTTESTMAIN_H + +// INCLUDES +#include +#include +#include +#include + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def +// Logging path +_LIT( KHapticsClientTestLogPath, "\\logs\\HapticsClientTest\\" ); +// Log file +_LIT( KHapticsClientTestLogFile, "HapticsClientTest.txt" ); + +// FUNCTION PROTOTYPES +//?type ?function_name(?arg_list); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; +class MT_HapticsTestAsyncPlaySender; + +// DATA TYPES +//enum ?declaration +//typedef ?declaration +//extern ?data_type; + +// CLASS DECLARATION + +/** +* HpaticsClient test class for STIF Test Framework TestScripter. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CHapticsClientTest) : public CScriptBase + { + public: // Constructors and destructor + + /** + * Two-phased constructor. + */ + static CHapticsClientTest* NewL( CTestModuleIf& aTestModuleIf ); + + /** + * Destructor. + */ + virtual ~CHapticsClientTest(); + + public: // New functions + + /** + * ?member_description. + * @since ?Series60_version + * @param ?arg1 ?description + * @return ?description + */ + //?type ?member_function( ?type ?arg1 ); + + public: // Functions from base classes + + /** + * From CScriptBase Runs a script line. + * @since ?Series60_version + * @param aItem Script line containing method name and parameters + * @return Symbian OS error code + */ + virtual TInt RunMethodL( CStifItemParser& aItem ); + + /** + * Method, which is called by the status callback, when a status + * has been received. Stops the wait loop waiting for a new status. + */ + void HapticsStatusReceived(); + + private: + + /** + * C++ default constructor. + */ + CHapticsClientTest( CTestModuleIf& aTestModuleIf ); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Frees all resources allocated from test methods. + * @since ?Series60_version + */ + void Delete(); + + /** + * Build resources needed for test methods. + * @since ?Series60_version + */ + void BuildL (); + + /** + * Test methods are listed below. + */ + /** + * Test construction; Creates haptics client instance. + */ + TInt SetupL(); + + /** + * Test teardown; Deletes haptics client instance. + */ + TInt Teardown(); + + /** + * Helpers for creating effects + */ + void CreateMagSweepEffect( CHWRMHaptics::THWRMHapticsMagSweepEffect& aEffect ); + void CreatePeriodicEffect( CHWRMHaptics::THWRMHapticsPeriodicEffect& aEffect ); + void CreateIVTEffect( RBuf8& aBuffer, CHWRMHaptics::THWRMHapticsEffectTypes aType ); + + /** + * Helper for such cases where it is first needed to load IVT data + */ + TInt LoadIVTDataInternal( TInt& aFileHandle, CHWRMHaptics::THWRMHapticsEffectTypes aType, + TBool aOpenActuator = ETrue ); + + /** + * Helper for such cases where it is first needed to load IVT data + */ + TInt LoadIVTDataInternal( TInt& aFileHandle, + const TUint8 aIvtData[], + TInt aIvtDataSize, + TBool aOpenActuator = ETrue ); + + /** + * Helper for such cases where contents of stream sample + * is not relevant. + */ + void CreateDummyStreamSample( TInt aSize, RBuf8& aBuffer ); + + TInt T_CreateAndDeleteL(); + TInt T_SeveralSessionsL(); + TInt T_ConsecutiveSessionsL(); + TInt T_SupportedActuators(); + TInt T_OpenSupportedActuator(); + TInt T_OpenNotSupportedActuator(); + TInt T_OpenAllActuators(); + TInt T_SeveralClientsWithOpenActuatorsL(); + TInt T_PlayMagSweepEffectSynchronous(); + TInt T_PlayMagSweepEffectAsynchronous(); + TInt T_PlayPeriodicEffectSynchronous(); + TInt T_PlayPeriodicEffectAsynchronous(); + TInt T_PlayIVTEffectWithDirectDataSynchronous(); + TInt T_PlayIVTEffectWithDirectDataAsynchronous(); + TInt T_PlayIVTEffectRepeatWithDirectDataSynchronous(); + TInt T_PlayIVTEffectRepeatWithDirectDataAsynchronous(); + TInt T_GetEffectState(); + TInt T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous(); + TInt T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous(); + TInt T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous(); + TInt T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous(); + TInt T_LoadMultipleIVTData(); + TInt T_PlayIVTEffectsFromMultipleIVTDataSynchronous(); + TInt T_PlayIVTEffectsFromMultipleIVTDataAsynchronous(); + TInt T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous(); + TInt T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous(); + TInt T_LoadIVTData(); + TInt T_DeleteIVTData(); + TInt T_DeleteAllIVTData(); + TInt T_LoadAndDeleteIVTData(); + TInt T_LoadAndDeleteIVTDataMixed(); + TInt T_LoadDeletePlaySync(); + TInt T_LoadDeletePlayAsync(); + TInt T_LoadDeletePlayRepeatSync(); + TInt T_LoadDeletePlayRepeatAsync(); + TInt T_PlayIVTEffectWithLoadedDataSynchronous(); + TInt T_PlayIVTEffectWithLoadedDataAsynchronous(); + TInt T_PlayIVTEffectRepeatWithLoadedDataSynchronous(); + TInt T_PlayIVTEffectRepeatWithLoadedDataAsynchronous(); + TInt T_ReserveAndReleaseHaptics(); + TInt T_ReserveHapticsSeveralTimes(); + TInt T_ReserveHapticsNoReleaseL(); + TInt T_ReleaseHapticsWithoutReservingFirst(); + TInt T_ReserveNoAutomaticFocusNotTrusted(); + TInt T_ReserveAlreadyReservedHigherL(); + TInt T_ReserveAlreadyReservedLowerL(); + TInt T_PlayWhenReservedL(); + TInt T_GetIVTEffectCount(); + TInt T_GetIVTEffectDuration(); + TInt T_GetIVTEffectIndexFromName(); + TInt T_GetIVTEffectType(); + TInt T_GetIVTEffectName(); + TInt T_GetIVTMagSweepEffectDefinition(); + TInt T_GetIVTPeriodicEffectDefinition(); + TInt T_CreateAndDeleteAsynchronousL(); + TInt T_SeveralSessionsAsynchronousL(); + TInt T_ConsecutiveSessionsAsynchronousL(); + TInt T_PauseEffect(); + TInt T_ResumeEffect(); + TInt T_StopEffect(); + TInt T_StopAllEffects(); + TInt T_PlayPauseResumeStop(); + TInt T_ConstantGetters(); + TInt T_ModifyMagSweepEffectSynchronous(); + TInt T_ModifyMagSweepEffectAsynchronous(); + TInt T_ModifyPeriodicEffectSynchronous(); + TInt T_ModifyPeriodicEffectAsynchronous(); + TInt T_VibeStatusToS60StatusConversions(); + TInt T_GetDeviceProperty_TInt_TInt(); + TInt T_GetDeviceProperty_TInt_TDesC(); + TInt T_SetDeviceProperty_TInt_TInt(); + TInt T_SetDeviceProperty_TInt_TDesC(); + TInt T_GetDeviceCapability_TInt_TInt(); + TInt T_GetDeviceCapability_TInt_TDesC(); + TInt T_GetHapticsStatus(); + TInt T_ObserveHapticsStatus(); + TInt T_GetHapticsStatusWithReservations(); + TInt T_ObserveHapticsStatusWithReservations(); + TInt T_GetHapticsStatusWithSeveralReservations(); + TInt T_ObserveHapticsStatusWithSeveralReservations(); + TInt T_GetHapticsStatusWithSeveralClientsOneReservation(); + TInt T_ObserveHapticsStatusWithSeveralClientsOneReservations(); + TInt T_CreateStreamingEffect(); + TInt T_PlayStreamingSample(); + TInt T_PlayStreamingSampleAsync(); + TInt T_PlayStreamingSampleWithOffset(); + TInt T_PlayStreamingSampleWithOffsetAsync(); + TInt T_DestroyStreamingEffect(); + TInt T_ObserveActuatorStatus(); + TInt T_ObserveActuatorStatusAndHapticsStatus(); + TInt T_PluginMgrTransTimerExpires(); + + private: // Data + /** + * Haptics client instance. Owned. + */ + CHWRMHaptics* iHaptics; + + /** + * Used to control tests, which are observing haptics status using + * status callback. + */ + CActiveSchedulerWait iWait; + + /** + * Async play-with-handle methods sender. + * Owned. + */ + MT_HapticsTestAsyncPlaySender* iSender; + + public: // Friend classes + //?friend_class_declaration; + protected: // Friend classes + //?friend_class_declaration; + private: // Friend classes + //?friend_class_declaration; + }; + +#endif // HAPTICSCLIENTTEST_H + +// End of File diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/inc/trace.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/inc/trace.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,617 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Trace macro definitions. +* +*/ + +#ifndef TRACE_H +#define TRACE_H + +#include // TCleanupItem +#include "traceconfiguration.hrh" + +#ifdef TRACE_INTO_FILE +#include // RFileLogger +#else +#include // RDebug +#endif + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- +// + +// NOTE! +// Replace all COMPONENT_NAME occurnaces with your own component / module name. + +/** +* Prefix trace macro to complete tracing with component name. +* Returns TDesC which can be used directly with RDebug or RFileLogger. +*/ +#define _PREFIX_TRACE( aMsg ) TPtrC( (const TText*)L"[HapticsClientTest]: " L##aMsg ) + +/** +* Prefix error trace +*/ +#define _PREFIX_ERROR( aMsg ) _PREFIX_TRACE( "[ERROR: %d]: " L##aMsg ) + +/** +* Prefix info trace. +*/ +#define _PREFIX_INFO( aMsg ) _PREFIX_TRACE( "[INFO]: " L##aMsg ) + +/** +* Prefix macro for strings +*/ +#define _PREFIX_CHAR( aMsg ) (const char*)"[HapticsClientTest]: " ##aMsg + +/** +* Define needed directories if TRACE_INTO_FILE macro in use +*/ +#ifdef TRACE_INTO_FILE + + _LIT( KDir, "HapticsClientTest" ); + _LIT( KFile, "HapticsClientTest.txt" ); + _LIT( KFullPath, "c:\\logs\\HapticsClientTest\\" ); + +#endif + +//----------------------------------------------------------------------------- +// Error trace macros +//----------------------------------------------------------------------------- +// +#ifdef ERROR_TRACE + + /** + * Error trace definitions. + */ + #ifdef TRACE_INTO_FILE + + #define ERROR( aErr, aMsg )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr );\ + }\ + } + #define ERROR_1( aErr, aMsg, aP1 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1 );\ + }\ + } + #define ERROR_2( aErr, aMsg, aP1, aP2 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\ + }\ + } + #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\ + }\ + } + #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4 );\ + }\ + } + #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5 );\ + }\ + } + #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5 );\ + }\ + } + #define TEST_ASSERT_DESC( aCondition, aDescription ) \ + {\ + if ( aCondition )\ + {\ + }\ + else\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aDescription ) );\ + }\ + } + #else//TRACE_INTO_FILE not defined + + #define ERROR( aErr, aMsg )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr );\ + }\ + } + #define ERROR_1( aErr, aMsg, aP1 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1 );\ + }\ + } + #define ERROR_2( aErr, aMsg, aP1, aP2 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\ + }\ + } + #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\ + }\ + } + #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4 );\ + }\ + } + #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5 );\ + }\ + } + #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3, aP4, aP5, aP6 );\ + }\ + } + #define TEST_ASSERT_DESC( aCondition, aDescription ) \ + {\ + if ( aCondition )\ + {\ + }\ + else\ + {\ + RDebug::Print( _PREFIX_INFO( aDescription ) );\ + }\ + } + + #endif//TRACE_INTO_FILE + + #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg ) + #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 ) + #define ERROR_GEN_2( aMsg, aP1, aP2 ) ERROR_2( KErrGeneral, aMsg, aP1, aP2 ) + #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) ERROR_3( KErrGeneral, aMsg, aP1, aP3 ) + #define ERROR_GEN_4( aMsg, aP1, aP2, aP3, aP4 ) ERROR_4( KErrGeneral, aMsg, aP1, aP3, aP4 ) + #define ERROR_GEN_5( aMsg, aP1, aP2, aP3, aP4, aP5 ) ERROR_5( KErrGeneral, aMsg, aP1, aP3, aP4, aP5 ) + #define ERROR_GEN_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 ) ERROR_6( KErrGeneral, aMsg, aP1, aP3, aP4, aP5, aP6 ) + +#else//ERROR_TRACE not defined + + #define ERROR( aErr, aMsg ) + #define ERROR_1( aErr, aMsg, aP1 ) + #define ERROR_2( aErr, aMsg, aP1, aP2 ) + #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 ) + #define ERROR_4( aErr, aMsg, aP1, aP2, aP3, aP4 ) + #define ERROR_5( aErr, aMsg, aP1, aP2, aP3, aP4, aP5 ) + #define ERROR_6( aErr, aMsg, aP1, aP2, aP3, aP4, aP5, aP6 ) + #define TEST_ASSERT_DESC( aCondition, aDescription ) + + #define ERROR_GEN( aMsg ) + #define ERROR_GEN_1( aMsg, aP1 ) + #define ERROR_GEN_2( aMsg, aP1, aP2 ) + #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) + #define ERROR_GEN_4( aMsg, aP1, aP2, aP3, aP4 ) + #define ERROR_GEN_5( aMsg, aP1, aP2, aP3, aP4, aP5 ) + #define ERROR_GEN_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 ) + #define TEST_ASSERT_DESC_GEN( aCondition, aDescription ) + + #endif//ERROR_TRACE + +//----------------------------------------------------------------------------- +// TRAP and trace with error macro +//----------------------------------------------------------------------------- +// +#define TRAP_ERROR( aErr, aFunction )\ + {\ + TRAP( aErr, aFunction );\ + TPtrC8 file( ( TText8* )__FILE__ );\ + ERROR_2( aErr, "Trapped leave in '%S' line %d", &file, __LINE__);\ + } + +//----------------------------------------------------------------------------- +// Info trace macros +//----------------------------------------------------------------------------- +// +#ifdef INFO_TRACE + + /** + * Info log message definitions. + */ + #ifdef TRACE_INTO_FILE + + #define INFO( aMsg )\ + {\ + RFileLogger::Write( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ) );\ + } + #define INFO_1( aMsg, aP1 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1 );\ + } + #define INFO_2( aMsg, aP1, aP2 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2 );\ + } + #define INFO_3( aMsg, aP1, aP2, aP3 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\ + } + #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\ + } + #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\ + } + #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5, aP6 );\ + } + + #else//TRACE_INTO_FILE not defined + + #define INFO( aMsg )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ) );\ + } + #define INFO_1( aMsg, aP1 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1 );\ + } + #define INFO_2( aMsg, aP1, aP2 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2 );\ + } + #define INFO_3( aMsg, aP1, aP2, aP3 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\ + } + #define INFO_4( aMsg, aP1, aP2, aP3, aP4 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\ + } + #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\ + } + #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5, aP6 );\ + } + + #endif//TRACE_INTO_FILE + +#else//INFO_TRACE not defined + + #define INFO( aMsg ) + #define INFO_1( aMsg, aP1 ) + #define INFO_2( aMsg, aP1, aP2 ) + #define INFO_3( aMsg, aP1, aP2, aP3 ) + #define INFO_4( aMsg, aP1, aP2, aP3, aP4 ) + #define INFO_5( aMsg, aP1, aP2, aP3, aP4, aP5 ) + #define INFO_6( aMsg, aP1, aP2, aP3, aP4, aP5, aP6 ) + +#endif//INFO_TRACE + +//----------------------------------------------------------------------------- +// Trace current client thread name and process id +//----------------------------------------------------------------------------- +// +#ifdef CLIENT_TRACE + + #define CLIENT_PROCESS\ + {\ + CLIENT_PROCESS_PREFIX( "" );\ + } + + #define CLIENT_PROCESS_PREFIX( aPrefix )\ + {\ + RProcess process;\ + TPtrC name( process.Name() );\ + TSecureId sid( process.SecureId() );\ + TPtrC prefix( _S( aPrefix ) );\ + if( prefix.Length() )\ + {\ + INFO_3( "%S: CLIENT - Name: [%S], Sid: [0x%x]", &prefix, &name, sid.iId );\ + }\ + else\ + {\ + INFO_2( "CLIENT - Name: [%S], Sid: [0x%x]", &name, sid.iId );\ + }\ + process.Close();\ + } + + #define CLIENT_MESSAGE( aMsg )\ + {\ + CLIENT_MESSAGE_PREFIX( "", aMsg );\ + } + + #define CLIENT_MESSAGE_PREFIX( aPrefix, aMsg )\ + {\ + RThread thread;\ + TInt err = aMsg.Client( thread );\ + if( err == KErrNone )\ + {\ + RProcess process;\ + err = thread.Process( process );\ + if( err == KErrNone )\ + {\ + TPtrC threadName( thread.Name() );\ + TUid processUid( process.SecureId() );\ + TPtrC prefix( _S( aPrefix ) );\ + if( prefix.Length() )\ + {\ + INFO_4( "%S: MSG - Name: [%S], Sid: [0x%x], Message ID: [%d]",\ + &prefix,\ + &threadName,\ + processUid,\ + aMsg.Function() );\ + }\ + else\ + {\ + INFO_3( "MSG - Name: [%S], Sid: [0x%x], Message ID: [%d]",\ + &threadName,\ + processUid,\ + aMsg.Function() );\ + }\ + }\ + process.Close();\ + }\ + thread.Close();\ + } + +#else + + #define CLIENT_PROCESS + #define CLIENT_PROCESS_PREFIX( aPrefix ) + #define CLIENT_MESSAGE( aMsg ) + #define CLIENT_MESSAGE_PREFIX( aPrefix, aMsg ) + +#endif + +//----------------------------------------------------------------------------- +// Function trace macros +//----------------------------------------------------------------------------- +// +#ifdef FUNC_TRACE + + /** + * Function logging definitions. + */ + #ifdef TRACE_INTO_FILE + + #define FUNC( aMsg, aP1 )\ + {\ + TPtrC8 trace( _S8( aMsg ) );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, trace, aP1 );\ + }\ + + #else//TRACE_INTO_FILE not defined + + #define FUNC( aMsg, aP1 )\ + {\ + RDebug::Printf( aMsg, aP1 );\ + }\ + + #endif//TRACE_INTO_FILE + + /** + * Function trace helper class. + * + * NOTE: + * LC -methods cannot be trapped. Therefore if LC -method leaves + * END trace is used instead of LEAVE trace. + * If you have an idea how to round this problem please tell. + */ + _LIT8( KFuncNameTerminator, "(" ); + _LIT8( KFuncLeavePatternL, "L" ); + class TFuncLog + { + public: + static void Cleanup( TAny* aPtr ) + { + TFuncLog* self = static_cast< TFuncLog* >( aPtr ); + self->iLeft = ETrue; + FUNC( _PREFIX_CHAR("%S-LEAVE"), &self->iFunc ); // Leave detected + } + inline TFuncLog( const char* aFunc ) : + iFunc( aFunc ? _S8( aFunc ) : _S8("") ), + iLeft( EFalse ), + iCleanupItem( Cleanup, this ), + iCanLeave( EFalse ) + { + TInt pos( iFunc.Find( KFuncNameTerminator ) ); + if( pos != KErrNotFound ) + { + iFunc.Set( iFunc.Left( pos ) ); + iCanLeave = !iFunc.Right( KFuncLeavePatternL().Length() ).Compare( KFuncLeavePatternL ); + if ( iCanLeave ) + { + CleanupStack::PushL( iCleanupItem ); // Ignore warnings + } + } + FUNC( _PREFIX_CHAR("%S-START"), &iFunc ); + } + + inline ~TFuncLog() + { + if ( !iLeft ) + { + if ( iCanLeave ) + { + CleanupStack::Pop( this ); // Pop the cleanup item + } + FUNC( _PREFIX_CHAR("%S-END"), &iFunc ); // Normally finished + } + } + + private: // Data + TPtrC8 iFunc; + TBool iLeft; + TCleanupItem iCleanupItem; + TBool iCanLeave; + }; + #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ ); + +#else//FUNC_TRACE not defined + + #define FUNC_LOG + +#endif//FUNC_TRACE + +//----------------------------------------------------------------------------- +// Timestamp trace macros +//----------------------------------------------------------------------------- +// +#ifdef TIMESTAMP_TRACE + + #ifdef TRACE_INTO_FILE + + #define TIMESTAMP( aCaption )\ + {\ + TTime t;\ + t.HomeTime();\ + TDateTime dt = t.DateTime();\ + _LIT( KCaption, aCaption );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\ + _PREFIX_TRACE("[TIMESTAMP] %S %d:%02d:%02d.%d us"),\ + &KCaption, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\ + } + + #else//TRACE_INTO_FILE not defined + + #define TIMESTAMP( aCaption )\ + {\ + TTime t;\ + t.HomeTime();\ + TDateTime dt = t.DateTime();\ + _LIT( KCaption, aCaption );\ + RDebug::Print( _PREFIX_TRACE("[TIMESTAMP] %S %d:%02d:%02d.%d us"),\ + &KCaption, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond() );\ + } + + #endif//TRACE_INTO_FILE + +#else//TIMESTAMP_TRACE not defined + + #define TIMESTAMP( aCaption ) + +#endif//TIMESTAMP_TRACE + +#ifdef HEAP_TRACE + + #ifdef TRACE_INTO_FILE + + #define HEAP( aMsg )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace );\ + } + #define HEAP_1( aMsg, aP1 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\ + } + #define HEAP_2( aMsg, aP1, aP2 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\ + } + #define HEAP_3( aMsg, aP1, aP2, aP3 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\ + } + #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\ + } + + #else//TRACE_INTO_FILE not defined + + #define HEAP( aMsg )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace );\ + } + #define HEAP_1( aMsg, aP1 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1 );\ + } + #define HEAP_2( aMsg, aP1, aP2 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2 );\ + } + #define HEAP_3( aMsg, aP1, aP2, aP3 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3 );\ + } + #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 )\ + {\ + TInt totalAllocSpace = 0;\ + User::AllocSize( totalAllocSpace );\ + RDebug::Print( _PREFIX_HEAP( aMsg ), totalAllocSpace, aP1, aP2, aP3, aP4 );\ + } + + #endif//TRACE_INTO_FILE + +#else//HEAP_TRACE not defined + + #define HEAP( aMsg ) + #define HEAP_1( aMsg, aP1 ) + #define HEAP_2( aMsg, aP1, aP2 ) + #define HEAP_3( aMsg, aP1, aP2, aP3 ) + #define HEAP_4( aMsg, aP1, aP2, aP3, aP4 ) + +#endif//HEAP_TRACE + +#endif + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/inc/traceconfiguration.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/inc/traceconfiguration.hrh Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* Trace Macro Configurations. +* +*/ + + +#ifndef TRACECONFIGURATION_HRH +#define TRACECONFIGURATION_HRH + +//----------------------------------------------------------------------------- +// Trace definitions +//----------------------------------------------------------------------------- +// + +/** +* Error trace enabled +*/ +#ifdef _DEBUG + #define ERROR_TRACE +#else + #undef ERROR_TRACE +#endif + +/** +* Info trace enabled +*/ +#ifdef _DEBUG + #define INFO_TRACE +#else + #undef INFO_TRACE +#endif + +/** +* Timestamp tracing on +*/ +#ifdef _DEBUG + #define TIMESTAMP_TRACE +#else + #undef TIMESTAMP_TRACE +#endif + +/** +* Tracing current client process and thread +*/ +#ifdef _DEBUG + #define CLIENT_TRACE +#else + #undef CLIENT_TRACE +#endif + +/** +* Function trace enabled +*/ +#ifdef _DEBUG + #define FUNC_TRACE +#else + #undef FUNC_TRACE +#endif + +/** +* Tracing into file enabled, default RDebug +*/ +#undef TRACE_INTO_FILE + +#endif + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/init/hapticsclienttest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/init/hapticsclienttest.ini Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,187 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. +# - Sets a device reset module's dll name(Reboot). +# + If Nokia specific reset module is not available or it is not correct one +# StifHWResetStub module may use as a template for user specific reset +# module. +# - Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation +# DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02 +# + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: 'Empty', 'Summary', 'Environment', + 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting + +DisableMeasurement= stifmeasurementdisablenone # Possible values are: + # 'stifmeasurementdisablenone', 'stifmeasurementdisableall' + # 'stifmeasurementplugin01', 'stifmeasurementplugin02', + # 'stifmeasurementplugin03', 'stifmeasurementplugin04', + # 'stifmeasurementplugin05' or 'stifbappeaprofiler' + +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= c:\testframework\YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= c:\testframework\NormalCases.txt +# TestCaseFile= c:\testframework\SmokeCases.txt +# TestCaseFile= c:\testframework\ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module +[New_Module] +ModuleName= TestScripter +TestCaseFile= c:\testframework\hapticsclienttest.cfg +[End_Module] + +# Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= c:\testframework\init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= c:\testframework\testcases1.cfg +#TestCaseFile= c:\testframework\testcases2.cfg +#TestCaseFile= c:\testframework\manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\LOGS\Module\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' +#NOTE: TestEngine and TestServer logging settings cannot change here + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/init/hwrmhapticspolicy.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/init/hwrmhapticspolicy.ini Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,7 @@ +// This is product specific policy file for Haptics. +// Not exported by haptics. Products need to include this in builds, +// if required. + +// For example, assuming SID is 0x12345678, add row: +// 10 0x12345678 + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/init/hwrmhapticsuid.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/init/hwrmhapticsuid.ini Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,8 @@ +// This file contains VIDs/SIDs which are allowed to use haptics license key auto setting. +// If SID is found from this list then related VID is omitted. +// For example, assuming SID 0x12345678 is allowed, add row (without slash signs): +//+ SID 0x12345678 + ++ VID 0x101FB657 //Nokia VID ++ SID 0x10003B20 //Window server ++ VID 0x101FB657 //EUnit \ No newline at end of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/src/hapticsclienttest.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/src/hapticsclienttest.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,4436 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "hapticsclienttest.h" +#include +#include +#include +#include +#include +#include "trace.h" + +// --------------------------------------------------------- +// Couple of static TUint8 arrays containing bytes for simple +// timeline and magsweep effects (that are used in PlayEffect +// and PlayEffectRepeat method related tests below). +// These are obtained using VibeTonz Studio's export to C-file +// functionality. +// --------------------------------------------------------- +static const TUint8 Timeline4HapticsMT_ivt[] = +{ + 0x01, 0x00, 0x02, 0x00, 0x1c, 0x00, 0x28, 0x00, 0x00, 0x00, 0x07, 0x00, 0xf1, 0xe0, 0x01, 0xe2, + 0x00, 0x00, 0xff, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, + 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x12, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, + 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x67, 0x00, + 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x00, 0x00 +}; + +static const TUint8 Magsweep4HapticsMT_ivt[] = +{ + 0x01, 0x00, 0x01, 0x00, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x81, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, + 0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x00, 0x00 +}; + +static const TUint8 Periodic4HapticsMT_ivt[] = +{ + 0x01, 0x00, 0x01, 0x00, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, + 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x00, 0x00 +}; + +// | Object name | Type | Duration | Magnitude | Period | +//-------------------------------------------------------------- +// 1. | Timeline1 | Timeline | 3915 | | | +// 2. | Timeline2 | Timeline | 5806 | | | +// 3. | Periodic1 | Periodic | 1000 | 7480 | 100 | +// 4. | Periodic2 | Periodic | 2000 | 7480 | 100 | +// 5. | MagSweep1 | MagSweep | 3000 | 7480 | | +// 6. | MagSweep2 | MagSweep | 4000 | 7480 | | +// ------------------------------------------------------------- +static const TUint8 EffectSetMT_ivt[] = +{ + 0x01, 0x00, 0x06, 0x00, 0x66, 0x00, 0x84, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x1a, 0x00, 0x2a, 0x00, + 0x3a, 0x00, 0x4a, 0x00, 0xf1, 0xe0, 0x02, 0xe2, 0x00, 0x00, 0xf1, 0xe0, 0x04, 0xe2, 0x03, 0x93, + 0xff, 0xf1, 0xe0, 0x03, 0xe2, 0x00, 0x00, 0xf1, 0xe0, 0x05, 0xe2, 0x07, 0x0e, 0xff, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x7d, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x01, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0xbb, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x81, 0x30, 0xc8, + 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0xfa, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x14, 0x00, 0x28, 0x00, 0x3c, 0x00, 0x50, 0x00, 0x64, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, + 0x65, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x31, 0x00, 0x00, 0x00, 0x54, 0x00, + 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x32, 0x00, + 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, + 0x63, 0x00, 0x31, 0x00, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, + 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x32, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x67, 0x00, + 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x31, 0x00, 0x00, 0x00, 0x4d, 0x00, + 0x61, 0x00, 0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x32, 0x00, + 0x00, 0x00 +}; + +static const TUint8 CorruptedMT_ivt[] = +{ + 0x00, 0x01, 0x01, 0x01, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, + 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, + 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x00, 0x00 +}; + +//offset value for +const TInt KEventOffset = 1000; + +// imaginary license key +_LIT8( KPlainKey, "73JJNDJ38EKDKD983783JDJD84U48DJ4" ); + +// --------------------------------------------------------- +// VibeStatus to S60 status mappings are tested by sending these +// special repeat values to server (calling PlayEffectRepeat). +// The test plugin will acknowledge these special values and +// returns corresponding VibeStatus error code.. +// --------------------------------------------------------- +// +enum repeat_values_4_vibestatustests + { + SUCCESS_TEST = 100, + ALREADY_INITIALIZED_TEST, + NOT_INITIALIZED_TEST, + INVALID_ARGUMENT_TEST, + FAIL_TEST, + INCOMPATIBLE_EFFECT_TYPE_TEST, + INCOMPATIBLE_CAPABILITY_TYPE_TEST, + INCOMPATIBLE_PROPERTY_TYPE_TEST, + DEVICE_NEEDS_LICENSE_TEST, + NOT_ENOUGH_MEMORY_TEST, + SERVICE_NOT_RUNNING_TEST, + INSUFFICIENT_PRIORITY_TEST, + SERVICE_BUSY_TEST, + WRN_NOT_PLAYING_TEST, + WRN_INSUFFICIENT_PRIORITY_TEST + }; + + +// - Haptics status callback implementation --------------------------------- +THapticsStatusCallback::THapticsStatusCallback( CHapticsClientTest* aMTCallback ) + : iHapticsStatus( MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + iMTCallback( aMTCallback ) + { + } + +THapticsStatusCallback::~THapticsStatusCallback() + { + } + +MHWRMHapticsObserver::THWRMHapticsStatus THapticsStatusCallback::Status() + { + return iHapticsStatus; + } + +// --------------------------------------------------------- +// from MHWRMHapticsObserver. Method which is called +// by the haptics client, when the haptics status of +// that client changes. +// --------------------------------------------------------- +// +void THapticsStatusCallback::HapticsStatusChangedL( THWRMHapticsStatus aStatus ) + { + iHapticsStatus = aStatus; + + // inform callback of new value + iMTCallback->HapticsStatusReceived(); + } + +// --------------------------------------------------------- +// from MHWRMHapticsObserver. Method is for future use, +// hence the empty implementation. +// --------------------------------------------------------- +// +void THapticsStatusCallback::EffectCompletedL( TInt /*aError*/, TInt /*aEffectHandle*/ ) + { + } + + +// - Actuator status callback implementation --------------------------------- +TActuatorStatusCallback::TActuatorStatusCallback( CHapticsClientTest* aMTCallback ) : iMTCallback( aMTCallback ) + { + } + +TActuatorStatusCallback::~TActuatorStatusCallback() + { + iActuatorStatus.Close(); + } + +MHWRMHapticsActuatorObserver::THWRMActuatorEvents TActuatorStatusCallback::Status( THWRMLogicalActuators aActuator ) + { + TInt index = iActuatorStatus.Find( aActuator ); + if ( index == KErrNotFound ) + { + return (MHWRMHapticsActuatorObserver::THWRMActuatorEvents)0; + } + return (MHWRMHapticsActuatorObserver::THWRMActuatorEvents)(iActuatorStatus[index+1]-KEventOffset); + } + +// --------------------------------------------------------- +// from MHWRMHapticsObserver. Method which is called +// by the haptics client, when the haptics status of +// that client changes. +// --------------------------------------------------------- +// +void TActuatorStatusCallback::ActuatorEventL( THWRMActuatorEvents aEvent, + THWRMLogicalActuators aActuator ) + { + TInt index = iActuatorStatus.Find( aActuator ); + if ( index == KErrNotFound ) + { + iActuatorStatus.Append( aActuator ); + iActuatorStatus.Append( aEvent + KEventOffset ); + } + else + { + iActuatorStatus.Remove( index ); + iActuatorStatus.Remove( index ); + iActuatorStatus.Append( aActuator ); + iActuatorStatus.Append( aEvent + KEventOffset ); + } + + // inform callback of new value + iMTCallback->HapticsStatusReceived(); + } + +// --------------------------------------------------------- +// MT_HapticsTestAsyncPlaySender methods +// --------------------------------------------------------- +// +MT_HapticsTestAsyncPlaySender::MT_HapticsTestAsyncPlaySender( + CHapticsClientTest* aMTCallback ) + : CActive( EPriorityStandard ), iMTCallback( aMTCallback ) + { + CActiveScheduler::Add( this ); + } + +MT_HapticsTestAsyncPlaySender::~MT_HapticsTestAsyncPlaySender() + { + } + +void MT_HapticsTestAsyncPlaySender::PlayRepeat( + CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TUint8 aRepeat, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ) + { + aClientStatus = KRequestPending; + iClientStatus = &aClientStatus; + aHaptics->PlayEffectRepeat( aFileHandle, + aEffectIndex, + aRepeat, + aEffectHandle, + iStatus ); + SetActive(); + } + +void MT_HapticsTestAsyncPlaySender::Play( + CHWRMHaptics* aHaptics, + TInt aFileHandle, + TInt aEffectIndex, + TInt& aEffectHandle, + TRequestStatus& aClientStatus ) + { + aClientStatus = KRequestPending; + iClientStatus = &aClientStatus; + aHaptics->PlayEffect( aFileHandle, + aEffectIndex, + aEffectHandle, + iStatus ); + SetActive(); + } + +void MT_HapticsTestAsyncPlaySender::RunL() + { + *iClientStatus = iStatus.Int(); + iMTCallback->HapticsStatusReceived(); + } + +void MT_HapticsTestAsyncPlaySender::DoCancel() + { + } + +TInt MT_HapticsTestAsyncPlaySender::RunError( TInt /* aError */ ) + { + return KErrNone; + } + +// - Construction ----------------------------------------------------------- + +void CHapticsClientTest::BuildL () + { + iSender = new ( ELeave ) MT_HapticsTestAsyncPlaySender( this ); + } + +void CHapticsClientTest::Delete () + { + delete iSender; + } + +// ----------------------------------------------------------------------------- +// CHapticsClientTest::RunMethodL +// Run specified method. Contains also table of test mothods and their names. +// ----------------------------------------------------------------------------- +// +TInt CHapticsClientTest::RunMethodL( + CStifItemParser& aItem ) + { + + static TStifFunctionInfo const KFunctions[] = + { + // Copy this line for every implemented function. + // First string is the function name used in TestScripter script file. + // Second is the actual implementation member function. + ENTRY( "Setup", CHapticsClientTest::SetupL ), + ENTRY( "Teardown", CHapticsClientTest::Teardown ), + ENTRY( "CreateAndDestroy", CHapticsClientTest::T_CreateAndDeleteL ), + ENTRY( "SeveralSessions", CHapticsClientTest::T_SeveralSessionsL ), + ENTRY( "ConsecutiveSessions", CHapticsClientTest::T_ConsecutiveSessionsL ), + ENTRY( "SupportedActuators", CHapticsClientTest::T_SupportedActuators ), + ENTRY( "OpenSupportedActuator", CHapticsClientTest::T_OpenSupportedActuator ), + ENTRY( "OpenUnsupportedActuator", CHapticsClientTest::T_OpenNotSupportedActuator ), + ENTRY( "OpenAllActuators", CHapticsClientTest::T_OpenAllActuators ), + ENTRY( "2ClientsOpenActuators", CHapticsClientTest::T_SeveralClientsWithOpenActuatorsL ), + ENTRY( "PlayMagSweepSynchData", CHapticsClientTest::T_PlayMagSweepEffectSynchronous ), + ENTRY( "PlayMagSweepAsynchData", CHapticsClientTest::T_PlayMagSweepEffectAsynchronous ), + ENTRY( "PlayPeriodicSynchData", CHapticsClientTest::T_PlayPeriodicEffectSynchronous ), + ENTRY( "PlayPeriodicAsynchData", CHapticsClientTest::T_PlayPeriodicEffectAsynchronous ), + ENTRY( "PlayIVTSynchData", CHapticsClientTest::T_PlayIVTEffectWithDirectDataSynchronous ), + ENTRY( "PlayIVTAsynchData", CHapticsClientTest::T_PlayIVTEffectWithDirectDataAsynchronous ), + ENTRY( "RepeatIVTSynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataSynchronous ), + ENTRY( "RepeatIVTAsynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataAsynchronous ), + ENTRY( "GetEffectState", CHapticsClientTest::T_GetEffectState ), + ENTRY( "RepeatIVTSynchDataNonTimeline", CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous ), + ENTRY( "RepeatIVTAsynchDataNonTimeline", CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous ), + ENTRY( "Zero-repeatIVTSynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous ), + ENTRY( "Zero-repeatIVTAsynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous ), + ENTRY( "LoadIVTData", CHapticsClientTest::T_LoadIVTData ), + ENTRY( "DeleteIVTData", CHapticsClientTest::T_DeleteIVTData ), + ENTRY( "DeleteAllIVTData", CHapticsClientTest::T_DeleteAllIVTData ), + ENTRY( "LoadAndDeleteMultiple", CHapticsClientTest::T_LoadAndDeleteIVTData ), + ENTRY( "LoadAndDeleteMixed", CHapticsClientTest::T_LoadAndDeleteIVTDataMixed ), + ENTRY( "LoadDeletePlaySync", CHapticsClientTest::T_LoadDeletePlaySync ), + ENTRY( "LoadDeletePlayAsync", CHapticsClientTest::T_LoadDeletePlayAsync ), + ENTRY( "LoadDeletePlayRepeatSync", CHapticsClientTest::T_LoadDeletePlayRepeatSync ), + ENTRY( "LoadDeletePlayRepeatAsync", CHapticsClientTest::T_LoadDeletePlayRepeatAsync ), + ENTRY( "PlayLoadedIVTSynch", CHapticsClientTest::T_PlayIVTEffectWithLoadedDataSynchronous ), + ENTRY( "PlayLoadedIVTAsynch", CHapticsClientTest::T_PlayIVTEffectWithLoadedDataAsynchronous ), + ENTRY( "RepeatLoadedIVTSynch", CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataSynchronous ), + ENTRY( "RepeatLoadedIVTAsynch", CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataAsynchronous ), + ENTRY( "LoadMultipleIVT-data", CHapticsClientTest::T_LoadMultipleIVTData ), + ENTRY( "PlayFromMultipleIVT-dataSynch", CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataSynchronous ), + ENTRY( "PlayFromMultipleIVT-dataAsynch", CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataAsynchronous ), + ENTRY( "PlayRepeatFromMultipleIVT-dataSynch", CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous ), + ENTRY( "PlayRepeatFromMultipleIVT-dataAsynch", CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous ), + ENTRY( "StatusConversions", CHapticsClientTest::T_VibeStatusToS60StatusConversions ), + ENTRY( "ReserveAndRelease", CHapticsClientTest::T_ReserveAndReleaseHaptics ), + ENTRY( "ReserveSeveralTimes", CHapticsClientTest::T_ReserveHapticsSeveralTimes ), + ENTRY( "ReserveNoRelease", CHapticsClientTest::T_ReserveHapticsNoReleaseL ), + ENTRY( "ReleaseNoReserve", CHapticsClientTest::T_ReleaseHapticsWithoutReservingFirst ), + ENTRY( "ReserveForceNoCoe", CHapticsClientTest::T_ReserveNoAutomaticFocusNotTrusted ), + ENTRY( "ReserveReservedHigher", CHapticsClientTest::T_ReserveAlreadyReservedHigherL ), + ENTRY( "ReserveReservedLower", CHapticsClientTest::T_ReserveAlreadyReservedLowerL ), + ENTRY( "PlayWhenReserved", CHapticsClientTest::T_PlayWhenReservedL ), + ENTRY( "GetEffectCount", CHapticsClientTest::T_GetIVTEffectCount ), + ENTRY( "GetEffectDuration", CHapticsClientTest::T_GetIVTEffectDuration ), + ENTRY( "GetEffectIndexFromName", CHapticsClientTest::T_GetIVTEffectIndexFromName ), + ENTRY( "GetEffectType", CHapticsClientTest::T_GetIVTEffectType ), + ENTRY( "GetEffectName", CHapticsClientTest::T_GetIVTEffectName ), + ENTRY( "GetMagSweepEffectDefinition", CHapticsClientTest::T_GetIVTMagSweepEffectDefinition ), + ENTRY( "GetPeriodicEffectDefinition", CHapticsClientTest::T_GetIVTPeriodicEffectDefinition ), + ENTRY( "CreateAndDestroyAsynchronous", CHapticsClientTest::T_CreateAndDeleteAsynchronousL ), + ENTRY( "SeveralSessionsAsynchronous", CHapticsClientTest::T_SeveralSessionsAsynchronousL ), + ENTRY( "ConsecutiveSessionsAsynchronous", CHapticsClientTest::T_ConsecutiveSessionsAsynchronousL), + ENTRY( "ConstantGetters", CHapticsClientTest::T_ConstantGetters ), + ENTRY( "PauseEffect", CHapticsClientTest::T_PauseEffect ), + ENTRY( "ResumeEffect", CHapticsClientTest::T_ResumeEffect), + ENTRY( "StopEffect", CHapticsClientTest::T_StopEffect), + ENTRY( "StopAllEffects", CHapticsClientTest::T_StopAllEffects ), + ENTRY( "PlayPauseResumeStop", CHapticsClientTest::T_PlayPauseResumeStop), + ENTRY( "ModifyPlayingMagsweepEffectSynchronous", CHapticsClientTest::T_ModifyMagSweepEffectSynchronous ), + ENTRY( "ModifyPlayingMagsweepEffectAsynchronous", CHapticsClientTest::T_ModifyMagSweepEffectAsynchronous ), + ENTRY( "ModifyPlayingPeriodicEffectSynchronous", CHapticsClientTest::T_ModifyPeriodicEffectSynchronous ), + ENTRY( "ModifyPlayingPeriodicEffectAsynchronous", CHapticsClientTest::T_ModifyPeriodicEffectAsynchronous ), + ENTRY( "GetDevicePropertyOfTIntValue", CHapticsClientTest::T_GetDeviceProperty_TInt_TInt ), + ENTRY( "GetDevicePropertyOfTDesCValue", CHapticsClientTest::T_GetDeviceProperty_TInt_TDesC ), + ENTRY( "SetDevicePropertyOfTIntValue", CHapticsClientTest::T_SetDeviceProperty_TInt_TInt ), + ENTRY( "SetDevicePropertyOfTDesCValue", CHapticsClientTest::T_SetDeviceProperty_TInt_TDesC ), + ENTRY( "GetDeviceCapabilityOfTIntValue", CHapticsClientTest::T_GetDeviceCapability_TInt_TInt ), + ENTRY( "GetDeviceCapabilityOfTDesCValue", CHapticsClientTest::T_GetDeviceCapability_TInt_TDesC ), + ENTRY( "FetchStatus", CHapticsClientTest::T_GetHapticsStatus ), + ENTRY( "ObserveStatus", CHapticsClientTest::T_ObserveHapticsStatus ), + ENTRY( "StatusReservation", CHapticsClientTest::T_GetHapticsStatusWithReservations ), + ENTRY( "StatusObserveReservation", CHapticsClientTest::T_ObserveHapticsStatusWithReservations ), + ENTRY( "Status2Reservations", CHapticsClientTest::T_GetHapticsStatusWithSeveralReservations ), + ENTRY( "StatusObserve2Reservation", CHapticsClientTest::T_ObserveHapticsStatusWithSeveralReservations ), + ENTRY( "StatusManyClients", CHapticsClientTest::T_GetHapticsStatusWithSeveralClientsOneReservation ), + ENTRY( "StatusObserverManyClients", CHapticsClientTest::T_ObserveHapticsStatusWithSeveralClientsOneReservations ), + ENTRY( "CreateStreamingEffect", CHapticsClientTest::T_CreateStreamingEffect ), + ENTRY( "PlayStreamingSample", CHapticsClientTest::T_PlayStreamingSample), + ENTRY( "PlayStreamingSampleAsync", CHapticsClientTest::T_PlayStreamingSampleAsync), + ENTRY( "PlayStreamingSampleWithOffset", CHapticsClientTest::T_PlayStreamingSampleWithOffset), + ENTRY( "PlayStreamingSampleWithOffsetAsync", CHapticsClientTest::T_PlayStreamingSampleWithOffsetAsync), + ENTRY( "DestroyStreamingEffect", CHapticsClientTest::T_DestroyStreamingEffect), + ENTRY( "ActuatorStatus", CHapticsClientTest::T_ObserveActuatorStatus), + ENTRY( "ActuatorOrHapticsStatus", CHapticsClientTest::T_ObserveActuatorStatusAndHapticsStatus), + ENTRY( "PluginMgrTransTimerExpires", CHapticsClientTest::T_PluginMgrTransTimerExpires), + }; + + const TInt count = sizeof( KFunctions ) / + sizeof( TStifFunctionInfo ); + + return RunInternalL( KFunctions, count, aItem ); + + } + +// --------------------------------------------------------- +// Method, which is called by the status callback, when a status +// has been received. Stops the wait loop waiting for a new status. +// --------------------------------------------------------- +// +void CHapticsClientTest::HapticsStatusReceived() + { + iWait.AsyncStop(); + } + +// - Test methods ----------------------------------------------------------- + +// --------------------------------------------------------- +// Default test env construction +// --------------------------------------------------------- +// +TInt CHapticsClientTest::SetupL() + { + iHaptics = CHWRMHaptics::NewL( NULL, NULL ); + return KErrNone; + } + +// --------------------------------------------------------- +// Default test env destruction +// --------------------------------------------------------- +// +TInt CHapticsClientTest::Teardown() + { + if( iHaptics ) + { + delete iHaptics; + iHaptics = NULL; + } + return KErrNone; + } + +// --------------------------------------------------------- +// Helper methods for creating various effects +// --------------------------------------------------------- +// +void CHapticsClientTest::CreateMagSweepEffect( CHWRMHaptics::THWRMHapticsMagSweepEffect& aEffect ) + { + aEffect.iDuration = 1000; + aEffect.iMagnitude = 5000; + aEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleSharp; + aEffect.iAttackTime = 0; + aEffect.iAttackLevel = 0; + aEffect.iFadeTime = 0; + aEffect.iFadeLevel = 0; + } + +void CHapticsClientTest::CreatePeriodicEffect( CHWRMHaptics::THWRMHapticsPeriodicEffect& aEffect ) + { + aEffect.iDuration = 1000; + aEffect.iMagnitude = 5000; + aEffect.iPeriod = 100; + aEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleSharp; + aEffect.iAttackTime = 0; + aEffect.iAttackLevel = 0; + aEffect.iFadeTime = 0; + aEffect.iFadeLevel = 0; + } + +void CHapticsClientTest::CreateIVTEffect( RBuf8& aBuffer, CHWRMHaptics::THWRMHapticsEffectTypes aType) + { + // Note: only magsweep and timeline IVT effects supported so far.. + switch ( aType ) + { + case CHWRMHaptics::EHWRMHapticsTypePeriodic: + { + aBuffer.ReAlloc( sizeof( Periodic4HapticsMT_ivt ) ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memcpy( tmpPtr, Periodic4HapticsMT_ivt, sizeof( Periodic4HapticsMT_ivt ) ); + aBuffer.SetLength( sizeof( Periodic4HapticsMT_ivt ) ); + break; + } + case CHWRMHaptics::EHWRMHapticsTypeMagSweep: + { + aBuffer.ReAlloc( sizeof( Magsweep4HapticsMT_ivt ) ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memcpy( tmpPtr, Magsweep4HapticsMT_ivt, sizeof( Magsweep4HapticsMT_ivt ) ); + aBuffer.SetLength( sizeof( Magsweep4HapticsMT_ivt ) ); + break; + } + case CHWRMHaptics::EHWRMHapticsTypeTimeline: + { + aBuffer.ReAlloc( sizeof( Timeline4HapticsMT_ivt ) ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memcpy( tmpPtr, Timeline4HapticsMT_ivt, sizeof( Timeline4HapticsMT_ivt ) ); + aBuffer.SetLength( sizeof( Timeline4HapticsMT_ivt ) ); + break; + } + default: + break; // no support for other types at the moment + } + } + + +void CHapticsClientTest::CreateDummyStreamSample( TInt aSize, RBuf8& aBuffer ) + { + aBuffer.ReAlloc( aSize ); + TUint8* tmpPtr = const_cast( aBuffer.Ptr() ); + memset( tmpPtr, 0x00, aSize ); + aBuffer.SetLength( aSize ); + } + +// --------------------------------------------------------- +// Open and close haptics client-server session, i.e. +// create and delete haptics client. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_CreateAndDeleteL() + { + // create iHaptics instance without observers + iHaptics = CHWRMHaptics::NewL( NULL, NULL ); + + // the connection has been opened successfully, if iHaptics is valid + TEST_ASSERT_DESC( iHaptics, "Haptics client creation failed!"); + + // the connection is closed, when iHaptics is deleted + delete iHaptics; + iHaptics = NULL; + return KErrNone; + } + +// --------------------------------------------------------- +// Create several simultaneous sessions to haptics server. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_SeveralSessionsL() + { + // create haptics instances without observers. This creates + // client-server sessions (session instances in the server) + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL ); + + // the connection has been opened successfully, if instances are valid + TEST_ASSERT_DESC( haptics1, "First haptics client creation failed!"); + TEST_ASSERT_DESC( haptics2, "Second haptics client creation failed!"); + TEST_ASSERT_DESC( haptics3, "Third haptics client creation failed!"); + + // delete haptics instances. This removes the sessions from + // haptics server, and closes the server, when the last session + // is closed + delete haptics1; haptics1 = NULL; + delete haptics2; haptics2 = NULL; + delete haptics3; haptics3 = NULL; + return KErrNone; + } + +// --------------------------------------------------------- +// Create several consecutive sessions to haptics server. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ConsecutiveSessionsL() + { + // Do create and delete three times in a row + T_CreateAndDeleteL(); + T_CreateAndDeleteL(); + T_CreateAndDeleteL(); + return KErrNone; + } + +// --------------------------------------------------------- +// Requests the supported actuators from haptics. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_SupportedActuators() + { + TUint32 actuators = 0; + TInt err = KErrNone; + err = iHaptics->SupportedActuators( actuators ); + + TEST_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" ); + TEST_ASSERT_DESC( actuators, "Actuators empty!"); + return err; + } + +// --------------------------------------------------------- +// Opens an actuator, which is supported by haptics. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_OpenSupportedActuator() + { + TUint32 actuators = 0; + TInt err = iHaptics->SupportedActuators( actuators ); + + // Open using first supported logical actuator type + if( EHWRMLogicalActuatorAny & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + } + else if( EHWRMLogicalActuatorDevice & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + } + else if( EHWRMLogicalActuatorPrimaryDisplay & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type PrimaryDisplay failed!" ); + } + else if( EHWRMLogicalActuatorSecondaryDisplay & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type SecondaryDisplay failed!" ); + } + else if( EHWRMLogicalActuatorGame & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Game failed!" ); + } + else if( EHWRMLogicalActuatorGameLeft & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type GameLeft failed!" ); + } + else if( EHWRMLogicalActuatorGameRight & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type GameRight failed!" ); + } + else if( EHWRMLogicalActuatorExternalVibra & actuators ) + { + TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type ExternalVibra failed!" ); + } + return err; + } + +// --------------------------------------------------------- +// Attemps to open an actuator, which is NOT supported +// by haptics. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_OpenNotSupportedActuator() + { + TUint32 actuators = 0; + TInt err = iHaptics->SupportedActuators( actuators ); + + TEST_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" ); + + // Open using first NOT supported logical actuator type + if( !( EHWRMLogicalActuatorAny & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + } + else if( !( EHWRMLogicalActuatorDevice & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + } + else if( !( EHWRMLogicalActuatorPrimaryDisplay & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) ); + } + else if( !( EHWRMLogicalActuatorSecondaryDisplay & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) ); + } + else if( !( EHWRMLogicalActuatorGame & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) ); + } + else if( !( EHWRMLogicalActuatorGameLeft & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) ); + } + else if( !( EHWRMLogicalActuatorGameRight & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) ); + } + else if( !( EHWRMLogicalActuatorExternalVibra & actuators ) ) + { + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) ); + } + + TEST_ASSERT_DESC( (err == KErrNotSupported), "Invalid error code value!" ); + TEST_ASSERT_DESC( (err != KErrNone), "Opening unsupported actuator succeeded!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Attemps to open actuators, using all available logical +// actuator types. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_OpenAllActuators() + { + TInt actuatorMask = EHWRMLogicalActuatorPrimaryDisplay | EHWRMLogicalActuatorSecondaryDisplay; + + TRAPD( err, iHaptics->OpenActuatorL( (THWRMLogicalActuators)actuatorMask ) ); + TEST_ASSERT_DESC( (err == KErrArgument), "Opening actuator with several type mask succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type PrimaryDisplay succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type SecondaryDisplay succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type Game succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type GameLeft succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type GameRight succeeded!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TEST_ASSERT_DESC( (err == KErrAlreadyExists), "Opening actuator with type Any; wrong error code" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + TEST_ASSERT_DESC( (err == KErrInUse), "Opening actuator with type Device; wrong error code" ); + + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) ); + TEST_ASSERT_DESC( (err == KErrInUse), "Opening actuator with type ExternalVibra; wrong error code!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Creates a couple of haptic client instances, and opens +// actuators in both of them. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_SeveralClientsWithOpenActuatorsL() + { + // create first haptics client instance + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + // create second haptics client instance + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + // fetch supported actuator types + TUint32 actuators = 0; + TInt err = haptics1->SupportedActuators( actuators ); + TEST_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" ); + + // open actuators for both instances using supported types + if( EHWRMLogicalActuatorAny & actuators ) + { + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + } + else + { + TEST_ASSERT_DESC( EFalse, "Actuator type Any not supported!" ); + } + + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Plays a magsweep effect using synchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayMagSweepEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effect; + CreateMagSweepEffect( effect ); + + // play effect + TInt effectHandle; + TInt err = iHaptics->PlayMagSweepEffect( effect, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect synchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing magsweep effect synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect synchronously failed! (StopAllPlayingEffects)" ); + return err; + } + + +// --------------------------------------------------------- +// Plays a magsweep effect using asynchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayMagSweepEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effect; + CreateMagSweepEffect( effect ); + + // play effect + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayMagSweepEffect( effect, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing magsweep effect asynchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing magsweep effect asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + TInt err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect asynchronously failed! (StopAllPlayingEffects)" ); + + return err; + } + + +// --------------------------------------------------------- +// Plays a periodic effect using synchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayPeriodicEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsPeriodicEffect effect; + CreatePeriodicEffect( effect ); + + // play effect + TInt effectHandle; + TInt err = iHaptics->PlayPeriodicEffect( effect, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing periodic effect synchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing periodic effect returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing periodic effect synchronously failed! (StopAllPlayingEffects)" ); + return err; + } + +// --------------------------------------------------------- +// Plays a periodic effect using synchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayPeriodicEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsPeriodicEffect effect; + CreatePeriodicEffect( effect ); + + // play effect + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayPeriodicEffect( effect, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing periodic effect asynchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing periodic effect asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + TInt err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing periodic effect asynchronously failed! (StopAllPlayingEffects)" ); + return err; + } + + +// --------------------------------------------------------- +// Plays an IVT effect using synchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectWithDirectDataSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect + TInt effectHandle; + TInt err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playingeffect IVT synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" ); + + return err; + } + +// --------------------------------------------------------- +// Plays an IVT effect using asynchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectWithDirectDataAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play effect + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffect( effBuf, 0, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect asynchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" ); + return err; + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using synchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play the effect (repeat 2 times) + TInt effectHandle; + TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" ); + return err; + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using asynchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play effect (repeat 2 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect repeatedly asynchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + return err; + } + +// --------------------------------------------------------- +// Gets the effect state while an effect: +// a) is being played +// b) has been paused +// c) has been completed (i.e., is not playing any more) +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetEffectState() + { + // open actuator.. + T_OpenSupportedActuator(); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effect; + CreateMagSweepEffect( effect ); + + // play effect + TInt effectHandle; + TInt err = iHaptics->PlayMagSweepEffect( effect, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (playing returned error)" ); + TEST_ASSERT_DESC( effectHandle, "GetEffectState failed! (empty effect handle)" ); + + // get state + TInt effectState; + err = iHaptics->GetEffectState( effectHandle, effectState ); + TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (1st call)" ); + TEST_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectPlaying), "GetEffectState failed! (1st call - wrong state)" ); + + // pause the effect and get state + err = iHaptics->PausePlayingEffect( effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (Pause)" ); + + err = iHaptics->GetEffectState( effectHandle, effectState ); + TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (2nd call)" ); + TEST_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectPaused), "GetEffectState failed! (2nd call - wrong state)" ); + + // stop the effect and get state again + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (StopAllPlayingEffects)" ); + + err = iHaptics->GetEffectState( effectHandle, effectState ); + TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (3rd call)" ); + TEST_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectNotPlaying), "GetEffectState failed! (3rd call - wrong state)" ); + return err; + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using synchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// Since the effect in question is not a timeline effect (in +// this test we use magsweep effect instead), the effect is +// played only once. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect (try to repeat 2 times.. in practice will only repeat once + // due to the effect being non timeline effect) + TInt effectHandle; + TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly synchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect (non-timeline) repeatedly synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly synchronously failed! (StopAllPlayingEffects)" ); + return err; + } + +// --------------------------------------------------------- +// Plays repeatedly an IVT effect using asynchronous API call. +// The effect is given as TDes8C& parameter directly to the API call. +// Since the effect in question is not a timeline effect (in +// this test we use magsweep effect instead), the effect is +// played only once. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect (try to repeat 2 times.. in practice will only repeat once + // due to the effect being non timeline effect) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect (non-timeline) repeatedly asynchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect (non-timeline) repeatedly asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + return err; + } + +TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play the effect (repeat 0 times) + TInt effectHandle; + TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) synchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly (zero repeats) synchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) synchronously failed! (StopAllPlayingEffects)" ); + return err; + } + + +TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // read timeline effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + + // play effect (repeat 0 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 0, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect repeatedly (zero repeats) asynchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly (zero repeats) asynchronously returned empty effect handle!" ); + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy(); // effBuf + TInt err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) asynchronously failed! (StopAllPlayingEffects)" ); + return err; + } + + +// --------------------------------------------------------- +// Loading IVT data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::LoadIVTDataInternal( TInt& aFileHandle, + CHWRMHaptics::THWRMHapticsEffectTypes aType, + TBool aOpenActuator ) + { + // NOTE: we can use the same IVT data as was used in previous "call PlayXXXEffect() + // with direct data cases (i.e., there's no need e.g. to read data from file..) + + // open actuator.. + if ( aOpenActuator ) + { + T_OpenSupportedActuator(); + } + + // read effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, aType ); + + TInt retVal = iHaptics->LoadEffectData( effBuf, aFileHandle ); + + CleanupStack::PopAndDestroy(); // effBuf + return retVal; + } + +TInt CHapticsClientTest::LoadIVTDataInternal( TInt& aFileHandle, + const TUint8 aIvtData[], + TInt aIvtDataSize, + TBool aOpenActuator ) + { + // open actuator.. + if ( aOpenActuator ) + { + T_OpenSupportedActuator(); + } + + // read effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + effBuf.ReAlloc( aIvtDataSize ); + TUint8* tmpPtr = const_cast( effBuf.Ptr() ); + memcpy( tmpPtr, aIvtData, aIvtDataSize ); + effBuf.SetLength( aIvtDataSize ); + + TInt retVal = iHaptics->LoadEffectData( effBuf, aFileHandle ); + + CleanupStack::PopAndDestroy(); // effBuf + return retVal; + } + +TInt CHapticsClientTest::T_LoadIVTData() + { + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (LoadIVTData case)" ); + return err; + } + + +// --------------------------------------------------------- +// Deleting previously loaded IVT data by calling DeleteIVTData +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_DeleteIVTData() + { + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (DeleteIVTData case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (DeleteIVTData case)!" ); + + err = iHaptics->DeleteEffectData( fileHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + return err; + } + + +// --------------------------------------------------------- +// Deleting previously loaded IVT data by calling DeleteAllIVTData +// instead of DeleteIVTData +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_DeleteAllIVTData() + { + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (DeleteAllIVTData case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (DeleteAllIVTData case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + return err; + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_LoadAndDeleteIVTData() + { + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // delete each IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle1 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + err = iHaptics->DeleteEffectData( fileHandle2 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + err = iHaptics->DeleteEffectData( fileHandle3 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // reload IVT-data + fileHandle1 = KErrNotFound; + fileHandle2 = KErrNotFound; + fileHandle3 = KErrNotFound; + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + return KErrNone; + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data (mixed order). +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_LoadAndDeleteIVTDataMixed() + { + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // delete second IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle2 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // load third IVT-data once more (filehandle should not change) + TInt newHandle = KErrNotFound; + err3 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + TEST_ASSERT_DESC( (fileHandle3 == newHandle), "Received incorrect filehandle!" ); + + // load second IVT-data once more (filehandle should change) + newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + fileHandle1 = KErrNotFound; + fileHandle2 = KErrNotFound; + fileHandle3 = KErrNotFound; + + // reload IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + return KErrNone; + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the synchronous play-method. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_LoadDeletePlaySync() + { + TInt effectHandle = 0; + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + TInt err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete second IVT-data + err = iHaptics->DeleteEffectData( fileHandle2 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + return err; + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the asynchronous play-method. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_LoadDeletePlayAsync() + { + TRequestStatus status1 = KRequestPending; + TRequestStatus status2 = KRequestPending; + TRequestStatus status3 = KRequestPending; + + TInt effectHandle = 0; + + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + // iHaptics->PlayEffect( fileHandle1, 0, effectHandle, status1 ); + // LoopForCompletion( status1 ); + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 ); + iWait.Start(); + TEST_ASSERT_DESC( (status1 == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 ); + iWait.Start(); + TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete second IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle2 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + status2 = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 ); + iWait.Start(); + TEST_ASSERT_DESC( (status1.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 ); + iWait.Start(); + TEST_ASSERT_DESC( (status3.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 ); + iWait.Start(); + TEST_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 ); + iWait.Start(); + TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + return KErrNone; + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the synchronous PlayRepeat-method. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_LoadDeletePlayRepeatSync() + { + TInt effectHandle = 0; + TInt repeat = 2; + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + TInt err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete second IVT-data + err = iHaptics->DeleteEffectData( fileHandle2 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + return err; + } + + +// --------------------------------------------------------- +// Loads and deletes IVT-data. Plays using the filehandles +// received by calling the asynchronous PlayRepeat-method. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_LoadDeletePlayRepeatAsync() + { + TRequestStatus status1 = KRequestPending; + TRequestStatus status2 = KRequestPending; + TRequestStatus status3 = KRequestPending; + + TInt effectHandle = 0; + TInt repeat = 7; + + TInt fileHandle1 = KErrNotFound; + TInt fileHandle2 = KErrNotFound; + TInt fileHandle3 = KErrNotFound; + + // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal()) + TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic ); + TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 ); + iWait.Start(); + TEST_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 ); + iWait.Start(); + TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete second IVT-data + TInt err = iHaptics->DeleteEffectData( fileHandle2 ); + TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" ); + + // play the first effect of the second data + status2 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT data succeeded!" ); + + // load second IVT-data once more (filehandle should change) + TInt newHandle = KErrNotFound; + err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" ); + TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" ); + fileHandle2 = newHandle; + + // play the first effect of the second data + status2 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + + // delete all IVT-data + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" ); + + // play the first effect of each data (each should fail, since data is deleted) + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 ); + iWait.Start(); + TEST_ASSERT_DESC( (status1.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 ); + iWait.Start(); + TEST_ASSERT_DESC( (status3.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" ); + + // load IVT-data + err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" ); + TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" ); + TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" ); + TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" ); + + // check that filehandles are unique + TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" ); + TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" ); + + // play the first effect of each data + status1 = KRequestPending; + status2 = KRequestPending; + status3 = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 ); + iWait.Start(); + TEST_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 ); + iWait.Start(); + TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 ); + iWait.Start(); + TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + return KErrNone; + } + + +// --------------------------------------------------------- +// Playing the previously loaded IVT data (synchronous version) +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectWithLoadedDataSynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // play the effect.. + TInt effectHandle; + err = iHaptics->PlayEffect( fileHandle, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" ); + return err; + } + + +// --------------------------------------------------------- +// Playing the previously loaded IVT data (asynchronous version) +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectWithLoadedDataAsynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" ); + + // play the effect.. + TInt effectHandle; + TRequestStatus status = KRequestPending; + iSender->Play( iHaptics, fileHandle, 0, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing asynchronously case))" ); + return err; + } + + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (synchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataSynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" ); + + // play the effect repeatedly (repeated 3 times) + TInt effectHandle; + err = iHaptics->PlayEffectRepeat( fileHandle, 0, 3, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT synchronously case))" ); + return err; + } + + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (asynchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataAsynchronous() + { + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" ); + + // play the effect (repeated 5 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, 5, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT asynchronously case))" ); + return err; + } + +// --------------------------------------------------------- +// VibeStatus to S60 status conversions +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_VibeStatusToS60StatusConversions() + { + // this is a bit ugly, i.e., we're using special repeat + // values and then the test adaptation stub acknowledges + // these special value and repeats accordingly with some + // (Vibe-error) status + + // load the IVT data + TInt fileHandle; + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Status conversion case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Status conversion case)!" ); + + // the actual status conversion cases (done with special repeat values + // using PlayIVTEffectRepeat) + TInt dummyEffectHandle; // we're not interested about this in these cases + // first the synch cases.. + err = iHaptics->PlayEffectRepeat( fileHandle, 0, SUCCESS_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Status conversion subcase SUCCESS_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, ALREADY_INITIALIZED_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrAlreadyExists), "Status conversion subcase ALREADY_INITIALIZED_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, NOT_INITIALIZED_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNotReady), "Status conversion subcase NOT_INITIALIZED_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INVALID_ARGUMENT_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrArgument), "Status conversion subcase INVALID_ARGUMENT_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, FAIL_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrGeneral), "Status conversion subcase FAIL_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_EFFECT_TYPE_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_EFFECT_TYPE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_CAPABILITY_TYPE_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_CAPABILITY_TYPE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_PROPERTY_TYPE_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_PROPERTY_TYPE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, DEVICE_NEEDS_LICENSE_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrAccessDenied), "Status conversion subcase DEVICE_NEEDS_LICENSE_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, NOT_ENOUGH_MEMORY_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNoMemory), "Status conversion subcase NOT_ENOUGH_MEMORY_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, SERVICE_NOT_RUNNING_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNotReady), "Status conversion subcase SERVICE_NOT_RUNNING_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrAccessDenied), "Status conversion subcase INSUFFICIENT_PRIORITY_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, SERVICE_BUSY_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Status conversion subcase SERVICE_BUSY_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, WRN_NOT_PLAYING_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrArgument), "Status conversion subcase WRN_NOT_PLAYING_TEST failed (synch)!" ); + + err = iHaptics->PlayEffectRepeat( fileHandle, 0, WRN_INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Status conversion subcase WRN_INSUFFICIENT_PRIORITY_TEST failed (synch)!" ); + + // then the asycnh cases + TRequestStatus status; + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, SUCCESS_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Status conversion subcase SUCCESS_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, ALREADY_INITIALIZED_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrAlreadyExists), "Status conversion subcase ALREADY_INITIALIZED_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, NOT_INITIALIZED_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNotReady), "Status conversion subcase NOT_INITIALIZED_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INVALID_ARGUMENT_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrArgument), "Status conversion subcase INVALID_ARGUMENT_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, FAIL_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrGeneral), "Status conversion subcase FAIL_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_EFFECT_TYPE_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_EFFECT_TYPE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_CAPABILITY_TYPE_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_CAPABILITY_TYPE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_PROPERTY_TYPE_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_PROPERTY_TYPE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, DEVICE_NEEDS_LICENSE_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrAccessDenied), "Status conversion subcase DEVICE_NEEDS_LICENSE_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, NOT_ENOUGH_MEMORY_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNoMemory), "Status conversion subcase NOT_ENOUGH_MEMORY_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, SERVICE_NOT_RUNNING_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNotReady), "Status conversion subcase SERVICE_NOT_RUNNING_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrAccessDenied), "Status conversion subcase INSUFFICIENT_PRIORITY_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, SERVICE_BUSY_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Status conversion subcase SERVICE_BUSY_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, WRN_NOT_PLAYING_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrArgument), "Status conversion subcase WRN_NOT_PLAYING_TEST failed (asynch)!" ); + + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, WRN_INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Status conversion subcase WRN_INSUFFICIENT_PRIORITY_TEST failed (asynch)!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Load multiple IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_LoadMultipleIVTData() + { + TInt fileHandle; + TInt prevFileHandle; + + // load the IVT data + TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Load multiple IVT-data case)!" ); + prevFileHandle = fileHandle; + + // load the IVT data + fileHandle = 0; + err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline ,EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" ); + TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Load multiple IVT-data case)!" ); + TEST_ASSERT_DESC( fileHandle!=prevFileHandle, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // try to load the same IVT data as before + fileHandle = 0; + err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" ); + TEST_ASSERT_DESC( fileHandle == prevFileHandle, "Loading IVT data failed, wrong fileHandle (Load multiple IVT-data case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" ); + return err; + } + +// --------------------------------------------------------- +// Playing from multiple IVT data (synchronous version) +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataSynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" ); + + // play the effect.. + TInt effectHandle; + err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect.. + effectHandle = 0; + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect.. + effectHandle = 0; + err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect.. + effectHandle = 0; + TInt unknownFileHandle = 3; + err = iHaptics->PlayEffect( unknownFileHandle, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing loaded IVT data failed, not bad handle (synch)!" ); + TEST_ASSERT_DESC( !effectHandle, "Playing loaded IVT data failed, not empty effectHandle (synch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" ); + return err; + } + +// --------------------------------------------------------- +// Playing the previously loaded IVT data (asynchronous version) +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataAsynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" ); + + // play the effect.. + TInt effectHandle; + TRequestStatus status = KRequestPending; + + iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect.. + effectHandle = 0; + status = KRequestPending; + iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect.. + effectHandle = 0; + status = KRequestPending; + TInt unknownFileHandle = 3; + iSender->Play( iHaptics, unknownFileHandle, 0, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrBadHandle), "Playing loaded IVT data failed, not bad handle (asynch)!" ); + TEST_ASSERT_DESC( !effectHandle, "Playing loaded IVT data failed, not empty effectHandle (asynch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing asynchronously case))" ); + return err; + } + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (synchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeTimeline ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" ); + + // play the effect repeatedly (repeated 3 times) + TInt effectHandle; + err = iHaptics->PlayEffectRepeat( fileHandle1, 0, 3, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect repeatedly (repeated 3 times) + effectHandle = 0; + err = iHaptics->PlayEffectRepeat( fileHandle2, 0, 3, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" ); + + // play the effect repeatedly (repeated 3 times) + effectHandle = 0; + TInt unknownFileHandle = 3; + err = iHaptics->PlayEffectRepeat( unknownFileHandle, 0, 3, effectHandle ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing repeatedly loaded IVT data failed, not bad handle (synch)!" ); + TEST_ASSERT_DESC( !effectHandle, "Playing repeatedly loaded IVT data failed, not empty effectHandle (synch)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT synchronously case))" ); + return err; + } + + +// --------------------------------------------------------- +// Playing with repeat the previously loaded IVT data +// (asynchronous version). Uses timeline effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous() + { + // load the IVT data + TInt fileHandle1; + TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" ); + + // load the IVT data + TInt fileHandle2; + err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" ); + + // play the effect (repeated 5 times) + TInt effectHandle; + TRequestStatus status = KRequestPending; + + iSender->PlayRepeat( iHaptics, fileHandle1, 0, 5, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect (repeated 5 times) + effectHandle = 0; + iSender->PlayRepeat( iHaptics, fileHandle2, 0, 5, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" ); + TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" ); + + // play the effect (repeated 5 times) + effectHandle = 0; + status = KRequestPending; + TInt unknownFileHandle = 3; + iSender->PlayRepeat( iHaptics, unknownFileHandle, 0, 5, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrBadHandle), "Playing repeatedly loaded IVT data failed, not bad handle (asynch)!" ); + TEST_ASSERT_DESC( !effectHandle, "Playing repeatedly loaded IVT data failed, not empty effectHandle (asynch)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" ); + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT asynchronously case))" ); + return err; + } + +// --------------------------------------------------------- +// Releasing previously reserved haptics +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ReserveAndReleaseHaptics() + { + // reserve + TRAPD( err, iHaptics->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Release haptics case failed (ReserveHapticsL leaves)!" ); + + // release (does not return an error code) + iHaptics->ReleaseHaptics(); + return err; + } + +// --------------------------------------------------------- +// Reserving haptics several (in this case three) times +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ReserveHapticsSeveralTimes() + { + TRAPD( err, iHaptics->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics (1st call) failed!" ); + TRAP( err, iHaptics->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics (2nd call) failed!" ); + TRAP( err, iHaptics->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics (3rd call) failed!" ); + return err; + } + +// --------------------------------------------------------- +// Reserving haptics +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ReserveHapticsNoReleaseL() + { + // create first haptics instance + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + // reserve + TRAPD( err, haptics1->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // create second haptics instance and open actuator + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // play an effect using second client (should fail because + // of reservation) + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TInt effectHandle = 0; + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although server reserved!" ); + + // destroy first client --> should release reservation + CleanupStack::PopAndDestroy( haptics1 ); + + // play an effect using second client (should succeed, since no + // reservation) + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed (no reservation)!" ); + + // cleanup + effBuf.Close(); + delete haptics2; + return err; + } + +// --------------------------------------------------------- +// Releasing haptics when it has not been previously reserved +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ReleaseHapticsWithoutReservingFirst() + { + // no return values nor leave to check, just execute + iHaptics->ReleaseHaptics(); + return KErrNone; + } + +// --------------------------------------------------------- +// Tries to reserve haptics with forceNoCoeEnv flag on. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ReserveNoAutomaticFocusNotTrusted() + { + TRAPD( err, iHaptics->ReserveHapticsL( ETrue ) ); + TEST_ASSERT_DESC( (err == KErrAccessDenied), "Reservation succeeded although not a trusted client!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Tries to reserve haptics, when it has already been +// reserved for another client with higher priority. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ReserveAlreadyReservedHigherL() + { + // create haptics instances and open actuators + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set first client priority (max) + haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + + // reserve + TRAP( err, haptics1->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // set second client priority (min) + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + + // reserve + TRAP( err, haptics2->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // play effect using the second client + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TInt effectHandle = 0; + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release first client's reservation + haptics1->ReleaseHaptics(); + + // play effect using the second client + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release second client's reservation + haptics2->ReleaseHaptics(); + + // cleanup + effBuf.Close(); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return err; + } + +// --------------------------------------------------------- +// Tries to reserve haptics, when it has already been +// reserved for another client with lower priority. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ReserveAlreadyReservedLowerL() + { + // create haptics instances and open actuators + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set first client priority (min) + haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + + // reserve + TRAP( err, haptics1->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // set second client priority (max) + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + + // reserve + TRAP( err, haptics2->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // play effect using first client + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + TInt effectHandle = 0; + err = haptics1->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // play effect using second client + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release second client + haptics2->ReleaseHaptics(); + + // play effect using first client + err = haptics1->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // play effect using second client + err = haptics2->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" ); + + // release first client + haptics1->ReleaseHaptics(); + + // cleanup + effBuf.Close(); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return err; + } + +// --------------------------------------------------------- +// Tries to play effects, when haptics has been reserved +// for a higher priority client. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayWhenReservedL() + { + // create haptics instances and open actuators + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set first client priority (max) + haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + + // reserve for first client + TRAP( err, haptics1->ReserveHapticsL() ); + TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" ); + + // set second client priority (min) + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + + // play effects using second client, when reserved for the first + // ---> + + // create effect data for playing effect directly using IVT-data + RBuf8 effBuf; + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // load the IVT data for playing effects using filehandle + TInt fileHandle = 0; + err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed!" ); + + // create a magsweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect magSweepEffect; + CreateMagSweepEffect( magSweepEffect ); + + // create a periodic effect + CHWRMHaptics::THWRMHapticsPeriodicEffect periodicEffect; + CreatePeriodicEffect( periodicEffect ); + + TInt effectHandle = 0; + TRequestStatus status = KRequestPending; + + // synchronous play with data + err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous play-repeat with data + err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play with data + status = KRequestPending; + iHaptics->PlayEffect( effBuf, 0, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play-repeat with data + status = KRequestPending; + iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous play with filehandle + err = iHaptics->PlayEffect( fileHandle, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous play-repeat with filehandle + err = iHaptics->PlayEffectRepeat( fileHandle, 0, 2, effectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play with filehandle + status = KRequestPending; + iSender->Play( iHaptics, fileHandle, 0, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous play-repeat with filehandle + status = KRequestPending; + iSender->PlayRepeat( iHaptics, fileHandle, 0, 2, effectHandle, status ); + iWait.Start(); + TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous manual magsweep + err = iHaptics->PlayMagSweepEffect( magSweepEffect, effectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // synchronous manual periodic + err = iHaptics->PlayPeriodicEffect( periodicEffect, effectHandle ); + TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous manual magsweep + status = KRequestPending; + iHaptics->PlayMagSweepEffect( magSweepEffect, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // asynchronous manual periodic + status = KRequestPending; + iHaptics->PlayPeriodicEffect( periodicEffect, effectHandle, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" ); + + // <--- + + // cleanup + effBuf.Close(); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Getting effect count from preloaded IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetIVTEffectCount() + { + TInt fileHandle1; + TInt fileHandle2; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" ); + TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" ); + + // load the IVT effect set 2 + err = LoadIVTDataInternal( fileHandle2, Magsweep4HapticsMT_ivt, + sizeof( Magsweep4HapticsMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" ); + TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" ); + + + TInt effectCount; + // get effect count from IVT-data 1 + err = iHaptics->GetEffectCount( fileHandle1, effectCount ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect count failed (GetIVTEffectCount case)!" ); + TEST_ASSERT_DESC( (effectCount == 6), "Wrong effect count (GetIVTEffectCount case)!" ); + + // get effect count from corrupted IVT-data + err = iHaptics->GetEffectCount( corruptedFile, effectCount ); + TEST_ASSERT_DESC( (err == KErrArgument), "Get count from corrupted IVT-data, incorrect error code (GetIVTEffectCount case)!" ); + + // get effect count from IVT-data 2 + err = iHaptics->GetEffectCount( fileHandle2, effectCount ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect count failed (GetIVTEffectCount case)!" ); + TEST_ASSERT_DESC( (effectCount == 1), "Wrong effect count (GetIVTEffectCount case)!" ); + + // get effect count using unknown file handle + err = iHaptics->GetEffectCount( unknownFileHandle, effectCount ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectCount case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectCount case))" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Getting effect duration from preloaded IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetIVTEffectDuration() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectDuration case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectDuration case)!" ); + + TInt effectDuration; + // duration of the last effect + TInt index = 5; + err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration ); + TEST_ASSERT_DESC( (err == KErrNone), "Get duration failed (GetIVTEffectDuration case)!" ); + TEST_ASSERT_DESC( (effectDuration == 4000), "Wrong duration (GetIVTEffectDuration case)!" ); + + // get duration using effect index out of bounds + index = 6; + err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration ); + TEST_ASSERT_DESC( (err != KErrNone), "Get duration succeeded (GetIVTEffectDuration case)!" ); + + // get duration from corrupted IVT-data + index = 0; err = KErrNone; + err = iHaptics->GetEffectDuration( corruptedFile, index, effectDuration ); + TEST_ASSERT_DESC( (err == KErrArgument), "Get duration from corrupted data, incorrect error code (GetIVTEffectDuration case)!" ); + + // duration of the first effect + index = 0; + err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration ); + TEST_ASSERT_DESC( (err == KErrNone), "Get duration failed (GetIVTEffectDuration case)!" ); + TEST_ASSERT_DESC( (effectDuration == 3915), "Wrong duration (GetIVTEffectDuration case)!" ); + + // get duration using unknown file handle + index = 0; + err = iHaptics->GetEffectDuration( unknownFileHandle, index, effectDuration ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectDuration case)!" ); + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectDuration case))" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Getting effect index from preloaded IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetIVTEffectIndexFromName() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetEffectIndexFromName case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetEffectIndexFromName case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetEffectIndexFromName case)!" ); + TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetEffectIndexFromName case)!" ); + + + TInt effectIndex; + _LIT8( KFirstName, "Timeline1" ); + _LIT8( KLastName, "MagSweep2" ); + _LIT8( KUnknownName, "Tiline1" ); + TBuf8<128> effectName; + + // get index of the first name + effectName = KFirstName; + err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect index failed (GetEffectIndexFromName case)!" ); + TEST_ASSERT_DESC( (effectIndex == 0), "Wrong effect index (GetEffectIndexFromName case)!" ); + + // get index of the last name + effectName = KLastName; + err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect index failed (GetEffectIndexFromName case)!" ); + TEST_ASSERT_DESC( (effectIndex == 5), "Wrong effect index (GetEffectIndexFromName case)!" ); + + // get index from corrupted IVT-data + effectName = KFirstName; + err = iHaptics->GetEffectIndexFromName( corruptedFile, effectName, effectIndex ); + TEST_ASSERT_DESC( (err == KErrArgument), "Get effect index from corrupted data, incorrect error code (GetEffectIndexFromName case)!" ); + + // get index using unknown name + effectName = KUnknownName; + err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex ); + TEST_ASSERT_DESC( (err != KErrNone), "Get effect succeeded (GetEffectIndexFromName case)!" ); + + // get index using unknown file handle + effectName = KUnknownName; + err = iHaptics->GetEffectIndexFromName( unknownFileHandle, effectName, effectIndex ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetEffectIndexFromName case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetEffectIndexFromName case))" ); + return err; + } + + +// --------------------------------------------------------- +// Getting effect type from preloaded IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetIVTEffectType() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectType case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectType case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectType case)!" ); + TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectType case)!" ); + + + // get type of the first effect + TInt effectType; + TInt effectIndex = 0; + err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect type failed (GetIVTEffectType case)!" ); + TEST_ASSERT_DESC( (effectType == CHWRMHaptics::EHWRMHapticsTypeTimeline), "Wrong effect type (GetIVTEffectType case)!" ); + + // get type from corrupted IVT-data + effectIndex = 5; + err = iHaptics->GetEffectType( corruptedFile, effectIndex, effectType ); + TEST_ASSERT_DESC( (err == KErrArgument), "Get effect type from corrupted data, incorrect error code (GetIVTEffectType case)!" ); + + // get type of the last effect + effectIndex = 5; + err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect type failed (GetIVTEffectType case)!" ); + TEST_ASSERT_DESC( (effectType == CHWRMHaptics::EHWRMHapticsTypeMagSweep), "Wrong effect type (GetIVTEffectType case)!" ); + + // get type using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType ); + TEST_ASSERT_DESC( (err != KErrNone), "Get effect type succeeded (GetIVTEffectType case)!" ); + + // get type using unknown file handle + effectIndex = 6; + err = iHaptics->GetEffectType( unknownFileHandle, effectIndex, effectType ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectType case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectType case))" ); + return err; + } + +// --------------------------------------------------------- +// Getting effect name from preloaded IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetIVTEffectName() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectName case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" ); + TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectName case)!" ); + + + // get name of the first effect + TBuf8<128> effectName; + TInt effectIndex = 0; + _LIT8( KTimeline1, "Timeline1" ); + _LIT8( KMagSweep2, "MagSweep2" ); + err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect name failed (GetIVTEffectName case)!" ); + TEST_ASSERT_DESC( (effectName == KTimeline1), "Wrong effect name (GetIVTEffectName case)!" ); + + // get name from corrupted IVT-data + effectIndex = 0; + err = iHaptics->GetEffectName( corruptedFile, effectIndex, effectName ); + TEST_ASSERT_DESC( (err == KErrArgument), "Get effect name from corrupted data, incorrect error code (GetIVTEffectName case)!" ); + + // get name of the last effect + effectIndex = 5; + err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect name failed (GetIVTEffectName case)!" ); + TEST_ASSERT_DESC( (effectName == KMagSweep2), "Wrong effect name (GetIVTEffectType case)!" ); + + // get name using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName ); + TEST_ASSERT_DESC( (err != KErrNone), "Get effect name succeeded (GetIVTEffectName case)!" ); + + // get name using unknown file handle + effectIndex = 0; + err = iHaptics->GetEffectName( unknownFileHandle, effectIndex, effectName ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectName case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectName case))" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Getting MagSweep effect definition from preloaded IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetIVTMagSweepEffectDefinition() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTMagSweepEffectDefinition case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTMagSweepEffectDefinition case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTMagSweepEffectDefinition case)!" ); + TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTMagSweepEffectDefinition case)!" ); + + + // get definition of the first MagSweep effect + CHWRMHaptics::THWRMHapticsMagSweepEffect effectDefinition; + TInt effectIndex = 4; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTMagSweepEffectDefinition case)!" ); + TEST_ASSERT_DESC( (effectDefinition.iDuration == 3000), "Wrong effect definition (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition from corrupted IVT-data + effectIndex = 0; + err = iHaptics->GetMagSweepEffectDefinition( corruptedFile, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrArgument), "Get effect definition from corrupted data, incorrect error code (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition of the last MagSweep effect + effectIndex = 5; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTMagSweepEffectDefinition case)!" ); + TEST_ASSERT_DESC( (effectDefinition.iDuration == 4000), "Wrong effect definition (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition using effect index not pointing to MagSweep effect + effectIndex = 2; + err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTMagSweepEffectDefinition case)!" ); + + // get definition using unknown file handle + effectIndex = 0; + err = iHaptics->GetMagSweepEffectDefinition( unknownFileHandle, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTMagSweepEffectDefinition case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTMagSweepEffectDefinition case))" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Getting Periodic effect definition from preloaded IVT-data +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetIVTPeriodicEffectDefinition() + { + TInt fileHandle1; + TInt corruptedFile; + TInt unknownFileHandle = 9; + + // load the IVT effect set 1 + TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt, + sizeof( EffectSetMT_ivt ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTPeriodicEffectDefinition case)!" ); + TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTPeriodicEffectDefinition case)!" ); + + // load corrupted IVT effect set + err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt, + sizeof( CorruptedMT_ivt ), EFalse ); + TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTPeriodicEffectDefinition case)!" ); + TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTPeriodicEffectDefinition case)!" ); + + + // get definition of the first Periodic effect + CHWRMHaptics::THWRMHapticsPeriodicEffect effectDefinition; + TInt effectIndex = 2; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTPeriodicEffectDefinition case)!" ); + TEST_ASSERT_DESC( (effectDefinition.iDuration == 1000), "Wrong effect definition (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition from corrupted IVT-data + effectIndex = 0; + err = iHaptics->GetPeriodicEffectDefinition( corruptedFile, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrArgument), "Get effect definition from corrupted data, incorrect error code (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition of the last Periodic effect + effectIndex = 3; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTPeriodicEffectDefinition case)!" ); + TEST_ASSERT_DESC( (effectDefinition.iDuration == 2000), "Wrong effect definition (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition using effect index out of bounds + effectIndex = 6; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition using effect index not pointing to Periodic effect + effectIndex = 5; + err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTPeriodicEffectDefinition case)!" ); + + // get definition using unknown file handle + effectIndex = 0; + err = iHaptics->GetPeriodicEffectDefinition( unknownFileHandle, effectIndex, effectDefinition ); + TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTPeriodicEffectDefinition case)!" ); + + + // clean up.. (Teardown() will handle the rest) + err = iHaptics->DeleteAllEffectData(); + TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTPeriodicEffectDefinition case))" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Open asynchronously and close haptics client-server session, i.e. +// create and delete haptics client. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_CreateAndDeleteAsynchronousL() + { + // create iHaptics instance without observers + TRequestStatus status; + iHaptics = CHWRMHaptics::NewL( NULL, NULL, status ); + User::WaitForRequest( status ); + + // the connection has been opened successfully, if iHaptics is valid and + // error code is not returned + TEST_ASSERT_DESC( status == KErrNone, "Haptics client creation failed!"); + TEST_ASSERT_DESC( iHaptics, "Haptics client creation failed!"); + + // the connection is closed, when iHaptics is deleted + delete iHaptics; + iHaptics = NULL; + return KErrNone; + } + +// --------------------------------------------------------- +// Create several simultaneous sessions to haptics server +// asynchronously. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_SeveralSessionsAsynchronousL() + { + // create haptics instances without observers. This creates + // client-server sessions (session instances in the server) + TRequestStatus status1; + TRequestStatus status2; + TRequestStatus status3; + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL, status1 ); + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL, status2 ); + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL, status3 ); + User::WaitForRequest( status1 ); + User::WaitForRequest( status2 ); + User::WaitForRequest( status3 ); + + // the connection has been opened successfully, if instances are valid and + // error code is not returned + TEST_ASSERT_DESC( status1 == KErrNone, "First haptics client creation failed!"); + TEST_ASSERT_DESC( status2 == KErrNone, "Second haptics client creation failed!"); + TEST_ASSERT_DESC( status3 == KErrNone, "Third haptics client creation failed!"); + TEST_ASSERT_DESC( haptics1, "First haptics client creation failed!"); + TEST_ASSERT_DESC( haptics2, "Second haptics client creation failed!"); + TEST_ASSERT_DESC( haptics3, "Third haptics client creation failed!"); + + // delete haptics instances. This removes the sessions from + // haptics server, and closes the server, when the last session + // is closed + delete haptics1; haptics1 = NULL; + delete haptics2; haptics2 = NULL; + delete haptics3; haptics3 = NULL; + return KErrNone; + } + +// --------------------------------------------------------- +// Create several consecutive sessions asynchronously +// to haptics server. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ConsecutiveSessionsAsynchronousL() + { + // Do create and delete three times in a row + T_CreateAndDeleteAsynchronousL(); + T_CreateAndDeleteAsynchronousL(); + T_CreateAndDeleteAsynchronousL(); + return KErrNone; + } + +// --------------------------------------------------------- +// Attemps to pause an effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PauseEffect() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // pause effect testing + TInt err = iHaptics->PausePlayingEffect( 0 ); + TEST_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle 0 failed!"); + err = iHaptics->PausePlayingEffect( INT_MIN ); + TEST_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle INT_MIN failed!"); + err = iHaptics->PausePlayingEffect( INT_MAX ); + TEST_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle INT_MAX failed!"); + return err; + } + +// --------------------------------------------------------- +// Attemps to resume an effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ResumeEffect() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // resume effect testing + TInt err = iHaptics->ResumePausedEffect( 0 ); + TEST_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle 0 failed!"); + err = iHaptics->ResumePausedEffect( INT_MIN ); + TEST_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle INT_MIN failed!"); + err = iHaptics->ResumePausedEffect( INT_MAX ); + TEST_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle INT_MAX failed!"); + return err; + } + +// --------------------------------------------------------- +// Attemps to stop an effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_StopEffect() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // stop effect testing + TInt err = iHaptics->StopPlayingEffect( 0 ); + TEST_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle 0 failed!"); + err = iHaptics->StopPlayingEffect( INT_MIN ); + TEST_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle INT_MIN failed!"); + err = iHaptics->StopPlayingEffect( INT_MAX ); + TEST_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle INT_MAX failed!"); + return err; + } + +// --------------------------------------------------------- +// Attemps to stop all effects. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_StopAllEffects() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // resume effect testing + TInt err = iHaptics->StopAllPlayingEffects(); + TEST_ASSERT_DESC( err == KErrNone, "Stopping all effects failed!"); + return err; + } + +// --------------------------------------------------------- +// Executes sequence: play effect, pause, resume, stop. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayPauseResumeStop() + { + // open a supported actuator + T_OpenSupportedActuator(); + + // read magsweep effect to buffer + RBuf8 effBuf; + CleanupClosePushL( effBuf ); + CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep ); + + // play the effect + TInt effectHandle = 0; + TInt err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed!" ); + TEST_ASSERT_DESC( effectHandle, "Playing IVT effect synchronously returned empty effect handle!" ); + + // cleanup buffer + CleanupStack::PopAndDestroy( &effBuf ); + + // pause the effect + err = iHaptics->PausePlayingEffect( effectHandle ); + TEST_ASSERT_DESC( err == KErrNone, "Pausing the effect failed!"); + + // resume the effect + err = iHaptics->ResumePausedEffect( effectHandle ); + TEST_ASSERT_DESC( err == KErrNone, "Resuming the effect failed!"); + + // stop the effect + err = iHaptics->StopPlayingEffect( effectHandle ); + TEST_ASSERT_DESC( err == KErrNone, "Stopping the effect failed!"); + return err; + } + +// --------------------------------------------------------- +// Constant getters testing. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ConstantGetters() + { + const TInt expectedInfRepeat = 255; // VIBE_REPEAT_COUNT_INFINITE + const TInt expectedInfDuration = INT_MAX; // VIBE_TIME_INFINITE; + const TInt expectedMaxEffNameLen = 128; // VIBE_MAX_EFFECT_NAME_LENGTH + const TInt expectedMaxDevNameLen = 64; // VIBE_MAX_DEVICE_NAME_LENGTH + const TInt expectedMaxCapaStrLen = 64; // VIBE_MAX_CAPABILITY_STRING_LENGTH + const TInt expectedMaxPropStrLen = 64; // VIBE_MAX_PROPERTY_STRING_LENGTH + const TInt expectedMaxStrmSampleLen = 255; // VIBE_MAX_STREAMING_SAMPLE_SIZE + const TInt expectedDefaultDevPriority = 0; // VIBE_DEVPRIORITY_DEFAULT + + TInt infRepeat = iHaptics->InfiniteRepeat(); + TEST_ASSERT_DESC( KErrNotReady == infRepeat, "InfiniteRepeat() wrong error code" ); + TInt infDuration = iHaptics->InfiniteDuration(); + TEST_ASSERT_DESC( KErrNotReady == infDuration, "InfiniteDuration() wrong error code" ); + TInt maxEffNameLen = iHaptics->MaxEffectNameLength(); + TEST_ASSERT_DESC( KErrNotReady == maxEffNameLen, "MaxEffectNameLength() wrong error code" ); + TInt maxDevNameLen = iHaptics->MaxDeviceNameLength(); + TEST_ASSERT_DESC( KErrNotReady == maxDevNameLen, "MaxDeviceNameLength() wrong error code" ); + TInt maxCapaStrLen = iHaptics->MaxCapabilityStringLength(); + TEST_ASSERT_DESC( KErrNotReady == maxCapaStrLen, "MaxCapabilityStringLength() wrong error code" ); + TInt maxPropStrLen = iHaptics->MaxPropertyStringLength(); + TEST_ASSERT_DESC( KErrNotReady == maxPropStrLen, "MaxPropertyStringLength() wrong error code" ); + TInt maxStrmSampleLen = iHaptics->MaxStreamingSampleSize(); + TEST_ASSERT_DESC( KErrNotReady == maxStrmSampleLen, "MaxStreamingSampleSize() wrong error code" ); + TInt defaultDevPriority = iHaptics->DefaultDevicePriority(); + TEST_ASSERT_DESC( KErrNotReady == defaultDevPriority, "DefaultDevicePriority() wrong error code" ); + + // open a supported actuator + T_OpenSupportedActuator(); + + infRepeat = iHaptics->InfiniteRepeat(); + TEST_ASSERT_DESC( expectedInfRepeat == infRepeat, "InfiniteRepeat() failed" ); + infDuration = iHaptics->InfiniteDuration(); + TEST_ASSERT_DESC( expectedInfDuration == infDuration, "InfiniteDuration() failed" ); + maxEffNameLen = iHaptics->MaxEffectNameLength(); + TEST_ASSERT_DESC( expectedMaxEffNameLen == maxEffNameLen, "MaxEffectNameLength() failed" ); + maxDevNameLen = iHaptics->MaxDeviceNameLength(); + TEST_ASSERT_DESC( expectedMaxDevNameLen == maxDevNameLen, "MaxDeviceNameLength() failed" ); + maxCapaStrLen = iHaptics->MaxCapabilityStringLength(); + TEST_ASSERT_DESC( expectedMaxCapaStrLen == maxCapaStrLen, "MaxCapabilityStringLength() failed" ); + maxPropStrLen = iHaptics->MaxPropertyStringLength(); + TEST_ASSERT_DESC( expectedMaxPropStrLen == maxPropStrLen, "MaxPropertyStringLength() failed" ); + maxStrmSampleLen = iHaptics->MaxStreamingSampleSize(); + TEST_ASSERT_DESC( expectedMaxStrmSampleLen == maxStrmSampleLen, "MaxStreamingSampleSize() failed" ); + defaultDevPriority = iHaptics->DefaultDevicePriority(); + TEST_ASSERT_DESC( expectedDefaultDevPriority == defaultDevPriority, "DefaultDevicePriority() failed" ); + return KErrNone; + } + + +// --------------------------------------------------------- +// Modifies playing magsweep effect using synchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ModifyMagSweepEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsMagSweepEffect modifiedEffect; + modifiedEffect.iDuration = 3030; + modifiedEffect.iMagnitude = 7070; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TInt err = iHaptics->ModifyPlayingMagSweepEffect( 0, modifiedEffect ); + TEST_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle 0 failed!" ); + + err = iHaptics->ModifyPlayingMagSweepEffect( INT_MIN, modifiedEffect ); + TEST_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle INT_MIN failed!" ); + + err = iHaptics->ModifyPlayingMagSweepEffect( INT_MAX, modifiedEffect ); + TEST_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle INT_MAX failed!" ); + return err; + } + + +// --------------------------------------------------------- +// Modifies playing magsweep effect using asynchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ModifyMagSweepEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsMagSweepEffect modifiedEffect; + modifiedEffect.iDuration = 5050; + modifiedEffect.iMagnitude = 1010; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TRequestStatus status = KRequestPending; + iHaptics->ModifyPlayingMagSweepEffect( 0, modifiedEffect, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle 0 failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingMagSweepEffect( INT_MIN, modifiedEffect, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle INT_MIN failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingMagSweepEffect( INT_MAX, modifiedEffect, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle INT_MAX failed!" ); + return KErrNone; + } + + +// --------------------------------------------------------- +// Modifies playing periodic effect using synchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ModifyPeriodicEffectSynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsPeriodicEffect modifiedEffect; + modifiedEffect.iDuration = 6060; + modifiedEffect.iMagnitude = 2020; + modifiedEffect.iPeriod = 200; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TInt err = iHaptics->ModifyPlayingPeriodicEffect( 0, modifiedEffect ); + TEST_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle 0 failed!" ); + + err = iHaptics->ModifyPlayingPeriodicEffect( INT_MIN, modifiedEffect ); + TEST_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle INT_MIN failed!" ); + + err = iHaptics->ModifyPlayingPeriodicEffect( INT_MAX, modifiedEffect ); + TEST_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle INT_MAX failed!" ); + return err; + } + + +// --------------------------------------------------------- +// Modifies playing periodic effect using asynchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ModifyPeriodicEffectAsynchronous() + { + // open actuator.. + T_OpenSupportedActuator(); + + // modify effect + CHWRMHaptics::THWRMHapticsPeriodicEffect modifiedEffect; + modifiedEffect.iDuration = 4040; + modifiedEffect.iMagnitude = 6060; + modifiedEffect.iPeriod = 200; + modifiedEffect.iStyle = CHWRMHaptics::EHWRMHapticsStyleStrong; + modifiedEffect.iAttackTime = 2000; + modifiedEffect.iAttackLevel = 500; + modifiedEffect.iFadeTime = 100; + modifiedEffect.iFadeLevel = 10; + + TRequestStatus status = KRequestPending; + iHaptics->ModifyPlayingPeriodicEffect( 0, modifiedEffect, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle 0 failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingPeriodicEffect( INT_MIN, modifiedEffect, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle INT_MIN failed!" ); + + status = KRequestPending; + iHaptics->ModifyPlayingPeriodicEffect( INT_MAX, modifiedEffect, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle INT_MAX failed!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Gets device TInt property +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetDeviceProperty_TInt_TInt() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get the same value 1 + TInt retValue (0); + TInt err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, retValue ); + TEST_ASSERT_DESC( (err == KErrNone), "Getting device property (Strength) failed(1)!" ); + + err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, retValue ); + TEST_ASSERT_DESC( (err == KErrNone), "Getting device property (disableEffects) failed(1)!" ); + return err; + } + +// --------------------------------------------------------- +// Gets device TDesC property +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetDeviceProperty_TInt_TDesC() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get property + TBuf8<100> retValue; + TInt err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsLicensekey, retValue ); + TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (EHWRMHapticsLicensekey) failed!" ); + return err; + } + +// --------------------------------------------------------- +// Sets device TInt property +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_SetDeviceProperty_TInt_TInt() + { + const TInt KSomeValue = 50; + // open actuator.. + T_OpenSupportedActuator(); + + // set property + TInt err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, KSomeValue ); + TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (Strength) failed!" ); + + err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, 0 ); + TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (disableEffects) failed!" ); + return err; + } + +// --------------------------------------------------------- +// Sets device TDesC property +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_SetDeviceProperty_TInt_TDesC() + { + // open actuator.. + T_OpenSupportedActuator(); + + // set property + TInt err = iHaptics->SetDeviceProperty( + CHWRMHaptics::EHWRMHapticsLicensekey, + KNullDesC8 ); + TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (NULL license key) failed!" ); + + err = iHaptics->SetDeviceProperty( + CHWRMHaptics::EHWRMHapticsLicensekey, + KPlainKey ); + TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (license key) failed!" ); + return err; + } + +TInt CHapticsClientTest::T_PluginMgrTransTimerExpires() + { + // open actuator.. + T_OpenSupportedActuator(); + + _LIT8 ( KTestPluginMgrTransTimerExpires, "KTestPluginMgrTransTimerExpires" ); + // set property with the TestCase ID string, so that the test plug-in doesn't send the response for the current + // transaction, till the Plug-in manager Transction timer expires. + // Out-come: Plug-in manager should hanlde this scenario and send cancel transaction command to test plug-in. + TInt err = iHaptics->SetDeviceProperty( + CHWRMHaptics::EHWRMHapticsLicensekey, + KTestPluginMgrTransTimerExpires ); + TEST_ASSERT_DESC( (err == KErrTimedOut), "Setting device property (license key) failed!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Gets device TInt capability +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetDeviceCapability_TInt_TInt() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get the value + TInt retValue (0); + TInt expectedValue (1); // from testplugin's stubresponse.txt + TInt err = iHaptics->GetDeviceCapability( CHWRMHaptics::EHWRMHapticsMaxNestedRepeats, retValue ); + TEST_ASSERT_DESC( (err == KErrNone), + "Getting device property (MaxNestedRepeats) failed!" ); + TEST_ASSERT_DESC( expectedValue == retValue, + "Getting device property (MaxNestedRepeats) failed, wrong value!") + return err; + } + +// --------------------------------------------------------- +// Gets device TDesC capability +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetDeviceCapability_TInt_TDesC() + { + // open actuator.. + T_OpenSupportedActuator(); + + // get the same value + TBuf8<100> retValue; + retValue.FillZ(); // sets length, important here.. + TInt err = iHaptics->GetDeviceCapability( CHWRMHaptics::EHWRMHapticsDeviceName, retValue ); + TEST_ASSERT_DESC( (err == KErrNone), "Getting device property (DevName) failed!" ); + // the following are based on what the testplugin retunrs (i.e., bytes + // containing the ASCII character values for "S","T","U" and "B") + const TInt expectedSize( 4 ); + TEST_ASSERT_DESC( expectedSize == retValue.Size(), + "Getting device property (DevName) failed, wrong length!" ); + const TUint8 ascii4S( 0x53 ); + const TUint8 ascii4T( 0x54 ); + const TUint8 ascii4U( 0x55 ); + const TUint8 ascii4B( 0x42 ); + TEST_ASSERT_DESC( ascii4S == retValue[0] && ascii4T == retValue[1] && + ascii4U == retValue[2] && ascii4B == retValue[3], + "Getting device property (DevName) failed, wrong data!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Fetches the haptics status using the getter method. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetHapticsStatus() + { + MHWRMHapticsObserver::THWRMHapticsStatus status = iHaptics->HapticsStatus(); + TEST_ASSERT_DESC( (status == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable), + "Invalid haptics status received!" ); + return KErrNone; + } + +// --------------------------------------------------------- +// Fetches the haptics status using the observer. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ObserveHapticsStatus() + { + // create callback instance + THapticsStatusCallback callback( this ); + + // create haptics client with observer + CHWRMHaptics* haptics = CHWRMHaptics::NewL( &callback, NULL ); + + // wait for the callback to be called + iWait.Start(); + + // check status (since execution of this method continues, the status + // has been updated in the callback) + TEST_ASSERT_DESC( (callback.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable), + "Invalid haptics status received!" ); + + // cleanup + delete haptics; + return KErrNone; + } + +// --------------------------------------------------------- +// Fetches status values, when one client is reserving +// haptics. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetHapticsStatusWithReservations() + { + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + // make reservation using the first client + haptics1->ReserveHapticsL(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation + haptics1->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Status value observing, when one client is reserving +// haptics. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ObserveHapticsStatusWithReservations() + { + // create callback instances + THapticsStatusCallback callback1( this ); + THapticsStatusCallback callback2( this ); + + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL ); + CleanupStack::PushL( haptics2 ); + + // wait for the initial notifications to arrive + iWait.Start(); + iWait.Start(); + + // make reservation using the first client + haptics1->ReserveHapticsL(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation + haptics1->ReleaseHaptics(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + status2 = callback2.Status(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Haptics status, when several clients are making +// reservations with equal priorities. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetHapticsStatusWithSeveralReservations() + { + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + // make reservation using both clients (second should become suspended) + haptics1->ReserveHapticsL(); + haptics2->ReserveHapticsL(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), + "Invalid haptics status received!" ); + + // release reservation of the first client + haptics1->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // release reservation of the second client + haptics2->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Haptics status using observation, when several clients +// are making reservations with equal priorities. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ObserveHapticsStatusWithSeveralReservations() + { + // create callback instances + THapticsStatusCallback callback1( this ); + THapticsStatusCallback callback2( this ); + + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL ); + CleanupStack::PushL( haptics2 ); + + // wait for the initial notifications to arrive + iWait.Start(); + iWait.Start(); + + // make reservation using the first client + haptics1->ReserveHapticsL(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // make reservation using the second client + haptics2->ReserveHapticsL(); + + // wait for the callback to be called (only second client + // should receive notification) + iWait.Start(); + + // check client status values + status2 = callback2.Status(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), + "Invalid haptics status received!" ); + + // release first client's reservation + haptics1->ReleaseHaptics(); + + // wait for the callback to be called (both clients should + // receive new status) + iWait.Start(); + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = callback1.Status(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + status2 = callback2.Status(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // release second client's reservation + haptics2->ReleaseHaptics(); + + // wait for the callback to be called (only first client + // should receive notification) + iWait.Start(); + + // check client status values + status1 = callback1.Status(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Several clients with one making a reservation --> tests +// that all other clients become "reserved". +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_GetHapticsStatusWithSeveralClientsOneReservation() + { + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics3 ); + + // reservation using first client + haptics1->ReserveHapticsL(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status3 = haptics3->HapticsStatus(); + TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation + haptics1->ReleaseHaptics(); + + // check client status values + status1 = haptics1->HapticsStatus(); + TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status2 = haptics2->HapticsStatus(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status3 = haptics3->HapticsStatus(); + TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics3 ); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Several clients with one making a reservation --> tests +// that all other clients become "reserved" using observers. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ObserveHapticsStatusWithSeveralClientsOneReservations() + { + // create callback instances + THapticsStatusCallback callback1( this ); + THapticsStatusCallback callback2( this ); + THapticsStatusCallback callback3( this ); + + // create haptics instances + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL ); + CleanupStack::PushL( haptics1 ); + + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL ); + CleanupStack::PushL( haptics2 ); + + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( &callback3, NULL ); + CleanupStack::PushL( haptics3 ); + + // wait for the initial notifications to arrive + iWait.Start(); + iWait.Start(); + iWait.Start(); + + // reservation using first client + haptics1->ReserveHapticsL(); + + // wait for the notifications for client2 and client3 + iWait.Start(); + iWait.Start(); + + // check client status values + MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + MHWRMHapticsObserver::THWRMHapticsStatus status3 = callback3.Status(); + TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + + // release reservation using first client + haptics1->ReleaseHaptics(); + + // wait for the notifications for client2 and client3 + iWait.Start(); + iWait.Start(); + + // check client status values + status2 = callback2.Status(); + TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + status3 = callback3.Status(); + TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics3 ); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + +// --------------------------------------------------------- +// Creates streaming effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_CreateStreamingEffect() + { + // open actuator.. + T_OpenSupportedActuator(); + + TInt effectHandle; + TInt err = iHaptics->CreateStreamingEffect( effectHandle ); + TEST_ASSERT_DESC( (err == KErrNone), "Creating streaming effect failed!" ); + TEST_ASSERT_DESC( effectHandle, "Creating streaming effect returned empty effect handle!" ); + return err; + } + +// --------------------------------------------------------- +// Plays streaming sample using synchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayStreamingSample() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // valid sized sample 0 handle 0 offset + TInt err = iHaptics->PlayStreamingSample( 0, validStreamSample ); + TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" ); + + // normal sample MIN handle MIN offset + err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample ); + TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" ); + + // normal sample MAX handle MAX offset + err = iHaptics->PlayStreamingSample( INT_MAX, validStreamSample ); + TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + err = iHaptics->PlayStreamingSample( INT_MAX, tooBigStreamSample ); + TEST_ASSERT_DESC( (err == KErrArgument), "Play streaming sample (over sized sample), wrong error code" ); + + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample ); + TEST_ASSERT_DESC( ( err == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + return KErrNone; + } + +// --------------------------------------------------------- +// Plays streaming sample using asynchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayStreamingSampleAsync() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // normal sample 0 handle 0 offset + TRequestStatus status = KRequestPending; + iHaptics->PlayStreamingSample( 0, validStreamSample, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" ); + + // normal sample MIN handle MIN offset + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" ); + + // normal sample MAX handle MAX offset + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MAX, validStreamSample, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MAX, tooBigStreamSample, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrArgument ), "Play streaming sample (over sized sample), wrong error code" ); + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + return KErrNone; + } + +// --------------------------------------------------------- +// Plays streaming sample with offset using +// synchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayStreamingSampleWithOffset() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // valid sized sample 0 handle 0 offset + TInt err = iHaptics->PlayStreamingSampleWithOffset( 0, validStreamSample, 0 ); + TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" ); + + // normal sample MIN handle MIN offset + err = iHaptics->PlayStreamingSampleWithOffset( INT_MIN, validStreamSample, INT_MIN ); + TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" ); + + // normal sample MAX handle MAX offset + err = iHaptics->PlayStreamingSampleWithOffset( INT_MAX, validStreamSample, INT_MAX ); + TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + err = iHaptics->PlayStreamingSampleWithOffset( INT_MAX, tooBigStreamSample, INT_MAX ); + TEST_ASSERT_DESC( (err == KErrArgument), "Play streaming sample with offset (over sized sample), wrong error code" ); + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample ); + TEST_ASSERT_DESC( ( err == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + return KErrNone; + } + +// --------------------------------------------------------- +// Plays streaming sample with offset using +// asynchronous API call. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_PlayStreamingSampleWithOffsetAsync() + { + // open actuator.. + T_OpenSupportedActuator(); + RBuf8 validStreamSample; + RBuf8 tooBigStreamSample; + CleanupClosePushL( validStreamSample ); + CleanupClosePushL( tooBigStreamSample ); + + TInt maxValidSize = iHaptics->MaxStreamingSampleSize(); + CreateDummyStreamSample( maxValidSize, validStreamSample ); + + // normal sample 0 handle 0 offset + TRequestStatus status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( 0, validStreamSample, 0, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" ); + + // normal sample MIN handle MIN offset + status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( INT_MIN, validStreamSample, INT_MIN, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" ); + + // normal sample MAX handle MAX offset + status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( INT_MAX, validStreamSample, INT_MAX, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" ); + + // over sized sample + CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample ); + status = KRequestPending; + iHaptics->PlayStreamingSampleWithOffset( INT_MAX, tooBigStreamSample, INT_MAX, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrArgument ), "Play streaming sample with offset (over sized sample), wrong error code" ); + + // Haptics reserved for higher priority client + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL ); + CleanupStack::PushL( haptics2 ); + + TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + + // set new client priority to maximum + haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMaxDevicePriority ); + // set default client priority to min + iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, + KHWRMHapticsMinDevicePriority ); + TRAP( error, haptics2->ReserveHapticsL() ); + + status = KRequestPending; + iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status ); + User::WaitForRequest( status ); + TEST_ASSERT_DESC( (status.Int() == KErrInUse ), "Play streaming sample with offset (haptics reserved), wrong error code" ); + + + + // clean up.. (Teardown will complete these) + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy(); //tooBigStreamSample + CleanupStack::PopAndDestroy(); //validStreamSample + return KErrNone; + } + +// --------------------------------------------------------- +// Destroys streaming effect. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_DestroyStreamingEffect() + { + // open actuator.. + T_OpenSupportedActuator(); + + // zero handle + TInt err = iHaptics->DestroyStreamingEffect( 0 ); + TEST_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle 0 failed!" ); + + // minimum handle value + err = iHaptics->DestroyStreamingEffect( INT_MIN ); + TEST_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle INT_MIN failed!" ); + + // maximum handle value + err = iHaptics->DestroyStreamingEffect( INT_MAX ); + TEST_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle INT_MAX failed!" ); + return err; + } + + +// --------------------------------------------------------- +// Fetches actuator state using the observer. +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ObserveActuatorStatus() + { + // Create 2 actuator status observer instances + TActuatorStatusCallback callback1( this ); + TActuatorStatusCallback callback2( this ); + + // create 1st haptics client with actuator observer + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, &callback1 ); + CleanupStack::PushL( haptics1 ); + + //Open actuator + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + // wait for the callback to be called + iWait.Start(); + + // check actuator state (since execution of this method continues, the state + // has been updated in the callback) + TEST_ASSERT_DESC( (callback1.Status(EHWRMLogicalActuatorAny) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator state received!" ); + + // create 2nd haptics client with actuator observer + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, &callback2 ); + CleanupStack::PushL( haptics2 ); + + //Open actuator + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + + // wait for the callback to be called + iWait.Start(); + + // check actuator state (since execution of this method continues, the state + // has been updated in the callback) + TEST_ASSERT_DESC( (callback2.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator state received!" ); + + + // cleanup + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } + + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +TInt CHapticsClientTest::T_ObserveActuatorStatusAndHapticsStatus() + { + // Create 3 actuator status observers. + TActuatorStatusCallback actuatorCallback1( this ); + TActuatorStatusCallback actuatorCallback2( this ); + TActuatorStatusCallback actuatorCallback3( this ); + + // Create 3 haptics status observers. + THapticsStatusCallback hapticsCallback1( this ); + THapticsStatusCallback hapticsCallback2( this ); + THapticsStatusCallback hapticsCallback3( this ); + + // create 1st haptics client with observers + CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &hapticsCallback1, &actuatorCallback1 ); + CleanupStack::PushL( haptics1 ); + + //Open actuator + TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + + // wait for the haptics status callback to be called + iWait.Start(); + // wait for the actuator status callback to be called + iWait.Start(); + + // check actuator status (since execution of this method continues, the status + // has been updated in the callback) + TEST_ASSERT_DESC( (actuatorCallback1.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator status received!" ); + // check haptics status + TEST_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + haptics1->ReserveHapticsL(); + + + // create 2nd and 3rd haptics clients with observers + CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &hapticsCallback2, &actuatorCallback2 ); + CleanupStack::PushL( haptics2 ); + CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( &hapticsCallback3, &actuatorCallback3 ); + CleanupStack::PushL( haptics3 ); + + // reserve haptics for 2nd client + haptics2->ReserveHapticsL(); + + //Open actuator + TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" ); + + TRAP( err, haptics3->OpenActuatorL( EHWRMLogicalActuatorDevice ) ); + TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" ); + + // wait for the haptics status callback to be called + iWait.Start(); + iWait.Start(); + iWait.Start(); + // wait for the actuator status callback to be called + iWait.Start(); + iWait.Start(); + + // check haptics status (since execution of this method continues, the status + // has been updated in the callback) + TEST_ASSERT_DESC( ( hapticsCallback2.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), + "Invalid haptics status received!" ); + TEST_ASSERT_DESC( ( hapticsCallback3.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + // check actuator status + TEST_ASSERT_DESC( (actuatorCallback2.Status(EHWRMLogicalActuatorAny) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator status received!" ); + TEST_ASSERT_DESC( (actuatorCallback3.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled), + "Invalid actuator status received!" ); + + // release haptics + haptics1->ReleaseHaptics(); + + // wait for the haptics status callback to be called + iWait.Start(); + iWait.Start(); + + TEST_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), + "Invalid haptics status received!" ); + TEST_ASSERT_DESC( ( hapticsCallback2.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + + // release haptics + haptics2->ReleaseHaptics(); + + // wait for the haptics status callback to be called + iWait.Start(); + iWait.Start(); + + TEST_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + TEST_ASSERT_DESC( ( hapticsCallback3.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), + "Invalid haptics status received!" ); + + // cleanup + CleanupStack::PopAndDestroy( haptics3 ); + CleanupStack::PopAndDestroy( haptics2 ); + CleanupStack::PopAndDestroy( haptics1 ); + return KErrNone; + } diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/haptics_stif/src/hapticsclienttest_main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/haptics_stif/src/hapticsclienttest_main.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,161 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: ?Description +* +*/ + + + +// INCLUDE FILES +#include +#include "hapticsclienttest.h" + + +// EXTERNAL DATA STRUCTURES +//extern ?external_data; + +// EXTERNAL FUNCTION PROTOTYPES +//extern ?external_function( ?arg_type,?arg_type ); + +// CONSTANTS +//const ?type ?constant_var = ?constant; + +// MACROS +//#define ?macro ?macro_def + +// LOCAL CONSTANTS AND MACROS +//const ?type ?constant_var = ?constant; +//#define ?macro_name ?macro_def + +// MODULE DATA STRUCTURES +//enum ?declaration +//typedef ?declaration + +// LOCAL FUNCTION PROTOTYPES +//?type ?function_name( ?arg_type, ?arg_type ); + +// FORWARD DECLARATIONS +//class ?FORWARD_CLASSNAME; + +// ============================= LOCAL FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// ?function_name ?description. +// ?description +// Returns: ?value_1: ?description +// ?value_n: ?description_line1 +// ?description_line2 +// ----------------------------------------------------------------------------- +// +/* +?type ?function_name( + ?arg_type arg, // ?description + ?arg_type arg) // ?description + { + + ?code // ?comment + + // ?comment + ?code + } +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// CHapticsClientTest::CHapticsClientTest +// C++ default constructor can NOT contain any code, that +// might leave. +// ----------------------------------------------------------------------------- +// +CHapticsClientTest::CHapticsClientTest( + CTestModuleIf& aTestModuleIf ): + CScriptBase( aTestModuleIf ) + { + } + +// ----------------------------------------------------------------------------- +// CHapticsClientTest::ConstructL +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void CHapticsClientTest::ConstructL() + { + iLog = CStifLogger::NewL( KHapticsClientTestLogPath, + KHapticsClientTestLogFile, + CStifLogger::ETxt, + CStifLogger::EFile, + EFalse ); + BuildL (); + } + +// ----------------------------------------------------------------------------- +// CHapticsClientTest::NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CHapticsClientTest* CHapticsClientTest::NewL( + CTestModuleIf& aTestModuleIf ) + { + CHapticsClientTest* self = new (ELeave) CHapticsClientTest( aTestModuleIf ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + + } + +// Destructor +CHapticsClientTest::~CHapticsClientTest() + { + + // Delete resources allocated from test methods + Delete(); + + // Delete logger + delete iLog; + + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point. +// Returns: CScriptBase: New CScriptBase derived object +// ----------------------------------------------------------------------------- +// +EXPORT_C CHapticsClientTest* LibEntryL( + CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework + { + CHapticsClientTest* libEntry ( CHapticsClientTest::NewL( aTestModuleIf ) ); + return libEntry; + } + +// ----------------------------------------------------------------------------- +// E32Dll is a DLL entry point function. +// Returns: KErrNone +// ----------------------------------------------------------------------------- +// +#ifndef EKA2 // Hide Dll entry point to EKA2 +GLDEF_C TInt E32Dll( + TDllReason /*aReason*/) // Reason code + { + return(KErrNone); + + } +#endif // EKA2 + +// End of File diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/data/2001CB6D.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/data/2001CB6D.rss Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2001 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics (adaptation) test plugins ECom resource file +* +*/ + + +#include + +// Declares info for implementations +RESOURCE REGISTRY_INFO SA_HAPTICS_ADAPTATION + { + resource_format_version = RESOURCE_FORMAT_VERSION_2; + dll_uid = 0x2001CB6D; //Haptics adaptation DLL + interfaces = + { + INTERFACE_INFO + { + interface_uid = 0x2001CBE4; //KCHWRMHapticsPluginServiceInterfaceUid + implementations = + { + // Haptics adaptation implementation + IMPLEMENTATION_INFO + { + implementation_uid = 0x2001CB6E; // Haptics Adaptation Plugin Implementation UID + version_no = 1; + display_name = "Haptics Test plugin"; + default_data = "EHWRMLogicalActuatorAny||EHWRMLogicalActuatorDevice"; + opaque_data = ""; + rom_only = 0; + } + }; + } + }; + } + +// End of File + + + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/data/hwrmhapticspolicy.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/data/hwrmhapticspolicy.ini Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,4 @@ +// This is product specific policy file for lights. +// Products need to include this in builds, +// if required. +// This empty file is exported by hwrmstubplugins diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/data/stubresponse.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/data/stubresponse.txt Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,53 @@ +[VIBEPKT_CMD_OPENDEVICE] "12000002000130" +[VIBEPKT_CMD_SETDEVICEPROPERTY] "1000000000000003" +[VIBEPKT_CMD_PLAYMAGSWEEPEFFECT] "1C0000000330F4" +[VIBEPKT_CMD_CLOSEDEVICE] "130000" +[VIBEPKT_CMD_DEVICE_COUNT] "150000" + +[VIBEPKT_CMD_GETDEVICEPROPERTY_INTEGER] "11000001000000010401000000" +[VIBEPKT_CMD_GETDEVICEPROPERTY_STRING] "1100000000000003205354554253545542535455425354554253545542535455425354554253545542" +[VIBEPKT_CMD_GETDEVICEPROPERTY_BOOL] "11000002000000020101" + +[VIBEPKT_CMD_GETDEVICESTATE] "0D000010000000" + +[VIBEPKT_CMD_GETDEVICECAPABILITIES_INTEGER] "09000001000000010401000000" +[VIBEPKT_CMD_GETDEVICECAPABILITIES_STRING] "0900000A000000030453545542" + +[VIBEPKT_CMD_PLAYPERIODICEFFECT] "1D0000000230D0" +[VIBEPKT_CMD_PLAYIVTEFFECT_INCLUDEIVTDATA] "04000010000000" +[VIBEPKT_CMD_PLAYIVTEFFECT_NOIVTDATA] "05000010000000" + +[VIBEPKT_CMD_STOPEFFECT] "070000" +[VIBEPKT_CMD_STOPALLEFFECTS] "080000" + +[VIBEPKT_CMD_PLAYSTREAMINGSAMPLE] "160000" +[VIBEPKT_CMD_CREATESTREAMINGEFFECT] "17000010000000" +[VIBEPKT_CMD_DESTROYSTREAMINGEFFECT] "180000" +[VIBEPKT_CMD_MODIFYPLAYINGMAGSWEEPEFFECT] "1E0000" +[VIBEPKT_CMD_MODIFYPLAYINGPERIODICEFFECT] "1F0000" +[VIBEPKT_CMD_PAUSEPLAYINGEFFECT] "190000" +[VIBEPKT_CMD_RESUMEPAUSEDEFFECT] "1A0000" + +[VIBEPKT_CMD_GETEFFECTSTATE_NOTPLAYING] "1B000000" +[VIBEPKT_CMD_GETEFFECTSTATE_PLAYING] "1B000001" +[VIBEPKT_CMD_GETEFFECTSTATE_PAUSED] "1B000002" +[VIBEPKT_CMD_SETKERNELPARAMETER] "0E00001001" +[VIBEPKT_CMD_GETKERNELPARAMETER] "0F00001001BB1C" + +[VIBEPKT_CMD_STATUSCASESUCCESS] "05000010000000" +[VIBEPKT_CMD_STATUSCASEALREADYINIT] "0500FF10000000" +[VIBEPKT_CMD_STATUSCASENOTINIT] "0500FE10000000" +[VIBEPKT_CMD_STATUSCASEINVALIDARG] "0500FD10000000" +[VIBEPKT_CMD_STATUSCASEFAIL] "0500FC10000000" +[VIBEPKT_CMD_STATUSCASEINCOMPEFFTYPE] "0500FB10000000" +[VIBEPKT_CMD_STATUSCASEINCOMPCAPATYPE] "0500FA10000000" +[VIBEPKT_CMD_STATUSCASEINCOMPPROPTYPE] "0500F910000000" +[VIBEPKT_CMD_STATUSCASEDEVNEEDSLICENSE] "0500F810000000" +[VIBEPKT_CMD_STATUSCASENOTENOUGHMEM] "0500F710000000" +[VIBEPKT_CMD_STATUSCASESRVNOTRUNNING] "0500F610000000" +[VIBEPKT_CMD_STATUSCASEERRINSUFFPRIORITY] "0500F510000000" +[VIBEPKT_CMD_STATUSCASESRVBUSY] "0500F410000000" +[VIBEPKT_CMD_STATUSCASEWRNNOTPLAYING] "05000110000000" +[VIBEPKT_CMD_STATUSCASEWRNINSUFFPRIORITY] "05000210000000" + +[VIBEPKT_CMD_SETLICENSE] "1000000000000003" diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics adaptation test plugins bld file +* +*/ + + +#include + +PRJ_PLATFORMS +DEFAULT + +PRJ_EXPORTS +../data/stubresponse.txt /epoc32/winscw/c/system/Apps/Haptics/stubresponse.txt +../data/stubresponse.txt /epoc32/data/z/system/Apps/Haptics/stubresponse.txt +../rom/hapticsadaptation.iby /epoc32/rom/include/hapticsadaptation.iby + +PRJ_MMPFILES +../group/hwrmhapticstestplugins.mmp + + +// End of File diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/group/hwrmhapticstestplugins.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/group/hwrmhapticstestplugins.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics test (adaptation) plugin project definition file +* +*/ + + +#include + +TARGET hapticsadaptation.dll +TARGETTYPE PLUGIN + +UID 0x10009D8D 0x2001CB6D + +VENDORID VID_DEFAULT + +CAPABILITY CAP_ECOM_PLUGIN + +SOURCEPATH ../src +SOURCE proxy.cpp +SOURCE hwrmhapticstestplugin.cpp +SOURCE plugintimer.cpp + +START RESOURCE ../data/2001CB6D.rss +TARGET hapticsadaptation.rsc +END + +USERINCLUDE ../inc +USERINCLUDE ../../../hapticspacketizer/plugins/hapticsvibepacketizerplugin/inc +USERINCLUDE ../../../inc + +OS_LAYER_SYSTEMINCLUDE +OS_LAYER_LIBC_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY ecom.lib +LIBRARY efsrv.lib +LIBRARY flogger.lib +LIBRARY estor.lib +LIBRARY eikcore.lib +LIBRARY cone.lib +LIBRARY hwrmhapticspluginservice.lib + +LANG SC + +// Test macro +// MACRO ENABLE_NOTIFICATIONS // Uncomment during testing to receive periodic notifications +MACRO PUBLISH_STATE_INFO // Uncomment before running HWRM module tests to get proper results + +SMPSAFE diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/inc/hwrmhapticstestplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/inc/hwrmhapticstestplugin.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,260 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics test (adaptation) plugin header file. +* +*/ + + +#ifndef __HWRMHAPTICSTESTPLUGIN_H_ +#define __HWRMHAPTICSTESTPLUGIN_H_ + +#include +#include +#include +#include "PluginTimer.h" +#include "hwrmhapticsvibepackets.h" + +#ifdef PUBLISH_STATE_INFO +#include +const TUid KPSUidHWResourceNotification = { 0x101F7A04 }; // HWRM private PS Uid +const TUint32 KHWRMTestHapticsCommand = 0x11110001; +const TUint32 KHWRMTestHapticsDataPckg = 0x11110002; +const TUint32 KHWRMTestVibCmdData = 0x11110003; +#endif // PUBLISH_STATE_INFO + +#ifdef __WINS__ + _LIT( KStubResponseFile, "C:\\system\\apps\\haptics\\stubresponse.txt" ); +#else + _LIT( KStubResponseFile, "Z:\\system\\apps\\haptics\\stubresponse.txt" ); +#endif + +_LIT8( KVibraCmdInitialize, "VIBEPKT_CMD_INITIALIZE" ); +_LIT8( KVibraCmdOpenDevice, "VIBEPKT_CMD_OPENDEVICE" ); +_LIT8( KVibraCmdSetDeviceProperty, "VIBEPKT_CMD_SETDEVICEPROPERTY" ); +_LIT8( KVibraCmdPlayMagSweepEffect, "VIBEPKT_CMD_PLAYMAGSWEEPEFFECT" ); +_LIT8( KVibraCmdCloseDevice, "VIBEPKT_CMD_CLOSEDEVICE" ); +_LIT8( KVibraCmdDeviceCount, "VIBEPKT_CMD_DEVICE_COUNT" ); +_LIT8( KVibraCmdGetDeviceProperty, "VIBEPKT_CMD_GETDEVICEPROPERTY" ); +_LIT8( KVibraCmdGetDevicePropertyInteger, "VIBEPKT_CMD_GETDEVICEPROPERTY_INTEGER" ); +_LIT8( KVibraCmdGetDevicePropertyString, "VIBEPKT_CMD_GETDEVICEPROPERTY_STRING" ); +_LIT8( KVibraCmdGetDevicePropertyBool, "VIBEPKT_CMD_GETDEVICEPROPERTY_BOOL" ); +_LIT8( KVibraCmdGetDeviceState, "VIBEPKT_CMD_GETDEVICESTATE" ); +_LIT8( KVibraCmdGetDeviceCapabilities, "VIBEPKT_CMD_GETDEVICECAPABILITIES" ); +_LIT8( KVibraCmdGetDeviceCapabilitiesInteger, "VIBEPKT_CMD_GETDEVICECAPABILITIES_INTEGER" ); +_LIT8( KVibraCmdGetDeviceCapabilitiesString, "VIBEPKT_CMD_GETDEVICECAPABILITIES_STRING" ); +_LIT8( KVibraCmdPlayPeriodicEffect, "VIBEPKT_CMD_PLAYPERIODICEFFECT" ); +_LIT8( KVibraCmdPlayIVTEffectIncludeIVTData, "VIBEPKT_CMD_PLAYIVTEFFECT_INCLUDEIVTDATA" ); +_LIT8( KVibraCmdPlayIVTEffectNoIVTData, "VIBEPKT_CMD_PLAYIVTEFFECT_NOIVTDATA" ); +_LIT8( KVibraCmdStopEffect, "VIBEPKT_CMD_STOPEFFECT" ); +_LIT8( KVibraCmdStopAllEffects, "VIBEPKT_CMD_STOPALLEFFECTS" ); +_LIT8( KVibraCmdPlayStreamingSample, "VIBEPKT_CMD_PLAYSTREAMINGSAMPLE" ); +_LIT8( KVibraCmdCreateStreamingEffect, "VIBEPKT_CMD_CREATESTREAMINGEFFECT" ); +_LIT8( KVibraCmdDestroyStreamingEffect, "VIBEPKT_CMD_DESTROYSTREAMINGEFFECT" ); +_LIT8( KVibraCmdModifyPlayingMagSweepEffect, "VIBEPKT_CMD_MODIFYPLAYINGMAGSWEEPEFFECT" ); +_LIT8( KVibraCmdModifyPlayingPeriodicEffect, "VIBEPKT_CMD_MODIFYPLAYINGPERIODICEFFECT" ); +_LIT8( KVibraCmdPausePlayingEffect, "VIBEPKT_CMD_PAUSEPLAYINGEFFECT" ); +_LIT8( KVibraCmdResumePausedEffect, "VIBEPKT_CMD_RESUMEPAUSEDEFFECT" ); +_LIT8( KVibraCmdGetEffectStateNotPlaying, "VIBEPKT_CMD_GETEFFECTSTATE_NOTPLAYING" ); +_LIT8( KVibraCmdGetEffectStatePlaying, "VIBEPKT_CMD_GETEFFECTSTATE_PLAYING" ); +_LIT8( KVibraCmdGetEffectStatePaused, "VIBEPKT_CMD_GETEFFECTSTATE_PAUSED" ); +_LIT8( KVibraCmdSetKernelParameter, "VIBEPKT_CMD_SETKERNELPARAMETER" ); +_LIT8( KVibraCmdGetKernelParameter, "VIBEPKT_CMD_GETKERNELPARAMETER" ); +_LIT8( KVibraCmdSetLicense, "VIBEPKT_CMD_SETLICENSE" ); + +// for vibe status to S60 status cases.. +_LIT8(KVibraCmdStatusCaseSuccess, "VIBEPKT_CMD_STATUSCASESUCCESS"); +_LIT8(KVibraCmdStatusCaseAlreadyInit, "VIBEPKT_CMD_STATUSCASEALREADYINIT"); +_LIT8(KVibraCmdStatusCaseNotInit, "VIBEPKT_CMD_STATUSCASENOTINIT"); +_LIT8(KVibraCmdStatusCaseInvalidArg, "VIBEPKT_CMD_STATUSCASEINVALIDARG"); +_LIT8(KVibraCmdStatusCaseFail, "VIBEPKT_CMD_STATUSCASEFAIL"); +_LIT8(KVibraCmdStatusCaseIncompEffType, "VIBEPKT_CMD_STATUSCASEINCOMPEFFTYPE"); +_LIT8(KVibraCmdStatusCaseIncompCapaType, "VIBEPKT_CMD_STATUSCASEINCOMPCAPATYPE"); +_LIT8(KVibraCmdStatusCaseIncompPropType, "VIBEPKT_CMD_STATUSCASEINCOMPPROPTYPE"); +_LIT8(KVibraCmdStatusCaseDevNeedsLicense, "VIBEPKT_CMD_STATUSCASEDEVNEEDSLICENSE"); +_LIT8(KVibraCmdStatusCaseNotEnoughMem, "VIBEPKT_CMD_STATUSCASENOTENOUGHMEM"); +_LIT8(KVibraCmdStatusCaseSrvNotRunning, "VIBEPKT_CMD_STATUSCASESRVNOTRUNNING"); +_LIT8(KVibraCmdStatusCaseErrInsuffPriority, "VIBEPKT_CMD_STATUSCASEERRINSUFFPRIORITY"); +_LIT8(KVibraCmdStatusCaseSrvBusy, "VIBEPKT_CMD_STATUSCASESRVBUSY"); +_LIT8(KVibraCmdStatusCaseWrnNotPlaying, "VIBEPKT_CMD_STATUSCASEWRNNOTPLAYING"); +_LIT8(KVibraCmdStatusCaseWrnInsuffPriority, "VIBEPKT_CMD_STATUSCASEWRNINSUFFPRIORITY"); + +const TInt KRespFileData = 3000; +const TInt KHexRespCode = 100; +const TInt KBinRespCode = 100; +const TInt KTimeOut = 500; + +class CPluginTimer; + +/** + * Haptics test plugin. + * Test implementation that handles reception and responding to + * haptics commands in adaptation layer in semi-hardcoded manner. + * (Where semi-hardcoded means that responses are chosen, based on + * the current state of the test stub, from a file containing hardcoded + * response alternatives. + * + * @since S60 5.1 + */ +class CHWRMHapticsTestPlugin : public CHWRMHapticsPluginService, + public MPluginTimerCallback + { +public: + /** + * Static method for instantiating test plugin objects. + * Uses two-phase construction. + * + * @param aCallback Callback to haptics subsystem. + */ + static CHWRMHapticsTestPlugin* NewL( MHWRMHapticsPluginCallback* aCallback ); + + /** + * Destructor + */ + virtual ~CHWRMHapticsTestPlugin(); + + /** + * Method to invoke a particular command in the plugin. + * Implements the CHWRMHapticsPluginService::ProcessCommandL + * abstract interface method. + * + * @param aCommandId Command ID + * @param aTransId Transaction ID + * @param aData Data associated with command + */ + virtual void ProcessCommandL( TInt aCommandId, + TUint8 aTransId, + TDesC8& aData ); + + /** + * Method to cancel a particular command. + * Implements the CHWRMHapticsPluginService::CancelCommandL + * abstract interface method. + * + * @param aTransId Transaction ID + * @param aCommandId Command ID to optionally double check with the + * transaction ID + */ + virtual void CancelCommandL( TUint8 aTransId, + TInt aCommandId ); + + /** + * The callback method that is called from CPluginTimer when timer + * has expired. + * This method basically does all the processing needed to return a + * (emulated) response to a Haptics command. + * + * @param aService Pointer to the implementation of + * MHWRMHapticsPluginCallback callback + * interface whose ProcessResponseL is called + * with (Haptics command's emulated) response + * data. + * @param aCommandId Id of the (emulated) Haptics command. + * @param aTransId Id of the transaction to which the (emulated) + * haptics command belongs to. + * @param aRetVal Return value to be inserted to the response + * of the (emulated) Haptics command. + */ + void GenericTimerFired(MHWRMHapticsPluginCallback* aService, + TInt aCommandId, + TUint8 aTransId, + TInt aRetVal); + /** + * Static method to convert hex string to binary format + * + * @param aSrcBuffer Reference to a descriptor containing the hex buffer. + * @param aDstBuffer Reference to a descriptor containing the buffer + * to which binary data is written. + */ + static void Hex2Bin(const TDesC8& aSrcBuffer, TDes8& aDstBuffer); + + /** + * Method that gets the hex data string from file buffer and converts it to binary format. + * + * @param aCmdPosition Command position in the file data. The command position + * is calculated in GenericTimerFired method based on + * emulated Haptics command's command Id + * @param aRetvalPackage Reference to a descriptor containing the buffer + * to which binary data is written. + */ + void CHWRMHapticsTestPlugin::GetBinRespCode(TInt aCmdPosition, TDes8& aRetvalPackage); + +private: + + /** + * Constructor. + * + * @param aCallback Callback to haptics subsystem. + */ + CHWRMHapticsTestPlugin( MHWRMHapticsPluginCallback* aCallback ); + + /** + * Two-phase construction ConstructL + */ + void ConstructL(); + + +private: // data + + /** + * Array of pointers to running CPluginTimer timer objects + */ + RPointerArray iTimers; + + /** + * File data buffer + */ + TBuf8 iFileData; + + /** + * Emulated haptics command's response data + */ + HWRMHapticsCommand::RHWRMHapticsRespData iStorage; + + /** + * Emulated haptics command (stored as a VibeTonz packet pointer) + */ + TVibePacket* iVibeCmdPacket; + + /** + * Effect state. Used to distinguish (in an emulated way) different + * states of effect ("Playing","Paused","Not playing"). + */ + enum TEffectState + { + ENotPlaying = 0, + EPlaying, + EPaused + }; + TEffectState iEffectState; + +#ifdef PUBLISH_STATE_INFO + + /** + * P&S property for publishing (emulated) Haptics command's command Id + */ + RProperty iCmdProperty; + + /** + * P&S property for publishing (emulated) Haptics command's data + */ + RProperty iDataProperty; + + /** + * P&S property for publishing (emulated) Haptics command's Vibe command code + */ + RProperty iVibeCmdProperty; +#endif // PUBLISH_STATE_INFO + }; + +#endif // __HWRMHAPTICSDPLUGIN_H_ diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/inc/plugintimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/inc/plugintimer.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,180 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics test (adaptation) plugin timer header file +* +*/ + + + +#ifndef __HWRMHAPTICSTESTPLUGINTIMER_H_ +#define __HWRMHAPTICSTESTPLUGINTIMER_H_ + +#include + +/** + * An interface for handling timer expiration events. + * + * @since S60 5.1 + */ +class MPluginTimerCallback + { +public: + /** + * Method that is called when the timer expires. + * Must be implemented by classes that support this interface. + * + * @param aService Pointer to an object that implements + * the MHWRMHapticsPluginCallback interface + * and thus handles the callbacks from this + * test plugin. In practice this is pointer + * to the Haptics plugin manager object. + * @param aCommandId ID of the command that was being executed + * (or actually emulated as being executed) + * at the time the timer expired. + * @param aTransId Transaction ID of the command that was being executed + * (or actually emulated as being executed) + * at the time the timer expired. + * @param aRetVal (Emulated) return value of the command that was + * being executed (or actually emulated as being executed) + * at the time the timer expired. + */ + virtual void GenericTimerFired( MHWRMHapticsPluginCallback* aService, + TInt aCommandId, + TUint8 aTransId, + TInt aRetVal ) = 0; + }; + + +/** + * Timer class that triggers command execution emulation. (This test + * stub emulates the real adaptation layer haptics command execution + * and the emulation "round" is triggered from this class). + * + * @since S60 5.1 + */ +class CPluginTimer : public CTimer + { +public: + /** + * Static method for instantiation. + * The instantiation also adds the instance to active scheduler and + * triggers start of the (embedded CTimer) timer. + * + * @param aInterval Timeout value for command execution emulation. + * @param aService Pointer to the object that handles the responses + * from command execution emulation. I.e., pointer + * to an object outside the test stub plugin that + * handles responses from all kinds of haptics plugins. + * In practice this is the Haptics plugin manager. + * @param aCommandId Id of the command whose execution is emulated. + * @param aTransId Id of the transaction to which the emulated command + * belongs to. + * @param aRetVal Return value of the emulated command. + * @param aCallback Pointer to the object that further handles the + * command emulation (i.e., pointer to the actual test + * stub plugin object). + */ + static CPluginTimer* NewL( + const TTimeIntervalMicroSeconds32& aInterval, + MHWRMHapticsPluginCallback* aService, + TInt aCommandId, + TUint8 aTransId, + TInt aRetVal, + MPluginTimerCallback* aCallback); + + /** + * Destructor + */ + ~CPluginTimer(); + + /** + * RunL handles (embedded CTimer) timer expirations. + * + * @see CActive + * @see CTimer + */ + void RunL(); + + /** + * Getter for transaction Id + */ + TUint8 TransId() const; + +private: + /** + * Constructor + * + * @param aPriority + * @param aService Pointer to an object that implements + * the MHWRMHapticsPluginCallback interface + * and thus handles the callbacks from this + * whole test plugin. + * @param aCommandId Id of the command for which the timer-based + * command execution emulation is started. + * @param aTransId Transaction Id + * @param aRetVal + * @param aCallback Pointer to an object that implements the above + * declared MPluginTimerCallback interface. In + * practice this is the CHWRMHapticsTestPlugin + * object. + */ + CPluginTimer( TInt aPriority, + MHWRMHapticsPluginCallback* aService, + TInt aCommandId, + TUint8 aTransId, + TInt aRetVal, + MPluginTimerCallback* aCallback ); + + /** + * Two-phase construction. ConstructL is needed because parent + * class (CTimer) requires two-phase construction. + */ + void ConstructL(); + +private: // data + + /** + * Pointer to an object that handles responses from this + * test plugin (i.e., in practice the Haptics plugin manager). + */ + MHWRMHapticsPluginCallback* iService; // Not owned + + /** + * Id of the command whose execution is being emulated by + * the test plugin + */ + TInt iCommandId; + + /** + * Id of the transaction to which the command, whose execution + * is being emulated by the test plugin, belongs to + */ + TUint8 iTransId; + + /** + * Return value that the emulated command execution is to return. + */ + TInt iRetVal; + + /** + * Pointer to an object that further handles the timer expiries + * from this CPluginTimer object. + * I.e, pointer to the actual test plugin object + */ + MPluginTimerCallback* iCallback; // Not owned + + }; + + +#endif // __HWRMHAPTICSTESTPLUGINTIMER_H_ \ No newline at end of file diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/rom/hapticsadaptation.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/rom/hapticsadaptation.iby Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics adaptation test plugins IBY file. +* +*/ + + +#ifndef __HWRMHAPTICSTESTPLUGINS_IBY__ +#define __HWRMHAPTICSTESTPLUGINS_IBY__ + +ECOM_PLUGIN( hapticsadaptation.dll , 2001CB6D.rsc ) +data=EPOCROOT##epoc32\data\z\system\apps\haptics\stubresponse.txt system\apps\haptics\stubresponse.txt + + +#endif // __HWRMHAPTICSTESTPLUGINS_IBY__ + +// End of File diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/src/hwrmhapticstestplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/src/hwrmhapticstestplugin.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,691 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics adaptation test plugin implementation. +* +*/ + +#include +#include + +#include "hwrmhapticstestplugin.h" +#include "hwrmhapticstrace.h" +#include "hwrmhapticsvibeconstants.h" +#include "plugintimer.h" + +// ----------------------------------------------------------------------------- +// Enumeration for special test case in which it is tested that HapticsClient +// correctly converts VibeStatus codes to Symbian/S60 error codes. +// ----------------------------------------------------------------------------- +// +enum vibestatustests + { + SUCCESS_TEST = 100, + ALREADY_INITIALIZED_TEST, + NOT_INITIALIZED_TEST, + INVALID_ARGUMENT_TEST, + FAIL_TEST, + INCOMPATIBLE_EFFECT_TYPE_TEST, + INCOMPATIBLE_CAPABILITY_TYPE_TEST, + INCOMPATIBLE_PROPERTY_TYPE_TEST, + DEVICE_NEEDS_LICENSE_TEST, + NOT_ENOUGH_MEMORY_TEST, + SERVICE_NOT_RUNNING_TEST, + INSUFFICIENT_PRIORITY_TEST, + SERVICE_BUSY_TEST, + WRN_NOT_PLAYING_TEST, + WRN_INSUFFICIENT_PRIORITY_TEST + }; + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::NewL +// Static instantiation method. Allocates mem and constructs new test plugin object. +// ----------------------------------------------------------------------------- +// +CHWRMHapticsTestPlugin* CHWRMHapticsTestPlugin::NewL( + MHWRMHapticsPluginCallback* aCallback ) + { + COMPONENT_TRACE( ( _L("CHWRMHapticsTestPlugin::NewL()") ) ); + CHWRMHapticsTestPlugin* self = + new ( ELeave ) CHWRMHapticsTestPlugin( aCallback ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::~CHWRMHapticsTestPlugin +// Destructor +// ----------------------------------------------------------------------------- +// +CHWRMHapticsTestPlugin::~CHWRMHapticsTestPlugin() + { + COMPONENT_TRACE( ( _L("CHWRMHapticsTestPlugin::~CFmtxPlugin()") ) ); + + iStorage.Close(); + + iTimers.ResetAndDestroy(); + iVibeCmdPacket = NULL; + #ifdef PUBLISH_STATE_INFO + iCmdProperty.Close(); + iDataProperty.Close(); + iVibeCmdProperty.Close(); +#endif /* PUBLISH_STATE_INFO */ + } + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::CHWRMHapticsTestPlugin +// Constructor +// ----------------------------------------------------------------------------- +// +CHWRMHapticsTestPlugin::CHWRMHapticsTestPlugin( + MHWRMHapticsPluginCallback* aCallback ) + { + COMPONENT_TRACE( ( _L("CHWRMHapticsTestPlugin::CHWRMHapticsTestPlugin()") ) ); + iResponseCallback = aCallback; + } + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::ConstructL +// Two-phase construction ConstructL that can leave. +// ----------------------------------------------------------------------------- +// +void CHWRMHapticsTestPlugin::ConstructL() + { + COMPONENT_TRACE( ( _L("CHWRMHapticsTestPlugin::ConstructL") ) ); + + // Create response data buffer + iStorage.Create( KHWRMHapticsRespMaxSize ); + + // Read in response file contents + RFs fileServer; + User::LeaveIfError( fileServer.Connect() ); + + RFile file; + TInt err = file.Open( fileServer, KStubResponseFile, EFileRead ); + if( err !=KErrNone ) + COMPONENT_TRACE( _L("HWRM HapticsPlugin: Couldn't open file successfully") ); + + file.Read( iFileData ); + + file.Close(); + fileServer.Close(); + +#ifdef PUBLISH_STATE_INFO + RProperty::Define( KPSUidHWResourceNotification, KHWRMTestHapticsCommand, RProperty::EInt ); + RProperty::Define( KPSUidHWResourceNotification, KHWRMTestHapticsDataPckg, RProperty::EByteArray, 512 ); + RProperty::Define( KPSUidHWResourceNotification, KHWRMTestVibCmdData, RProperty::EInt ); + iCmdProperty.Attach( KPSUidHWResourceNotification, KHWRMTestHapticsCommand ); + iDataProperty.Attach( KPSUidHWResourceNotification, KHWRMTestHapticsDataPckg ); + iVibeCmdProperty.Attach( KPSUidHWResourceNotification, KHWRMTestVibCmdData ); +#endif /* PUBLISH_STATE_INFO */ + + // inform haptics of the plugin state + iResponseCallback->PluginEnabled( EHWRMLogicalActuatorAny, ETrue ); + iResponseCallback->PluginEnabled( EHWRMLogicalActuatorDevice, ETrue ); + } + + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::ProcessCommandL +// Implementation of CHWRMHapticsPluginService::ProcessCommandL. +// This method processes the haptics command in adaptation layer. In this test +// plugin simply a timer instance is created with the given data and later, after +// the timer expiry, the semi-hard-coded response is created in GenericTimerFired +// method below. +// ----------------------------------------------------------------------------- +// +void CHWRMHapticsTestPlugin::ProcessCommandL( TInt aCommandId, + TUint8 aTransId, + TDesC8& aData ) + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Processing command: 0x%x, TransId: 0x%x" ), aCommandId, aTransId ) ); + + TInt retVal( KErrNone ); + + switch ( aCommandId ) + { + case HWRMHapticsCommand::EHapticsCmdId : + { + COMPONENT_TRACE( _L("HWRM HapticsPlugin: Processed EHapticsCmdId") ); + } + break; + default : + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Unknown Command: 0x%x" ), aCommandId ) ); +#ifdef _DEBUG + User::Invariant(); // panic here to notice the problem early +#endif + } + break; + } + + + iVibeCmdPacket = reinterpret_cast( const_cast( aData.Ptr() ) ); + // check for NULL pointer + if ( NULL == iVibeCmdPacket ) + { + User::Leave( KErrBadDescriptor ); + } + + TInt timeout( KTimeOut ); + + _LIT8 ( KTestPluginMgrTransTimerExpires, "KTestPluginMgrTransTimerExpires" ); + if ( aData.FindF ( KTestPluginMgrTransTimerExpires ) != KErrNotFound ) + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: set the timeout that is more than plug-in manager transaction generic timer time-out period") ) ); + // set the timeout that is more than plug-in manager transaction generic timer time-out period i.e. > KDefaultPluginTimeout + timeout = 4000000; + } + +#ifdef PUBLISH_STATE_INFO + // publish + iCmdProperty.Set( aCommandId ); + iDataProperty.Set( aData ); + iVibeCmdProperty.Set( iVibeCmdPacket->iSimpleRsp.iCmdCode ); +#endif /* PUBLISH_STATE_INFO */ + + // create new timer and append it to the timer (pointer) array + CPluginTimer* timer = CPluginTimer::NewL( timeout, iResponseCallback, aCommandId, aTransId, retVal, this ); + CleanupStack::PushL( timer ); + iTimers.AppendL( timer ); + CleanupStack::Pop( timer ); + + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Processing command - return") ) ); + } + + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::CancelCommandL +// Implementation of CHWRMHapticsPluginService::CancelCommandL. +// Method for cancelling ongoing (emulated) command execution. In practice +// removes the timer that was started in order to emulate the given command. +// ----------------------------------------------------------------------------- +// +void CHWRMHapticsTestPlugin::CancelCommandL( + TUint8 aTransId, + TInt /*aCommandId*/ ) + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Cancelling command - iTimers.Count(): %d " ), iTimers.Count() ) ); + + for( TInt i = 0; i < iTimers.Count(); i++ ) + { + if ( iTimers[i]->TransId() == aTransId ) + { + delete iTimers[i]; + iTimers.Remove( i ); + break; + } + } + } + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::GenericTimerFired +// Callback method that is called from the CPluginTimer after timer expiry. +// This method emulates reception of response from the ISA layer to a haptics +// command. The actual response is read from a file, converted to binary and +// then the Haptics plugin manager's callback method (ProcessResponseL) is +// called with that binary data. +// ----------------------------------------------------------------------------- +// +void CHWRMHapticsTestPlugin::GenericTimerFired( + MHWRMHapticsPluginCallback* aService, + TInt aCommandId, + TUint8 aTransId, + TInt aRetVal ) + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: GenericTimerFired (0x%x, 0x%x, %d)" ), aCommandId, aTransId, aRetVal ) ); + + __ASSERT_ALWAYS( aService != NULL, User::Invariant() ); + + TInt err = KErrNone; + TBuf8 binRespData; + if ( NULL != iVibeCmdPacket ) + { + TBool jumpCases = EFalse; + + // Special case for vibeStatus to S60 err code manipulations: + if ( iVibeCmdPacket->iSimpleRsp.iCmdCode == KVibeCmdPlayIVTEffectNoData ) + { + TVibePacketPlayIVTEffectRequest* playReq = reinterpret_cast( iVibeCmdPacket ); + if ( playReq ) + { + jumpCases = ETrue; + + // the repeat value is used to indicate which sub-case is ongoing.. + // values between 100...114 are treated as special values. + switch ( playReq->iRepeat ) + { + case SUCCESS_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_S_SUCCESS") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseSuccess ), binRespData ); + break; + } + case ALREADY_INITIALIZED_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_ALREADY_INITIALIZED") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseAlreadyInit ), binRespData ); + break; + } + case NOT_INITIALIZED_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_NOT_INITIALIZED") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseNotInit ), binRespData ); + break; + } + case INVALID_ARGUMENT_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_INVALID_ARGUMENT") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseInvalidArg ), binRespData ); + break; + } + case FAIL_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_FAIL") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseFail ), binRespData ); + break; + } + case INCOMPATIBLE_EFFECT_TYPE_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_INCOMPATIBLE_EFFECT_TYPE") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseIncompEffType ), binRespData ); + break; + } + case INCOMPATIBLE_CAPABILITY_TYPE_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_INCOMPATIBLE_CAPABILITY_TYPE") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseIncompCapaType ), binRespData ); + break; + } + case INCOMPATIBLE_PROPERTY_TYPE_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_INCOMPATIBLE_PROPERTY_TYPE") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseIncompPropType ), binRespData ); + break; + } + case DEVICE_NEEDS_LICENSE_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_DEVICE_NEEDS_LICENSE") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseDevNeedsLicense ), binRespData ); + break; + } + case NOT_ENOUGH_MEMORY_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_NOT_ENOUGH_MEMORY") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseNotEnoughMem ), binRespData ); + break; + } + case SERVICE_NOT_RUNNING_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_SERVICE_NOT_RUNNING") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseSrvNotRunning ), binRespData ); + break; + } + case INSUFFICIENT_PRIORITY_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_INSUFFICIENT_PRIORITY") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseErrInsuffPriority ), binRespData ); + break; + } + case SERVICE_BUSY_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_E_SERVICE_BUSY") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseSrvBusy ), binRespData ); + break; + } + case WRN_NOT_PLAYING_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_W_NOT_PLAYING") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseWrnNotPlaying ), binRespData ); + break; + } + case WRN_INSUFFICIENT_PRIORITY_TEST: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: Returning status VIBE_W_INSUFFICIENT_PRIORITY") ) ); + this->GetBinRespCode( iFileData.Find( KVibraCmdStatusCaseWrnInsuffPriority ), binRespData ); + break; + } + default: + { + jumpCases = EFalse; + break; + } + } + if ( jumpCases ) + { + iEffectState = ENotPlaying; + } + } + } + + if ( !jumpCases ) + { + // Other cases.. + switch( iVibeCmdPacket->iSimpleRsp.iCmdCode ) + { + + case KVibeCmdInitialize: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_INITIALIZE command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdInitialize ); + iEffectState = ENotPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdOpenDevice: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_OPENDEVICE command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdOpenDevice ); + iEffectState = ENotPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdSetDeviceProperty: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_SETDEVICEPROPERTY command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdSetDeviceProperty ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdPlayMagSweepEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_PLAYMAGSWEEPEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdPlayMagSweepEffect ); + iEffectState = EPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdCloseDevice: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_CLOSEDEVICE command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdCloseDevice ); + iEffectState = ENotPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdDeviceCount: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_DEVICE_COUNT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdDeviceCount ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdGetDeviceProperty: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_GETDEVICEPROPERTY command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = 0; + switch (iVibeCmdPacket->iGetDevicePropertyReq.iPropertyValueType) + { + case KVibeValuetypeInt32: + pos = iFileData.Find( KVibraCmdGetDevicePropertyInteger ); + break; + case KVibeValuetypeString: + pos = iFileData.Find( KVibraCmdGetDevicePropertyString ); + break; + case KVibeValuetypeBool: + pos = iFileData.Find( KVibraCmdGetDevicePropertyBool ); + break; + default: +#ifdef _DEBUG + User::Invariant(); // wrong value type +#endif + ; + } + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdGetDeviceState: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_GETDEVICESTATE command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdGetDeviceState ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdGetDeviceCapabilities: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_GETDEVICECAPABILITIES command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = 0; + switch (iVibeCmdPacket->iGetDeviceCapsReq.iCapabilityValueType) + { + case KVibeValuetypeInt32: + pos = iFileData.Find( KVibraCmdGetDeviceCapabilitiesInteger ); + break; + case KVibeValuetypeString: + pos = iFileData.Find( KVibraCmdGetDeviceCapabilitiesString ); + break; + default: +#ifdef _DEBUG + User::Invariant(); // wrong value type +#endif + ; + } + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdPlayPeriodicEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_PLAYPERIODICEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdPlayPeriodicEffect ); + iEffectState = EPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdPlayIVTEffectIncludeData: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_PLAYIVTEFFECT_INCLUDEIVTDATA command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdPlayIVTEffectIncludeIVTData ); + iEffectState = EPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdPlayIVTEffectNoData: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_PLAYIVTEFFECT_NOIVTDATA command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdPlayIVTEffectNoIVTData ); + iEffectState = EPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdStopEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_STOPEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdStopEffect ); + iEffectState = ENotPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdStopAllEffects: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_STOPALLEFFECTS command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdStopAllEffects ); + iEffectState = ENotPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdPlayStreamingSample: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_PLAYSTREAMINGSAMPLE command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdPlayStreamingSample ); + iEffectState = EPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + + case KVibeCmdCreateStreamingEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_CREATESTREAMINGEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdCreateStreamingEffect ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdDestroyStreamingEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_DESTROYSTREAMINGEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdDestroyStreamingEffect ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdModifyPlayingMagSweepEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_MODIFYPLAYINGMAGSWEEPEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdModifyPlayingMagSweepEffect ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdModifyPlayingPeriodicEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_MODIFYPLAYINGPERIODICEFFECT: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdModifyPlayingPeriodicEffect ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdPausePlayingEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_PAUSEPLAYINGEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdPausePlayingEffect ); + iEffectState = EPaused; + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdResumePausedEffect: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_RESUMEPAUSEDEFFECT command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdResumePausedEffect ); + iEffectState = EPlaying; + this->GetBinRespCode( pos, binRespData ); + break; + } + + case KVibeCmdGetEffectState: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_GETEFFECTSTATE command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos; + if ( iEffectState == ENotPlaying ) + { + pos = iFileData.Find( KVibraCmdGetEffectStateNotPlaying ); + } + else if ( iEffectState == EPlaying ) + { + pos = iFileData.Find( KVibraCmdGetEffectStatePlaying ); + } + else + { + pos = iFileData.Find( KVibraCmdGetEffectStatePaused ); + } + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdSetKernelParameter: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_SETKERNELPARAMETER command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdSetKernelParameter ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdGetKernelParameter: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_GETKERNELPARAMETER command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdGetKernelParameter ); + this->GetBinRespCode( pos, binRespData ); + break; + } + case KVibeCmdSetLicense: + { + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: VIBEPKT_CMD_SETLICENSE command: 0x%x" ), iVibeCmdPacket->iSimpleRsp.iCmdCode ) ); + TInt pos = iFileData.Find( KVibraCmdSetLicense ); + this->GetBinRespCode( pos, binRespData ); + break; + } + default: + { + // do panic --> packetized message not recognized + break; + } + }//switch + } + + CHWRMHapticsRespData* respData; + TInt32 errorCode( KErrNone ); + respData = CHWRMHapticsRespData::NewLC( errorCode, binRespData ); + RDesWriteStream writer( iStorage ); + CleanupClosePushL( writer ); + // write to resp data + writer << *respData; + // remove from stack , it will commit the actual data to the stoarage. + CleanupStack::PopAndDestroy( &writer ); + CleanupStack::PopAndDestroy( respData ); + + } // if block end for pRsp check + + + TRAP( err, aService->ProcessResponseL( aCommandId, aTransId, iStorage ) ); + // delete obsolete timers + for( TInt i = ( iTimers.Count()-1 ); i > -1 ; i-- ) + { + if ( !iTimers[i]->IsActive() ) + { + delete iTimers[i]; + iTimers.Remove( i ); + COMPONENT_TRACE( ( _L("HWRM HapticsPlugin: GenericTimerFired - Removed obsolete timer") ) ); + } + } + } + + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::Hex2Bin +// Converts hexadecimal string given as first parameter to binary data that is +// stored to the object referenced by the second parameter. +// ----------------------------------------------------------------------------- +// +void CHWRMHapticsTestPlugin::Hex2Bin( const TDesC8& aSrcBuffer, TDes8& aDstBuffer ) + { + TInt len = aSrcBuffer.Length(); + aDstBuffer.SetLength( len >> 1 ); + for ( TInt n=0; n '9' ) ? aSrcBuffer[n] - 'A' + 10: aSrcBuffer[n] - '0' ); + TUint8 loNibble = ( (aSrcBuffer[n+1] > '9' ) ? aSrcBuffer[n+1] - 'A' + 10: aSrcBuffer[n+1] - '0' ); + + aDstBuffer[n>>1] = static_cast( ( ( hiNibble << 4 ) + loNibble ) ); + } + } + + +// ----------------------------------------------------------------------------- +// CHWRMHapticsTestPlugin::GetBinRespCode +// Helper method that gets the response data string from given position (line) +// of the (buffered in) response data file, and with the above Hex2Bin method +// converts the string into binary data that is then stored to the TDes8 object +// whose reference is given as second param (aBinRespData). +// ----------------------------------------------------------------------------- +// +void CHWRMHapticsTestPlugin::GetBinRespCode( TInt aCmdPosition, TDes8& aBinRespData ) + { + TBuf8 tempFileData; + TBuf8 hexRespCode; + + tempFileData.Copy( iFileData.Mid( aCmdPosition ) ); + TInt pos2 = tempFileData.Locate( '"' ); + TInt pos3 = tempFileData.Locate( '\r' ); + TInt respCodeLength = ( pos3-2 ) - pos2; + + hexRespCode.Copy( tempFileData.Mid( pos2+1, respCodeLength ) ); + + CHWRMHapticsTestPlugin::Hex2Bin( hexRespCode, aBinRespData ); + } + + + diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/src/plugintimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/src/plugintimer.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics test adaptation plugin timer implementation +* +*/ + + +#include "plugintimer.h" +#include +#include +#include "hwrmhapticstrace.h" + +// ----------------------------------------------------------------------------- +// CPluginTimer::NewL +// Instantiates a CPluginTimer object. +// Also adds the newly constructed object to active scheduler and starts the +// embedded CTimer through After() method call. +// ----------------------------------------------------------------------------- +// +CPluginTimer* CPluginTimer::NewL( + const TTimeIntervalMicroSeconds32& aInterval, + MHWRMHapticsPluginCallback* aService, + TInt aCommandId, + TUint8 aTransId, + TInt aRetVal, + MPluginTimerCallback* aCallback ) + { + CPluginTimer* self = new( ELeave ) CPluginTimer( 0, aService, aCommandId, aTransId, aRetVal, aCallback ); + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + + CActiveScheduler::Add( self ); + + COMPONENT_TRACE( (_L("HWRM Plugin - CPluginTimer::NewL - Setting timer: %d"), aInterval) ); + + self->After( aInterval ); + + return self; + } + +// ----------------------------------------------------------------------------- +// CPluginTimer::~CPluginTimer +// Destructor +// ----------------------------------------------------------------------------- +// +CPluginTimer::~CPluginTimer() + { + // PCLint demands + iCallback = NULL; + iService = NULL; + } + +// ----------------------------------------------------------------------------- +// CPluginTimer::CPluginTimer +// Constructor +// ----------------------------------------------------------------------------- +// +CPluginTimer::CPluginTimer( TInt aPriority, + MHWRMHapticsPluginCallback* aService, + TInt aCommandId, + TUint8 aTransId, + TInt aRetVal, + MPluginTimerCallback* aCallback ) + : CTimer( aPriority ), + iService( aService ), + iCommandId( aCommandId ), + iTransId( aTransId ), + iRetVal( aRetVal ), + iCallback( aCallback ) + { + // empty + } + +// ----------------------------------------------------------------------------- +// CPluginTimer::ConstructL +// Two-phase (leavable) construction method. Calls the parent class ConstructL. +// ----------------------------------------------------------------------------- +// +void CPluginTimer::ConstructL() + { + CTimer::ConstructL(); + } + +// ----------------------------------------------------------------------------- +// CPluginTimer::RunL +// Active scheduler calls RunL when timer expires. This in turn dispatches the +// further handling to the test stub object through MPluginTimerCallback interface. +// ----------------------------------------------------------------------------- +// +void CPluginTimer::RunL() + { + iCallback->GenericTimerFired( iService, iCommandId, iTransId, iRetVal ); + } + +// ----------------------------------------------------------------------------- +// CPluginTimer::TransId +// Getter method for transaction Id. +// ----------------------------------------------------------------------------- +// +TUint8 CPluginTimer::TransId() const + { + return iTransId; + } + +// End of files diff -r d38941471f1c -r cb32bcc88bad hwrmhaptics/tsrc/hapticstestplugins/src/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hwrmhaptics/tsrc/hapticstestplugins/src/proxy.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Symbian Foundation License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Haptics adaptation test plugin ECom implementation proxy definition file +* +*/ + + +#include +#include + +#include "hwrmhapticstestplugin.h" + +/** + * Mapping of the interface implementation UIDs to implementation factory functions + */ +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY( 0x2001CB6E, CHWRMHapticsTestPlugin::NewL ) + }; + +/** + * Exported proxy for instantiation method resolution. + */ +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) + { + aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); + return ImplementationTable; + } diff -r d38941471f1c -r cb32bcc88bad package_definition.xml --- a/package_definition.xml Wed Sep 29 15:13:21 2010 +0300 +++ b/package_definition.xml Fri Oct 08 14:33:25 2010 +0300 @@ -141,6 +141,9 @@ + + + diff -r d38941471f1c -r cb32bcc88bad resourcemgmt/hwresourcesmgr/server/src/HWRMVibraService.cpp --- a/resourcemgmt/hwresourcesmgr/server/src/HWRMVibraService.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/resourcemgmt/hwresourcesmgr/server/src/HWRMVibraService.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -522,10 +522,11 @@ CHWRMGenericTimer* timer = CHWRMGenericTimer::NewL(*this, iVibraCommonData.MaximumOnTime(), count ); iActiveTimerId = count; + CleanupStack::PushL( timer ); CPulseData* pulseData = CPulseData::NewL(*timer, iLastIntensity, aIntensity, iActiveTimerId ); CleanupStack::PushL( pulseData ); iPulseData.AppendL( pulseData ); - CleanupStack::Pop( pulseData ); + CleanupStack::Pop( 2, timer ); iPulseData[count]->Timer().Set(aDuration); } diff -r d38941471f1c -r cb32bcc88bad resourcemgmt/hwrmfmtxwatcherplugin/src/hwrmfmtxaccobserver.cpp --- a/resourcemgmt/hwrmfmtxwatcherplugin/src/hwrmfmtxaccobserver.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/resourcemgmt/hwrmfmtxwatcherplugin/src/hwrmfmtxaccobserver.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -17,7 +17,7 @@ // INCLUDE FILES -#include +#include #include "hwrmfmtxaccobserver.h" #include "trace.h" diff -r d38941471f1c -r cb32bcc88bad sensorservices/sensorserver/src/server/sensrvsession.cpp --- a/sensorservices/sensorserver/src/server/sensrvsession.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sensorservices/sensorserver/src/server/sensrvsession.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -53,9 +53,13 @@ CSensrvSession* self = new( ELeave ) CSensrvSession(aServer, aProxyManager, aSecureId); + CleanupStack::PushL(self); + self->ConstructL(); COMPONENT_TRACE( ( _L( "Sensor Server - CSensrvSession::NewL - return 0x%x" ), self ) ); + + CleanupStack::Pop(self); return self; } diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/ssmcmdlists/data/noncriticalcmdlist_hw.rss --- a/sysstatemgmt/ssmcmdlists/data/noncriticalcmdlist_hw.rss Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/ssmcmdlists/data/noncriticalcmdlist_hw.rss Fri Oct 08 14:33:25 2010 +0300 @@ -80,6 +80,8 @@ #ifdef FF_MOBILITY_MANAGEMENT_ERRORS ,r_cmd_item_nwnotifier #endif // FF_MOBILITY_MANAGEMENT_ERRORS + // prio 0x7EEA + ,r_cmd_logs //PMES-83ZD5M }; } @@ -129,7 +131,18 @@ timeout = 10000; background = 1; // To background } - + +// --------------------------------------------------------------------------- +// r_cmd_logs +// --------------------------------------------------------------------------- +// +RESOURCE SSM_START_PROCESS_INFO r_cmd_logs + { + priority = 0x7EEA; + name = "logs.exe"; + execution_behaviour = ESsmFireAndForget; + args = "-logsbootup"; + } // --------------------------------------------------------------------------- // r_cmd_provisioning diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/bwins/ssmcmn_graceful_shutdownu.def --- a/sysstatemgmt/systemstatemgr/cmn/bwins/ssmcmn_graceful_shutdownu.def Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/bwins/ssmcmn_graceful_shutdownu.def Fri Oct 08 14:33:25 2010 +0300 @@ -99,4 +99,13 @@ ?IsSsmGracefulOffline@@YAKXZ @ 98 NONAME ; unsigned long IsSsmGracefulOffline(void) ?KSsmGracefulOffline@@3KB @ 99 NONAME ; unsigned long const KSsmGracefulOffline ?KSsmInvalidSim@@3KB @ 100 NONAME ; unsigned long const KSsmInvalidSim + ?RequestStateNotificationCancel@CSsmStateAwareSession2@@QAEXXZ @ 101 NONAME ; void CSsmStateAwareSession2::RequestStateNotificationCancel(void) + ?AcknowledgeAndRequestStateNotification@CSsmStateAwareSession2@@QAEXH@Z @ 102 NONAME ; void CSsmStateAwareSession2::AcknowledgeAndRequestStateNotification(int) + ?GetState@CSsmStateAwareSession2@@QAE?AVTSsmState@@XZ @ 103 NONAME ; class TSsmState CSsmStateAwareSession2::GetState(void) + ?CancelDeferral@RSsmStateAwareSession@@QAEXXZ @ 104 NONAME ; void RSsmStateAwareSession::CancelDeferral(void) + ?NewL@CSsmStateAwareSession2@@SAPAV1@GAAVMStateChangeNotificationSubscriber2@@@Z @ 105 NONAME ; class CSsmStateAwareSession2 * CSsmStateAwareSession2::NewL(unsigned short, class MStateChangeNotificationSubscriber2 &) + ?DeferAcknowledgement@RSsmStateAwareSession@@QAEXAAVTRequestStatus@@@Z @ 106 NONAME ; void RSsmStateAwareSession::DeferAcknowledgement(class TRequestStatus &) + ?AcknowledgeStateNotification@CSsmStateAwareSession2@@QAEXH@Z @ 107 NONAME ; void CSsmStateAwareSession2::AcknowledgeStateNotification(int) + ?RequestStateNotification@CSsmStateAwareSession2@@QAEXXZ @ 108 NONAME ; void CSsmStateAwareSession2::RequestStateNotification(void) + ??1CSsmStateAwareSession2@@UAE@XZ @ 109 NONAME ; CSsmStateAwareSession2::~CSsmStateAwareSession2(void) diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/bwins/ssmcmnu.def --- a/sysstatemgmt/systemstatemgr/cmn/bwins/ssmcmnu.def Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/bwins/ssmcmnu.def Fri Oct 08 14:33:25 2010 +0300 @@ -99,4 +99,13 @@ ?IsSsmGracefulOffline@@YAKXZ @ 98 NONAME ; unsigned long IsSsmGracefulOffline(void) ?KSsmGracefulOffline@@3KB @ 99 NONAME ; unsigned long const KSsmGracefulOffline ?KSsmInvalidSim@@3KB @ 100 NONAME ; unsigned long const KSsmInvalidSim + ?RequestStateNotificationCancel@CSsmStateAwareSession2@@QAEXXZ @ 101 NONAME ; void CSsmStateAwareSession2::RequestStateNotificationCancel(void) + ?AcknowledgeAndRequestStateNotification@CSsmStateAwareSession2@@QAEXH@Z @ 102 NONAME ; void CSsmStateAwareSession2::AcknowledgeAndRequestStateNotification(int) + ?GetState@CSsmStateAwareSession2@@QAE?AVTSsmState@@XZ @ 103 NONAME ; class TSsmState CSsmStateAwareSession2::GetState(void) + ?CancelDeferral@RSsmStateAwareSession@@QAEXXZ @ 104 NONAME ; void RSsmStateAwareSession::CancelDeferral(void) + ?NewL@CSsmStateAwareSession2@@SAPAV1@GAAVMStateChangeNotificationSubscriber2@@@Z @ 105 NONAME ; class CSsmStateAwareSession2 * CSsmStateAwareSession2::NewL(unsigned short, class MStateChangeNotificationSubscriber2 &) + ?DeferAcknowledgement@RSsmStateAwareSession@@QAEXAAVTRequestStatus@@@Z @ 106 NONAME ; void RSsmStateAwareSession::DeferAcknowledgement(class TRequestStatus &) + ?AcknowledgeStateNotification@CSsmStateAwareSession2@@QAEXH@Z @ 107 NONAME ; void CSsmStateAwareSession2::AcknowledgeStateNotification(int) + ?RequestStateNotification@CSsmStateAwareSession2@@QAEXXZ @ 108 NONAME ; void CSsmStateAwareSession2::RequestStateNotification(void) + ??1CSsmStateAwareSession2@@UAE@XZ @ 109 NONAME ; CSsmStateAwareSession2::~CSsmStateAwareSession2(void) diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/eabi/ssmcmn_graceful_shutdownu.def --- a/sysstatemgmt/systemstatemgr/cmn/eabi/ssmcmn_graceful_shutdownu.def Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/eabi/ssmcmn_graceful_shutdownu.def Fri Oct 08 14:33:25 2010 +0300 @@ -117,4 +117,15 @@ KSsmGracefulOffline @ 116 NONAME DATA 4 _Z20IsSsmGracefulOfflinev @ 117 NONAME KSsmInvalidSim @ 118 NONAME DATA 4 + _ZN21RSsmStateAwareSession14CancelDeferralEv @ 119 NONAME + _ZN21RSsmStateAwareSession20DeferAcknowledgementER14TRequestStatus @ 120 NONAME + _ZN22CSsmStateAwareSession224RequestStateNotificationEv @ 121 NONAME + _ZN22CSsmStateAwareSession228AcknowledgeStateNotificationEi @ 122 NONAME + _ZN22CSsmStateAwareSession230RequestStateNotificationCancelEv @ 123 NONAME + _ZN22CSsmStateAwareSession238AcknowledgeAndRequestStateNotificationEi @ 124 NONAME + _ZN22CSsmStateAwareSession24NewLEtR35MStateChangeNotificationSubscriber2 @ 125 NONAME + _ZN22CSsmStateAwareSession28GetStateEv @ 126 NONAME + _ZN22CSsmStateAwareSession2D0Ev @ 127 NONAME + _ZN22CSsmStateAwareSession2D1Ev @ 128 NONAME + _ZN22CSsmStateAwareSession2D2Ev @ 129 NONAME diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/eabi/ssmcmnu.def --- a/sysstatemgmt/systemstatemgr/cmn/eabi/ssmcmnu.def Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/eabi/ssmcmnu.def Fri Oct 08 14:33:25 2010 +0300 @@ -117,4 +117,15 @@ KSsmGracefulOffline @ 116 NONAME DATA 4 _Z20IsSsmGracefulOfflinev @ 117 NONAME KSsmInvalidSim @ 118 NONAME DATA 4 + _ZN21RSsmStateAwareSession14CancelDeferralEv @ 119 NONAME + _ZN21RSsmStateAwareSession20DeferAcknowledgementER14TRequestStatus @ 120 NONAME + _ZN22CSsmStateAwareSession224RequestStateNotificationEv @ 121 NONAME + _ZN22CSsmStateAwareSession228AcknowledgeStateNotificationEi @ 122 NONAME + _ZN22CSsmStateAwareSession230RequestStateNotificationCancelEv @ 123 NONAME + _ZN22CSsmStateAwareSession238AcknowledgeAndRequestStateNotificationEi @ 124 NONAME + _ZN22CSsmStateAwareSession24NewLEtR35MStateChangeNotificationSubscriber2 @ 125 NONAME + _ZN22CSsmStateAwareSession28GetStateEv @ 126 NONAME + _ZN22CSsmStateAwareSession2D0Ev @ 127 NONAME + _ZN22CSsmStateAwareSession2D1Ev @ 128 NONAME + _ZN22CSsmStateAwareSession2D2Ev @ 129 NONAME diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/inc/cmnpanic.h --- a/sysstatemgmt/systemstatemgr/cmn/inc/cmnpanic.h Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/inc/cmnpanic.h Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -26,24 +26,29 @@ ECmnPropMonError1 = 1, //CSsmStateMonitor errors - ECmnStateMonError1, + ECmnStateMonError1 = 2, //CSsmSystemWideProperty errors - ECmnSwpSession1, + ECmnSwpSession1 = 3, //SsmStateAwareSession errors - ECmnErrState, - ECmnErrRqstStateNotif, - ECmnErrRqstStateNotifCancel, - ECmnErrAcknldgStateNotif, - ECmnErrAcknldgRqstStateNotif, - ECmnErrStateMon, + ECmnErrState = 4, + ECmnErrRqstStateNotif = 5, + ECmnErrRqstStateNotifCancel = 6, + ECmnErrAcknldgStateNotif = 7, + ECmnErrAcknldgRqstStateNotif = 8, + ECmnErrStateMon = 9, + ECmnErrDeferAcknNotif = 10, + ECmnErrCancelDeferNotif = 11, //TSsmState errors - ECmnStateMaxValue1, //Out of range value supplied to the main state in TSsmState::TSsmState() - ECmnStateMaxValue2, //Out of range value supplied to the main state in TSsmState::TSsmState() - ECmnStateMaxValue3, //Out of range value supplied to the main state in TSsmState::Set() - ECmnStateMaxValue4 //Out of range value supplied to the main state in TSsmState::SetFromInt() + ECmnStateMaxValue1 = 12, //Out of range value supplied to the main state in TSsmState::TSsmState() + ECmnStateMaxValue2 = 13, //Out of range value supplied to the main state in TSsmState::TSsmState() + ECmnStateMaxValue3 = 14, //Out of range value supplied to the main state in TSsmState::Set() + ECmnStateMaxValue4 = 15, //Out of range value supplied to the main state in TSsmState::SetFromInt() + + //CSsmDeferralMonitor + ECmnErrDeferNotif = 16 }; #endif // __CMNPANICCODES_H__ diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/inc/ssmstatemonitor.h --- a/sysstatemgmt/systemstatemgr/cmn/inc/ssmstatemonitor.h Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/inc/ssmstatemonitor.h Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -48,5 +48,44 @@ TSsmState iState; }; +/** +This active object will, once activated, repeatedly attempt to defer +a transition deadline. +It will stop once an attempt to defer fails eg. because deferral +was cancelled or the transition was acknowledged or the deferral limit was reached. +@internalComponent +@released +*/ +NONSHARABLE_CLASS(CSsmDeferralMonitor) : public CActive + { +public: + CSsmDeferralMonitor(RSsmStateAwareSession& aStateAwareSession, CSsmStateAwareSession2& aOwnerActiveObject); + ~CSsmDeferralMonitor(); + + /** + Request deadline deferral for the last transition + notification + */ + void DeferNotification(); + void NotifyOfAcknowledgement(); + +protected: + /** + Re-call DeferNotification(), unless the previous + call completed with an error. + */ + void RunL(); + + /** + Handle errors thrown from RunL() - call HandleDeferralErrror() + */ + TInt RunError(TInt aError); + void DoCancel(); +private: + RSsmStateAwareSession& iSsmStateAwareSession; + CSsmStateAwareSession2& iOwnerActiveObject; + TBool iCeaseDeferral; + }; + #endif diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/src/ssmstateawaresession.cpp --- a/sysstatemgmt/systemstatemgr/cmn/src/ssmstateawaresession.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/src/ssmstateawaresession.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -25,15 +25,6 @@ @internalComponent @released */ -static void Panic(TInt aReason) - { - User::Panic(KPanicSsmCmn, aReason); - } - -/** - @internalComponent - @released - */ class RSsmStateAwareSession::RPrivateImpl : public RDmDomain { }; @@ -91,7 +82,7 @@ */ EXPORT_C TSsmState RSsmStateAwareSession::State() const { - __ASSERT_ALWAYS(iPimpl, Panic(ECmnErrState)); + __ASSERT_ALWAYS(iPimpl, User::Panic(KPanicSsmCmn, ECmnErrState)); TUint32 ds = 0; //returned TDmDomainState is currently only 8 bits @@ -108,7 +99,7 @@ */ EXPORT_C void RSsmStateAwareSession::RequestStateNotification(TRequestStatus& aStatus) { - __ASSERT_ALWAYS(iPimpl, Panic(ECmnErrRqstStateNotif)); + __ASSERT_ALWAYS(iPimpl, User::Panic(KPanicSsmCmn, ECmnErrRqstStateNotif)); iPimpl->RequestTransitionNotification(aStatus); //lint !e613 Possible use of NULL pointer - caught by ASSERT_ALWAYS } @@ -118,7 +109,7 @@ */ EXPORT_C void RSsmStateAwareSession::RequestStateNotificationCancel() { - __ASSERT_ALWAYS(iPimpl, Panic(ECmnErrRqstStateNotifCancel)); + __ASSERT_ALWAYS(iPimpl, User::Panic(KPanicSsmCmn, ECmnErrRqstStateNotifCancel)); iPimpl->CancelTransitionNotification(); //lint !e613 Possible use of NULL pointer - caught by ASSERT_ALWAYS } @@ -131,7 +122,7 @@ */ EXPORT_C void RSsmStateAwareSession::AcknowledgeStateNotification(TInt aError) { - __ASSERT_ALWAYS(iPimpl, Panic(ECmnErrAcknldgStateNotif)); + __ASSERT_ALWAYS(iPimpl, User::Panic(KPanicSsmCmn, ECmnErrAcknldgStateNotif)); iPimpl->AcknowledgeLastState(aError); //lint !e613 Possible use of NULL pointer - caught by ASSERT_ALWAYS } @@ -143,13 +134,83 @@ */ EXPORT_C void RSsmStateAwareSession::AcknowledgeAndRequestStateNotification(TInt aError, TRequestStatus& aStatus) { - __ASSERT_ALWAYS(iPimpl, Panic(ECmnErrAcknldgRqstStateNotif)); + __ASSERT_ALWAYS(iPimpl, User::Panic(KPanicSsmCmn, ECmnErrAcknldgRqstStateNotif)); //Typical pattern of using P&S is to subscribe first then get current state iPimpl->RequestTransitionNotification(aStatus); //lint !e613 Possible use of NULL pointer - caught by ASSERT_ALWAYS //Tell domain manager that we have processed the last state change. iPimpl->AcknowledgeLastState(aError); //lint !e613 Possible use of NULL pointer - caught by ASSERT_ALWAYS } +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +/** +Defers the acknowledgement requesting more time. +To be sure of deferring in time a client should call this immediately +after receiving notification. This asynchronous call will complete once the original deadline +is reached (ie. one period earlier than the final deadline), at which point the member must either +defer again or acknowledge the transition. In the meantime, the member should perform +its transition actions, whilst remaining responsive to new completion events. + +@note Deferrals are not always possible, +whether the member will actually be given more time depends on if + - The current transition allows deferrals at all. + - The member still has deferrals left - there may be a maximum number + allowed. + - The deferral request was received in time. + +@param aStatus Status of request + - KErrNone Request has completed i.e. The member must either defer again or acknowledge. + - KErrCompletion The deferral was obsoleted by a subsequent call to AcknowledgeLastState. + - KErrNotSupported The current transition may not be deferred, or maximum deferral count reached. + - KErrCancel The deferral was cancelled. + - KErrNotReady Deferral attempted before a transition notification was received + or after the deadline for the previous one. + - KErrPermissionDenied The member lacked the necessary capabilities. + - KErrAlreadyExists A deferral was already outstanding. + Both new and existing calls will complete with this error. + +This function is provided for members to inform the Domain Manager that they +are still active and are responding to a transition notification. +For example, a server may have to persist data using +the file server before shut down. Since this task should be allowed to complete +before shutdown continues, the member should defer the transition, and then persist +the data, using asynchronous calls. + +At least one of the below capabilities is required in order to defer a +domain transition. Without them, the client will get KErrPermissionDenied. + +@capability WriteDeviceData +@capability ProtServ + +@pre The member has been notified of a transition which it has not yet acknowledged. + */ +EXPORT_C void RSsmStateAwareSession::DeferAcknowledgement(TRequestStatus& aStatus) + { + __ASSERT_ALWAYS(iPimpl, User::Panic(KPanicSsmCmn, ECmnErrDeferAcknNotif)); + iPimpl->DeferAcknowledgement(aStatus); //lint !e613 Possible use of NULL pointer - caught by ASSERT_ALWAYS + + } + +/** +Cancels the deferred call. +Will cancel a call of DeferAcknowledgement, if one was pending. +If none was pending, it does nothing. +*/ +EXPORT_C void RSsmStateAwareSession::CancelDeferral() + { + __ASSERT_ALWAYS(iPimpl, User::Panic(KPanicSsmCmn, ECmnErrCancelDeferNotif)); + iPimpl->CancelDeferral(); //lint !e613 Possible use of NULL pointer - caught by ASSERT_ALWAYS + } +#else +EXPORT_C void RSsmStateAwareSession::DeferAcknowledgement(TRequestStatus& aStatus) + { + TRequestStatus* pStatus = &aStatus; + User::RequestComplete(pStatus, KErrNotSupported); + } + +EXPORT_C void RSsmStateAwareSession::CancelDeferral() + { + } +#endif // //---------------- class CSsmStateAwareSession ------------------ // @@ -218,7 +279,7 @@ */ EXPORT_C TSsmState CSsmStateAwareSession::State() const { - __ASSERT_ALWAYS(iMonitor, Panic(ECmnErrStateMon)); + __ASSERT_ALWAYS(iMonitor, User::Panic(KPanicSsmCmn, ECmnErrStateMon)); return iMonitor->State(); } @@ -270,3 +331,178 @@ #endif } } //lint !e1746 Suppress parameter 'aSsmState' could be made const reference + +// +//---------------- class CExtendedSsmStateAwareSession ------------------ +// +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +/** +Factory method that returns an instance of this object, connected to the domain +identified by the specified domain Id and setup to subscribe on System State changes. +@param aDomainId The Id of the domain to connect to. +@param aSubscriber reference to MStateChangeNotificationSubscriber2 +*/ +EXPORT_C CSsmStateAwareSession2* CSsmStateAwareSession2::NewL(TDmDomainId aDomainId, MStateChangeNotificationSubscriber2& aSubscriber) + { + CSsmStateAwareSession2* self = new (ELeave)CSsmStateAwareSession2(aSubscriber); + CleanupStack::PushL(self); + self->ConstructL(aDomainId); + CleanupStack::Pop(self); + return self; + } + +CSsmStateAwareSession2::CSsmStateAwareSession2(MStateChangeNotificationSubscriber2& aSubscriber): +CActive(CActive::EPriorityStandard), iDeferNotification(NULL), iSubscriber(&aSubscriber) + { + CActiveScheduler::Add(this); + } + +void CSsmStateAwareSession2::ConstructL(TDmDomainId aDomainId) + { + User::LeaveIfError(iSsmStateAwareSession.Connect(aDomainId)); + iDeferNotification = new (ELeave) CSsmDeferralMonitor(iSsmStateAwareSession, *this); + + } +/** +Destructor. +Cleanup the internal CSsmDeferralMonitor active object. +*/ +EXPORT_C CSsmStateAwareSession2::~CSsmStateAwareSession2() + { + Cancel(); + delete iDeferNotification; + iSsmStateAwareSession.Close(); + } + +/** + Gets the TSsmState state. + */ +EXPORT_C TSsmState CSsmStateAwareSession2::GetState() + { + return iSsmStateAwareSession.State(); + } + +/** + Use to get a notification when the System State changes. + */ +EXPORT_C void CSsmStateAwareSession2::RequestStateNotification() + { + __ASSERT_ALWAYS(!IsActive(), User::Panic(KPanicSsmCmn, ECmnErrRqstStateNotif)); + iSsmStateAwareSession.RequestStateNotification(iStatus); + SetActive(); + } + +/** + Cancels an outstanding RequestStateNotification operation. + */ +EXPORT_C void CSsmStateAwareSession2::RequestStateNotificationCancel() + { + iDeferNotification->Cancel(); + iSsmStateAwareSession.RequestStateNotificationCancel(); + } + +/** + Acknowledges the state change. + An application must acknowledge that it has performed all actions required by the last known state of the domain. + @param set aError while acknowledging. + */ +EXPORT_C void CSsmStateAwareSession2::AcknowledgeStateNotification(TInt aError) + { + iSsmStateAwareSession.AcknowledgeStateNotification(aError); + iDeferNotification->NotifyOfAcknowledgement(); + } + +/** + Acknowledges the state change. + An application must acknowledge that it has performed all actions required by the last known state of the domain. + This function appears like an atomic function and minimize the risk for missing a state notification. + @param aError for aknowledging with error. + */ +EXPORT_C void CSsmStateAwareSession2::AcknowledgeAndRequestStateNotification(TInt aError) + { + __ASSERT_ALWAYS(!IsActive(), User::Panic(KPanicSsmCmn, ECmnErrAcknldgRqstStateNotif)); + iSsmStateAwareSession.AcknowledgeAndRequestStateNotification(aError,iStatus); + iDeferNotification->NotifyOfAcknowledgement(); + SetActive(); + } + +/** + Handles the client deferral error. + @param aError Error code to handle + */ +TInt CSsmStateAwareSession2::HandleDeferralError(TInt aError) + { + return (iSubscriber->HandleDeferralError(aError)); + } + +/** + Handle completion of request notifications, begins deferrals. +@note Clients should not need to override this, they +will be notified of events via interface HandleTransition(). + */ +void CSsmStateAwareSession2::RunL() + { + iDeferNotification->DeferNotification(); + iSubscriber->HandleTransition(iStatus.Int()); + } + +/** +Cancels an outstanding notification request. +Any outstanding notification request completes with KErrCancel. +*/ +void CSsmStateAwareSession2::DoCancel() + { + iDeferNotification->Cancel(); + iSsmStateAwareSession.RequestStateNotificationCancel(); + } + +#else +EXPORT_C CSsmStateAwareSession2* CSsmStateAwareSession2::NewL(TDmDomainId /*aDomainId*/, MStateChangeNotificationSubscriber2& /*aSubscriber*/) + { + //This functionality is not supported , so returning NULL. + return NULL; + } + +//All the below functionality will not be provided. + +EXPORT_C CSsmStateAwareSession2::~CSsmStateAwareSession2() + { + } + +EXPORT_C TSsmState CSsmStateAwareSession2::GetState() + { + //returning dummyState to get rid of compiler warning. + TSsmState dummyState; + return dummyState; + } + +EXPORT_C void CSsmStateAwareSession2::RequestStateNotification() + { + } + +EXPORT_C void CSsmStateAwareSession2::RequestStateNotificationCancel() + { + } + +EXPORT_C void CSsmStateAwareSession2::AcknowledgeStateNotification(TInt /*aError*/) + { + } + +EXPORT_C void CSsmStateAwareSession2::AcknowledgeAndRequestStateNotification(TInt /*aError*/) + { + } + +void CSsmStateAwareSession2::RunL() + { + } + +void CSsmStateAwareSession2::DoCancel() + { + } + +TInt CSsmStateAwareSession2::HandleDeferralError(TInt aError) + { + return aError; + } + +#endif diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/cmn/src/ssmstatemonitor.cpp --- a/sysstatemgmt/systemstatemgr/cmn/src/ssmstatemonitor.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/cmn/src/ssmstatemonitor.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -110,3 +110,81 @@ { return iState; } + + +CSsmDeferralMonitor::CSsmDeferralMonitor(RSsmStateAwareSession& aStateAwareSession, CSsmStateAwareSession2& aOwnerActiveObject) + : CActive(CActive::EPriorityHigh), iSsmStateAwareSession(aStateAwareSession), iOwnerActiveObject(aOwnerActiveObject), iCeaseDeferral(EFalse) + { + CActiveScheduler::Add(this); + } + +CSsmDeferralMonitor::~CSsmDeferralMonitor() + { + Cancel(); + } + +/** + * Defers the Acknowledgement. + */ +void CSsmDeferralMonitor::DeferNotification() + { + __ASSERT_ALWAYS(!IsActive(), User::Panic(KPanicSsmCmn, ECmnErrDeferNotif)); + iSsmStateAwareSession.DeferAcknowledgement(iStatus); + SetActive(); + } + +/** +Informs the object that the state transition has +been _successfully_ acknowledged +*/ +void CSsmDeferralMonitor::NotifyOfAcknowledgement() + { + if (IsActive()) + { + iCeaseDeferral = ETrue; + } + } + +void CSsmDeferralMonitor::RunL() + { + const TInt error = iStatus.Int(); + TBool ceaseDeferral = iCeaseDeferral; + iCeaseDeferral = EFalse; + // We are leaving with error after resetting iCeaseDeferral. This is because + // we might again RequestStateNotification() in HandleDeferralError(), in which case + // we need to reset iCeaseDeferral to EFalse so that deferral may happen again. + User::LeaveIfError(error); + + if(!ceaseDeferral) + { + DeferNotification(); + } + else + { + // At this point we know error == KErrNone + // However, we return the error code KErrCompletion, as this + // is what would have happened, had the acknowledgment come in + // a little earlier, + // whilst the deferral was still outstanding on the server. + User::Leave(KErrCompletion); + } + } + +/** + Handle errors thrown from RunL() - call HandleDeferralErrror() +*/ +TInt CSsmDeferralMonitor::RunError(TInt aError) + { + DEBUGPRINT2A("CSsmDeferralMonitor::RunError: %d", aError); + return iOwnerActiveObject.HandleDeferralError(aError); + } + +/** + * Cancels the outstanding deferral request. + */ +void CSsmDeferralMonitor::DoCancel() + { + iSsmStateAwareSession.CancelDeferral(); + } + + diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/dompolicy/src/domainpolicy2.cpp --- a/sysstatemgmt/systemstatemgr/dompolicy/src/domainpolicy2.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/dompolicy/src/domainpolicy2.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -15,6 +15,9 @@ #include "ssmdomaindefs.h" #include "ssmsubstates.hrh" +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#include "ssmstates.hrh" +#endif //SYMBIAN_INCLUDE_APP_CENTRIC #ifdef __WINS__ const TInt KStateTransitionTimeout = 30000000; /* 30 seconds */ @@ -22,6 +25,10 @@ const TInt KStateTransitionTimeout = 10000000; /* 10 seconds */ #endif +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +const TInt KStateDeferredLimit = 1; /* 1 time */ +const TInt KMemberTimeout = 5; /* 5msec */ +#endif //SYMBIAN_INCLUDE_APP_CENTRIC /* Domain specification and policy for the startup domain hierarchy */ @@ -38,10 +45,22 @@ { KSM2UiServicesDomain3, KSM2AppServicesDomain4, _INIT_SECURITY_POLICY_PASS, ESsmStartupSubStateUndefined, KStateTransitionTimeout }, { KSM2UiApplicationDomain3, KSM2UiServicesDomain3, _INIT_SECURITY_POLICY_PASS, ESsmStartupSubStateUndefined, KStateTransitionTimeout }, // end of array marker - { KDmIdNone, KDmIdNone, _INIT_SECURITY_POLICY_PASS, 0, 0 } + TDM_DOMAIN_SPEC_END }; +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +/** + * Note that the transition monitor feature is enabled for states added to StateSpecification array only. + */ +static const SDmStateSpecV1 StateSpecification[]= + { + {(ESsmShutdown << 16 | ESsmShutdownSubStateCritical), KMemberTimeout, KStateDeferredLimit, ETransitionFailureUsePolicyFromOrdinal3}, + {(ESsmShutdown << 16 | ESsmShutdownSubStateNonCritical), KMemberTimeout, KStateDeferredLimit, ETransitionFailureUsePolicyFromOrdinal3} + + }; + +#endif //SYMBIAN_INCLUDE_APP_CENTRIC /* Note that the _INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData) is not used for the root domain, since this refers to the capabilities of the SSA components connecting to the Start-up Domain Hierarchy. No capabilities are required by SSA components to attach to the Start-up Domain Hierarchy. @@ -100,3 +119,43 @@ return KErrNone; } +/** +Retrieves the state specification array. +The domain manager retrieves the StateSpecification array to read the state for which the transition +monitoring feature has to be enabled. +This should be present in the oridinal4 of the domainpolicy def file. + +@param aPtr Will have the state specification structure used in the array . +@param aNumElements Will hold the number of elements in the array. + +@return will return the version of the domain policy if the feature is enabled or else returns KErrNotSupported. + */ +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +EXPORT_C TInt DmPolicy::GetStateSpec(TAny*& aPtr, TUint& aNumElements) + { + TInt version = KErrNotSupported; + aPtr = (TAny*) StateSpecification; + aNumElements = sizeof(StateSpecification)/sizeof(SDmStateSpecV1); + version = KSDmStateSpecV1; + return version; + } +#else +EXPORT_C TInt DmPolicy::GetStateSpec(TAny*& aPtr, TUint& aNumElements) + { + aPtr = NULL; + aNumElements = 0; + return KErrNotSupported; + } +#endif //SYMBIAN_INCLUDE_APP_CENTRIC + +/** +Defines the function type for a static function that is implemented by +a device's domain policy DLL at ordinal 5. +The domain manager uses this function to release the state specification returned by ordinal 4. +The implementation may be empty and simply return if no release action needs +to be taken. + */ +EXPORT_C void DmPolicy::ReleaseStateSpec(TAny* /*aStateSpec*/) + { + } + diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/inc/ssmstateawaresession.h --- a/sysstatemgmt/systemstatemgr/inc/ssmstateawaresession.h Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/inc/ssmstateawaresession.h Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -18,10 +18,13 @@ #include #include +#include #include class CSsmStateMonitor; +class CSsmDeferralMonitor; + /** Read-only client interface to receive notifications when the @@ -44,6 +47,9 @@ IMPORT_C void RequestStateNotificationCancel(); IMPORT_C void AcknowledgeStateNotification(TInt aError); IMPORT_C void AcknowledgeAndRequestStateNotification(TInt aError, TRequestStatus& aStatus); + IMPORT_C void DeferAcknowledgement(TRequestStatus& aStatus); + IMPORT_C void CancelDeferral(); + private: RSsmStateAwareSession(const RSsmStateAwareSession& aState); @@ -103,5 +109,76 @@ CSsmStateMonitor* iMonitor; TInt iSpare[4]; }; + + +/** +Interface to implement for clients that want to use the @c CExtendedSsmStateAwareSession +utility class. + +@publishedPartner +@released +*/ +class MStateChangeNotificationSubscriber2 + { +public: + /*HandleTransition() will be called when the transition notification + comes in. Thereafter, the active object will contineouslly defer the transition. + + The implementation of this function should be used first to call + RequestTransitionNotification() again if required, and then to initiate the + response to the transition. It should be kept as quick as possible. + + Once the Domain Member's transition operations are complete, it should call + AcknowledgeLastState() on this active object, to indicate it is ready to be + transitioned*/ + + virtual void HandleTransition(TInt aError) = 0; + + virtual TInt HandleDeferralError(TInt aError) = 0; + }; + +/** +This class automatically deferrs transitions as long as possible after the original notification +is received. + +To make use of this class, one has to implement the implement the HandleTransition() +in MStateChangeNotificationSubscriber2. HandleTransition() will be called when the transition notification +comes in. Thereafter, the active object will continually defer the transition. + +This object is intended to simplify the handling of notifications and +deferrals. The member must ensure that other active objects do not block or +have long-running RunL()s; this is to ensure that the Active Scheduler will +remain responsive to the completion of deadline deferrals. + +The capabilities needed are the same as those needed for RDmDomain::DeferAcknowledgement() +@capability WriteDeviceData +@capability ProtServ +@see +*/ +NONSHARABLE_CLASS(CSsmStateAwareSession2):public CActive + { +public: + IMPORT_C static CSsmStateAwareSession2* NewL(TDmDomainId aDomainId, MStateChangeNotificationSubscriber2& aSubscriber ); + IMPORT_C ~CSsmStateAwareSession2(); + IMPORT_C void RequestStateNotification(); + IMPORT_C void RequestStateNotificationCancel(); + IMPORT_C void AcknowledgeStateNotification(TInt aError); + IMPORT_C void AcknowledgeAndRequestStateNotification(TInt aError); + IMPORT_C TSsmState GetState(); + TInt HandleDeferralError(TInt aError); + +private: + CSsmStateAwareSession2(MStateChangeNotificationSubscriber2& aSubscriber); + void RunL(); + void DoCancel(); + void ConstructL(TDmDomainId aDomainId); + + +private: + RSsmStateAwareSession iSsmStateAwareSession; + //For deferring the notification. + CSsmDeferralMonitor* iDeferNotification; + MStateChangeNotificationSubscriber2* iSubscriber; + }; #endif diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/ss/group/ssmstartsafe.mmp --- a/sysstatemgmt/systemstatemgr/ss/group/ssmstartsafe.mmp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/ss/group/ssmstartsafe.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -38,7 +38,7 @@ source fireandforget.cpp source activewaiter.cpp -library euser.lib ssmcmn.lib estor.lib +library euser.lib ssmcmn.lib estor.lib efsrv.lib diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/ss/src/fireandforget.cpp --- a/sysstatemgmt/systemstatemgr/ss/src/fireandforget.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/ss/src/fireandforget.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -17,6 +17,8 @@ #include "timeoutwaiter.h" #include "ssmdebug.h" +#include + _LIT(KApStartDLL, "apstart.dll"); _LIT( KSysMonProxyDLL, "loadsysmon.dll" ); typedef CApaStarter* (*TFuncNewL)( void ); @@ -75,7 +77,7 @@ TFullName searchTerm(iStartupProperties->FileName()); _LIT(KSearchAny, "*"); searchTerm += KSearchAny; - TFindProcess find(searchTerm); + TFindProcess find(TParsePtrC(searchTerm).NameAndExt()); TFullName name; err = find.Next(name); if(err == KErrNone) diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/ss/src/rvobserver.cpp --- a/sysstatemgmt/systemstatemgr/ss/src/rvobserver.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/ss/src/rvobserver.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -20,7 +20,8 @@ #include "rvobservernotification.h" #include "ssconst.h" #include "ssmdebug.h" - + +#include /** We are either starting for the first time, or an app or process has rendezvouzed. If the latter, check if it has done so without error and behave as appropriate. @@ -187,7 +188,7 @@ TFullName searchTerm(iStartupProperties->FileName()); _LIT(KSearchAny, "*"); searchTerm += KSearchAny; - TFindProcess find(searchTerm); + TFindProcess find(TParsePtrC(searchTerm).NameAndExt()); TFullName name; err = find.Next(name); if(err == KErrNone) diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/ssm/src/main.cpp --- a/sysstatemgmt/systemstatemgr/ssm/src/main.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/ssm/src/main.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -37,10 +37,12 @@ { PanicNow(KPanicSysStateMgr, EAddDomainHierarchyError); } - + RLibrary lib; + lib.Load(_L("libc")); + CleanupClosePushL(lib); CSsmServer* server = CSsmServer::NewLC(ESsmStartup); sched->Start(); - + CleanupStack::PopAndDestroy(&lib); CleanupStack::PopAndDestroy(server); CleanupStack::PopAndDestroy(sched); } diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/group/bld.inf --- a/sysstatemgmt/systemstatemgr/test/tcmn/group/bld.inf Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -34,6 +34,12 @@ PRJ_TESTMMPFILES tcmn_server.mmp +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +tcmn_transitionmonitor_server.mmp +#endif // TEST_SSM_GRACEFUL_SHUTDOWN +#endif // SYMBIAN_INCLUDE_APP_CENTRIC + //Define TEST_SSM_GRACEFUL_OFFLINE only when patchable constant KSsmGracefulOffline is enabled #ifdef TEST_SSM_GRACEFUL_OFFLINE tcmn_gracefulnotify_server.mmp @@ -53,6 +59,28 @@ ../scripts/ssmatest_cmn_swpvalue.script z:/ssmatest/ssmatest_cmn_swpvalue.script ../scripts/ssmatest_cmn_systemwideproperty.script z:/ssmatest/ssmatest_cmn_systemwideproperty.script ../scripts/ssmatest_cmn_stateawaresession.script z:/ssmatest/ssmatest_cmn_stateawaresession.script + +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +../scripts/ssmatest_cmn_canceldeferral.script z:/ssmatest/ssmatest_cmn_canceldeferral.script +../scripts/ssmatest_cmn_deferackn.script z:/ssmatest/ssmatest_cmn_deferackn.script +../scripts/ssmatest_cmn_noackn.script z:/ssmatest/ssmatest_cmn_noackn.script +../scripts/ssmatest_cmn_acklaststate.script z:/ssmatest/ssmatest_cmn_acklaststate.script +../scripts/ssmatest_cmn_maxdefer.script z:/ssmatest/ssmatest_cmn_maxdefer.script +../scripts/ssmatest_cmn_deferwocap.script z:/ssmatest/ssmatest_cmn_deferwocap.script +../scripts/ssmatest_cmn_defertwice.script z:/ssmatest/ssmatest_cmn_defertwice.script +../scripts/ssmatest_cmn_defertooearly.script z:/ssmatest/ssmatest_cmn_defertooearly.script +../scripts/ssmatest_cmn_deferautomatic.script z:/ssmatest/ssmatest_cmn_deferautomatic.script +../scripts/ssmatest_cmn_deferautomaticwocap.script z:/ssmatest/ssmatest_cmn_deferautomaticwocap.script +../scripts/ssmatest_cmn_maxautomaticdefer.script z:/ssmatest/ssmatest_cmn_maxautomaticdefer.script +../scripts/ssmatest_cmn_deferackn_anysubstate.script z:/ssmatest/ssmatest_cmn_deferackn_anysubstate.script +../scripts/ssmatest_cmn_deferackn_failstate.script z:/ssmatest/ssmatest_cmn_deferackn_failstate.script +../scripts/ssmatest_cmn_requestandcancelstatenotification.script z:/ssmatest/ssmatest_cmn_requestandcancelstatenotification.script + +../testdata/ssmatest_cmn_transitionmonitor.ini z:/ssmatest/ssmatest_cmn_transitionmonitor.ini +#endif // TEST_SSM_GRACEFUL_SHUTDOWN +#endif // SYMBIAN_INCLUDE_APP_CENTRIC + #ifdef TEST_SSM_GRACEFUL_OFFLINE ../scripts/ssmatest_cmn_gracefulofflinestatenotify.script z:/ssmatest/ssmatest_cmn_gracefulofflinestatenotify.script ../testdata/ssmatest_cmn_gracefulofflinestatenotify.ini z:/ssmatest/ssmatest_cmn_gracefulofflinestatenotify.ini diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/group/ssmatest_cmn.iby --- a/sysstatemgmt/systemstatemgr/test/tcmn/group/ssmatest_cmn.iby Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/group/ssmatest_cmn.iby Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -22,9 +22,15 @@ // test server data=ABI_DIR\DEBUG_DIR\tcmn_server.exe sys\bin\tcmn_server.exe +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +data=ABI_DIR\DEBUG_DIR\tcmn_transitionmonitor.exe sys\bin\tcmn_transitionmonitor.exe +#endif // TEST_SSM_GRACEFUL_SHUTDOWN +#endif // SYMBIAN_INCLUDE_APP_CENTRIC + #ifdef TEST_SSM_GRACEFUL_OFFLINE data=ABI_DIR\DEBUG_DIR\tcmn_gracefulnotify.exe sys\bin\tcmn_gracefulnotify.exe -#endif +#endif // TEST_SSM_GRACEFUL_OFFLINE // script files data=DATAZ_\ssmatest\ssmatest_cmn_run.bat \ssmatest_cmn_run.bat @@ -38,6 +44,27 @@ data=DATAZ_\ssmatest\ssmatest_cmn_gracefulofflinestatenotify.ini \ssmatest\ssmatest_cmn_gracefulofflinestatenotify.ini // rsc file data=EPOCROOT##epoc32\data\z\private\2000d75b\startup\0\tgracefulofflinepatch.rsc private\2000d75b\startup\0\tgracefulofflinepatch.rsc -#endif +#endif // TEST_SSM_GRACEFUL_OFFLINE -#endif +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +data=DATAZ_\ssmatest\ssmatest_cmn_canceldeferral.script \ssmatest\ssmatest_cmn_canceldeferral.script +data=DATAZ_\ssmatest\ssmatest_cmn_deferackn.script \ssmatest\ssmatest_cmn_deferackn.script +data=DATAZ_\ssmatest\ssmatest_cmn_noackn.script \ssmatest\ssmatest_cmn_noackn.script +data=DATAZ_\ssmatest\ssmatest_cmn_acklaststate.script \ssmatest\ssmatest_cmn_acklaststate.script +data=DATAZ_\ssmatest\ssmatest_cmn_maxdefer.script \ssmatest\ssmatest_cmn_maxdefer.script +data=DATAZ_\ssmatest\ssmatest_cmn_deferwocap.script \ssmatest\ssmatest_cmn_deferwocap.script +data=DATAZ_\ssmatest\ssmatest_cmn_defertwice.script \ssmatest\ssmatest_cmn_defertwice.script +data=DATAZ_\ssmatest\ssmatest_cmn_defertooearly.script \ssmatest\ssmatest_cmn_defertooearly.script +data=DATAZ_\ssmatest\ssmatest_cmn_deferautomatic.script \ssmatest\ssmatest_cmn_deferautomatic.script +data=DATAZ_\ssmatest\ssmatest_cmn_deferautomaticwocap.script \ssmatest\ssmatest_cmn_deferautomaticwocap.script +data=DATAZ_\ssmatest\ssmatest_cmn_maxautomaticdefer.script \ssmatest\ssmatest_cmn_maxautomaticdefer.script +data=DATAZ_\ssmatest\ssmatest_cmn_deferackn_anysubstate.script \ssmatest\ssmatest_cmn_deferackn_anysubstate.script +data=DATAZ_\ssmatest\ssmatest_cmn_deferackn_failstate.script \ssmatest\ssmatest_cmn_deferackn_failstate.script +data=DATAZ_\ssmatest\ssmatest_cmn_requestandcancelstatenotification.script \ssmatest\ssmatest_cmn_requestandcancelstatenotification.script + +data=DATAZ_\ssmatest\ssmatest_cmn_transitionmonitor.ini \ssmatest\ssmatest_cmn_transitionmonitor.ini +#endif // TEST_SSM_GRACEFUL_SHUTDOWN +#endif // SYMBIAN_INCLUDE_APP_CENTRIC + +#endif // __SSMATEST_CMN_IBY__ diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/group/tcmn_server.mmp --- a/sysstatemgmt/systemstatemgr/test/tcmn/group/tcmn_server.mmp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/group/tcmn_server.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -39,6 +39,12 @@ USERINCLUDE ../../../localinc USERINCLUDE ../../../cmd/inc +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +USERINCLUDE ../../../../inc +#endif //TEST_SSM_GRACEFUL_SHUTDOWN +#endif //TEST_SSM_GRACEFUL_SHUTDOWN + SOURCEPATH ../../../cmn/src SOURCE ssmstatemanager.cpp @@ -59,6 +65,12 @@ SOURCE tcmn_step_stateawaresession.cpp SOURCE tcmn_step_systemwideproperty.cpp +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +SOURCE t_stateawaresession2.cpp +#endif //TEST_SSM_GRACEFUL_SHUTDOWN +#endif //SYMBIAN_INCLUDE_APP_CENTRIC + SOURCEPATH ../../testutils/src SOURCE ssmatest_utils.cpp diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/group/tcmn_transitionmonitor_server.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/group/tcmn_transitionmonitor_server.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,55 @@ +//tcmn_transitionmonitor_server.mmp + +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Server for handling graceful notification incase of state change +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +TARGET tcmn_transitionmonitor.exe +TARGETTYPE exe +TARGETPATH /sys/bin + +UID 0x1000007A 0x20031E47 +VENDORID 0x70000001 + +CAPABILITY ProtServ WriteDeviceData PowerMgmt + +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +// testcode +USERINCLUDE ../inc +USERINCLUDE ../../../../inc + +SOURCEPATH ../src +SOURCE tcmn_transitionmonitor_server.cpp +SOURCE t_stateawaresessionwrapper.cpp +SOURCE t_ssmstatemanager.cpp +SOURCE t_stateawaresession2.cpp + +LIBRARY ssmcmn.lib +LIBRARY euser.lib +LIBRARY efsrv.lib +LIBRARY ssmcmd.lib +LIBRARY testexecuteutils.lib +LIBRARY bafl.lib +LIBRARY centralrepository.lib + +SMPSAFE + diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/inc/t_stateawaresession2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/inc/t_stateawaresession2.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,75 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Wrapper for Testing CStateAwareSession2 class. +// +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#ifndef __T_STATEAWARESESSIONWRAPPER2_H__ +#define __T_STATEAWARESESSIONWRAPPER2_H__ + +#include +#include + +#include +#include + +// This structure is used to hold data read from the test ini file for CTestCStateAwareSession +struct TIniData3 + { + TBool iAcknowledge; + TInt iAsyncIndex; + TIniData3(); + }; + +class CTestCStateAwareSession : public CDataWrapper, public MStateChangeNotificationSubscriber2 + { +public: + CTestCStateAwareSession(); + ~CTestCStateAwareSession(); + + TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/); + + TAny* GetObject(); + void SetObjectL(TAny* aAny); + void DisownObjectL(); + + void DoCmdNew(); + void DoCmdDestructor(); + void DoCmdRequestStateNotification(); + void DoCmdAcknowledgeStateNotification(const TDesC& aSection); + void DoCmdAcknowledgeAndRequestStateNotification(const TDesC& aSection); + void DoCmdRequestStateNotificationCancel(); + void DoCmdReturnCount(const TDesC& aSection); + void DoCmdReadIniData(const TDesC& aSection); + + //helper + void DoCleanup(); + + //from MStateChangeNotificationSubscriber2 + void HandleTransition(TInt aError); + TInt HandleDeferralError(TInt aError); + +private: + CSsmStateAwareSession2* iSsmStateAwareSession; + TIniData3 iIniData; + }; + +#endif // __T_STATEAWARESESSIONWRAPPER_H__ diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/inc/t_stateawaresessionwrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/inc/t_stateawaresessionwrapper.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,142 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Wrapper for testing RStateAwareSession class. +// +// +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#ifndef __T_STATEAWARESESSIONWRAPPER_H__ +#define __T_STATEAWARESESSIONWRAPPER_H__ + +#include +#include + +#include +#include + +// This structure is used to hold data read from the test ini file for CTestRStateAwareSession1 +struct TIniData1 + { + TBool iCancelDeferral; + TBool iAckLastState; + TBool iDeferTwice; + TInt iCount; + TBool iAcknowledge; + TIniData1(); + }; + +// This structure is used to hold data read from the test ini file for CTestRStateAwareSession2 +struct TIniData2 + { + TInt iCount; + TBool iAcknowledge; + TIniData2(); + }; + +//Client 1 +class CTestRStateAwareSession1 : public CDataWrapper + { +public: + static CTestRStateAwareSession1* NewL(); + ~CTestRStateAwareSession1(); + + TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex); + + TAny* GetObject(); + void SetObjectL(TAny* aAny); + void DisownObjectL(); + + + void DoCmdNew(); + void DoCmdDestructor(); + void DoCmdConnect(const TDesC& aSection); + void DoCmdClose(); + void DoCmdRequestStateNotification(const TInt aAsyncErrorIndex); + void DoCmdAcknowledgeStateNotification(const TDesC& aSection); + void DoCmdAcknowledgeAndRequestStateNotification(const TDesC& aSection, const TInt aAsyncErrorIndex); + void DoCmdRequestStateNotificationCancel(); + void DoCmdDeferAcknowledgement(const TInt aAsyncErrorIndex); + void DoCmdReturnCount(const TDesC& aSection); + void DoCmdReadIniData(const TDesC& aSection); + + //helper + void DoCleanup(); + +protected: + CTestRStateAwareSession1(); + void ConstructL(); + + void RunL(CActive* aActive, TInt aIndex); + void DoCancel(CActive* aActive, TInt aIndex); + + +private: + RSsmStateAwareSession* iSsmStateAwareSession; + CActiveCallback* iActiveNotifyOnChange; + CActiveCallback* iActiveNotifyOnChange2; + // The iCount variable is used to store the no. of deferral calls made. + // It is incremented each time a deferral call is made. + TInt iCount; + TIniData1 iIniData; + }; + +//Client 2 +class CTestRStateAwareSession2 : public CDataWrapper + { +public: + static CTestRStateAwareSession2* NewL(); + ~CTestRStateAwareSession2(); + + TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex); + + TAny* GetObject(); + void SetObjectL(TAny* aAny); + void DisownObjectL(); + + + void DoCmdNew(); + void DoCmdDestructor(); + void DoCmdConnect(const TDesC& aSection); + void DoCmdClose(); + void DoCmdRequestStateNotification(const TInt aAsyncErrorIndex); + void DoCmdAcknowledgeStateNotification(const TDesC& aSection); + void DoCmdAcknowledgeAndRequestStateNotification(const TDesC& aSection, const TInt aAsyncErrorIndex); + void DoCmdRequestStateNotificationCancel(); + void DoCmdReadIniData(const TDesC& aSection); + + //helper + void DoCleanup(); + +protected: + CTestRStateAwareSession2(); + void ConstructL(); + + void RunL(CActive* aActive, TInt aIndex); + void DoCancel(CActive* aActive, TInt aIndex); + + +private: + RSsmStateAwareSession* iSsmStateAwareSession; + CActiveCallback* iActiveNotifyOnChange; + TInt iCount; + TIniData2 iIniData; + }; + +#endif // __T_STATEAWARESESSIONWRAPPER_H__ diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/inc/tcmn_step_stateawaresession.h --- a/sysstatemgmt/systemstatemgr/test/tcmn/inc/tcmn_step_stateawaresession.h Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/inc/tcmn_step_stateawaresession.h Fri Oct 08 14:33:25 2010 +0300 @@ -47,6 +47,11 @@ void doTestRConnectL(); void StartThread(TInt aOption); void doTestCSsmStateAwareSessionL(); +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN + void doTestCSsmDeferralMonitorL(); +#endif //TEST_SSM_GRACEFUL_SHUTDOWN +#endif //TEST_SSM_GRACEFUL_SHUTDOWN RArray iStateChanges; diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/inc/tcmn_transitionmonitor_server.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/inc/tcmn_transitionmonitor_server.h Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,50 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Server for handling graceful notification incase of state change +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + +#ifndef __TCMN_TRANSITIONMONITOR_SERVER_H__ +#define __TCMN_TRANSITIONMONITOR_SERVER_H__ + +#include +#include +#include + +class CAwareSessionTestBlock : public CTestBlockController + { +public: + CAwareSessionTestBlock() : CTestBlockController() {} + ~CAwareSessionTestBlock() {} + + CDataWrapper* CreateDataL(const TDesC& aData); + }; + + +class CAwareSessionTestServer : public CTestServer2 + { +public: + CAwareSessionTestServer() {} + ~CAwareSessionTestServer() {} + + static CAwareSessionTestServer* NewL(); + CTestBlockController* CreateTestBlock(); + }; + +#endif //__TCMN_TRANSITIONMONITOR_SERVER_H__ diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_acklaststate.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_acklaststate.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,57 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0016 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test whether acknowledging state change notification without waiting for the deferral to complete succeeds. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0016 +//! @SYMTestCaseID DVS-SSMA-CMN-0016 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers acknowledgement first after receiving shutdown state change notificcation and acknowledges immediately +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown +/! 3.Defer acknowledgement upon receiving state change notification to shutdown state +//! 4.Acknowledge state change notification without waiting for the deferral to complete +//! @SYMTestExpectedResults The call to defer completes with KErrCompletion + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND RSsmStateAwareSession1 ReadIniData AckLastState + COMMAND !AsyncError=-17 RSsmStateAwareSession1 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionCriticalSubState + OUTSTANDING + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession1 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0016 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_canceldeferral.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_canceldeferral.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,58 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0010 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test if cancelling a deferral after submitting a deferral call indeed cancels the deferral. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0010 +//! @SYMTestCaseID DVS-SSMA-CMN-0010 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers acknowledgement to the shutdown state change notification and then cancels the deferral +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown +//! 3.Defer acknowledgement upon receiving state change notification to shutdown state +//! 4.Cancel the deferral and acknowledge state change notification +//! @SYMTestExpectedResults The call to defer completes with KErrCancel + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND RSsmStateAwareSession1 ReadIniData CancelDeferral + COMMAND !AsyncError=-3 RSsmStateAwareSession1 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionCriticalSubState + OUTSTANDING + COMMAND RSsmStateAwareSession1 ReturnCount CancelDeferral + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession1 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0010 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferackn.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferackn.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,57 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0009 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test if the acknowledgement deferral functionality of a client works correctly. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0009 +//! @SYMTestCaseID DVS-SSMA-CMN-0009 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers acknowledgement to shutdown state change once and then acknowledges +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown +//! 3.Defer acknowledgement upon receiving state change notification to shutdown state +//! 4.Acknowledge once the deferral has completed +//! @SYMTestExpectedResults The call to defer completes successfully + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND RSsmStateAwareSession1 ReadIniData DeferAckn + COMMAND RSsmStateAwareSession1 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionCriticalSubState + OUTSTANDING + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession1 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0009 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferackn_anysubstate.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferackn_anysubstate.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,55 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0018 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test whether deferring acknowledgement to a state not supporting transition monitoring fails with appropriate error. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0018 +//! @SYMTestCaseID DVS-SSMA-CMN-0018 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers acknowledgement to KSsmAnySubState of Shutdown state. +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown, KSsmAnySubState +//! 3.Defer acknowledgement upon receiving state change notification to shutdown state +//! @SYMTestExpectedResults The call to defer completes with KErrNotSupported + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession2 RSsmStateAwareSession2 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession2 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession2 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND !AsyncError=-5 RSsmStateAwareSession2 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionAnySubState + OUTSTANDING + COMMAND RSsmStateAwareSession2 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession2 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0018 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferackn_failstate.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferackn_failstate.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,55 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0017 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in fail state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test whether deferring acknowledgement to a state not supporting transition monitoring fails with appropriate error. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0017 +//! @SYMTestCaseID DVS-SSMA-CMN-0017 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers acknowledgement to Fail state. +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for fail state change notification +//! 2.Request state change to ESsmFail +//! 3.Defer acknowledgement upon receiving state change notification to fail state +//! @SYMTestExpectedResults The call to defer completes with KErrNotSupported + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession2 RSsmStateAwareSession2 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession2 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession2 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND !AsyncError=-5 RSsmStateAwareSession2 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition FailTransitionAnySubState + OUTSTANDING + COMMAND RSsmStateAwareSession2 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession2 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0017 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferautomatic.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferautomatic.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,56 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0020 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test if the client keeps deferring acknowledgement automatically +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0020 +//! @SYMTestCaseID DVS-SSMA-CMN-0020 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which automatically defers acknowledgement to shutdown state change +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown - KSsmAnySubState +//! 3.Upon receiving state change notification to Shutdown - KSsmAnySubState, acknowledge and request state change notification again +//! 4.Upon receiving state change notification to Shutdown Critical substate, the acknowledgement is deferred automatically +//! 5.Acknowledge the state change and check whether the final return code is KErrCompletion +//! @SYMTestExpectedResults The test completes with error code, KErrCompletion + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT CSsmStateAwareSession2 CSsmStateAwareSession2 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND CSsmStateAwareSession2 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateManager Connect + COMMAND CSsmStateAwareSession2 ReadIniData DeferAutomatic + COMMAND !AsyncError=-17 CSsmStateAwareSession2 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionAnySubState + OUTSTANDING + COMMAND RSsmStateManager Close + COMMAND CSsmStateAwareSession2 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0020 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferautomaticwocap.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferautomaticwocap.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,58 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0019 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test if the client keeps deferring acknowledgement automatically +//! @SYMScriptCreationDate 18/08/2010 + +RUN_PROGRAM -1 setcap tcmn_transitionmonitor.exe 00004 tcmn_transitionmonitor_wocap.exe +LOAD_SUITE tcmn_transitionmonitor_wocap + +START_TESTCASE DVS-SSMA-CMN-0019 +//! @SYMTestCaseID DVS-SSMA-CMN-0019 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server without appropriate capabilities which automatically defers acknowledgement to shutdown state change +//! @SYMTestActions 1.Create a thread without WriteDeviceData and ProtServ capabilities +//! 2.Connect to the server with a domain Id and request for shutdown state change notification +//! 3.Request state change to ESsmShutdown - KSsmAnySubState +//! 4.Upon receiving state change notification to Shutdown KSsmAnySubState, acknowledge and request state change notification again +//! 5.Upon receiving state change notification to Shutdown Critical substate, the acknowledgement is deferred automatically +//! 6.Acknowledge the state change and check whether the final return code is KErrPermissionDenied +//! @SYMTestExpectedResults The call to defer completes with KErrPermissionDenied + +START_TEST_BLOCK 100 tcmn_transitionmonitor_wocap z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT CSsmStateAwareSession2 CSsmStateAwareSession2 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND CSsmStateAwareSession2 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateManager Connect + COMMAND CSsmStateAwareSession2 ReadIniData DeferAutomatic + COMMAND !AsyncError=-46 CSsmStateAwareSession2 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionAnySubState + OUTSTANDING + COMMAND RSsmStateManager Close + COMMAND CSsmStateAwareSession2 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0019 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_defertooearly.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_defertooearly.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,47 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0012 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! @SYMScriptPurpose Test if deferring before receiving a state change notification returns with appropriate error. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0012 +//! @SYMTestCaseID DVS-SSMA-CMN-0012 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers acknowledgement to shutdown state change even before the state has changed +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id +//! 2.Defer acknowledgement to shutdown state change even before the state change notification is received +//! @SYMTestExpectedResults The call to defer returns with KErrNotReady + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateAwareSession1 ReadIniData DeferTooEarly + COMMAND !AsyncError=-18 RSsmStateAwareSession1 DeferAcknowledgement + OUTSTANDING + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateAwareSession1 ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0012 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_defertwice.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_defertwice.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,56 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0013 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test whether deferring ackn when a deferral was already outstanding results in an appropriate error. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0013 +//! @SYMTestCaseID DVS-SSMA-CMN-0013 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers acknowledgement twice in succession without waiting for the first defer call to complete +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown +//! 3.Defer acknowledgement twice upon receiving the shutdown state change notification +//! @SYMTestExpectedResults The second call to defer completes with KErrServerBusy + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND RSsmStateAwareSession1 ReadIniData DeferTwice + COMMAND !AsyncError=-16 RSsmStateAwareSession1 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionCriticalSubState + OUTSTANDING + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession1 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0013 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferwocap.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_deferwocap.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,57 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0015 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test whether a client deferring without required capabilities results in an error +//! @SYMScriptCreationDate 18/08/2010 + +RUN_PROGRAM -1 setcap tcmn_transitionmonitor.exe 00004 tcmn_transitionmonitor_wocap.exe +LOAD_SUITE tcmn_transitionmonitor_wocap + +START_TESTCASE DVS-SSMA-CMN-0015 +//! @SYMTestCaseID DVS-SSMA-CMN-0015 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which tries to defer state notification without appropriate capabilities +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown +//! 3.Defer acknowledgement, upon receiving state change notification to shutdown state, without WriteDeviceData and ProtServ capabilities +//! @SYMTestExpectedResults Request to defer acknowledgement should fail with KErrPermissionDenied + +START_TEST_BLOCK 100 tcmn_transitionmonitor_wocap z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND RSsmStateAwareSession1 ReadIniData DeferWoCap + COMMAND !AsyncError=-46 RSsmStateAwareSession1 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionCriticalSubState + OUTSTANDING + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession1 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0015 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_maxautomaticdefer.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_maxautomaticdefer.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,56 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0021 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test if the client keeps deferring acknowledgement automatically +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0021 +//! @SYMTestCaseID DVS-SSMA-CMN-0021 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which automatically defers acknowledgement to shutdown state change +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown - KSsmAnySubState +//! 3.Upon receiving state change notification to Shutdown KSsmAnySubState, acknowledge and request state change notification again +//! 4.Upon receiving state change notification to Shutdown Critical substate, the acknowledgement is deferred automatically +//! 5.Do not acknowledge the state change, check whether the final return value is KErrNotSupported +//! @SYMTestExpectedResults The test completes with error code, KErrNotSupported + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT CSsmStateAwareSession2 CSsmStateAwareSession2 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND CSsmStateAwareSession2 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateManager Connect + COMMAND CSsmStateAwareSession2 ReadIniData MaxAutomaticDefer + COMMAND !AsyncError=-5 CSsmStateAwareSession2 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionAnySubState + OUTSTANDING + COMMAND RSsmStateManager Close + COMMAND CSsmStateAwareSession2 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0021 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_maxdefer.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_maxdefer.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,57 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0014 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test whether deferring a client more than the no. of times allowed returns an appropriate error. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0014 +//! @SYMTestCaseID DVS-SSMA-CMN-0014 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which defers more than the number of times a server is allowed to defer acknowledgement +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Request state change to ESsmShutdown +//! 3.Defer acknowledgement twice, upon receiving state change notification to shutdown state, each time waiting for the previous defer call to complete before calling again +//! @SYMTestExpectedResults The second call to defer returns with KErrNotSupported + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND RSsmStateAwareSession1 ReadIniData MaxDefer + COMMAND !AsyncError=-5 RSsmStateAwareSession1 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionCriticalSubState + OUTSTANDING + COMMAND RSsmStateAwareSession1 ReturnCount MaxDefer + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession1 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0014 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_noackn.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_noackn.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,64 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0011 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! Note: The system is going to be in shutdown state after executing this test and can not be restored to normal for executing other tests. +//! So this test has to be executed separately or at the end on overnight build machines. +//! @SYMScriptPurpose Test whether shutdown state is reached even when the state change notification is not acknowledged. +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0011 +//! @SYMTestCaseID DVS-SSMA-CMN-0011 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which never acknowledges state change notification +//! @SYMTestActions 1.Create 2 threads and connect to the server with a domain Id and request for shutdown state change notification in both the threads +//! 2.Request state change to ESsmShutdown +//! 3.Defer the acknowledgement, upon receiving state change notification to shutdown state, once in the first thread and don't acknowledge when it returns. +//! 4.Acknowledge notfification in the second thread. +//! @SYMTestExpectedResults Shutdown continues since failure policy is ETransitionFailureContinue + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT RSsmStateAwareSession1 RSsmStateAwareSession1 + CREATE_OBJECT RSsmStateAwareSession2 RSsmStateAwareSession2 + CREATE_OBJECT RSsmStateManager RSsmStateManager + COMMAND RSsmStateAwareSession1 NewL + COMMAND RSsmStateAwareSession2 NewL + COMMAND RSsmStateManager NewL + COMMAND RSsmStateAwareSession1 Connect Domain + COMMAND RSsmStateAwareSession2 Connect Domain + COMMAND RSsmStateManager Connect + COMMAND RSsmStateAwareSession1 ReadIniData NoAckn + COMMAND RSsmStateAwareSession2 ReadIniData NoAckn2 + COMMAND RSsmStateAwareSession1 RequestStateNotification + COMMAND RSsmStateAwareSession2 RequestStateNotification + COMMAND RSsmStateManager RequestStateTransition ShutdownTransitionCriticalSubState + OUTSTANDING + COMMAND RSsmStateAwareSession1 Close + COMMAND RSsmStateAwareSession2 Close + COMMAND RSsmStateManager Close + COMMAND RSsmStateAwareSession1 ~ + COMMAND RSsmStateAwareSession2 ~ + COMMAND RSsmStateManager ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0011 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_requestandcancelstatenotification.script --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_requestandcancelstatenotification.script Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,45 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Testing for Transition Monitoring feature implemented as part of Staged Shutdown REQ for AppCentric architecture. This feature allows clients to defer acknowledgement to state change notifications during shutdown. +// + +//! @file +//! @SYMTestSuiteName DVS-SSMA-CMN-0022 +//! @SYMScriptTestEnvironment Details as in below:- +//! 1. testexecute framework(TEF3.0). +//! For the testing purpose define macro TEST_SSM_GRACEFUL_SHUTDOWN(For power off request feature) and SYMBIAN_INCLUDE_APP_CENTRIC(for transition monitoring feature). +//! @SYMScriptPurpose Test if the client keeps deferring acknowledgement automatically +//! @SYMScriptCreationDate 18/08/2010 + +LOAD_SUITE tcmn_transitionmonitor + +START_TESTCASE DVS-SSMA-CMN-0022 +//! @SYMTestCaseID DVS-SSMA-CMN-0022 +//! @SYMPREQ SUB 405-5490 +//! @SYMTestType CIT +//! @SYMTestPriority Critical +//! @SYMTestStatus Implemented +//! @SYMTestCaseDesc Test the behaviour of a server which automatically defers acknowledgement to shutdown state change +//! @SYMTestActions 1.Create a thread and connect to the server with a domain Id and request for shutdown state change notification +//! 2.Delete the object, which automatically cancels the state change notification +//! 3.Check whether the test completes without any error +//! @SYMTestExpectedResults The test completes with error code, KErrNone + +START_TEST_BLOCK 100 tcmn_transitionmonitor z:\ssmatest\ssmatest_cmn_transitionmonitor.ini + CREATE_OBJECT CSsmStateAwareSession2 CSsmStateAwareSession2 + COMMAND CSsmStateAwareSession2 NewL + COMMAND CSsmStateAwareSession2 ReadIniData RequestAndCancel + COMMAND !AsyncError=0 CSsmStateAwareSession2 RequestStateNotification + COMMAND CSsmStateAwareSession2 ~ +END_TEST_BLOCK +END_TESTCASE DVS-SSMA-CMN-0022 diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_stateawaresession.script --- a/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_stateawaresession.script Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/scripts/ssmatest_cmn_stateawaresession.script Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -36,6 +36,8 @@ //! 7.Check OOM conditions for all leaving functions //! 8.Add subscribers using AddSubscriberL(). Check that upon notification NotifySubscribers() perfoms appropriate action. //! 9.Delete some of the subscribers using RemoveSubscriber(). Check that upon notification NotifySubscribers() performs appropriate action. +//! For CSsmDeferralMonitor: +//! 10.Create a CSsmDeferralMonitor object and call DeferNotification(). Then delete the object. //! @SYMTestExpectedResults The expected results are: //! The request is dealt appropriately resulting in the call to return: //! 1.Should return KDmErrBadDomainId @@ -47,5 +49,6 @@ //! 7.All allocated memory should be cleaned up either by the CleanupStack or by a destructor. //! 8.Added subscribers are notified appropriately //! 9.Subscribers are notified appropriately except those that were removed MStateChangeNotificationSubscriber +//! 10.The test should complete without any panics RUN_TEST_STEP 100 tcmn_server CmnStateAwareSessionStep END_TESTCASE DEVSRVS-SSMA-CMN-0005 \ No newline at end of file diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/src/t_ssmstatemanager.cpp --- a/sysstatemgmt/systemstatemgr/test/tcmn/src/t_ssmstatemanager.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/src/t_ssmstatemanager.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -278,7 +278,7 @@ INFO_PRINTF1(_L("RSsmStateManager->RunL()is called")); if (aActive == iActiveNotifyOnChange) { - TInt err=iActiveNotifyOnChange->iStatus.Int(); + TInt err=iActiveNotifyOnChange->iStatus.Int(); if ( err != KErrNone ) { ERR_PRINTF2(_L("RunL Error %d"), err); @@ -364,7 +364,31 @@ else if(!(aGetSubState.Compare(_L("ESsmNormalRfOnSubState")))) { aSubState = ESsmNormalRfOnSubState; - } + } + else if(!(aGetSubState.Compare(_L("ESsmShutdownSubStateCritical")))) + { + aSubState = ESsmShutdownSubStateCritical; + } + else if(!(aGetSubState.Compare(_L("ESsmShutdownSubStateNonCritical")))) + { + aSubState = ESsmShutdownSubStateNonCritical; + } + else if(!(aGetSubState.Compare(_L("ESsmShutdownSubStatePowerOff")))) + { + aSubState = ESsmShutdownSubStatePowerOff; + } + else if(!(aGetSubState.Compare(_L("ESsmShutdownSubStateReStart")))) + { + aSubState = ESsmShutdownSubStateReStart; + } + else if(!(aGetSubState.Compare(_L("ESsmFailSubStatePowerOff")))) + { + aSubState = ESsmFailSubStatePowerOff; + } + else if(!(aGetSubState.Compare(_L("KSsmAnySubState")))) + { + aSubState = KSsmAnySubState; + } else { ret = EFalse; diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/src/t_stateawaresession2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/src/t_stateawaresession2.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,273 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +//Contributors: +// +// Description: Test wrapper for CSsmStateAwareSession2 + +#include +#include +#include +#include +#include +#include "ssmsubstateext.hrh" + +#include "t_stateawaresession2.h" + +const TDmDomainId KTestDdmDomain = {KSM2AppServicesDomain3}; + +// +_LIT(KError, "error"); +_LIT(KAsyncIndex, "asyncIndex"); +_LIT(KAcknowledge, "acknowledge"); + +//commands +_LIT(KCmdNewL, "NewL"); +_LIT(KCmdReadIniData, "ReadIniData"); +_LIT(KCmdRequestStateNotification, "RequestStateNotification"); +_LIT(KCmdAcknowledgeStateNotification, "AcknowledgeStateNotification"); +_LIT(KCmdRequestStateNotificationCancel, "RequestStateNotificationCancel"); +_LIT(KCmdDestructor, "~"); + +/** + * Constructor + */ +TIniData3::TIniData3() + : iAcknowledge(ETrue) + , iAsyncIndex(0) + {} +/** +* @return pointer to the object that the data wraps +*/ +TAny* CTestCStateAwareSession::GetObject() + { + return iSsmStateAwareSession; + } + +/** + * SetObjectL + */ +void CTestCStateAwareSession::SetObjectL(TAny* aAny) + { + DoCleanup(); + iSsmStateAwareSession=static_cast (aAny); + } + +/** + * DisownObjectL + */ +void CTestCStateAwareSession::DisownObjectL() + { + iSsmStateAwareSession=NULL; + } + +/** + * Constructor. + */ +CTestCStateAwareSession::CTestCStateAwareSession(): +CDataWrapper() + { + } + +/** + * Destructor. + */ +CTestCStateAwareSession::~CTestCStateAwareSession() + { + DoCleanup(); + } + +/** + * Process a command read from the ini file + * + * @param aCommand the command to process + * @param aSection the entry in the ini file requiring the command to be processed + * + * @return ETrue if the command is processed + */ +TBool CTestCStateAwareSession::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) + { + TBool retVal = ETrue; + if (aCommand == KCmdNewL) + { + DoCmdNew(); + } + else if (aCommand == KCmdReadIniData) + { + DoCmdReadIniData(aSection); + } + else if (aCommand == KCmdAcknowledgeStateNotification) + { + DoCmdAcknowledgeStateNotification(aSection); + } + else if (aCommand == KCmdRequestStateNotification) + { + DoCmdRequestStateNotification(); + } + else if (aCommand == KCmdRequestStateNotificationCancel) + { + DoCmdRequestStateNotificationCancel(); + } + else if (aCommand == KCmdDestructor) + { + DoCmdDestructor(); + } + else + { + retVal = EFalse; + } + + return retVal; + } + +/** + * Creates CSsmStateAwareSession2 class instance + */ +void CTestCStateAwareSession::DoCmdNew() + { + INFO_PRINTF1(_L("Create CSsmStateAwareSession2 class instance")); + DoCleanup(); + + TRAPD(err, iSsmStateAwareSession = CSsmStateAwareSession2::NewL(KTestDdmDomain, *this)); + + if (err != KErrNone) + { + ERR_PRINTF2(_L("CSsmStateAwareSession2::NewL() error %d"), err); + SetError(err); + } + } + +/* + * Helper function to read ini file data + */ +void CTestCStateAwareSession::DoCmdReadIniData(const TDesC& aSection) + { + if( !GetIntFromConfig(aSection, KAsyncIndex(), iIniData.iAsyncIndex ) || + !GetBoolFromConfig(aSection, KAcknowledge(), iIniData.iAcknowledge ) ) + { + ERR_PRINTF1(_L("Error reading ini file data")); + SetError(KErrNotFound); + } + } + +/** + * Contains cleanup implementation + */ +void CTestCStateAwareSession::DoCleanup() + { + if(iSsmStateAwareSession != NULL) + { + INFO_PRINTF1(_L("Deleting current CSsmStateAwareSession2")); + delete iSsmStateAwareSession; + iSsmStateAwareSession = NULL; + } + } + +/** + * Destroy CSsmStateAwareSession2 object + */ +void CTestCStateAwareSession::DoCmdDestructor() + { + INFO_PRINTF1(_L("Destroying the CStateAwareSession2 object")); + DoCleanup(); + } + +/** + * DoCmdRequestStateNotification + */ +void CTestCStateAwareSession::DoCmdRequestStateNotification() + { + INFO_PRINTF1(_L("CTestCStateAwareSession: RequestStateNotification")); + iSsmStateAwareSession->RequestStateNotification(); + IncOutstanding(); + } + +/** + * DoCmdAcknowledgeStateNotification + */ +void CTestCStateAwareSession::DoCmdAcknowledgeStateNotification(const TDesC& aSection) + { + INFO_PRINTF1(_L("CTestCStateAwareSession: AcknowledgeStateNotification")); + TInt error; + if (!GetIntFromConfig(aSection, KError(), error )) + { + //set default error value if value is not provided in .ini file + error = KErrNone; + } + iSsmStateAwareSession->AcknowledgeStateNotification(error); + } + +/** + * DoCmdAcknowledgeAndRequestStateNotification + */ +void CTestCStateAwareSession::DoCmdAcknowledgeAndRequestStateNotification(const TDesC& aSection) + { + INFO_PRINTF1(_L("CTestCStateAwareSession: AcknowledgeAndRequestStateNotification")); + TInt error; + if (!GetIntFromConfig(aSection, KError(), error )) + { + //set default error value if value is not provided in .ini file + error = KErrNone; + } + iSsmStateAwareSession->AcknowledgeAndRequestStateNotification(error); + IncOutstanding(); + } + +/** + * DoCmdRequestStateNotificationCancel + */ +void CTestCStateAwareSession::DoCmdRequestStateNotificationCancel() + { + INFO_PRINTF1(_L("CTestCStateAwareSession: RequestStateNotificationCancel")); + iSsmStateAwareSession->RequestStateNotificationCancel(); + } + +/** + * HandleTransition + */ +void CTestCStateAwareSession::HandleTransition(TInt aError) + { + INFO_PRINTF1(_L("CTestCStateAwareSession::HandleTransition")); + TSsmState currentState; + currentState = iSsmStateAwareSession->GetState(); + TUint16 currentMainState = currentState.MainState(); + TUint16 currentSubState = currentState.SubState(); + if(currentMainState == ESsmShutdown && + currentSubState == ESsmShutdownSubStateCritical && + iIniData.iAcknowledge) + { + iSsmStateAwareSession->AcknowledgeStateNotification(aError); + } + } + +/** + * HandleDeferralError + */ +TInt CTestCStateAwareSession::HandleDeferralError(TInt aError) + { + INFO_PRINTF2(_L("CTestCStateAwareSession::HandleDeferralError error = %d"), aError); + RDebug::Printf("Entered CTestCStateAwareSession::HandleDeferralError() with error %d", aError); + TSsmState currentState; + currentState = iSsmStateAwareSession->GetState(); + TUint16 currentMainState = currentState.MainState(); + TUint16 currentSubState = currentState.SubState(); + if(currentMainState == ESsmShutdown && + currentSubState == ESsmNormalShutdown) + { + iSsmStateAwareSession->AcknowledgeAndRequestStateNotification(KErrNone); + IncOutstanding(); + } + else + { + SetAsyncError(iIniData.iAsyncIndex, aError); + } + DecOutstanding(); + return KErrNone; + } diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/src/t_stateawaresessionwrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/src/t_stateawaresessionwrapper.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,841 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +//Contributors: +// +// Description: Test wrapper for RSsmStateAwareSession + +#include +#include +#include +#include +#include +#include +#include + +#include "t_stateawaresessionwrapper.h" + +// +_LIT(KDomainId, "domainId"); +_LIT(KAcknowledge, "acknowledge"); +_LIT(KError, "error"); +_LIT(KCancelDeferral, "cancelDeferral"); +_LIT(KCount, "count"); +_LIT(KAckLastState, "ackLastState"); +_LIT(KDeferTwice, "deferTwice"); + +//commands +_LIT(KCmdNewL, "NewL"); +_LIT(KCmdConnect, "Connect"); +_LIT(KCmdReadIniData, "ReadIniData"); +_LIT(KCmdRequestStateNotification, "RequestStateNotification"); +_LIT(KCmdAcknowledgeStateNotification, "AcknowledgeStateNotification"); +_LIT(KCmdClose, "Close"); +_LIT(KCmdRequestStateNotificationCancel, "RequestStateNotificationCancel"); +_LIT(KCmdAcknowledgeAndRequestStateNotification, "AcknowledgeAndRequestStateNotification"); +_LIT(KCmdDeferAcknowledgement, "DeferAcknowledgement"); +_LIT(KCmdReturnCount, "ReturnCount"); +_LIT(KCmdDestructor, "~"); + +/** + * Helper method to map the DomainIds. + */ +static TBool MapToDomainId(TPtrC& aDomainIdName, TDmDomainId& aDomainId); + +/** + * Constructor + */ +TIniData1::TIniData1() + : iCancelDeferral(EFalse) + , iAckLastState(EFalse) + , iDeferTwice(EFalse) + , iCount(0) + , iAcknowledge(ETrue) + {} + +/** + * Constructor + */ +TIniData2::TIniData2() + : iCount(0) + , iAcknowledge(ETrue) + {} + +/** + * Two phase constructor + */ +CTestRStateAwareSession1* CTestRStateAwareSession1::NewL() + { + CTestRStateAwareSession1* testStateAwareSession = new (ELeave) CTestRStateAwareSession1(); + CleanupStack::PushL(testStateAwareSession); + testStateAwareSession->ConstructL(); + CleanupStack::Pop(testStateAwareSession); + return testStateAwareSession; + } + +/** +* @return pointer to the object that the data wraps +*/ +TAny* CTestRStateAwareSession1::GetObject() + { + return iSsmStateAwareSession; + } + +/** + * SetObjectL + */ +void CTestRStateAwareSession1::SetObjectL(TAny* aAny) + { + DoCleanup(); + iSsmStateAwareSession=static_cast (aAny); + } + +/** + * DisownObjectL + */ +void CTestRStateAwareSession1::DisownObjectL() + { + iSsmStateAwareSession=NULL; + } + +/** + * Protected constructor. First phase construction + */ +CTestRStateAwareSession1::CTestRStateAwareSession1(): +CDataWrapper() + { + } + +/** + * Protected constructor. Second phase construction + */ +void CTestRStateAwareSession1::ConstructL() + { + iActiveNotifyOnChange = CActiveCallback::NewL(*this); + iActiveNotifyOnChange2 = CActiveCallback::NewL(*this); + } + +/** + * Destructor. + */ +CTestRStateAwareSession1::~CTestRStateAwareSession1() + { + DoCleanup(); + delete iActiveNotifyOnChange; + delete iActiveNotifyOnChange2; + } + +/** + * Process a command read from the ini file + * + * @param aCommand the command to process + * @param aSection the entry in the ini file requiring the command to be processed + * + * @return ETrue if the command is processed + */ +TBool CTestRStateAwareSession1::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) + { + TBool retVal = ETrue; + if (aCommand == KCmdNewL) + { + DoCmdNew(); + } + else if (aCommand == KCmdConnect) + { + DoCmdConnect(aSection); + } + else if (aCommand == KCmdReadIniData) + { + DoCmdReadIniData(aSection); + } + else if (aCommand == KCmdRequestStateNotification) + { + DoCmdRequestStateNotification(aAsyncErrorIndex); + } + else if (aCommand == KCmdAcknowledgeStateNotification) + { + DoCmdAcknowledgeStateNotification(aSection); + } + else if (aCommand == KCmdClose) + { + DoCmdClose(); + } + else if (aCommand == KCmdRequestStateNotificationCancel) + { + DoCmdRequestStateNotificationCancel(); + } + else if (aCommand == KCmdAcknowledgeAndRequestStateNotification) + { + DoCmdAcknowledgeAndRequestStateNotification(aSection, aAsyncErrorIndex); + } + else if (aCommand == KCmdDeferAcknowledgement) + { + DoCmdDeferAcknowledgement( aAsyncErrorIndex); + } + else if (aCommand == KCmdReturnCount) + { + DoCmdReturnCount(aSection); + } + else if (aCommand == KCmdDestructor) + { + DoCmdDestructor(); + } + else + { + retVal = EFalse; + } + + return retVal; + } + +/** + * Creates RSSmStateAwareSession class instance + */ +void CTestRStateAwareSession1::DoCmdNew() + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: Create RSsmStateAwareSession class instance")); + DoCleanup(); + + TRAPD(err, iSsmStateAwareSession = new (ELeave)RSsmStateAwareSession()); + + if (err != KErrNone) + { + ERR_PRINTF2(_L("CTestRStateAwareSession1: new error %d"), err); + SetError(err); + } + } + +/** + * Close RSsmStateAwareSession handle + */ +void CTestRStateAwareSession1::DoCmdClose() + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: Close RSsmStateAwareSession")); + iSsmStateAwareSession->Close(); + } + +/** + * Contains cleanup implementation + */ +void CTestRStateAwareSession1::DoCleanup() + { + if(iSsmStateAwareSession != NULL) + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: Deleting current RSsmStateAwareSession")); + delete iSsmStateAwareSession; + iSsmStateAwareSession = NULL; + } + } + +/** + * Destroy RSsmStateAwareSession object + */ +void CTestRStateAwareSession1::DoCmdDestructor() + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: Destroying the RStateAwareSession object")); + DoCleanup(); + } + +/** + * Check whether the client is deferred expected no. of times + */ +void CTestRStateAwareSession1::DoCmdReturnCount(const TDesC& aSection) + { + TInt expectedCount = 0; + if ( !GetIntFromConfig(aSection, KCount(), expectedCount)) + { + ERR_PRINTF1(_L("CTestRStateAwareSession1: Error reading ini file data")); + SetError(KErrNotFound); + } + if (iCount == expectedCount) + return; + ERR_PRINTF3(_L("CTestRStateAwareSession1: Actual count = %d, Expected count = %d"), iCount, expectedCount); + SetError(KErrGeneral); + } + +/* + * Helper function to read ini file data + */ +void CTestRStateAwareSession1::DoCmdReadIniData(const TDesC& aSection) + { + if( !GetIntFromConfig(aSection, KCount(), iIniData.iCount) || + !GetBoolFromConfig(aSection, KCancelDeferral(), iIniData.iCancelDeferral) || + !GetBoolFromConfig(aSection, KAckLastState(), iIniData.iAckLastState) || + !GetBoolFromConfig(aSection, KDeferTwice(), iIniData.iDeferTwice) ) + { + ERR_PRINTF1(_L("CTestRStateAwareSession1: Error reading ini file data")); + SetError(KErrNotFound); + } + } + +/** + * Connects a client to RSsmStateAwareSession with Domain Id + */ +void CTestRStateAwareSession1::DoCmdConnect(const TDesC& aSection) + { + TPtrC domainIdName; + if (!GetStringFromConfig(aSection, KDomainId(), domainIdName)) + { + //set default domainId if value is not provided in .ini file + domainIdName.Set(_L("KSM2UiServicesDomain1")); + } + TDmDomainId domainId; + if(MapToDomainId(domainIdName, domainId )) + { + INFO_PRINTF2(_L("CTestRStateAwareSession1: Calling RSsmStateAwareSession->Connect with domain id %S"), &domainIdName ); + TInt err = iSsmStateAwareSession->Connect(domainId); + if (KErrNone != err) + { + ERR_PRINTF2(_L("CTestRStateAwareSession1: Connect() error %d"), err); + SetError(err); + } + } + else + { + ERR_PRINTF2(_L("CTestRStateAwareSession1: Could not map %S to domain Id"), &domainIdName ); + SetBlockResult(EFail); + } + } + +/** + * DoCmdRequestStateNotification + */ +void CTestRStateAwareSession1::DoCmdRequestStateNotification(const TInt aAsyncErrorIndex) + { + INFO_PRINTF2(_L("CTestRStateAwareSession1: RequestStateNotification with Async Error Index: %d"), aAsyncErrorIndex); + iSsmStateAwareSession->RequestStateNotification(iActiveNotifyOnChange->iStatus); + iActiveNotifyOnChange->Activate(aAsyncErrorIndex); + IncOutstanding(); + } + +/** + * DoCmdAcknowledgeStateNotification + */ +void CTestRStateAwareSession1::DoCmdAcknowledgeStateNotification(const TDesC& aSection) + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: AcknowledgeStateNotification")); + TInt error; + if (!GetIntFromConfig(aSection, KError(), error )) + { + //set default error value if value is not provided in .ini file + error = KErrNone; + } + iSsmStateAwareSession->AcknowledgeStateNotification(error); + } + +/** + * DoCmdAcknowledgeAndRequestStateNotification + */ +void CTestRStateAwareSession1::DoCmdAcknowledgeAndRequestStateNotification(const TDesC& aSection, const TInt aAsyncErrorIndex) + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: AcknowledgeAndRequestStateNotification")); + TInt error; + if (!GetIntFromConfig(aSection, KError(), error )) + { + //set default error value if value is not provided in .ini file + error = KErrNone; + } + iSsmStateAwareSession->AcknowledgeAndRequestStateNotification(error, iActiveNotifyOnChange->iStatus ); + iActiveNotifyOnChange->Activate(aAsyncErrorIndex); + IncOutstanding(); + } + +/** + * DoCmdRequestStateNotificationCancel + */ +void CTestRStateAwareSession1::DoCmdRequestStateNotificationCancel() + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: RequestStateNotificationCancel is called ")); + iSsmStateAwareSession->RequestStateNotificationCancel(); + } + +void CTestRStateAwareSession1::DoCmdDeferAcknowledgement(const TInt aAsyncErrorIndex) + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: DeferAcknowledgement is called")); + iSsmStateAwareSession->DeferAcknowledgement(iActiveNotifyOnChange->iStatus); + iActiveNotifyOnChange->Activate(aAsyncErrorIndex); + IncOutstanding(); + } + +void CTestRStateAwareSession1::RunL(CActive* aActive, TInt aIndex) + { + TInt error = KErrNone; + + if ( aActive == iActiveNotifyOnChange ) + { + error = iActiveNotifyOnChange->iStatus.Int(); + switch ( error ) + { + case KErrNone: + { + //Request has completed i.e. The member must either defer again or acknowledge. + TSsmState currentState = iSsmStateAwareSession->State(); + // This component only responds to Shutdown state events. + if ( (currentState.MainState() == ESsmShutdown) && + (currentState.SubState() == ESsmShutdownSubStateCritical || currentState.SubState() == ESsmShutdownSubStateNonCritical) ) + { + if( iCount < iIniData.iCount ) + { + iCount++; + iSsmStateAwareSession->DeferAcknowledgement(iActiveNotifyOnChange->iStatus); + iActiveNotifyOnChange->Activate(aIndex); + IncOutstanding(); + if( iIniData.iDeferTwice ) + { + iCount++; + iSsmStateAwareSession->DeferAcknowledgement(iActiveNotifyOnChange2->iStatus); + iActiveNotifyOnChange2->Activate(aIndex); + IncOutstanding(); + } + else if( iIniData.iAckLastState ) + { + iSsmStateAwareSession->AcknowledgeStateNotification(KErrNone); + } + else if( iIniData.iCancelDeferral ) + { + iSsmStateAwareSession->CancelDeferral(); + } + } + else + { + //Acknowledge with success + if (iIniData.iAcknowledge) + { + iSsmStateAwareSession->AcknowledgeStateNotification(KErrNone); + } + } + } + break; + } + default: + { + // Error + INFO_PRINTF2(_L("CTestRStateAwareSession1: Test returned with error = %d"),error); + SetAsyncError(aIndex, error); + } + } + } + else if ( aActive == iActiveNotifyOnChange2 ) + { + error = iActiveNotifyOnChange2->iStatus.Int(); + SetAsyncError(aIndex, error); + } + DecOutstanding(); + } + +/** + Virtual DoCancel - Request to cancel the asynchronous command + @see - MTPActiveCallback + @param aActive Active Object that DoCancel has been called on + @pre - N/A + @post - N/A + @leave system wide error code +*/ +void CTestRStateAwareSession1::DoCancel(CActive* aActive, TInt aIndex) + { + INFO_PRINTF1(_L("CTestRStateAwareSession1: DoCancel")); + if(aActive == iActiveNotifyOnChange) + { + TInt err = iActiveNotifyOnChange->iStatus.Int(); + if (err != KErrNone) + { + ERR_PRINTF2(_L("CTestRStateAwareSession1: DoCancel Error %d"), err); + SetAsyncError(aIndex, err); + } + } + else if(aActive == iActiveNotifyOnChange2) + { + TInt err = iActiveNotifyOnChange2->iStatus.Int(); + if (err != KErrNone) + { + ERR_PRINTF2(_L("CTestRStateAwareSession1: DoCancel Error %d"), err); + SetAsyncError(aIndex, err); + } + } + DecOutstanding(); + } + +/** + * Helper method to map the DomainIds. This can be extendable for other domain Ids + */ +static TBool MapToDomainId(TPtrC& aDomainIdName, TDmDomainId& aDomainId) + { + TBool ret = ETrue; + if (!(aDomainIdName.Compare(_L("KSM2UiServicesDomain1")))) + { + aDomainId = KSM2UiServicesDomain1; + } + else if (!(aDomainIdName.Compare(_L("KSM2HALDomain2")))) + { + aDomainId = KSM2HALDomain2; + } + else if (!(aDomainIdName.Compare(_L("KSM2HALDomain3")))) + { + aDomainId = KSM2HALDomain3; + } + else if (!(aDomainIdName.Compare(_L("KSM2AppServicesDomain1")))) + { + aDomainId = KSM2AppServicesDomain1; + } + else if (!(aDomainIdName.Compare(_L("KSM2AppServicesDomain2")))) + { + aDomainId = KSM2AppServicesDomain2; + } + else if (!(aDomainIdName.Compare(_L("KSM2AppServicesDomain3")))) + { + aDomainId = KSM2AppServicesDomain3; + } + else if (!(aDomainIdName.Compare(_L("KSM2AppServicesDomain4")))) + { + aDomainId = KSM2AppServicesDomain4; + } + else + { + ret = EFalse; + } + return ret; + } + + +/** + * Two phase constructor + */ +CTestRStateAwareSession2* CTestRStateAwareSession2::NewL() + { + CTestRStateAwareSession2* testStateAwareSession = new (ELeave) CTestRStateAwareSession2(); + CleanupStack::PushL(testStateAwareSession); + testStateAwareSession->ConstructL(); + CleanupStack::Pop(testStateAwareSession); + return testStateAwareSession; + } + +/** +* @return pointer to the object that the data wraps +*/ +TAny* CTestRStateAwareSession2::GetObject() + { + return iSsmStateAwareSession; + } + +/** + * SetObjectL + */ +void CTestRStateAwareSession2::SetObjectL(TAny* aAny) + { + DoCleanup(); + iSsmStateAwareSession=static_cast (aAny); + } + +/** + * DisownObjectL + */ +void CTestRStateAwareSession2::DisownObjectL() + { + iSsmStateAwareSession=NULL; + } + +/** + * Protected constructor. First phase construction + */ +CTestRStateAwareSession2::CTestRStateAwareSession2(): +CDataWrapper() + { + } + +/** + * Protected constructor. Second phase construction + */ +void CTestRStateAwareSession2::ConstructL() + { + iActiveNotifyOnChange = CActiveCallback::NewL(*this); + } + +/** + * Destructor. + */ +CTestRStateAwareSession2::~CTestRStateAwareSession2() + { + DoCleanup(); + delete iActiveNotifyOnChange; + } + +/** + * Process a command read from the ini file + * + * @param aCommand the command to process + * @param aSection the entry in the ini file requiring the command to be processed + * + * @return ETrue if the command is processed + */ +TBool CTestRStateAwareSession2::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) + { + TBool retVal = ETrue; + if (aCommand == KCmdNewL) + { + DoCmdNew(); + } + else if (aCommand == KCmdConnect) + { + DoCmdConnect(aSection); + } + else if (aCommand == KCmdReadIniData) + { + DoCmdReadIniData(aSection); + } + else if (aCommand == KCmdRequestStateNotification) + { + DoCmdRequestStateNotification(aAsyncErrorIndex); + } + else if (aCommand == KCmdAcknowledgeStateNotification) + { + DoCmdAcknowledgeStateNotification(aSection); + } + else if (aCommand == KCmdClose) + { + DoCmdClose(); + } + else if (aCommand == KCmdRequestStateNotificationCancel) + { + DoCmdRequestStateNotificationCancel(); + } + else if (aCommand == KCmdAcknowledgeAndRequestStateNotification) + { + DoCmdAcknowledgeAndRequestStateNotification(aSection, aAsyncErrorIndex); + } + else if (aCommand == KCmdDestructor) + { + DoCmdDestructor(); + } + else + { + retVal = EFalse; + } + + return retVal; + } + +/** + * Creates RSSmStateAwareSession class instance + */ +void CTestRStateAwareSession2::DoCmdNew() + { + INFO_PRINTF1(_L("CTestRStateAwareSession2: Create RSsmStateAwareSession class instance")); + DoCleanup(); + + TRAPD(err, iSsmStateAwareSession = new (ELeave)RSsmStateAwareSession()); + + if (err != KErrNone) + { + ERR_PRINTF2(_L("CTestRStateAwareSession2: new error %d"), err); + SetError(err); + } + } + +/** + * Close RSsmStateAwareSession handle + */ +void CTestRStateAwareSession2::DoCmdClose() + { + INFO_PRINTF1(_L("CTestRStateAwareSession2: Close RSsmStateAwareSession")); + iSsmStateAwareSession->Close(); + } + +/** + * Contains cleanup implementation + */ +void CTestRStateAwareSession2::DoCleanup() + { + if(iSsmStateAwareSession != NULL) + { + INFO_PRINTF1(_L("CTestRStateAwareSession2: Deleting current RSsmStateAwareSession")); + delete iSsmStateAwareSession; + iSsmStateAwareSession = NULL; + } + } + +/** + * Destroy RSsmStateAwareSession object + */ +void CTestRStateAwareSession2::DoCmdDestructor() + { + INFO_PRINTF1(_L("CTestRStateAwareSession2: Destroying the RStateAwareSession object")); + DoCleanup(); + } + +/** + * Connects a client to RSsmStateAwareSession with Domain Id + */ +void CTestRStateAwareSession2::DoCmdConnect(const TDesC& aSection) + { + TPtrC domainIdName; + if (!GetStringFromConfig(aSection, KDomainId(), domainIdName)) + { + //set default domainId if value is not provided in .ini file + domainIdName.Set(_L("KSM2UiServicesDomain1")); + } + TDmDomainId domainId; + if(MapToDomainId(domainIdName, domainId )) + { + INFO_PRINTF2(_L("CTestRStateAwareSession2: Calling RSsmStateAwareSession->Connect with domain id %S"), &domainIdName ); + TInt err = iSsmStateAwareSession->Connect(domainId); + if (KErrNone != err) + { + ERR_PRINTF2(_L("CTestRStateAwareSession2: Connect() error %d"), err); + SetError(err); + } + } + else + { + ERR_PRINTF2(_L("CTestRStateAwareSession2: Could not map %S to domain Id"), &domainIdName ); + SetBlockResult(EFail); + } + } + +/* + * Helper function to read ini file data + */ +void CTestRStateAwareSession2::DoCmdReadIniData(const TDesC& aSection) +{ + if( !GetIntFromConfig(aSection,KCount(), iIniData.iCount) || + !GetBoolFromConfig(aSection,KAcknowledge(), iIniData.iAcknowledge) ) + { + ERR_PRINTF1(_L("Error reading ini file data")); + SetError(KErrNotFound); + } +} + +/** + * DoCmdRequestStateNotification + */ +void CTestRStateAwareSession2::DoCmdRequestStateNotification(const TInt aAsyncErrorIndex) + { + INFO_PRINTF2(_L("CTestRStateAwareSession2: RequestStateNotification with Asyc Error Index: %d"), aAsyncErrorIndex); + iSsmStateAwareSession->RequestStateNotification(iActiveNotifyOnChange->iStatus); + iActiveNotifyOnChange->Activate(aAsyncErrorIndex); + IncOutstanding(); + } + +/** + * DoCmdAcknowledgeStateNotification + */ +void CTestRStateAwareSession2::DoCmdAcknowledgeStateNotification(const TDesC& aSection) + { + TInt error; + if (!GetIntFromConfig(aSection, KError(), error )) + { + //set default error value if value is not provided in .ini file + error = KErrNone; + } + iSsmStateAwareSession->AcknowledgeStateNotification(error); + } + +/** + * DoCmdAcknowledgeAndRequestStateNotification + */ +void CTestRStateAwareSession2::DoCmdAcknowledgeAndRequestStateNotification(const TDesC& aSection, const TInt aAsyncErrorIndex) + { + TInt error; + if (!GetIntFromConfig(aSection, KError(), error )) + { + //set default error value if value is not provided in .ini file + error = KErrNone; + } + iSsmStateAwareSession->AcknowledgeAndRequestStateNotification(error, iActiveNotifyOnChange->iStatus ); + iActiveNotifyOnChange->Activate(aAsyncErrorIndex); + IncOutstanding(); + } + +/** + * DoCmdRequestStateNotificationCancel + */ +void CTestRStateAwareSession2::DoCmdRequestStateNotificationCancel() + { + INFO_PRINTF1(_L("CTestRStateAwareSession2: RequestStateNotificationCancel is called ")); + iSsmStateAwareSession->RequestStateNotificationCancel(); + } + +/** + Virtual RunL - Called on completion of an asynchronous command + @see MTPActiveCallback + @param aActive Active Object that RunL has been called on + @pre N/A + @post N/A + @leave system wide error code +*/ +void CTestRStateAwareSession2::RunL(CActive* aActive, TInt aIndex) + { + TInt error = KErrNone; + + if (aActive == iActiveNotifyOnChange) + { + error = iActiveNotifyOnChange->iStatus.Int(); + if (error == KErrNone) + { + // Request has completed i.e. The member must either defer again or acknowledge. + TSsmState currentState = iSsmStateAwareSession->State(); + // This component only responds to Shutdown state events. + if ( (currentState.MainState() == ESsmShutdown) && + (currentState.SubState() == ESsmShutdownSubStateCritical || currentState.SubState() == ESsmShutdownSubStateNonCritical) ) + { + if(iCount < iIniData.iCount) + { + iCount++; + iSsmStateAwareSession->DeferAcknowledgement(iActiveNotifyOnChange->iStatus); + iActiveNotifyOnChange->Activate(aIndex); + IncOutstanding(); + } + else + { + //Acknowledge with success/failure + if (iIniData.iAcknowledge) + { + iSsmStateAwareSession->AcknowledgeStateNotification(KErrNone); + } + } + } + else + { + INFO_PRINTF1(_L("CTestRStateAwareSession2: Deferring acknowledgement for a state that doesn't support transition monitoring")); + iSsmStateAwareSession->DeferAcknowledgement(iActiveNotifyOnChange->iStatus); + iActiveNotifyOnChange->Activate(aIndex); + IncOutstanding(); + } + } + else + { + INFO_PRINTF2(_L("CTestRStateAwareSession2: RunL Error %d"), error); + SetAsyncError(aIndex, error); + } + } + DecOutstanding(); + } + +/** + Virtual DoCancel - Request to cancel the asynchronous command + @see - MTPActiveCallback + @param aActive Active Object that DoCancel has been called on + @pre - N/A + @post - N/A + @leave system wide error code +*/ +void CTestRStateAwareSession2::DoCancel(CActive* aActive, TInt aIndex) + { + INFO_PRINTF1(_L("CTestRStateAwareSession2: DoCancel")); + if(aActive == iActiveNotifyOnChange) + { + TInt err = iActiveNotifyOnChange->iStatus.Int(); + if (err!=KErrNone) + { + ERR_PRINTF2(_L("CTestRStateAwareSession2: DoCancel Error %d"), err); + SetAsyncError(aIndex, err); + } + } + DecOutstanding(); + } diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/src/tcmn_step_stateawaresession.cpp --- a/sysstatemgmt/systemstatemgr/test/tcmn/src/tcmn_step_stateawaresession.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/src/tcmn_step_stateawaresession.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -24,12 +24,21 @@ #include #include #include +#include +#include #include "ssmdebug.h" #include "cmnpanic.h" #include "ssmatest_utils.h" #include "tcmn_step_stateawaresession.h" #include "tssm_ssmclient.h" #include "tssm_startserver.h" + +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +#include "ssmstatemonitor.h" +#include "t_stateawaresession2.h" +#endif //SYMBIAN_INCLUDE_APP_CENTRIC +#endif //TEST_SSM_GRACEFUL_SHUTDOWN @@ -275,6 +284,34 @@ __UHEAP_MARKEND; } +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN +//This test is written for coverAGE purposes to call CSsmDeferralMonitor::DoCancel() API. +//The test is deemed to be successful if it completes without any panic. +void CCmnStateAwareSessionTest::doTestCSsmDeferralMonitorL() + { + //Create an active scheduler + CActiveScheduler* sched = new(ELeave) CActiveScheduler; + CleanupStack::PushL(sched); + CActiveScheduler::Install(sched); + //Create a CSsmDeferralMonitor object and call DeferNotification() + RSsmStateAwareSession rSas; + rSas.Connect(KTestDdmDomain); + CleanupClosePushL(rSas); + CTestCStateAwareSession* tSas = new (ELeave) CTestCStateAwareSession(); + CleanupStack::PushL(tSas); + CSsmStateAwareSession2 *cSas = CSsmStateAwareSession2::NewL(KTestDdmDomain, *tSas); + CleanupStack::PushL(cSas); + CSsmDeferralMonitor* aDm = new (ELeave) CSsmDeferralMonitor(rSas, *cSas); + CleanupStack::PushL(aDm); + //Call DeferNotification() so the active object becomes active + aDm->DeferNotification(); + //Destroy all objects. This will call the DoCancel() method of CSsmDeferralMonitor, which is what is intended here. + CleanupStack::PopAndDestroy(5); + } +#endif //SYMBIAN_INCLUDE_APP_CENTRIC +#endif //TEST_SSM_GRACEFUL_SHUTDOWN + //---------------------------------------------------------------- @@ -311,6 +348,11 @@ __UHEAP_MARK; doTestCSsmStateAwareSessionL(); doTestForMemoryLeaksL(); +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#ifdef TEST_SSM_GRACEFUL_SHUTDOWN + doTestCSsmDeferralMonitorL(); +#endif //SYMBIAN_INCLUDE_APP_CENTRIC +#endif //TEST_SSM_GRACEFUL_SHUTDOWN __UHEAP_MARKEND; INFO_PRINTF1(_L("....CCmnStateAwareSessionTest completed!")); diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/src/tcmn_transitionmonitor_server.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/src/tcmn_transitionmonitor_server.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,113 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: Test Server to test transition monitoring feature incase of state change to shutdown state +// + +/** + @file + @test + @internalComponent - Internal Symbian test code +*/ + + + +#include "tcmn_transitionmonitor_server.h" +#include "t_stateawaresessionwrapper.h" +#include "t_ssmstatemanager.h" +#include "t_stateawaresession2.h" + +_LIT(KTransitionMonitorServer, "TransitionMonitorServer"); +_LIT(KStateAwareSession1, "RSsmStateAwareSession1"); +_LIT(KStateAwareSession2, "RSsmStateAwareSession2"); +_LIT(KStateManager, "RSsmStateManager"); +_LIT(KStateAwareSession3, "CSsmStateAwareSession2"); + +CAwareSessionTestServer* CAwareSessionTestServer::NewL( ) + { + CAwareSessionTestServer* server = new (ELeave)CAwareSessionTestServer(); + CleanupStack::PushL(server); + server->ConstructL(); + CleanupStack::Pop(server); + return server; + } + +static void MainL() + { + CActiveScheduler* sched=new(ELeave) CActiveScheduler; + CActiveScheduler::Install(sched); + CAwareSessionTestServer* server = NULL; + TRAPD(err, server = CAwareSessionTestServer::NewL()); + if(!err) + { + RProcess::Rendezvous(KErrNone); + sched->Start(); + } + delete server; + delete sched; + } + +/** + Process entry point. Called by client using RProcess API + @return - Standard Epoc error code on process exit + */ +TInt E32Main(void) + { + CTrapCleanup* cleanup = CTrapCleanup::New(); + if(cleanup == NULL) + { + return KErrNoMemory; + } + TRAPD(err,MainL()); + if (err) + { + _LIT(KMainErrorStatement, "KTransitionMonitorServer::MainL - Error: %d"); + RDebug::Print(KMainErrorStatement, err); + User::Panic(KTransitionMonitorServer, err); + } + delete cleanup; + return KErrNone; + } + +CTestBlockController* CAwareSessionTestServer::CreateTestBlock() + { + CTestBlockController* controller = NULL; + TRAPD(err, (controller = new (ELeave) CAwareSessionTestBlock())); + if(KErrNone != err) + { + User::Panic(KTransitionMonitorServer, err); + } + return controller; + } + +CDataWrapper* CAwareSessionTestBlock::CreateDataL(const TDesC& aData) + { + // Print out the parameters for debugging + CDataWrapper* wrapper = NULL; + if ( KStateAwareSession1() == aData ) + { + wrapper = CTestRStateAwareSession1::NewL(); + } + else if ( KStateAwareSession2() == aData ) + { + wrapper = CTestRStateAwareSession2::NewL(); + } + else if ( KStateManager() == aData ) + { + wrapper = CTestRSsmStateManager::NewL(); + } + else if ( KStateAwareSession3() == aData) + { + wrapper = new (ELeave) CTestCStateAwareSession(); + } + return wrapper; + } diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tcmn/testdata/ssmatest_cmn_transitionmonitor.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/tcmn/testdata/ssmatest_cmn_transitionmonitor.ini Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,105 @@ + +[RSsmStateManager] +name = RSsmStateManager + +[RSsmStateAwareSession1] +name = RSsmStateAwareSession1 + +[RSsmStateAwareSession2] +name = RSsmStateAwareSession2 + +[CSsmStateAwareSession2] +name = CSsmStateAwareSession2 + +[Domain] +domainId=KSM2AppServicesDomain3 + +[ShutdownTransitionCriticalSubState] +mainState = ESsmShutdown +subState = ESsmShutdownSubStateCritical +reason = 0 +async = ETrue + +[ShutdownTransitionAnySubState] +mainState = ESsmShutdown +subState = KSsmAnySubState +reason = 0 +async = ETrue + +[FailTransitionAnySubState] +mainState = ESsmFail +subState = KSsmAnySubState +reason = 0 +async = ETrue + +[DeferAckn] +cancelDeferral = EFalse +count = 1 +ackLastState = EFalse +deferTwice = EFalse +acknowledge = ETrue + +[CancelDeferral] +cancelDeferral = ETrue +count = 1 +ackLastState = EFalse +deferTwice = EFalse +acknowledge = ETrue + +[NoAckn] +cancelDeferral = EFalse +count = 1 +ackLastState = EFalse +deferTwice = EFalse +acknowledge = EFalse + +[NoAckn2] +count = 0 +acknowledge = ETrue + +[MaxDefer] +cancelDeferral = EFalse +count = 2 +ackLastState = EFalse +deferTwice = EFalse +acknowledge = EFalse + +[DeferWoCap] +cancelDeferral = EFalse +count = 1 +ackLastState = EFalse +deferTwice = EFalse +acknowledge = EFalse + +[DeferTwice] +cancelDeferral = EFalse +count = 1 +ackLastState = EFalse +deferTwice = ETrue +acknowledge = EFalse + +[DeferTooEarly] +cancelDeferral = EFalse +count = 0 +ackLastState = EFalse +deferTwice = EFalse +acknowledge = EFalse + +[AckLastState] +cancelDeferral = EFalse +count = 1 +ackLastState = ETrue +deferTwice = EFalse +acknowledge = EFalse + +[DeferAutomatic] +asyncIndex = 6 +acknowledge = ETrue + +[MaxAutomaticDefer] +asyncIndex = 6 +acknowledge = EFalse + +[RequestAndCancel] +asyncIndex = 3 +acknowledge = EFalse \ No newline at end of file diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/testapps/group/bld.inf --- a/sysstatemgmt/systemstatemgr/test/testapps/group/bld.inf Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/testapps/group/bld.inf Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -35,6 +35,7 @@ ssmtestprocwritetime.mmp ssmcletestproc.mmp ssmcletestapplication.mmp +ssmtestprocgood1.mmp ssmstatetranfromnormalwocap.mmp PRJ_TESTEXPORTS diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/testapps/group/ssmtestprocgood.iby --- a/sysstatemgmt/systemstatemgr/test/testapps/group/ssmtestprocgood.iby Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/testapps/group/ssmtestprocgood.iby Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -17,5 +17,6 @@ #define __SSMTESTPROCGOOD_IBY__ file=ABI_DIR\BUILD_DIR\ssmtestprocgood.exe sys\bin\ssmtestprocgood.exe +file=ABI_DIR\BUILD_DIR\ssmtestprocgood1.exe sys\bin\ssmtestprocgood1.exe #endif // __SSMTESTPROCGOOD_IBY__ diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/testapps/group/ssmtestprocgood1.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysstatemgmt/systemstatemgr/test/testapps/group/ssmtestprocgood1.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -0,0 +1,38 @@ +// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +TARGET ssmtestprocgood1.exe +TARGETTYPE exe +TARGETPATH /sys/bin + +CAPABILITY None + +UID 0x0 0x2003458B +VENDORID 0x70000001 + +SOURCEPATH ../src +SOURCE ssmtestprocgood.cpp + +USERINCLUDE . +USERINCLUDE ../inc +USERINCLUDE ../../../inc + +OS_LAYER_SYSTEMINCLUDE_SYMBIAN + +LIBRARY euser.lib sysmoncli.lib ssmcmn.lib startupproperties.lib + + + +SMPSAFE diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tss/inc/tss_procstartmon.h --- a/sysstatemgmt/systemstatemgr/test/tss/inc/tss_procstartmon.h Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tss/inc/tss_procstartmon.h Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -47,7 +47,7 @@ public: void DoTestMonSyncL(); - void DoTestMonForAlreadyStartedProcL(); + void DoTestMonForAlreadyStartedProcL(const TDesC& aFileNameWithPath, const TDesC& aProcName); private: CActiveScheduler* iActiveScheduler; diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatemgr/test/tss/src/tss_procstartmon.cpp --- a/sysstatemgmt/systemstatemgr/test/tss/src/tss_procstartmon.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatemgr/test/tss/src/tss_procstartmon.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -31,6 +31,8 @@ const TInt KThrottleTime = 15000000; //15s const TInt KStartMonStopperTimeout = 5000000; // Could (probably) be shaved. +_LIT(KTestProcGoodFullPath, "z:\\sys\\bin\\ssmtestprocgood1.exe"); +_LIT(KTestProcName, "ssmtestprocgood1.exe"); TVerdict CSsTestStepProcStartMon::doTestStepL( void ) { @@ -41,10 +43,14 @@ __UHEAP_MARK; - TRAP(err, DoTestMonForAlreadyStartedProcL()); + TRAP(err, DoTestMonForAlreadyStartedProcL(KTestProcGoodFullPath, KTestProcName)); TEST(err == KErrNone); - INFO_PRINTF2(_L("DoTestMonForAlreadyStartedProcL completed with err = %d"), err); + INFO_PRINTF2(_L("DoTestMonForAlreadyStartedProcL using exe name with full path completed with err = %d"), err); + TRAP(err, DoTestMonForAlreadyStartedProcL(KTestProcGood, KTestProcGood)); + TEST(err == KErrNone); + INFO_PRINTF2(_L("DoTestMonForAlreadyStartedProcL using only exe name[without path] completed with err = %d"), err); + TRAP(err, DoTestMonSyncL()); TEST(err == KErrNone); INFO_PRINTF2(_L("DoTestMonSyncL completed with err = %d"), err); @@ -121,13 +127,13 @@ CleanupStack::PopAndDestroy( 4, startupProperties ); } -void CSsTestStepProcStartMon::DoTestMonForAlreadyStartedProcL() +void CSsTestStepProcStartMon::DoTestMonForAlreadyStartedProcL(const TDesC& aFileNameWithPath, const TDesC& aProcName) { INFO_PRINTF1( _L("Performing Process-monitor test for already started process") ); RProcess process; CleanupClosePushL(process); - User::LeaveIfError(process.Create(KTestProcGood, KLaunchServerCommandLineOption)); + User::LeaveIfError(process.Create(aProcName, KLaunchServerCommandLineOption)); TRequestStatus status; process.Rendezvous(status); @@ -151,7 +157,7 @@ CleanupStack::PushL( startupProperties ); // Need to start testprocess as a server so that we can tell it to stop being monitored. - startupProperties->SetFileParamsL(KTestProcGood, KLaunchServerCommandLineOption); + startupProperties->SetFileParamsL(aFileNameWithPath, KLaunchServerCommandLineOption); startupProperties->SetCommandTypeL(ESsmCmdStartProcess); startupProperties->SetExecutionBehaviour(ESsmWaitForSignal); @@ -201,7 +207,8 @@ testProcServerSession.CancelMonitor(); testProcServerSession.Close(); } - TEST(1 == FindAndKill(KTestProcGood)); + TEST(1 == FindAndKill(aProcName)); + CleanupStack::PopAndDestroy(3, &process); } diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatereferenceplugins/custcmd/group/customcmds.mmp --- a/sysstatemgmt/systemstatereferenceplugins/custcmd/group/customcmds.mmp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatereferenceplugins/custcmd/group/customcmds.mmp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -34,6 +34,11 @@ OS_LAYER_SYSTEMINCLUDE_SYMBIAN +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +// This system include will be removed/changed once the security driver code is exported to foundation. +SYSTEMINCLUDE NON_FOUNDATION_ADAPT_LAYER_SYSTEMINCLUDE +#endif + SOURCEPATH ../src SOURCE cmdsimsecuritycheck.cpp SOURCE cmddevicesecuritycheck.cpp diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatereferenceplugins/custcmd/inc/cmdcoopsysselftest.h --- a/sysstatemgmt/systemstatereferenceplugins/custcmd/inc/cmdcoopsysselftest.h Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatereferenceplugins/custcmd/inc/cmdcoopsysselftest.h Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -23,7 +23,12 @@ #define __CMDCOOPSYSSELFTEST_H__ #include +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +#include +#else #include +#endif //SYMBIAN_INCLUDE_APP_CENTRIC + NONSHARABLE_CLASS (CCustomCmdCoopSysSelfTest) : public CBase, public MSsmCustomCommand { @@ -42,7 +47,14 @@ ~CCustomCmdCoopSysSelfTest(); private: +//Read the selftest result from Security Driver if SYMBIAN_INCLUDE_APP_CENTRIC is enabled. +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC + RSecEnvLogicalChannel iSecEnvLogicalChannel; + TBool iSsmLoadSecLdd; + TSecSelfTest iParam; +#else RSsmStateAdaptation iSsmStateAdaptation; +#endif //SYMBIAN_INCLUDE_APP_CENTRIC }; #endif // __CMDCOOPSYSSELFTEST_H__ \ No newline at end of file diff -r d38941471f1c -r cb32bcc88bad sysstatemgmt/systemstatereferenceplugins/custcmd/src/cmdcoopsysselftest.cpp --- a/sysstatemgmt/systemstatereferenceplugins/custcmd/src/cmdcoopsysselftest.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/sysstatemgmt/systemstatereferenceplugins/custcmd/src/cmdcoopsysselftest.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -20,6 +20,11 @@ */ #include "cmdcoopsysselftest.h" +#include "ssmdebug.h" + +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC +_LIT( KSecEnvLogicalDeviceDriverName, "secldd" ); +#endif //SYMBIAN_INCLUDE_APP_CENTRIC CCustomCmdCoopSysSelfTest* CCustomCmdCoopSysSelfTest::NewL() { @@ -28,7 +33,10 @@ } CCustomCmdCoopSysSelfTest::CCustomCmdCoopSysSelfTest() - { +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC + : iSsmLoadSecLdd(EFalse) +#endif //SYMBIAN_INCLUDE_APP_CENTRIC + { } CCustomCmdCoopSysSelfTest::~CCustomCmdCoopSysSelfTest() @@ -37,17 +45,45 @@ TInt CCustomCmdCoopSysSelfTest::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/) { + TInt err = KErrNone; +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC + //Load the logical device. + err = User::LoadLogicalDevice(KSecEnvLogicalDeviceDriverName); + DEBUGPRINT2A("CCustomCmdCoopSysSelfTest: LoadLogicalDevice returned error %d", err); + iSsmLoadSecLdd = (KErrNone == err) ? ETrue : EFalse; + if ( KErrNone == err || KErrAlreadyExists == err ) + { + err = iSecEnvLogicalChannel.Open(); + DEBUGPRINT2A("CCustomCmdCoopSysSelfTest: Opening the Logical channel retured error %d", err); + } +#else //Connect RSsmStateAdaptation - return iSsmStateAdaptation.Connect(); + err = iSsmStateAdaptation.Connect(); +#endif //SYMBIAN_INCLUDE_APP_CENTRIC + return err; } void CCustomCmdCoopSysSelfTest::Close() { +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC + //Cancel the request if there is any + iSecEnvLogicalChannel.CancelRequest(KErrCancel); + //Close the channel. + iSecEnvLogicalChannel.Close(); + //Free the ldd if it is loaded by SSM selftest custom command. + if (iSsmLoadSecLdd) + { + //Ignore the error returned by unloading the logical device. + TInt err = User::FreeLogicalDevice(KSecEnvDriverName); + DEBUGPRINT2A("CCustomCmdCoopSysSelfTest: FreeLogicalDevice() returned error %d", err); + } +#else //Cancel the request if there is any iSsmStateAdaptation.RequestCancel(); - //Close RSsmStateAdaptation + // Close RSsmStateAdaptation iSsmStateAdaptation.Close(); +#endif //SYMBIAN_INCLUDE_APP_CENTRIC } void CCustomCmdCoopSysSelfTest::Release() @@ -57,12 +93,22 @@ void CCustomCmdCoopSysSelfTest::Execute(const TDesC8& /*aParams*/, TRequestStatus& aStatus) { - //Request coop system to perform self test +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC + iParam.iSelfTest = TSecSelfTest::ESelfTestSecurity; + iSecEnvLogicalChannel.ServiceRequest(aStatus, iParam); +#else +//Request coop system to perform self test iSsmStateAdaptation.RequestCoopSysSelfTest(aStatus); +#endif //SYMBIAN_INCLUDE_APP_CENTRIC + } void CCustomCmdCoopSysSelfTest::ExecuteCancel() { +#ifdef SYMBIAN_INCLUDE_APP_CENTRIC + iSecEnvLogicalChannel.CancelRequest(KErrCancel); +#else //Cancel the request if there is any iSsmStateAdaptation.RequestCancel(); +#endif //SYMBIAN_INCLUDE_APP_CENTRIC } diff -r d38941471f1c -r cb32bcc88bad systemhealthmanagement/systemhealthmgr/sysmonsrc/timerlist.cpp --- a/systemhealthmanagement/systemhealthmgr/sysmonsrc/timerlist.cpp Wed Sep 29 15:13:21 2010 +0300 +++ b/systemhealthmanagement/systemhealthmgr/sysmonsrc/timerlist.cpp Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -47,29 +47,36 @@ { CTimer::ConstructL(); } - + +static void DoCleanUp(TAny* aTimerInfo) + { + CTimerList::TTimerInfo* timerInfo = static_cast(aTimerInfo); + delete timerInfo; + timerInfo = NULL; + } + TInt32 CTimerList::AddL(const TTimeIntervalMicroSeconds32& aInterval, const TCallBack& aCallBack) { TTimerInfo* info = new(ELeave) TTimerInfo; - + CleanupStack::PushL(TCleanupItem(DoCleanUp, info)); info->iCallBack = aCallBack; info->iTime.UniversalTime(); info->iTime += TTimeIntervalMicroSeconds32(aInterval); AddL(info); - + CleanupStack::Pop(info); return reinterpret_cast(info); } TInt32 CTimerList::AddL(const TTime& aTime, const TCallBack& aCallBack) { TTimerInfo* info = new(ELeave) TTimerInfo; - + CleanupStack::PushL(TCleanupItem(DoCleanUp, info)); info->iCallBack = aCallBack; info->iTime = aTime; AddL(info); - + CleanupStack::Pop(info); return reinterpret_cast(info); } diff -r d38941471f1c -r cb32bcc88bad systemhealthmanagement/systemhealthmgr/sysmonsrc/timerlist.h --- a/systemhealthmanagement/systemhealthmgr/sysmonsrc/timerlist.h Wed Sep 29 15:13:21 2010 +0300 +++ b/systemhealthmanagement/systemhealthmgr/sysmonsrc/timerlist.h Fri Oct 08 14:33:25 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" @@ -43,14 +43,14 @@ TInt32 AddL(const TTime& aTime, const TCallBack& aCallBack); void Remove(TInt32 aTimer); -protected: class TTimerInfo { public: TTime iTime; TCallBack iCallBack; }; - + +protected: void RunL(); void ConstructL(); TInt RunError(TInt aError);