uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestbuttons/src/bctestbuttonscase.cpp
branchRCL_3
changeset 56 d48ab3b357f1
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
       
     1 /*
       
     2 * Copyright (c) 2006 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:  test case
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <w32std.h>
       
    20 #include <coecntrl.h>
       
    21 #include <avkon.hrh>
       
    22 #include <AknsConstants.h> //
       
    23 
       
    24 #include <eikbgfty.h>
       
    25 #include <eikenv.h>
       
    26 #include <eikcolib.h>
       
    27 #include <eikbtgpc.h>
       
    28 #include <eikcmbut.h>
       
    29 #include <eikbutb.h>
       
    30 #include <s32file.h>
       
    31 #include <eikcba.h>
       
    32 #include <eikcmbut.h>
       
    33 #include <barsread.h>
       
    34 #include <avkon.mbg>
       
    35 #include <eiklbbut.h>
       
    36 #include <coecntrl.h>
       
    37 #include <eikmnbut.h>
       
    38 #include <eikbtgps.h>
       
    39 #include <eikbtgrp.h>
       
    40 
       
    41 #include <akniconutils.h>
       
    42 #include <bctestbuttons.rsg>
       
    43 #include <bctestbuttons.mbg>
       
    44 
       
    45 #include "bctestbuttonscase.h"
       
    46 #include "bctestbuttonscontainer.h"
       
    47 #include "bctestbuttons.hrh"
       
    48 #include "streamlogger.h"
       
    49 
       
    50 _LIT( KStreamName, "c:\\BCTestLog\\buttontest.txt" );
       
    51 
       
    52 // ======== MEMBER FUNCTIONS ========
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Symbian 2nd static Constructor
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CBCTestButtonsCase* CBCTestButtonsCase::NewL(
       
    59     CBCTestButtonsContainer* aContainer )
       
    60     {
       
    61     CBCTestButtonsCase* self = new( ELeave ) CBCTestButtonsCase(
       
    62         aContainer );
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     CleanupStack::Pop( self );
       
    66     return self;
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // C++ default constructor
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CBCTestButtonsCase::CBCTestButtonsCase(
       
    74     CBCTestButtonsContainer* aContainer )
       
    75     : iContainer( aContainer )
       
    76     {
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // Destructor
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 CBCTestButtonsCase::~CBCTestButtonsCase()
       
    84     {
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Symbian 2nd Constructor
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CBCTestButtonsCase::ConstructL()
       
    92     {
       
    93     BuildScriptL();
       
    94     iEnv = CEikonEnv::Static();
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // CBCTestButtonsCase::BuildScriptL
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void CBCTestButtonsCase::BuildScriptL()
       
   102     {
       
   103     // Add script as your need.
       
   104 	AddTestL( DELAY(1), TEND);
       
   105     TInt loop = EBCTestCmdMaxOutline - EBCTestCmdTestEikBgftyAndEikBtgpcL;
       
   106     for ( TInt i = 0; i < loop; i++ )
       
   107         {
       
   108         AddTestL( LeftCBA, REP( Down, i ), KeyOK, TEND );
       
   109         }
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // CBCTestButtonsCase::RunL
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 void CBCTestButtonsCase::RunL( TInt aCmd )
       
   117     {
       
   118     if ( aCmd < EBCTestCmdTestEikBgftyAndEikBtgpcL  || aCmd > EBCTestCmdMaxOutline )
       
   119         {
       
   120         return;
       
   121         }
       
   122     // Call release before prepare to let container has time to draw the
       
   123     // control created in PrepareCaseL.
       
   124     switch ( aCmd )
       
   125         {
       
   126         case EBCTestCmdTestEikBgftyAndEikBtgpcL:
       
   127             TestEikBgftyAndEikBtgpcL();
       
   128             break;
       
   129         case EBCTestCmdTestEikButbAndEikCbaL:
       
   130             TestEikButbAndEikCbaL();
       
   131             break;
       
   132         case EBCTestCEikCommandButtonL:
       
   133             TestCEikCommandButtonL();
       
   134             break;
       
   135         case EBCTestCEikTwoPictureCmdL:
       
   136             TestCEikTwoPictureCmdL();
       
   137             break;
       
   138         case EBCTestCEikInverterCmdL:
       
   139             TestCEikInverterCmdL();
       
   140             break;
       
   141         case EBCTestCEikTextBtnL:
       
   142             TestCEikTextBtnL();
       
   143             break;
       
   144         case EBCTestCEikBitmapBtnL:
       
   145             TestCEikBitmapBtnL();
       
   146             break;
       
   147         case EBCTestCEikLabeledBtnL:
       
   148             TestCEikLabeledBtnL();
       
   149             break;
       
   150         case EBCTestMnbutAndBtgpsAndBtgrpL:
       
   151             TestMnbutAndBtgpsAndBtgrpL();
       
   152             break;
       
   153         case EBCTestCba:
       
   154             TestCbaButtonL();
       
   155             break;
       
   156         default:
       
   157             break;
       
   158         }
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // CBCTestButtonsCase::TestEikBgftyAndEikBtgpcL
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CBCTestButtonsCase::TestEikBgftyAndEikBtgpcL()
       
   166     {
       
   167     // Test some API for class EikButtonGroupFactory
       
   168     TBCTestCommandObserver commandObserver;
       
   169     TInt resourceId = R_BCTESTBUTTONS_MENU;
       
   170 
       
   171     RWindowGroup& parentWg = iEnv->RootWin();
       
   172     TUint flags = 0;
       
   173 
       
   174     EikButtonGroupFactory::TCreationData creationData(
       
   175         CEikButtonGroupContainer::EView, &commandObserver,
       
   176         resourceId, &parentWg, flags,
       
   177         CEikButtonGroupContainer::EVertical );
       
   178     _LIT( KTCreationData, "TCreationData test" );
       
   179     AssertTrueL( ETrue, KTCreationData );
       
   180 
       
   181     // Test some API for class CEikButtonGroupFactoryArray
       
   182     CEikButtonGroupFactoryArray::AppendFactoryFunctionL(
       
   183         CEikCoCtlLibrary::ButtonGroupFactory() );
       
   184     _LIT( KAppendFactoryFunctionL, "AppendFactoryFunctionL test" );
       
   185     AssertTrueL( ETrue, KAppendFactoryFunctionL );
       
   186 
       
   187     CEikButtonGroupFactoryArray::RemoveFactoryFunction(
       
   188         CEikCoCtlLibrary::ButtonGroupFactory() );
       
   189     _LIT( KRemoveFactoryFunction, "RemoveFactoryFunction test" );
       
   190     AssertTrueL( ETrue, KRemoveFactoryFunction );
       
   191 
       
   192     // Test some API for class CEikButtonGroupContainer
       
   193     TInt resourceIdForToolbar = R_BCTESTBUTTONS_TOOLBAR;
       
   194     CEikButtonGroupContainer* buttonGroupContainer1 =
       
   195         CEikButtonGroupContainer::NewL( CEikButtonGroupContainer::EView,
       
   196         CEikButtonGroupContainer::EVertical, &commandObserver,
       
   197         resourceIdForToolbar, CEikButtonGroupContainer::EAddToStack );
       
   198     CleanupStack::PushL( buttonGroupContainer1 );
       
   199     _LIT( KNewL, "NewL test" );
       
   200     AssertTrueL( ETrue, KNewL );
       
   201     CleanupStack::PopAndDestroy( buttonGroupContainer1 );
       
   202 
       
   203     CEikButtonGroupContainer* buttonGroupContainer2 =
       
   204         CEikButtonGroupContainer::NewL( CEikButtonGroupContainer::EView,
       
   205         CEikButtonGroupContainer::EVertical, &commandObserver,
       
   206         resourceIdForToolbar, *iContainer,
       
   207         CEikButtonGroupContainer::EAddToStack);
       
   208     CleanupStack::PushL( buttonGroupContainer2 );
       
   209     _LIT( KNewLWithCCoeControl, "NewL WithCCoeControl test" );
       
   210     AssertTrueL( ETrue, KNewLWithCCoeControl );
       
   211     CleanupStack::PopAndDestroy( buttonGroupContainer2 );
       
   212 
       
   213 
       
   214     CEikButtonGroupContainer* buttonGroupContainer3 =
       
   215         CEikButtonGroupContainer::NewL( CEikButtonGroupContainer::EView,
       
   216         CEikButtonGroupContainer::EVertical, &commandObserver,
       
   217         resourceIdForToolbar, parentWg,
       
   218         CEikButtonGroupContainer::EAddToStack );
       
   219     CleanupStack::PushL( buttonGroupContainer3 );
       
   220     _LIT( KNewLWithRWindowGroup, "NewL With RWindowGroup test" );
       
   221     AssertTrueL( ETrue, KNewLWithRWindowGroup );
       
   222     CleanupStack::PopAndDestroy( buttonGroupContainer3 );
       
   223 
       
   224     CEikButtonGroupContainer* buttonGroupContainer4 =
       
   225         CEikButtonGroupContainer::Current();
       
   226 
       
   227     _LIT( KCurrent, "Current test" );
       
   228     AssertTrueL( ETrue, KCurrent );
       
   229 
       
   230     TInt resourceIdForCba = R_BCTESTBUTTONS_CBA_OPTIONS_NEXT;
       
   231     buttonGroupContainer4->SetCommandSetL( resourceIdForCba );
       
   232     _LIT( KSetCommandSetL, "SetCommandSetL test" );
       
   233     AssertTrueL( ETrue, KSetCommandSetL );
       
   234 
       
   235     buttonGroupContainer4->AddCommandSetToStackL( resourceIdForCba );
       
   236     _LIT( KAddCommandSetToStackL, "AddCommandSetToStackL test" );
       
   237     AssertTrueL( ETrue, KAddCommandSetToStackL );
       
   238 
       
   239     TInt commandId = EAknSoftkeyOptions;
       
   240     TInt position = buttonGroupContainer4->PositionById( commandId );
       
   241     _LIT( KPositionById, "PositionById test" );
       
   242     AssertTrueL( ETrue, KPositionById );
       
   243 
       
   244     buttonGroupContainer4->RemoveCommandFromStack( position, commandId);
       
   245     _LIT( KRemoveCommandFromStack, "RemoveCommandFromStack test" );
       
   246     AssertTrueL( ETrue, KRemoveCommandFromStack );
       
   247 
       
   248     buttonGroupContainer4->SetDefaultCommand( commandId );
       
   249     _LIT( KSetDefaultCommand, "SetDefaultCommand test" );
       
   250     AssertTrueL( ETrue, KSetDefaultCommand );
       
   251 
       
   252     TSize size1 = buttonGroupContainer4->CalcMinimumSizeL( resourceIdForCba );
       
   253     _LIT( KCalcMinimumSizeL, "CalcMinimumSizeL test" );
       
   254     AssertTrueL( ETrue, KCalcMinimumSizeL );
       
   255 
       
   256     buttonGroupContainer4->CleanupCommandPushL( position );
       
   257     _LIT( KCleanupCommandPushL, "CleanupCommandPushL test" );
       
   258     AssertTrueL( ETrue, KCleanupCommandPushL );
       
   259     
       
   260     TInt res( KErrNone );
       
   261     _LIT( KOfferCommandListL, "OfferCommandListL tested" );
       
   262     TRAP( res, buttonGroupContainer4->OfferCommandListL( resourceIdForCba ) );
       
   263     AssertTrueL( ETrue, KOfferCommandListL );
       
   264     
       
   265     RArray<TInt> arr;
       
   266     arr.Append( commandId );
       
   267     _LIT( KOfferCommandListLOverload, "OfferCommandListL overload tested" );
       
   268     TRAP( res, buttonGroupContainer4->OfferCommandListL( arr ) );
       
   269     AssertTrueL( ETrue, KOfferCommandListLOverload );
       
   270     arr.Close();
       
   271 
       
   272     TInt countForCleanupCommandPop = 1;
       
   273     buttonGroupContainer4->CleanupCommandPop( countForCleanupCommandPop );
       
   274     _LIT( KCleanupCommandPop, "CleanupCommandPop test" );
       
   275     AssertTrueL( ETrue, KCleanupCommandPop );
       
   276 
       
   277     TInt maxCommands = buttonGroupContainer4->MaxCommands();
       
   278     _LIT( KMaxCommands, "MaxCommands test" );
       
   279     AssertTrueL( ETrue, KMaxCommands );
       
   280 
       
   281     TInt buttonCount = buttonGroupContainer4->ButtonCount();
       
   282     _LIT( KButtonCount, "ButtonCount test" );
       
   283     AssertTrueL( ETrue, KButtonCount );
       
   284 
       
   285     TBool dimmed = ETrue;
       
   286     buttonGroupContainer4->DimCommand( commandId, dimmed );
       
   287     _LIT( KDimCommand, "DimCommand test" );
       
   288     AssertTrueL( ETrue, KDimCommand );
       
   289     buttonGroupContainer4->DimCommand( commandId, EFalse );
       
   290 
       
   291     TBool isCommandDimmed = buttonGroupContainer4->IsCommandDimmed( commandId );
       
   292     _LIT( KIsCommandDimmed, "IsCommandDimmed test" );
       
   293     AssertTrueL( ETrue, KIsCommandDimmed );
       
   294 
       
   295     TBool visible = ETrue;
       
   296     buttonGroupContainer4->MakeCommandVisible( commandId, visible );
       
   297      _LIT( KMakeCommandVisible, "MakeCommandVisible test" );
       
   298     AssertTrueL( ETrue, KMakeCommandVisible );
       
   299 
       
   300     TBool isCommandVisible = buttonGroupContainer4->IsCommandVisible( commandId );
       
   301     _LIT( KIsCommandVisible, "IsCommandVisible test" );
       
   302     AssertTrueL( ETrue, KIsCommandVisible );
       
   303 
       
   304     buttonGroupContainer4->AnimateCommand( commandId );
       
   305     _LIT( KAnimateCommand1, "AnimateCommand test" );
       
   306     AssertTrueL( ETrue, KAnimateCommand1 );
       
   307 
       
   308     CEikButtonGroupContainer::TLocation location =
       
   309         buttonGroupContainer4->Location();
       
   310     _LIT( KLocation, "Location test" );
       
   311     AssertTrueL( ETrue, KLocation );
       
   312 
       
   313 #ifndef _DEBUG
       
   314     CEikCommandButton* commandButton1 =
       
   315         buttonGroupContainer4->CommandButtonOrNull( commandId );
       
   316     CleanupStack::PushL( commandButton1 );
       
   317     _LIT( KCommandButtonOrNull, "CommandButtonOrNull test" );
       
   318     AssertTrueL( ETrue, KCommandButtonOrNull );
       
   319     CleanupStack::PopAndDestroy( commandButton1 );
       
   320 #endif
       
   321 
       
   322     TRect rect = iContainer->Rect();
       
   323     buttonGroupContainer4->SetBoundingRect( rect );
       
   324     _LIT( KSetBoundingRect, "SetBoundingRect test" );
       
   325     AssertTrueL( ETrue, KSetBoundingRect );
       
   326 
       
   327     buttonGroupContainer4->ReduceRect( rect );
       
   328     _LIT( KReduceRect, "ReduceRect test" );
       
   329     AssertTrueL( ETrue, KReduceRect );
       
   330 
       
   331     CCoeControl* coeControl =
       
   332         buttonGroupContainer4->ControlOrNull( commandId );
       
   333     _LIT( KControlOrNull, "ControlOrNull test" );
       
   334     AssertTrueL( ETrue, KControlOrNull );
       
   335 
       
   336 #ifndef _DEBUG
       
   337     CEikCommandButton* commandbutton2 =
       
   338         buttonGroupContainer4->ButtonById( commandId );
       
   339     _LIT( KButtonById, "ButtonById test" );
       
   340     AssertTrueL( ETrue, KButtonById );
       
   341 #endif
       
   342 
       
   343     TInt keyId = 1;
       
   344     buttonGroupContainer4->UpdateHotKey( commandId,
       
   345         CEikButtonGroupContainer::EShowHotKey, keyId);
       
   346     _LIT( KUpdateHotKey, "UpdateHotKey test" );
       
   347     AssertTrueL( ETrue, KUpdateHotKey );
       
   348 
       
   349     TInt pos = 1;
       
   350     buttonGroupContainer4->UpdateCommandObserverL( pos, commandObserver );
       
   351     _LIT( KUpdateCommandObserverL, "UpdateCommandObserverL test" );
       
   352     AssertTrueL( ETrue, KUpdateCommandObserverL );
       
   353 
       
   354     buttonGroupContainer4->RemoveCommandObserver( pos );
       
   355     _LIT( KRemoveCommandObserver, "RemoveCommandObserver test" );
       
   356     AssertTrueL( ETrue, KRemoveCommandObserver );
       
   357 
       
   358     TBool delayActivation = buttonGroupContainer4->DelayActivation();
       
   359     _LIT( KDelayActivation, "DelayActivation test" );
       
   360     AssertTrueL( ETrue, KDelayActivation );
       
   361 
       
   362     TSize minimumSize1 = buttonGroupContainer4->MinimumSize();
       
   363     _LIT( KMinimumSize1, "MinimumSize test" );
       
   364     AssertTrueL( ETrue, KMinimumSize1 );
       
   365 
       
   366     TKeyEvent keyEvent1 = { EKeyPause, EStdKeySpace, 0, 0  };
       
   367     TKeyResponse keyresponse =
       
   368         buttonGroupContainer4->OfferKeyEventL( keyEvent1, EEventKey );
       
   369     _LIT( KOfferKeyEventL1, "OfferKeyEventL test" );
       
   370     AssertTrueL( ETrue, KOfferKeyEventL1 );
       
   371 
       
   372     RFs& tempServer = iEnv->FsSession();
       
   373     tempServer.Delete( KStreamName );
       
   374     RFileWriteStream fWrite;
       
   375     User::LeaveIfError( fWrite.Create( tempServer,
       
   376         KStreamName, EFileWrite ) );
       
   377     CleanupClosePushL( fWrite );
       
   378     buttonGroupContainer4->WriteInternalStateL( fWrite );
       
   379     CleanupStack::PopAndDestroy( &fWrite );
       
   380     tempServer.Delete( KStreamName );
       
   381     _LIT( KWriteInternalStateL1, "WriteInternalStateLtest test" );
       
   382     AssertTrueL( ETrue, KWriteInternalStateL1);
       
   383 
       
   384     buttonGroupContainer4->Reserved_MtsmPosition();
       
   385     _LIT( KReserved_MtsmPosition, "Reserved_MtsmPosition" );
       
   386     AssertTrueL( ETrue, KReserved_MtsmPosition );
       
   387 
       
   388     buttonGroupContainer4->Reserved_MtsmObject();
       
   389      _LIT( KReserved_MtsmObject, "Reserved_MtsmObject test" );
       
   390     AssertTrueL( ETrue, KReserved_MtsmObject );
       
   391 
       
   392     TBool isCommandInGroup = buttonGroupContainer4->IsCommandInGroup( commandId );
       
   393     _LIT( KIsCommandInGroup, "IsCommandInGroup test" );
       
   394     AssertTrueL( ETrue, KIsCommandInGroup );
       
   395 
       
   396     buttonGroupContainer4->ReplaceCommand( commandId, resourceIdForCba );
       
   397     _LIT( KReplaceCommand, "ReplaceCommand test" );
       
   398     AssertTrueL( ETrue, KReplaceCommand );
       
   399     }
       
   400 
       
   401 // --------------------------------------------------------------------------
       
   402 // TBCTestCommandObserver::ProcessCommandL
       
   403 // ---------------------------------------------------------------------------
       
   404 //
       
   405 void TBCTestCommandObserver::ProcessCommandL( TInt )
       
   406     {
       
   407     }
       
   408 
       
   409 // ---------------------------------------------------------------------------
       
   410 // CBCTestButtonsCase::TestEikButbAndEikCbaL
       
   411 // ---------------------------------------------------------------------------
       
   412 //
       
   413 void CBCTestButtonsCase::TestEikButbAndEikCbaL()
       
   414     {
       
   415     // Test some API for class TEikButtonCoordinator
       
   416     TEikButtonCoordinator coordinator;
       
   417     _LIT( KTEikButtonCoordinator, "TEikButtonCoordinator test" );
       
   418     AssertTrueL( ETrue, KTEikButtonCoordinator );
       
   419 
       
   420     CEikButtonBase* chosenButton = new( ELeave ) CEikButtonBase();
       
   421     CleanupStack::PushL( chosenButton );
       
   422     coordinator.SetChosenButton( chosenButton );
       
   423      _LIT( KSetChosenButton, "SetChosenButton test" );
       
   424     AssertTrueL( ETrue, KSetChosenButton );
       
   425     CleanupStack::PopAndDestroy( chosenButton );
       
   426     }
       
   427 
       
   428 // ---------------------------------------------------------------------------
       
   429 // CBCTestButtonsCase::SetupCommandBtnL
       
   430 // ---------------------------------------------------------------------------
       
   431 //
       
   432 CEikCommandButton* CBCTestButtonsCase::SetupCommandBtnL()
       
   433     {
       
   434     //1. just new
       
   435     CEikCommandButton* commandButton = new( ELeave )CEikCommandButton();
       
   436     CleanupStack::PushL( commandButton );
       
   437 
       
   438     //2. construct from res
       
   439     TResourceReader reader1;
       
   440     iEnv->CreateResourceReaderLC( reader1, R_BCTESTBUTTONS_CMBUT );
       
   441     commandButton->ConstructFromResourceL( reader1 );
       
   442     _LIT( KConstructFromResourceL1, "ConstructFromResourceL test" );
       
   443     AssertTrueL( ETrue, KConstructFromResourceL1 );
       
   444     CleanupStack::PopAndDestroy(); //reader1
       
   445 
       
   446     return commandButton;
       
   447     }
       
   448 
       
   449 // ---------------------------------------------------------------------------
       
   450 // CBCTestButtonsCase::TeardownCommandBtnL
       
   451 // ---------------------------------------------------------------------------
       
   452 //
       
   453 void CBCTestButtonsCase::TeardownCommandBtnL(CEikCommandButton* aBtn)
       
   454     {
       
   455     CleanupStack::PopAndDestroy( aBtn );
       
   456     _LIT( KDesCommandButton, "~CommandButton() test" );
       
   457     AssertTrueL( ETrue, KDesCommandButton );
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------------------------
       
   461 // CBCTestButtonsCase::TestSetBtnLayoutL
       
   462 // ---------------------------------------------------------------------------
       
   463 //
       
   464 void CBCTestButtonsCase::TestSetBtnLayoutL()
       
   465     {
       
   466     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   467 
       
   468     commandButton->SetButtonLayout( CEikCommandButton::ETextRightPictureLeft );
       
   469     _LIT( KSetButtonLayout, "TSetButtonLayout test" );
       
   470     AssertTrueL( ETrue, KSetButtonLayout);
       
   471 
       
   472     TeardownCommandBtnL(commandButton);
       
   473     }
       
   474 
       
   475 // ---------------------------------------------------------------------------
       
   476 // CBCTestButtonsCase::TestExcessSpace
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 void CBCTestButtonsCase::TestExcessSpace()
       
   480     {
       
   481     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   482 
       
   483     commandButton->SetExcessSpace( CEikCommandButton::EShare );
       
   484     _LIT( KSetExcessSpace, "SetExcessSpace test" );
       
   485     AssertTrueL( ETrue, KSetExcessSpace );
       
   486 
       
   487     TeardownCommandBtnL(commandButton);
       
   488     }
       
   489 
       
   490 // ---------------------------------------------------------------------------
       
   491 // CBCTestButtonsCase::TestStuff
       
   492 // ---------------------------------------------------------------------------
       
   493 //
       
   494 void CBCTestButtonsCase::TestStuff()
       
   495     {
       
   496     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   497 
       
   498     _LIT( KText, "xxxxxxxxx" );
       
   499     commandButton->SetTextL( KText );
       
   500     _LIT( KSetTextL1, "SetTextL test" );
       
   501     AssertTrueL( ETrue, KSetTextL1 );
       
   502 
       
   503     CEikLabel* label = commandButton->Label();
       
   504     _LIT( KLabel1, "Label test" );
       
   505     AssertTrueL( ETrue, KLabel1 );
       
   506 
       
   507     commandButton->SetDisplayContent( CEikCommandButton::ETextOnly );
       
   508     _LIT( KSetDisplayContent, "SetDisplayContent test" );
       
   509     AssertTrueL( ETrue, KSetDisplayContent );
       
   510 
       
   511     TeardownCommandBtnL(commandButton);
       
   512     }
       
   513 
       
   514 // ---------------------------------------------------------------------------
       
   515 // CBCTestButtonsCase::TestImgBtnL()
       
   516 // ---------------------------------------------------------------------------
       
   517 //
       
   518 void CBCTestButtonsCase::TestImgBtnL()
       
   519     {
       
   520     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   521 
       
   522     _LIT( KButtonIconFile1, "z:\\resource\\apps\\BCTestButtons.mbm" );
       
   523     TInt normal1 = 1;
       
   524     CFbsBitmap * normalBitmap1 = AknIconUtils::CreateIconL( KButtonIconFile1, normal1 );
       
   525     CleanupStack::PushL( normalBitmap1 );
       
   526 
       
   527     commandButton->SetPictureL( normalBitmap1, NULL );
       
   528     _LIT( KSetPictureL1, "SetPictureL test" );
       
   529     AssertTrueL( ETrue, KSetPictureL1 );
       
   530 
       
   531     CEikImage* image = commandButton->Picture();
       
   532     _LIT( KPicture, "Picture test" );
       
   533     AssertTrueL( ETrue, KPicture );
       
   534 
       
   535     CleanupStack::Pop(normalBitmap1);
       
   536 
       
   537     TeardownCommandBtnL(commandButton);
       
   538     }
       
   539 
       
   540 // ---------------------------------------------------------------------------
       
   541 // CBCTestButtonsCase::TestStackRelatedL
       
   542 // ---------------------------------------------------------------------------
       
   543 //
       
   544 void CBCTestButtonsCase::TestStackRelatedL()
       
   545     {
       
   546     // stack realated have issues
       
   547     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   548 
       
   549     _LIT( KButtonIconFile2, "z:\\resource\\apps\\BCTestButtons.mbm" );
       
   550     TInt normal2 = 1;
       
   551     CFbsBitmap * normalBitmap2 = AknIconUtils::CreateIconL( KButtonIconFile2, normal2 );
       
   552     CleanupStack::PushL( normalBitmap2 );
       
   553 
       
   554     TInt commandId2 = EProgCmdAutoTest;
       
   555     TBuf<10> buf2 = _L( "xxxxxxx" );
       
   556     commandButton->AddCommandToStackL( commandId2, &buf2, normalBitmap2, normalBitmap2 );
       
   557     _LIT( KAddCommandToStackL, "AddCommandToStackL test" );
       
   558     AssertTrueL( ETrue, KAddCommandToStackL );
       
   559 
       
   560     CleanupStack::Pop( normalBitmap2 );
       
   561 
       
   562     TBool removeCommandFromStack = commandButton->RemoveCommandFromStack( R_BCTESTBUTTONS_CBA_OPTIONS_NEXT );
       
   563     _LIT( KRemoveCommandFromStack, "RemoveCommandFromStack test" );
       
   564     AssertTrueL( ETrue, KRemoveCommandFromStack );
       
   565 
       
   566     TInt popCommandFromStack = commandButton->PopCommandFromStack();
       
   567     _LIT( KPopCommandFromStack, "PopCommandFromStack test" );
       
   568     AssertTrueL( ETrue, KPopCommandFromStack );
       
   569 
       
   570     TeardownCommandBtnL(commandButton);
       
   571     }
       
   572 
       
   573 // ---------------------------------------------------------------------------
       
   574 // CBCTestButtonsCase::TestCommandButtonBaseL
       
   575 // ---------------------------------------------------------------------------
       
   576 //
       
   577 void CBCTestButtonsCase::TestCommandButtonBaseL()
       
   578     {
       
   579     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   580 
       
   581     commandButton->CCoeControl::DrawNow();
       
   582     _LIT( KDraw, "Draw for CEikCommandButtonBase test" );
       
   583     AssertTrueL( ETrue, KDraw );
       
   584 	
       
   585     commandButton->CEikCommandButtonBase::LayoutComponents();
       
   586     _LIT( KLayoutComponents,
       
   587         "LayoutComponents for CEikCommandButtonBase test" );
       
   588     AssertTrueL( ETrue, KLayoutComponents );
       
   589 
       
   590     commandButton->CEikCommandButtonBase::SetDefault( ETrue );
       
   591     _LIT( KSetDefault, "SetDefault for CEikCommandButtonBase test" );
       
   592     AssertTrueL( ETrue, KSetDefault );
       
   593 
       
   594     /*iCmdBtnBase = new( ELeave )CBCTestCmdBtnBase();
       
   595     iContainer->SetControl( iCmdBtnBase );
       
   596     _LIT( KDraw, "Draw for CEikCommandButtonBase test" );
       
   597     AssertTrueL( ETrue, KDraw );*/
       
   598 
       
   599     commandButton->CEikCommandButtonBase::FocusChanged( ENoDrawNow );
       
   600     _LIT( KFocusChanged, "FocusChanged for CEikCommandButtonBase test" );
       
   601     AssertTrueL( ETrue, KFocusChanged );
       
   602 
       
   603     CArrayFixFlat<TCoeColorUse>* colorUseList2 =
       
   604         new( ELeave ) CArrayFixFlat<TCoeColorUse>( 1 );
       
   605     TCoeColorUse colorUse2;
       
   606     colorUseList2->AppendL( colorUse2 );
       
   607     commandButton->CEikCommandButtonBase::GetColorUseListL( *colorUseList2 );
       
   608     CleanupStack::PushL( colorUseList2 );
       
   609     _LIT( KGetColorUseListL2,
       
   610         "GetColorUseListL for CEikCommandButtonBase test" );
       
   611     AssertTrueL( ETrue, KGetColorUseListL2 );
       
   612     CleanupStack::PopAndDestroy( colorUseList2 );
       
   613 
       
   614     TKeyEvent keyEvent3 = { EKeyPause, EStdKeySpace, 0, 0  };
       
   615     TKeyResponse keyResponse =
       
   616         commandButton->CEikCommandButtonBase::OfferKeyEventL(
       
   617         keyEvent3, EEventNull );
       
   618     _LIT( KOfferKeyEventL3, "OfferKeyEventL for CEikCommandButtonBase test" );
       
   619     AssertTrueL( ETrue, KOfferKeyEventL3 );
       
   620 
       
   621     commandButton->CEikCommandButtonBase::ActivateL();
       
   622     _LIT( KActivateL2, "ActivateL for CEikCommandButtonBase test" );
       
   623     AssertTrueL( ETrue, KActivateL2 );
       
   624 
       
   625     commandButton->CEikCommandButtonBase::UpdateComponentAlignment();
       
   626     _LIT( KUpdateComponentAlignment,
       
   627         "UpdateComponentAlignment for CEikCommandButtonBase test" );
       
   628     AssertTrueL( ETrue, KUpdateComponentAlignment );
       
   629 
       
   630 
       
   631     TeardownCommandBtnL(commandButton);
       
   632     }
       
   633 
       
   634 // ---------------------------------------------------------------------------
       
   635 // CBCTestButtonsCase::TestButtonBaseL
       
   636 // ---------------------------------------------------------------------------
       
   637 //
       
   638 void CBCTestButtonsCase::TestButtonBaseL()
       
   639     {
       
   640     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   641 
       
   642     CBCTestBtnBase* btnBase = new( ELeave )CBCTestBtnBase();
       
   643     CleanupStack::PushL( btnBase );
       
   644 
       
   645     CEikButtonBase* buttonBase = new( ELeave ) CEikButtonBase();
       
   646     CleanupStack::PushL( buttonBase );
       
   647     btnBase->CEikButtonBase::CopyDrawStateTo( buttonBase );
       
   648     CleanupStack::PopAndDestroy( buttonBase );
       
   649     _LIT( KCopyDrawStateTo, "CopyDrawStateTo for CEikButtonBase test" );
       
   650     AssertTrueL( ETrue, KCopyDrawStateTo );
       
   651 
       
   652     TBool isPressed = btnBase->CEikButtonBase::IsPressed();
       
   653     _LIT( KIsPressed, "IsPressed for CEikButtonBase test" );
       
   654     AssertTrueL( ETrue, KIsPressed );
       
   655 
       
   656     btnBase->CEikButtonBase::SetAllowTristate();
       
   657     _LIT( KSetAllowTristate, "SetAllowTristate for CEikButtonBase test" );
       
   658     AssertTrueL( ETrue, KSetAllowTristate );
       
   659 
       
   660     CleanupStack::PopAndDestroy( btnBase );
       
   661 
       
   662     CArrayFixFlat<TCoeColorUse>* colorUseList3 =
       
   663         new( ELeave ) CArrayFixFlat<TCoeColorUse>( 1 );
       
   664     TCoeColorUse colorUse3;
       
   665     colorUseList3->AppendL( colorUse3 );
       
   666     commandButton->CEikButtonBase::GetColorUseListL( *colorUseList3 );
       
   667     CleanupStack::PushL( colorUseList3 );
       
   668     _LIT( KGetColorUseListL3,
       
   669         "GetColorUseListL for CEikButtonBase test" );
       
   670     AssertTrueL( ETrue, KGetColorUseListL3 );
       
   671     CleanupStack::PopAndDestroy( colorUseList3 );
       
   672 
       
   673     TCoeInputCapabilities capabilities =
       
   674         commandButton->CEikButtonBase::InputCapabilities();
       
   675     _LIT( KInputCapabilities, "InputCapabilities for CEikButtonBase test" );
       
   676     AssertTrueL( ETrue, KInputCapabilities );
       
   677 
       
   678     TKeyEvent keyEvent4 = { EKeyPause, EStdKeySpace, 0, 0  };
       
   679     TKeyResponse keyResponse4 =
       
   680         commandButton->CEikButtonBase::OfferKeyEventL(
       
   681         keyEvent4, EEventNull );
       
   682     _LIT( KOfferKeyEventL4, "OfferKeyEventL for CEikButtonBase test" );
       
   683     AssertTrueL( ETrue, KOfferKeyEventL4 );
       
   684 
       
   685     TEikButtonCoordinator butCoord;
       
   686     commandButton->CEikButtonBase::SetCoordinator( &butCoord );
       
   687     _LIT( KSetCoordinator, "SetCoordinator for CEikButtonBase test" );
       
   688     AssertTrueL( ETrue, KSetCoordinator );
       
   689 
       
   690     commandButton->CEikButtonBase::SetIgnoreNextPointerUp();
       
   691     _LIT( KSetIgnoreNextPointerUp, "SetIgnoreNextPointerUp for CEikButtonBase test" );
       
   692     AssertTrueL( ETrue, KSetIgnoreNextPointerUp );
       
   693 
       
   694     TeardownCommandBtnL(commandButton);
       
   695     }
       
   696 // ---------------------------------------------------------------------------
       
   697 // CBCTestButtonsCase::TestCEikCommandButton
       
   698 // ---------------------------------------------------------------------------
       
   699 //
       
   700 void CBCTestButtonsCase::TestCEikCommandButtonL()
       
   701     {
       
   702     // Test some API for class CEikCommandButtonBase
       
   703     TestSetBtnLayoutL();
       
   704     TestExcessSpace();
       
   705     TestStuff();
       
   706     TestImgBtnL();
       
   707     TestCommandButtonBaseL();
       
   708     TestButtonBaseL();
       
   709 
       
   710     CEikCommandButton* commandButton = SetupCommandBtnL();
       
   711 
       
   712     _LIT( KButtonIconFile1, "z:\\resource\\apps\\BCTestButtons.mbm" );
       
   713     TInt normal1 = 1;
       
   714     CFbsBitmap * normalBitmap1 = AknIconUtils::CreateIconL( KButtonIconFile1, normal1 );
       
   715     CleanupStack::PushL( normalBitmap1 );
       
   716 
       
   717     TInt commandId = R_BCTESTBUTTONS_CBA_OPTIONS_NEXT;
       
   718     TBuf<10> buf = _L( "xxxxxxx" );
       
   719     commandButton->SetCommandL( commandId, &buf, normalBitmap1, normalBitmap1 );
       
   720     _LIT( KSetCommandL, "SetCommandL test" );
       
   721     AssertTrueL( ETrue, KSetCommandL );
       
   722 
       
   723     CleanupStack::Pop(normalBitmap1);
       
   724 
       
   725     TPointerEvent pointerEvent1;
       
   726     pointerEvent1.iType = TPointerEvent::EButton1Up;
       
   727     commandButton->HandlePointerEventL( pointerEvent1 );
       
   728     _LIT( KHandlePointerEventL1, "HandlePointerEventL test" );
       
   729     AssertTrueL( ETrue, KHandlePointerEventL1 );
       
   730 
       
   731     commandButton->UpdateComponentAlignment();
       
   732     _LIT( KUpdateComponentAlignment, "UpdateComponentAlignment test" );
       
   733     AssertTrueL( ETrue, KUpdateComponentAlignment );
       
   734 
       
   735     commandButton->SetPictureFromFileL( AknIconUtils::AvkonIconFileName(),
       
   736         EMbmAvkonQgn_indi_marked_add, EMbmAvkonQgn_indi_marked_add_mask );
       
   737     _LIT( KSetPictureFromFileL1, "SetPictureFromFileL test" );
       
   738     AssertTrueL( ETrue, KSetPictureFromFileL1 );
       
   739 
       
   740     TestStackRelatedL();
       
   741 
       
   742     TeardownCommandBtnL(commandButton);
       
   743     }
       
   744 
       
   745 CEikTwoPictureCommandButton* CBCTestButtonsCase::SetupTwoPictureCmdL()
       
   746     {
       
   747     //1. just new
       
   748     CEikTwoPictureCommandButton* twoPictureCommandButton =
       
   749         new( ELeave ) CEikTwoPictureCommandButton();
       
   750     CleanupStack::PushL( twoPictureCommandButton );
       
   751     _LIT( KCEikTwoPictureCommandButton, "CEikTwoPictureCommandButton() test" );
       
   752     AssertTrueL( ETrue, KCEikTwoPictureCommandButton );
       
   753 
       
   754     //2. construct from res
       
   755     TResourceReader reader2;
       
   756     iEnv->CreateResourceReaderLC( reader2, R_BCTESTBUTTONS_PICMBUT );
       
   757     twoPictureCommandButton->ConstructFromResourceL( reader2 );
       
   758     _LIT( KConstructFromResourceL2,
       
   759         "ConstructFromResourceL For CEikTwoPictureCommandButton test" );
       
   760     AssertTrueL( ETrue, KConstructFromResourceL2 );
       
   761     CleanupStack::PopAndDestroy(); //reader2
       
   762 
       
   763     return twoPictureCommandButton;
       
   764     }
       
   765 
       
   766 void CBCTestButtonsCase::TeardownTwoPictureCmdL(CEikTwoPictureCommandButton* aBtn)
       
   767     {
       
   768     CleanupStack::PopAndDestroy( aBtn );
       
   769     _LIT( KDesCEikTwoPictureCommandButton, "~CEikTwoPictureCommandButton() test" );
       
   770     AssertTrueL( ETrue, KDesCEikTwoPictureCommandButton );
       
   771     }
       
   772 
       
   773 void CBCTestButtonsCase::TestSetTwoPicturesL()
       
   774     {
       
   775     CEikTwoPictureCommandButton* twoPictureCommandButton = SetupTwoPictureCmdL();
       
   776 
       
   777     _LIT( KButtonIconFile2, "z:\\resource\\apps\\BCTestButtons.mbm" );
       
   778     TInt normal2 = 1;
       
   779     CFbsBitmap * normalBitmap2 = AknIconUtils::CreateIconL( KButtonIconFile2, normal2 );
       
   780     CleanupStack::PushL( normalBitmap2 );
       
   781 
       
   782     twoPictureCommandButton->SetTwoPicturesL( normalBitmap2, NULL, NULL, NULL);
       
   783     _LIT( KSetTwoPicturesL, "SetTwoPicturesL test" );
       
   784     AssertTrueL( ETrue, KSetTwoPicturesL );
       
   785 
       
   786     CleanupStack::Pop(normalBitmap2);
       
   787     TeardownTwoPictureCmdL( twoPictureCommandButton );
       
   788     }
       
   789 
       
   790 // ---------------------------------------------------------------------------
       
   791 // CBCTestButtonsCase::TestCEikTwoPictureCmd
       
   792 // ---------------------------------------------------------------------------
       
   793 //
       
   794 void CBCTestButtonsCase::TestCEikTwoPictureCmdL()
       
   795     {
       
   796     // Test some API for class CEikTwoPictureCommandButton
       
   797     CEikTwoPictureCommandButton* twoPictureCommandButton = SetupTwoPictureCmdL();
       
   798 
       
   799     TestSetTwoPicturesL();
       
   800 
       
   801     TBool isSecondPictureOwnedExternally =
       
   802         twoPictureCommandButton->IsSecondPictureOwnedExternally();
       
   803     _LIT( KIsSecondPictureOwnedExternally, "IsSecondPictureOwnedExternally test" );
       
   804     AssertTrueL( ETrue, KIsSecondPictureOwnedExternally );
       
   805 
       
   806     CEikImage* eikImage =  twoPictureCommandButton->Picture();
       
   807     _LIT( KPicture2, "Picture test" );
       
   808     AssertTrueL( ETrue, KPicture2 );
       
   809 
       
   810     _LIT( KText2,"xxxxxxxxxx" );
       
   811     twoPictureCommandButton->SetTextL( KText2 );
       
   812     _LIT( KSetTextL2, "SetTextL For CEikTwoPictureCommandButton test" );
       
   813     AssertTrueL( ETrue, KSetTextL2 );
       
   814 
       
   815     _LIT( KButtonIconFile3, "z:\\resource\\apps\\BCTestButtons.mbm" );
       
   816     TInt normal3 = 1;
       
   817     CFbsBitmap * normalBitmap3 = AknIconUtils::CreateIconL( KButtonIconFile3, normal3 );
       
   818     CleanupStack::PushL( normalBitmap3 );
       
   819 
       
   820     twoPictureCommandButton->SetSecondPicture( normalBitmap3, NULL );
       
   821     _LIT( KSetSecondPicture3, "SetSecondPicture test" );
       
   822     AssertTrueL( ETrue, KSetSecondPicture3 );
       
   823 
       
   824     CleanupStack::Pop(normalBitmap3);
       
   825 
       
   826     twoPictureCommandButton->SetSecondPictureOwnedExternally( EFalse );
       
   827     _LIT( KSetSecondPictureOwnedExternally, "SetSecondPictureOwnedExternally test" );
       
   828     AssertTrueL( ETrue, KSetSecondPictureOwnedExternally );
       
   829 
       
   830     twoPictureCommandButton->ActivateL();
       
   831     _LIT( KActivateL1, "ActivateL test" );
       
   832     AssertTrueL( ETrue, KActivateL1 );
       
   833 
       
   834     TPointerEvent pointerEvent2;
       
   835     pointerEvent2.iType = TPointerEvent::EButton1Up;
       
   836     twoPictureCommandButton->HandlePointerEventL( pointerEvent2 );
       
   837     _LIT( KHandlePointerEventL2,
       
   838         "HandlePointerEventL For CEikTwoPictureCommandButton test" );
       
   839     AssertTrueL( ETrue, KHandlePointerEventL2 );
       
   840 
       
   841     CBCTestTwoPicture* twoPicture = new( ELeave ) CBCTestTwoPicture();
       
   842     CleanupStack::PushL( twoPicture );
       
   843     TResourceReader reader;
       
   844     iEnv->CreateResourceReaderLC( reader, R_BCTESTBUTTONS_PICMBUT );
       
   845     twoPicture->ConstructFromResourceL( reader );
       
   846     CleanupStack::PopAndDestroy(); // reader
       
   847 
       
   848     _LIT( KStreamName2, "c:\\BCTestLog\\buttontest.txt" );
       
   849     RFs& tempServer2 = iEnv->FsSession();
       
   850     tempServer2.Delete( KStreamName2 );
       
   851     RFileWriteStream fWrite2;
       
   852     User::LeaveIfError( fWrite2.Create( tempServer2,
       
   853         KStreamName2, EFileWrite ) );
       
   854     CleanupClosePushL( fWrite2 );
       
   855     twoPicture->WriteInternalStateL( fWrite2 );
       
   856     CleanupStack::PopAndDestroy( &fWrite2 );
       
   857     CleanupStack::PopAndDestroy( twoPicture );
       
   858     _LIT( KWriteInternalStateL2, "WriteInternalStateL test" );
       
   859     AssertTrueL( ETrue, KWriteInternalStateL2 );
       
   860 
       
   861     TeardownTwoPictureCmdL( twoPictureCommandButton );
       
   862     
       
   863     // Test private APIs
       
   864     CCoeControl* test = new( ELeave ) CEikTwoPictureCommandButton();
       
   865     CleanupStack::PushL( test );
       
   866     test->DrawNow();
       
   867     _LIT( KDraw, "Draw for CEikTwoPictureCommandButton test" );
       
   868     AssertTrueL( ETrue, KDraw );
       
   869     CleanupStack::PopAndDestroy( test );
       
   870     
       
   871     
       
   872     }
       
   873 
       
   874 CEikInverterCommandButton* CBCTestButtonsCase::SetupInverterCmdL()
       
   875     {
       
   876     //1. just new
       
   877     CEikInverterCommandButton* inverterCommandButton = new( ELeave ) CEikInverterCommandButton();
       
   878     CleanupStack::PushL( inverterCommandButton );
       
   879     _LIT( KCEikInverterCommandButton, "CEikInverterCommandButton test" );
       
   880     AssertTrueL( ETrue, KCEikInverterCommandButton );
       
   881 
       
   882     return inverterCommandButton;
       
   883     }
       
   884 
       
   885 void CBCTestButtonsCase::TeardownInverterCmdL(CEikInverterCommandButton* aBtn)
       
   886 
       
   887     {
       
   888     CleanupStack::PopAndDestroy( aBtn );
       
   889     _LIT( KDesCEikInverterCommandButton, "~CEikInverterCommandButton() test" );
       
   890     AssertTrueL( ETrue, KDesCEikInverterCommandButton );
       
   891     }
       
   892 
       
   893 // ---------------------------------------------------------------------------
       
   894 // CBCTestButtonsCase::TestCEikInverterCmdL
       
   895 // ---------------------------------------------------------------------------
       
   896 //
       
   897 void CBCTestButtonsCase::TestCEikInverterCmdL()
       
   898     {
       
   899     // Test some API for class CEikInverterCommandButton
       
   900     CEikInverterCommandButton* inverterCommandButton = SetupInverterCmdL();
       
   901 
       
   902     TPointerEvent pointerEvent3;
       
   903     pointerEvent3.iType = TPointerEvent::EButton1Up;
       
   904     inverterCommandButton->HandlePointerEventL( pointerEvent3 );
       
   905     _LIT( KHandlePointerEventL3, "HandlePointerEventL For CEikInverterCommandButton test" );
       
   906     AssertTrueL( ETrue, KHandlePointerEventL3 );
       
   907 
       
   908     CBCTestInverterCmdButton* inverterBtn = new( ELeave ) CBCTestInverterCmdButton();
       
   909     CleanupStack::PushL( inverterBtn );
       
   910     TResourceReader reader;
       
   911     iEnv->CreateResourceReaderLC( reader, R_BCTESTBUTTONS_CMBUT );
       
   912     inverterBtn->ConstructFromResourceL( reader );
       
   913     CleanupStack::PopAndDestroy(); // reader
       
   914 
       
   915     _LIT( KStreamName2, "c:\\BCTestLog\\buttontest.txt" );
       
   916     RFs& tempServer2 = iEnv->FsSession();
       
   917     tempServer2.Delete( KStreamName2 );
       
   918     RFileWriteStream fWrite2;
       
   919     User::LeaveIfError( fWrite2.Create( tempServer2,
       
   920         KStreamName2, EFileWrite ) );
       
   921     CleanupClosePushL( fWrite2 );
       
   922     inverterBtn->WriteInternalStateL( fWrite2 );
       
   923     CleanupStack::PopAndDestroy( &fWrite2 );
       
   924     //WriteInternalStateL(RWriteStream& aWriteStream)
       
   925     CleanupStack::PopAndDestroy( inverterBtn );
       
   926     _LIT( KWriteInternalStateL3, "WriteInternalStateL test" );
       
   927     AssertTrueL( ETrue, KWriteInternalStateL3 );
       
   928 
       
   929     TeardownInverterCmdL( inverterCommandButton );
       
   930     }
       
   931 
       
   932 CEikTextButton* CBCTestButtonsCase::SetupTextBtnL()
       
   933     {
       
   934     //1. just new
       
   935     CEikTextButton* textButton = new( ELeave ) CEikTextButton();
       
   936     CleanupStack::PushL( textButton );
       
   937     _LIT( KCEikTextButton, "CEikTextButton test" );
       
   938     AssertTrueL( ETrue, KCEikTextButton );
       
   939     //2. construct from res
       
   940     TResourceReader reader3;
       
   941     iEnv->CreateResourceReaderLC( reader3, R_BCTESTBUTTONS_TXTBUT );
       
   942     textButton->ConstructFromResourceL( reader3 );
       
   943     _LIT( KConstructFromResourceL3, "ConstructFromResourceL For CEikTextButton test" );
       
   944     AssertTrueL( ETrue, KConstructFromResourceL3 );
       
   945     CleanupStack::PopAndDestroy(); //reader3
       
   946     return textButton;
       
   947     }
       
   948 
       
   949 void CBCTestButtonsCase::TeardownTextBtnL( CEikTextButton* aBtn )
       
   950 
       
   951     {
       
   952     CleanupStack::PopAndDestroy( aBtn );
       
   953     _LIT( KDesCEikTextButton, "~CEikTextButton() test" );
       
   954     AssertTrueL( ETrue, KDesCEikTextButton );
       
   955     }
       
   956 
       
   957 // ---------------------------------------------------------------------------
       
   958 // CBCTestButtonsCase::TestCEikTextBtnL()
       
   959 // ---------------------------------------------------------------------------
       
   960 //
       
   961 void CBCTestButtonsCase::TestCEikTextBtnL()
       
   962     {
       
   963     // Test some API for class CEikTextButton
       
   964     CEikTextButton* textButton = SetupTextBtnL();
       
   965 
       
   966     _LIT( KText3, "xxxxxxxxxxx" );
       
   967     textButton->SetTextL( KText3, CEikCommandButtonBase::EFirst );
       
   968     _LIT( KSetTextL3, "SetTextL For CEikTextButton test" );
       
   969     AssertTrueL( ETrue, KSetTextL3 );
       
   970 
       
   971     CEikLabel* label2 = textButton->Label( CEikCommandButtonBase::EFirst );
       
   972     _LIT( KLabel2, "Label test" );
       
   973     AssertTrueL( ETrue, KLabel2 );
       
   974 
       
   975     TPointerEvent pointerEvent4;
       
   976     pointerEvent4.iType = TPointerEvent::EButton1Up;
       
   977     textButton->HandlePointerEventL( pointerEvent4 );
       
   978     _LIT( KHandlePointerEventL4, "HandlePointerEventL For CEikTextButton test" );
       
   979     AssertTrueL( ETrue, KHandlePointerEventL4 );
       
   980 
       
   981     TeardownTextBtnL( textButton );
       
   982     }
       
   983 
       
   984 CEikBitmapButton* CBCTestButtonsCase::SetupBitmapBtnL()
       
   985     {
       
   986     //1. just new
       
   987     CEikBitmapButton* bitmapButton = new( ELeave ) CEikBitmapButton();
       
   988     CleanupStack::PushL( bitmapButton );
       
   989     _LIT( KCEikBitmapButton, "CEikBitmapButton test" );
       
   990     AssertTrueL( ETrue, KCEikBitmapButton );
       
   991     //2. construct from res
       
   992     TResourceReader reader4;
       
   993     iEnv->CreateResourceReaderLC( reader4, R_BCTESTBUTTONS_BMPBUT );
       
   994     bitmapButton->ConstructFromResourceL( reader4 );
       
   995     _LIT( KConstructFromResourceL4, "ConstructFromResourceL For CEikBitmapButton test" );
       
   996     AssertTrueL( ETrue, KConstructFromResourceL4 );
       
   997     CleanupStack::PopAndDestroy();//reader4
       
   998 
       
   999     return bitmapButton;
       
  1000     }
       
  1001 void CBCTestButtonsCase::TeardownBitmapBtnL( CEikBitmapButton* aBtn )
       
  1002     {
       
  1003     CleanupStack::PopAndDestroy( aBtn );
       
  1004     _LIT( KDesCEikBitmapButton, "~CEikBitmapButton test" );
       
  1005     AssertTrueL( ETrue, KDesCEikBitmapButton );
       
  1006     }
       
  1007 // ---------------------------------------------------------------------------
       
  1008 // CBCTestButtonsCase::TestCEikBitmapBtnL
       
  1009 // ---------------------------------------------------------------------------
       
  1010 //
       
  1011 void CBCTestButtonsCase::TestCEikBitmapBtnL()
       
  1012     {
       
  1013     CEikBitmapButton* bitmapButton = SetupBitmapBtnL();
       
  1014 
       
  1015     // Test some API for class CEikBitmapButton
       
  1016     _LIT( KButtonIconFile3, "z:\\resource\\apps\\BCTestButtons.mbm" );
       
  1017     TInt normal3 = 1;
       
  1018     CFbsBitmap * normalBitmap3 = AknIconUtils::CreateIconL(
       
  1019         KButtonIconFile3, normal3 );
       
  1020     CleanupStack::PushL( normalBitmap3 );
       
  1021 
       
  1022     bitmapButton->SetPictureL( normalBitmap3, NULL,
       
  1023         CEikCommandButtonBase::EFirst );
       
  1024     _LIT( KSetPictureL3, "SetPictureL for CEikBitmapButton test" );
       
  1025     AssertTrueL( ETrue, KSetPictureL3 );
       
  1026 
       
  1027     CleanupStack::Pop( normalBitmap3 );
       
  1028 
       
  1029     bitmapButton->SetPictureFromFileL( KButtonIconFile3,
       
  1030         EMbmBctestbuttonsSampleicon, EMbmBctestbuttonsSampleiconmask,
       
  1031         CEikCommandButtonBase::ESecond );
       
  1032     _LIT( KBitmapBtn1, "CEikBitmapButton::SetPictureFromFileL" );
       
  1033     AssertTrueL( ETrue, KBitmapBtn1 );
       
  1034 
       
  1035     CEikImage* picture = bitmapButton->Picture( CEikCommandButtonBase::EFirst );
       
  1036     _LIT( KPicture1, "Picture For CEikTextButton test" );
       
  1037     AssertTrueL( ETrue, KPicture1 );
       
  1038 
       
  1039 
       
  1040     TPointerEvent pointerEvent5;
       
  1041     pointerEvent5.iType = TPointerEvent::EButton1Up;
       
  1042     bitmapButton->HandlePointerEventL( pointerEvent5 );
       
  1043     _LIT( KHandlePointerEventL5, "HandlePointerEventL For CEikBitmapButton test" );
       
  1044     AssertTrueL( ETrue, KHandlePointerEventL5 );
       
  1045 
       
  1046     TeardownBitmapBtnL( bitmapButton );
       
  1047     }
       
  1048 
       
  1049 CEikLabeledButton* CBCTestButtonsCase::SetupLabeledBtnLC()
       
  1050     {
       
  1051     //1. just new
       
  1052     CEikLabeledButton* labeledButton = new( ELeave ) CEikLabeledButton();
       
  1053     CleanupStack::PushL( labeledButton );
       
  1054     _LIT( KCEikLabeledButton, "CEikLabeledButton test" );
       
  1055     AssertTrueL( ETrue, KCEikLabeledButton );
       
  1056 
       
  1057     //2. construct from res
       
  1058     TInt hotKeyCode = 1;
       
  1059     TInt flags = 1;
       
  1060     CEikCommandButton* commandButton = new( ELeave )CEikCommandButton();
       
  1061     CleanupStack::PushL( commandButton );
       
  1062     labeledButton->ConstructL( commandButton, hotKeyCode, flags );
       
  1063     _LIT( KConstructL, "ConstructL For CEikLabelButton test" );
       
  1064     AssertTrueL( ETrue, KConstructL );
       
  1065     CleanupStack::Pop( commandButton );
       
  1066     CleanupStack::PopAndDestroy( labeledButton );
       
  1067 
       
  1068     labeledButton = new( ELeave ) CEikLabeledButton();
       
  1069     CleanupStack::PushL( labeledButton );
       
  1070     TResourceReader reader5;
       
  1071     iEnv->CreateResourceReaderLC( reader5, R_BCTESTBUTTONS_LBBUT );
       
  1072     labeledButton->ConstructFromResourceL( reader5 );
       
  1073     _LIT( KConstructFromResourceL5, "ConstructFromResourceL For CEikLabeledButton test" );
       
  1074     AssertTrueL( ETrue, KConstructFromResourceL5 );
       
  1075     CleanupStack::PopAndDestroy(); //reader5
       
  1076 
       
  1077     return labeledButton;
       
  1078     }
       
  1079 
       
  1080 void CBCTestButtonsCase::TeardownLabeledBtnL( CEikLabeledButton* aBtn )
       
  1081     {
       
  1082     CleanupStack::PopAndDestroy( aBtn );
       
  1083     _LIT( KDesCEikLabeledButton, "~CEikLabeledButton test" );
       
  1084     AssertTrueL( ETrue, KDesCEikLabeledButton );
       
  1085     }
       
  1086 
       
  1087 // ---------------------------------------------------------------------------
       
  1088 // CBCTestButtonsCase::TestCEikLabeledBtnL
       
  1089 // ---------------------------------------------------------------------------
       
  1090 //
       
  1091 void CBCTestButtonsCase::TestCEikLabeledBtnL()
       
  1092     {
       
  1093     // Test some API for class CEikLabeledButton
       
  1094     CEikLabeledButton* labeledButton = SetupLabeledBtnLC();
       
  1095 
       
  1096     CEikCommandButtonBase* commandButtonBase = labeledButton->Button();
       
  1097     _LIT( KButton, "Button test" );
       
  1098     AssertTrueL( ETrue, KButton );
       
  1099 
       
  1100     CEikLabel* label3 = labeledButton->Label();
       
  1101     _LIT( KLabel3, "Label For CEikLabeledButton test" );
       
  1102     AssertTrueL( ETrue, KLabel3 );
       
  1103 
       
  1104     TInt hotKeyCode2 = labeledButton->HotKeyCode();
       
  1105     _LIT( KHotKeyCode2, "HotKeyCode For CEikLabeledButton test" );
       
  1106     AssertTrueL( ETrue, KHotKeyCode2 );
       
  1107 
       
  1108     TBool showsHotKey = labeledButton->ShowsHotKey();
       
  1109     _LIT( KShowsHotKey, "ShowsHotKey test" );
       
  1110     AssertTrueL( ETrue, KShowsHotKey );
       
  1111 
       
  1112     TBool plainHotKey = labeledButton->PlainHotKey();
       
  1113     _LIT( KPlainHotKey, "PlainHotKey test" );
       
  1114     AssertTrueL( ETrue, KPlainHotKey );
       
  1115 
       
  1116     labeledButton->Animate();
       
  1117     _LIT( KAnimate1, "Animate test" );
       
  1118     AssertTrueL( ETrue, KAnimate1 );
       
  1119 
       
  1120     labeledButton->UpdateHotKey( EAknSoftkeyOk, CEikLabeledButton::EShowHotKey );
       
  1121     _LIT( KUpdateHotKey2, "UpdateHotKeytest" );
       
  1122     AssertTrueL( ETrue, KUpdateHotKey2 );
       
  1123 
       
  1124     TKeyEvent keyEvent2 = { EKeyPause, EStdKeySpace, 0, 0  };
       
  1125     TKeyResponse keyResponse = labeledButton->OfferKeyEventL( keyEvent2, EEventNull );
       
  1126     _LIT( KOfferKeyEventL2, "OfferKeyEventL For CeikLabeledButton test" );
       
  1127     AssertTrueL( ETrue, KOfferKeyEventL2 );
       
  1128 
       
  1129     TSize size2 = labeledButton->MinimumSize();
       
  1130     _LIT( KMinimumSize2, "MinimumSize test" );
       
  1131     AssertTrueL( ETrue, KMinimumSize2 );
       
  1132 
       
  1133     labeledButton->SetContainerWindowL( *iContainer );
       
  1134     _LIT( KSetContainerWindowL, "SetContainerWindowL test" );
       
  1135     AssertTrueL( ETrue, KSetContainerWindowL );
       
  1136 
       
  1137     labeledButton->SetDimmed( ETrue );
       
  1138     _LIT( KSetDimmed, "SetDimmed test" );
       
  1139     AssertTrueL( ETrue, KSetDimmed );
       
  1140 
       
  1141     CArrayFixFlat<TCoeColorUse>* colorUseList = new( ELeave ) CArrayFixFlat<TCoeColorUse>( 1 );
       
  1142     TCoeColorUse colorUse;
       
  1143     colorUseList->AppendL( colorUse );
       
  1144     labeledButton->GetColorUseListL( *colorUseList );
       
  1145     CleanupStack::PushL( colorUseList );
       
  1146     _LIT( KGetColorUseListL, "GetColorUseListL test" );
       
  1147     AssertTrueL( ETrue, KGetColorUseListL );
       
  1148     CleanupStack::PopAndDestroy( colorUseList );
       
  1149 
       
  1150     TInt type = 1;
       
  1151     labeledButton->HandleResourceChange( type );
       
  1152     _LIT( KHandleResourceChange, "HandleResourceChange test" );
       
  1153     AssertTrueL( ETrue, KHandleResourceChange );
       
  1154 
       
  1155     TCoeInputCapabilities inputCapablilities = labeledButton->InputCapabilities();
       
  1156     _LIT( KInputCapabilities, "InputCapabilities test" );
       
  1157     AssertTrueL( ETrue, KInputCapabilities );
       
  1158 
       
  1159 
       
  1160     TPointerEvent pointerEvent6;
       
  1161     pointerEvent6.iType = TPointerEvent::EButton1Up;
       
  1162     labeledButton->HandlePointerEventL( pointerEvent6 );
       
  1163     _LIT( KHandlePointerEventL6, "HandlePointerEventL test" );
       
  1164     AssertTrueL( ETrue, KHandlePointerEventL6 );
       
  1165 
       
  1166     TeardownLabeledBtnL( labeledButton );
       
  1167     }
       
  1168 
       
  1169 
       
  1170 // ---------------------------------------------------------------------------
       
  1171 // CBCTestButtonsCase::TestMnbutAndBtgpsAndBtgrpL
       
  1172 // ---------------------------------------------------------------------------
       
  1173 //
       
  1174 void CBCTestButtonsCase::TestMnbutAndBtgpsAndBtgrpL()
       
  1175     {
       
  1176     // Test some API for class CEikMenuButton
       
  1177     CBCTestMenuButton* menuButton = new( ELeave ) CBCTestMenuButton();
       
  1178     CleanupStack::PushL( menuButton );
       
  1179     _LIT( KCEikMenuButton, "CEikMenuButton test" );
       
  1180     AssertTrueL( ETrue, KCEikMenuButton );
       
  1181 
       
  1182     menuButton->SetContainerWindowL( *iContainer );
       
  1183 
       
  1184     TResourceReader reader6;
       
  1185     iEnv->CreateResourceReaderLC( reader6, R_BCTESTBUTTONS_MNBUT );
       
  1186     menuButton->ConstructFromResourceL( reader6 );
       
  1187     _LIT( KConstructFromResourceL6, "ConstructFromResourceL For CEikMenuButton test" );
       
  1188     AssertTrueL( ETrue, KConstructFromResourceL6 );
       
  1189     CleanupStack::PopAndDestroy(); //reader6
       
  1190 
       
  1191     menuButton->SetMenuPaneId( R_BCTESTBUTTONS_MENU );
       
  1192     _LIT( KSetMenuPaneId, "SetMenuPaneId test" );
       
  1193     AssertTrueL( ETrue, KSetMenuPaneId );
       
  1194 
       
  1195     TBCTestMenuObserver menuObserver;
       
  1196     menuButton->LaunchPopupMenuL( &menuObserver );
       
  1197     _LIT( KLaunchPopupMenuL, "LaunchPopupMenuL test" );
       
  1198     AssertTrueL( ETrue, KLaunchPopupMenuL );
       
  1199 
       
  1200     menuButton->Animate();
       
  1201     _LIT( KAnimate2, "Animatet For CEikMenuButton test" );
       
  1202     AssertTrueL( ETrue, KAnimate2 );
       
  1203 
       
  1204     RFs& tempServer = iEnv->FsSession();
       
  1205     tempServer.Delete( KStreamName );
       
  1206     RFileWriteStream fWrite;
       
  1207     User::LeaveIfError( fWrite.Create( tempServer,
       
  1208         KStreamName, EFileWrite ) );
       
  1209     CleanupClosePushL( fWrite );
       
  1210     menuButton->WriteInternalStateL( fWrite );
       
  1211     CleanupStack::PopAndDestroy( &fWrite );
       
  1212     tempServer.Delete( KStreamName );
       
  1213     _LIT( KMenuWriteInternal, "CEikMenuButton::WriteInternalStateL" );
       
  1214     AssertTrueL( ETrue, KMenuWriteInternal );
       
  1215 
       
  1216     TPointerEvent pointerEvent7;
       
  1217     pointerEvent7.iType = TPointerEvent::EButton1Up;
       
  1218     menuButton->HandlePointerEventL( pointerEvent7 );
       
  1219     _LIT( KHandlePointerEventL7, "HandlePointerEventL For CEikMenuButton test" );
       
  1220     AssertTrueL( ETrue, KHandlePointerEventL7 );
       
  1221 
       
  1222     CleanupStack::PopAndDestroy( menuButton );
       
  1223     _LIT( KDesCEikMenuButton, "~CEikMenuButton() test" );
       
  1224     AssertTrueL( ETrue, KDesCEikMenuButton );
       
  1225 
       
  1226     // Test some API for class CEikButtonGroupStack
       
  1227     TSize minimumSize3 = CEikButtonGroupStack::MinimumSize();
       
  1228      _LIT( KMinimumSize, "MinimumSizetest For CEikMenuButton" );
       
  1229     AssertTrueL( ETrue, KMinimumSize );
       
  1230     }
       
  1231 
       
  1232 void CBCTestButtonsCase::TestCbaButtonL()
       
  1233     {
       
  1234     
       
  1235     _LIT( KSetButtonGroupFlags, " SetButtonGroupFlags " );
       
  1236     _LIT( KSetSkinBackgroundId, " SetSkinBackgroundId " );
       
  1237     _LIT( KOfferCommandListL, " OfferCommandListL( array )" );
       
  1238     _LIT( KOfferCommandListResL, " OfferCommandListL( resource ) " );
       
  1239     _LIT( KIsCommandInGroup, " IsCommandInGroup " );
       
  1240     _LIT( KReplaceCommand, " ReplaceCommand " );
       
  1241     _LIT( KHandlePointerEventL, "HandlePointerEventL" );
       
  1242     
       
  1243     TInt resourceid = R_BCTESTBUTTONS_MENU;
       
  1244     TBCTestCommandObserver commandobserver;
       
  1245     
       
  1246     RWindowGroup& parentwg = iEnv->RootWin();
       
  1247     TUint flags = 0;
       
  1248 
       
  1249     EikButtonGroupFactory::TCreationData creationData(
       
  1250         CEikButtonGroupContainer::EView, &commandobserver,
       
  1251         resourceid, &parentwg, flags, CEikButtonGroupContainer::EVertical );
       
  1252      
       
  1253     TInt toolbarresid = R_BCTESTBUTTONS_TOOLBAR;
       
  1254     
       
  1255     CEikButtonGroupContainer* buttongroup1 = CEikButtonGroupContainer::NewL( 
       
  1256         CEikButtonGroupContainer::EView, CEikButtonGroupContainer::EVertical, 
       
  1257         &commandobserver, toolbarresid, parentwg,
       
  1258         CEikButtonGroupContainer::EAddToStack );
       
  1259     CleanupStack::PushL( buttongroup1 );
       
  1260     CleanupStack::PopAndDestroy( buttongroup1 );
       
  1261 
       
  1262     CEikButtonGroupContainer* buttongroup = CEikButtonGroupContainer::Current();
       
  1263     
       
  1264     CEikCba *eikcba = static_cast<CEikCba*>( buttongroup->ButtonGroup() );
       
  1265     
       
  1266     eikcba->SetButtonGroupFlags( 0 );
       
  1267     AssertTrueL( ETrue, KSetButtonGroupFlags );
       
  1268     
       
  1269     eikcba->SetSkinBackgroundId( KAknsIIDQsnBgAreaControlIdle );
       
  1270     AssertTrueL( ETrue, KSetSkinBackgroundId );
       
  1271     
       
  1272     TInt toolbarresourceid = R_BCTESTBUTTONS_CBA_OPTIONS_NEXT;
       
  1273     TInt commandid = EAknSoftkeyOptions;
       
  1274     TInt res;
       
  1275     
       
  1276     RArray<TInt> arr;
       
  1277     arr.Append( commandid );
       
  1278     TRAP( res, eikcba->OfferCommandListL( arr ) );
       
  1279     AssertTrueL( ETrue, KOfferCommandListL );
       
  1280     arr.Close();
       
  1281     
       
  1282     eikcba->IsCommandInGroup( commandid );
       
  1283     AssertTrueL( ETrue, KIsCommandInGroup );
       
  1284     eikcba->ReplaceCommand( commandid, toolbarresourceid );
       
  1285     AssertTrueL( ETrue, KReplaceCommand );
       
  1286    
       
  1287     TRAP( res, eikcba->OfferCommandListL( commandid ) );
       
  1288     AssertTrueL( ETrue, KOfferCommandListResL );
       
  1289     
       
  1290     CEikCbaButton* cbabutton = (CEikCbaButton*) buttongroup->ControlOrNull(commandid);
       
  1291     TPointerEvent pevent;
       
  1292     pevent.iType = TPointerEvent::EButton1Up; 
       
  1293     TRAP( res, cbabutton->HandlePointerEventL( pevent ) );
       
  1294     AssertTrueL( ETrue, KHandlePointerEventL );
       
  1295     }
       
  1296 // --------------------------------------------------------------------------
       
  1297 // TBCTestMenuObserver::SetEmphasis
       
  1298 // ---------------------------------------------------------------------------
       
  1299 //
       
  1300 void TBCTestMenuObserver::SetEmphasis( CCoeControl*, TBool )
       
  1301     {
       
  1302     }
       
  1303 // --------------------------------------------------------------------------
       
  1304 // TBCTestMenuObserver::ProcessCommandL
       
  1305 // ---------------------------------------------------------------------------
       
  1306 //
       
  1307 void TBCTestMenuObserver::ProcessCommandL( TInt )
       
  1308     {
       
  1309 
       
  1310     }
       
  1311 
       
  1312 
       
  1313 
       
  1314 
       
  1315 
       
  1316 
       
  1317