uiaccelerator_plat/alf_visual_api/tsrc/src/testplatalfvisualblockspropertyowner.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     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 functions for alfpropertyowner.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES]
       
    21 #include <alf/alfpropertyowner.h>
       
    22 #include <alf/alfvisual.h>
       
    23 
       
    24 #include "testplatalfvisual.h"
       
    25 
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KFooIntValue = 23;
       
    29 const TInt KFooIntValue2 = 19;
       
    30 
       
    31 _LIT8( KFooName, "FooProperty" );
       
    32 _LIT8( KFooName2, "Bar" );
       
    33 _LIT8( KFooName3, "listbox.opacity" );
       
    34 _LIT( KFooValue, "Hello world!" );
       
    35 _LIT( KFooValue2, "My test string... This will be stored as a property value." );
       
    36 
       
    37 
       
    38 // FORWARD DECLARATION
       
    39 // class CTestPropertyOwner for testing CAlfPropertyOwner
       
    40 class CTestPropertyOwner : public CAlfPropertyOwner
       
    41     {
       
    42 public:
       
    43     void TestPropertyOwnerExtension()
       
    44         {
       
    45         TBool inFocusChain( EFalse );
       
    46         TAny* pInFocusChain = &inFocusChain;
       
    47         CAlfPropertyOwner::PropertyOwnerExtension( KUidAlfPropOwnerExtControlFocusChainChanged, &pInFocusChain );
       
    48         }
       
    49     };
       
    50 
       
    51 
       
    52 // ============================ MEMBER FUNCTIONS ===============================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CTestPlatAlfVisual::TestPropOwnerConstructorL
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 TInt CTestPlatAlfVisual::TestPropOwnerConstructorL( CStifItemParser& /*aItem*/ )
       
    59     {
       
    60     // Print to UI
       
    61     _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
       
    62     _LIT( KTestPropOwnerConstructorL, "TestPropOwnerConstructorL" );
       
    63     TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestPropOwnerConstructorL );
       
    64     // Print to log file
       
    65     iLog->Log( KTestPropOwnerConstructorL );
       
    66     
       
    67     CAlfPropertyOwner* owner = new ( ELeave ) CAlfPropertyOwner();
       
    68     CleanupStack::PushL( owner );
       
    69     STIF_ASSERT_NOT_NULL( owner );
       
    70     CleanupStack::PopAndDestroy( owner );
       
    71     
       
    72     return KErrNone;
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CTestPlatAlfVisual::TestPropOwnerPropertyRemoveL
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TInt CTestPlatAlfVisual::TestPropOwnerPropertyRemoveL( CStifItemParser& /*aItem*/ )
       
    80     {
       
    81     // Print to UI
       
    82     _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
       
    83     _LIT( KTestPropOwnerPropertyRemoveL, "TestPropOwnerPropertyRemoveL" );
       
    84     TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestPropOwnerPropertyRemoveL );
       
    85     // Print to log file
       
    86     iLog->Log( KTestPropOwnerPropertyRemoveL );
       
    87     
       
    88     CAlfPropertyOwner* owner = new ( ELeave ) CAlfVisual;
       
    89     CleanupStack::PushL( owner );
       
    90     STIF_ASSERT_NOT_NULL( owner );
       
    91     owner->PropertySetIntegerL( KFooName, 0 );
       
    92     owner->PropertySetIntegerL( KFooName2, 0 );
       
    93     owner->PropertySetIntegerL( KFooName3, 0 );
       
    94     TBool success = owner->PropertyFindInteger( KFooName );
       
    95     STIF_ASSERT_TRUE( success );
       
    96     success = owner->PropertyRemove( KFooName );
       
    97     STIF_ASSERT_TRUE( success );
       
    98     CleanupStack::PopAndDestroy( owner );
       
    99     
       
   100     return KErrNone;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CTestPlatAlfVisual::TestPropOwnerPropertyClearL
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 TInt CTestPlatAlfVisual::TestPropOwnerPropertyClearL( CStifItemParser& /*aItem*/ )
       
   108     {
       
   109     // Print to UI
       
   110     _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
       
   111     _LIT( KTestPropOwnerPropertyClearL, "TestPropOwnerPropertyClearL" );
       
   112     TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestPropOwnerPropertyClearL );
       
   113     // Print to log file
       
   114     iLog->Log( KTestPropOwnerPropertyClearL );
       
   115     
       
   116     CAlfPropertyOwner* owner = new ( ELeave ) CAlfVisual;
       
   117     CleanupStack::PushL( owner );
       
   118     STIF_ASSERT_NOT_NULL( owner );
       
   119     owner->PropertySetIntegerL( KFooName, 0 );
       
   120     owner->PropertySetIntegerL( KFooName2, 0 );
       
   121     owner->PropertySetIntegerL( KFooName3, 0 );
       
   122     
       
   123     owner->PropertyClear();
       
   124        
       
   125     STIF_ASSERT_TRUE( !owner->PropertyFindInteger( KFooName ) ); 
       
   126     STIF_ASSERT_TRUE( !owner->PropertyFindInteger( KFooName2 ) ); 
       
   127     STIF_ASSERT_TRUE( !owner->PropertyFindInteger( KFooName3 ) );
       
   128 
       
   129     CleanupStack::PopAndDestroy( owner );
       
   130     
       
   131     return KErrNone;
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CTestPlatAlfVisual::TestPropOwnerPropertyIntegerL
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 TInt CTestPlatAlfVisual::TestPropOwnerPropertyIntegerL( CStifItemParser& /*aItem*/ )
       
   139     {
       
   140     // Print to UI
       
   141     _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
       
   142     _LIT( KTestPropOwnerPropertyIntegerL, "TestPropOwnerPropertyIntegerL" );
       
   143     TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestPropOwnerPropertyIntegerL );
       
   144     // Print to log file
       
   145     iLog->Log( KTestPropOwnerPropertyIntegerL );
       
   146     
       
   147     CAlfPropertyOwner* owner = new ( ELeave ) CAlfVisual;
       
   148     CleanupStack::PushL( owner );
       
   149     STIF_ASSERT_NOT_NULL( owner );
       
   150     
       
   151     TInt ret = 0;
       
   152     
       
   153     // Set initial value.
       
   154     owner->PropertySetIntegerL( KFooName, KFooIntValue );
       
   155     TBool success = owner->PropertyFindInteger(KFooName, &ret);
       
   156     STIF_ASSERT_TRUE( success );
       
   157     STIF_ASSERT_EQUALS( KFooIntValue, ret );
       
   158     
       
   159     // Set a new value.
       
   160     owner->PropertySetIntegerL( KFooName, KFooIntValue2 );
       
   161     success = owner->PropertyFindInteger(KFooName, &ret);
       
   162     STIF_ASSERT_TRUE( success );
       
   163     STIF_ASSERT_EQUALS( KFooIntValue2, ret );
       
   164     
       
   165     STIF_ASSERT_TRUE( owner->PropertyRemove( KFooName ) );
       
   166     
       
   167     STIF_ASSERT_TRUE( !owner->PropertyFindInteger( KFooName ) );
       
   168     
       
   169     CleanupStack::PopAndDestroy( owner );
       
   170     
       
   171     return KErrNone;
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CTestPlatAlfVisual::TestPropOwnerPropertyStringL
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 TInt CTestPlatAlfVisual::TestPropOwnerPropertyStringL( CStifItemParser& /*aItem*/ )
       
   179     {
       
   180     // Print to UI
       
   181     _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
       
   182     _LIT( KTestPropOwnerPropertyStringL, "TestPropOwnerPropertyStringL" );
       
   183     TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestPropOwnerPropertyStringL );
       
   184     // Print to log file
       
   185     iLog->Log( KTestPropOwnerPropertyStringL );
       
   186     
       
   187     CAlfPropertyOwner* owner = new ( ELeave ) CAlfVisual;
       
   188     CleanupStack::PushL( owner );
       
   189     STIF_ASSERT_NOT_NULL( owner );
       
   190     
       
   191     TDesC* ret = NULL;
       
   192     
       
   193     owner->PropertySetStringL( KFooName, KFooValue2 );
       
   194     owner->PropertySetStringL( KFooName2, KFooValue );
       
   195     owner->PropertySetStringL( KFooName3, KFooValue );
       
   196     
       
   197     TBool success = owner->PropertyFindString( KFooName, &ret );
       
   198     
       
   199     STIF_ASSERT_TRUE( success );
       
   200     
       
   201     success = *ret == KFooValue2;
       
   202     STIF_ASSERT_TRUE( success );
       
   203     
       
   204     CleanupStack::PopAndDestroy( owner );
       
   205     
       
   206     return KErrNone;
       
   207     }
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CTestPlatAlfVisual::TestPropOwnerCopyPropertyL
       
   211 // -----------------------------------------------------------------------------
       
   212 //
       
   213 TInt CTestPlatAlfVisual::TestPropOwnerCopyPropertyL( CStifItemParser& /*aItem*/ )
       
   214     {
       
   215     // Print to UI
       
   216     _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
       
   217     _LIT( KTestPropOwnerCopyPropertyL, "TestPropOwnerCopyPropertyL" );
       
   218     TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestPropOwnerCopyPropertyL );
       
   219     // Print to log file
       
   220     iLog->Log( KTestPropOwnerCopyPropertyL );
       
   221     
       
   222     CAlfPropertyOwner* originalOwner = new ( ELeave ) CAlfPropertyOwner();
       
   223     CleanupStack::PushL( originalOwner );
       
   224     STIF_ASSERT_NOT_NULL( originalOwner );
       
   225     originalOwner->PropertySetStringL( KFooName, KFooValue );
       
   226     CAlfPropertyOwner* owner = new ( ELeave ) CAlfPropertyOwner();
       
   227     CleanupStack::PushL( owner );
       
   228     STIF_ASSERT_NOT_NULL( owner );
       
   229     owner->CopyProperty( *originalOwner, KFooName );
       
   230     CleanupStack::PopAndDestroy( owner );
       
   231     CleanupStack::PopAndDestroy( originalOwner );
       
   232     
       
   233     return KErrNone;
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CTestPlatAlfVisual::TestPropOwnerPropertyOwnerExtensionL
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 TInt CTestPlatAlfVisual::TestPropOwnerPropertyOwnerExtensionL( CStifItemParser& /*aItem*/ )
       
   241     {
       
   242     // Print to UI
       
   243     _LIT( KTestPlatAlfVisual, "TestPlatAlfVisual" );
       
   244     _LIT( KTestPropOwnerPropertyOwnerExtensionL, "TestPropOwnerPropertyOwnerExtensionL" );
       
   245     TestModuleIf().Printf( 0, KTestPlatAlfVisual, KTestPropOwnerPropertyOwnerExtensionL );
       
   246     // Print to log file
       
   247     iLog->Log( KTestPropOwnerPropertyOwnerExtensionL );
       
   248     
       
   249     CTestPropertyOwner* owner = new ( ELeave ) CTestPropertyOwner;
       
   250     CleanupStack::PushL( owner );
       
   251     STIF_ASSERT_NOT_NULL( owner );
       
   252     owner->TestPropertyOwnerExtension();
       
   253     CleanupStack::PopAndDestroy( owner );
       
   254     
       
   255     return KErrNone;
       
   256     }
       
   257 
       
   258 
       
   259 //  [End of File]