uifw/AvKon/tsrc/bc/S60_SDKMCL/bctestsingleclick/src/bctestsingleclickcase.cpp
branchRCL_3
changeset 16 71dd06cfe933
parent 0 2f259fa3e83a
equal deleted inserted replaced
15:08e69e956a8c 16:71dd06cfe933
    16 */
    16 */
    17 
    17 
    18 #include <w32std.h>
    18 #include <w32std.h>
    19 #include <coecntrl.h>
    19 #include <coecntrl.h>
    20 #include <aknitemactionmenu.h>
    20 #include <aknitemactionmenu.h>
    21 #ifdef RD_TOUCH2
       
    22 #include <aknViewAppUi.h>
    21 #include <aknViewAppUi.h>
    23 #include <aknview.h>
    22 #include <aknview.h>
    24 #else
       
    25 #include <aknappui.h>
       
    26 #endif // RD_TOUCH2
       
    27 #include <eikmenup.h>
    23 #include <eikmenup.h>
    28 #include <eikmenub.h>
    24 #include <eikmenub.h>
    29 #include <avkon.hrh>
    25 #include <avkon.hrh>
    30 #include <eikfrlb.h>
    26 #include <eikfrlb.h>
    31 #include <bctestsingleclick.rsg>
    27 #include <bctestsingleclick.rsg>
    32 #ifdef RD_TOUCH2
    28 #include "aknitemactionmenuregister.h"
    33 #include <aknitemactionmenuregister.h>
       
    34 #endif // RD_TOUCH2
       
    35 
    29 
    36 #include "bctestsingleclickcase.h"
    30 #include "bctestsingleclickcase.h"
    37 #include "bctestsingleclickcontainer.h"
    31 #include "bctestsingleclickcontainer.h"
    38 #include "bctestsingleclick.hrh"
    32 #include "bctestsingleclick.hrh"
    39 
    33 
   172     _LIT( KSetConstructingMenuBarOwnerL, 
   166     _LIT( KSetConstructingMenuBarOwnerL, 
   173         "AknItemActionMenuRegister::SetConstructingMenuBarOwnerL" );
   167         "AknItemActionMenuRegister::SetConstructingMenuBarOwnerL" );
   174     _LIT( KIsSingleClickCompatible, 
   168     _LIT( KIsSingleClickCompatible, 
   175         "CAknAppUiBase::IsSingleClickCompatible()" );    
   169         "CAknAppUiBase::IsSingleClickCompatible()" );    
   176     _LIT( KRegisterCollectionL, "CAknItemActionMenu::RegisterCollectionL" ); 
   170     _LIT( KRegisterCollectionL, "CAknItemActionMenu::RegisterCollectionL" ); 
       
   171     _LIT( KRegisterCollection2L, 
       
   172             "CAknItemActionMenu::RegisterCollectionL( MAknCollection, MObjectProvider" ); 
   177     _LIT( KInitMenuL, "CAknItemActionMenu::InitMenuL" ); 
   173     _LIT( KInitMenuL, "CAknItemActionMenu::InitMenuL" ); 
   178     _LIT( KShowMenuL, "CAknItemActionMenu::ShowMenuL" ); 
   174     _LIT( KShowMenuL, "CAknItemActionMenu::ShowMenuL" ); 
   179     _LIT( KRemoveCollection, "CAknItemActionMenu::RemoveCollection" ); 
   175     _LIT( KRemoveCollection, "CAknItemActionMenu::RemoveCollection" ); 
   180     _LIT( KItemSpecificCommandsEnabled, 
   176     _LIT( KItemSpecificCommandsEnabled, 
   181          "CEikMenuBar::ItemSpecificCommandsEnabled()" );
   177          "CEikMenuBar::ItemSpecificCommandsEnabled()" );
   182     _LIT( KSetItemSpecific, "CEikMenuPane::SetItemSpecific()" );    
   178     _LIT( KSetItemSpecific, "CEikMenuPane::SetItemSpecific()" );    
   183 #ifdef RD_TOUCH2    
       
   184     _LIT( KSetOverridingMenuBarOwnerL, 
   179     _LIT( KSetOverridingMenuBarOwnerL, 
   185         "AknItemActionMenuRegister::SetOverridingMenuBarOwnerL" );
   180         "AknItemActionMenuRegister::SetOverridingMenuBarOwnerL" );
   186     _LIT( KCollectionChanged, "CAknItemActionMenu::CollectionChanged" );
   181     _LIT( KCollectionChanged, "CAknItemActionMenu::CollectionChanged" );
   187 #endif // RD_TOUCH2
       
   188 
   182 
   189     //AknItemActionMenuRegister::SetConstructingMenuBarOwnerL is invoked in 
   183     //AknItemActionMenuRegister::SetConstructingMenuBarOwnerL is invoked in 
   190     //CAknView::BaseConstructL().
   184     //CAknView::BaseConstructL().
   191     AssertTrueL( ETrue, KSetConstructingMenuBarOwnerL );
   185     AssertTrueL( ETrue, KSetConstructingMenuBarOwnerL );
   192 
   186 
   193 #ifdef RD_TOUCH2
       
   194     CCoeControl* dummy = new ( ELeave ) CCoeControl;
   187     CCoeControl* dummy = new ( ELeave ) CCoeControl;
   195     CleanupStack::PushL( dummy );
   188     CleanupStack::PushL( dummy );
   196     AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( dummy );
   189     AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( dummy );
   197     AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( NULL );
   190     AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( NULL );
   198     AssertTrueL( ETrue, KSetOverridingMenuBarOwnerL );
   191     AssertTrueL( ETrue, KSetOverridingMenuBarOwnerL );
   199     CleanupStack::PopAndDestroy();
   192     CleanupStack::PopAndDestroy();
   200 #endif // RD_TOUCH2
       
   201     
   193     
   202     TBool isSingleClick = iAvkonAppUiBase->IsSingleClickCompatible();
   194     TBool isSingleClick = iAvkonAppUiBase->IsSingleClickCompatible();
   203     AssertTrueL( isSingleClick, KIsSingleClickCompatible );
   195     AssertTrueL( isSingleClick, KIsSingleClickCompatible );
   204     
   196     
   205     CAknItemActionMenu* aknItemActionMenu = 
   197     CAknItemActionMenu* aknItemActionMenu = 
   206         CAknItemActionMenu::RegisterCollectionL( *this );
   198         CAknItemActionMenu::RegisterCollectionL( *this );
   207     AssertTrueL( ETrue, KRegisterCollectionL );
   199     AssertTrueL( ETrue, KRegisterCollectionL );
       
   200 
   208     if ( aknItemActionMenu )
   201     if ( aknItemActionMenu )
   209         {        
   202         {        
   210         aknItemActionMenu->InitMenuL();
   203         aknItemActionMenu->InitMenuL();
   211         AssertTrueL( ETrue, KInitMenuL );
   204         AssertTrueL( ETrue, KInitMenuL );
   212         
   205         
   213         TPoint p( 10, 10 );
   206         TPoint p( 10, 10 );
   214         aknItemActionMenu->ShowMenuL( p );
   207         aknItemActionMenu->ShowMenuL( p );
   215         AssertTrueL( ETrue, KShowMenuL );
   208         AssertTrueL( ETrue, KShowMenuL );
   216         
   209         
   217 #ifdef RD_TOUCH2
       
   218         aknItemActionMenu->CollectionChanged( *this );
   210         aknItemActionMenu->CollectionChanged( *this );
   219         AssertTrueL( ETrue, KCollectionChanged );
   211         AssertTrueL( ETrue, KCollectionChanged );
   220 #endif // RD_TOUCH2
       
   221 
   212 
   222         aknItemActionMenu->RemoveCollection( *this );
   213         aknItemActionMenu->RemoveCollection( *this );
   223         AssertTrueL( ETrue, KRemoveCollection );
   214         AssertTrueL( ETrue, KRemoveCollection );
   224         }
   215         }
   225     
   216 
   226 #ifdef RD_TOUCH2
   217     CAknItemActionMenu* aknItemActionMenu2 = 
       
   218         CAknItemActionMenu::RegisterCollectionL( *this, this );
       
   219     AssertTrueL( ETrue, KRegisterCollection2L );
       
   220 
       
   221     if ( aknItemActionMenu2 )
       
   222         {
       
   223         aknItemActionMenu2->RemoveCollection( *this );
       
   224         }
       
   225 
       
   226     
   227     TVwsViewId uid;
   227     TVwsViewId uid;
   228     
   228     
   229     iAvkonViewAppUi->GetActiveViewId( uid );
   229     iAvkonViewAppUi->GetActiveViewId( uid );
   230     CEikMenuBar* menuBar = iAvkonViewAppUi->View( uid.iViewUid )->MenuBar();
   230     CEikMenuBar* menuBar = iAvkonViewAppUi->View( uid.iViewUid )->MenuBar();
   231 #else
       
   232     CEikMenuBar* menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar();
       
   233 #endif // RD_TOUCH2
       
   234     CEikMenuPane* menuPane = NULL;
   231     CEikMenuPane* menuPane = NULL;
   235     if ( menuBar )
   232     if ( menuBar )
   236         {
   233         {
   237         menuBar->ItemSpecificCommandsEnabled();
   234         menuBar->ItemSpecificCommandsEnabled();
   238         AssertTrueL( ETrue, KItemSpecificCommandsEnabled );
   235         AssertTrueL( ETrue, KItemSpecificCommandsEnabled );
   252 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   253 //    
   250 //    
   254 void CBCTESTSingleClickCase::TestListBoxL()
   251 void CBCTESTSingleClickCase::TestListBoxL()
   255     {
   252     {
   256     _LIT( KDisableSingleClick, "CEikListBox::DisableSingleClick() invoked" );
   253     _LIT( KDisableSingleClick, "CEikListBox::DisableSingleClick() invoked" );
       
   254     _LIT( KIsHighlightEnabled, "CEikListBox::IsHighlightEnabled() invoked" );
   257      
   255      
   258     CEikFormattedCellListBox* listbox = new CEikFormattedCellListBox();
   256     CEikFormattedCellListBox* listbox = new CEikFormattedCellListBox();
   259     CleanupStack::PushL( listbox );
   257     CleanupStack::PushL( listbox );
   260     
   258     
   261     listbox->ConstructL( iContainer, EAknListBoxSelectionList );
   259     listbox->ConstructL( iContainer, EAknListBoxSelectionList );
   269     listbox->Model()->SetItemTextArray( text );
   267     listbox->Model()->SetItemTextArray( text );
   270     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
   268     listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
   271     
   269     
   272     listbox->DisableSingleClick( ETrue );
   270     listbox->DisableSingleClick( ETrue );
   273     AssertTrueL( ETrue, KDisableSingleClick );
   271     AssertTrueL( ETrue, KDisableSingleClick );
   274    
   272 
       
   273     TBool enabled = listbox->IsHighlightEnabled();
       
   274     AssertTrueL( enabled, KIsHighlightEnabled );
       
   275     
   275     CleanupStack::PopAndDestroy( text );
   276     CleanupStack::PopAndDestroy( text );
   276     CleanupStack::PopAndDestroy( listbox );
   277     CleanupStack::PopAndDestroy( listbox );
   277     }
   278     }
   278 
   279 
       
   280 // ---------------------------------------------------------------------------
       
   281 // CBCTESTSingleClickCase::MopSupplyObject
       
   282 // ---------------------------------------------------------------------------
       
   283 //    
       
   284 TTypeUid::Ptr CBCTESTSingleClickCase::MopSupplyObject(TTypeUid /*aId*/)
       
   285     {
       
   286     return TTypeUid::Null();
       
   287     }