uifw/AvKon/tsrc/bc/S60_SDK3.0/bctestlist/src/bctestlistdecoratorcase.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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 for aknlistboxlayoutdecorator
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <w32std.h>
       
    20 #include <eikenv.h>
       
    21 #include <aknlistboxlayoutdecorator.h>
       
    22 
       
    23 #include "bctestlistdecoratorcase.h"
       
    24 #include "bctestlistcontainer.h"
       
    25 #include "bctestlist.hrh"
       
    26 #include <bctestlist.rsg>
       
    27 
       
    28 _LIT( KDecoratorTest1, "CAknListBoxLayoutDecorator::NewL()" );
       
    29 _LIT( KDecoratorTest2, "CAknListBoxLayoutDecorator::SetArray and Array" );
       
    30 _LIT( KDecoratorTest3, "CAknListBoxLayoutDecorator::SetLeadingDecorationTextL" );
       
    31 _LIT( KDecoratorTest4, "CAknListBoxLayoutDecorator::SetTrailingDecorationTextL" );
       
    32 _LIT( KDecoratorTest5, "CAknListBoxLayoutDecorator::SetActive" );
       
    33 _LIT( KDecoratorTest6, "CAknListBoxLayoutDecorator::MdcaCount" );
       
    34 _LIT( KDecoratorTest7, "CAknListBoxLayoutDecorator::MdcaPoint" );
       
    35 _LIT( KTextLeading, "Leading text" );
       
    36 _LIT( KTextTrailing, "Trailing text" );
       
    37 
       
    38 // ======== MEMBER FUNCTIONS ========
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Symbian 2nd static Constructor
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CBCTestListDecoratorCase* CBCTestListDecoratorCase::NewL( 
       
    45     CBCTestListContainer* aContainer, CEikonEnv* aEikEnv )
       
    46     {
       
    47     CBCTestListDecoratorCase* self = new( ELeave ) CBCTestListDecoratorCase( 
       
    48         aContainer, aEikEnv );
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop( self );
       
    52     return self;
       
    53     }
       
    54     
       
    55 // ---------------------------------------------------------------------------
       
    56 // C++ default constructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CBCTestListDecoratorCase::CBCTestListDecoratorCase( CBCTestListContainer* aContainer,
       
    60     CEikonEnv* aEikEnv )
       
    61     : CBCTestListBaseCase( aContainer, aEikEnv )
       
    62     {    
       
    63     }
       
    64     
       
    65 // ---------------------------------------------------------------------------
       
    66 // Destructor
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CBCTestListDecoratorCase::~CBCTestListDecoratorCase()
       
    70     {  
       
    71     }
       
    72     
       
    73 // ---------------------------------------------------------------------------
       
    74 // Symbian 2nd Constructor
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 void CBCTestListDecoratorCase::ConstructL()
       
    78     {    
       
    79     BuildScriptL();    
       
    80     }
       
    81     
       
    82 // ---------------------------------------------------------------------------
       
    83 // CBCTestListDecoratorCase::BuildScriptL
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CBCTestListDecoratorCase::BuildScriptL()
       
    87     {    
       
    88     for ( TInt i=0; i <= EBCTestCmdOutline44 - EBCTestCmdOutline43; i++ )
       
    89         {
       
    90         AddTestL( LeftCBA, REP( Down, 5 ), KeyOK, TEND );
       
    91         AddTestL( REP( Down, i ), KeyOK, TEND );
       
    92         }      
       
    93     }
       
    94     
       
    95 // ---------------------------------------------------------------------------
       
    96 // CBCTestListDecoratorCase::RunL
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CBCTestListDecoratorCase::RunL( TInt aCmd )
       
   100     {
       
   101     if ( aCmd < EBCTestCmdOutline43 || aCmd > EBCTestCmdOutline44 )
       
   102         {
       
   103         return;
       
   104         }
       
   105     ReleaseCase();
       
   106     switch ( aCmd )  
       
   107         {
       
   108         case EBCTestCmdOutline43:
       
   109             TestLayoutDecoratorL();
       
   110             break;        
       
   111         default:
       
   112             break;
       
   113         }
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CBCTestListDecoratorCase::ReleaseCase
       
   118 // ---------------------------------------------------------------------------
       
   119 //   
       
   120 void CBCTestListDecoratorCase::ReleaseCase()
       
   121     {
       
   122     iContainer->ResetControl();    
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // CBCTestListDecoratorCase::TestLayoutDecorator
       
   127 // ---------------------------------------------------------------------------
       
   128 //    
       
   129 void CBCTestListDecoratorCase::TestLayoutDecoratorL()
       
   130     {
       
   131     CDesCArray* textArray = iEikEnv->ReadDesCArrayResourceL( 
       
   132         R_BCTESTLIST_ITEM_SINGLE1 );
       
   133     CleanupStack::PushL( textArray );
       
   134 
       
   135     CAknListBoxLayoutDecorator* decorator = NULL;    
       
   136     decorator = CAknListBoxLayoutDecorator::NewL();
       
   137     CleanupStack::PushL( decorator );
       
   138     AssertNotNullL( decorator, KDecoratorTest1 );    
       
   139     
       
   140     decorator->SetArray( textArray );
       
   141     const MDesCArray* array = decorator->Array();
       
   142     AssertTrueL( ( array == textArray ), KDecoratorTest2 );    
       
   143     
       
   144     decorator->SetLeadingDecorationTextL( KTextLeading );
       
   145     AssertTrueL( ETrue, KDecoratorTest3 );
       
   146     
       
   147     decorator->SetTrailingDecorationTextL( KTextTrailing );
       
   148     AssertTrueL( ETrue, KDecoratorTest4 );
       
   149         
       
   150     decorator->SetActive( ETrue );
       
   151     decorator->SetActive( EFalse );
       
   152     AssertTrueL( ETrue, KDecoratorTest5 );    
       
   153     
       
   154     TInt mdcaCount = decorator->MdcaCount();
       
   155     AssertIntL( textArray->Count(), mdcaCount, KDecoratorTest6 );    
       
   156     for ( TInt i=0; i< mdcaCount; i++ )
       
   157         {
       
   158         TPtrC ptr = decorator->MdcaPoint( i );        
       
   159         }
       
   160     AssertTrueL( ETrue, KDecoratorTest7 );
       
   161     
       
   162     CleanupStack::PopAndDestroy( decorator );    
       
   163     CleanupStack::PopAndDestroy( textArray );
       
   164     }
       
   165