bluetoothengine/btnotif/tsrc/BtNotifApiTest/src/BtNotifApiTestBlocks.cpp
branchRCL_3
changeset 55 613943a21004
parent 54 0ba996a9b75d
child 56 9386f31cc85b
equal deleted inserted replaced
54:0ba996a9b75d 55:613943a21004
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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 "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES] - do not remove
       
    21 #include <e32svr.h>
       
    22 #include <StifParser.h>
       
    23 #include <Stiftestinterface.h>
       
    24 #include "BtNotifApiTest.h"
       
    25 
       
    26 // EXTERNAL DATA STRUCTURES
       
    27 //extern  ?external_data;
       
    28 
       
    29 // EXTERNAL FUNCTION PROTOTYPES  
       
    30 //extern ?external_function( ?arg_type,?arg_type );
       
    31 
       
    32 // CONSTANTS
       
    33 //const ?type ?constant_var = ?constant;
       
    34 
       
    35 // MACROS
       
    36 //#define ?macro ?macro_def
       
    37 
       
    38 // LOCAL CONSTANTS AND MACROS
       
    39 //const ?type ?constant_var = ?constant;
       
    40 //#define ?macro_name ?macro_def
       
    41 
       
    42 // MODULE DATA STRUCTURES
       
    43 //enum ?declaration
       
    44 //typedef ?declaration
       
    45 
       
    46 // LOCAL FUNCTION PROTOTYPES
       
    47 //?type ?function_name( ?arg_type, ?arg_type );
       
    48 
       
    49 // FORWARD DECLARATIONS
       
    50 //class ?FORWARD_CLASSNAME;
       
    51 
       
    52 // ============================= LOCAL FUNCTIONS ===============================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // ?function_name ?description.
       
    56 // ?description
       
    57 // Returns: ?value_1: ?description
       
    58 //          ?value_n: ?description_line1
       
    59 //                    ?description_line2
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 /*
       
    63 ?type ?function_name(
       
    64     ?arg_type arg,  // ?description
       
    65     ?arg_type arg)  // ?description
       
    66     {
       
    67 
       
    68     ?code  // ?comment
       
    69 
       
    70     // ?comment
       
    71     ?code
       
    72     }
       
    73 */
       
    74 
       
    75 // ============================ MEMBER FUNCTIONS ===============================
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CBtNotifApiTest::Delete
       
    79 // Delete here all resources allocated and opened from test methods. 
       
    80 // Called from destructor. 
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 void CBtNotifApiTest::Delete() 
       
    84     {
       
    85         delete iNotifier;
       
    86         iNotifier = NULL;
       
    87         delete iBtSettings;
       
    88         iBtSettings = NULL;
       
    89         delete iBtEngDevManObserver;
       
    90         iBtEngDevManObserver = NULL;
       
    91         delete iBtDeviceArray;
       
    92         iBtDeviceArray = NULL;
       
    93         delete iTestDevice;
       
    94         iTestDevice = NULL;
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CBtNotifApiTest::RunMethodL
       
    99 // Run specified method. Contains also table of test mothods and their names.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 TInt CBtNotifApiTest::RunMethodL( 
       
   103     CStifItemParser& aItem ) 
       
   104     {
       
   105 
       
   106     static TStifFunctionInfo const KFunctions[] =
       
   107         {  
       
   108         // Copy this line for every implemented function.
       
   109         // First string is the function name used in TestScripter script file.
       
   110         // Second is the actual implementation member function. 
       
   111                 
       
   112         ENTRY( "PairedDeviceSettingNotifierTest", CBtNotifApiTest::PairedDeviceSettingNotifierTest ),
       
   113         ENTRY( "FinishPairedDeviceSettingQuery", CBtNotifApiTest::FinishPairedDeviceSettingQuery ),
       
   114                 
       
   115         ENTRY( "PbapAuthNotifierTest", CBtNotifApiTest::PbapAuthNotifierTest ),
       
   116         ENTRY( "FinishPbapAuthQuery", CBtNotifApiTest::FinishPbapAuthQuery ),
       
   117                 
       
   118         ENTRY( "PasskeyDisplayNotifierTest", CBtNotifApiTest::PasskeyDisplayNotifierTest ),
       
   119         ENTRY( "FinishPasskeyDisplayQuery", CBtNotifApiTest::FinishPasskeyDisplayQuery ),
       
   120 
       
   121         ENTRY( "NumericComparisonQueryNotifierTest", CBtNotifApiTest::NumericComparisonQueryNotifierTest ),
       
   122         ENTRY( "FinishNumericComparisonQuery", CBtNotifApiTest::FinishNumericComparisonQuery ),
       
   123         
       
   124         ENTRY( "AuthQueryNotifierTest", CBtNotifApiTest::AuthQueryNotifierTest ),
       
   125         ENTRY( "FinishAuthQuery", CBtNotifApiTest::FinishAuthQuery ),
       
   126         
       
   127         ENTRY( "PinPasskeyQueryNotifierTest", CBtNotifApiTest::PinPasskeyQueryNotifierTest ),
       
   128         ENTRY( "FinishPinPasskeyQuery", CBtNotifApiTest::FinishPinPasskeyQuery ),
       
   129         
       
   130         ENTRY( "InquiryNotifierTest", CBtNotifApiTest::InquiryNotifierTest ),
       
   131         ENTRY( "FinishInquiry", CBtNotifApiTest::FinishInquiry ),
       
   132         
       
   133         ENTRY( "ObexPasskeyQueryNotifierTest", CBtNotifApiTest::ObexPasskeyQueryNotifierTest ),
       
   134         ENTRY( "FinishObexPasskeyQuery", CBtNotifApiTest::FinishObexPasskeyQuery ),
       
   135         
       
   136         ENTRY( "PowerModeQueryNotifierTest", CBtNotifApiTest::PowerModeQueryNotifierTest ),
       
   137         ENTRY( "FinishPowerModeQuery", CBtNotifApiTest::FinishPowerModeQuery ),
       
   138         
       
   139         ENTRY( "GenericInfoNotifierTest", CBtNotifApiTest::GenericInfoNotifierTest ),
       
   140         
       
   141         ENTRY( "GenericQueryNotifierTest", CBtNotifApiTest::GenericQueryNotifierTest ),
       
   142         ENTRY( "FinishGenericQuery", CBtNotifApiTest::FinishGenericQuery ),
       
   143         
       
   144         ENTRY( "TurnLightsOn", CBtNotifApiTest::TurnLightsOn ),
       
   145                 
       
   146         //ADD NEW ENTRY HERE
       
   147         // [test cases entries] - Do not remove
       
   148 
       
   149         };
       
   150 
       
   151     const TInt count = sizeof( KFunctions ) / 
       
   152                         sizeof( TStifFunctionInfo );
       
   153 
       
   154     return RunInternalL( KFunctions, count, aItem );
       
   155 
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CBtNotifApiTest::PairedDeviceSettingNotifierTests
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 
       
   163 TInt CBtNotifApiTest::PairedDeviceSettingNotifierTest( CStifItemParser& aItem )
       
   164     {
       
   165     TInt res;
       
   166     TBTRegistrySearch regSearch;
       
   167     
       
   168     res = iNotifier -> Connect();
       
   169     if ( res != KErrNone )
       
   170         {
       
   171         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   172         return res;
       
   173         }   
       
   174     iLog -> Log( _L("RNotifier connected") );
       
   175     
       
   176     regSearch.FindAll();    
       
   177     res = iBtEngDevManObserver -> GetDevices( regSearch, iBtDeviceArray );
       
   178     if ( res != KErrNone )
       
   179         {
       
   180         iLog -> Log( _L("Getting devices from register failed with value: %d"), res );
       
   181         return res;
       
   182         }
       
   183 
       
   184     if ( iBtDeviceArray -> Count() > 0 )
       
   185         {
       
   186         iBtDeviceArray -> Reset();
       
   187         res = iBtEngDevManObserver -> DeleteDevices( regSearch );
       
   188         if ( res != KErrNone )
       
   189             {
       
   190             iLog -> Log( _L("Deleting devices from register failed with value: %d"), res );
       
   191             return res;
       
   192             }
       
   193         }
       
   194 
       
   195     TBTDevAddr addr( 0x12345678 );
       
   196     CBTDevice *testDevice = CBTDevice::NewL( addr );
       
   197     CleanupStack::PushL( testDevice );
       
   198     testDevice -> SetPaired( ELinkKeyAuthenticated );
       
   199     TTime time;
       
   200     time.UniversalTime();
       
   201     testDevice -> SetUsed( time );
       
   202     testDevice -> SetDeviceNameL( _L8( "TestedDevice" ) );
       
   203     CleanupStack::Pop( testDevice );
       
   204     
       
   205     res = iBtEngDevManObserver -> AddDevice( *testDevice );
       
   206     if ( res != KErrNone )
       
   207         {
       
   208         iLog -> Log( _L("Adding device to register failed with value: %d"), res );
       
   209         delete testDevice;
       
   210         return res;
       
   211         }
       
   212 
       
   213     TInt paramStatus = KErrNone;  
       
   214     TBTPairedDeviceSettingParams notifierParams;    
       
   215     notifierParams.iPairingStatus = paramStatus;
       
   216     notifierParams.iRemoteAddr = testDevice -> BDAddr();
       
   217     TBTPairedDeviceSettingParamsPckg notifierParamsPckg( notifierParams );
       
   218        
       
   219     TPckgBuf<TBool> notifierResponsePckg;
       
   220     
       
   221     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTPairedDeviceSettingNotifierUid, notifierParamsPckg, notifierResponsePckg );
       
   222     iLog -> Log( _L("Notifier started") );    
       
   223     
       
   224     User::WaitForRequest( iReqStatus );
       
   225   
       
   226     iLog -> Log( _L("Request status value: %d"), iReqStatus.Int() );
       
   227     iLog -> Log( _L("Input status value: %d"), notifierParams.iPairingStatus );
       
   228     iLog -> Log( _L("Pairing status value: %d"), notifierResponsePckg() );
       
   229     
       
   230     delete testDevice;
       
   231     iNotifier -> Close();  
       
   232     return KErrNone;
       
   233     }
       
   234 
       
   235 
       
   236 TInt CBtNotifApiTest::FinishPairedDeviceSettingQuery( CStifItemParser& aItem )
       
   237     {
       
   238     iLog -> Log( _L("Test case passed") );
       
   239     return KErrNone;
       
   240     }
       
   241 
       
   242 // -----------------------------------------------------------------------------
       
   243 // CBtNotifApiTest::PbapAuthNotifierTests
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 
       
   247 TInt CBtNotifApiTest::PbapAuthNotifierTest( CStifItemParser& aItem )
       
   248     {
       
   249     TInt res;
       
   250 
       
   251     res = iNotifier -> Connect();
       
   252     if ( res != KErrNone )
       
   253         {
       
   254         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   255         return res;
       
   256         }   
       
   257     iLog -> Log( _L("RNotifier connected") );
       
   258     
       
   259     TPbapAuthNotifierParams notifierParams = TPbapAuthNotifierParams();
       
   260     TPbapAuthNotifierParamsPckg notifierParamsPckg( notifierParams );
       
   261     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KPbapAuthNotifierUid, notifierParamsPckg, iPbapAuthNotifierResponsePckg );
       
   262     iLog -> Log( _L("Notifier started") );
       
   263 
       
   264     return KErrNone;
       
   265     }
       
   266 
       
   267 
       
   268 TInt CBtNotifApiTest::FinishPbapAuthQuery( CStifItemParser& aItem )
       
   269     {
       
   270     TInt res;
       
   271     TPtrC optionName( KNullDesC );
       
   272     TTestOption option;
       
   273     TPbapAuthNotifierResponse expectedData;
       
   274     
       
   275     if ( !expectedData.SetPassword( _L( "0000" ) ) )
       
   276         {
       
   277         iLog -> Log( _L("SetPassword failed") );
       
   278         iNotifier -> Close();
       
   279         return KErrGeneral;
       
   280         }       
       
   281     
       
   282     res = aItem.GetString( _L( "FinishPbapAuthQuery" ), optionName );   
       
   283     if ( res != KErrNone )
       
   284         {
       
   285         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   286         iNotifier -> Close();
       
   287         return res;
       
   288         }
       
   289     
       
   290     res = GetTestOption( optionName, option );
       
   291     if ( res != KErrNone )
       
   292         {
       
   293         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
   294         iNotifier -> Close();
       
   295         return res;
       
   296         }  
       
   297     
       
   298     User::WaitForRequest( iReqStatus );    
       
   299     if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel )
       
   300         {
       
   301         iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() );
       
   302         iNotifier -> Close();
       
   303         return iReqStatus.Int();
       
   304         }
       
   305     iLog -> Log( _L("Notifier responded") );
       
   306     
       
   307     switch ( option )
       
   308         {
       
   309         case ECheckPasskey:
       
   310             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
   311             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
   312             iLog -> Log( _L("Equal passkeys expected") );
       
   313             STIF_ASSERT_EQUALS( expectedData.Password(), iPbapAuthNotifierResponsePckg().Password() );                       
       
   314             break;
       
   315         case EQueryCanceled:
       
   316             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   317             STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   318             break;    
       
   319         default:
       
   320             iLog -> Log( _L("Option unavailable") );
       
   321             return KErrNotFound;
       
   322             
       
   323         }
       
   324     
       
   325     iNotifier -> Close();
       
   326     iLog -> Log( _L("Test case passed") );
       
   327     return KErrNone;
       
   328     }
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // CBtNotifApiTest::PasskeyDisplayNotifierTests
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 
       
   335 TInt CBtNotifApiTest::PasskeyDisplayNotifierTest( CStifItemParser& aItem )
       
   336     {
       
   337     TInt res;
       
   338     TBTRegistrySearch regSearch;
       
   339     TPtrC initOptionName( KNullDesC );
       
   340     TUint32 numericalValue = 999;
       
   341     TBTPasskeyDisplayParams notifierParams;
       
   342     TBTPasskeyDisplayParamsPckg emptyReplyPckg;
       
   343     
       
   344     res = iNotifier -> Connect();
       
   345     if ( res != KErrNone )
       
   346         {
       
   347         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   348         return res;
       
   349         }   
       
   350     iLog -> Log( _L("RNotifier connected") );
       
   351     
       
   352     regSearch.FindAll();    
       
   353     res = iBtEngDevManObserver -> GetDevices( regSearch, iBtDeviceArray );
       
   354     if ( res != KErrNone )
       
   355         {
       
   356         iLog -> Log( _L("Getting devices from register failed with value: %d"), res );
       
   357         iNotifier -> Close();
       
   358         return res;
       
   359         }
       
   360 
       
   361     if ( iBtDeviceArray -> Count() > 0 )
       
   362         {
       
   363         iBtDeviceArray -> Reset();
       
   364         res = iBtEngDevManObserver -> DeleteDevices( regSearch );
       
   365         if ( res != KErrNone )
       
   366             {
       
   367             iLog -> Log( _L("Deleting devices from register failed with value: %d"), res );
       
   368             iNotifier -> Close();
       
   369             return res;
       
   370             }
       
   371         }
       
   372     
       
   373     iTestDevice -> SetDeviceAddress( 0x12345678 );
       
   374     iTestDevice -> SetDeviceNameL( _L8( "Tested_Device" ) );
       
   375     iTestDevice -> SetFriendlyNameL( _L( "TestedDevice" ) );
       
   376     
       
   377     res = iBtEngDevManObserver -> AddDevice( *iTestDevice );
       
   378     if ( res != KErrNone )
       
   379         {
       
   380         iLog -> Log( _L("Adding device to register failed with value: %d"), res );
       
   381         iNotifier -> Close();
       
   382         return res;
       
   383         }
       
   384     
       
   385     res = aItem.GetString( _L( "PasskeyDisplayNotifierTest" ), initOptionName );   
       
   386     if ( res != KErrNone )
       
   387         {
       
   388         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   389         iNotifier -> Close();
       
   390         return res;
       
   391         } 
       
   392     
       
   393     if ( !initOptionName.Compare( _L( "LOCAL" ) ) )
       
   394         {
       
   395         iLog -> Log( _L("Locally initiated connection") );
       
   396         notifierParams = TBTPasskeyDisplayParams( iTestDevice -> BDAddr(), iTestDevice -> FriendlyName(), numericalValue, ETrue );
       
   397         }
       
   398     else if ( !initOptionName.Compare( _L( "REMOTE" ) ) )
       
   399         {
       
   400         iLog -> Log( _L("Remote side initiated connection") );
       
   401         notifierParams = TBTPasskeyDisplayParams( iTestDevice -> BDAddr(), iTestDevice -> FriendlyName(), numericalValue, EFalse );
       
   402         }
       
   403     else
       
   404         {
       
   405         iLog -> Log( _L("Option unavailable") );
       
   406         return KErrNotFound;
       
   407         }
       
   408        
       
   409     TBTPasskeyDisplayParamsPckg notifierParamsPckg( notifierParams );
       
   410     
       
   411     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTPasskeyDisplayNotifierUid, notifierParamsPckg, emptyReplyPckg );
       
   412     iLog -> Log( _L("Notifier started") );
       
   413 
       
   414     return KErrNone;
       
   415     }
       
   416 
       
   417 TInt CBtNotifApiTest::FinishPasskeyDisplayQuery( CStifItemParser& aItem )
       
   418     {
       
   419     TInt res;
       
   420     TBTRegistrySearch regSearch;
       
   421     TPtrC deviceBlockOptionName( KNullDesC );
       
   422     
       
   423     res = aItem.GetString( _L( "FinishPasskeyDisplayQuery" ), deviceBlockOptionName );   
       
   424     
       
   425     User::WaitForRequest( iReqStatus );   
       
   426     
       
   427     if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) )
       
   428         {
       
   429         iLog -> Log( _L("Block test device") );
       
   430         iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied );
       
   431         STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() );
       
   432         }
       
   433     else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) )
       
   434         {
       
   435         iLog -> Log( _L("Don't block test device") );
       
   436         iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   437         STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   438         }
       
   439     else
       
   440         {
       
   441         iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   442         STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   443         }
       
   444     
       
   445     iBtDeviceArray -> Reset();
       
   446     res = iBtEngDevManObserver -> DeleteDevices( regSearch );
       
   447     if ( res != KErrNone )
       
   448         {
       
   449         iLog -> Log( _L("Deleting devices from register failed with value: %d"), res );
       
   450         iNotifier -> Close();
       
   451         return res;
       
   452         }
       
   453     
       
   454     iNotifier -> Close();
       
   455     iLog -> Log( _L("Test case passed") );
       
   456     return KErrNone;
       
   457     }
       
   458 
       
   459 // -----------------------------------------------------------------------------
       
   460 // CBtNotifApiTest::NumericComparisonQueryNotifierTests
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 
       
   464 TInt CBtNotifApiTest::NumericComparisonQueryNotifierTest( CStifItemParser& aItem )
       
   465     {
       
   466     TInt res;
       
   467     TPtrC initOptionName( KNullDesC );
       
   468     TUint32 numericalValue = 999999;
       
   469     TBTNumericComparisonParams notifierParams;
       
   470     
       
   471     
       
   472     res = iNotifier -> Connect();
       
   473     if ( res != KErrNone )
       
   474         {
       
   475         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   476         return res;
       
   477         }   
       
   478     iLog -> Log( _L("RNotifier connected") );
       
   479     
       
   480     res = aItem.GetString( _L( "NumericComparisonQueryNotifierTest" ), initOptionName );   
       
   481     if ( res != KErrNone )
       
   482         {
       
   483         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   484         iNotifier -> Close();
       
   485         return res;
       
   486         } 
       
   487     
       
   488     if ( !initOptionName.Compare( _L( "LOCAL" ) ) )
       
   489         {
       
   490         iLog -> Log( _L("Locally initiated connection") );
       
   491         notifierParams = TBTNumericComparisonParams( TBTDevAddr(), _L( "Test Device" ), numericalValue, TBTNumericComparisonParams::ERemoteCannotConfirm, ETrue );
       
   492         }
       
   493     else if ( !initOptionName.Compare( _L( "REMOTE" ) ) )
       
   494         {
       
   495         iLog -> Log( _L("Remote side initiated connection") );
       
   496         notifierParams = TBTNumericComparisonParams( TBTDevAddr(), _L( "Test Device" ), numericalValue, TBTNumericComparisonParams::ERemoteCannotConfirm, EFalse );
       
   497         }
       
   498     else
       
   499         {
       
   500         iLog -> Log( _L("Option unavailable") );
       
   501         return KErrNotFound;
       
   502         }
       
   503     
       
   504     TBTNumericComparisonParamsPckg notifierParamsPckg( notifierParams );
       
   505     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTNumericComparisonNotifierUid, notifierParamsPckg, iNumericComparisonQueryReply );
       
   506     iLog -> Log( _L("Notifier started") );
       
   507     
       
   508     return KErrNone;
       
   509     }
       
   510 
       
   511 
       
   512 TInt CBtNotifApiTest::FinishNumericComparisonQuery( CStifItemParser& aItem )
       
   513     {
       
   514     TInt res;
       
   515     TPtrC optionName( KNullDesC );
       
   516     TPtrC deviceBlockOptionName( KNullDesC );
       
   517     TTestOption option;
       
   518     
       
   519     res = aItem.GetString( _L( "FinishNumericComparisonQuery" ), optionName );   
       
   520     if ( res != KErrNone )
       
   521         {
       
   522         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   523         iNotifier -> Close();
       
   524         return res;
       
   525         }
       
   526     
       
   527     res = GetTestOption( optionName, option );
       
   528     if ( res != KErrNone )
       
   529         {
       
   530         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
   531         iNotifier -> Close();
       
   532         return res;
       
   533         }  
       
   534     
       
   535     User::WaitForRequest( iReqStatus );    
       
   536     if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel && iReqStatus.Int()!= KErrAccessDenied )
       
   537         {
       
   538         iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() );
       
   539         iNotifier -> Close();
       
   540         return iReqStatus.Int();
       
   541         }
       
   542     iLog -> Log( _L("Notifier responded") );
       
   543     
       
   544     switch ( option )
       
   545         {
       
   546         case EQueryDiscarded:
       
   547             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
   548             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
   549             iLog -> Log( _L("Notifier's response value: %d, expected: %b"), iNumericComparisonQueryReply(), EFalse );  
       
   550             STIF_ASSERT_FALSE( iNumericComparisonQueryReply() );
       
   551             break;
       
   552         case EQueryAccepted:
       
   553             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
   554             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
   555             iLog -> Log( _L("Notifier's response value: %d, expected: %b"), iNumericComparisonQueryReply(), ETrue );  
       
   556             STIF_ASSERT_TRUE( iNumericComparisonQueryReply() );
       
   557             break;
       
   558         case EQueryCanceled:
       
   559             res = aItem.GetNextString( deviceBlockOptionName );   
       
   560             if ( res != KErrNone )
       
   561                 {
       
   562                 iLog -> Log( _L("GetNextString failed with value: %d"), res );
       
   563                 iNotifier -> Close();
       
   564                 return res;
       
   565                 }
       
   566             
       
   567             if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) )
       
   568                 {
       
   569                 iLog -> Log( _L("Block test device") );
       
   570                 iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied );
       
   571                 STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() );
       
   572                 }
       
   573             else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) )
       
   574                 {
       
   575                 iLog -> Log( _L("Don't block test device") );
       
   576                 iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   577                 STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   578                 }
       
   579             else
       
   580                 {
       
   581                 iLog -> Log( _L("Option unavailable") );
       
   582                 return KErrNotFound;
       
   583                 }
       
   584             break;
       
   585         default:
       
   586             iLog -> Log( _L("Option unavailable") );
       
   587             return KErrNotFound;
       
   588         }
       
   589 
       
   590     iNotifier -> Close();
       
   591     iLog -> Log( _L("Test case passed") );
       
   592     return KErrNone;
       
   593     }
       
   594 
       
   595 // -----------------------------------------------------------------------------
       
   596 // CBtNotifApiTest::AuthQueryNotifierTests
       
   597 // -----------------------------------------------------------------------------
       
   598 //
       
   599 
       
   600 TInt CBtNotifApiTest::AuthQueryNotifierTest( CStifItemParser& aItem )
       
   601     {
       
   602     TInt res;
       
   603     
       
   604     res = iNotifier -> Connect();
       
   605     if ( res != KErrNone )
       
   606         {
       
   607         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   608         return res;
       
   609         }   
       
   610     iLog -> Log( _L("RNotifier connected") );
       
   611     
       
   612     TBTAuthorisationParams notifierParams;
       
   613     notifierParams.iName = _L( "Test Device" );
       
   614     TBTAuthorisationParamsPckg notifierParamsPckg( notifierParams );
       
   615     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTManAuthNotifierUid, notifierParamsPckg, iAuthQueryReply );
       
   616     iLog -> Log( _L("Notifier started") );
       
   617     
       
   618     return KErrNone;
       
   619     }
       
   620 
       
   621 
       
   622 TInt CBtNotifApiTest::FinishAuthQuery( CStifItemParser& aItem )
       
   623     {
       
   624     TInt res;
       
   625     TPtrC optionName( KNullDesC );
       
   626     TPtrC deviceBlockOptionName( KNullDesC );
       
   627     TTestOption option;
       
   628     
       
   629     res = aItem.GetString( _L("FinishAuthQuery"), optionName );   
       
   630     if ( res != KErrNone )
       
   631         {
       
   632         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   633         iNotifier -> Close();
       
   634         return res;
       
   635         }
       
   636     
       
   637     res = aItem.GetNextString( deviceBlockOptionName );
       
   638     
       
   639     res = GetTestOption( optionName, option );
       
   640     if ( res != KErrNone )
       
   641         {
       
   642         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
   643         iNotifier -> Close();
       
   644         return res;
       
   645         }  
       
   646     
       
   647     User::WaitForRequest( iReqStatus );
       
   648     if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel && iReqStatus.Int()!= KErrAccessDenied )
       
   649         {
       
   650         iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() );
       
   651         iNotifier -> Close();
       
   652         return iReqStatus.Int();
       
   653         }
       
   654     iLog -> Log( _L("Notifier responded") );
       
   655     
       
   656     switch ( option )
       
   657         {
       
   658         case EQueryDiscarded:
       
   659             if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) )
       
   660                 {
       
   661                 iLog -> Log( _L("Block test device") );
       
   662                 iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied );
       
   663                 STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() );
       
   664                 iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iAuthQueryReply(), EFalse );  
       
   665                 STIF_ASSERT_FALSE( iAuthQueryReply() );
       
   666                 }
       
   667             else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) )
       
   668                 {
       
   669                 iLog -> Log( _L("Don't block test device") );
       
   670                 iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   671                 STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   672                 iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iAuthQueryReply(), EFalse );  
       
   673                 STIF_ASSERT_FALSE( iAuthQueryReply() );
       
   674                 }
       
   675             else
       
   676                 {
       
   677                 iLog -> Log( _L("Option unavailable") );
       
   678                 return KErrNotFound;
       
   679                 }
       
   680             break;
       
   681         case EQueryAccepted:
       
   682             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
   683             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
   684             iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iAuthQueryReply(), ETrue );
       
   685             STIF_ASSERT_TRUE( iAuthQueryReply() );
       
   686             break;
       
   687         default:
       
   688             iLog -> Log( _L("Option unavailable") );
       
   689             return KErrNotFound;
       
   690         }
       
   691     
       
   692     iNotifier -> Close();
       
   693     iLog -> Log( _L("Test case passed") );
       
   694     return KErrNone;
       
   695     }
       
   696 
       
   697 // -----------------------------------------------------------------------------
       
   698 // CBtNotifApiTest::PinPasskeyQueryNotifierTests
       
   699 // -----------------------------------------------------------------------------
       
   700 //
       
   701 
       
   702 TInt CBtNotifApiTest::PinPasskeyQueryNotifierTest( CStifItemParser& aItem )
       
   703     {
       
   704     TInt res;
       
   705     TPtrC initOptionName( KNullDesC );
       
   706     TUint pinCodeMinLength = 4;
       
   707     
       
   708     res = iNotifier -> Connect();
       
   709     if ( res != KErrNone )
       
   710         {
       
   711         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   712         return res;
       
   713         }   
       
   714     iLog -> Log( _L("RNotifier connected") );
       
   715     
       
   716     res = aItem.GetString( _L( "PinPasskeyQueryNotifierTest" ), initOptionName );   
       
   717     if ( res != KErrNone )
       
   718         {
       
   719         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   720         iNotifier -> Close();
       
   721         return res;
       
   722         }
       
   723     
       
   724     TBTPinCodeEntryNotifierParams notifierParams;
       
   725     
       
   726     if ( !initOptionName.Compare( _L( "LOCAL" ) ) )
       
   727         {
       
   728         iLog -> Log( _L("Locally initiated connection") );
       
   729         notifierParams = TBTPinCodeEntryNotifierParams( TBTDevAddr(), _L( "Test Device" ), pinCodeMinLength, ETrue, EFalse, pinCodeMinLength );
       
   730         }
       
   731     else if ( !initOptionName.Compare( _L( "REMOTE" ) ) )
       
   732         {
       
   733         iLog -> Log( _L("Remote side initiated connection") );
       
   734         notifierParams = TBTPinCodeEntryNotifierParams( TBTDevAddr(), _L( "Test Device" ), pinCodeMinLength, EFalse, EFalse, pinCodeMinLength );
       
   735         }
       
   736     else
       
   737         {
       
   738         iLog -> Log( _L("Option unavailable") );
       
   739         return KErrNotFound;
       
   740         }
       
   741           
       
   742     TBTPinCodeEntryNotifierParamsPckg notifierParamsPckg( notifierParams );
       
   743        
       
   744     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTPinCodeEntryNotifierUid, notifierParamsPckg, iEnteredPinPasskey );
       
   745     iLog -> Log( _L("Notifier started") );
       
   746     
       
   747     return KErrNone;
       
   748     }
       
   749 
       
   750 
       
   751 TInt CBtNotifApiTest::FinishPinPasskeyQuery( CStifItemParser& aItem )
       
   752     {
       
   753     TInt res;
       
   754     TPtrC optionName( KNullDesC );
       
   755     TPtrC connectionOptionName( KNullDesC );
       
   756     TPtrC deviceBlockOptionName( KNullDesC );
       
   757     TTestOption option;    
       
   758     TPINCodeV10 pinKey;
       
   759     
       
   760     pinKey.iLength = 4;
       
   761     pinKey.iPIN[0] = '0';
       
   762     pinKey.iPIN[1] = '0';
       
   763     pinKey.iPIN[2] = '0';
       
   764     pinKey.iPIN[3] = '0';
       
   765     
       
   766     for ( int i = pinKey.iLength; i< KHCIPINCodeSize; i++ )
       
   767         {
       
   768         pinKey.iPIN[i] = NULL;
       
   769         } 
       
   770     iPinPasskey = pinKey;   
       
   771     
       
   772     res = aItem.GetString( _L( "FinishPinPasskeyQuery" ), optionName );   
       
   773     if ( res != KErrNone )
       
   774         {
       
   775         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   776         iNotifier -> Close();
       
   777         return res;
       
   778         }
       
   779     
       
   780     res = GetTestOption( optionName, option );
       
   781     if ( res != KErrNone )
       
   782         {
       
   783         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
   784         iNotifier -> Close();
       
   785         return res;
       
   786         }
       
   787     
       
   788     User::WaitForRequest( iReqStatus );
       
   789     
       
   790     switch( option )
       
   791         {
       
   792         case ECheckPasskey:
       
   793             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
   794             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
   795             iLog -> Log( _L("Equal passkeys expected") );
       
   796             STIF_ASSERT_EQUALS( iPinPasskey, iEnteredPinPasskey );                       
       
   797             break;
       
   798         case EQueryCanceled:
       
   799             res = aItem.GetNextString( connectionOptionName );   
       
   800             if ( res == KErrNone )
       
   801                 {
       
   802                 if ( !connectionOptionName.Compare( _L( "DISCARDCONN" ) ) )
       
   803                     {
       
   804                     res = aItem.GetNextString( deviceBlockOptionName );
       
   805                     if ( res != KErrNone )
       
   806                         {
       
   807                         iLog -> Log( _L("GetNextString failed with value: %d"), res );
       
   808                         iNotifier -> Close();
       
   809                         return res;
       
   810                         }
       
   811                     
       
   812                     if ( !deviceBlockOptionName.Compare( _L( "BLOCK" ) ) )
       
   813                         {
       
   814                         iLog -> Log( _L("Block test device") );
       
   815                         iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrAccessDenied );
       
   816                         STIF_ASSERT_EQUALS( KErrAccessDenied, iReqStatus.Int() );
       
   817                         }
       
   818                     else if ( !deviceBlockOptionName.Compare( _L( "NONBLOCK" ) ) )
       
   819                         {
       
   820                         iLog -> Log( _L("Don't block test device") );
       
   821                         iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   822                         STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   823                         }
       
   824                     else
       
   825                         {
       
   826                         iLog -> Log( _L("Block connection option unavailable") );
       
   827                         return KErrNotFound;
       
   828                         }                    
       
   829                     }
       
   830                 else if ( !connectionOptionName.Compare( _L( "ACCEPTCONN" ) ) )
       
   831                     {
       
   832                     iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   833                     STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   834                     }      
       
   835                 else 
       
   836                     {
       
   837                     iLog -> Log( _L("Connection option unavailable") );
       
   838                     return KErrNotFound;
       
   839                     }
       
   840                 }
       
   841             else if ( res == KErrNotFound )
       
   842                 {
       
   843                 iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
   844                 STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
   845                 }
       
   846             else 
       
   847                 return res;
       
   848             break;
       
   849         default:
       
   850             iLog -> Log( _L("Option unavailable") );
       
   851             return KErrNotFound;
       
   852         }
       
   853     
       
   854     iNotifier -> Close();
       
   855     iLog -> Log( _L("Test case passed") );
       
   856     
       
   857     return KErrNone;
       
   858     }
       
   859 
       
   860 // -----------------------------------------------------------------------------
       
   861 // CBtNotifApiTest::InquiryNotifierTests
       
   862 // -----------------------------------------------------------------------------
       
   863 //
       
   864 
       
   865 TInt CBtNotifApiTest::InquiryNotifierTest( CStifItemParser& aItem )
       
   866     {
       
   867     TInt res;
       
   868     TPtrC initOptionName( KNullDesC );
       
   869     TBTRegistrySearch regSearch;
       
   870     TBTPowerStateValue btPowerState;
       
   871     TBTDeviceSelectionParamsPckg emptyNotifierParamsPckg;
       
   872         
       
   873     res = iNotifier -> Connect();
       
   874     if ( res != KErrNone )
       
   875         {
       
   876         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
   877         return res;
       
   878         }   
       
   879     iLog -> Log( _L("RNotifier connected") );
       
   880     
       
   881     res = iBtSettings -> GetPowerState( btPowerState );
       
   882     if ( res != KErrNone )
       
   883         {
       
   884         iLog -> Log( _L("Failed to get BT power state with value: %d"), res );
       
   885         iNotifier -> Close();
       
   886         return res;
       
   887         }
       
   888     
       
   889     if ( btPowerState == EBTPowerOn )
       
   890         {
       
   891         res = iBtSettings -> SetPowerState( EBTPowerOff );
       
   892         if ( res != KErrNone )
       
   893             {
       
   894             iLog -> Log( _L("Failed to set BT off with value: %d"), res );
       
   895             iNotifier -> Close();
       
   896             return res;
       
   897             } 
       
   898         }
       
   899     
       
   900     regSearch.FindAll();    
       
   901     res = iBtEngDevManObserver -> GetDevices( regSearch, iBtDeviceArray );
       
   902     if ( res != KErrNone )
       
   903         {
       
   904         iLog -> Log( _L("Getting devices from register failed with value: %d"), res );
       
   905         iNotifier -> Close();
       
   906         return res;
       
   907         }
       
   908 
       
   909     if ( iBtDeviceArray -> Count() > 0 )
       
   910         {
       
   911         iBtDeviceArray -> Reset();
       
   912         res = iBtEngDevManObserver -> DeleteDevices( regSearch );
       
   913         if ( res != KErrNone )
       
   914             {
       
   915             iLog -> Log( _L("Deleting devices from register failed with value: %d"), res );
       
   916             iNotifier -> Close();
       
   917             return res;
       
   918             }
       
   919         }
       
   920     
       
   921     res = aItem.GetString( _L( "InquiryNotifierTest" ), initOptionName );   
       
   922     if ( res != KErrNone )
       
   923         {
       
   924         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   925         iNotifier -> Close();
       
   926         return res;
       
   927         }
       
   928     
       
   929     if ( !initOptionName.Compare( _L( "BTOFF" ) ) )
       
   930         {    
       
   931         iLog -> Log( _L("Init test option: bt off") );
       
   932         }
       
   933     else if ( !initOptionName.Compare( _L( "PAIRED" ) ) )
       
   934         {
       
   935         iLog -> Log( _L("Init test option: paired test device") );
       
   936         iTestDevice -> SetDeviceAddress( 0x12345678 );
       
   937         iTestDevice -> SetPaired( ELinkKeyAuthenticated );
       
   938         TBTDeviceClass testDeviceClass( EMajorServiceLimitedDiscoverableMode, EMajorDeviceComputer, EMinorDeviceComputerUnclassified );
       
   939         iTestDevice -> SetDeviceClass( testDeviceClass );
       
   940         iTestDevice -> SetDeviceNameL( _L8( "TestedDevice" ) );
       
   941         
       
   942         res = iBtEngDevManObserver -> AddDevice( *iTestDevice );
       
   943         if ( res != KErrNone )
       
   944             {
       
   945             iLog -> Log( _L("Adding device to register failed with value: %d"), res );
       
   946             iNotifier -> Close();
       
   947             return res;
       
   948             }
       
   949         }
       
   950     else if ( !initOptionName.Compare( _L( "NONPAIRED" ) ) )
       
   951         {
       
   952         iLog -> Log( _L("Init test option: test device not paired") );
       
   953         }
       
   954     else
       
   955         {
       
   956         iLog -> Log( _L("Option unavailable") );
       
   957         iNotifier -> Close();
       
   958         return KErrNotFound;
       
   959         }
       
   960     
       
   961     if ( initOptionName.Compare( _L( "BTOFF" ) ) )
       
   962         {
       
   963         res = iBtSettings -> SetPowerState( EBTPowerOn );
       
   964         if ( res != KErrNone )
       
   965             {
       
   966             iLog -> Log( _L("Failed to set BT on with value: %d"), res );
       
   967             iNotifier -> Close();
       
   968             return res;
       
   969             } 
       
   970         }
       
   971 
       
   972     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KDeviceSelectionNotifierUid, emptyNotifierParamsPckg, iBtDeviceResponseParamsPckg );
       
   973     iLog -> Log( _L("Notifier started") );
       
   974     
       
   975     User::After( 5000000 );
       
   976 
       
   977     return KErrNone;
       
   978     }
       
   979 
       
   980 
       
   981 TInt CBtNotifApiTest::FinishInquiry( CStifItemParser& aItem )
       
   982     {
       
   983     TInt res;
       
   984     TPtrC optionName( KNullDesC );
       
   985     TPtrC subOptionName( KNullDesC );
       
   986     TBTPowerStateValue btPowerState;
       
   987     TTestOption option;
       
   988     
       
   989     res = aItem.GetString( _L( "FinishInquiry" ), optionName );   
       
   990     if ( res != KErrNone )
       
   991         {
       
   992         iLog -> Log( _L("GetString failed with value: %d"), res );
       
   993         iNotifier -> Close();
       
   994         return res;
       
   995         }
       
   996     
       
   997     res = aItem.GetNextString( subOptionName );   
       
   998     iLog -> Log( _L("GetString  value: %d"), res );
       
   999     
       
  1000     if ( !subOptionName.Compare( _L( "BTOFF" ) ) )
       
  1001         {
       
  1002         iLog -> Log( _L("Test suboption: set bt off") );
       
  1003         iBtSettings -> SetPowerState( EBTPowerOff );
       
  1004         if ( res != KErrNone )
       
  1005             {
       
  1006             iLog -> Log( _L("Failed to set BT off with value: %d"), res );
       
  1007             iNotifier -> Close();
       
  1008             return res;
       
  1009             } 
       
  1010         }
       
  1011    
       
  1012     res = GetTestOption( optionName, option );
       
  1013     if ( res != KErrNone )
       
  1014         {
       
  1015         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
  1016         iNotifier -> Close();
       
  1017         return res;
       
  1018         }
       
  1019     
       
  1020     User::WaitForRequest( iReqStatus );
       
  1021     
       
  1022     switch( option )
       
  1023         {
       
  1024         case EQueryAccepted:
       
  1025             {
       
  1026             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
  1027             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
  1028             
       
  1029             HBufC16* inputDeviceNameBuf = HBufC16::New( iTestDevice -> DeviceName().Length() );
       
  1030             TPtr16 inputDeviceName = inputDeviceNameBuf -> Des();
       
  1031             inputDeviceName.Copy( iTestDevice -> DeviceName() );
       
  1032             
       
  1033             HBufC16* outputDeviceNameBuf = HBufC16::New( iBtDeviceResponseParamsPckg().DeviceName().Length() );
       
  1034             TPtr16 outputDeviceName = outputDeviceNameBuf -> Des();
       
  1035             outputDeviceName.Copy( iBtDeviceResponseParamsPckg().DeviceName() );
       
  1036               
       
  1037             iLog -> Log( _L( "Equal device addresses expected" ) );
       
  1038             STIF_ASSERT_EQUALS( iTestDevice -> BDAddr(), iBtDeviceResponseParamsPckg().BDAddr() );
       
  1039             iLog -> Log( _L( "Equal device names expected" ) );
       
  1040             STIF_ASSERT_EQUALS( inputDeviceName, outputDeviceName );
       
  1041             iLog -> Log( _L( "Equal device classes expected" ) );
       
  1042             STIF_ASSERT_EQUALS( iTestDevice -> DeviceClass(), iBtDeviceResponseParamsPckg().DeviceClass() );
       
  1043             
       
  1044             delete inputDeviceNameBuf;
       
  1045             delete outputDeviceNameBuf;
       
  1046             }
       
  1047             break;
       
  1048         case EQueryCanceled:
       
  1049             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
  1050             STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
  1051             break;
       
  1052         default:
       
  1053             iLog -> Log( _L("Option unavailable") );
       
  1054             return KErrNotFound;
       
  1055         }
       
  1056     
       
  1057     res = iBtSettings -> GetPowerState( btPowerState );
       
  1058     if ( res != KErrNone )
       
  1059         {
       
  1060         iLog -> Log( _L("Failed to get BT power state with value: %d"), res );
       
  1061         iNotifier -> Close();
       
  1062         return res;
       
  1063         }
       
  1064     
       
  1065     if ( btPowerState == EBTPowerOn )
       
  1066         {
       
  1067         res = iBtSettings -> SetPowerState( EBTPowerOff );
       
  1068         if ( res != KErrNone )
       
  1069             {
       
  1070             iLog -> Log( _L("Failed to set BT off with value: %d"), res );
       
  1071             iNotifier -> Close();
       
  1072             return res;
       
  1073             } 
       
  1074         }
       
  1075     
       
  1076     iNotifier -> Close();
       
  1077     iLog -> Log( _L("Test case passed") );
       
  1078     return KErrNone;
       
  1079     }
       
  1080 
       
  1081 // -----------------------------------------------------------------------------
       
  1082 // CBtNotifApiTest::ObexPasskeyQueryNotifierTests
       
  1083 // -----------------------------------------------------------------------------
       
  1084 //
       
  1085 
       
  1086 TInt CBtNotifApiTest::ObexPasskeyQueryNotifierTest( CStifItemParser& aItem )
       
  1087     {
       
  1088     TInt res;
       
  1089     TUint8 passCode[] = { "0000" };
       
  1090     TBTObexPasskey passKey = passCode;
       
  1091     
       
  1092     res = iNotifier -> Connect();
       
  1093     if ( res != KErrNone )
       
  1094         {
       
  1095         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
  1096         return res;
       
  1097         }   
       
  1098     iLog -> Log( _L("RNotifier connected") );
       
  1099     
       
  1100     iObexPasskeyBuf = passKey;  
       
  1101     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTObexPasskeyQueryNotifierUid, iObexPasskeyBuf, iEnteredPasskeyBuf );
       
  1102     iLog -> Log( _L("Notifier started") );
       
  1103     
       
  1104     return KErrNone;
       
  1105     }
       
  1106 
       
  1107 
       
  1108 TInt CBtNotifApiTest::FinishObexPasskeyQuery( CStifItemParser& aItem )
       
  1109     {
       
  1110     TInt res;
       
  1111     TPtrC optionName( KNullDesC );
       
  1112     TTestOption option;
       
  1113     
       
  1114     res = aItem.GetNextString( optionName );   
       
  1115     if ( res != KErrNone )
       
  1116         {
       
  1117         iLog -> Log( _L("GetNextString failed with value: %d"), res );
       
  1118         iNotifier -> Close();
       
  1119         return res;
       
  1120         }  
       
  1121     
       
  1122     res = GetTestOption( optionName, option );
       
  1123     if ( res != KErrNone )
       
  1124         {
       
  1125         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
  1126         iNotifier -> Close();
       
  1127         return res;
       
  1128         }  
       
  1129     
       
  1130     User::WaitForRequest( iReqStatus );    
       
  1131     switch( option )
       
  1132         {
       
  1133         case ECheckPasskey:
       
  1134             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
  1135             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
  1136             iLog -> Log( _L("Equal passkeys expected") );
       
  1137             STIF_ASSERT_EQUALS( iObexPasskeyBuf(), iEnteredPasskeyBuf() );
       
  1138             break;
       
  1139         case EQueryCanceled:
       
  1140             iLog -> Log( _L("Request status value: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
  1141             STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
  1142             break;
       
  1143         default:
       
  1144             iLog -> Log( _L("Option unavailable") );
       
  1145             return KErrNotFound;
       
  1146         }
       
  1147     
       
  1148     iNotifier -> Close();
       
  1149     iLog -> Log( _L("Test case passed") );
       
  1150 
       
  1151     return KErrNone;
       
  1152     }
       
  1153 
       
  1154 // -----------------------------------------------------------------------------
       
  1155 // CBtNotifApiTest::PowerModeQueryNotifierTests
       
  1156 // -----------------------------------------------------------------------------
       
  1157 //
       
  1158 
       
  1159 TInt CBtNotifApiTest::PowerModeQueryNotifierTest( CStifItemParser& aItem )
       
  1160     {
       
  1161     TInt res;
       
  1162     TBTPowerStateValue state;
       
  1163     TBuf<KMaxBCBluetoothNameLen> testDeviceName = _L( "Device Test Name" );
       
  1164     
       
  1165     res = iNotifier -> Connect();
       
  1166     if ( res != KErrNone )
       
  1167         {
       
  1168         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
  1169         return res;
       
  1170         }   
       
  1171     iLog -> Log( _L("RNotifier connected") );
       
  1172     
       
  1173     
       
  1174     res = iBtSettings -> GetPowerState( state );
       
  1175     if ( res != KErrNone )
       
  1176         {
       
  1177         iLog -> Log( _L("Failed to get bt power state with value: %d"), res );
       
  1178         return res;
       
  1179         }
       
  1180     
       
  1181     if ( state != EBTPowerOff )
       
  1182         {
       
  1183         res = iBtSettings -> SetPowerState( EBTPowerOff );
       
  1184         if ( res != KErrNone )
       
  1185             {
       
  1186             iLog -> Log( _L("Failed to set bt power state with value: %d"), res );
       
  1187             return res;
       
  1188             }
       
  1189         }
       
  1190     
       
  1191     res = iBtSettings -> GetLocalName( iLocalDeviceName );
       
  1192     if ( res != KErrNone )
       
  1193         {
       
  1194         iLog -> Log( _L("Failed backup device name: %d"), res );
       
  1195         return res;
       
  1196         }
       
  1197     
       
  1198     res = iBtSettings -> SetLocalName( testDeviceName );
       
  1199     if ( res != KErrNone )
       
  1200         {
       
  1201         iLog -> Log( _L("Failed set device name: %d"), res );
       
  1202         return res;
       
  1203         }
       
  1204     
       
  1205     TPckgBuf<TBool> emptyInput;   
       
  1206     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KPowerModeSettingNotifierUid, emptyInput, iPowerModeQueryReply );
       
  1207     iLog -> Log( _L("Notifier started") );
       
  1208     
       
  1209     return KErrNone;
       
  1210     }
       
  1211 
       
  1212 
       
  1213 TInt CBtNotifApiTest::FinishPowerModeQuery( CStifItemParser& aItem )
       
  1214     {
       
  1215     TInt res;
       
  1216     TPtrC optionName( KNullDesC );
       
  1217     TTestOption option;    
       
  1218     
       
  1219     res = aItem.GetNextString( optionName );   
       
  1220     if ( res != KErrNone )
       
  1221         {
       
  1222         iLog -> Log( _L("GetNextString failed with value: %d"), res );
       
  1223         iNotifier -> Close();
       
  1224         return res;
       
  1225         }  
       
  1226     
       
  1227     res = GetTestOption( optionName, option );
       
  1228     if ( res != KErrNone )
       
  1229         {
       
  1230         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
  1231         iNotifier -> Close();
       
  1232         return res;
       
  1233         }    
       
  1234     
       
  1235     User::WaitForRequest( iReqStatus );
       
  1236     
       
  1237     if ( iReqStatus.Int()!= KErrNone && iReqStatus.Int()!= KErrCancel )
       
  1238         {
       
  1239         iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() );
       
  1240         iNotifier -> Close();
       
  1241         return iReqStatus.Int();
       
  1242         }
       
  1243     iLog -> Log( _L("Notifier responded") );
       
  1244     
       
  1245     iBtSettings -> SetLocalName( iLocalDeviceName );
       
  1246     
       
  1247     switch ( option )
       
  1248         {
       
  1249         case EQueryDiscarded:
       
  1250             iLog -> Log( _L("Returned request status: %d, expected: %d"), iReqStatus.Int(), KErrCancel );
       
  1251             STIF_ASSERT_EQUALS( KErrCancel, iReqStatus.Int() );
       
  1252             iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iPowerModeQueryReply(), EFalse );  
       
  1253             STIF_ASSERT_FALSE( iPowerModeQueryReply() );
       
  1254             break;
       
  1255         case EQueryAccepted:
       
  1256             res = iBtSettings -> SetPowerState( EBTPowerOff );
       
  1257             if ( res != KErrNone )
       
  1258                 {
       
  1259                 iLog -> Log( _L("Failed to set bt power state off with value: %d"), res );
       
  1260                 return res;
       
  1261                 }
       
  1262             iLog -> Log( _L("Returned request status: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
  1263             STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
  1264             iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iPowerModeQueryReply(), ETrue );
       
  1265             STIF_ASSERT_TRUE( iPowerModeQueryReply() );
       
  1266             break;
       
  1267         default:
       
  1268             iLog -> Log( _L("Option unavailable") );
       
  1269             return KErrNotFound;
       
  1270         }
       
  1271   
       
  1272     iNotifier -> Close();
       
  1273     iLog -> Log( _L("Test case passed") );
       
  1274     
       
  1275     return KErrNone;
       
  1276     }
       
  1277 
       
  1278 // -----------------------------------------------------------------------------
       
  1279 // CBtNotifApiTest::GenericInfoNotifierTests
       
  1280 // -----------------------------------------------------------------------------
       
  1281 //
       
  1282 
       
  1283 TInt CBtNotifApiTest::GenericInfoNotifierTest( CStifItemParser& aItem )
       
  1284     {
       
  1285     TInt res;
       
  1286     TBTGenericInfoNotifierParams notifierParams;
       
  1287     TBTGenericInfoNoteType genericInfoNoteType;
       
  1288     TPtrC genericInfoNoteTypeString( KNullDesC );
       
  1289     
       
  1290     res = iNotifier -> Connect();
       
  1291     if ( res != KErrNone )
       
  1292         {
       
  1293         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
  1294         return res;
       
  1295         }   
       
  1296     iLog -> Log( _L("RNotifier connected") );
       
  1297     
       
  1298     res = aItem.GetNextString( genericInfoNoteTypeString );
       
  1299     if ( res != KErrNone )
       
  1300         {
       
  1301         iLog -> Log( _L("GetNextString failed with value: %d"), res );
       
  1302         iNotifier -> Close();
       
  1303         return res;
       
  1304         }  
       
  1305     
       
  1306     res = GetGenericInfoNoteType( genericInfoNoteTypeString, genericInfoNoteType );
       
  1307     if ( res != KErrNone )
       
  1308         {
       
  1309         iLog -> Log( _L("Generic info note type not found") );
       
  1310         iNotifier -> Close();
       
  1311         return res;
       
  1312         }
       
  1313     
       
  1314     notifierParams.iMessageType = genericInfoNoteType;
       
  1315     notifierParams.iRemoteAddr = _L8( "012345" );
       
  1316     TBTGenericInfoNotiferParamsPckg messageInfo( notifierParams );
       
  1317     TPckgBuf<TBool> emptyReply;
       
  1318     
       
  1319     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTGenericInfoNotifierUid, messageInfo, emptyReply );
       
  1320     iLog -> Log( _L("Notifier started") );
       
  1321     User::WaitForRequest( iReqStatus );
       
  1322     iLog -> Log( _L("Returned request status: %d, expected: %d"), iReqStatus.Int(), KErrNone );
       
  1323     STIF_ASSERT_EQUALS( KErrNone, iReqStatus.Int() );
       
  1324     
       
  1325     iNotifier -> Close();
       
  1326     iLog -> Log( _L("Test case passed") );
       
  1327     
       
  1328     return KErrNone;
       
  1329     }
       
  1330 
       
  1331 TInt CBtNotifApiTest::GetGenericInfoNoteType( TPtrC aTypeString, TBTGenericInfoNoteType& aGenericInfoNoteType )
       
  1332     {
       
  1333     if ( !aTypeString.Compare( _L( "EBTConnected" ) ) )
       
  1334         {
       
  1335         aGenericInfoNoteType = EBTConnected;
       
  1336         iLog -> Log( _L("Generic info message type: EBTConnected") );
       
  1337         }
       
  1338     else if ( !aTypeString.Compare( _L( "EBTDisconnected" ) ) )
       
  1339         {
       
  1340         aGenericInfoNoteType = EBTDisconnected;
       
  1341         iLog -> Log( _L("Generic info message type: EBTDisconnected") );
       
  1342         }
       
  1343     else if ( !aTypeString.Compare( _L( "EBTAudioAccessory" ) ) )
       
  1344         {
       
  1345         aGenericInfoNoteType = EBTAudioAccessory;
       
  1346         iLog -> Log( _L("Generic info message type: EBTAudioAccessory") );
       
  1347         }
       
  1348     else if ( !aTypeString.Compare( _L( "EBTAudioHandset" ) ) )
       
  1349         {
       
  1350         aGenericInfoNoteType = EBTAudioHandset;
       
  1351         iLog -> Log( _L("Generic info message type: EBTAudioHandset") );
       
  1352         }
       
  1353     else if ( !aTypeString.Compare( _L( "EBTClosed" ) ) )
       
  1354         {
       
  1355         aGenericInfoNoteType = EBTClosed;
       
  1356         iLog -> Log( _L("Generic info message type: EBTClosed") );
       
  1357         }
       
  1358     else if ( !aTypeString.Compare( _L( "EBTDeviceNotAvailable" ) ) )
       
  1359         {
       
  1360         aGenericInfoNoteType = EBTDeviceNotAvailable;
       
  1361         iLog -> Log( _L("Generic info message type: EBTDeviceNotAvailable") );
       
  1362         }
       
  1363     else if ( !aTypeString.Compare( _L( "EBTOfflineDisabled" ) ) )
       
  1364         {
       
  1365         aGenericInfoNoteType = EBTOfflineDisabled;
       
  1366         iLog -> Log( _L("Generic info message type: EBTOfflineDisabled") );
       
  1367         }
       
  1368     else if ( !aTypeString.Compare( _L( "EBTVisibilityTimeout" ) ) )
       
  1369         {
       
  1370         aGenericInfoNoteType = EBTVisibilityTimeout;
       
  1371         iLog -> Log( _L("Generic info message type: EBTVisibilityTimeout") );
       
  1372         }
       
  1373     else if ( !aTypeString.Compare( _L( "EBTEnterSap" ) ) )
       
  1374         {
       
  1375         aGenericInfoNoteType = EBTEnterSap;
       
  1376         iLog -> Log( _L("Generic info message type: EBTEnterSap") );
       
  1377         }
       
  1378     else if ( !aTypeString.Compare( _L( "EBTSapOk" ) ) )
       
  1379         {
       
  1380         aGenericInfoNoteType = EBTSapOk;
       
  1381         iLog -> Log( _L("Generic info message type: EBTSapOk") );
       
  1382         }
       
  1383     else if ( !aTypeString.Compare( _L( "EBTSapFailed" ) ) )
       
  1384         {
       
  1385         aGenericInfoNoteType = EBTSapFailed;
       
  1386         iLog -> Log( _L("Generic info message type: EBTSapFailed") );
       
  1387         }
       
  1388     else if ( !aTypeString.Compare( _L( "EBTSapNoSim" ) ) )
       
  1389         {
       
  1390         aGenericInfoNoteType = EBTSapNoSim;
       
  1391         iLog -> Log( _L("Generic info message type: EBTSapNoSim") );
       
  1392         }
       
  1393     else if ( !aTypeString.Compare( _L( "EBTDeviceBusy" ) ) )
       
  1394         {
       
  1395         aGenericInfoNoteType = EBTDeviceBusy;
       
  1396         iLog -> Log( _L("Generic info message type: EBTDeviceBusy") );
       
  1397         }
       
  1398     else if ( !aTypeString.Compare( _L( "EIRNotSupported" ) ) )
       
  1399         {
       
  1400         aGenericInfoNoteType = EIRNotSupported;
       
  1401         iLog -> Log( _L("Generic info message type: EIRNotSupported") );
       
  1402         }
       
  1403     else if ( !aTypeString.Compare( _L( "ECmdShowBtBatteryLow" ) ) )
       
  1404         {
       
  1405         aGenericInfoNoteType = ECmdShowBtBatteryLow;
       
  1406         iLog -> Log( _L("Generic info message type: ECmdShowBtBatteryLow") );
       
  1407         }
       
  1408     else if ( !aTypeString.Compare( _L( "ECmdShowBtBatteryCritical" ) ) )
       
  1409         {
       
  1410         aGenericInfoNoteType = ECmdShowBtBatteryCritical;
       
  1411         iLog -> Log( _L("Generic info message type: ECmdShowBtBatteryCritical") );
       
  1412         }
       
  1413     else if ( !aTypeString.Compare( _L( "EBTStayPowerOn" ) ) )
       
  1414         {
       
  1415         aGenericInfoNoteType = EBTStayPowerOn;
       
  1416         iLog -> Log( _L("Generic info message type: EBTStayPowerOn") );
       
  1417         }
       
  1418     else
       
  1419         {
       
  1420         iLog -> Log( _L("Generic info message type: No type matched") );
       
  1421         return KErrNotFound;
       
  1422         }
       
  1423     
       
  1424     return KErrNone;
       
  1425     }
       
  1426 
       
  1427 // -----------------------------------------------------------------------------
       
  1428 // CBtNotifApiTest::GenericQueryNotifierTests
       
  1429 // -----------------------------------------------------------------------------
       
  1430 //
       
  1431 
       
  1432 TInt CBtNotifApiTest::GenericQueryNotifierTest( CStifItemParser& aItem )
       
  1433     {
       
  1434     TInt res;
       
  1435     TBTGenericQueryNotifierParams notifierParams;
       
  1436     TBTGenericQueryNoteType genericQueryNoteType;
       
  1437     TPtrC genericQueryNoteTypeString( KNullDesC );
       
  1438     
       
  1439     res = iNotifier -> Connect();
       
  1440     if ( res != KErrNone )
       
  1441         {
       
  1442         iLog -> Log( _L("Failed to connect RNotifier with value: %d"), res );
       
  1443         return res;
       
  1444         }   
       
  1445     iLog -> Log( _L("RNotifier connected") );
       
  1446     
       
  1447     res = aItem.GetNextString( genericQueryNoteTypeString );
       
  1448     if ( res != KErrNone )
       
  1449         {
       
  1450         iLog -> Log( _L("GetNextString failed with value: %d"), res );
       
  1451         iNotifier -> Close();
       
  1452         return res;
       
  1453         } 
       
  1454     
       
  1455     res = GetGenericQueryNoteType( genericQueryNoteTypeString, genericQueryNoteType );
       
  1456     if ( res != KErrNone )
       
  1457         {
       
  1458         iLog -> Log( _L("Generic query note type not found") );
       
  1459         iNotifier -> Close();
       
  1460         return res;
       
  1461         }
       
  1462     
       
  1463     notifierParams.iMessageType = genericQueryNoteType;
       
  1464     notifierParams.iNameExists = EFalse;   
       
  1465     TBTGenericQueryNotiferParamsPckg messageInfo( notifierParams );   
       
  1466     iNotifier -> StartNotifierAndGetResponse( iReqStatus, KBTGenericQueryNotifierUid, messageInfo, iGenericQueryReply );
       
  1467     iLog -> Log( _L("Notifier started") );
       
  1468     
       
  1469     return KErrNone;
       
  1470     }
       
  1471 
       
  1472 
       
  1473 TInt CBtNotifApiTest::FinishGenericQuery( CStifItemParser& aItem )
       
  1474     {
       
  1475     TInt res;
       
  1476     TPtrC optionName( KNullDesC );
       
  1477     TTestOption option;
       
  1478     
       
  1479     res = aItem.GetNextString( optionName );   
       
  1480     if ( res != KErrNone )
       
  1481         {
       
  1482         iLog -> Log( _L("GetNextString failed with value: %d"), res );
       
  1483         iNotifier -> Close();
       
  1484         return res;
       
  1485         }  
       
  1486     
       
  1487     res = GetTestOption( optionName, option );
       
  1488     if ( res != KErrNone )
       
  1489         {
       
  1490         iLog -> Log( _L("GetTestOption failed with value: %d"), res );
       
  1491         iNotifier -> Close();
       
  1492         return res;
       
  1493         }   
       
  1494     
       
  1495     User::WaitForRequest( iReqStatus );
       
  1496     if ( iReqStatus.Int()!= KErrNone )
       
  1497         {
       
  1498         iLog -> Log( _L("Failed to get notifier's response: %d"), iReqStatus.Int() );
       
  1499         iNotifier -> Close();
       
  1500         return iReqStatus.Int();
       
  1501         }
       
  1502     iLog -> Log( _L("Notifier responded") );
       
  1503     
       
  1504     switch ( option )
       
  1505         {
       
  1506         case EQueryDiscarded:
       
  1507             iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iGenericQueryReply(), EFalse );  
       
  1508             STIF_ASSERT_FALSE( iGenericQueryReply() );
       
  1509             break;
       
  1510         case EQueryAccepted:
       
  1511             iLog -> Log( _L("Notifier's response value: %b, expected: %b"), iGenericQueryReply(), ETrue );
       
  1512             STIF_ASSERT_TRUE( iGenericQueryReply() );
       
  1513             break;
       
  1514         default:
       
  1515             iLog -> Log( _L("Option unavailable") );
       
  1516             return KErrNotFound;
       
  1517         }
       
  1518     
       
  1519     iNotifier -> Close();
       
  1520     iLog -> Log( _L("Test case passed") );
       
  1521     
       
  1522     return KErrNone;
       
  1523     }
       
  1524 
       
  1525 
       
  1526 TInt CBtNotifApiTest::GetGenericQueryNoteType( TPtrC aTypeString, TBTGenericQueryNoteType& aGenericQueryNoteType )
       
  1527     {   
       
  1528     if ( !aTypeString.Compare( _L( "EBTReceiveMessageQuery" ) ) )
       
  1529         {
       
  1530         aGenericQueryNoteType = EBTReceiveMessageQuery;
       
  1531         iLog -> Log( _L("Generic query message type: EBTReceiveMessageQuery") );
       
  1532         }
       
  1533     else if ( !aTypeString.Compare( _L( "EBTReceiveMessagePairedQuery" ) ) )
       
  1534         {
       
  1535         aGenericQueryNoteType = EBTReceiveMessagePairedQuery;
       
  1536         iLog -> Log( _L("Generic query message type: EBTReceiveMessagePairedQuery") );
       
  1537         }
       
  1538     else if ( !aTypeString.Compare( _L( "EBTIsOffQuery" ) ) )
       
  1539         {
       
  1540         aGenericQueryNoteType = EBTIsOffQuery;
       
  1541         iLog -> Log( _L("Generic query message type: EBTIsOffQuery") );
       
  1542         }
       
  1543     else if ( !aTypeString.Compare( _L( "EBTActivateOffLineQuery" ) ) )
       
  1544         {
       
  1545         aGenericQueryNoteType = EBTActivateOffLineQuery;
       
  1546         iLog -> Log( _L("Generic query message type: EBTActivateOffLineQuery") );
       
  1547         }
       
  1548     else if ( !aTypeString.Compare( _L( "EBTNoDevicesFoundQuery" ) ) )
       
  1549         {
       
  1550         aGenericQueryNoteType = EBTNoDevicesFoundQuery;
       
  1551         iLog -> Log( _L("Generic query message type: EBTNoDevicesFoundQuery") );
       
  1552         }
       
  1553     else if ( !aTypeString.Compare( _L( "EBTAcceptRequestQuery" ) ) )
       
  1554         {
       
  1555         aGenericQueryNoteType = EBTAcceptRequestQuery;
       
  1556         iLog -> Log( _L("Generic query message type: EBTAcceptRequestQuery") );
       
  1557         }
       
  1558     else if ( !aTypeString.Compare( _L( "EBTBlockConnectionQuery" ) ) )
       
  1559         {
       
  1560         aGenericQueryNoteType = EBTBlockConnectionQuery;
       
  1561         iLog -> Log( _L("Generic query message type: EBTBlockConnectionQuery") );
       
  1562         }
       
  1563     else if ( !aTypeString.Compare( _L( "EBTBlockPairedConnectionQuery" ) ) )
       
  1564         {
       
  1565         aGenericQueryNoteType = EBTBlockPairedConnectionQuery;
       
  1566         iLog -> Log( _L("Generic query message type: EBTBlockPairedConnectionQuery") );
       
  1567         }
       
  1568     else if ( !aTypeString.Compare( _L( "EBTIsNotShownQuery" ) ) )
       
  1569         {
       
  1570         aGenericQueryNoteType = EBTIsNotShownQuery;
       
  1571         iLog -> Log( _L("Generic query message type: EBTIsNotShownQuery") );
       
  1572         }
       
  1573     else if ( !aTypeString.Compare( _L( "EBTIsOffJavaQuery" ) ) )
       
  1574         {
       
  1575         aGenericQueryNoteType = EBTIsOffJavaQuery;
       
  1576         iLog -> Log( _L("Generic query message type: EBTIsOffJavaQuery") );
       
  1577         }
       
  1578     else
       
  1579         {
       
  1580         iLog -> Log( _L("Generic query message type: No type matched") );
       
  1581         return KErrNotFound;
       
  1582         }
       
  1583     
       
  1584     return KErrNone;
       
  1585     }
       
  1586 
       
  1587 
       
  1588 // -----------------------------------------------------------------------------
       
  1589 // CBtNotifApiTest::GetTestOption
       
  1590 // -----------------------------------------------------------------------------
       
  1591 //
       
  1592 
       
  1593 TInt CBtNotifApiTest::GetTestOption( TPtrC aOptionString, TTestOption& aOption )
       
  1594     {    
       
  1595     if ( !aOptionString.Compare( _L( "DISCARD" ) ) )
       
  1596         {
       
  1597         aOption = EQueryDiscarded;
       
  1598         iLog -> Log( _L("Test type: EQueryDiscarded") );
       
  1599         }
       
  1600     else if ( !aOptionString.Compare( _L( "ACCEPT" ) ) )
       
  1601         {
       
  1602         aOption = EQueryAccepted;
       
  1603         iLog -> Log( _L("Test type: EQueryAccepted") );
       
  1604         }
       
  1605     else if ( !aOptionString.Compare( _L( "PASSKEY" ) ) )
       
  1606         {
       
  1607         aOption = ECheckPasskey;
       
  1608         iLog -> Log( _L("Test type: ECheckPasskey") );
       
  1609         }
       
  1610     else if ( !aOptionString.Compare( _L( "CANCEL" ) ) )
       
  1611         {
       
  1612         aOption = EQueryCanceled;
       
  1613         iLog -> Log( _L("Test type: EQueryCanceled") );
       
  1614         }
       
  1615     else
       
  1616         return KErrNotFound;  
       
  1617  
       
  1618     return KErrNone;
       
  1619     }
       
  1620 
       
  1621 TInt CBtNotifApiTest::TurnLightsOn( CStifItemParser& aItem )
       
  1622     {
       
  1623     TInt res;
       
  1624     res = RProperty::Set(KPSUidCoreApplicationUIs, KLightsControl, ELightsOn);
       
  1625     return res;
       
  1626     }
       
  1627 
       
  1628 
       
  1629 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  1630 // None
       
  1631 
       
  1632 //  [End of File] - Do not remove