srsf/tsrc/public/basic/ttsutilitytest/src/ttsutilitytestblocks.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32svr.h>
       
    22 #include <stifparser.h>
       
    23 #include <stiftestinterface.h>
       
    24 #include <stiftesteventinterface.h>
       
    25 
       
    26 #include <audiopreference.h>
       
    27 #include <nssttscustomcommands.h>
       
    28 #include <utf.h>
       
    29 
       
    30 #include "ttsutilitytest.h"
       
    31 
       
    32 _LIT( Kttsutilitytest, "ttsutilitytest" );
       
    33 
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ===============================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // Cttsutilitytest::Delete
       
    39 // Delete here all resources allocated and opened from test methods. 
       
    40 // Called from destructor. 
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 void Cttsutilitytest::Delete() 
       
    44     {
       
    45     iFs.Close();
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // Cttsutilitytest::RunMethodL
       
    50 // Run specified method. Contains also table of test mothods and their names.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 TInt Cttsutilitytest::RunMethodL( 
       
    54     CStifItemParser& aItem ) 
       
    55     {
       
    56     TStifFunctionInfo const KFunctions[] =
       
    57         {  
       
    58         ENTRY( "CreateTtsUtility",      Cttsutilitytest::CreateTtsUtilityL ),
       
    59         ENTRY( "DestroyTtsUtility",     Cttsutilitytest::DestroyTtsUtilityL ),
       
    60         ENTRY( "StyleSettings",         Cttsutilitytest::StyleSettingsL ),
       
    61         ENTRY( "PlaybackProperties",    Cttsutilitytest::PlaybackPropertiesL ),
       
    62         ENTRY( "Play",                  Cttsutilitytest::Play ),
       
    63         ENTRY( "Pause",                 Cttsutilitytest::Pause ),
       
    64         ENTRY( "Stop",                  Cttsutilitytest::Stop ),
       
    65         ENTRY( "OpenDes",               Cttsutilitytest::OpenDesL ),
       
    66         ENTRY( "OpenDes8",              Cttsutilitytest::OpenDes8L ),
       
    67         ENTRY( "OpenFile",              Cttsutilitytest::OpenFileL ),
       
    68         ENTRY( "OpenParsedText",        Cttsutilitytest::OpenParsedTextL ),
       
    69         ENTRY( "OpenAndPlayDes",        Cttsutilitytest::OpenAndPlayDesL ),
       
    70         ENTRY( "OpenAndPlayDes8",       Cttsutilitytest::OpenAndPlayDes8L ),
       
    71         ENTRY( "OpenAndPlayFile",       Cttsutilitytest::OpenAndPlayFileL ),
       
    72         ENTRY( "OpenAndPlayParsedText", Cttsutilitytest::OpenAndPlayParsedTextL ),
       
    73         ENTRY( "SynthesisToFile",       Cttsutilitytest::SynthesisToFileL ),
       
    74         ENTRY( "CustomCommands",        Cttsutilitytest::CustomCommandsL ),
       
    75         ENTRY( "CustomCommands2",       Cttsutilitytest::CustomCommands2L ),
       
    76         };
       
    77 
       
    78     const TInt count = sizeof( KFunctions ) / 
       
    79                         sizeof( TStifFunctionInfo );
       
    80 
       
    81     return RunInternalL( KFunctions, count, aItem );
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // Cttsutilitytest::CreateTtsUtilityL
       
    86 // 
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 TInt Cttsutilitytest::CreateTtsUtilityL()
       
    90     {
       
    91     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In CreateTtsUtilityL") );
       
    92     
       
    93     if ( iTtsUtility )
       
    94         {
       
    95         User::LeaveIfError( KErrAlreadyExists );
       
    96         }
       
    97     
       
    98     iTtsUtility = CTtsUtility::NewL( *this );
       
    99     
       
   100     return KErrNone;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // Cttsutilitytest::DestroyTtsUtilityL
       
   105 // 
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TInt Cttsutilitytest::DestroyTtsUtilityL()
       
   109     {
       
   110     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In DestroyTtsUtilityL") );
       
   111     
       
   112     delete iParsedText;
       
   113     iParsedText = NULL;
       
   114     
       
   115     iTtsUtility->Close();
       
   116     
       
   117     delete iTtsUtility;
       
   118     iTtsUtility = NULL; 
       
   119     
       
   120     return KErrNone;
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // Cttsutilitytest::StyleSettingsL
       
   125 // 
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 TInt Cttsutilitytest::StyleSettingsL()
       
   129     {
       
   130     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In StyleSettingsL") );
       
   131     
       
   132     OpenPluginL();
       
   133     
       
   134     iStyle.iLanguage = ELangEnglish;
       
   135     iStyle.iVoice    = KDefaultVoiceNameMale;
       
   136     iStyle.iQuality  = ETtsQualityLowPreferred;
       
   137     
       
   138     iTtsUtility->SetDefaultStyleL( iStyle );
       
   139     
       
   140     TTtsStyle defaultStyle = iTtsUtility->DefaultStyleL();
       
   141     if ( iStyle.iLanguage != defaultStyle.iLanguage || 
       
   142          iStyle.iVoice    != defaultStyle.iVoice || 
       
   143          iStyle.iQuality  != defaultStyle.iQuality )
       
   144         {
       
   145         User::Leave( KErrGeneral );
       
   146         }
       
   147     
       
   148     TTtsStyleID styleId = iTtsUtility->AddStyleL( iStyle ); 
       
   149     
       
   150     TTtsStyle style = iTtsUtility->StyleL( styleId ); 
       
   151     
       
   152     if ( iStyle.iLanguage != style.iLanguage || 
       
   153          iStyle.iVoice    != style.iVoice || 
       
   154          iStyle.iQuality  != style.iQuality )
       
   155         {
       
   156         User::Leave( KErrGeneral );
       
   157         }
       
   158     
       
   159     // There should be only one style
       
   160     TUint16 index = 1;
       
   161     TRAPD( error, style = iTtsUtility->StyleL( index ) );
       
   162     if ( error != KErrNotFound )
       
   163         {
       
   164         User::Leave( KErrGeneral );
       
   165         }
       
   166         
       
   167     if ( iTtsUtility->NumberOfStyles() == 1 )
       
   168         {
       
   169         iTtsUtility->DeleteStyle( styleId );
       
   170         }
       
   171     
       
   172     RArray<TLanguage> languages;
       
   173     CleanupClosePushL( languages );
       
   174     
       
   175     iTtsUtility->GetSupportedLanguagesL( languages );
       
   176     
       
   177     if ( languages.Count() > 0 )
       
   178         {
       
   179         RArray<TTtsStyle> voices;
       
   180         
       
   181         iTtsUtility->GetSupportedVoicesL( languages[0], voices );
       
   182         
       
   183         if ( voices.Count() == 0 )
       
   184             {
       
   185             User::Leave( KErrNotFound );
       
   186             }
       
   187             
       
   188         voices.Close();
       
   189         }
       
   190     else
       
   191         {
       
   192         User::Leave( KErrNotFound );
       
   193         }
       
   194     
       
   195     CleanupStack::PopAndDestroy( &languages );
       
   196     
       
   197     return KErrNone;
       
   198     }
       
   199     
       
   200 // -----------------------------------------------------------------------------
       
   201 // Cttsutilitytest::PlaybackPropertiesL
       
   202 // 
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 TInt Cttsutilitytest::PlaybackPropertiesL()
       
   206     {
       
   207     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In PlaybackPropertiesL") );
       
   208     
       
   209     OpenPluginL();
       
   210     
       
   211     TInt maxVolume( iTtsUtility->MaxVolume() );
       
   212     iTtsUtility->SetVolume( maxVolume );
       
   213     
       
   214     TInt volume;
       
   215     iTtsUtility->GetVolume( volume );
       
   216     
       
   217     if ( volume != maxVolume )
       
   218         {
       
   219         User::Leave( KErrGeneral );
       
   220         }
       
   221     
       
   222     TRAP_IGNORE( TInt speakingRate = iTtsUtility->SpeakingRateL() );
       
   223     TRAP_IGNORE( iTtsUtility->SetSpeakingRateL( KTtsMaxSpeakingRate ) );
       
   224     
       
   225     iTtsUtility->SetRepeats( 1, 1000 );
       
   226     
       
   227     TInt balance;
       
   228     iTtsUtility->GetBalance( balance );
       
   229     iTtsUtility->SetBalance( balance );
       
   230     
       
   231     TTimeIntervalMicroSeconds duration = iTtsUtility->Duration();
       
   232     
       
   233     iTtsUtility->SetPriority( KAudioPriorityVoiceDial, 
       
   234                               (TMdaPriorityPreference)KAudioPrefVocosPlayback );
       
   235     
       
   236     iTtsUtility->GetPosition( duration );
       
   237     iTtsUtility->SetPosition( duration );
       
   238     
       
   239     TInt wordIndex( KErrNotFound );
       
   240     iTtsUtility->GetPosition( wordIndex );
       
   241     iTtsUtility->SetPosition( wordIndex );
       
   242     
       
   243     return KErrNone;
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // Cttsutilitytest::Play
       
   248 // 
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 TInt Cttsutilitytest::Play()
       
   252     {
       
   253     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In Play") );
       
   254     
       
   255     iTtsUtility->Play();
       
   256     
       
   257     return KErrNone;
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // Cttsutilitytest::Pause
       
   262 // 
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 TInt Cttsutilitytest::Pause()
       
   266     {
       
   267     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In Pause") );
       
   268     
       
   269     iTtsUtility->Pause();
       
   270     
       
   271     return KErrNone;
       
   272     }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // Cttsutilitytest::Stop
       
   276 // 
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 TInt Cttsutilitytest::Stop()
       
   280     {
       
   281     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In Stop") );
       
   282     
       
   283     iTtsUtility->Stop();
       
   284     
       
   285     return KErrNone;
       
   286     }
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // Cttsutilitytest::OpenDesL
       
   290 // 
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 TInt Cttsutilitytest::OpenDesL( CStifItemParser& aItem )
       
   294     {
       
   295     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenDesL") );
       
   296     
       
   297     TPtrC input;
       
   298     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   299     
       
   300     iTtsUtility->OpenDesL( input );
       
   301     
       
   302     return KErrNone;
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // Cttsutilitytest::OpenDes8L
       
   307 // 
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 TInt Cttsutilitytest::OpenDes8L( CStifItemParser& aItem )
       
   311     {
       
   312     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenDes8L") );
       
   313     
       
   314     TPtrC input;
       
   315     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   316     
       
   317     HBufC8* input8 = HBufC8::NewLC( 4 * input.Length() );
       
   318     TPtr8 refText = input8->Des();
       
   319     
       
   320     User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) );
       
   321 
       
   322     iTtsUtility->OpenDesL( *input8 );
       
   323     
       
   324     CleanupStack::PopAndDestroy( input8 );
       
   325     
       
   326     return KErrNone;
       
   327     }
       
   328 
       
   329 // -----------------------------------------------------------------------------
       
   330 // Cttsutilitytest::OpenFileL
       
   331 // 
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 TInt Cttsutilitytest::OpenFileL( CStifItemParser& aItem )
       
   335     {
       
   336     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenFileL") );
       
   337     
       
   338     TPtrC input;
       
   339     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   340         
       
   341     iTtsUtility->OpenFileL( input );
       
   342     
       
   343     return KErrNone;
       
   344     }
       
   345 // -----------------------------------------------------------------------------
       
   346 // Cttsutilitytest::OpenParsedTextL
       
   347 // 
       
   348 // -----------------------------------------------------------------------------
       
   349 //
       
   350 TInt Cttsutilitytest::OpenParsedTextL( CStifItemParser& aItem )
       
   351     {
       
   352     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenParsedTextL") );
       
   353     
       
   354     TInt result( KErrGeneral );
       
   355     
       
   356     TPtrC input;
       
   357     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   358     
       
   359     if ( iParsedText )
       
   360         {
       
   361         delete iParsedText;
       
   362         iParsedText = NULL;
       
   363         }
       
   364         
       
   365     iStyle.iLanguage = User::Language();
       
   366     iStyle.iVoice    = KDefaultVoiceNameFemale;
       
   367     iStyle.iQuality  = ETtsQualityLowOnly;
       
   368     
       
   369     iParsedText = CTtsParsedText::NewL();
       
   370     iParsedText->SetPhonemeNotationL( KNullDesC );
       
   371     iParsedText->SetTextL( input );
       
   372     
       
   373     iSegment.SetStyle( iStyle );
       
   374     iStyle = iSegment.StyleL();
       
   375     iSegment.ResetStyle();
       
   376     
       
   377     iSegment.SetTrailingSilenceL( iSegment.TrailingSilence() );
       
   378     
       
   379     iSegment.SetStyleID( iTtsUtility->AddStyleL( iStyle ) );
       
   380     iSegment.SetTextPtr( iParsedText->Text() );
       
   381     iParsedText->AddSegmentL( iSegment );   
       
   382     
       
   383     if ( iParsedText->IsValid() )
       
   384         {
       
   385         result = KErrNone;
       
   386         iTtsUtility->OpenParsedTextL( *iParsedText );
       
   387         }
       
   388         
       
   389     return result;
       
   390     }
       
   391 // -----------------------------------------------------------------------------
       
   392 // Cttsutilitytest::OpenAndPlayDesL
       
   393 // 
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 TInt Cttsutilitytest::OpenAndPlayDesL( CStifItemParser& aItem )
       
   397     {
       
   398     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayDesL") );
       
   399     
       
   400     TPtrC input;
       
   401     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   402     
       
   403     iTtsUtility->OpenAndPlayDesL( input );
       
   404     
       
   405     return KErrNone;
       
   406     }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // Cttsutilitytest::OpenAndPlayDes8L
       
   410 // 
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 TInt Cttsutilitytest::OpenAndPlayDes8L( CStifItemParser& aItem )
       
   414     {
       
   415     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayDes8L") );
       
   416     
       
   417     TPtrC input;
       
   418     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   419     
       
   420     HBufC8* input8 = HBufC8::NewLC( 4 * input.Length() );
       
   421     TPtr8 refText = input8->Des();
       
   422     
       
   423     User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( refText, input ) );
       
   424 
       
   425     iTtsUtility->OpenAndPlayDesL( *input8 );
       
   426     
       
   427     CleanupStack::PopAndDestroy( input8 );
       
   428     
       
   429     return KErrNone;
       
   430     }
       
   431 
       
   432 // -----------------------------------------------------------------------------
       
   433 // Cttsutilitytest::OpenAndPlayFileL
       
   434 // 
       
   435 // -----------------------------------------------------------------------------
       
   436 //
       
   437 TInt Cttsutilitytest::OpenAndPlayFileL( CStifItemParser& aItem )
       
   438     {
       
   439     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayFileL") );
       
   440     
       
   441     TPtrC input;
       
   442     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   443         
       
   444     iTtsUtility->OpenAndPlayFileL( input );
       
   445     
       
   446     return KErrNone;
       
   447     }
       
   448     
       
   449 // -----------------------------------------------------------------------------
       
   450 // Cttsutilitytest::OpenAndPlayParsedTextL
       
   451 // 
       
   452 // -----------------------------------------------------------------------------
       
   453 //
       
   454 TInt Cttsutilitytest::OpenAndPlayParsedTextL( CStifItemParser& aItem )
       
   455     {
       
   456     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In OpenAndPlayParsedTextL") );
       
   457     
       
   458     TPtrC input;
       
   459     User::LeaveIfError( aItem.GetNextString ( input ) );
       
   460     
       
   461     if ( iParsedText == NULL )
       
   462         {
       
   463         iStyle.iLanguage = User::Language();
       
   464         iStyle.iVoice    = KDefaultVoiceNameFemale;
       
   465         iStyle.iQuality  = ETtsQualityLowOnly;
       
   466         
       
   467         iParsedText = CTtsParsedText::NewL();
       
   468         iParsedText->SetTextL( input );
       
   469     
       
   470         iSegment.SetStyleID( iTtsUtility->AddStyleL( iStyle ) );
       
   471         iSegment.SetTextPtr( iParsedText->Text() );
       
   472         iParsedText->AddSegmentL( iSegment );   
       
   473         }
       
   474         
       
   475     iTtsUtility->OpenAndPlayParsedTextL( *iParsedText );
       
   476     
       
   477     return KErrNone;
       
   478     }
       
   479 
       
   480 // -----------------------------------------------------------------------------
       
   481 // Cttsutilitytest::SynthesisToFileL
       
   482 // 
       
   483 // -----------------------------------------------------------------------------
       
   484 //
       
   485 TInt Cttsutilitytest::SynthesisToFileL( CStifItemParser& aItem )
       
   486     {
       
   487     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In SynthesisToFileL") );
       
   488     
       
   489     TPtrC fileName;
       
   490     User::LeaveIfError( aItem.GetNextString ( fileName ) );
       
   491     
       
   492     User::LeaveIfError( iFs.Connect() );
       
   493     User::LeaveIfError( iFs.ShareProtected() ); 
       
   494     iFs.MkDirAll( fileName ); // Ignore error (KErrAlreadyExists comes quite often)
       
   495     
       
   496     User::LeaveIfError( iFile.Replace( iFs, fileName, EFileWrite ) ); 
       
   497     
       
   498     iTtsUtility->SetOutputFileL( iFile );
       
   499     
       
   500     return KErrNone;
       
   501     }
       
   502 
       
   503 // -----------------------------------------------------------------------------
       
   504 // Cttsutilitytest::CustomCommandsL
       
   505 // 
       
   506 // -----------------------------------------------------------------------------
       
   507 //
       
   508 TInt Cttsutilitytest::CustomCommandsL()
       
   509     {
       
   510     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In CustomCommandsL") );
       
   511     
       
   512     TUid openPlugin = OpenPluginL();
       
   513     TMMFMessageDestinationPckg destination( openPlugin );
       
   514     
       
   515     TBuf8<2> dataTo;
       
   516     dataTo.AppendNum( 1 );    
       
   517 
       
   518     TInt err1 = iTtsUtility->CustomCommandSync( destination, ETtsCustomCommandSetAudioOutput, 
       
   519                                                 dataTo, KNullDesC8 );
       
   520     
       
   521     TBuf8<16> dataFrom;
       
   522     TInt err2 = iTtsUtility->CustomCommandSync( destination, ETtsCustomCommandSetAudioOutput, 
       
   523                                                 dataTo, KNullDesC8, dataFrom );
       
   524 
       
   525     TRequestStatus status1( KRequestPending );
       
   526     iTtsUtility->CustomCommandAsync( destination, ETtsCustomCommandSetAudioOutput, 
       
   527                                      dataTo, KNullDesC8, status1 );
       
   528     User::WaitForRequest( status1 );
       
   529     
       
   530     TRequestStatus status2( KRequestPending );
       
   531     iTtsUtility->CustomCommandAsync( destination, ETtsCustomCommandSetAudioOutput, 
       
   532                                     dataTo, KNullDesC8, dataFrom, status2 );
       
   533     
       
   534     User::WaitForRequest( status2 );
       
   535     
       
   536     TInt result( KErrNone );
       
   537     
       
   538     if ( err1 || err2 || status1.Int() || status2.Int() )
       
   539         {
       
   540         result = KErrGeneral;
       
   541         }
       
   542     
       
   543     return result;
       
   544     }
       
   545 
       
   546 // -----------------------------------------------------------------------------
       
   547 // Cttsutilitytest::CustomCommands2L
       
   548 // 
       
   549 // -----------------------------------------------------------------------------
       
   550 //
       
   551 TInt Cttsutilitytest::CustomCommands2L()
       
   552     {
       
   553     TestModuleIf().Printf( 0, Kttsutilitytest, _L("In CustomCommands2L") );
       
   554     
       
   555     const TUid KUidTtsPlugin = { 0x101FF934 };
       
   556     
       
   557     RMMFController controller;
       
   558     RTtsCustomCommands ttsCustomCommands( controller );
       
   559     TMMFPrioritySettings prioritySettings;
       
   560     
       
   561     User::LeaveIfError( controller.Open( KUidTtsPlugin, prioritySettings ) );
       
   562     
       
   563     TUint16 count;
       
   564     User::LeaveIfError( ttsCustomCommands.NumberOfStyles( count ) );
       
   565     
       
   566     if ( count > 0 )
       
   567         {
       
   568         TTtsStyleID styleId( 0 );
       
   569         User::LeaveIfError( ttsCustomCommands.Style( styleId, iStyle ) );
       
   570         
       
   571         TUint16 styleId16( 0 );
       
   572         User::LeaveIfError( ttsCustomCommands.Style( styleId16, iStyle ) );
       
   573         }
       
   574         
       
   575     controller.Close();
       
   576     
       
   577     return KErrNone;
       
   578     }
       
   579     
       
   580 // -----------------------------------------------------------------------------
       
   581 // Cttsutilitytest::OpenPluginL
       
   582 // 
       
   583 // -----------------------------------------------------------------------------
       
   584 //
       
   585 TUid Cttsutilitytest::OpenPluginL()
       
   586     {
       
   587     const TUid KUidTtsPlugin = { 0x101FF934 };
       
   588     
       
   589     RArray<TUid> uids;
       
   590     CleanupClosePushL( uids );    
       
   591     iTtsUtility->ListPluginsL( uids );
       
   592     
       
   593     TInt index = uids.Find( KUidTtsPlugin );
       
   594     TUid openUid( KNullUid );
       
   595     
       
   596     if ( index >= 0 )
       
   597         {
       
   598         openUid = uids[index];
       
   599         }
       
   600     else if ( uids.Count() > 0 )
       
   601         {
       
   602         openUid = uids[0];
       
   603         }
       
   604     else
       
   605         {
       
   606         User::Leave( KErrNotFound );
       
   607         }
       
   608 
       
   609     iTtsUtility->OpenPluginL( openUid );
       
   610     
       
   611     CleanupStack::PopAndDestroy( &uids );
       
   612     
       
   613     return openUid;
       
   614     }
       
   615 
       
   616 // -----------------------------------------------------------------------------
       
   617 // Cttsutilitytest::MapcInitComplete
       
   618 //
       
   619 // -----------------------------------------------------------------------------
       
   620 // 
       
   621 void Cttsutilitytest::MapcInitComplete( TInt aError, 
       
   622                                         const TTimeIntervalMicroSeconds& /*aDuration*/ )
       
   623     {
       
   624     if ( aError )
       
   625         {
       
   626         User::Panic( Kttsutilitytest, aError );
       
   627         }
       
   628     
       
   629     TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcInitComplete" ) );
       
   630     TestModuleIf().Event( stifEvent );    
       
   631     }
       
   632     
       
   633 // -----------------------------------------------------------------------------
       
   634 // Cttsutilitytest::MapcPlayComplete
       
   635 //
       
   636 // -----------------------------------------------------------------------------
       
   637 // 
       
   638 void Cttsutilitytest::MapcPlayComplete( TInt aError )
       
   639     {
       
   640     if ( aError )
       
   641         {
       
   642         User::Panic( Kttsutilitytest, aError );
       
   643         }
       
   644     
       
   645     TEventIf stifEvent( TEventIf::ESetEvent, _L( "MapcPlayComplete" ) );
       
   646     TestModuleIf().Event( stifEvent );
       
   647     }
       
   648     
       
   649 //  End of File