hwrmhaptics/tsrc/haptics_stif/src/hapticsclienttest.cpp
changeset 76 cb32bcc88bad
equal deleted inserted replaced
73:d38941471f1c 76:cb32bcc88bad
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "hapticsclienttest.h"
       
    20 #include <e32svr.h>
       
    21 #include <StifParser.h>
       
    22 #include <Stiftestinterface.h>
       
    23 #include <StifItemParser.h>
       
    24 #include <limits.h>
       
    25 #include "trace.h"
       
    26 
       
    27 // ---------------------------------------------------------
       
    28 // Couple of static TUint8 arrays containing bytes for simple
       
    29 // timeline and magsweep effects (that are used in PlayEffect
       
    30 // and PlayEffectRepeat method related tests below).
       
    31 // These are obtained using VibeTonz Studio's export to C-file
       
    32 // functionality. 
       
    33 // ---------------------------------------------------------
       
    34 static const TUint8 Timeline4HapticsMT_ivt[] = 
       
    35 {
       
    36     0x01, 0x00, 0x02, 0x00, 0x1c, 0x00, 0x28, 0x00, 0x00, 0x00, 0x07, 0x00, 0xf1, 0xe0, 0x01, 0xe2,
       
    37     0x00, 0x00, 0xff, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f,
       
    38     0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x12, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00, 0x65, 0x00,
       
    39     0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x67, 0x00,
       
    40     0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x00, 0x00
       
    41 };
       
    42 
       
    43 static const TUint8 Magsweep4HapticsMT_ivt[] = 
       
    44 {
       
    45     0x01, 0x00, 0x01, 0x00, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00,
       
    46     0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x81, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00,
       
    47     0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x00, 0x00
       
    48 };
       
    49 
       
    50 static const TUint8 Periodic4HapticsMT_ivt[] = 
       
    51 {
       
    52     0x01, 0x00, 0x01, 0x00, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00,
       
    53     0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00,
       
    54     0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x00, 0x00
       
    55 };
       
    56 
       
    57 //    | Object name | Type     | Duration | Magnitude | Period |
       
    58 //--------------------------------------------------------------
       
    59 // 1. | Timeline1   | Timeline | 3915     |           |        |
       
    60 // 2. | Timeline2   | Timeline | 5806     |           |        |
       
    61 // 3. | Periodic1   | Periodic | 1000     | 7480      | 100    |
       
    62 // 4. | Periodic2   | Periodic | 2000     | 7480      | 100    |
       
    63 // 5. | MagSweep1   | MagSweep | 3000     | 7480      |        |
       
    64 // 6. | MagSweep2   | MagSweep | 4000     | 7480      |        |
       
    65 // -------------------------------------------------------------
       
    66 static const TUint8 EffectSetMT_ivt[] = 
       
    67 {
       
    68     0x01, 0x00, 0x06, 0x00, 0x66, 0x00, 0x84, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x1a, 0x00, 0x2a, 0x00,
       
    69     0x3a, 0x00, 0x4a, 0x00, 0xf1, 0xe0, 0x02, 0xe2, 0x00, 0x00, 0xf1, 0xe0, 0x04, 0xe2, 0x03, 0x93,
       
    70     0xff, 0xf1, 0xe0, 0x03, 0xe2, 0x00, 0x00, 0xf1, 0xe0, 0x05, 0xe2, 0x07, 0x0e, 0xff, 0x30, 0xc8,
       
    71     0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x30, 0xc8,
       
    72     0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0x7d, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x01, 0x30, 0xc8,
       
    73     0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0xbb, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x81, 0x30, 0xc8,
       
    74     0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x20, 0xfa, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x01, 0x00, 0x00,
       
    75     0x14, 0x00, 0x28, 0x00, 0x3c, 0x00, 0x50, 0x00, 0x64, 0x00, 0x54, 0x00, 0x69, 0x00, 0x6d, 0x00,
       
    76     0x65, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x31, 0x00, 0x00, 0x00, 0x54, 0x00,
       
    77     0x69, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x65, 0x00, 0x32, 0x00,
       
    78     0x00, 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00,
       
    79     0x63, 0x00, 0x31, 0x00, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x6f, 0x00,
       
    80     0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x32, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x67, 0x00,
       
    81     0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x31, 0x00, 0x00, 0x00, 0x4d, 0x00,
       
    82     0x61, 0x00, 0x67, 0x00, 0x53, 0x00, 0x77, 0x00, 0x65, 0x00, 0x65, 0x00, 0x70, 0x00, 0x32, 0x00,
       
    83     0x00, 0x00
       
    84 };
       
    85 
       
    86 static const TUint8 CorruptedMT_ivt[] = 
       
    87 {
       
    88     0x00, 0x01, 0x01, 0x01, 0x12, 0x00, 0x14, 0x00, 0x00, 0x00, 0x30, 0xc8, 0x00, 0xc8, 0x00, 0x00,
       
    89     0x00, 0x00, 0x20, 0x3e, 0x00, 0x00, 0x5f, 0x81, 0x3e, 0x81, 0x00, 0x00, 0x50, 0x00, 0x65, 0x00,
       
    90     0x72, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x69, 0x00, 0x63, 0x00, 0x00, 0x00
       
    91 };
       
    92 
       
    93 //offset value for 
       
    94 const TInt KEventOffset = 1000;
       
    95 
       
    96 // imaginary license key
       
    97 _LIT8( KPlainKey,     "73JJNDJ38EKDKD983783JDJD84U48DJ4" );
       
    98 			
       
    99 // ---------------------------------------------------------
       
   100 // VibeStatus to S60 status mappings are tested by sending these
       
   101 // special repeat values to server (calling PlayEffectRepeat).
       
   102 // The test plugin will acknowledge these special values and 
       
   103 // returns corresponding VibeStatus error code..
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 enum repeat_values_4_vibestatustests
       
   107     {
       
   108     SUCCESS_TEST = 100,
       
   109     ALREADY_INITIALIZED_TEST,
       
   110     NOT_INITIALIZED_TEST,
       
   111     INVALID_ARGUMENT_TEST,
       
   112     FAIL_TEST,
       
   113     INCOMPATIBLE_EFFECT_TYPE_TEST,
       
   114     INCOMPATIBLE_CAPABILITY_TYPE_TEST,
       
   115     INCOMPATIBLE_PROPERTY_TYPE_TEST,
       
   116     DEVICE_NEEDS_LICENSE_TEST,
       
   117     NOT_ENOUGH_MEMORY_TEST,
       
   118     SERVICE_NOT_RUNNING_TEST,
       
   119     INSUFFICIENT_PRIORITY_TEST,
       
   120     SERVICE_BUSY_TEST,
       
   121     WRN_NOT_PLAYING_TEST,
       
   122     WRN_INSUFFICIENT_PRIORITY_TEST
       
   123     };
       
   124 
       
   125 
       
   126 // - Haptics status callback implementation ---------------------------------
       
   127 THapticsStatusCallback::THapticsStatusCallback( CHapticsClientTest* aMTCallback )
       
   128     : iHapticsStatus( MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ),
       
   129       iMTCallback( aMTCallback )
       
   130     {
       
   131     }
       
   132 
       
   133 THapticsStatusCallback::~THapticsStatusCallback()
       
   134     {
       
   135     }
       
   136 
       
   137 MHWRMHapticsObserver::THWRMHapticsStatus THapticsStatusCallback::Status()
       
   138     {
       
   139     return iHapticsStatus;
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------
       
   143 // from MHWRMHapticsObserver. Method which is called
       
   144 // by the haptics client, when the haptics status of
       
   145 // that client changes.
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 void THapticsStatusCallback::HapticsStatusChangedL( THWRMHapticsStatus aStatus )
       
   149     {
       
   150     iHapticsStatus = aStatus;
       
   151     
       
   152     // inform callback of new value
       
   153     iMTCallback->HapticsStatusReceived();
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------
       
   157 // from MHWRMHapticsObserver. Method is for future use,
       
   158 // hence the empty implementation.
       
   159 // ---------------------------------------------------------
       
   160 //
       
   161 void THapticsStatusCallback::EffectCompletedL( TInt /*aError*/, TInt /*aEffectHandle*/ )
       
   162     {
       
   163     }
       
   164 
       
   165 
       
   166 // - Actuator status callback implementation ---------------------------------
       
   167 TActuatorStatusCallback::TActuatorStatusCallback( CHapticsClientTest* aMTCallback ) : iMTCallback( aMTCallback ) 
       
   168     {
       
   169     }
       
   170 
       
   171 TActuatorStatusCallback::~TActuatorStatusCallback()
       
   172     {
       
   173     iActuatorStatus.Close();
       
   174     }
       
   175 
       
   176 MHWRMHapticsActuatorObserver::THWRMActuatorEvents TActuatorStatusCallback::Status( THWRMLogicalActuators aActuator )
       
   177     {
       
   178     TInt index = iActuatorStatus.Find( aActuator );
       
   179     if ( index == KErrNotFound )
       
   180         {
       
   181         return (MHWRMHapticsActuatorObserver::THWRMActuatorEvents)0;
       
   182         }        
       
   183     return (MHWRMHapticsActuatorObserver::THWRMActuatorEvents)(iActuatorStatus[index+1]-KEventOffset);
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------
       
   187 // from MHWRMHapticsObserver. Method which is called
       
   188 // by the haptics client, when the haptics status of
       
   189 // that client changes.
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 void TActuatorStatusCallback::ActuatorEventL( THWRMActuatorEvents aEvent,
       
   193                                               THWRMLogicalActuators aActuator )
       
   194     {
       
   195     TInt index = iActuatorStatus.Find( aActuator );
       
   196     if ( index == KErrNotFound )
       
   197         {
       
   198         iActuatorStatus.Append( aActuator );
       
   199         iActuatorStatus.Append( aEvent + KEventOffset );
       
   200         }
       
   201     else
       
   202         {
       
   203         iActuatorStatus.Remove( index );
       
   204         iActuatorStatus.Remove( index );
       
   205         iActuatorStatus.Append( aActuator );
       
   206         iActuatorStatus.Append( aEvent + KEventOffset );
       
   207         }
       
   208     
       
   209     // inform callback of new value
       
   210     iMTCallback->HapticsStatusReceived();
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------
       
   214 // MT_HapticsTestAsyncPlaySender methods
       
   215 // ---------------------------------------------------------
       
   216 //
       
   217 MT_HapticsTestAsyncPlaySender::MT_HapticsTestAsyncPlaySender(
       
   218     CHapticsClientTest* aMTCallback ) 
       
   219     : CActive( EPriorityStandard ), iMTCallback( aMTCallback )
       
   220     {
       
   221     CActiveScheduler::Add( this );
       
   222     }
       
   223 
       
   224 MT_HapticsTestAsyncPlaySender::~MT_HapticsTestAsyncPlaySender()
       
   225     {
       
   226     }
       
   227 
       
   228 void MT_HapticsTestAsyncPlaySender::PlayRepeat( 
       
   229     CHWRMHaptics* aHaptics,
       
   230     TInt  aFileHandle,
       
   231     TInt aEffectIndex,
       
   232     TUint8 aRepeat,
       
   233     TInt& aEffectHandle,
       
   234     TRequestStatus& aClientStatus )
       
   235     {
       
   236     aClientStatus = KRequestPending;
       
   237     iClientStatus = &aClientStatus;
       
   238     aHaptics->PlayEffectRepeat( aFileHandle, 
       
   239                                 aEffectIndex,
       
   240                                 aRepeat,
       
   241                                 aEffectHandle,
       
   242                                 iStatus );
       
   243     SetActive();  
       
   244     }
       
   245 
       
   246 void MT_HapticsTestAsyncPlaySender::Play( 
       
   247         CHWRMHaptics* aHaptics,
       
   248        TInt  aFileHandle,
       
   249        TInt aEffectIndex,
       
   250        TInt& aEffectHandle,
       
   251        TRequestStatus& aClientStatus )
       
   252     {
       
   253     aClientStatus = KRequestPending;
       
   254     iClientStatus = &aClientStatus;
       
   255     aHaptics->PlayEffect( aFileHandle, 
       
   256                           aEffectIndex,
       
   257                           aEffectHandle,
       
   258                           iStatus );
       
   259     SetActive();
       
   260     }
       
   261 
       
   262 void MT_HapticsTestAsyncPlaySender::RunL()
       
   263     {
       
   264     *iClientStatus = iStatus.Int();
       
   265     iMTCallback->HapticsStatusReceived();
       
   266     }
       
   267 
       
   268 void MT_HapticsTestAsyncPlaySender::DoCancel()
       
   269     {
       
   270     }
       
   271 
       
   272 TInt MT_HapticsTestAsyncPlaySender::RunError( TInt /* aError */ )
       
   273     {
       
   274     return KErrNone;
       
   275     }
       
   276        
       
   277 // - Construction -----------------------------------------------------------
       
   278 
       
   279 void CHapticsClientTest::BuildL ()
       
   280     {
       
   281     iSender = new ( ELeave ) MT_HapticsTestAsyncPlaySender( this );
       
   282     }
       
   283 
       
   284 void CHapticsClientTest::Delete ()
       
   285     {
       
   286     delete iSender;
       
   287     }
       
   288 	
       
   289 // -----------------------------------------------------------------------------
       
   290 // CHapticsClientTest::RunMethodL
       
   291 // Run specified method. Contains also table of test mothods and their names.
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 TInt CHapticsClientTest::RunMethodL( 
       
   295     CStifItemParser& aItem ) 
       
   296     {
       
   297 
       
   298     static TStifFunctionInfo const KFunctions[] =
       
   299         {  
       
   300         // Copy this line for every implemented function.
       
   301         // First string is the function name used in TestScripter script file.
       
   302         // Second is the actual implementation member function. 
       
   303         ENTRY( "Setup", CHapticsClientTest::SetupL ),
       
   304         ENTRY( "Teardown", CHapticsClientTest::Teardown ),
       
   305 		ENTRY( "CreateAndDestroy", CHapticsClientTest::T_CreateAndDeleteL ),
       
   306 		ENTRY( "SeveralSessions", CHapticsClientTest::T_SeveralSessionsL ),
       
   307 		ENTRY( "ConsecutiveSessions", CHapticsClientTest::T_ConsecutiveSessionsL ),
       
   308 		ENTRY( "SupportedActuators", CHapticsClientTest::T_SupportedActuators ),
       
   309 		ENTRY( "OpenSupportedActuator", CHapticsClientTest::T_OpenSupportedActuator ),
       
   310 		ENTRY( "OpenUnsupportedActuator", CHapticsClientTest::T_OpenNotSupportedActuator ),
       
   311 		ENTRY( "OpenAllActuators", CHapticsClientTest::T_OpenAllActuators ),
       
   312 		ENTRY( "2ClientsOpenActuators", CHapticsClientTest::T_SeveralClientsWithOpenActuatorsL ),
       
   313 		ENTRY( "PlayMagSweepSynchData", CHapticsClientTest::T_PlayMagSweepEffectSynchronous ),
       
   314 		ENTRY( "PlayMagSweepAsynchData", CHapticsClientTest::T_PlayMagSweepEffectAsynchronous ),
       
   315 		ENTRY( "PlayPeriodicSynchData", CHapticsClientTest::T_PlayPeriodicEffectSynchronous ),
       
   316 		ENTRY( "PlayPeriodicAsynchData", CHapticsClientTest::T_PlayPeriodicEffectAsynchronous ),
       
   317 		ENTRY( "PlayIVTSynchData", CHapticsClientTest::T_PlayIVTEffectWithDirectDataSynchronous ),
       
   318 		ENTRY( "PlayIVTAsynchData", CHapticsClientTest::T_PlayIVTEffectWithDirectDataAsynchronous ),
       
   319 		ENTRY( "RepeatIVTSynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataSynchronous ),
       
   320 		ENTRY( "RepeatIVTAsynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataAsynchronous ),
       
   321 		ENTRY( "GetEffectState", CHapticsClientTest::T_GetEffectState ),
       
   322 		ENTRY( "RepeatIVTSynchDataNonTimeline", CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous ),
       
   323 		ENTRY( "RepeatIVTAsynchDataNonTimeline", CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous ),
       
   324 		ENTRY( "Zero-repeatIVTSynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous ),
       
   325 		ENTRY( "Zero-repeatIVTAsynchData", CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous ),  
       
   326 		ENTRY( "LoadIVTData", CHapticsClientTest::T_LoadIVTData ),
       
   327 		ENTRY( "DeleteIVTData", CHapticsClientTest::T_DeleteIVTData ),
       
   328 		ENTRY( "DeleteAllIVTData", CHapticsClientTest::T_DeleteAllIVTData ),
       
   329 		ENTRY( "LoadAndDeleteMultiple", CHapticsClientTest::T_LoadAndDeleteIVTData ),
       
   330 		ENTRY( "LoadAndDeleteMixed", CHapticsClientTest::T_LoadAndDeleteIVTDataMixed ),
       
   331 		ENTRY( "LoadDeletePlaySync", CHapticsClientTest::T_LoadDeletePlaySync ),
       
   332 		ENTRY( "LoadDeletePlayAsync", CHapticsClientTest::T_LoadDeletePlayAsync ),
       
   333 		ENTRY( "LoadDeletePlayRepeatSync", CHapticsClientTest::T_LoadDeletePlayRepeatSync ),
       
   334 		ENTRY( "LoadDeletePlayRepeatAsync", CHapticsClientTest::T_LoadDeletePlayRepeatAsync ),
       
   335 		ENTRY( "PlayLoadedIVTSynch", CHapticsClientTest::T_PlayIVTEffectWithLoadedDataSynchronous ),
       
   336 		ENTRY( "PlayLoadedIVTAsynch", CHapticsClientTest::T_PlayIVTEffectWithLoadedDataAsynchronous ),
       
   337 		ENTRY( "RepeatLoadedIVTSynch", CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataSynchronous ),
       
   338 		ENTRY( "RepeatLoadedIVTAsynch", CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataAsynchronous ),
       
   339 		ENTRY( "LoadMultipleIVT-data", CHapticsClientTest::T_LoadMultipleIVTData ),
       
   340 		ENTRY( "PlayFromMultipleIVT-dataSynch", CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataSynchronous ),
       
   341 		ENTRY( "PlayFromMultipleIVT-dataAsynch", CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataAsynchronous ),
       
   342 		ENTRY( "PlayRepeatFromMultipleIVT-dataSynch", CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous ),
       
   343 		ENTRY( "PlayRepeatFromMultipleIVT-dataAsynch", CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous ),
       
   344 		ENTRY( "StatusConversions", CHapticsClientTest::T_VibeStatusToS60StatusConversions ),
       
   345 		ENTRY( "ReserveAndRelease", CHapticsClientTest::T_ReserveAndReleaseHaptics ),
       
   346 		ENTRY( "ReserveSeveralTimes", CHapticsClientTest::T_ReserveHapticsSeveralTimes ),
       
   347 		ENTRY( "ReserveNoRelease", CHapticsClientTest::T_ReserveHapticsNoReleaseL ),
       
   348 		ENTRY( "ReleaseNoReserve", CHapticsClientTest::T_ReleaseHapticsWithoutReservingFirst ),
       
   349 		ENTRY( "ReserveForceNoCoe", CHapticsClientTest::T_ReserveNoAutomaticFocusNotTrusted ),
       
   350 		ENTRY( "ReserveReservedHigher", CHapticsClientTest::T_ReserveAlreadyReservedHigherL ),
       
   351 		ENTRY( "ReserveReservedLower", CHapticsClientTest::T_ReserveAlreadyReservedLowerL ),
       
   352 		ENTRY( "PlayWhenReserved", CHapticsClientTest::T_PlayWhenReservedL ),
       
   353 		ENTRY( "GetEffectCount", CHapticsClientTest::T_GetIVTEffectCount ),
       
   354 		ENTRY( "GetEffectDuration", CHapticsClientTest::T_GetIVTEffectDuration ),
       
   355 		ENTRY( "GetEffectIndexFromName", CHapticsClientTest::T_GetIVTEffectIndexFromName ),
       
   356 		ENTRY( "GetEffectType", CHapticsClientTest::T_GetIVTEffectType ),
       
   357 		ENTRY( "GetEffectName", CHapticsClientTest::T_GetIVTEffectName ),
       
   358 		ENTRY( "GetMagSweepEffectDefinition", CHapticsClientTest::T_GetIVTMagSweepEffectDefinition ),
       
   359 		ENTRY( "GetPeriodicEffectDefinition", CHapticsClientTest::T_GetIVTPeriodicEffectDefinition ),
       
   360 		ENTRY( "CreateAndDestroyAsynchronous", CHapticsClientTest::T_CreateAndDeleteAsynchronousL ),
       
   361 		ENTRY( "SeveralSessionsAsynchronous", CHapticsClientTest::T_SeveralSessionsAsynchronousL ),
       
   362 		ENTRY( "ConsecutiveSessionsAsynchronous", CHapticsClientTest::T_ConsecutiveSessionsAsynchronousL),
       
   363 		ENTRY( "ConstantGetters", CHapticsClientTest::T_ConstantGetters ),
       
   364 		ENTRY( "PauseEffect", CHapticsClientTest::T_PauseEffect ),
       
   365 		ENTRY( "ResumeEffect", CHapticsClientTest::T_ResumeEffect),
       
   366 		ENTRY( "StopEffect", CHapticsClientTest::T_StopEffect),
       
   367 		ENTRY( "StopAllEffects", CHapticsClientTest::T_StopAllEffects ),
       
   368 		ENTRY( "PlayPauseResumeStop", CHapticsClientTest::T_PlayPauseResumeStop),
       
   369 		ENTRY( "ModifyPlayingMagsweepEffectSynchronous", CHapticsClientTest::T_ModifyMagSweepEffectSynchronous ),
       
   370 		ENTRY( "ModifyPlayingMagsweepEffectAsynchronous", CHapticsClientTest::T_ModifyMagSweepEffectAsynchronous ),
       
   371 		ENTRY( "ModifyPlayingPeriodicEffectSynchronous", CHapticsClientTest::T_ModifyPeriodicEffectSynchronous ),
       
   372 		ENTRY( "ModifyPlayingPeriodicEffectAsynchronous", CHapticsClientTest::T_ModifyPeriodicEffectAsynchronous ),
       
   373 		ENTRY( "GetDevicePropertyOfTIntValue", CHapticsClientTest::T_GetDeviceProperty_TInt_TInt ),
       
   374 		ENTRY( "GetDevicePropertyOfTDesCValue", CHapticsClientTest::T_GetDeviceProperty_TInt_TDesC ),
       
   375 		ENTRY( "SetDevicePropertyOfTIntValue", CHapticsClientTest::T_SetDeviceProperty_TInt_TInt ),
       
   376 		ENTRY( "SetDevicePropertyOfTDesCValue", CHapticsClientTest::T_SetDeviceProperty_TInt_TDesC ),    
       
   377 		ENTRY( "GetDeviceCapabilityOfTIntValue", CHapticsClientTest::T_GetDeviceCapability_TInt_TInt ),
       
   378 		ENTRY( "GetDeviceCapabilityOfTDesCValue", CHapticsClientTest::T_GetDeviceCapability_TInt_TDesC ),
       
   379 		ENTRY( "FetchStatus", CHapticsClientTest::T_GetHapticsStatus ),
       
   380 		ENTRY( "ObserveStatus", CHapticsClientTest::T_ObserveHapticsStatus ),
       
   381 		ENTRY( "StatusReservation", CHapticsClientTest::T_GetHapticsStatusWithReservations ),
       
   382 		ENTRY( "StatusObserveReservation", CHapticsClientTest::T_ObserveHapticsStatusWithReservations ),
       
   383 		ENTRY( "Status2Reservations", CHapticsClientTest::T_GetHapticsStatusWithSeveralReservations ),
       
   384 		ENTRY( "StatusObserve2Reservation", CHapticsClientTest::T_ObserveHapticsStatusWithSeveralReservations ),
       
   385 		ENTRY( "StatusManyClients", CHapticsClientTest::T_GetHapticsStatusWithSeveralClientsOneReservation ),
       
   386 		ENTRY( "StatusObserverManyClients", CHapticsClientTest::T_ObserveHapticsStatusWithSeveralClientsOneReservations ),
       
   387 		ENTRY( "CreateStreamingEffect", CHapticsClientTest::T_CreateStreamingEffect ),
       
   388 		ENTRY( "PlayStreamingSample", CHapticsClientTest::T_PlayStreamingSample),
       
   389 		ENTRY( "PlayStreamingSampleAsync", CHapticsClientTest::T_PlayStreamingSampleAsync),
       
   390 		ENTRY( "PlayStreamingSampleWithOffset", CHapticsClientTest::T_PlayStreamingSampleWithOffset),
       
   391 		ENTRY( "PlayStreamingSampleWithOffsetAsync", CHapticsClientTest::T_PlayStreamingSampleWithOffsetAsync),
       
   392 		ENTRY( "DestroyStreamingEffect", CHapticsClientTest::T_DestroyStreamingEffect),
       
   393 		ENTRY( "ActuatorStatus", CHapticsClientTest::T_ObserveActuatorStatus),
       
   394 		ENTRY( "ActuatorOrHapticsStatus", CHapticsClientTest::T_ObserveActuatorStatusAndHapticsStatus),
       
   395 		ENTRY( "PluginMgrTransTimerExpires", CHapticsClientTest::T_PluginMgrTransTimerExpires),
       
   396         };
       
   397 
       
   398     const TInt count = sizeof( KFunctions ) / 
       
   399                         sizeof( TStifFunctionInfo );
       
   400 
       
   401     return RunInternalL( KFunctions, count, aItem );
       
   402     
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------
       
   406 // Method, which is called by the status callback, when a status
       
   407 // has been received. Stops the wait loop waiting for a new status.
       
   408 // ---------------------------------------------------------
       
   409 //
       
   410 void CHapticsClientTest::HapticsStatusReceived()
       
   411     {
       
   412     iWait.AsyncStop();
       
   413     }
       
   414 	
       
   415 // - Test methods -----------------------------------------------------------
       
   416 
       
   417 // ---------------------------------------------------------
       
   418 // Default test env construction
       
   419 // ---------------------------------------------------------
       
   420 //
       
   421 TInt CHapticsClientTest::SetupL()
       
   422     {
       
   423     iHaptics = CHWRMHaptics::NewL( NULL, NULL );
       
   424     return KErrNone;
       
   425     }
       
   426 
       
   427 // ---------------------------------------------------------
       
   428 // Default test env destruction
       
   429 // ---------------------------------------------------------
       
   430 //
       
   431 TInt CHapticsClientTest::Teardown()
       
   432     {
       
   433     if( iHaptics )
       
   434         {
       
   435         delete iHaptics;
       
   436         iHaptics = NULL;
       
   437         }
       
   438     return KErrNone;
       
   439     }
       
   440     
       
   441 // ---------------------------------------------------------
       
   442 // Helper methods for creating various effects
       
   443 // ---------------------------------------------------------
       
   444 //
       
   445 void CHapticsClientTest::CreateMagSweepEffect( CHWRMHaptics::THWRMHapticsMagSweepEffect& aEffect )
       
   446     {
       
   447     aEffect.iDuration    = 1000;
       
   448     aEffect.iMagnitude   = 5000;
       
   449     aEffect.iStyle       = CHWRMHaptics::EHWRMHapticsStyleSharp;
       
   450     aEffect.iAttackTime  = 0;
       
   451     aEffect.iAttackLevel = 0;
       
   452     aEffect.iFadeTime    = 0;
       
   453     aEffect.iFadeLevel   = 0;
       
   454     }
       
   455 
       
   456 void CHapticsClientTest::CreatePeriodicEffect( CHWRMHaptics::THWRMHapticsPeriodicEffect& aEffect )
       
   457     {
       
   458     aEffect.iDuration    = 1000;
       
   459     aEffect.iMagnitude   = 5000;
       
   460     aEffect.iPeriod      = 100;
       
   461     aEffect.iStyle       = CHWRMHaptics::EHWRMHapticsStyleSharp;
       
   462     aEffect.iAttackTime  = 0;
       
   463     aEffect.iAttackLevel = 0;
       
   464     aEffect.iFadeTime    = 0;
       
   465     aEffect.iFadeLevel   = 0;
       
   466     }
       
   467 
       
   468 void CHapticsClientTest::CreateIVTEffect( RBuf8& aBuffer, CHWRMHaptics::THWRMHapticsEffectTypes aType)
       
   469     {
       
   470     // Note: only magsweep and timeline IVT effects supported so far..
       
   471     switch ( aType )
       
   472         {
       
   473         case CHWRMHaptics::EHWRMHapticsTypePeriodic:
       
   474             {
       
   475             aBuffer.ReAlloc( sizeof( Periodic4HapticsMT_ivt ) );
       
   476             TUint8* tmpPtr = const_cast<TUint8*>( aBuffer.Ptr() );
       
   477             memcpy( tmpPtr, Periodic4HapticsMT_ivt, sizeof( Periodic4HapticsMT_ivt ) );
       
   478             aBuffer.SetLength( sizeof( Periodic4HapticsMT_ivt ) );
       
   479             break;  
       
   480             }
       
   481         case CHWRMHaptics::EHWRMHapticsTypeMagSweep:
       
   482             {
       
   483             aBuffer.ReAlloc( sizeof( Magsweep4HapticsMT_ivt ) );
       
   484             TUint8* tmpPtr = const_cast<TUint8*>( aBuffer.Ptr() );
       
   485             memcpy( tmpPtr, Magsweep4HapticsMT_ivt, sizeof( Magsweep4HapticsMT_ivt ) );
       
   486             aBuffer.SetLength( sizeof( Magsweep4HapticsMT_ivt ) );
       
   487             break;
       
   488             }
       
   489         case CHWRMHaptics::EHWRMHapticsTypeTimeline:
       
   490             {
       
   491             aBuffer.ReAlloc( sizeof( Timeline4HapticsMT_ivt ) );
       
   492             TUint8* tmpPtr = const_cast<TUint8*>( aBuffer.Ptr() );
       
   493             memcpy( tmpPtr, Timeline4HapticsMT_ivt, sizeof( Timeline4HapticsMT_ivt ) );
       
   494             aBuffer.SetLength( sizeof( Timeline4HapticsMT_ivt ) );
       
   495             break;  
       
   496             }
       
   497         default:
       
   498             break; // no support for other types at the moment
       
   499         }
       
   500     }
       
   501 
       
   502 
       
   503 void CHapticsClientTest::CreateDummyStreamSample( TInt aSize, RBuf8& aBuffer )
       
   504     {
       
   505     aBuffer.ReAlloc( aSize );
       
   506     TUint8* tmpPtr = const_cast<TUint8*>( aBuffer.Ptr() );
       
   507     memset( tmpPtr, 0x00, aSize );
       
   508     aBuffer.SetLength( aSize );
       
   509     }
       
   510 
       
   511 // ---------------------------------------------------------
       
   512 // Open and close haptics client-server session, i.e.
       
   513 // create and delete haptics client.
       
   514 // ---------------------------------------------------------
       
   515 //
       
   516 TInt CHapticsClientTest::T_CreateAndDeleteL()
       
   517     {
       
   518     // create iHaptics instance without observers
       
   519     iHaptics = CHWRMHaptics::NewL( NULL, NULL );
       
   520 
       
   521     // the connection has been opened successfully, if iHaptics is valid
       
   522     TEST_ASSERT_DESC( iHaptics, "Haptics client creation failed!");
       
   523 
       
   524     // the connection is closed, when iHaptics is deleted
       
   525     delete iHaptics;
       
   526     iHaptics = NULL;
       
   527     return KErrNone;
       
   528     }
       
   529     
       
   530 // ---------------------------------------------------------
       
   531 // Create several simultaneous sessions to haptics server.
       
   532 // ---------------------------------------------------------
       
   533 //
       
   534 TInt CHapticsClientTest::T_SeveralSessionsL()
       
   535     {
       
   536     // create haptics instances without observers. This creates
       
   537     // client-server sessions (session instances in the server)
       
   538     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
   539     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
   540     CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL );
       
   541 
       
   542     // the connection has been opened successfully, if instances are valid
       
   543     TEST_ASSERT_DESC( haptics1, "First haptics client creation failed!");
       
   544     TEST_ASSERT_DESC( haptics2, "Second haptics client creation failed!");
       
   545     TEST_ASSERT_DESC( haptics3, "Third haptics client creation failed!");
       
   546 
       
   547     // delete haptics instances. This removes the sessions from 
       
   548     // haptics server, and closes the server, when the last session 
       
   549     // is closed
       
   550     delete haptics1; haptics1 = NULL;
       
   551     delete haptics2; haptics2 = NULL;
       
   552     delete haptics3; haptics3 = NULL;
       
   553     return KErrNone;
       
   554     }
       
   555 
       
   556 // ---------------------------------------------------------
       
   557 // Create several consecutive sessions to haptics server.
       
   558 // ---------------------------------------------------------
       
   559 //
       
   560 TInt CHapticsClientTest::T_ConsecutiveSessionsL()
       
   561     {
       
   562     // Do create and delete three times in a row
       
   563     T_CreateAndDeleteL();
       
   564     T_CreateAndDeleteL();
       
   565     T_CreateAndDeleteL();
       
   566     return KErrNone;
       
   567     }
       
   568 
       
   569 // ---------------------------------------------------------
       
   570 // Requests the supported actuators from haptics.
       
   571 // ---------------------------------------------------------
       
   572 //
       
   573 TInt CHapticsClientTest::T_SupportedActuators()
       
   574     {
       
   575     TUint32 actuators = 0;
       
   576     TInt err = KErrNone;
       
   577     err = iHaptics->SupportedActuators( actuators );
       
   578     
       
   579     TEST_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" );
       
   580     TEST_ASSERT_DESC( actuators, "Actuators empty!");
       
   581     return err;
       
   582     }
       
   583 
       
   584 // ---------------------------------------------------------
       
   585 // Opens an actuator, which is supported by haptics.
       
   586 // ---------------------------------------------------------
       
   587 //
       
   588 TInt CHapticsClientTest::T_OpenSupportedActuator()
       
   589     {
       
   590     TUint32 actuators = 0;
       
   591     TInt err = iHaptics->SupportedActuators( actuators );
       
   592     
       
   593     // Open using first supported logical actuator type
       
   594     if( EHWRMLogicalActuatorAny & actuators )
       
   595         {
       
   596         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
   597         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" );
       
   598         }
       
   599     else if( EHWRMLogicalActuatorDevice & actuators )
       
   600         {
       
   601         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) );
       
   602         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" );
       
   603         }
       
   604     else if( EHWRMLogicalActuatorPrimaryDisplay & actuators )
       
   605         {
       
   606         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) );
       
   607         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type PrimaryDisplay failed!" );
       
   608         }
       
   609     else if( EHWRMLogicalActuatorSecondaryDisplay & actuators )
       
   610         {
       
   611         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) );
       
   612         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type SecondaryDisplay failed!" );
       
   613         }
       
   614     else if( EHWRMLogicalActuatorGame & actuators )
       
   615         {
       
   616         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) );
       
   617         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Game failed!" );
       
   618         }
       
   619     else if( EHWRMLogicalActuatorGameLeft & actuators )
       
   620         {
       
   621         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) );
       
   622         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type GameLeft failed!" );
       
   623         }
       
   624     else if( EHWRMLogicalActuatorGameRight & actuators )
       
   625         {
       
   626         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) );
       
   627         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type GameRight failed!" );
       
   628         }
       
   629     else if( EHWRMLogicalActuatorExternalVibra & actuators )
       
   630         {
       
   631         TRAPD( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) );
       
   632         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type ExternalVibra failed!" );
       
   633         }
       
   634     return err;
       
   635     }
       
   636 
       
   637 // ---------------------------------------------------------
       
   638 // Attemps to open an actuator, which is NOT supported 
       
   639 // by haptics.
       
   640 // ---------------------------------------------------------
       
   641 //
       
   642 TInt CHapticsClientTest::T_OpenNotSupportedActuator()
       
   643     {
       
   644     TUint32 actuators = 0;
       
   645     TInt err = iHaptics->SupportedActuators( actuators );
       
   646     
       
   647     TEST_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" );
       
   648 
       
   649     // Open using first NOT supported logical actuator type
       
   650     if( !( EHWRMLogicalActuatorAny & actuators ) )
       
   651         {
       
   652         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
   653         }
       
   654     else if( !( EHWRMLogicalActuatorDevice & actuators ) )
       
   655         {
       
   656         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) );
       
   657         }
       
   658     else if( !( EHWRMLogicalActuatorPrimaryDisplay & actuators ) )
       
   659         {
       
   660         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) );
       
   661         }
       
   662     else if( !( EHWRMLogicalActuatorSecondaryDisplay & actuators ) )
       
   663         {
       
   664         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) );
       
   665         }
       
   666     else if( !( EHWRMLogicalActuatorGame & actuators ) )
       
   667         {
       
   668         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) );
       
   669         }
       
   670     else if( !( EHWRMLogicalActuatorGameLeft & actuators ) )
       
   671         {
       
   672         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) );
       
   673         }
       
   674     else if( !( EHWRMLogicalActuatorGameRight & actuators ) )
       
   675         {
       
   676         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) );
       
   677         }
       
   678     else if( !( EHWRMLogicalActuatorExternalVibra & actuators ) )
       
   679         {
       
   680         TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) );
       
   681         }
       
   682     
       
   683     TEST_ASSERT_DESC( (err == KErrNotSupported), "Invalid error code value!" );
       
   684     TEST_ASSERT_DESC( (err != KErrNone), "Opening unsupported actuator succeeded!" );
       
   685     return KErrNone;
       
   686     }
       
   687 
       
   688 // ---------------------------------------------------------
       
   689 // Attemps to open actuators, using all available logical
       
   690 // actuator types.
       
   691 // ---------------------------------------------------------
       
   692 //
       
   693 TInt CHapticsClientTest::T_OpenAllActuators()
       
   694     {
       
   695     TInt actuatorMask = EHWRMLogicalActuatorPrimaryDisplay | EHWRMLogicalActuatorSecondaryDisplay;
       
   696     
       
   697     TRAPD( err, iHaptics->OpenActuatorL( (THWRMLogicalActuators)actuatorMask ) );
       
   698     TEST_ASSERT_DESC( (err == KErrArgument), "Opening actuator with several type mask succeeded!" );
       
   699 
       
   700     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorPrimaryDisplay ) );
       
   701     TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type PrimaryDisplay succeeded!" );
       
   702 
       
   703     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorSecondaryDisplay ) );
       
   704     TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type SecondaryDisplay succeeded!" );
       
   705 
       
   706     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGame ) );
       
   707     TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type Game succeeded!" );
       
   708 
       
   709     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameLeft ) );
       
   710     TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type GameLeft succeeded!" );
       
   711 
       
   712     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorGameRight ) );
       
   713     TEST_ASSERT_DESC( (err == KErrNotSupported), "Opening actuator with type GameRight succeeded!" );
       
   714 
       
   715     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
   716     TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" );
       
   717 
       
   718     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
   719     TEST_ASSERT_DESC( (err == KErrAlreadyExists), "Opening actuator with type Any; wrong error code" );
       
   720 
       
   721     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorDevice ) );
       
   722     TEST_ASSERT_DESC( (err == KErrInUse), "Opening actuator with type Device; wrong error code" );
       
   723 
       
   724     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorExternalVibra ) );
       
   725     TEST_ASSERT_DESC( (err == KErrInUse), "Opening actuator with type ExternalVibra; wrong error code!" );
       
   726     return KErrNone;
       
   727     }
       
   728 
       
   729 // ---------------------------------------------------------
       
   730 // Creates a couple of haptic client instances, and opens
       
   731 // actuators in both of them.
       
   732 // ---------------------------------------------------------
       
   733 //
       
   734 TInt CHapticsClientTest::T_SeveralClientsWithOpenActuatorsL()
       
   735     {
       
   736     // create first haptics client instance
       
   737     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
   738     CleanupStack::PushL( haptics1 );
       
   739 
       
   740     // create second haptics client instance
       
   741     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
   742     CleanupStack::PushL( haptics2 );
       
   743 
       
   744     // fetch supported actuator types
       
   745     TUint32 actuators = 0;
       
   746     TInt err = haptics1->SupportedActuators( actuators );
       
   747     TEST_ASSERT_DESC( (err == KErrNone), "Error returned from SupportedActuators()!" );
       
   748 
       
   749     // open actuators for both instances using supported types
       
   750     if( EHWRMLogicalActuatorAny & actuators )
       
   751         {
       
   752         TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
   753         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" );
       
   754 
       
   755         TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
   756         TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" );
       
   757         }
       
   758     else
       
   759         {
       
   760         TEST_ASSERT_DESC( EFalse, "Actuator type Any not supported!" );
       
   761         }
       
   762 
       
   763     CleanupStack::PopAndDestroy( haptics2 );
       
   764     CleanupStack::PopAndDestroy( haptics1 );
       
   765     return KErrNone;
       
   766     }
       
   767 
       
   768 // ---------------------------------------------------------
       
   769 // Plays a magsweep effect using synchronous API call.
       
   770 // ---------------------------------------------------------
       
   771 //
       
   772 TInt CHapticsClientTest::T_PlayMagSweepEffectSynchronous()
       
   773     {
       
   774     // open actuator.. 
       
   775     T_OpenSupportedActuator();
       
   776     
       
   777     // create a magsweep effect
       
   778     CHWRMHaptics::THWRMHapticsMagSweepEffect effect;
       
   779     CreateMagSweepEffect( effect );
       
   780     
       
   781     // play effect  
       
   782     TInt effectHandle;
       
   783     TInt err = iHaptics->PlayMagSweepEffect( effect, effectHandle ); 
       
   784     TEST_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect synchronously failed!" );
       
   785     TEST_ASSERT_DESC( effectHandle, "Playing magsweep effect synchronously returned empty effect handle!" );
       
   786 
       
   787     // clean up.. (Teardown will complete these)
       
   788     err = iHaptics->StopAllPlayingEffects();
       
   789     TEST_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect synchronously failed! (StopAllPlayingEffects)" );
       
   790     return err;
       
   791     }
       
   792     
       
   793 
       
   794 // ---------------------------------------------------------
       
   795 // Plays a magsweep effect using asynchronous API call.
       
   796 // ---------------------------------------------------------
       
   797 //  
       
   798 TInt CHapticsClientTest::T_PlayMagSweepEffectAsynchronous()
       
   799     {
       
   800     // open actuator.. 
       
   801     T_OpenSupportedActuator();
       
   802     
       
   803     // create a magsweep effect
       
   804     CHWRMHaptics::THWRMHapticsMagSweepEffect effect;
       
   805     CreateMagSweepEffect( effect );
       
   806     
       
   807     // play effect  
       
   808     TInt effectHandle;
       
   809     TRequestStatus status = KRequestPending;
       
   810     iHaptics->PlayMagSweepEffect( effect, effectHandle, status ); 
       
   811     User::WaitForRequest( status );
       
   812     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing magsweep effect asynchronously failed!" );
       
   813     TEST_ASSERT_DESC( effectHandle, "Playing magsweep effect asynchronously returned empty effect handle!" );
       
   814 
       
   815     // clean up.. (Teardown will complete these)
       
   816     TInt err = iHaptics->StopAllPlayingEffects();
       
   817     TEST_ASSERT_DESC( (err == KErrNone), "Playing magsweep effect asynchronously failed! (StopAllPlayingEffects)" );
       
   818     
       
   819     return err;
       
   820     }
       
   821      
       
   822 
       
   823 // ---------------------------------------------------------
       
   824 // Plays a periodic effect using synchronous API call.
       
   825 // ---------------------------------------------------------
       
   826 //  
       
   827 TInt CHapticsClientTest::T_PlayPeriodicEffectSynchronous()
       
   828     {
       
   829     // open actuator.. 
       
   830     T_OpenSupportedActuator();
       
   831     
       
   832     // create a magsweep effect
       
   833     CHWRMHaptics::THWRMHapticsPeriodicEffect effect;
       
   834     CreatePeriodicEffect( effect );
       
   835     
       
   836     // play effect  
       
   837     TInt effectHandle;
       
   838     TInt err = iHaptics->PlayPeriodicEffect( effect, effectHandle ); 
       
   839     TEST_ASSERT_DESC( (err == KErrNone), "Playing periodic effect synchronously failed!" );
       
   840     TEST_ASSERT_DESC( effectHandle, "Playing periodic effect returned empty effect handle!" );
       
   841 
       
   842     // clean up.. (Teardown will complete these)
       
   843     err = iHaptics->StopAllPlayingEffects();
       
   844     TEST_ASSERT_DESC( (err == KErrNone), "Playing periodic effect synchronously failed! (StopAllPlayingEffects)" );
       
   845     return err;
       
   846     }
       
   847     
       
   848 // ---------------------------------------------------------
       
   849 // Plays a periodic effect using synchronous API call.
       
   850 // ---------------------------------------------------------
       
   851 //  
       
   852 TInt CHapticsClientTest::T_PlayPeriodicEffectAsynchronous()
       
   853     {
       
   854     // open actuator.. 
       
   855     T_OpenSupportedActuator();
       
   856     
       
   857     // create a magsweep effect
       
   858     CHWRMHaptics::THWRMHapticsPeriodicEffect effect;
       
   859     CreatePeriodicEffect( effect );
       
   860     
       
   861     // play effect  
       
   862     TInt effectHandle;
       
   863     TRequestStatus status = KRequestPending;
       
   864     iHaptics->PlayPeriodicEffect( effect, effectHandle, status ); 
       
   865     User::WaitForRequest( status );
       
   866     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing periodic effect asynchronously failed!" );
       
   867     TEST_ASSERT_DESC( effectHandle, "Playing periodic effect asynchronously returned empty effect handle!" );
       
   868 
       
   869     // clean up.. (Teardown will complete these)
       
   870     TInt err = iHaptics->StopAllPlayingEffects();
       
   871     TEST_ASSERT_DESC( (err == KErrNone), "Playing periodic effect asynchronously failed! (StopAllPlayingEffects)" );
       
   872     return err;
       
   873     }
       
   874 
       
   875 
       
   876 // ---------------------------------------------------------
       
   877 // Plays an IVT effect using synchronous API call.
       
   878 // The effect is given as TDes8C& parameter directly to the API call.
       
   879 // ---------------------------------------------------------
       
   880 // 
       
   881 TInt CHapticsClientTest::T_PlayIVTEffectWithDirectDataSynchronous()
       
   882     {
       
   883     // open actuator.. 
       
   884     T_OpenSupportedActuator();
       
   885     
       
   886     // read magsweep effect to buffer
       
   887     RBuf8 effBuf;
       
   888     CleanupClosePushL( effBuf );
       
   889     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
   890     
       
   891     // play the effect  
       
   892     TInt effectHandle;
       
   893     TInt err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); 
       
   894     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed!" );
       
   895     TEST_ASSERT_DESC( effectHandle, "Playingeffect IVT synchronously returned empty effect handle!" );
       
   896 
       
   897     // clean up.. (Teardown will complete these)
       
   898     CleanupStack::PopAndDestroy(); // effBuf
       
   899     err = iHaptics->StopAllPlayingEffects();
       
   900     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" );
       
   901 
       
   902     return err;
       
   903     }
       
   904     
       
   905 // ---------------------------------------------------------
       
   906 // Plays an IVT effect using asynchronous API call.
       
   907 // The effect is given as TDes8C& parameter directly to the API call.
       
   908 // ---------------------------------------------------------
       
   909 //   
       
   910 TInt CHapticsClientTest::T_PlayIVTEffectWithDirectDataAsynchronous()
       
   911     {
       
   912     // open actuator.. 
       
   913     T_OpenSupportedActuator();
       
   914     
       
   915     // read magsweep effect to buffer
       
   916     RBuf8 effBuf;
       
   917     CleanupClosePushL( effBuf );
       
   918     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
   919     
       
   920     // play effect  
       
   921     TInt effectHandle;
       
   922     TRequestStatus status = KRequestPending;
       
   923     iHaptics->PlayEffect( effBuf, 0, effectHandle, status );
       
   924     User::WaitForRequest( status );
       
   925     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect asynchronously failed!" );
       
   926     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect asynchronously returned empty effect handle!" );
       
   927     
       
   928     // clean up.. (Teardown will complete these)
       
   929     CleanupStack::PopAndDestroy(); // effBuf
       
   930     TInt err = iHaptics->StopAllPlayingEffects();
       
   931     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" );
       
   932     return err;
       
   933     }
       
   934     
       
   935 // ---------------------------------------------------------
       
   936 // Plays repeatedly an IVT effect using synchronous API call.
       
   937 // The effect is given as TDes8C& parameter directly to the API call.
       
   938 // ---------------------------------------------------------
       
   939 //  
       
   940 TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataSynchronous()
       
   941     {
       
   942     // open actuator.. 
       
   943     T_OpenSupportedActuator();
       
   944     
       
   945     // read timeline effect to buffer
       
   946     RBuf8 effBuf;
       
   947     CleanupClosePushL( effBuf );
       
   948     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline );
       
   949     
       
   950     // play the effect (repeat 2 times)
       
   951     TInt effectHandle;
       
   952     TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); 
       
   953     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed!" );
       
   954     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly synchronously returned empty effect handle!" );
       
   955 
       
   956     // clean up.. (Teardown will complete these)
       
   957     CleanupStack::PopAndDestroy(); // effBuf
       
   958     err = iHaptics->StopAllPlayingEffects();
       
   959     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" );
       
   960     return err;
       
   961     }
       
   962 
       
   963 // ---------------------------------------------------------
       
   964 // Plays repeatedly an IVT effect using asynchronous API call.
       
   965 // The effect is given as TDes8C& parameter directly to the API call.
       
   966 // ---------------------------------------------------------
       
   967 //      
       
   968 TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataAsynchronous()
       
   969     {
       
   970     // open actuator.. 
       
   971     T_OpenSupportedActuator();
       
   972     
       
   973     // read timeline effect to buffer
       
   974     RBuf8 effBuf;
       
   975     CleanupClosePushL( effBuf );
       
   976     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline );
       
   977     
       
   978     // play effect  (repeat 2 times)
       
   979     TInt effectHandle;
       
   980     TRequestStatus status = KRequestPending;
       
   981     iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status );
       
   982     User::WaitForRequest( status );
       
   983     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect repeatedly asynchronously failed!" );
       
   984     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly asynchronously returned empty effect handle!" );
       
   985     
       
   986     // clean up.. (Teardown will complete these)
       
   987     CleanupStack::PopAndDestroy(); // effBuf
       
   988     TInt err = iHaptics->StopAllPlayingEffects();
       
   989     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" );
       
   990     return err;
       
   991     }
       
   992 
       
   993 // ---------------------------------------------------------
       
   994 // Gets the effect state while an effect:
       
   995 //    a) is being played
       
   996 //    b) has been paused
       
   997 //    c) has been completed (i.e., is not playing any more)
       
   998 // ---------------------------------------------------------
       
   999 // 
       
  1000 TInt CHapticsClientTest::T_GetEffectState()
       
  1001     {
       
  1002     // open actuator.. 
       
  1003     T_OpenSupportedActuator();
       
  1004     
       
  1005     // create a magsweep effect
       
  1006     CHWRMHaptics::THWRMHapticsMagSweepEffect effect;
       
  1007     CreateMagSweepEffect( effect );
       
  1008     
       
  1009     // play effect  
       
  1010     TInt effectHandle;
       
  1011     TInt err = iHaptics->PlayMagSweepEffect( effect, effectHandle ); 
       
  1012     TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (playing returned error)" );
       
  1013     TEST_ASSERT_DESC( effectHandle, "GetEffectState failed! (empty effect handle)" );
       
  1014 
       
  1015     // get state
       
  1016     TInt effectState;
       
  1017     err = iHaptics->GetEffectState( effectHandle, effectState );
       
  1018     TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (1st call)" );
       
  1019     TEST_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectPlaying), "GetEffectState failed! (1st call - wrong state)" );
       
  1020     
       
  1021     // pause the effect and get state
       
  1022     err = iHaptics->PausePlayingEffect( effectHandle );
       
  1023     TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (Pause)" );
       
  1024 
       
  1025     err = iHaptics->GetEffectState( effectHandle, effectState );
       
  1026     TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (2nd call)" );
       
  1027     TEST_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectPaused), "GetEffectState failed! (2nd call - wrong state)" ); 
       
  1028 
       
  1029     // stop the effect and get state again
       
  1030     err = iHaptics->StopAllPlayingEffects();
       
  1031     TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (StopAllPlayingEffects)" );
       
  1032     
       
  1033     err = iHaptics->GetEffectState( effectHandle, effectState );
       
  1034     TEST_ASSERT_DESC( (err == KErrNone), "GetEffectState failed! (3rd call)" );
       
  1035     TEST_ASSERT_DESC( (effectState == CHWRMHaptics::EHWRMHapticsEffectNotPlaying), "GetEffectState failed! (3rd call - wrong state)" );
       
  1036     return err;
       
  1037     }
       
  1038 
       
  1039 // ---------------------------------------------------------
       
  1040 // Plays repeatedly an IVT effect using synchronous API call.
       
  1041 // The effect is given as TDes8C& parameter directly to the API call.
       
  1042 // Since the effect in question is not a timeline effect (in 
       
  1043 // this test we use magsweep effect instead), the effect is 
       
  1044 // played only once.
       
  1045 // ---------------------------------------------------------
       
  1046 //  
       
  1047 TInt CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataSynchronous()
       
  1048     {
       
  1049     // open actuator.. 
       
  1050     T_OpenSupportedActuator();
       
  1051     
       
  1052     // read magsweep effect to buffer
       
  1053     RBuf8 effBuf;
       
  1054     CleanupClosePushL( effBuf );
       
  1055     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1056     
       
  1057     // play the effect (try to repeat 2 times.. in practice will only repeat once 
       
  1058     // due to the effect being non timeline effect)
       
  1059     TInt effectHandle;
       
  1060     TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); 
       
  1061     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly synchronously failed!" );
       
  1062     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect (non-timeline) repeatedly synchronously returned empty effect handle!" );
       
  1063 
       
  1064     // clean up.. (Teardown will complete these)
       
  1065     CleanupStack::PopAndDestroy(); // effBuf
       
  1066     err = iHaptics->StopAllPlayingEffects();
       
  1067     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly synchronously failed! (StopAllPlayingEffects)" );
       
  1068     return err;
       
  1069     }
       
  1070 
       
  1071 // ---------------------------------------------------------
       
  1072 // Plays repeatedly an IVT effect using asynchronous API call.
       
  1073 // The effect is given as TDes8C& parameter directly to the API call.
       
  1074 // Since the effect in question is not a timeline effect (in 
       
  1075 // this test we use magsweep effect instead), the effect is 
       
  1076 // played only once.
       
  1077 // ---------------------------------------------------------
       
  1078 // 
       
  1079 TInt CHapticsClientTest::T_PlayNonTimelineIVTEffectRepeatWithDirectDataAsynchronous()
       
  1080     {
       
  1081     // open actuator.. 
       
  1082     T_OpenSupportedActuator();
       
  1083     
       
  1084     // read magsweep effect to buffer
       
  1085     RBuf8 effBuf;
       
  1086     CleanupClosePushL( effBuf );
       
  1087     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1088     
       
  1089     // play the effect (try to repeat 2 times.. in practice will only repeat once 
       
  1090     // due to the effect being non timeline effect)
       
  1091     TInt effectHandle;
       
  1092     TRequestStatus status = KRequestPending;
       
  1093     iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status );
       
  1094     User::WaitForRequest( status );
       
  1095     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect (non-timeline) repeatedly asynchronously failed!" );
       
  1096     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect (non-timeline) repeatedly asynchronously returned empty effect handle!" );
       
  1097     
       
  1098     // clean up.. (Teardown will complete these)
       
  1099     CleanupStack::PopAndDestroy(); // effBuf
       
  1100     TInt err = iHaptics->StopAllPlayingEffects();
       
  1101     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect (non-timeline) repeatedly asynchronously failed! (StopAllPlayingEffects)" );
       
  1102     return err;
       
  1103     }
       
  1104     
       
  1105 TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueSynchronous()
       
  1106     {
       
  1107     // open actuator.. 
       
  1108     T_OpenSupportedActuator();
       
  1109     
       
  1110     // read timeline effect to buffer
       
  1111     RBuf8 effBuf;
       
  1112     CleanupClosePushL( effBuf );
       
  1113     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline );
       
  1114     
       
  1115     // play the effect (repeat 0 times)
       
  1116     TInt effectHandle;
       
  1117     TInt err = iHaptics->PlayEffectRepeat( effBuf, 0, 0, effectHandle ); 
       
  1118     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) synchronously failed!" );
       
  1119     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly (zero repeats) synchronously returned empty effect handle!" );
       
  1120 
       
  1121     // clean up.. (Teardown will complete these)
       
  1122     CleanupStack::PopAndDestroy(); // effBuf
       
  1123     err = iHaptics->StopAllPlayingEffects();
       
  1124     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) synchronously failed! (StopAllPlayingEffects)" );
       
  1125     return err;
       
  1126     }
       
  1127 
       
  1128 
       
  1129 TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithDirectDataWithZeroRepeatValueAsynchronous()
       
  1130     {
       
  1131     // open actuator.. 
       
  1132     T_OpenSupportedActuator();
       
  1133     
       
  1134     // read timeline effect to buffer
       
  1135     RBuf8 effBuf;
       
  1136     CleanupClosePushL( effBuf );
       
  1137     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeTimeline );
       
  1138     
       
  1139     // play effect  (repeat 0 times)
       
  1140     TInt effectHandle;
       
  1141     TRequestStatus status = KRequestPending;
       
  1142     iHaptics->PlayEffectRepeat( effBuf, 0, 0, effectHandle, status );
       
  1143     User::WaitForRequest( status );
       
  1144     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing IVT effect repeatedly (zero repeats) asynchronously failed!" );
       
  1145     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect repeatedly (zero repeats) asynchronously returned empty effect handle!" );
       
  1146     
       
  1147     // clean up.. (Teardown will complete these)
       
  1148     CleanupStack::PopAndDestroy(); // effBuf
       
  1149     TInt err = iHaptics->StopAllPlayingEffects();
       
  1150     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly (zero repeats) asynchronously failed! (StopAllPlayingEffects)" );
       
  1151     return err;
       
  1152     }
       
  1153 
       
  1154     
       
  1155 // ---------------------------------------------------------
       
  1156 // Loading IVT data 
       
  1157 // ---------------------------------------------------------
       
  1158 //
       
  1159 TInt CHapticsClientTest::LoadIVTDataInternal( TInt& aFileHandle, 
       
  1160                                             CHWRMHaptics::THWRMHapticsEffectTypes aType,
       
  1161                                             TBool aOpenActuator )
       
  1162     {
       
  1163     // NOTE: we can use the same IVT data as was used in previous "call PlayXXXEffect()
       
  1164     // with direct data cases (i.e., there's no need e.g. to read data from file..)
       
  1165     
       
  1166     // open actuator.. 
       
  1167     if ( aOpenActuator )
       
  1168         {
       
  1169         T_OpenSupportedActuator();
       
  1170         }
       
  1171 
       
  1172     // read effect to buffer
       
  1173     RBuf8 effBuf;
       
  1174     CleanupClosePushL( effBuf );
       
  1175     CreateIVTEffect( effBuf, aType );
       
  1176 
       
  1177     TInt retVal = iHaptics->LoadEffectData( effBuf, aFileHandle );
       
  1178     
       
  1179     CleanupStack::PopAndDestroy(); // effBuf
       
  1180     return retVal;
       
  1181     }
       
  1182 
       
  1183 TInt CHapticsClientTest::LoadIVTDataInternal( TInt& aFileHandle, 
       
  1184                                             const TUint8 aIvtData[],
       
  1185                                             TInt aIvtDataSize,
       
  1186                                             TBool aOpenActuator )
       
  1187     {
       
  1188     // open actuator.. 
       
  1189     if ( aOpenActuator )
       
  1190         {
       
  1191         T_OpenSupportedActuator();
       
  1192         }
       
  1193 
       
  1194     // read effect to buffer
       
  1195     RBuf8 effBuf;
       
  1196     CleanupClosePushL( effBuf );
       
  1197     effBuf.ReAlloc( aIvtDataSize );
       
  1198     TUint8* tmpPtr = const_cast<TUint8*>( effBuf.Ptr() );
       
  1199     memcpy( tmpPtr, aIvtData, aIvtDataSize );
       
  1200     effBuf.SetLength( aIvtDataSize );
       
  1201 
       
  1202     TInt retVal = iHaptics->LoadEffectData( effBuf, aFileHandle );
       
  1203     
       
  1204     CleanupStack::PopAndDestroy(); // effBuf
       
  1205     return retVal;
       
  1206     }
       
  1207 
       
  1208 TInt CHapticsClientTest::T_LoadIVTData()
       
  1209     {
       
  1210     TInt fileHandle;
       
  1211     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1212     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed!" );
       
  1213     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle!" );
       
  1214     
       
  1215     // clean up.. (Teardown() will handle the rest)
       
  1216     err = iHaptics->DeleteAllEffectData();
       
  1217     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (LoadIVTData case)" );
       
  1218     return err;
       
  1219     }
       
  1220 
       
  1221 
       
  1222 // ---------------------------------------------------------
       
  1223 // Deleting previously loaded IVT data by calling DeleteIVTData
       
  1224 // ---------------------------------------------------------
       
  1225 //
       
  1226 TInt CHapticsClientTest::T_DeleteIVTData()
       
  1227     {
       
  1228     TInt fileHandle;
       
  1229     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1230     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (DeleteIVTData case)!" );
       
  1231     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (DeleteIVTData case)!" );
       
  1232     
       
  1233     err = iHaptics->DeleteEffectData( fileHandle );
       
  1234     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1235     return err;
       
  1236     }
       
  1237 
       
  1238 
       
  1239 // ---------------------------------------------------------
       
  1240 // Deleting previously loaded IVT data by calling DeleteAllIVTData
       
  1241 // instead of DeleteIVTData
       
  1242 // ---------------------------------------------------------
       
  1243 //
       
  1244 TInt CHapticsClientTest::T_DeleteAllIVTData()
       
  1245     {
       
  1246     TInt fileHandle;
       
  1247     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1248     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (DeleteAllIVTData case)!" );
       
  1249     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (DeleteAllIVTData case)!" );
       
  1250     
       
  1251     // clean up.. (Teardown() will handle the rest)
       
  1252     err = iHaptics->DeleteAllEffectData();
       
  1253     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" );
       
  1254     return err;
       
  1255     }
       
  1256 
       
  1257 
       
  1258 // ---------------------------------------------------------
       
  1259 // Loads and deletes IVT-data.
       
  1260 // ---------------------------------------------------------
       
  1261 //
       
  1262 TInt CHapticsClientTest::T_LoadAndDeleteIVTData()
       
  1263     {
       
  1264     TInt fileHandle1 = KErrNotFound;
       
  1265     TInt fileHandle2 = KErrNotFound;
       
  1266     TInt fileHandle3 = KErrNotFound;
       
  1267 
       
  1268     // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal())
       
  1269     TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic );
       
  1270     TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1271     TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1272     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1273     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1274     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1275     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1276     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1277     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1278 
       
  1279     // check that filehandles are unique
       
  1280     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1281     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1282     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1283 
       
  1284     // delete each IVT-data
       
  1285     TInt err = iHaptics->DeleteEffectData( fileHandle1 );
       
  1286     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1287     err = iHaptics->DeleteEffectData( fileHandle2 );
       
  1288     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1289     err = iHaptics->DeleteEffectData( fileHandle3 );
       
  1290     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1291 
       
  1292     // reload IVT-data
       
  1293     fileHandle1 = KErrNotFound;
       
  1294     fileHandle2 = KErrNotFound;
       
  1295     fileHandle3 = KErrNotFound;
       
  1296     err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse );
       
  1297     err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1298     err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1299     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1300     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1301     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1302     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1303     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1304     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1305 
       
  1306     // check that filehandles are unique
       
  1307     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1308     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1309     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1310     return KErrNone;
       
  1311     }
       
  1312 
       
  1313 
       
  1314 // ---------------------------------------------------------
       
  1315 // Loads and deletes IVT-data (mixed order).
       
  1316 // ---------------------------------------------------------
       
  1317 //
       
  1318 TInt CHapticsClientTest::T_LoadAndDeleteIVTDataMixed()
       
  1319     {
       
  1320     TInt fileHandle1 = KErrNotFound;
       
  1321     TInt fileHandle2 = KErrNotFound;
       
  1322     TInt fileHandle3 = KErrNotFound;
       
  1323 
       
  1324     // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal())
       
  1325     TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic );
       
  1326     TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1327     TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1328     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1329     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1330     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1331     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1332     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1333     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1334 
       
  1335     // check that filehandles are unique
       
  1336     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1337     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1338     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1339 
       
  1340     // delete second IVT-data
       
  1341     TInt err = iHaptics->DeleteEffectData( fileHandle2 );
       
  1342     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1343 
       
  1344     // load third IVT-data once more (filehandle should not change)
       
  1345     TInt newHandle = KErrNotFound;
       
  1346     err3 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1347     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1348     TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" );
       
  1349     TEST_ASSERT_DESC( (fileHandle3 == newHandle), "Received incorrect filehandle!" );
       
  1350 
       
  1351     // load second IVT-data once more (filehandle should change)
       
  1352     newHandle = KErrNotFound;
       
  1353     err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1354     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1355     TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" );
       
  1356     TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" );
       
  1357     fileHandle2 = newHandle;
       
  1358 
       
  1359     // delete all IVT-data
       
  1360     err = iHaptics->DeleteAllEffectData();
       
  1361     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" );
       
  1362 
       
  1363     fileHandle1 = KErrNotFound;
       
  1364     fileHandle2 = KErrNotFound;
       
  1365     fileHandle3 = KErrNotFound;
       
  1366 
       
  1367     // reload IVT-data
       
  1368     err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse );
       
  1369     err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1370     err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1371     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1372     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1373     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1374     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1375     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1376     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1377 
       
  1378     // check that filehandles are unique
       
  1379     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1380     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1381     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1382     return KErrNone;
       
  1383     }
       
  1384 
       
  1385 
       
  1386 // ---------------------------------------------------------
       
  1387 // Loads and deletes IVT-data. Plays using the filehandles
       
  1388 // received by calling the synchronous play-method.
       
  1389 // ---------------------------------------------------------
       
  1390 //
       
  1391 TInt CHapticsClientTest::T_LoadDeletePlaySync()
       
  1392     {
       
  1393     TInt effectHandle = 0;
       
  1394     TInt fileHandle1 = KErrNotFound;
       
  1395     TInt fileHandle2 = KErrNotFound;
       
  1396     TInt fileHandle3 = KErrNotFound;
       
  1397 
       
  1398     // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal())
       
  1399     TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic );
       
  1400     TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1401     TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1402     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1403     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1404     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1405     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1406     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1407     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1408 
       
  1409     // check that filehandles are unique
       
  1410     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1411     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1412     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1413 
       
  1414     // play the first effect of each data
       
  1415     TInt err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle );
       
  1416     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1417     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  1418     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1419     err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle );
       
  1420     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1421 
       
  1422     // play the first effect of the second data
       
  1423     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  1424     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1425 
       
  1426     // delete second IVT-data
       
  1427     err = iHaptics->DeleteEffectData( fileHandle2 );
       
  1428     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1429 
       
  1430     // play the first effect of the second data
       
  1431     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  1432     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1433 
       
  1434     // load second IVT-data once more (filehandle should change)
       
  1435     TInt newHandle = KErrNotFound;
       
  1436     err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1437     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1438     TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" );
       
  1439     TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" );
       
  1440     fileHandle2 = newHandle;
       
  1441 
       
  1442     // play the first effect of the second data
       
  1443     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  1444     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1445 
       
  1446     // delete all IVT-data
       
  1447     err = iHaptics->DeleteAllEffectData();
       
  1448     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" );
       
  1449 
       
  1450     // play the first effect of each data (each should fail, since data is deleted)
       
  1451     err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle );
       
  1452     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1453     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  1454     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1455     err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle );
       
  1456     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1457 
       
  1458     // load IVT-data
       
  1459     err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse );
       
  1460     err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1461     err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1462     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1463     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1464     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1465     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1466     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1467     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1468 
       
  1469     // check that filehandles are unique
       
  1470     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1471     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1472     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1473 
       
  1474     // play the first effect of each data
       
  1475     err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle );
       
  1476     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1477     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  1478     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1479     err = iHaptics->PlayEffect( fileHandle3, 0, effectHandle );
       
  1480     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1481     return err;
       
  1482     }
       
  1483 
       
  1484 
       
  1485 // ---------------------------------------------------------
       
  1486 // Loads and deletes IVT-data. Plays using the filehandles
       
  1487 // received by calling the asynchronous play-method.
       
  1488 // ---------------------------------------------------------
       
  1489 //
       
  1490 TInt CHapticsClientTest::T_LoadDeletePlayAsync()
       
  1491     {
       
  1492     TRequestStatus status1 = KRequestPending;
       
  1493     TRequestStatus status2 = KRequestPending;
       
  1494     TRequestStatus status3 = KRequestPending;
       
  1495 
       
  1496     TInt effectHandle = 0;
       
  1497 
       
  1498     TInt fileHandle1 = KErrNotFound;
       
  1499     TInt fileHandle2 = KErrNotFound;
       
  1500     TInt fileHandle3 = KErrNotFound;
       
  1501 
       
  1502     // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal())
       
  1503     TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic );
       
  1504     TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1505     TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1506     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1507     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1508     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1509     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1510     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1511     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1512 
       
  1513     // check that filehandles are unique
       
  1514     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1515     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1516     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1517 
       
  1518     // play the first effect of each data
       
  1519     // iHaptics->PlayEffect( fileHandle1, 0, effectHandle, status1 );
       
  1520     // LoopForCompletion( status1 );
       
  1521     iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 );
       
  1522     iWait.Start();
       
  1523     TEST_ASSERT_DESC( (status1 == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1524 
       
  1525     iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 );
       
  1526     iWait.Start();
       
  1527     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1528 
       
  1529     iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 );
       
  1530     iWait.Start();
       
  1531     TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1532 
       
  1533     // play the first effect of the second data
       
  1534     status2 = KRequestPending;
       
  1535     iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 );
       
  1536     iWait.Start();
       
  1537     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1538 
       
  1539     // delete second IVT-data
       
  1540     TInt err = iHaptics->DeleteEffectData( fileHandle2 );
       
  1541     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1542 
       
  1543     // play the first effect of the second data
       
  1544     status2 = KRequestPending;
       
  1545     iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 );
       
  1546     iWait.Start();
       
  1547     TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT data succeeded!" );
       
  1548 
       
  1549     // load second IVT-data once more (filehandle should change)
       
  1550     TInt newHandle = KErrNotFound;
       
  1551     err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1552     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1553     TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" );
       
  1554     TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" );
       
  1555     fileHandle2 = newHandle;
       
  1556 
       
  1557     // play the first effect of the second data
       
  1558     status2 = KRequestPending;
       
  1559     iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 );
       
  1560     iWait.Start();
       
  1561     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1562 
       
  1563     // delete all IVT-data
       
  1564     err = iHaptics->DeleteAllEffectData();
       
  1565     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" );
       
  1566 
       
  1567     // play the first effect of each data (each should fail, since data is deleted)
       
  1568     status1 = KRequestPending;
       
  1569     status2 = KRequestPending;
       
  1570     status3 = KRequestPending;
       
  1571     iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 );
       
  1572     iWait.Start();
       
  1573     TEST_ASSERT_DESC( (status1.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1574     iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 );
       
  1575     iWait.Start();
       
  1576     TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1577     iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 );
       
  1578     iWait.Start();
       
  1579     TEST_ASSERT_DESC( (status3.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1580 
       
  1581     // load IVT-data
       
  1582     err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse );
       
  1583     err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1584     err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1585     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1586     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1587     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1588     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1589     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1590     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1591 
       
  1592     // check that filehandles are unique
       
  1593     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1594     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1595     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1596 
       
  1597     // play the first effect of each data
       
  1598     status1 = KRequestPending;
       
  1599     status2 = KRequestPending;
       
  1600     status3 = KRequestPending;
       
  1601     iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status1 );
       
  1602     iWait.Start();
       
  1603     TEST_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1604     iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status2 );
       
  1605     iWait.Start();
       
  1606     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1607     iSender->Play( iHaptics, fileHandle3, 0, effectHandle, status3 );
       
  1608     iWait.Start();
       
  1609     TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1610     return KErrNone;
       
  1611     }
       
  1612 
       
  1613 
       
  1614 // ---------------------------------------------------------
       
  1615 // Loads and deletes IVT-data. Plays using the filehandles
       
  1616 // received by calling the synchronous PlayRepeat-method.
       
  1617 // ---------------------------------------------------------
       
  1618 //
       
  1619 TInt CHapticsClientTest::T_LoadDeletePlayRepeatSync()
       
  1620     {
       
  1621     TInt effectHandle = 0;
       
  1622     TInt repeat = 2;
       
  1623     TInt fileHandle1 = KErrNotFound;
       
  1624     TInt fileHandle2 = KErrNotFound;
       
  1625     TInt fileHandle3 = KErrNotFound;
       
  1626 
       
  1627     // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal())
       
  1628     TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic );
       
  1629     TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1630     TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1631     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1632     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1633     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1634     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1635     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1636     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1637 
       
  1638     // check that filehandles are unique
       
  1639     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1640     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1641     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1642 
       
  1643     // play the first effect of each data
       
  1644     TInt err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle );
       
  1645     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1646     err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle );
       
  1647     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1648     err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle );
       
  1649     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1650 
       
  1651     // play the first effect of the second data
       
  1652     err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle );
       
  1653     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1654 
       
  1655     // delete second IVT-data
       
  1656     err = iHaptics->DeleteEffectData( fileHandle2 );
       
  1657     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1658 
       
  1659     // play the first effect of the second data
       
  1660     err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle );
       
  1661     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1662 
       
  1663     // load second IVT-data once more (filehandle should change)
       
  1664     TInt newHandle = KErrNotFound;
       
  1665     err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1666     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1667     TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" );
       
  1668     TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" );
       
  1669     fileHandle2 = newHandle;
       
  1670 
       
  1671     // play the first effect of the second data
       
  1672     err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle );
       
  1673     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1674 
       
  1675     // delete all IVT-data
       
  1676     err = iHaptics->DeleteAllEffectData();
       
  1677     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" );
       
  1678 
       
  1679     // play the first effect of each data (each should fail, since data is deleted)
       
  1680     err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle );
       
  1681     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1682     err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle );
       
  1683     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1684     err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle );
       
  1685     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1686 
       
  1687     // load IVT-data
       
  1688     err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse );
       
  1689     err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1690     err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1691     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1692     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1693     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1694     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1695     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1696     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1697 
       
  1698     // check that filehandles are unique
       
  1699     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1700     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1701     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1702 
       
  1703     // play the first effect of each data
       
  1704     err = iHaptics->PlayEffectRepeat( fileHandle1, 0, repeat, effectHandle );
       
  1705     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1706     err = iHaptics->PlayEffectRepeat( fileHandle2, 0, repeat, effectHandle );
       
  1707     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1708     err = iHaptics->PlayEffectRepeat( fileHandle3, 0, repeat, effectHandle );
       
  1709     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1710     return err;
       
  1711     }
       
  1712 
       
  1713 
       
  1714 // ---------------------------------------------------------
       
  1715 // Loads and deletes IVT-data. Plays using the filehandles
       
  1716 // received by calling the asynchronous PlayRepeat-method.
       
  1717 // ---------------------------------------------------------
       
  1718 //
       
  1719 TInt CHapticsClientTest::T_LoadDeletePlayRepeatAsync()
       
  1720     {
       
  1721     TRequestStatus status1 = KRequestPending;
       
  1722     TRequestStatus status2 = KRequestPending;
       
  1723     TRequestStatus status3 = KRequestPending;
       
  1724 
       
  1725     TInt effectHandle = 0;
       
  1726     TInt repeat = 7;
       
  1727 
       
  1728     TInt fileHandle1 = KErrNotFound;
       
  1729     TInt fileHandle2 = KErrNotFound;
       
  1730     TInt fileHandle3 = KErrNotFound;
       
  1731 
       
  1732     // load IVT-data (open actuator on the first load only inside LoadIVTDataInternal())
       
  1733     TInt err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic );
       
  1734     TInt err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1735     TInt err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1736     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1737     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1738     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1739     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1740     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1741     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1742 
       
  1743     // check that filehandles are unique
       
  1744     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1745     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1746     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1747 
       
  1748     // play the first effect of each data
       
  1749     iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 );
       
  1750     iWait.Start();
       
  1751     TEST_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1752     iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 );
       
  1753     iWait.Start();
       
  1754     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1755     iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 );
       
  1756     iWait.Start();
       
  1757     TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1758 
       
  1759     // play the first effect of the second data
       
  1760     status2 = KRequestPending;
       
  1761     iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 );
       
  1762     iWait.Start();
       
  1763     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1764 
       
  1765     // delete second IVT-data
       
  1766     TInt err = iHaptics->DeleteEffectData( fileHandle2 );
       
  1767     TEST_ASSERT_DESC( (err == KErrNone), "Delete IVT data failed!" );
       
  1768 
       
  1769     // play the first effect of the second data
       
  1770     status2 = KRequestPending;
       
  1771     iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 );
       
  1772     iWait.Start();
       
  1773     TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT data succeeded!" );
       
  1774 
       
  1775     // load second IVT-data once more (filehandle should change)
       
  1776     TInt newHandle = KErrNotFound;
       
  1777     err2 = LoadIVTDataInternal( newHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1778     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1779     TEST_ASSERT_DESC( newHandle, "Loading IVT data failed, empty newHandle!" );
       
  1780     TEST_ASSERT_DESC( (fileHandle2 != newHandle), "Received incorrect filehandle!" );
       
  1781     fileHandle2 = newHandle;
       
  1782 
       
  1783     // play the first effect of the second data
       
  1784     status2 = KRequestPending;
       
  1785     iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 );
       
  1786     iWait.Start();
       
  1787     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1788 
       
  1789     // delete all IVT-data
       
  1790     err = iHaptics->DeleteAllEffectData();
       
  1791     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed!" );
       
  1792 
       
  1793     // play the first effect of each data (each should fail, since data is deleted)
       
  1794     status1 = KRequestPending;
       
  1795     status2 = KRequestPending;
       
  1796     status3 = KRequestPending;
       
  1797     iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 );
       
  1798     iWait.Start();
       
  1799     TEST_ASSERT_DESC( (status1.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1800     iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 );
       
  1801     iWait.Start();
       
  1802     TEST_ASSERT_DESC( (status2.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1803     iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 );
       
  1804     iWait.Start();
       
  1805     TEST_ASSERT_DESC( (status3.Int() == KErrBadHandle), "Playing deleted IVT-data succeeded!" );
       
  1806 
       
  1807     // load IVT-data
       
  1808     err1 = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse );
       
  1809     err2 = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  1810     err3 = LoadIVTDataInternal( fileHandle3, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  1811     TEST_ASSERT_DESC( (err1 == KErrNone), "Loading IVT data1 failed!" );
       
  1812     TEST_ASSERT_DESC( (err2 == KErrNone), "Loading IVT data2 failed!" );
       
  1813     TEST_ASSERT_DESC( (err3 == KErrNone), "Loading IVT data3 failed!" );
       
  1814     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle1!" );
       
  1815     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle2!" );
       
  1816     TEST_ASSERT_DESC( fileHandle3, "Loading IVT data failed, empty fileHandle3!" );
       
  1817 
       
  1818     // check that filehandles are unique
       
  1819     TEST_ASSERT_DESC( (fileHandle1 != fileHandle3), "Received same filehandles!" );
       
  1820     TEST_ASSERT_DESC( (fileHandle1 != fileHandle2), "Received same filehandles!" );
       
  1821     TEST_ASSERT_DESC( (fileHandle2 != fileHandle3), "Received same filehandles!" );
       
  1822 
       
  1823     // play the first effect of each data
       
  1824     status1 = KRequestPending;
       
  1825     status2 = KRequestPending;
       
  1826     status3 = KRequestPending;
       
  1827     iSender->PlayRepeat( iHaptics, fileHandle1, 0, repeat, effectHandle, status1 );
       
  1828     iWait.Start();
       
  1829     TEST_ASSERT_DESC( (status1.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1830     iSender->PlayRepeat( iHaptics, fileHandle2, 0, repeat, effectHandle, status2 );
       
  1831     iWait.Start();
       
  1832     TEST_ASSERT_DESC( (status2.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1833     iSender->PlayRepeat( iHaptics, fileHandle3, 0, repeat, effectHandle, status3 );
       
  1834     iWait.Start();
       
  1835     TEST_ASSERT_DESC( (status3.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1836     return KErrNone;
       
  1837     }
       
  1838 
       
  1839 
       
  1840 // ---------------------------------------------------------
       
  1841 // Playing the previously loaded IVT data (synchronous version)
       
  1842 // ---------------------------------------------------------
       
  1843 //
       
  1844 TInt CHapticsClientTest::T_PlayIVTEffectWithLoadedDataSynchronous()
       
  1845     {
       
  1846     // load the IVT data 
       
  1847     TInt fileHandle;
       
  1848     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1849     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" );
       
  1850     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" );
       
  1851     
       
  1852     // play the effect.. 
       
  1853     TInt effectHandle;
       
  1854     err = iHaptics->PlayEffect( fileHandle, 0, effectHandle );
       
  1855     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  1856     TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" );
       
  1857 
       
  1858     
       
  1859     // clean up.. (Teardown() will handle the rest)
       
  1860     err = iHaptics->StopAllPlayingEffects();
       
  1861     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" );
       
  1862     err = iHaptics->DeleteAllEffectData();
       
  1863     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" );
       
  1864     return err;
       
  1865     }
       
  1866 
       
  1867 
       
  1868 // ---------------------------------------------------------
       
  1869 // Playing the previously loaded IVT data (asynchronous version)
       
  1870 // ---------------------------------------------------------
       
  1871 //
       
  1872 TInt CHapticsClientTest::T_PlayIVTEffectWithLoadedDataAsynchronous()
       
  1873     {
       
  1874     // load the IVT data 
       
  1875     TInt fileHandle;
       
  1876     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1877     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" );
       
  1878     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" );
       
  1879 
       
  1880     // play the effect.. 
       
  1881     TInt effectHandle;
       
  1882     TRequestStatus status = KRequestPending;
       
  1883     iSender->Play( iHaptics, fileHandle, 0, effectHandle, status );
       
  1884     iWait.Start();
       
  1885     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  1886     TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" );
       
  1887     
       
  1888     // clean up.. (Teardown() will handle the rest)
       
  1889     err = iHaptics->StopAllPlayingEffects();
       
  1890     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" );
       
  1891     err = iHaptics->DeleteAllEffectData();
       
  1892     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing asynchronously case))" );
       
  1893     return err;
       
  1894     }
       
  1895 
       
  1896 
       
  1897 // ---------------------------------------------------------
       
  1898 // Playing with repeat the previously loaded IVT data 
       
  1899 // (synchronous version). Uses timeline effect.
       
  1900 // ---------------------------------------------------------
       
  1901 //
       
  1902 TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataSynchronous()
       
  1903     {
       
  1904     // load the IVT data 
       
  1905     TInt fileHandle;
       
  1906     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline );
       
  1907     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" );
       
  1908     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" );
       
  1909     
       
  1910     // play the effect repeatedly (repeated 3 times) 
       
  1911     TInt effectHandle;
       
  1912     err = iHaptics->PlayEffectRepeat( fileHandle, 0, 3, effectHandle );
       
  1913     TEST_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" );
       
  1914     TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" );
       
  1915 
       
  1916     // clean up.. (Teardown() will handle the rest)
       
  1917     err = iHaptics->StopAllPlayingEffects();
       
  1918     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" );
       
  1919     err = iHaptics->DeleteAllEffectData();
       
  1920     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT synchronously case))" );
       
  1921     return err;
       
  1922     }
       
  1923 
       
  1924 
       
  1925 // ---------------------------------------------------------
       
  1926 // Playing with repeat the previously loaded IVT data 
       
  1927 // (asynchronous version). Uses timeline effect.
       
  1928 // ---------------------------------------------------------
       
  1929 //
       
  1930 TInt CHapticsClientTest::T_PlayIVTEffectRepeatWithLoadedDataAsynchronous()
       
  1931     {
       
  1932     // load the IVT data 
       
  1933     TInt fileHandle;
       
  1934     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  1935     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" );
       
  1936     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" );
       
  1937 
       
  1938     // play the effect (repeated 5 times) 
       
  1939     TInt effectHandle;
       
  1940     TRequestStatus status = KRequestPending;
       
  1941     iSender->PlayRepeat( iHaptics, fileHandle, 0, 5, effectHandle, status );
       
  1942     iWait.Start();
       
  1943     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" );
       
  1944     TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" );
       
  1945     
       
  1946     // clean up.. (Teardown() will handle the rest)
       
  1947     err = iHaptics->StopAllPlayingEffects();
       
  1948     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" );
       
  1949     err = iHaptics->DeleteAllEffectData();
       
  1950     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT asynchronously case))" );
       
  1951     return err;
       
  1952     }
       
  1953 
       
  1954 // ---------------------------------------------------------
       
  1955 // VibeStatus to S60 status conversions
       
  1956 // ---------------------------------------------------------
       
  1957 //
       
  1958 TInt CHapticsClientTest::T_VibeStatusToS60StatusConversions()
       
  1959     {
       
  1960     // this is a bit ugly, i.e., we're using special repeat 
       
  1961     // values and then the test adaptation stub acknowledges
       
  1962     // these special value and repeats accordingly with some
       
  1963     // (Vibe-error) status
       
  1964     
       
  1965     // load the IVT data 
       
  1966     TInt fileHandle;
       
  1967     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline );
       
  1968     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Status conversion case)!" );
       
  1969     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Status conversion case)!" );
       
  1970     
       
  1971     // the actual status conversion cases (done with special repeat values
       
  1972     // using PlayIVTEffectRepeat)
       
  1973     TInt dummyEffectHandle; // we're not interested about this in these cases
       
  1974     // first the synch cases..
       
  1975     err = iHaptics->PlayEffectRepeat( fileHandle, 0, SUCCESS_TEST, dummyEffectHandle );
       
  1976     TEST_ASSERT_DESC( (err == KErrNone), "Status conversion subcase SUCCESS_TEST failed (synch)!" );
       
  1977 
       
  1978     err = iHaptics->PlayEffectRepeat( fileHandle, 0, ALREADY_INITIALIZED_TEST, dummyEffectHandle );
       
  1979     TEST_ASSERT_DESC( (err == KErrAlreadyExists), "Status conversion subcase ALREADY_INITIALIZED_TEST failed (synch)!" );
       
  1980 
       
  1981     err = iHaptics->PlayEffectRepeat( fileHandle, 0, NOT_INITIALIZED_TEST, dummyEffectHandle );
       
  1982     TEST_ASSERT_DESC( (err == KErrNotReady), "Status conversion subcase NOT_INITIALIZED_TEST failed (synch)!" );
       
  1983 
       
  1984     err = iHaptics->PlayEffectRepeat( fileHandle, 0, INVALID_ARGUMENT_TEST, dummyEffectHandle );
       
  1985     TEST_ASSERT_DESC( (err == KErrArgument), "Status conversion subcase INVALID_ARGUMENT_TEST failed (synch)!" );
       
  1986 
       
  1987     err = iHaptics->PlayEffectRepeat( fileHandle, 0, FAIL_TEST, dummyEffectHandle );
       
  1988     TEST_ASSERT_DESC( (err == KErrGeneral), "Status conversion subcase FAIL_TEST failed (synch)!" );
       
  1989 
       
  1990     err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_EFFECT_TYPE_TEST, dummyEffectHandle );
       
  1991     TEST_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_EFFECT_TYPE_TEST failed (synch)!" );
       
  1992 
       
  1993     err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_CAPABILITY_TYPE_TEST, dummyEffectHandle );
       
  1994     TEST_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_CAPABILITY_TYPE_TEST failed (synch)!" );
       
  1995 
       
  1996     err = iHaptics->PlayEffectRepeat( fileHandle, 0, INCOMPATIBLE_PROPERTY_TYPE_TEST, dummyEffectHandle );
       
  1997     TEST_ASSERT_DESC( (err == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_PROPERTY_TYPE_TEST failed (synch)!" );
       
  1998 
       
  1999     err = iHaptics->PlayEffectRepeat( fileHandle, 0, DEVICE_NEEDS_LICENSE_TEST, dummyEffectHandle );
       
  2000     TEST_ASSERT_DESC( (err == KErrAccessDenied), "Status conversion subcase DEVICE_NEEDS_LICENSE_TEST failed (synch)!" );
       
  2001 
       
  2002     err = iHaptics->PlayEffectRepeat( fileHandle, 0, NOT_ENOUGH_MEMORY_TEST, dummyEffectHandle );
       
  2003     TEST_ASSERT_DESC( (err == KErrNoMemory), "Status conversion subcase NOT_ENOUGH_MEMORY_TEST failed (synch)!" );
       
  2004 
       
  2005     err = iHaptics->PlayEffectRepeat( fileHandle, 0, SERVICE_NOT_RUNNING_TEST, dummyEffectHandle );
       
  2006     TEST_ASSERT_DESC( (err == KErrNotReady), "Status conversion subcase SERVICE_NOT_RUNNING_TEST failed (synch)!" );
       
  2007 
       
  2008     err = iHaptics->PlayEffectRepeat( fileHandle, 0, INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle );
       
  2009     TEST_ASSERT_DESC( (err == KErrAccessDenied), "Status conversion subcase INSUFFICIENT_PRIORITY_TEST failed (synch)!" );
       
  2010 
       
  2011     err = iHaptics->PlayEffectRepeat( fileHandle, 0, SERVICE_BUSY_TEST, dummyEffectHandle );
       
  2012     TEST_ASSERT_DESC( (err == KErrInUse), "Status conversion subcase SERVICE_BUSY_TEST failed (synch)!" );
       
  2013 
       
  2014     err = iHaptics->PlayEffectRepeat( fileHandle, 0, WRN_NOT_PLAYING_TEST, dummyEffectHandle );
       
  2015     TEST_ASSERT_DESC( (err == KErrArgument), "Status conversion subcase WRN_NOT_PLAYING_TEST failed (synch)!" );
       
  2016 
       
  2017     err = iHaptics->PlayEffectRepeat( fileHandle, 0, WRN_INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle );
       
  2018     TEST_ASSERT_DESC( (err == KErrNone), "Status conversion subcase WRN_INSUFFICIENT_PRIORITY_TEST failed (synch)!" );
       
  2019 
       
  2020     // then the asycnh cases
       
  2021     TRequestStatus status;
       
  2022     
       
  2023     status = KRequestPending;
       
  2024     iSender->PlayRepeat( iHaptics, fileHandle, 0, SUCCESS_TEST, dummyEffectHandle, status );
       
  2025     iWait.Start();
       
  2026     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Status conversion subcase SUCCESS_TEST failed (asynch)!" );
       
  2027  
       
  2028     status = KRequestPending;
       
  2029     iSender->PlayRepeat( iHaptics, fileHandle, 0, ALREADY_INITIALIZED_TEST, dummyEffectHandle, status );
       
  2030     iWait.Start();
       
  2031     TEST_ASSERT_DESC( (status.Int() == KErrAlreadyExists), "Status conversion subcase ALREADY_INITIALIZED_TEST failed (asynch)!" );
       
  2032     
       
  2033     status = KRequestPending;
       
  2034     iSender->PlayRepeat( iHaptics, fileHandle, 0, NOT_INITIALIZED_TEST, dummyEffectHandle, status );
       
  2035     iWait.Start();
       
  2036     TEST_ASSERT_DESC( (status.Int() == KErrNotReady), "Status conversion subcase NOT_INITIALIZED_TEST failed (asynch)!" );
       
  2037         
       
  2038     status = KRequestPending;
       
  2039     iSender->PlayRepeat( iHaptics, fileHandle, 0, INVALID_ARGUMENT_TEST, dummyEffectHandle, status );
       
  2040     iWait.Start();
       
  2041     TEST_ASSERT_DESC( (status.Int() == KErrArgument), "Status conversion subcase INVALID_ARGUMENT_TEST failed (asynch)!" );
       
  2042 
       
  2043     status = KRequestPending;
       
  2044     iSender->PlayRepeat( iHaptics, fileHandle, 0, FAIL_TEST, dummyEffectHandle, status );
       
  2045     iWait.Start();
       
  2046     TEST_ASSERT_DESC( (status.Int() == KErrGeneral), "Status conversion subcase FAIL_TEST failed (asynch)!" );
       
  2047 
       
  2048     status = KRequestPending;
       
  2049     iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_EFFECT_TYPE_TEST, dummyEffectHandle, status );
       
  2050     iWait.Start();
       
  2051     TEST_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_EFFECT_TYPE_TEST failed (asynch)!" );
       
  2052  
       
  2053     status = KRequestPending;
       
  2054     iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_CAPABILITY_TYPE_TEST, dummyEffectHandle, status );
       
  2055     iWait.Start();
       
  2056     TEST_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_CAPABILITY_TYPE_TEST failed (asynch)!" );
       
  2057         
       
  2058     status = KRequestPending;
       
  2059     iSender->PlayRepeat( iHaptics, fileHandle, 0, INCOMPATIBLE_PROPERTY_TYPE_TEST, dummyEffectHandle, status );
       
  2060     iWait.Start();
       
  2061     TEST_ASSERT_DESC( (status.Int() == KErrNotSupported), "Status conversion subcase INCOMPATIBLE_PROPERTY_TYPE_TEST failed (asynch)!" );
       
  2062 
       
  2063     status = KRequestPending;
       
  2064     iSender->PlayRepeat( iHaptics, fileHandle, 0, DEVICE_NEEDS_LICENSE_TEST, dummyEffectHandle, status );
       
  2065     iWait.Start();
       
  2066     TEST_ASSERT_DESC( (status.Int() == KErrAccessDenied), "Status conversion subcase DEVICE_NEEDS_LICENSE_TEST failed (asynch)!" );
       
  2067 
       
  2068     status = KRequestPending;
       
  2069     iSender->PlayRepeat( iHaptics, fileHandle, 0, NOT_ENOUGH_MEMORY_TEST, dummyEffectHandle, status );
       
  2070     iWait.Start();
       
  2071     TEST_ASSERT_DESC( (status.Int() == KErrNoMemory), "Status conversion subcase NOT_ENOUGH_MEMORY_TEST failed (asynch)!" );
       
  2072  
       
  2073     status = KRequestPending;
       
  2074     iSender->PlayRepeat( iHaptics, fileHandle, 0, SERVICE_NOT_RUNNING_TEST, dummyEffectHandle, status );
       
  2075     iWait.Start();
       
  2076     TEST_ASSERT_DESC( (status.Int() == KErrNotReady), "Status conversion subcase SERVICE_NOT_RUNNING_TEST failed (asynch)!" );
       
  2077         
       
  2078     status = KRequestPending;
       
  2079     iSender->PlayRepeat( iHaptics, fileHandle, 0, INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle, status );
       
  2080     iWait.Start();
       
  2081     TEST_ASSERT_DESC( (status.Int() == KErrAccessDenied), "Status conversion subcase INSUFFICIENT_PRIORITY_TEST failed (asynch)!" );
       
  2082 
       
  2083     status = KRequestPending;
       
  2084     iSender->PlayRepeat( iHaptics, fileHandle, 0, SERVICE_BUSY_TEST, dummyEffectHandle, status );
       
  2085     iWait.Start();
       
  2086     TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Status conversion subcase SERVICE_BUSY_TEST failed (asynch)!" );
       
  2087 
       
  2088     status = KRequestPending;
       
  2089     iSender->PlayRepeat( iHaptics, fileHandle, 0, WRN_NOT_PLAYING_TEST, dummyEffectHandle, status );
       
  2090     iWait.Start();
       
  2091     TEST_ASSERT_DESC( (status.Int() == KErrArgument), "Status conversion subcase WRN_NOT_PLAYING_TEST failed (asynch)!" );
       
  2092 
       
  2093     status = KRequestPending;
       
  2094     iSender->PlayRepeat( iHaptics, fileHandle, 0, WRN_INSUFFICIENT_PRIORITY_TEST, dummyEffectHandle, status );
       
  2095     iWait.Start();
       
  2096     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Status conversion subcase WRN_INSUFFICIENT_PRIORITY_TEST failed (asynch)!" ); 
       
  2097     return KErrNone;
       
  2098     }
       
  2099 
       
  2100 // ---------------------------------------------------------
       
  2101 // Load multiple IVT-data
       
  2102 // ---------------------------------------------------------
       
  2103 //
       
  2104 TInt CHapticsClientTest::T_LoadMultipleIVTData()
       
  2105     {
       
  2106     TInt fileHandle;
       
  2107     TInt prevFileHandle;
       
  2108 
       
  2109     // load the IVT data 
       
  2110     TInt err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2111     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" );
       
  2112     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Load multiple IVT-data case)!" );
       
  2113     prevFileHandle = fileHandle;
       
  2114 
       
  2115     // load the IVT data 
       
  2116     fileHandle = 0;
       
  2117     err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeTimeline ,EFalse );
       
  2118     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" );
       
  2119     TEST_ASSERT_DESC( fileHandle, "Loading IVT data failed, empty fileHandle (Load multiple IVT-data case)!" );
       
  2120     TEST_ASSERT_DESC( fileHandle!=prevFileHandle, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" );
       
  2121     
       
  2122     // try to load the same IVT data as before
       
  2123     fileHandle = 0;
       
  2124     err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  2125     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Load multiple IVT-data case)!" );
       
  2126     TEST_ASSERT_DESC( fileHandle == prevFileHandle, "Loading IVT data failed, wrong fileHandle (Load multiple IVT-data case)!" );
       
  2127 
       
  2128     // clean up.. (Teardown() will handle the rest)
       
  2129     err = iHaptics->DeleteAllEffectData();
       
  2130     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" );
       
  2131     return err;
       
  2132     }
       
  2133 
       
  2134 // ---------------------------------------------------------
       
  2135 // Playing from multiple IVT data (synchronous version)
       
  2136 // ---------------------------------------------------------
       
  2137 //
       
  2138 TInt CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataSynchronous()
       
  2139     {
       
  2140     // load the IVT data 
       
  2141     TInt fileHandle1;
       
  2142     TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2143     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" );
       
  2144     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" );
       
  2145 
       
  2146     // load the IVT data 
       
  2147     TInt fileHandle2;
       
  2148     err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  2149     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing synchronously case)!" );
       
  2150     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Playing synchronously case)!" );
       
  2151     
       
  2152     // play the effect..
       
  2153     TInt effectHandle;
       
  2154     err = iHaptics->PlayEffect( fileHandle1, 0, effectHandle );
       
  2155     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  2156     TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" );
       
  2157 
       
  2158     // play the effect.. 
       
  2159     effectHandle = 0;
       
  2160     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  2161     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  2162     TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" );
       
  2163 
       
  2164     // play the effect.. 
       
  2165     effectHandle = 0;
       
  2166     err = iHaptics->PlayEffect( fileHandle2, 0, effectHandle );
       
  2167     TEST_ASSERT_DESC( (err == KErrNone), "Playing loaded IVT data failed (synch)!" );
       
  2168     TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (synch)!" );
       
  2169 
       
  2170     // play the effect.. 
       
  2171     effectHandle = 0;
       
  2172     TInt unknownFileHandle = 3;
       
  2173     err = iHaptics->PlayEffect( unknownFileHandle, 0, effectHandle );
       
  2174     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing loaded IVT data failed, not bad handle (synch)!" );
       
  2175     TEST_ASSERT_DESC( !effectHandle, "Playing loaded IVT data failed, not empty effectHandle (synch)!" );
       
  2176 
       
  2177     
       
  2178     // clean up.. (Teardown() will handle the rest)
       
  2179     err = iHaptics->StopAllPlayingEffects();
       
  2180     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed! (StopAllPlayingEffects)" );
       
  2181     err = iHaptics->DeleteAllEffectData();
       
  2182     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing synchronously case))" );
       
  2183     return err;
       
  2184     }
       
  2185 
       
  2186 // ---------------------------------------------------------
       
  2187 // Playing the previously loaded IVT data (asynchronous version)
       
  2188 // ---------------------------------------------------------
       
  2189 //
       
  2190 TInt CHapticsClientTest::T_PlayIVTEffectsFromMultipleIVTDataAsynchronous()
       
  2191     {
       
  2192     // load the IVT data 
       
  2193     TInt fileHandle1;
       
  2194     TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2195     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" );
       
  2196     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" );
       
  2197 
       
  2198     // load the IVT data 
       
  2199     TInt fileHandle2;
       
  2200     err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  2201     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Playing asynchronously case)!" );
       
  2202     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Playing asynchronously case)!" );
       
  2203 
       
  2204     // play the effect..
       
  2205     TInt effectHandle;
       
  2206     TRequestStatus status = KRequestPending;
       
  2207 
       
  2208     iSender->Play( iHaptics, fileHandle1, 0, effectHandle, status );
       
  2209     iWait.Start(); 
       
  2210     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  2211     TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" );
       
  2212     
       
  2213     // play the effect..
       
  2214     effectHandle = 0;
       
  2215     status = KRequestPending;
       
  2216     iSender->Play( iHaptics, fileHandle2, 0, effectHandle, status );
       
  2217     iWait.Start();
       
  2218     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing loaded IVT data failed (asynch)!" );
       
  2219     TEST_ASSERT_DESC( effectHandle, "Playing loaded IVT data failed, empty effectHandle (asynch)!" );
       
  2220     
       
  2221     // play the effect..
       
  2222     effectHandle = 0;
       
  2223     status = KRequestPending;
       
  2224     TInt unknownFileHandle = 3;
       
  2225     iSender->Play( iHaptics, unknownFileHandle, 0, effectHandle, status );
       
  2226     iWait.Start();
       
  2227     TEST_ASSERT_DESC( (status.Int() == KErrBadHandle), "Playing loaded IVT data failed, not bad handle (asynch)!" );
       
  2228     TEST_ASSERT_DESC( !effectHandle, "Playing loaded IVT data failed, not empty effectHandle (asynch)!" );
       
  2229     
       
  2230     
       
  2231     // clean up.. (Teardown() will handle the rest)
       
  2232     err = iHaptics->StopAllPlayingEffects();
       
  2233     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect asynchronously failed! (StopAllPlayingEffects)" );
       
  2234     err = iHaptics->DeleteAllEffectData();
       
  2235     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Playing asynchronously case))" );
       
  2236     return err;
       
  2237     }
       
  2238 
       
  2239 // ---------------------------------------------------------
       
  2240 // Playing with repeat the previously loaded IVT data 
       
  2241 // (synchronous version). Uses timeline effect.
       
  2242 // ---------------------------------------------------------
       
  2243 //
       
  2244 TInt CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataSynchronous()
       
  2245     {
       
  2246     // load the IVT data 
       
  2247     TInt fileHandle1;
       
  2248     TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeTimeline );
       
  2249     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" );
       
  2250     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" );
       
  2251 
       
  2252     // load the IVT data 
       
  2253     TInt fileHandle2;
       
  2254     err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeTimeline, EFalse );
       
  2255     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT synchronously case)!" );
       
  2256     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Repeat IVT synchronously case)!" );
       
  2257     
       
  2258     // play the effect repeatedly (repeated 3 times) 
       
  2259     TInt effectHandle;
       
  2260     err = iHaptics->PlayEffectRepeat( fileHandle1, 0, 3, effectHandle );
       
  2261     TEST_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" );
       
  2262     TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" );
       
  2263 
       
  2264     // play the effect repeatedly (repeated 3 times) 
       
  2265     effectHandle = 0;
       
  2266     err = iHaptics->PlayEffectRepeat( fileHandle2, 0, 3, effectHandle );
       
  2267     TEST_ASSERT_DESC( (err == KErrNone), "Playing repeatedly loaded IVT data failed (synch)!" );
       
  2268     TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (synch)!" );
       
  2269 
       
  2270     // play the effect repeatedly (repeated 3 times) 
       
  2271     effectHandle = 0;
       
  2272     TInt unknownFileHandle = 3;
       
  2273     err = iHaptics->PlayEffectRepeat( unknownFileHandle, 0, 3, effectHandle );
       
  2274     TEST_ASSERT_DESC( (err == KErrBadHandle), "Playing repeatedly loaded IVT data failed, not bad handle (synch)!" );
       
  2275     TEST_ASSERT_DESC( !effectHandle, "Playing repeatedly loaded IVT data failed, not empty effectHandle (synch)!" );
       
  2276 
       
  2277     // clean up.. (Teardown() will handle the rest)
       
  2278     err = iHaptics->StopAllPlayingEffects();
       
  2279     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly synchronously failed! (StopAllPlayingEffects)" );
       
  2280     err = iHaptics->DeleteAllEffectData();
       
  2281     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT synchronously case))" );
       
  2282     return err;
       
  2283     }
       
  2284 
       
  2285 
       
  2286 // ---------------------------------------------------------
       
  2287 // Playing with repeat the previously loaded IVT data 
       
  2288 // (asynchronous version). Uses timeline effect.
       
  2289 // ---------------------------------------------------------
       
  2290 //
       
  2291 TInt CHapticsClientTest::T_PlayIVTEffectRepeatFromMultipleIVTDataAsynchronous()
       
  2292     {
       
  2293     // load the IVT data 
       
  2294     TInt fileHandle1;
       
  2295     TInt err = LoadIVTDataInternal( fileHandle1, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2296     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" );
       
  2297     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" );
       
  2298     
       
  2299     // load the IVT data 
       
  2300     TInt fileHandle2;
       
  2301     err = LoadIVTDataInternal( fileHandle2, CHWRMHaptics::EHWRMHapticsTypeMagSweep, EFalse );
       
  2302     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (Repeat IVT asynchronously case)!" );
       
  2303     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (Repeat IVT asynchronously case)!" );
       
  2304     
       
  2305     // play the effect (repeated 5 times) 
       
  2306     TInt effectHandle;
       
  2307     TRequestStatus status = KRequestPending;
       
  2308 
       
  2309     iSender->PlayRepeat( iHaptics, fileHandle1, 0, 5, effectHandle, status );
       
  2310     iWait.Start();
       
  2311     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" );
       
  2312     TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" );
       
  2313 
       
  2314     // play the effect (repeated 5 times) 
       
  2315     effectHandle = 0;
       
  2316     iSender->PlayRepeat( iHaptics, fileHandle2, 0, 5, effectHandle, status );
       
  2317     iWait.Start();
       
  2318     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Playing repeatedly loaded IVT data failed (asynch)!" );
       
  2319     TEST_ASSERT_DESC( effectHandle, "Playing repeatedly loaded IVT data failed, empty effectHandle (asynch)!" );
       
  2320 
       
  2321     // play the effect (repeated 5 times) 
       
  2322     effectHandle = 0;
       
  2323     status = KRequestPending;
       
  2324     TInt unknownFileHandle = 3;
       
  2325     iSender->PlayRepeat( iHaptics, unknownFileHandle, 0, 5, effectHandle, status );
       
  2326     iWait.Start();
       
  2327     TEST_ASSERT_DESC( (status.Int() == KErrBadHandle), "Playing repeatedly loaded IVT data failed, not bad handle (asynch)!" );
       
  2328     TEST_ASSERT_DESC( !effectHandle, "Playing repeatedly loaded IVT data failed, not empty effectHandle (asynch)!" );
       
  2329 
       
  2330     
       
  2331     // clean up.. (Teardown() will handle the rest)
       
  2332     err = iHaptics->StopAllPlayingEffects();
       
  2333     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect repeatedly asynchronously failed! (StopAllPlayingEffects)" );
       
  2334     err = iHaptics->DeleteAllEffectData();
       
  2335     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (Repeat IVT asynchronously case))" );
       
  2336     return err;
       
  2337     }
       
  2338 
       
  2339 // ---------------------------------------------------------
       
  2340 // Releasing previously reserved haptics
       
  2341 // ---------------------------------------------------------
       
  2342 //  
       
  2343 TInt CHapticsClientTest::T_ReserveAndReleaseHaptics()
       
  2344     {
       
  2345     // reserve
       
  2346     TRAPD( err, iHaptics->ReserveHapticsL() );
       
  2347     TEST_ASSERT_DESC( (err == KErrNone), "Release haptics case failed (ReserveHapticsL leaves)!" );
       
  2348 
       
  2349     // release (does not return an error code)
       
  2350     iHaptics->ReleaseHaptics();
       
  2351     return err;
       
  2352     }
       
  2353 
       
  2354 // ---------------------------------------------------------
       
  2355 // Reserving haptics several (in this case three) times
       
  2356 // ---------------------------------------------------------
       
  2357 //
       
  2358 TInt CHapticsClientTest::T_ReserveHapticsSeveralTimes()
       
  2359     {
       
  2360     TRAPD( err, iHaptics->ReserveHapticsL() );
       
  2361     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics (1st call) failed!" );
       
  2362     TRAP( err, iHaptics->ReserveHapticsL() );
       
  2363     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics (2nd call) failed!" );
       
  2364     TRAP( err, iHaptics->ReserveHapticsL() );
       
  2365     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics (3rd call) failed!" );
       
  2366     return err;
       
  2367     }
       
  2368 
       
  2369 // ---------------------------------------------------------
       
  2370 // Reserving haptics
       
  2371 // ---------------------------------------------------------
       
  2372 //  
       
  2373 TInt CHapticsClientTest::T_ReserveHapticsNoReleaseL()
       
  2374     {
       
  2375     // create first haptics instance
       
  2376     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
  2377     CleanupStack::PushL( haptics1 );
       
  2378 
       
  2379     // reserve
       
  2380     TRAPD( err, haptics1->ReserveHapticsL() );
       
  2381     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" );
       
  2382 
       
  2383     // create second haptics instance and open actuator
       
  2384     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  2385     TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  2386 
       
  2387     // play an effect using second client (should fail because 
       
  2388     // of reservation)
       
  2389     RBuf8 effBuf;
       
  2390     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2391     TInt effectHandle = 0;
       
  2392     err = haptics2->PlayEffect( effBuf, 0, effectHandle ); 
       
  2393     TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although server reserved!" );
       
  2394 
       
  2395     // destroy first client --> should release reservation
       
  2396     CleanupStack::PopAndDestroy( haptics1 );
       
  2397 
       
  2398     // play an effect using second client (should succeed, since no
       
  2399     // reservation)
       
  2400     err = haptics2->PlayEffect( effBuf, 0, effectHandle ); 
       
  2401     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed (no reservation)!" );
       
  2402 
       
  2403     // cleanup
       
  2404     effBuf.Close();
       
  2405     delete haptics2;
       
  2406     return err;
       
  2407     }
       
  2408 
       
  2409 // ---------------------------------------------------------
       
  2410 // Releasing haptics when it has not been previously reserved
       
  2411 // ---------------------------------------------------------
       
  2412 //  
       
  2413 TInt CHapticsClientTest::T_ReleaseHapticsWithoutReservingFirst()
       
  2414     {
       
  2415     // no return values nor leave to check, just execute
       
  2416     iHaptics->ReleaseHaptics();
       
  2417     return KErrNone;
       
  2418     }
       
  2419 
       
  2420 // ---------------------------------------------------------
       
  2421 // Tries to reserve haptics with forceNoCoeEnv flag on.
       
  2422 // ---------------------------------------------------------
       
  2423 //  
       
  2424 TInt CHapticsClientTest::T_ReserveNoAutomaticFocusNotTrusted()
       
  2425     {
       
  2426     TRAPD( err, iHaptics->ReserveHapticsL( ETrue ) );
       
  2427     TEST_ASSERT_DESC( (err == KErrAccessDenied), "Reservation succeeded although not a trusted client!" );
       
  2428     return KErrNone;
       
  2429     }
       
  2430 
       
  2431 // ---------------------------------------------------------
       
  2432 // Tries to reserve haptics, when it has already been 
       
  2433 // reserved for another client with higher priority.
       
  2434 // ---------------------------------------------------------
       
  2435 //  
       
  2436 TInt CHapticsClientTest::T_ReserveAlreadyReservedHigherL()
       
  2437     {
       
  2438     // create haptics instances and open actuators
       
  2439     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
  2440     CleanupStack::PushL( haptics1 );
       
  2441     TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  2442     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  2443     CleanupStack::PushL( haptics2 );
       
  2444     TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  2445 
       
  2446     // set first client priority (max)
       
  2447     haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  2448                                  KHWRMHapticsMaxDevicePriority );
       
  2449 
       
  2450     // reserve
       
  2451     TRAP( err, haptics1->ReserveHapticsL() );
       
  2452     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" );
       
  2453 
       
  2454     // set second client priority (min)
       
  2455     haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  2456                                  KHWRMHapticsMinDevicePriority );
       
  2457 
       
  2458     // reserve
       
  2459     TRAP( err, haptics2->ReserveHapticsL() );
       
  2460     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" );
       
  2461 
       
  2462     // play effect using the second client
       
  2463     RBuf8 effBuf;
       
  2464     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2465     TInt effectHandle = 0;
       
  2466     err = haptics2->PlayEffect( effBuf, 0, effectHandle ); 
       
  2467     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" );
       
  2468 
       
  2469     // release first client's reservation
       
  2470     haptics1->ReleaseHaptics();
       
  2471 
       
  2472     // play effect using the second client
       
  2473     err = haptics2->PlayEffect( effBuf, 0, effectHandle ); 
       
  2474     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" );
       
  2475     
       
  2476     // release second client's reservation
       
  2477     haptics2->ReleaseHaptics();
       
  2478 
       
  2479     // cleanup
       
  2480     effBuf.Close();
       
  2481     CleanupStack::PopAndDestroy( haptics2 );
       
  2482     CleanupStack::PopAndDestroy( haptics1 );
       
  2483     return err;
       
  2484     }
       
  2485 
       
  2486 // ---------------------------------------------------------
       
  2487 // Tries to reserve haptics, when it has already been 
       
  2488 // reserved for another client with lower priority.
       
  2489 // ---------------------------------------------------------
       
  2490 //  
       
  2491 TInt CHapticsClientTest::T_ReserveAlreadyReservedLowerL()
       
  2492     {
       
  2493     // create haptics instances and open actuators
       
  2494     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
  2495     CleanupStack::PushL( haptics1 );
       
  2496     TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  2497     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  2498     CleanupStack::PushL( haptics2 );
       
  2499     TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  2500 
       
  2501     // set first client priority (min)
       
  2502     haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  2503                                  KHWRMHapticsMinDevicePriority );
       
  2504 
       
  2505     // reserve
       
  2506     TRAP( err, haptics1->ReserveHapticsL() );
       
  2507     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" );
       
  2508 
       
  2509     // set second client priority (max)
       
  2510     haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  2511                                  KHWRMHapticsMaxDevicePriority );
       
  2512 
       
  2513     // reserve
       
  2514     TRAP( err, haptics2->ReserveHapticsL() );
       
  2515     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" );
       
  2516     
       
  2517     // play effect using first client
       
  2518     RBuf8 effBuf;
       
  2519     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2520     TInt effectHandle = 0;
       
  2521     err = haptics1->PlayEffect( effBuf, 0, effectHandle ); 
       
  2522     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" );
       
  2523 
       
  2524     // play effect using second client
       
  2525     err = haptics2->PlayEffect( effBuf, 0, effectHandle ); 
       
  2526     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" );
       
  2527 
       
  2528     // release second client
       
  2529     haptics2->ReleaseHaptics();
       
  2530 
       
  2531     // play effect using first client
       
  2532     err = haptics1->PlayEffect( effBuf, 0, effectHandle ); 
       
  2533     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" );
       
  2534 
       
  2535     // play effect using second client
       
  2536     err = haptics2->PlayEffect( effBuf, 0, effectHandle ); 
       
  2537     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect failed!" );
       
  2538 
       
  2539     // release first client
       
  2540     haptics1->ReleaseHaptics();
       
  2541 
       
  2542     // cleanup
       
  2543     effBuf.Close();
       
  2544     CleanupStack::PopAndDestroy( haptics2 );
       
  2545     CleanupStack::PopAndDestroy( haptics1 );
       
  2546     return err;
       
  2547     }
       
  2548 
       
  2549 // ---------------------------------------------------------
       
  2550 // Tries to play effects, when haptics has been reserved
       
  2551 // for a higher priority client.
       
  2552 // ---------------------------------------------------------
       
  2553 // 
       
  2554 TInt CHapticsClientTest::T_PlayWhenReservedL()
       
  2555     {
       
  2556     // create haptics instances and open actuators
       
  2557     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
  2558     CleanupStack::PushL( haptics1 );
       
  2559     TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  2560     TRAP( err, iHaptics->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  2561 
       
  2562     // set first client priority (max)
       
  2563     haptics1->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  2564                                  KHWRMHapticsMaxDevicePriority );
       
  2565 
       
  2566     // reserve for first client
       
  2567     TRAP( err, haptics1->ReserveHapticsL() );
       
  2568     TEST_ASSERT_DESC( (err == KErrNone), "Reserve haptics failed!" );
       
  2569 
       
  2570     // set second client priority (min)
       
  2571     iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  2572                                  KHWRMHapticsMinDevicePriority );
       
  2573 
       
  2574     // play effects using second client, when reserved for the first
       
  2575     // ---> 
       
  2576 
       
  2577     // create effect data for playing effect directly using IVT-data
       
  2578     RBuf8 effBuf;
       
  2579     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  2580 
       
  2581     // load the IVT data for playing effects using filehandle
       
  2582     TInt fileHandle = 0;
       
  2583     err = LoadIVTDataInternal( fileHandle, CHWRMHaptics::EHWRMHapticsTypePeriodic, EFalse );
       
  2584     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed!" );
       
  2585 
       
  2586     // create a magsweep effect
       
  2587     CHWRMHaptics::THWRMHapticsMagSweepEffect magSweepEffect;
       
  2588     CreateMagSweepEffect( magSweepEffect );
       
  2589 
       
  2590     // create a periodic effect
       
  2591     CHWRMHaptics::THWRMHapticsPeriodicEffect periodicEffect;
       
  2592     CreatePeriodicEffect( periodicEffect );
       
  2593 
       
  2594     TInt effectHandle = 0;
       
  2595     TRequestStatus status = KRequestPending;
       
  2596 
       
  2597     // synchronous play with data
       
  2598     err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); 
       
  2599     TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2600     
       
  2601     // synchronous play-repeat with data
       
  2602     err = iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle ); 
       
  2603     TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2604     
       
  2605     // asynchronous play with data
       
  2606     status = KRequestPending;
       
  2607     iHaptics->PlayEffect( effBuf, 0, effectHandle, status );
       
  2608     User::WaitForRequest( status );
       
  2609     TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2610 
       
  2611     // asynchronous play-repeat with data
       
  2612     status = KRequestPending;
       
  2613     iHaptics->PlayEffectRepeat( effBuf, 0, 2, effectHandle, status ); 
       
  2614     User::WaitForRequest( status );
       
  2615     TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2616 
       
  2617     // synchronous play with filehandle
       
  2618     err = iHaptics->PlayEffect( fileHandle, 0, effectHandle ); 
       
  2619     TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2620     
       
  2621     // synchronous play-repeat with filehandle
       
  2622     err = iHaptics->PlayEffectRepeat( fileHandle, 0, 2, effectHandle ); 
       
  2623     TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2624 
       
  2625     // asynchronous play with filehandle
       
  2626     status = KRequestPending;
       
  2627     iSender->Play( iHaptics, fileHandle, 0, effectHandle, status );
       
  2628     iWait.Start();
       
  2629     TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2630 
       
  2631     // asynchronous play-repeat with filehandle
       
  2632     status = KRequestPending;
       
  2633     iSender->PlayRepeat( iHaptics, fileHandle, 0, 2, effectHandle, status );
       
  2634     iWait.Start();
       
  2635     TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2636 
       
  2637     // synchronous manual magsweep
       
  2638     err = iHaptics->PlayMagSweepEffect( magSweepEffect, effectHandle ); 
       
  2639     TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2640 
       
  2641     // synchronous manual periodic
       
  2642     err = iHaptics->PlayPeriodicEffect( periodicEffect, effectHandle ); 
       
  2643     TEST_ASSERT_DESC( (err == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2644 
       
  2645     // asynchronous manual magsweep
       
  2646     status = KRequestPending;
       
  2647     iHaptics->PlayMagSweepEffect( magSweepEffect, effectHandle, status ); 
       
  2648     User::WaitForRequest( status );
       
  2649     TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2650 
       
  2651     // asynchronous manual periodic
       
  2652     status = KRequestPending;
       
  2653     iHaptics->PlayPeriodicEffect( periodicEffect, effectHandle, status ); 
       
  2654     User::WaitForRequest( status );
       
  2655     TEST_ASSERT_DESC( (status.Int() == KErrInUse), "Playing IVT effect succeeded although reserved!" );
       
  2656 
       
  2657     // <--- 
       
  2658 
       
  2659     // cleanup
       
  2660     effBuf.Close();
       
  2661     CleanupStack::PopAndDestroy( haptics1 );
       
  2662     return KErrNone;
       
  2663     }
       
  2664 
       
  2665 // ---------------------------------------------------------
       
  2666 // Getting effect count from preloaded IVT-data
       
  2667 // ---------------------------------------------------------
       
  2668 // 
       
  2669 TInt CHapticsClientTest::T_GetIVTEffectCount()
       
  2670     {
       
  2671     TInt fileHandle1;
       
  2672     TInt fileHandle2;
       
  2673     TInt corruptedFile;
       
  2674     TInt unknownFileHandle = 9;
       
  2675     
       
  2676     // load the IVT effect set 1
       
  2677     TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt,
       
  2678                                     sizeof( EffectSetMT_ivt ) );
       
  2679     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" );
       
  2680     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" );
       
  2681 
       
  2682     // load corrupted IVT effect set
       
  2683     err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt,
       
  2684                                     sizeof( CorruptedMT_ivt ), EFalse );
       
  2685     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" );
       
  2686     TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" );
       
  2687 
       
  2688     // load the IVT effect set 2
       
  2689     err = LoadIVTDataInternal( fileHandle2, Magsweep4HapticsMT_ivt,
       
  2690                                     sizeof( Magsweep4HapticsMT_ivt ), EFalse );
       
  2691     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectCount case)!" );
       
  2692     TEST_ASSERT_DESC( fileHandle2, "Loading IVT data failed, empty fileHandle (GetIVTEffectCount case)!" );
       
  2693 
       
  2694 
       
  2695     TInt effectCount;
       
  2696     // get effect count from IVT-data 1
       
  2697     err = iHaptics->GetEffectCount( fileHandle1, effectCount );
       
  2698     TEST_ASSERT_DESC( (err == KErrNone), "Get effect count failed (GetIVTEffectCount case)!" );
       
  2699     TEST_ASSERT_DESC( (effectCount == 6), "Wrong effect count (GetIVTEffectCount case)!" );
       
  2700 
       
  2701     // get effect count from corrupted IVT-data
       
  2702     err = iHaptics->GetEffectCount( corruptedFile, effectCount );
       
  2703     TEST_ASSERT_DESC( (err == KErrArgument), "Get count from corrupted IVT-data, incorrect error code (GetIVTEffectCount case)!" );
       
  2704 
       
  2705     // get effect count from IVT-data 2
       
  2706     err = iHaptics->GetEffectCount( fileHandle2, effectCount );
       
  2707     TEST_ASSERT_DESC( (err == KErrNone), "Get effect count failed (GetIVTEffectCount case)!" );
       
  2708     TEST_ASSERT_DESC( (effectCount == 1), "Wrong effect count (GetIVTEffectCount case)!" );
       
  2709 
       
  2710     // get effect count using unknown file handle
       
  2711     err = iHaptics->GetEffectCount( unknownFileHandle, effectCount );
       
  2712     TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectCount case)!" );
       
  2713 
       
  2714     // clean up.. (Teardown() will handle the rest)
       
  2715     err = iHaptics->DeleteAllEffectData();
       
  2716     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectCount case))" );
       
  2717     return KErrNone;
       
  2718     }
       
  2719 
       
  2720 // ---------------------------------------------------------
       
  2721 // Getting effect duration from preloaded IVT-data
       
  2722 // ---------------------------------------------------------
       
  2723 // 
       
  2724 TInt CHapticsClientTest::T_GetIVTEffectDuration()
       
  2725     {
       
  2726     TInt fileHandle1;
       
  2727     TInt corruptedFile;
       
  2728     TInt unknownFileHandle = 9;
       
  2729     
       
  2730     // load the IVT effect set 1
       
  2731     TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt,
       
  2732                                     sizeof( EffectSetMT_ivt ) );
       
  2733     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" );
       
  2734     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectDuration case)!" );
       
  2735 
       
  2736     // load corrupted IVT effect set
       
  2737     err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt,
       
  2738                                     sizeof( CorruptedMT_ivt ), EFalse );
       
  2739     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" );
       
  2740     TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectDuration case)!" );
       
  2741 
       
  2742     TInt effectDuration;
       
  2743     // duration of the last effect
       
  2744     TInt index = 5;
       
  2745     err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration );
       
  2746     TEST_ASSERT_DESC( (err == KErrNone), "Get duration failed (GetIVTEffectDuration case)!" );
       
  2747     TEST_ASSERT_DESC( (effectDuration == 4000), "Wrong duration (GetIVTEffectDuration case)!" );
       
  2748 
       
  2749     // get duration using effect index out of bounds
       
  2750     index = 6;
       
  2751     err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration );
       
  2752     TEST_ASSERT_DESC( (err != KErrNone), "Get duration succeeded (GetIVTEffectDuration case)!" );
       
  2753 
       
  2754     // get duration from corrupted IVT-data
       
  2755     index = 0; err = KErrNone;
       
  2756     err = iHaptics->GetEffectDuration( corruptedFile, index, effectDuration );
       
  2757     TEST_ASSERT_DESC( (err == KErrArgument), "Get duration from corrupted data, incorrect error code (GetIVTEffectDuration case)!" );
       
  2758 
       
  2759     // duration of the first effect
       
  2760     index = 0;
       
  2761     err = iHaptics->GetEffectDuration( fileHandle1, index, effectDuration );
       
  2762     TEST_ASSERT_DESC( (err == KErrNone), "Get duration failed (GetIVTEffectDuration case)!" );
       
  2763     TEST_ASSERT_DESC( (effectDuration == 3915), "Wrong duration (GetIVTEffectDuration case)!" );
       
  2764 
       
  2765     // get duration using unknown file handle
       
  2766     index = 0;
       
  2767     err = iHaptics->GetEffectDuration( unknownFileHandle, index, effectDuration );
       
  2768     TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectDuration case)!" );
       
  2769 
       
  2770     // clean up.. (Teardown() will handle the rest)
       
  2771     err = iHaptics->DeleteAllEffectData();
       
  2772     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectDuration case))" );
       
  2773     return KErrNone;
       
  2774     }
       
  2775 
       
  2776 // ---------------------------------------------------------
       
  2777 // Getting effect index from preloaded IVT-data
       
  2778 // ---------------------------------------------------------
       
  2779 // 
       
  2780 TInt CHapticsClientTest::T_GetIVTEffectIndexFromName()
       
  2781     {
       
  2782     TInt fileHandle1;
       
  2783     TInt corruptedFile;
       
  2784     TInt unknownFileHandle = 9;
       
  2785     
       
  2786     // load the IVT effect set 1
       
  2787     TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt,
       
  2788                                     sizeof( EffectSetMT_ivt ) );
       
  2789     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetEffectIndexFromName case)!" );
       
  2790     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetEffectIndexFromName case)!" );
       
  2791 
       
  2792     // load corrupted IVT effect set
       
  2793     err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt,
       
  2794                                     sizeof( CorruptedMT_ivt ), EFalse );
       
  2795     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetEffectIndexFromName case)!" );
       
  2796     TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetEffectIndexFromName case)!" );
       
  2797 
       
  2798 
       
  2799     TInt effectIndex;
       
  2800     _LIT8( KFirstName, "Timeline1" );
       
  2801     _LIT8( KLastName, "MagSweep2" );
       
  2802     _LIT8( KUnknownName, "Tiline1" );
       
  2803     TBuf8<128> effectName;
       
  2804 
       
  2805     // get index of the first name
       
  2806     effectName = KFirstName;
       
  2807     err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex );
       
  2808     TEST_ASSERT_DESC( (err == KErrNone), "Get effect index failed (GetEffectIndexFromName case)!" );
       
  2809     TEST_ASSERT_DESC( (effectIndex == 0), "Wrong effect index (GetEffectIndexFromName case)!" );
       
  2810     
       
  2811     // get index of the last name
       
  2812     effectName = KLastName;
       
  2813     err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex );
       
  2814     TEST_ASSERT_DESC( (err == KErrNone), "Get effect index failed (GetEffectIndexFromName case)!" );
       
  2815     TEST_ASSERT_DESC( (effectIndex == 5), "Wrong effect index (GetEffectIndexFromName case)!" );
       
  2816 
       
  2817     // get index from corrupted IVT-data
       
  2818     effectName = KFirstName;
       
  2819     err = iHaptics->GetEffectIndexFromName( corruptedFile, effectName, effectIndex );
       
  2820     TEST_ASSERT_DESC( (err == KErrArgument), "Get effect index from corrupted data, incorrect error code (GetEffectIndexFromName case)!" );
       
  2821 
       
  2822     // get index using unknown name
       
  2823     effectName = KUnknownName;
       
  2824     err = iHaptics->GetEffectIndexFromName( fileHandle1, effectName, effectIndex );
       
  2825     TEST_ASSERT_DESC( (err != KErrNone), "Get effect succeeded (GetEffectIndexFromName case)!" );
       
  2826 
       
  2827     // get index using unknown file handle
       
  2828     effectName = KUnknownName;
       
  2829     err = iHaptics->GetEffectIndexFromName( unknownFileHandle, effectName, effectIndex );
       
  2830     TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetEffectIndexFromName case)!" );
       
  2831 
       
  2832 
       
  2833     // clean up.. (Teardown() will handle the rest)
       
  2834     err = iHaptics->DeleteAllEffectData();
       
  2835     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetEffectIndexFromName case))" );
       
  2836     return err;
       
  2837     }
       
  2838 
       
  2839 
       
  2840 // ---------------------------------------------------------
       
  2841 // Getting effect type from preloaded IVT-data
       
  2842 // ---------------------------------------------------------
       
  2843 // 
       
  2844 TInt CHapticsClientTest::T_GetIVTEffectType()
       
  2845     {
       
  2846     TInt fileHandle1;
       
  2847     TInt corruptedFile;
       
  2848     TInt unknownFileHandle = 9;
       
  2849     
       
  2850     // load the IVT effect set 1
       
  2851     TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt,
       
  2852                                     sizeof( EffectSetMT_ivt ) );
       
  2853     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectType case)!" );
       
  2854     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectType case)!" );
       
  2855 
       
  2856     // load corrupted IVT effect set
       
  2857     err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt,
       
  2858                                     sizeof( CorruptedMT_ivt ), EFalse );
       
  2859     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectType case)!" );
       
  2860     TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectType case)!" );
       
  2861 
       
  2862 
       
  2863     // get type of the first effect
       
  2864     TInt effectType;
       
  2865     TInt effectIndex = 0;
       
  2866     err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType );
       
  2867     TEST_ASSERT_DESC( (err == KErrNone), "Get effect type failed (GetIVTEffectType case)!" );
       
  2868     TEST_ASSERT_DESC( (effectType == CHWRMHaptics::EHWRMHapticsTypeTimeline), "Wrong effect type (GetIVTEffectType case)!" );    
       
  2869 
       
  2870     // get type from corrupted IVT-data
       
  2871     effectIndex = 5;
       
  2872     err = iHaptics->GetEffectType( corruptedFile, effectIndex, effectType );
       
  2873     TEST_ASSERT_DESC( (err == KErrArgument), "Get effect type from corrupted data, incorrect error code (GetIVTEffectType case)!" );
       
  2874 
       
  2875     // get type of the last effect
       
  2876     effectIndex = 5;
       
  2877     err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType );
       
  2878     TEST_ASSERT_DESC( (err == KErrNone), "Get effect type failed (GetIVTEffectType case)!" );
       
  2879     TEST_ASSERT_DESC( (effectType == CHWRMHaptics::EHWRMHapticsTypeMagSweep), "Wrong effect type (GetIVTEffectType case)!" );    
       
  2880 
       
  2881     // get type using effect index out of bounds
       
  2882     effectIndex = 6;
       
  2883     err = iHaptics->GetEffectType( fileHandle1, effectIndex, effectType );
       
  2884     TEST_ASSERT_DESC( (err != KErrNone), "Get effect type succeeded (GetIVTEffectType case)!" );
       
  2885 
       
  2886     // get type using unknown file handle
       
  2887     effectIndex = 6;
       
  2888     err = iHaptics->GetEffectType( unknownFileHandle, effectIndex, effectType );
       
  2889     TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectType case)!" );
       
  2890 
       
  2891 
       
  2892     // clean up.. (Teardown() will handle the rest)
       
  2893     err = iHaptics->DeleteAllEffectData();
       
  2894     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectType case))" );
       
  2895     return err;
       
  2896     }
       
  2897 
       
  2898 // ---------------------------------------------------------
       
  2899 // Getting effect name from preloaded IVT-data
       
  2900 // ---------------------------------------------------------
       
  2901 // 
       
  2902 TInt CHapticsClientTest::T_GetIVTEffectName()
       
  2903     {
       
  2904     TInt fileHandle1;
       
  2905     TInt corruptedFile;
       
  2906     TInt unknownFileHandle = 9;
       
  2907     
       
  2908     // load the IVT effect set 1
       
  2909     TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt,
       
  2910                                     sizeof( EffectSetMT_ivt ) );
       
  2911     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" );
       
  2912     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTEffectName case)!" );
       
  2913 
       
  2914     // load corrupted IVT effect set
       
  2915     err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt,
       
  2916                                     sizeof( CorruptedMT_ivt ), EFalse );
       
  2917     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTEffectDuration case)!" );
       
  2918     TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTEffectName case)!" );
       
  2919 
       
  2920 
       
  2921     // get name of the first effect
       
  2922     TBuf8<128> effectName;
       
  2923     TInt effectIndex = 0;
       
  2924     _LIT8( KTimeline1, "Timeline1" );
       
  2925     _LIT8( KMagSweep2, "MagSweep2" );
       
  2926     err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName );
       
  2927     TEST_ASSERT_DESC( (err == KErrNone), "Get effect name failed (GetIVTEffectName case)!" );
       
  2928     TEST_ASSERT_DESC( (effectName == KTimeline1), "Wrong effect name (GetIVTEffectName case)!" );    
       
  2929 
       
  2930     // get name from corrupted IVT-data
       
  2931     effectIndex = 0;
       
  2932     err = iHaptics->GetEffectName( corruptedFile, effectIndex, effectName );
       
  2933     TEST_ASSERT_DESC( (err == KErrArgument), "Get effect name from corrupted data, incorrect error code (GetIVTEffectName case)!" );
       
  2934 
       
  2935     // get name of the last effect
       
  2936     effectIndex = 5;
       
  2937     err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName );
       
  2938     TEST_ASSERT_DESC( (err == KErrNone), "Get effect name failed (GetIVTEffectName case)!" );
       
  2939     TEST_ASSERT_DESC( (effectName == KMagSweep2), "Wrong effect name (GetIVTEffectType case)!" );    
       
  2940 
       
  2941     // get name using effect index out of bounds
       
  2942     effectIndex = 6;
       
  2943     err = iHaptics->GetEffectName( fileHandle1, effectIndex, effectName );
       
  2944     TEST_ASSERT_DESC( (err != KErrNone), "Get effect name succeeded (GetIVTEffectName case)!" );
       
  2945 
       
  2946     // get name using unknown file handle
       
  2947     effectIndex = 0;
       
  2948     err = iHaptics->GetEffectName( unknownFileHandle, effectIndex, effectName );
       
  2949     TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTEffectName case)!" );
       
  2950 
       
  2951 
       
  2952     // clean up.. (Teardown() will handle the rest)
       
  2953     err = iHaptics->DeleteAllEffectData();
       
  2954     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTEffectName case))" );
       
  2955     return KErrNone;
       
  2956     }
       
  2957 
       
  2958 // ---------------------------------------------------------
       
  2959 // Getting MagSweep effect definition from preloaded IVT-data
       
  2960 // ---------------------------------------------------------
       
  2961 // 
       
  2962 TInt CHapticsClientTest::T_GetIVTMagSweepEffectDefinition()
       
  2963     {
       
  2964     TInt fileHandle1;
       
  2965     TInt corruptedFile;
       
  2966     TInt unknownFileHandle = 9;
       
  2967     
       
  2968     // load the IVT effect set 1
       
  2969     TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt,
       
  2970                                     sizeof( EffectSetMT_ivt ) );
       
  2971     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTMagSweepEffectDefinition case)!" );
       
  2972     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTMagSweepEffectDefinition case)!" );
       
  2973 
       
  2974     // load corrupted IVT effect set
       
  2975     err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt,
       
  2976                                     sizeof( CorruptedMT_ivt ), EFalse );
       
  2977     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTMagSweepEffectDefinition case)!" );
       
  2978     TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTMagSweepEffectDefinition case)!" );
       
  2979 
       
  2980 
       
  2981     // get definition of the first MagSweep effect
       
  2982     CHWRMHaptics::THWRMHapticsMagSweepEffect effectDefinition;
       
  2983     TInt effectIndex = 4;
       
  2984     err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  2985     TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTMagSweepEffectDefinition case)!" );
       
  2986     TEST_ASSERT_DESC( (effectDefinition.iDuration == 3000), "Wrong effect definition (GetIVTMagSweepEffectDefinition case)!" );    
       
  2987 
       
  2988     // get definition from corrupted IVT-data
       
  2989     effectIndex = 0;
       
  2990     err = iHaptics->GetMagSweepEffectDefinition( corruptedFile, effectIndex, effectDefinition );
       
  2991     TEST_ASSERT_DESC( (err == KErrArgument), "Get effect definition from corrupted data, incorrect error code (GetIVTMagSweepEffectDefinition case)!" );
       
  2992 
       
  2993     // get definition of the last MagSweep effect
       
  2994     effectIndex = 5;
       
  2995     err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  2996     TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTMagSweepEffectDefinition case)!" );
       
  2997     TEST_ASSERT_DESC( (effectDefinition.iDuration == 4000), "Wrong effect definition (GetIVTMagSweepEffectDefinition case)!" );    
       
  2998 
       
  2999     // get definition using effect index out of bounds
       
  3000     effectIndex = 6;
       
  3001     err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  3002     TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTMagSweepEffectDefinition case)!" );
       
  3003 
       
  3004     // get definition using effect index not pointing to MagSweep effect
       
  3005     effectIndex = 2;
       
  3006     err = iHaptics->GetMagSweepEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  3007     TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTMagSweepEffectDefinition case)!" );
       
  3008 
       
  3009     // get definition using unknown file handle
       
  3010     effectIndex = 0;
       
  3011     err = iHaptics->GetMagSweepEffectDefinition( unknownFileHandle, effectIndex, effectDefinition );
       
  3012     TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTMagSweepEffectDefinition case)!" );
       
  3013 
       
  3014 
       
  3015     // clean up.. (Teardown() will handle the rest)
       
  3016     err = iHaptics->DeleteAllEffectData();
       
  3017     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTMagSweepEffectDefinition case))" );
       
  3018     return KErrNone;
       
  3019     }
       
  3020 
       
  3021 // ---------------------------------------------------------
       
  3022 // Getting Periodic effect definition from preloaded IVT-data
       
  3023 // ---------------------------------------------------------
       
  3024 // 
       
  3025 TInt CHapticsClientTest::T_GetIVTPeriodicEffectDefinition()
       
  3026     {
       
  3027     TInt fileHandle1;
       
  3028     TInt corruptedFile;
       
  3029     TInt unknownFileHandle = 9;
       
  3030     
       
  3031     // load the IVT effect set 1
       
  3032     TInt err = LoadIVTDataInternal( fileHandle1, EffectSetMT_ivt,
       
  3033                                     sizeof( EffectSetMT_ivt ) );
       
  3034     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTPeriodicEffectDefinition case)!" );
       
  3035     TEST_ASSERT_DESC( fileHandle1, "Loading IVT data failed, empty fileHandle (GetIVTPeriodicEffectDefinition case)!" );
       
  3036 
       
  3037     // load corrupted IVT effect set
       
  3038     err = LoadIVTDataInternal( corruptedFile, CorruptedMT_ivt,
       
  3039                                     sizeof( CorruptedMT_ivt ), EFalse );
       
  3040     TEST_ASSERT_DESC( (err == KErrNone), "Loading IVT data failed (GetIVTPeriodicEffectDefinition case)!" );
       
  3041     TEST_ASSERT_DESC( corruptedFile, "Loading IVT data failed, empty fileHandle (GetIVTPeriodicEffectDefinition case)!" );
       
  3042 
       
  3043 
       
  3044     // get definition of the first Periodic effect
       
  3045     CHWRMHaptics::THWRMHapticsPeriodicEffect effectDefinition;
       
  3046     TInt effectIndex = 2;
       
  3047     err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  3048     TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTPeriodicEffectDefinition case)!" );
       
  3049     TEST_ASSERT_DESC( (effectDefinition.iDuration == 1000), "Wrong effect definition (GetIVTPeriodicEffectDefinition case)!" );    
       
  3050 
       
  3051     // get definition from corrupted IVT-data
       
  3052     effectIndex = 0;
       
  3053     err = iHaptics->GetPeriodicEffectDefinition( corruptedFile, effectIndex, effectDefinition );
       
  3054     TEST_ASSERT_DESC( (err == KErrArgument), "Get effect definition from corrupted data, incorrect error code (GetIVTPeriodicEffectDefinition case)!" );
       
  3055 
       
  3056     // get definition of the last Periodic effect
       
  3057     effectIndex = 3;
       
  3058     err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  3059     TEST_ASSERT_DESC( (err == KErrNone), "Get effect definition failed (GetIVTPeriodicEffectDefinition case)!" );
       
  3060     TEST_ASSERT_DESC( (effectDefinition.iDuration == 2000), "Wrong effect definition (GetIVTPeriodicEffectDefinition case)!" );    
       
  3061 
       
  3062     // get definition using effect index out of bounds
       
  3063     effectIndex = 6;
       
  3064     err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  3065     TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTPeriodicEffectDefinition case)!" );
       
  3066 
       
  3067     // get definition using effect index not pointing to Periodic effect
       
  3068     effectIndex = 5;
       
  3069     err = iHaptics->GetPeriodicEffectDefinition( fileHandle1, effectIndex, effectDefinition );
       
  3070     TEST_ASSERT_DESC( (err != KErrNone), "Get effect definition succeeded (GetIVTPeriodicEffectDefinition case)!" );
       
  3071 
       
  3072     // get definition using unknown file handle
       
  3073     effectIndex = 0;
       
  3074     err = iHaptics->GetPeriodicEffectDefinition( unknownFileHandle, effectIndex, effectDefinition );
       
  3075     TEST_ASSERT_DESC( (err == KErrBadHandle), "Incorrect error code (GetIVTPeriodicEffectDefinition case)!" );
       
  3076 
       
  3077 
       
  3078     // clean up.. (Teardown() will handle the rest)
       
  3079     err = iHaptics->DeleteAllEffectData();
       
  3080     TEST_ASSERT_DESC( (err == KErrNone), "Delete All IVT data failed! (GetIVTPeriodicEffectDefinition case))" );
       
  3081     return KErrNone;
       
  3082     }
       
  3083 
       
  3084 // ---------------------------------------------------------
       
  3085 // Open asynchronously and close haptics client-server session, i.e.
       
  3086 // create and delete haptics client.
       
  3087 // ---------------------------------------------------------
       
  3088 //
       
  3089 TInt CHapticsClientTest::T_CreateAndDeleteAsynchronousL()
       
  3090     {
       
  3091     // create iHaptics instance without observers
       
  3092     TRequestStatus status;
       
  3093     iHaptics = CHWRMHaptics::NewL( NULL, NULL, status );
       
  3094     User::WaitForRequest( status );
       
  3095 
       
  3096     // the connection has been opened successfully, if iHaptics is valid and
       
  3097     // error code is not returned
       
  3098     TEST_ASSERT_DESC( status == KErrNone, "Haptics client creation failed!");
       
  3099     TEST_ASSERT_DESC( iHaptics, "Haptics client creation failed!");
       
  3100 
       
  3101     // the connection is closed, when iHaptics is deleted
       
  3102     delete iHaptics;
       
  3103     iHaptics = NULL;
       
  3104     return KErrNone;
       
  3105     }
       
  3106     
       
  3107 // ---------------------------------------------------------
       
  3108 // Create several simultaneous sessions to haptics server
       
  3109 // asynchronously.
       
  3110 // ---------------------------------------------------------
       
  3111 //
       
  3112 TInt CHapticsClientTest::T_SeveralSessionsAsynchronousL()
       
  3113     {
       
  3114     // create haptics instances without observers. This creates
       
  3115     // client-server sessions (session instances in the server)
       
  3116     TRequestStatus status1;
       
  3117     TRequestStatus status2;
       
  3118     TRequestStatus status3;
       
  3119     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL, status1 );
       
  3120     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL, status2 );
       
  3121     CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL, status3 );
       
  3122     User::WaitForRequest( status1 );
       
  3123     User::WaitForRequest( status2 );
       
  3124     User::WaitForRequest( status3 );
       
  3125 
       
  3126     // the connection has been opened successfully, if instances are valid and
       
  3127     // error code is not returned
       
  3128     TEST_ASSERT_DESC( status1 == KErrNone, "First haptics client creation failed!");
       
  3129     TEST_ASSERT_DESC( status2 == KErrNone, "Second haptics client creation failed!");
       
  3130     TEST_ASSERT_DESC( status3 == KErrNone, "Third haptics client creation failed!");
       
  3131     TEST_ASSERT_DESC( haptics1, "First haptics client creation failed!");
       
  3132     TEST_ASSERT_DESC( haptics2, "Second haptics client creation failed!");
       
  3133     TEST_ASSERT_DESC( haptics3, "Third haptics client creation failed!");
       
  3134 
       
  3135     // delete haptics instances. This removes the sessions from 
       
  3136     // haptics server, and closes the server, when the last session 
       
  3137     // is closed
       
  3138     delete haptics1; haptics1 = NULL;
       
  3139     delete haptics2; haptics2 = NULL;
       
  3140     delete haptics3; haptics3 = NULL;
       
  3141     return KErrNone;
       
  3142     }
       
  3143 
       
  3144 // ---------------------------------------------------------
       
  3145 // Create several consecutive sessions asynchronously
       
  3146 // to haptics server.
       
  3147 // ---------------------------------------------------------
       
  3148 //
       
  3149 TInt CHapticsClientTest::T_ConsecutiveSessionsAsynchronousL()
       
  3150     {
       
  3151     // Do create and delete three times in a row
       
  3152     T_CreateAndDeleteAsynchronousL();
       
  3153     T_CreateAndDeleteAsynchronousL();
       
  3154     T_CreateAndDeleteAsynchronousL();
       
  3155     return KErrNone;
       
  3156     }
       
  3157     
       
  3158 // ---------------------------------------------------------
       
  3159 // Attemps to pause an effect.
       
  3160 // ---------------------------------------------------------
       
  3161 //
       
  3162 TInt CHapticsClientTest::T_PauseEffect()
       
  3163     {
       
  3164     // open a supported actuator
       
  3165     T_OpenSupportedActuator();
       
  3166     
       
  3167     // pause effect testing
       
  3168     TInt err = iHaptics->PausePlayingEffect( 0 );
       
  3169     TEST_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle 0 failed!");
       
  3170     err = iHaptics->PausePlayingEffect( INT_MIN );
       
  3171     TEST_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle INT_MIN failed!");
       
  3172     err = iHaptics->PausePlayingEffect( INT_MAX );
       
  3173     TEST_ASSERT_DESC( err == KErrNone, "Pausing an effect with handle INT_MAX failed!");
       
  3174     return err;
       
  3175     }
       
  3176 
       
  3177 // ---------------------------------------------------------
       
  3178 // Attemps to resume an effect.
       
  3179 // ---------------------------------------------------------
       
  3180 //
       
  3181 TInt CHapticsClientTest::T_ResumeEffect()
       
  3182     {
       
  3183     // open a supported actuator
       
  3184     T_OpenSupportedActuator();
       
  3185     
       
  3186     // resume effect testing
       
  3187     TInt err = iHaptics->ResumePausedEffect( 0 );
       
  3188     TEST_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle 0 failed!");
       
  3189     err = iHaptics->ResumePausedEffect( INT_MIN );
       
  3190     TEST_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle INT_MIN failed!");
       
  3191     err = iHaptics->ResumePausedEffect( INT_MAX );
       
  3192     TEST_ASSERT_DESC( err == KErrNone, "Resuming an effect with handle INT_MAX failed!");
       
  3193     return err;
       
  3194     }
       
  3195 
       
  3196 // ---------------------------------------------------------
       
  3197 // Attemps to stop an effect.
       
  3198 // ---------------------------------------------------------
       
  3199 //
       
  3200 TInt CHapticsClientTest::T_StopEffect()
       
  3201     {
       
  3202     // open a supported actuator
       
  3203     T_OpenSupportedActuator();
       
  3204     
       
  3205     // stop effect testing
       
  3206     TInt err = iHaptics->StopPlayingEffect( 0 );
       
  3207     TEST_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle 0 failed!");
       
  3208     err = iHaptics->StopPlayingEffect( INT_MIN );
       
  3209     TEST_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle INT_MIN failed!");
       
  3210     err = iHaptics->StopPlayingEffect( INT_MAX );
       
  3211     TEST_ASSERT_DESC( err == KErrNone, "Stopping an effect with handle INT_MAX failed!");
       
  3212     return err;
       
  3213     }
       
  3214 
       
  3215 // ---------------------------------------------------------
       
  3216 // Attemps to stop all effects.
       
  3217 // ---------------------------------------------------------
       
  3218 //
       
  3219 TInt CHapticsClientTest::T_StopAllEffects()
       
  3220     {
       
  3221     // open a supported actuator
       
  3222     T_OpenSupportedActuator();
       
  3223     
       
  3224     // resume effect testing
       
  3225     TInt err = iHaptics->StopAllPlayingEffects();
       
  3226     TEST_ASSERT_DESC( err == KErrNone, "Stopping all effects failed!");
       
  3227     return err;
       
  3228     }
       
  3229 
       
  3230 // ---------------------------------------------------------
       
  3231 // Executes sequence: play effect, pause, resume, stop.
       
  3232 // ---------------------------------------------------------
       
  3233 //
       
  3234 TInt CHapticsClientTest::T_PlayPauseResumeStop()
       
  3235     {
       
  3236     // open a supported actuator
       
  3237     T_OpenSupportedActuator();
       
  3238     
       
  3239     // read magsweep effect to buffer
       
  3240     RBuf8 effBuf;
       
  3241     CleanupClosePushL( effBuf );
       
  3242     CreateIVTEffect( effBuf, CHWRMHaptics::EHWRMHapticsTypeMagSweep );
       
  3243     
       
  3244     // play the effect  
       
  3245     TInt effectHandle = 0;
       
  3246     TInt err = iHaptics->PlayEffect( effBuf, 0, effectHandle ); 
       
  3247     TEST_ASSERT_DESC( (err == KErrNone), "Playing IVT effect synchronously failed!" );
       
  3248     TEST_ASSERT_DESC( effectHandle, "Playing IVT effect synchronously returned empty effect handle!" );
       
  3249 
       
  3250     // cleanup buffer
       
  3251     CleanupStack::PopAndDestroy( &effBuf );
       
  3252 
       
  3253     // pause the effect
       
  3254     err = iHaptics->PausePlayingEffect( effectHandle );
       
  3255     TEST_ASSERT_DESC( err == KErrNone, "Pausing the effect failed!");
       
  3256 
       
  3257     // resume the effect
       
  3258     err = iHaptics->ResumePausedEffect( effectHandle );
       
  3259     TEST_ASSERT_DESC( err == KErrNone, "Resuming the effect failed!");
       
  3260 
       
  3261     // stop the effect
       
  3262     err = iHaptics->StopPlayingEffect( effectHandle );
       
  3263     TEST_ASSERT_DESC( err == KErrNone, "Stopping the effect failed!");
       
  3264     return err;
       
  3265     }
       
  3266 
       
  3267 // ---------------------------------------------------------
       
  3268 // Constant getters testing.
       
  3269 // ---------------------------------------------------------
       
  3270 //
       
  3271 TInt CHapticsClientTest::T_ConstantGetters()
       
  3272     {
       
  3273     const TInt expectedInfRepeat          = 255;     // VIBE_REPEAT_COUNT_INFINITE
       
  3274     const TInt expectedInfDuration        = INT_MAX; // VIBE_TIME_INFINITE;
       
  3275     const TInt expectedMaxEffNameLen      = 128;     // VIBE_MAX_EFFECT_NAME_LENGTH
       
  3276     const TInt expectedMaxDevNameLen      = 64;      // VIBE_MAX_DEVICE_NAME_LENGTH
       
  3277     const TInt expectedMaxCapaStrLen      = 64;      // VIBE_MAX_CAPABILITY_STRING_LENGTH
       
  3278     const TInt expectedMaxPropStrLen      = 64;      // VIBE_MAX_PROPERTY_STRING_LENGTH
       
  3279     const TInt expectedMaxStrmSampleLen   = 255;     // VIBE_MAX_STREAMING_SAMPLE_SIZE
       
  3280     const TInt expectedDefaultDevPriority = 0;       // VIBE_DEVPRIORITY_DEFAULT
       
  3281 
       
  3282     TInt infRepeat = iHaptics->InfiniteRepeat();
       
  3283     TEST_ASSERT_DESC( KErrNotReady == infRepeat, "InfiniteRepeat() wrong error code" );
       
  3284     TInt infDuration = iHaptics->InfiniteDuration();
       
  3285     TEST_ASSERT_DESC( KErrNotReady == infDuration, "InfiniteDuration() wrong error code" );
       
  3286     TInt maxEffNameLen = iHaptics->MaxEffectNameLength();
       
  3287     TEST_ASSERT_DESC( KErrNotReady == maxEffNameLen, "MaxEffectNameLength() wrong error code" );
       
  3288     TInt maxDevNameLen = iHaptics->MaxDeviceNameLength();
       
  3289     TEST_ASSERT_DESC( KErrNotReady == maxDevNameLen, "MaxDeviceNameLength() wrong error code" );
       
  3290     TInt maxCapaStrLen = iHaptics->MaxCapabilityStringLength();
       
  3291     TEST_ASSERT_DESC( KErrNotReady == maxCapaStrLen, "MaxCapabilityStringLength() wrong error code" );
       
  3292     TInt maxPropStrLen = iHaptics->MaxPropertyStringLength();
       
  3293     TEST_ASSERT_DESC( KErrNotReady == maxPropStrLen, "MaxPropertyStringLength() wrong error code" );
       
  3294     TInt maxStrmSampleLen = iHaptics->MaxStreamingSampleSize();
       
  3295     TEST_ASSERT_DESC( KErrNotReady == maxStrmSampleLen, "MaxStreamingSampleSize() wrong error code" );
       
  3296     TInt defaultDevPriority = iHaptics->DefaultDevicePriority();
       
  3297     TEST_ASSERT_DESC( KErrNotReady == defaultDevPriority, "DefaultDevicePriority() wrong error code" );
       
  3298 
       
  3299     // open a supported actuator
       
  3300     T_OpenSupportedActuator();
       
  3301 
       
  3302     infRepeat = iHaptics->InfiniteRepeat();
       
  3303     TEST_ASSERT_DESC( expectedInfRepeat == infRepeat, "InfiniteRepeat() failed" );
       
  3304     infDuration = iHaptics->InfiniteDuration();
       
  3305     TEST_ASSERT_DESC( expectedInfDuration == infDuration, "InfiniteDuration() failed" );
       
  3306     maxEffNameLen = iHaptics->MaxEffectNameLength();
       
  3307     TEST_ASSERT_DESC( expectedMaxEffNameLen == maxEffNameLen, "MaxEffectNameLength() failed" );
       
  3308     maxDevNameLen = iHaptics->MaxDeviceNameLength();
       
  3309     TEST_ASSERT_DESC( expectedMaxDevNameLen == maxDevNameLen, "MaxDeviceNameLength() failed" );
       
  3310     maxCapaStrLen = iHaptics->MaxCapabilityStringLength();
       
  3311     TEST_ASSERT_DESC( expectedMaxCapaStrLen == maxCapaStrLen, "MaxCapabilityStringLength() failed" );
       
  3312     maxPropStrLen = iHaptics->MaxPropertyStringLength();
       
  3313     TEST_ASSERT_DESC( expectedMaxPropStrLen == maxPropStrLen, "MaxPropertyStringLength() failed" );
       
  3314     maxStrmSampleLen = iHaptics->MaxStreamingSampleSize();
       
  3315     TEST_ASSERT_DESC( expectedMaxStrmSampleLen == maxStrmSampleLen, "MaxStreamingSampleSize() failed" );
       
  3316     defaultDevPriority = iHaptics->DefaultDevicePriority();
       
  3317     TEST_ASSERT_DESC( expectedDefaultDevPriority == defaultDevPriority, "DefaultDevicePriority() failed" );
       
  3318     return KErrNone;
       
  3319     }
       
  3320 
       
  3321 
       
  3322 // ---------------------------------------------------------
       
  3323 // Modifies playing magsweep effect using synchronous API call.
       
  3324 // ---------------------------------------------------------
       
  3325 //
       
  3326 TInt CHapticsClientTest::T_ModifyMagSweepEffectSynchronous()
       
  3327     {
       
  3328     // open actuator.. 
       
  3329     T_OpenSupportedActuator();
       
  3330     
       
  3331     // modify effect
       
  3332     CHWRMHaptics::THWRMHapticsMagSweepEffect modifiedEffect;
       
  3333     modifiedEffect.iDuration    = 3030;
       
  3334     modifiedEffect.iMagnitude   = 7070;
       
  3335     modifiedEffect.iStyle       = CHWRMHaptics::EHWRMHapticsStyleStrong;
       
  3336     modifiedEffect.iAttackTime  = 2000;
       
  3337     modifiedEffect.iAttackLevel = 500;
       
  3338     modifiedEffect.iFadeTime    = 100;
       
  3339     modifiedEffect.iFadeLevel   = 10;
       
  3340 
       
  3341     TInt err = iHaptics->ModifyPlayingMagSweepEffect( 0, modifiedEffect );
       
  3342     TEST_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle 0 failed!" );
       
  3343 
       
  3344     err = iHaptics->ModifyPlayingMagSweepEffect( INT_MIN, modifiedEffect );
       
  3345     TEST_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle INT_MIN failed!" );
       
  3346 
       
  3347     err = iHaptics->ModifyPlayingMagSweepEffect( INT_MAX, modifiedEffect );
       
  3348     TEST_ASSERT_DESC( (err == KErrNone), "Modifying magsweep effect with handle INT_MAX failed!" );
       
  3349     return err;
       
  3350     }
       
  3351 
       
  3352 
       
  3353 // ---------------------------------------------------------
       
  3354 // Modifies playing magsweep effect using asynchronous API call.
       
  3355 // ---------------------------------------------------------
       
  3356 //
       
  3357 TInt CHapticsClientTest::T_ModifyMagSweepEffectAsynchronous()
       
  3358     {
       
  3359     // open actuator.. 
       
  3360     T_OpenSupportedActuator();
       
  3361     
       
  3362     // modify effect
       
  3363     CHWRMHaptics::THWRMHapticsMagSweepEffect modifiedEffect;
       
  3364     modifiedEffect.iDuration    = 5050;
       
  3365     modifiedEffect.iMagnitude   = 1010;
       
  3366     modifiedEffect.iStyle       = CHWRMHaptics::EHWRMHapticsStyleStrong;
       
  3367     modifiedEffect.iAttackTime  = 2000;
       
  3368     modifiedEffect.iAttackLevel = 500;
       
  3369     modifiedEffect.iFadeTime    = 100;
       
  3370     modifiedEffect.iFadeLevel   = 10;
       
  3371 
       
  3372     TRequestStatus status = KRequestPending;
       
  3373     iHaptics->ModifyPlayingMagSweepEffect( 0, modifiedEffect, status );
       
  3374     User::WaitForRequest( status );
       
  3375     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle 0 failed!" );
       
  3376 
       
  3377     status = KRequestPending;
       
  3378     iHaptics->ModifyPlayingMagSweepEffect( INT_MIN, modifiedEffect, status );
       
  3379     User::WaitForRequest( status );
       
  3380     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle INT_MIN failed!" );
       
  3381 
       
  3382     status = KRequestPending;
       
  3383     iHaptics->ModifyPlayingMagSweepEffect( INT_MAX, modifiedEffect, status );
       
  3384     User::WaitForRequest( status );
       
  3385     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying magsweep effect with handle INT_MAX failed!" );
       
  3386     return KErrNone;
       
  3387     }
       
  3388 
       
  3389 
       
  3390 // ---------------------------------------------------------
       
  3391 // Modifies playing periodic effect using synchronous API call.
       
  3392 // ---------------------------------------------------------
       
  3393 //  
       
  3394 TInt CHapticsClientTest::T_ModifyPeriodicEffectSynchronous()
       
  3395     {
       
  3396     // open actuator.. 
       
  3397     T_OpenSupportedActuator();
       
  3398     
       
  3399     // modify effect
       
  3400     CHWRMHaptics::THWRMHapticsPeriodicEffect modifiedEffect;
       
  3401     modifiedEffect.iDuration    = 6060;
       
  3402     modifiedEffect.iMagnitude   = 2020;
       
  3403     modifiedEffect.iPeriod      = 200;
       
  3404     modifiedEffect.iStyle       = CHWRMHaptics::EHWRMHapticsStyleStrong;
       
  3405     modifiedEffect.iAttackTime  = 2000;
       
  3406     modifiedEffect.iAttackLevel = 500;
       
  3407     modifiedEffect.iFadeTime    = 100;
       
  3408     modifiedEffect.iFadeLevel   = 10;
       
  3409 
       
  3410     TInt err = iHaptics->ModifyPlayingPeriodicEffect( 0, modifiedEffect );
       
  3411     TEST_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle 0 failed!" );
       
  3412     
       
  3413     err = iHaptics->ModifyPlayingPeriodicEffect( INT_MIN, modifiedEffect );
       
  3414     TEST_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle INT_MIN failed!" );
       
  3415 
       
  3416     err = iHaptics->ModifyPlayingPeriodicEffect( INT_MAX, modifiedEffect );
       
  3417     TEST_ASSERT_DESC( (err == KErrNone), "Modifying periodic effect with handle INT_MAX failed!" );
       
  3418     return err;
       
  3419     }
       
  3420 
       
  3421 
       
  3422 // ---------------------------------------------------------
       
  3423 // Modifies playing periodic effect using asynchronous API call.
       
  3424 // ---------------------------------------------------------
       
  3425 //  
       
  3426 TInt CHapticsClientTest::T_ModifyPeriodicEffectAsynchronous()
       
  3427     {
       
  3428     // open actuator.. 
       
  3429     T_OpenSupportedActuator();
       
  3430 
       
  3431     // modify effect
       
  3432     CHWRMHaptics::THWRMHapticsPeriodicEffect modifiedEffect;
       
  3433     modifiedEffect.iDuration    = 4040;
       
  3434     modifiedEffect.iMagnitude   = 6060;
       
  3435     modifiedEffect.iPeriod      = 200;
       
  3436     modifiedEffect.iStyle       = CHWRMHaptics::EHWRMHapticsStyleStrong;
       
  3437     modifiedEffect.iAttackTime  = 2000;
       
  3438     modifiedEffect.iAttackLevel = 500;
       
  3439     modifiedEffect.iFadeTime    = 100;
       
  3440     modifiedEffect.iFadeLevel   = 10;
       
  3441 
       
  3442     TRequestStatus status = KRequestPending;
       
  3443     iHaptics->ModifyPlayingPeriodicEffect( 0, modifiedEffect, status );
       
  3444     User::WaitForRequest( status );
       
  3445     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle 0 failed!" );
       
  3446 
       
  3447     status = KRequestPending;
       
  3448     iHaptics->ModifyPlayingPeriodicEffect( INT_MIN, modifiedEffect, status );
       
  3449     User::WaitForRequest( status );
       
  3450     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle INT_MIN failed!" );
       
  3451 
       
  3452     status = KRequestPending;
       
  3453     iHaptics->ModifyPlayingPeriodicEffect( INT_MAX, modifiedEffect, status );
       
  3454     User::WaitForRequest( status );
       
  3455     TEST_ASSERT_DESC( (status.Int() == KErrNone), "Modifying periodic effect with handle INT_MAX failed!" );
       
  3456     return KErrNone;
       
  3457     }
       
  3458 
       
  3459 // ---------------------------------------------------------
       
  3460 // Gets device TInt property
       
  3461 // ---------------------------------------------------------
       
  3462 //  
       
  3463 TInt CHapticsClientTest::T_GetDeviceProperty_TInt_TInt()
       
  3464     {
       
  3465     // open actuator.. 
       
  3466     T_OpenSupportedActuator();
       
  3467     
       
  3468     // get the same value 1
       
  3469     TInt retValue (0);
       
  3470     TInt err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, retValue );
       
  3471     TEST_ASSERT_DESC( (err == KErrNone), "Getting device property (Strength) failed(1)!" );
       
  3472 
       
  3473     err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, retValue );
       
  3474     TEST_ASSERT_DESC( (err == KErrNone), "Getting device property (disableEffects) failed(1)!" );
       
  3475     return err;
       
  3476     }
       
  3477 
       
  3478 // ---------------------------------------------------------
       
  3479 // Gets device TDesC property
       
  3480 // ---------------------------------------------------------
       
  3481 //  
       
  3482 TInt CHapticsClientTest::T_GetDeviceProperty_TInt_TDesC()
       
  3483     {
       
  3484     // open actuator.. 
       
  3485     T_OpenSupportedActuator();
       
  3486     
       
  3487     // get property 
       
  3488     TBuf8<100> retValue;
       
  3489     TInt err = iHaptics->GetDeviceProperty( CHWRMHaptics::EHWRMHapticsLicensekey, retValue );
       
  3490     TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (EHWRMHapticsLicensekey) failed!" );
       
  3491     return err;
       
  3492     }
       
  3493 
       
  3494 // ---------------------------------------------------------
       
  3495 // Sets device TInt property
       
  3496 // ---------------------------------------------------------
       
  3497 //  
       
  3498 TInt CHapticsClientTest::T_SetDeviceProperty_TInt_TInt()
       
  3499     {
       
  3500     const TInt KSomeValue = 50; 
       
  3501     // open actuator.. 
       
  3502     T_OpenSupportedActuator();
       
  3503     
       
  3504     // set property 
       
  3505     TInt err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsStrength, KSomeValue ); 
       
  3506     TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (Strength) failed!" );
       
  3507 
       
  3508     err = iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsDisableEffects, 0 ); 
       
  3509     TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (disableEffects) failed!" );
       
  3510     return err;
       
  3511     }
       
  3512 
       
  3513 // ---------------------------------------------------------
       
  3514 // Sets device TDesC property
       
  3515 // ---------------------------------------------------------
       
  3516 //  
       
  3517 TInt CHapticsClientTest::T_SetDeviceProperty_TInt_TDesC()
       
  3518     {
       
  3519     // open actuator.. 
       
  3520     T_OpenSupportedActuator();
       
  3521     
       
  3522     // set property    
       
  3523     TInt err = iHaptics->SetDeviceProperty( 
       
  3524                 CHWRMHaptics::EHWRMHapticsLicensekey, 
       
  3525                 KNullDesC8 ); 
       
  3526     TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (NULL license key) failed!" );
       
  3527 
       
  3528     err = iHaptics->SetDeviceProperty( 
       
  3529                 CHWRMHaptics::EHWRMHapticsLicensekey, 
       
  3530                 KPlainKey ); 
       
  3531     TEST_ASSERT_DESC( (err == KErrNone), "Setting device property (license key) failed!" );
       
  3532     return err;
       
  3533     }
       
  3534 
       
  3535 TInt CHapticsClientTest::T_PluginMgrTransTimerExpires()
       
  3536     {
       
  3537     // open actuator.. 
       
  3538     T_OpenSupportedActuator();
       
  3539 
       
  3540     _LIT8 ( KTestPluginMgrTransTimerExpires, "KTestPluginMgrTransTimerExpires" );
       
  3541     // set property with the TestCase ID string, so that the test plug-in doesn't send the response for the current
       
  3542     // transaction, till the Plug-in manager Transction timer expires.
       
  3543     // Out-come: Plug-in manager should hanlde this scenario and send cancel transaction command to test plug-in.
       
  3544     TInt err = iHaptics->SetDeviceProperty( 
       
  3545                 CHWRMHaptics::EHWRMHapticsLicensekey, 
       
  3546                 KTestPluginMgrTransTimerExpires ); 
       
  3547     TEST_ASSERT_DESC( (err == KErrTimedOut), "Setting device property (license key) failed!" );
       
  3548     return KErrNone;
       
  3549     }
       
  3550 
       
  3551 // ---------------------------------------------------------
       
  3552 // Gets device TInt capability
       
  3553 // ---------------------------------------------------------
       
  3554 //  
       
  3555 TInt CHapticsClientTest::T_GetDeviceCapability_TInt_TInt()
       
  3556     {
       
  3557     // open actuator.. 
       
  3558     T_OpenSupportedActuator();
       
  3559     
       
  3560     // get the value
       
  3561     TInt retValue (0);
       
  3562     TInt expectedValue (1); // from testplugin's stubresponse.txt
       
  3563     TInt err = iHaptics->GetDeviceCapability( CHWRMHaptics::EHWRMHapticsMaxNestedRepeats, retValue ); 
       
  3564     TEST_ASSERT_DESC( (err == KErrNone), 
       
  3565                        "Getting device property (MaxNestedRepeats) failed!" );
       
  3566     TEST_ASSERT_DESC( expectedValue == retValue, 
       
  3567                        "Getting device property (MaxNestedRepeats) failed, wrong value!")                   
       
  3568     return err;
       
  3569     }
       
  3570 
       
  3571 // ---------------------------------------------------------
       
  3572 // Gets device TDesC capability
       
  3573 // ---------------------------------------------------------
       
  3574 //  
       
  3575 TInt CHapticsClientTest::T_GetDeviceCapability_TInt_TDesC()
       
  3576     {
       
  3577     // open actuator.. 
       
  3578     T_OpenSupportedActuator();
       
  3579     
       
  3580     // get the same value
       
  3581     TBuf8<100> retValue;
       
  3582     retValue.FillZ(); // sets length, important here..
       
  3583     TInt err = iHaptics->GetDeviceCapability( CHWRMHaptics::EHWRMHapticsDeviceName, retValue ); 
       
  3584     TEST_ASSERT_DESC( (err == KErrNone), "Getting device property (DevName) failed!" );
       
  3585     // the following are based on what the testplugin retunrs (i.e., bytes 
       
  3586     // containing the ASCII character values for "S","T","U" and "B")
       
  3587     const TInt expectedSize( 4 );
       
  3588     TEST_ASSERT_DESC( expectedSize == retValue.Size(),
       
  3589         "Getting device property (DevName) failed, wrong length!" );
       
  3590     const TUint8 ascii4S( 0x53 );
       
  3591     const TUint8 ascii4T( 0x54 );
       
  3592     const TUint8 ascii4U( 0x55 );
       
  3593     const TUint8 ascii4B( 0x42 );   
       
  3594     TEST_ASSERT_DESC( ascii4S == retValue[0] && ascii4T == retValue[1] &&
       
  3595                        ascii4U == retValue[2] && ascii4B == retValue[3],
       
  3596         "Getting device property (DevName) failed, wrong data!" );
       
  3597     return KErrNone;
       
  3598     }
       
  3599 
       
  3600 // ---------------------------------------------------------
       
  3601 // Fetches the haptics status using the getter method.
       
  3602 // ---------------------------------------------------------
       
  3603 //
       
  3604 TInt CHapticsClientTest::T_GetHapticsStatus()
       
  3605     {
       
  3606     MHWRMHapticsObserver::THWRMHapticsStatus status = iHaptics->HapticsStatus();
       
  3607     TEST_ASSERT_DESC( (status == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable), 
       
  3608                        "Invalid haptics status received!" );
       
  3609     return KErrNone;
       
  3610     }
       
  3611 
       
  3612 // ---------------------------------------------------------
       
  3613 // Fetches the haptics status using the observer.
       
  3614 // ---------------------------------------------------------
       
  3615 //
       
  3616 TInt CHapticsClientTest::T_ObserveHapticsStatus()
       
  3617     {
       
  3618     // create callback instance
       
  3619     THapticsStatusCallback callback( this );
       
  3620     
       
  3621     // create haptics client with observer
       
  3622     CHWRMHaptics* haptics = CHWRMHaptics::NewL( &callback, NULL );
       
  3623 
       
  3624     // wait for the callback to be called
       
  3625     iWait.Start();
       
  3626     
       
  3627     // check status (since execution of this method continues, the status
       
  3628     // has been updated in the callback)
       
  3629     TEST_ASSERT_DESC( (callback.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable), 
       
  3630                        "Invalid haptics status received!" );
       
  3631 
       
  3632     // cleanup
       
  3633     delete haptics;
       
  3634     return KErrNone;
       
  3635     }
       
  3636 
       
  3637 // ---------------------------------------------------------
       
  3638 // Fetches status values, when one client is reserving 
       
  3639 // haptics.
       
  3640 // ---------------------------------------------------------
       
  3641 //
       
  3642 TInt CHapticsClientTest::T_GetHapticsStatusWithReservations()
       
  3643     {
       
  3644     // create haptics instances
       
  3645     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
  3646     CleanupStack::PushL( haptics1 );
       
  3647     
       
  3648     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  3649     CleanupStack::PushL( haptics2 );
       
  3650 
       
  3651     // make reservation using the first client
       
  3652     haptics1->ReserveHapticsL();
       
  3653 
       
  3654     // check client status values
       
  3655     MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus();
       
  3656     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3657                        "Invalid haptics status received!" );
       
  3658     MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus();
       
  3659     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3660                        "Invalid haptics status received!" );
       
  3661 
       
  3662     // release reservation
       
  3663     haptics1->ReleaseHaptics();
       
  3664 
       
  3665     // check client status values
       
  3666     status1 = haptics1->HapticsStatus();
       
  3667     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3668                        "Invalid haptics status received!" );
       
  3669     status2 = haptics2->HapticsStatus();
       
  3670     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3671                        "Invalid haptics status received!" );
       
  3672 
       
  3673     // cleanup
       
  3674     CleanupStack::PopAndDestroy( haptics2 );
       
  3675     CleanupStack::PopAndDestroy( haptics1 );
       
  3676     return KErrNone;
       
  3677     }
       
  3678 
       
  3679 // ---------------------------------------------------------
       
  3680 // Status value observing, when one client is reserving
       
  3681 // haptics.
       
  3682 // ---------------------------------------------------------
       
  3683 //
       
  3684 TInt CHapticsClientTest::T_ObserveHapticsStatusWithReservations()
       
  3685     {
       
  3686     // create callback instances
       
  3687     THapticsStatusCallback callback1( this );
       
  3688     THapticsStatusCallback callback2( this );
       
  3689 
       
  3690     // create haptics instances
       
  3691     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL );
       
  3692     CleanupStack::PushL( haptics1 );
       
  3693     
       
  3694     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL );
       
  3695     CleanupStack::PushL( haptics2 );
       
  3696 
       
  3697     // wait for the initial notifications to arrive
       
  3698     iWait.Start();
       
  3699     iWait.Start();
       
  3700 
       
  3701     // make reservation using the first client
       
  3702     haptics1->ReserveHapticsL();
       
  3703     
       
  3704     // wait for the callback to be called (only second client 
       
  3705     // should receive notification)
       
  3706     iWait.Start();
       
  3707 
       
  3708     // check client status values
       
  3709     MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status();
       
  3710     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3711                        "Invalid haptics status received!" );
       
  3712 
       
  3713     // release reservation
       
  3714     haptics1->ReleaseHaptics();
       
  3715 
       
  3716     // wait for the callback to be called (only second client 
       
  3717     // should receive notification)
       
  3718     iWait.Start();
       
  3719 
       
  3720     // check client status values
       
  3721     status2 = callback2.Status();
       
  3722     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3723                        "Invalid haptics status received!" );
       
  3724 
       
  3725     // cleanup
       
  3726     CleanupStack::PopAndDestroy( haptics2 );
       
  3727     CleanupStack::PopAndDestroy( haptics1 );
       
  3728     return KErrNone;
       
  3729     }
       
  3730 
       
  3731 // ---------------------------------------------------------
       
  3732 // Haptics status, when several clients are making 
       
  3733 // reservations with equal priorities.
       
  3734 // ---------------------------------------------------------
       
  3735 //
       
  3736 TInt CHapticsClientTest::T_GetHapticsStatusWithSeveralReservations()
       
  3737     {
       
  3738     // create haptics instances
       
  3739     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
  3740     CleanupStack::PushL( haptics1 );
       
  3741     
       
  3742     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  3743     CleanupStack::PushL( haptics2 );
       
  3744     
       
  3745     // make reservation using both clients (second should become suspended)
       
  3746     haptics1->ReserveHapticsL();
       
  3747     haptics2->ReserveHapticsL();
       
  3748 
       
  3749     // check client status values
       
  3750     MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus();
       
  3751     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3752                        "Invalid haptics status received!" );
       
  3753     MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus();
       
  3754     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), 
       
  3755                        "Invalid haptics status received!" );
       
  3756     
       
  3757     // release reservation of the first client
       
  3758     haptics1->ReleaseHaptics();
       
  3759     
       
  3760     // check client status values
       
  3761     status1 = haptics1->HapticsStatus();
       
  3762     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3763                        "Invalid haptics status received!" );
       
  3764     status2 = haptics2->HapticsStatus();
       
  3765     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3766                        "Invalid haptics status received!" );
       
  3767     
       
  3768     // release reservation of the second client
       
  3769     haptics2->ReleaseHaptics();
       
  3770     
       
  3771     // check client status values
       
  3772     status1 = haptics1->HapticsStatus();
       
  3773     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3774                        "Invalid haptics status received!" );
       
  3775     status2 = haptics2->HapticsStatus();
       
  3776     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3777                        "Invalid haptics status received!" );
       
  3778 
       
  3779     // cleanup
       
  3780     CleanupStack::PopAndDestroy( haptics2 );
       
  3781     CleanupStack::PopAndDestroy( haptics1 );
       
  3782     return KErrNone;
       
  3783     }
       
  3784 
       
  3785 // ---------------------------------------------------------
       
  3786 // Haptics status using observation, when several clients 
       
  3787 // are making reservations with equal priorities.
       
  3788 // ---------------------------------------------------------
       
  3789 //
       
  3790 TInt CHapticsClientTest::T_ObserveHapticsStatusWithSeveralReservations()
       
  3791     {
       
  3792     // create callback instances
       
  3793     THapticsStatusCallback callback1( this );
       
  3794     THapticsStatusCallback callback2( this );
       
  3795 
       
  3796     // create haptics instances
       
  3797     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL );
       
  3798     CleanupStack::PushL( haptics1 );
       
  3799     
       
  3800     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL );
       
  3801     CleanupStack::PushL( haptics2 );
       
  3802 
       
  3803     // wait for the initial notifications to arrive
       
  3804     iWait.Start();
       
  3805     iWait.Start();
       
  3806 
       
  3807     // make reservation using the first client
       
  3808     haptics1->ReserveHapticsL();
       
  3809 
       
  3810     // wait for the callback to be called (only second client 
       
  3811     // should receive notification)
       
  3812     iWait.Start();
       
  3813 
       
  3814     // check client status values
       
  3815     MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status();
       
  3816     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3817                        "Invalid haptics status received!" );
       
  3818 
       
  3819     // make reservation using the second client
       
  3820     haptics2->ReserveHapticsL();
       
  3821 
       
  3822     // wait for the callback to be called (only second client 
       
  3823     // should receive notification)
       
  3824     iWait.Start();
       
  3825 
       
  3826     // check client status values
       
  3827     status2 = callback2.Status();
       
  3828     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), 
       
  3829                        "Invalid haptics status received!" );
       
  3830 
       
  3831     // release first client's reservation
       
  3832     haptics1->ReleaseHaptics();
       
  3833 
       
  3834     // wait for the callback to be called (both clients should
       
  3835     // receive new status)
       
  3836     iWait.Start();
       
  3837     iWait.Start();
       
  3838 
       
  3839     // check client status values
       
  3840     MHWRMHapticsObserver::THWRMHapticsStatus status1 = callback1.Status();
       
  3841     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3842                        "Invalid haptics status received!" );
       
  3843     status2 = callback2.Status();
       
  3844     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3845                        "Invalid haptics status received!" );
       
  3846 
       
  3847     // release second client's reservation
       
  3848     haptics2->ReleaseHaptics();
       
  3849 
       
  3850     // wait for the callback to be called (only first client 
       
  3851     // should receive notification)
       
  3852     iWait.Start();
       
  3853 
       
  3854     // check client status values
       
  3855     status1 = callback1.Status();
       
  3856     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3857                        "Invalid haptics status received!" );
       
  3858 
       
  3859     // cleanup
       
  3860     CleanupStack::PopAndDestroy( haptics2 );
       
  3861     CleanupStack::PopAndDestroy( haptics1 );
       
  3862     return KErrNone;
       
  3863     }
       
  3864 
       
  3865 // ---------------------------------------------------------
       
  3866 // Several clients with one making a reservation --> tests
       
  3867 // that all other clients become "reserved".
       
  3868 // ---------------------------------------------------------
       
  3869 //
       
  3870 TInt CHapticsClientTest::T_GetHapticsStatusWithSeveralClientsOneReservation()
       
  3871     {
       
  3872     // create haptics instances
       
  3873     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, NULL );
       
  3874     CleanupStack::PushL( haptics1 );
       
  3875     
       
  3876     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  3877     CleanupStack::PushL( haptics2 );
       
  3878 
       
  3879     CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( NULL, NULL );
       
  3880     CleanupStack::PushL( haptics3 );
       
  3881 
       
  3882     // reservation using first client
       
  3883     haptics1->ReserveHapticsL();
       
  3884     
       
  3885     // check client status values
       
  3886     MHWRMHapticsObserver::THWRMHapticsStatus status1 = haptics1->HapticsStatus();
       
  3887     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3888                        "Invalid haptics status received!" );
       
  3889     MHWRMHapticsObserver::THWRMHapticsStatus status2 = haptics2->HapticsStatus();
       
  3890     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3891                        "Invalid haptics status received!" );
       
  3892     MHWRMHapticsObserver::THWRMHapticsStatus status3 = haptics3->HapticsStatus();
       
  3893     TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3894                        "Invalid haptics status received!" );
       
  3895 
       
  3896     // release reservation
       
  3897     haptics1->ReleaseHaptics();
       
  3898 
       
  3899     // check client status values
       
  3900     status1 = haptics1->HapticsStatus();
       
  3901     TEST_ASSERT_DESC( ( status1 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3902                        "Invalid haptics status received!" );
       
  3903     status2 = haptics2->HapticsStatus();
       
  3904     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3905                        "Invalid haptics status received!" );
       
  3906     status3 = haptics3->HapticsStatus();
       
  3907     TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3908                        "Invalid haptics status received!" );
       
  3909 
       
  3910     // cleanup
       
  3911     CleanupStack::PopAndDestroy( haptics3 );
       
  3912     CleanupStack::PopAndDestroy( haptics2 );
       
  3913     CleanupStack::PopAndDestroy( haptics1 );
       
  3914     return KErrNone;
       
  3915     }
       
  3916 
       
  3917 // ---------------------------------------------------------
       
  3918 // Several clients with one making a reservation --> tests
       
  3919 // that all other clients become "reserved" using observers.
       
  3920 // ---------------------------------------------------------
       
  3921 //
       
  3922 TInt CHapticsClientTest::T_ObserveHapticsStatusWithSeveralClientsOneReservations()
       
  3923     {
       
  3924     // create callback instances
       
  3925     THapticsStatusCallback callback1( this );
       
  3926     THapticsStatusCallback callback2( this );
       
  3927     THapticsStatusCallback callback3( this );
       
  3928 
       
  3929     // create haptics instances
       
  3930     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &callback1, NULL );
       
  3931     CleanupStack::PushL( haptics1 );
       
  3932     
       
  3933     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &callback2, NULL );
       
  3934     CleanupStack::PushL( haptics2 );
       
  3935 
       
  3936     CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( &callback3, NULL );
       
  3937     CleanupStack::PushL( haptics3 );
       
  3938 
       
  3939     // wait for the initial notifications to arrive
       
  3940     iWait.Start();
       
  3941     iWait.Start();
       
  3942     iWait.Start();
       
  3943 
       
  3944     // reservation using first client
       
  3945     haptics1->ReserveHapticsL();
       
  3946 
       
  3947     // wait for the notifications for client2 and client3
       
  3948     iWait.Start();
       
  3949     iWait.Start();
       
  3950 
       
  3951     // check client status values
       
  3952     MHWRMHapticsObserver::THWRMHapticsStatus status2 = callback2.Status();
       
  3953     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3954                        "Invalid haptics status received!" );
       
  3955     MHWRMHapticsObserver::THWRMHapticsStatus status3 = callback3.Status();
       
  3956     TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  3957                        "Invalid haptics status received!" );
       
  3958 
       
  3959     // release reservation using first client
       
  3960     haptics1->ReleaseHaptics();
       
  3961 
       
  3962     // wait for the notifications for client2 and client3
       
  3963     iWait.Start();
       
  3964     iWait.Start();
       
  3965 
       
  3966     // check client status values
       
  3967     status2 = callback2.Status();
       
  3968     TEST_ASSERT_DESC( ( status2 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3969                        "Invalid haptics status received!" );
       
  3970     status3 = callback3.Status();
       
  3971     TEST_ASSERT_DESC( ( status3 == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  3972                        "Invalid haptics status received!" );
       
  3973 
       
  3974     // cleanup
       
  3975     CleanupStack::PopAndDestroy( haptics3 );
       
  3976     CleanupStack::PopAndDestroy( haptics2 );
       
  3977     CleanupStack::PopAndDestroy( haptics1 );
       
  3978     return KErrNone;
       
  3979     }
       
  3980 
       
  3981 // ---------------------------------------------------------
       
  3982 // Creates streaming effect.
       
  3983 // ---------------------------------------------------------
       
  3984 //  
       
  3985 TInt CHapticsClientTest::T_CreateStreamingEffect()
       
  3986     {
       
  3987     // open actuator.. 
       
  3988     T_OpenSupportedActuator();
       
  3989     
       
  3990     TInt effectHandle;
       
  3991     TInt err = iHaptics->CreateStreamingEffect( effectHandle );
       
  3992     TEST_ASSERT_DESC( (err == KErrNone), "Creating streaming effect failed!" );
       
  3993     TEST_ASSERT_DESC( effectHandle, "Creating streaming effect returned empty effect handle!" );
       
  3994     return err;
       
  3995     }
       
  3996 
       
  3997 // ---------------------------------------------------------
       
  3998 // Plays streaming sample using synchronous API call.
       
  3999 // ---------------------------------------------------------
       
  4000 //  
       
  4001 TInt CHapticsClientTest::T_PlayStreamingSample()
       
  4002     {
       
  4003     // open actuator.. 
       
  4004     T_OpenSupportedActuator();
       
  4005     RBuf8 validStreamSample;
       
  4006     RBuf8 tooBigStreamSample;
       
  4007     CleanupClosePushL( validStreamSample );
       
  4008     CleanupClosePushL( tooBigStreamSample );
       
  4009     
       
  4010     TInt maxValidSize = iHaptics->MaxStreamingSampleSize();
       
  4011     CreateDummyStreamSample( maxValidSize, validStreamSample );
       
  4012 
       
  4013     // valid sized sample 0 handle 0 offset
       
  4014     TInt err = iHaptics->PlayStreamingSample( 0, validStreamSample );
       
  4015     TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" );
       
  4016 
       
  4017     // normal sample MIN handle MIN offset
       
  4018     err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample );
       
  4019     TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" );
       
  4020 
       
  4021     // normal sample MAX handle MAX offset
       
  4022     err = iHaptics->PlayStreamingSample( INT_MAX, validStreamSample );
       
  4023     TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample failed!" );
       
  4024     
       
  4025     // over sized sample
       
  4026     CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample );
       
  4027     err = iHaptics->PlayStreamingSample( INT_MAX, tooBigStreamSample );
       
  4028     TEST_ASSERT_DESC( (err == KErrArgument), "Play streaming sample (over sized sample), wrong error code" );
       
  4029 
       
  4030 
       
  4031     // Haptics reserved for higher priority client
       
  4032     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  4033     CleanupStack::PushL( haptics2 );
       
  4034 
       
  4035     TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  4036 
       
  4037     // set new client priority to maximum
       
  4038     haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4039                                  KHWRMHapticsMaxDevicePriority );
       
  4040     // set default client priority to min
       
  4041     iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4042                                  KHWRMHapticsMinDevicePriority );
       
  4043     TRAP( error, haptics2->ReserveHapticsL() );
       
  4044 
       
  4045     err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample );
       
  4046     TEST_ASSERT_DESC( ( err == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" );
       
  4047 
       
  4048 
       
  4049 
       
  4050     // clean up.. (Teardown will complete these)
       
  4051     CleanupStack::PopAndDestroy( haptics2 );
       
  4052     CleanupStack::PopAndDestroy(); //tooBigStreamSample
       
  4053     CleanupStack::PopAndDestroy(); //validStreamSample
       
  4054     return KErrNone;
       
  4055     }
       
  4056 
       
  4057 // ---------------------------------------------------------
       
  4058 // Plays streaming sample using asynchronous API call.
       
  4059 // ---------------------------------------------------------
       
  4060 //  
       
  4061 TInt CHapticsClientTest::T_PlayStreamingSampleAsync()
       
  4062     {
       
  4063     // open actuator.. 
       
  4064     T_OpenSupportedActuator();
       
  4065     RBuf8 validStreamSample;
       
  4066     RBuf8 tooBigStreamSample;
       
  4067     CleanupClosePushL( validStreamSample );
       
  4068     CleanupClosePushL( tooBigStreamSample );
       
  4069     
       
  4070     TInt maxValidSize = iHaptics->MaxStreamingSampleSize();
       
  4071     CreateDummyStreamSample( maxValidSize, validStreamSample );
       
  4072 
       
  4073     // normal sample 0 handle 0 offset
       
  4074     TRequestStatus status = KRequestPending;
       
  4075     iHaptics->PlayStreamingSample( 0, validStreamSample, status );
       
  4076     User::WaitForRequest( status );
       
  4077     TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" );
       
  4078 
       
  4079     // normal sample MIN handle MIN offset
       
  4080     status = KRequestPending;
       
  4081     iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status );
       
  4082     User::WaitForRequest( status );
       
  4083     TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" );
       
  4084 
       
  4085     // normal sample MAX handle MAX offset
       
  4086     status = KRequestPending;
       
  4087     iHaptics->PlayStreamingSample( INT_MAX, validStreamSample, status );
       
  4088     User::WaitForRequest( status );
       
  4089     TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample failed!" );
       
  4090     
       
  4091     // over sized sample
       
  4092     CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample );
       
  4093     status = KRequestPending;
       
  4094     iHaptics->PlayStreamingSample( INT_MAX, tooBigStreamSample, status );
       
  4095     User::WaitForRequest( status );
       
  4096     TEST_ASSERT_DESC( (status.Int() == KErrArgument ), "Play streaming sample (over sized sample), wrong error code" );
       
  4097 
       
  4098     // Haptics reserved for higher priority client
       
  4099     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  4100     CleanupStack::PushL( haptics2 );
       
  4101 
       
  4102     TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  4103 
       
  4104     // set new client priority to maximum
       
  4105     haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4106                                  KHWRMHapticsMaxDevicePriority );
       
  4107     // set default client priority to min
       
  4108     iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4109                                  KHWRMHapticsMinDevicePriority );
       
  4110     TRAP( error, haptics2->ReserveHapticsL() );
       
  4111 
       
  4112     status = KRequestPending;
       
  4113     iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status );
       
  4114     User::WaitForRequest( status );
       
  4115     TEST_ASSERT_DESC( (status.Int() == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" );
       
  4116 
       
  4117 
       
  4118 
       
  4119     // clean up.. (Teardown will complete these)
       
  4120     CleanupStack::PopAndDestroy( haptics2 );
       
  4121     CleanupStack::PopAndDestroy(); //tooBigStreamSample
       
  4122     CleanupStack::PopAndDestroy(); //validStreamSample
       
  4123     return KErrNone;
       
  4124     }
       
  4125 
       
  4126 // ---------------------------------------------------------
       
  4127 // Plays streaming sample with offset using
       
  4128 // synchronous API call.
       
  4129 // ---------------------------------------------------------
       
  4130 //  
       
  4131 TInt CHapticsClientTest::T_PlayStreamingSampleWithOffset()
       
  4132     {
       
  4133     // open actuator.. 
       
  4134     T_OpenSupportedActuator();
       
  4135     RBuf8 validStreamSample;
       
  4136     RBuf8 tooBigStreamSample;
       
  4137     CleanupClosePushL( validStreamSample );
       
  4138     CleanupClosePushL( tooBigStreamSample );
       
  4139     
       
  4140     TInt maxValidSize = iHaptics->MaxStreamingSampleSize();
       
  4141     CreateDummyStreamSample( maxValidSize, validStreamSample );
       
  4142 
       
  4143     // valid sized sample 0 handle 0 offset
       
  4144     TInt err = iHaptics->PlayStreamingSampleWithOffset( 0, validStreamSample, 0 );
       
  4145     TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" );
       
  4146 
       
  4147     // normal sample MIN handle MIN offset
       
  4148     err = iHaptics->PlayStreamingSampleWithOffset( INT_MIN, validStreamSample, INT_MIN );
       
  4149     TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" );
       
  4150 
       
  4151     // normal sample MAX handle MAX offset
       
  4152     err = iHaptics->PlayStreamingSampleWithOffset( INT_MAX, validStreamSample, INT_MAX );
       
  4153     TEST_ASSERT_DESC( (err == KErrNone), "Play streaming sample with offset failed!" );
       
  4154     
       
  4155     // over sized sample
       
  4156     CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample );
       
  4157     err = iHaptics->PlayStreamingSampleWithOffset( INT_MAX, tooBigStreamSample, INT_MAX );
       
  4158     TEST_ASSERT_DESC( (err == KErrArgument), "Play streaming sample with offset (over sized sample), wrong error code" );
       
  4159 
       
  4160     // Haptics reserved for higher priority client
       
  4161     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  4162     CleanupStack::PushL( haptics2 );
       
  4163 
       
  4164     TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  4165 
       
  4166     // set new client priority to maximum
       
  4167     haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4168                                  KHWRMHapticsMaxDevicePriority );
       
  4169     // set default client priority to min
       
  4170     iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4171                                  KHWRMHapticsMinDevicePriority );
       
  4172     TRAP( error, haptics2->ReserveHapticsL() );
       
  4173 
       
  4174     err = iHaptics->PlayStreamingSample( INT_MIN, validStreamSample );
       
  4175     TEST_ASSERT_DESC( ( err == KErrInUse ), "Play streaming sample (haptics reserved), wrong error code" );
       
  4176 
       
  4177 
       
  4178 
       
  4179     // clean up.. (Teardown will complete these)
       
  4180     CleanupStack::PopAndDestroy( haptics2 );
       
  4181     CleanupStack::PopAndDestroy(); //tooBigStreamSample
       
  4182     CleanupStack::PopAndDestroy(); //validStreamSample
       
  4183     return KErrNone;
       
  4184     }
       
  4185 
       
  4186 // ---------------------------------------------------------
       
  4187 // Plays streaming sample with offset using
       
  4188 // asynchronous API call.
       
  4189 // ---------------------------------------------------------
       
  4190 //  
       
  4191 TInt CHapticsClientTest::T_PlayStreamingSampleWithOffsetAsync()
       
  4192     {
       
  4193     // open actuator.. 
       
  4194     T_OpenSupportedActuator();
       
  4195     RBuf8 validStreamSample;
       
  4196     RBuf8 tooBigStreamSample;
       
  4197     CleanupClosePushL( validStreamSample );
       
  4198     CleanupClosePushL( tooBigStreamSample );
       
  4199     
       
  4200     TInt maxValidSize = iHaptics->MaxStreamingSampleSize();
       
  4201     CreateDummyStreamSample( maxValidSize, validStreamSample );
       
  4202 
       
  4203     // normal sample 0 handle 0 offset
       
  4204     TRequestStatus status = KRequestPending;
       
  4205     iHaptics->PlayStreamingSampleWithOffset( 0, validStreamSample, 0, status );
       
  4206     User::WaitForRequest( status );
       
  4207     TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" );
       
  4208 
       
  4209     // normal sample MIN handle MIN offset
       
  4210     status = KRequestPending;
       
  4211     iHaptics->PlayStreamingSampleWithOffset( INT_MIN, validStreamSample, INT_MIN, status );
       
  4212     User::WaitForRequest( status );
       
  4213     TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" );
       
  4214 
       
  4215     // normal sample MAX handle MAX offset
       
  4216     status = KRequestPending;
       
  4217     iHaptics->PlayStreamingSampleWithOffset( INT_MAX, validStreamSample, INT_MAX, status );
       
  4218     User::WaitForRequest( status );
       
  4219     TEST_ASSERT_DESC( (status.Int() == KErrNone ), "Play streaming sample with offset failed!" );
       
  4220     
       
  4221     // over sized sample
       
  4222     CreateDummyStreamSample( maxValidSize+1, tooBigStreamSample );
       
  4223     status = KRequestPending;
       
  4224     iHaptics->PlayStreamingSampleWithOffset( INT_MAX, tooBigStreamSample, INT_MAX, status );
       
  4225     User::WaitForRequest( status );
       
  4226     TEST_ASSERT_DESC( (status.Int() == KErrArgument ), "Play streaming sample with offset (over sized sample), wrong error code" );
       
  4227 
       
  4228     // Haptics reserved for higher priority client
       
  4229     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, NULL );
       
  4230     CleanupStack::PushL( haptics2 );
       
  4231 
       
  4232     TRAPD( error, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  4233 
       
  4234     // set new client priority to maximum
       
  4235     haptics2->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4236                                  KHWRMHapticsMaxDevicePriority );
       
  4237     // set default client priority to min
       
  4238     iHaptics->SetDeviceProperty( CHWRMHaptics::EHWRMHapticsPriority, 
       
  4239                                  KHWRMHapticsMinDevicePriority );
       
  4240     TRAP( error, haptics2->ReserveHapticsL() );
       
  4241 
       
  4242     status = KRequestPending;
       
  4243     iHaptics->PlayStreamingSample( INT_MIN, validStreamSample, status );
       
  4244     User::WaitForRequest( status );
       
  4245     TEST_ASSERT_DESC( (status.Int() == KErrInUse ), "Play streaming sample with offset (haptics reserved), wrong error code" );
       
  4246 
       
  4247 
       
  4248 
       
  4249     // clean up.. (Teardown will complete these)
       
  4250     CleanupStack::PopAndDestroy( haptics2 );
       
  4251     CleanupStack::PopAndDestroy(); //tooBigStreamSample
       
  4252     CleanupStack::PopAndDestroy(); //validStreamSample
       
  4253     return KErrNone;
       
  4254     }
       
  4255 
       
  4256 // ---------------------------------------------------------
       
  4257 // Destroys streaming effect.
       
  4258 // ---------------------------------------------------------
       
  4259 //  
       
  4260 TInt CHapticsClientTest::T_DestroyStreamingEffect()
       
  4261     {
       
  4262     // open actuator.. 
       
  4263     T_OpenSupportedActuator();
       
  4264     
       
  4265     // zero handle
       
  4266     TInt err = iHaptics->DestroyStreamingEffect( 0 );
       
  4267     TEST_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle 0 failed!" );
       
  4268 
       
  4269     // minimum handle value
       
  4270     err = iHaptics->DestroyStreamingEffect( INT_MIN );
       
  4271     TEST_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle INT_MIN failed!" );
       
  4272 
       
  4273     // maximum handle value
       
  4274     err = iHaptics->DestroyStreamingEffect( INT_MAX );
       
  4275     TEST_ASSERT_DESC( (err == KErrNone), "Destroying streaming effect with handle INT_MAX failed!" );
       
  4276     return err;
       
  4277     }
       
  4278 
       
  4279 
       
  4280 // ---------------------------------------------------------
       
  4281 // Fetches actuator state using the observer.
       
  4282 // ---------------------------------------------------------
       
  4283 //
       
  4284 TInt CHapticsClientTest::T_ObserveActuatorStatus()
       
  4285     {
       
  4286     // Create 2 actuator status observer instances
       
  4287     TActuatorStatusCallback callback1( this );
       
  4288     TActuatorStatusCallback callback2( this );
       
  4289     
       
  4290     // create 1st haptics client with actuator observer
       
  4291     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( NULL, &callback1 );
       
  4292     CleanupStack::PushL( haptics1 );
       
  4293 
       
  4294     //Open actuator
       
  4295     TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  4296     TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" );
       
  4297 
       
  4298     // wait for the callback to be called
       
  4299     iWait.Start();
       
  4300 
       
  4301     // check actuator state (since execution of this method continues, the state
       
  4302     // has been updated in the callback)
       
  4303     TEST_ASSERT_DESC( (callback1.Status(EHWRMLogicalActuatorAny) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled),
       
  4304                        "Invalid actuator state received!" );
       
  4305 
       
  4306     // create 2nd haptics client with actuator observer
       
  4307     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( NULL, &callback2 );
       
  4308     CleanupStack::PushL( haptics2 );
       
  4309     
       
  4310     //Open actuator
       
  4311     TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorDevice ) );
       
  4312     TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" );
       
  4313 
       
  4314     // wait for the callback to be called
       
  4315     iWait.Start();
       
  4316 
       
  4317     // check actuator state (since execution of this method continues, the state
       
  4318     // has been updated in the callback)
       
  4319     TEST_ASSERT_DESC( (callback2.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled),
       
  4320                        "Invalid actuator state received!" );
       
  4321 
       
  4322 
       
  4323     // cleanup
       
  4324     CleanupStack::PopAndDestroy( haptics2 );
       
  4325     CleanupStack::PopAndDestroy( haptics1 );
       
  4326     return KErrNone;
       
  4327     }
       
  4328 
       
  4329 
       
  4330 // ---------------------------------------------------------
       
  4331 // 
       
  4332 // ---------------------------------------------------------
       
  4333 //
       
  4334 TInt CHapticsClientTest::T_ObserveActuatorStatusAndHapticsStatus()
       
  4335     {
       
  4336     //  Create 3 actuator status observers.
       
  4337     TActuatorStatusCallback actuatorCallback1( this );
       
  4338     TActuatorStatusCallback actuatorCallback2( this );
       
  4339     TActuatorStatusCallback actuatorCallback3( this );
       
  4340 
       
  4341     // Create 3 haptics status observers.
       
  4342     THapticsStatusCallback hapticsCallback1( this );
       
  4343     THapticsStatusCallback hapticsCallback2( this );
       
  4344     THapticsStatusCallback hapticsCallback3( this );
       
  4345     
       
  4346     // create 1st haptics client with observers
       
  4347     CHWRMHaptics* haptics1 = CHWRMHaptics::NewL( &hapticsCallback1, &actuatorCallback1 );
       
  4348     CleanupStack::PushL( haptics1 );
       
  4349 
       
  4350     //Open actuator
       
  4351     TRAPD( err, haptics1->OpenActuatorL( EHWRMLogicalActuatorDevice ) );
       
  4352     TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" );
       
  4353 
       
  4354     // wait for the haptics status callback to be called
       
  4355     iWait.Start();
       
  4356     // wait for the actuator status callback to be called
       
  4357     iWait.Start();
       
  4358 
       
  4359     // check actuator status (since execution of this method continues, the status
       
  4360     // has been updated in the callback)
       
  4361     TEST_ASSERT_DESC( (actuatorCallback1.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled),
       
  4362                        "Invalid actuator status received!" );
       
  4363     // check haptics status
       
  4364     TEST_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  4365                        "Invalid haptics status received!" );
       
  4366 
       
  4367     haptics1->ReserveHapticsL();
       
  4368 
       
  4369 
       
  4370     // create 2nd and 3rd haptics clients with observers
       
  4371     CHWRMHaptics* haptics2 = CHWRMHaptics::NewL( &hapticsCallback2, &actuatorCallback2 );
       
  4372     CleanupStack::PushL( haptics2 );
       
  4373     CHWRMHaptics* haptics3 = CHWRMHaptics::NewL( &hapticsCallback3, &actuatorCallback3 );
       
  4374     CleanupStack::PushL( haptics3 );
       
  4375 
       
  4376     // reserve haptics for 2nd client
       
  4377     haptics2->ReserveHapticsL();
       
  4378 
       
  4379     //Open actuator
       
  4380     TRAP( err, haptics2->OpenActuatorL( EHWRMLogicalActuatorAny ) );
       
  4381     TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Any failed!" );
       
  4382 
       
  4383     TRAP( err, haptics3->OpenActuatorL( EHWRMLogicalActuatorDevice ) );
       
  4384     TEST_ASSERT_DESC( (err == KErrNone), "Opening actuator with type Device failed!" );
       
  4385 
       
  4386     // wait for the haptics status callback to be called
       
  4387     iWait.Start();
       
  4388     iWait.Start();
       
  4389     iWait.Start();
       
  4390     // wait for the actuator status callback to be called
       
  4391     iWait.Start();
       
  4392     iWait.Start();
       
  4393 
       
  4394     // check haptics status (since execution of this method continues, the status
       
  4395     // has been updated in the callback)
       
  4396     TEST_ASSERT_DESC( ( hapticsCallback2.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusSuspended ), 
       
  4397                        "Invalid haptics status received!" );
       
  4398     TEST_ASSERT_DESC( ( hapticsCallback3.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  4399                        "Invalid haptics status received!" );
       
  4400     // check actuator status
       
  4401     TEST_ASSERT_DESC( (actuatorCallback2.Status(EHWRMLogicalActuatorAny) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled),
       
  4402                        "Invalid actuator status received!" );
       
  4403     TEST_ASSERT_DESC( (actuatorCallback3.Status(EHWRMLogicalActuatorDevice) == MHWRMHapticsActuatorObserver::EHWRMActuatorEnabled),
       
  4404                        "Invalid actuator status received!" );
       
  4405 
       
  4406     // release haptics
       
  4407     haptics1->ReleaseHaptics();
       
  4408 
       
  4409     // wait for the haptics status callback to be called    
       
  4410     iWait.Start();
       
  4411     iWait.Start();
       
  4412 
       
  4413     TEST_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusReserved ), 
       
  4414                        "Invalid haptics status received!" );
       
  4415     TEST_ASSERT_DESC( ( hapticsCallback2.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  4416                        "Invalid haptics status received!" );
       
  4417 
       
  4418 
       
  4419     // release haptics
       
  4420     haptics2->ReleaseHaptics();
       
  4421 
       
  4422     // wait for the haptics status callback to be called    
       
  4423     iWait.Start();
       
  4424     iWait.Start();
       
  4425 
       
  4426     TEST_ASSERT_DESC( ( hapticsCallback1.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  4427                        "Invalid haptics status received!" );
       
  4428     TEST_ASSERT_DESC( ( hapticsCallback3.Status() == MHWRMHapticsObserver::EHWRMHapticsStatusAvailable ), 
       
  4429                        "Invalid haptics status received!" );
       
  4430 
       
  4431     // cleanup
       
  4432     CleanupStack::PopAndDestroy( haptics3 );
       
  4433     CleanupStack::PopAndDestroy( haptics2 );
       
  4434     CleanupStack::PopAndDestroy( haptics1 );
       
  4435     return KErrNone;
       
  4436     }