classicui_pub/buttons_api/tsrc/src/testsdkbuttonsblockseikbutb.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Test api in eikbutb.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES]
       
    21 #include <stifparser.h>
       
    22 #include <s32mem.h>
       
    23 
       
    24 #include "testsdkbuttons.h"
       
    25 
       
    26 // CONSTANTS
       
    27 const TInt KArraySize = 10;
       
    28 const TInt KHbufSize = 2000;
       
    29 // FORWARD DECLARATIONS
       
    30 /*
       
    31  * ==============================================================================
       
    32  * Test protect functions of CTestButtonBase
       
    33  * ==============================================================================
       
    34  * */
       
    35 class CTestButtonBase : public CEikButtonBase
       
    36     {
       
    37 public:
       
    38     // NewL function
       
    39     static CTestButtonBase* NewL();
       
    40     
       
    41     // Deconstructor
       
    42     ~CTestButtonBase();
       
    43 public:
       
    44 
       
    45     /**
       
    46      * Test protected function DrawState of CEikButtonBase
       
    47      */
       
    48     TInt DoDrawState();
       
    49 
       
    50     /**
       
    51      * Test protected function SetAllowTristate of CEikButtonBase
       
    52      */
       
    53     TInt DoSetAllowTristate();
       
    54 
       
    55     /**
       
    56      * Test protected function CopyDrawStateTo of CEikButtonBase
       
    57      */
       
    58     TInt DoCopyDrawStateTo(CEikButtonBase* aTargetButton);
       
    59     
       
    60 private:
       
    61     /**
       
    62      * 2nd constuctor
       
    63      */
       
    64     void ConstructL();
       
    65     /**
       
    66      * Constructor
       
    67      */
       
    68     CTestButtonBase();
       
    69     
       
    70 private:
       
    71     // Data
       
    72     
       
    73     };
       
    74 // -----------------------------------------------------------------------------
       
    75 // CTestButtonBase::CTestButtonBase
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CTestButtonBase::CTestButtonBase(){}
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CTestButtonBase::~CTestButtonBase
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 CTestButtonBase::~CTestButtonBase(){}
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CTestButtonBase::CTestButtonBase
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CTestButtonBase* CTestButtonBase::NewL()
       
    91     {
       
    92     CTestButtonBase* self = new ( ELeave ) CTestButtonBase;
       
    93     CleanupStack::PushL( self );
       
    94     self->ConstructL();
       
    95     CleanupStack::Pop( self );
       
    96     return self;
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CTestButtonBase::ConstructL
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CTestButtonBase::ConstructL()
       
   104     {
       
   105     // Nothing to do
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CTestButtonBase::DoDrawState
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 TInt CTestButtonBase::DoDrawState()
       
   113     {
       
   114     CEikButtonBase::SetReportOnPointerDown();
       
   115     CEikButtonBase::SetIgnoreNextPointerUp();
       
   116     SetReportOnPointerDown();
       
   117     IsPressed();
       
   118     DrawState();
       
   119     return KErrNone;
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CTestButtonBase::DoSetAllowTristate
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TInt CTestButtonBase::DoSetAllowTristate()
       
   127     {
       
   128     SetAllowTristate();
       
   129     return KErrNone;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CTestButtonBase::DoCopyDrawStateTo
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TInt CTestButtonBase::DoCopyDrawStateTo( CEikButtonBase* aTargetButton )
       
   137     {
       
   138     CopyDrawStateTo( aTargetButton );
       
   139     if ( this->State() != aTargetButton->State() )
       
   140         return KErrGeneral;
       
   141     return KErrNone;
       
   142     }
       
   143 
       
   144 // ============================ MEMBER FUNCTIONS ===============================
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CTestSDKButtons::TestCEikBtBaseConstructorL
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 TInt CTestSDKButtons::TestCEikBtBaseConstructorL( CStifItemParser& /*aItem*/ )
       
   151     {
       
   152     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   153     CleanupStack::PushL( btbase );
       
   154     STIF_ASSERT_NOT_NULL( btbase );
       
   155     CleanupStack::PopAndDestroy( btbase );
       
   156     
       
   157     return KErrNone;
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CTestSDKButtons::TestCEikBtBaseConstructorL
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TInt CTestSDKButtons::TestCEikBtBaseSetAndGetStateL( CStifItemParser& /*aItem*/ )
       
   165     {
       
   166     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   167     CleanupStack::PushL( btbase );
       
   168     btbase->SetState( CEikButtonBase::ESet );
       
   169     CEikButtonBase::TState state = CEikButtonBase::EClear;
       
   170     state = btbase->State();
       
   171     if ( state != CEikButtonBase::ESet )
       
   172         {
       
   173         return KErrGeneral;
       
   174         }
       
   175         
       
   176     CleanupStack::PopAndDestroy( btbase );
       
   177     
       
   178     return KErrNone;
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CTestSDKButtons::TestCEikBtBaseAnimateL
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt CTestSDKButtons::TestCEikBtBaseAnimateL( CStifItemParser& /*aItem*/ )
       
   186     {
       
   187     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   188     CleanupStack::PushL( btbase );
       
   189     btbase->Animate();
       
   190     
       
   191     CleanupStack::PopAndDestroy( btbase );
       
   192     
       
   193     return KErrNone;
       
   194     }
       
   195 
       
   196 // -----------------------------------------------------------------------------
       
   197 // CTestSDKButtons::TestCEikBtBaseSetCoordinatorL
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 TInt CTestSDKButtons::TestCEikBtBaseSetCoordinatorL( CStifItemParser& /*aItem*/ )
       
   201     {
       
   202     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   203     CleanupStack::PushL( btbase );
       
   204     CEikButtonBase* cobtbase = new ( ELeave ) CEikButtonBase;
       
   205     CleanupStack::PushL( cobtbase );
       
   206     TEikButtonCoordinator coordinator;
       
   207     coordinator.SetChosenButton( cobtbase );
       
   208     btbase->SetCoordinator( &coordinator );
       
   209     
       
   210     CleanupStack::PopAndDestroy( 2 );
       
   211     
       
   212     return KErrNone;
       
   213     }
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CTestSDKButtons::TestCEikBtBaseSetBehaviorL
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 TInt CTestSDKButtons::TestCEikBtBaseSetBehaviorL( CStifItemParser& /*aItem*/ )
       
   220     {
       
   221     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   222     CleanupStack::PushL( btbase );
       
   223     btbase->SetBehavior( EEikButtonStaysSet );
       
   224     
       
   225     CleanupStack::PopAndDestroy( btbase );
       
   226     
       
   227     return KErrNone;
       
   228     }
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CTestSDKButtons::TestCEikBtBaseGetColorUseListL
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 TInt CTestSDKButtons::TestCEikBtBaseGetColorUseListL( CStifItemParser& /*aItem*/ )
       
   235     {
       
   236     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   237     CleanupStack::PushL( btbase );
       
   238     
       
   239     CArrayFixFlat<TCoeColorUse>* array = new ( ELeave ) CArrayFixFlat<TCoeColorUse>( KArraySize );
       
   240     CleanupStack::PushL( array );
       
   241     btbase->GetColorUseListL( *array );
       
   242     STIF_ASSERT_EQUALS( 0, array->Count() );
       
   243     CleanupStack::PopAndDestroy( 2 );
       
   244     
       
   245     return KErrNone;
       
   246     }
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // CTestSDKButtons::TestCEikBtBaseHandleResourceChangeL
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 TInt CTestSDKButtons::TestCEikBtBaseHandleResourceChangeL( CStifItemParser& /*aItem*/ )
       
   253     {
       
   254     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   255     CleanupStack::PushL( btbase );
       
   256     btbase->HandleResourceChange( 0 );
       
   257     
       
   258     CleanupStack::PopAndDestroy( btbase );
       
   259     
       
   260     return KErrNone;
       
   261     }
       
   262 
       
   263 // -----------------------------------------------------------------------------
       
   264 // CTestSDKButtons::TestCEikBtBaseWriteInternalStateL
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 TInt CTestSDKButtons::TestCEikBtBaseWriteInternalStateL( CStifItemParser& /*aItem*/ )
       
   268     {
       
   269     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   270     CleanupStack::PushL( btbase );
       
   271     RDesWriteStream stream;
       
   272     CleanupClosePushL( stream );
       
   273     HBufC8* buf = HBufC8::NewL( KHbufSize );
       
   274     CleanupStack::PushL( buf );
       
   275     TPtr8 ptr = buf->Des();
       
   276     stream.Open( ptr );
       
   277     btbase->WriteInternalStateL( stream );
       
   278     stream.CommitL();
       
   279     stream.Close();
       
   280     CleanupStack::PopAndDestroy( 3 );
       
   281     
       
   282     return KErrNone;
       
   283     }
       
   284 
       
   285 // -----------------------------------------------------------------------------
       
   286 // CTestSDKButtons::TestCEikBtBaseDrawStateL
       
   287 // -----------------------------------------------------------------------------
       
   288 //
       
   289 TInt CTestSDKButtons::TestCEikBtBaseDrawStateL( CStifItemParser& /*aItem*/ )
       
   290     {
       
   291     CTestButtonBase* abtbase = CTestButtonBase::NewL();
       
   292     CleanupStack::PushL( abtbase );
       
   293     TInt err = abtbase->DoDrawState();
       
   294     CleanupStack::PopAndDestroy( abtbase );
       
   295     
       
   296     return err;
       
   297     }
       
   298 
       
   299 // -----------------------------------------------------------------------------
       
   300 // CTestSDKButtons::TestCEikBtBaseSetAllowTristateL
       
   301 // -----------------------------------------------------------------------------
       
   302 //
       
   303 TInt CTestSDKButtons::TestCEikBtBaseSetAllowTristateL( CStifItemParser& /*aItem*/ )
       
   304     {
       
   305     CTestButtonBase* abtbase = CTestButtonBase::NewL();
       
   306     CleanupStack::PushL( abtbase );
       
   307     TInt err = abtbase->DoSetAllowTristate();
       
   308     CleanupStack::PopAndDestroy( abtbase );
       
   309     
       
   310     return err;
       
   311     }
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 // CTestSDKButtons::TestCEikBtBaseCopyDrawStateToL
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 TInt CTestSDKButtons::TestCEikBtBaseCopyDrawStateToL( CStifItemParser& /*aItem*/ )
       
   318     {
       
   319     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   320     CleanupStack::PushL( btbase );
       
   321     btbase->SetState( CEikButtonBase::ESet );
       
   322     CTestButtonBase* abtbase = CTestButtonBase::NewL();
       
   323     CleanupStack::PushL( abtbase );
       
   324     TInt err = abtbase->DoCopyDrawStateTo( btbase );
       
   325     CleanupStack::PopAndDestroy( 2 );
       
   326     
       
   327     return err;
       
   328     }
       
   329 
       
   330 // -----------------------------------------------------------------------------
       
   331 // CTestSDKButtons::TestCEikBtBaseOfferKeyEventL
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 TInt CTestSDKButtons::TestCEikBtBaseOfferKeyEventL( CStifItemParser& /*aItem*/ )
       
   335     {
       
   336     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   337     CleanupStack::PushL( btbase );
       
   338     TKeyEvent keyevent;
       
   339     keyevent.iCode = EKeyDevice3;
       
   340     btbase->OfferKeyEventL( keyevent, EEventKey );
       
   341     CleanupStack::PopAndDestroy( btbase );
       
   342     
       
   343     return KErrNone;
       
   344     }
       
   345 
       
   346 // -----------------------------------------------------------------------------
       
   347 // CTestSDKButtons::TestCEikBtBaseInputCapabilitiesL
       
   348 // -----------------------------------------------------------------------------
       
   349 //
       
   350 TInt CTestSDKButtons::TestCEikBtBaseInputCapabilitiesL( CStifItemParser& /*aItem*/ )
       
   351     {
       
   352     CEikButtonBase* btbase = new ( ELeave ) CEikButtonBase;
       
   353     CleanupStack::PushL( btbase );
       
   354     TCoeInputCapabilities ability = btbase->InputCapabilities();
       
   355     CleanupStack::PopAndDestroy( btbase );
       
   356     
       
   357     return KErrNone;
       
   358     }
       
   359 
       
   360 // End of file