uiaccelerator_plat/alf_core_toolkit_api/tsrc/src/testuiaifcoretoolkitblocksdropshadow.cpp
branchRCL_3
changeset 52 31fccae4f8a7
parent 22 7c5dd702d6d3
equal deleted inserted replaced
51:e5af45d51884 52:31fccae4f8a7
       
     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 of alf_core_toolkit
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // [INCLUDE FILES]
       
    20 #include <e32svr.h>
       
    21 #include <gdi.h>
       
    22 #include <e32math.h>
       
    23 #include <stifparser.h>
       
    24 #include <AknsConstants.h>
       
    25 #include <uiacceltk/huienv.h>
       
    26 #include <stiftestinterface.h>
       
    27 #include <uiacceltk/huienv.h>
       
    28 #include <uiacceltk/huistatic.h>
       
    29 #include <uiacceltk/huidropshadow.h>
       
    30 
       
    31 #include <uiacceltk/huidisplay.h>
       
    32 #include <uiacceltk/huidisplaybackgrounditem.h>
       
    33 #include <uiacceltk/huicontrol.h>
       
    34 #include <uiacceltk/huicontrolgroup.h>
       
    35 #include <uiacceltk/huiimagevisual.h>
       
    36 #include <uiacceltk/huiutil.h>
       
    37 
       
    38 #include "testuiaifcoretoolkit.h"
       
    39 
       
    40 #define FLOAT_COMPARE(a, b) (Abs(a-b)<0.001f)
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CTestUiAifCoreToolkit::TestTHSetOffsetL
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 TInt CTestUiAifCoreToolkit::TestTHSetOffsetL( CStifItemParser& /*aItem*/ )
       
    47     {
       
    48 
       
    49     // Print to UI
       
    50     _LIT( Ktestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
    51     _LIT( KTestTHSetOffsetL, "In TestTHSetOffsetL" );
       
    52     TestModuleIf().Printf( 0, Ktestuiaifcoretoolkit, KTestTHSetOffsetL );
       
    53     // Print to log file 
       
    54     iLog->Log( KTestTHSetOffsetL );
       
    55     
       
    56     TBool temp = ETrue;
       
    57     CHuiVisual* huiVisual = CHuiVisual::AddNewL( *iHuiControl );
       
    58     huiVisual->EnableDropShadowL( temp );
       
    59     CHuiDropShadow* dropShadow = huiVisual->DropShadowHandler();
       
    60     
       
    61     // polar coorinates
       
    62     const TReal32 angle = 123.2f;
       
    63     const THuiMetric distance( 1234.6f, EHuiUnitS60 );
       
    64     const TInt transitionTime = 23;
       
    65     
       
    66     dropShadow->SetOffset( angle, distance, transitionTime );
       
    67     
       
    68     // wait the result
       
    69     CHuiEnv::RefreshCallBack( iHuiEnv );
       
    70     User::After( 1.2f*transitionTime );
       
    71     CHuiEnv::RefreshCallBack( iHuiEnv );
       
    72     
       
    73     // verify:
       
    74     TReal shouldBeX;
       
    75     Math::Cos( shouldBeX, 2.0*KPi*angle/360.0 );
       
    76     shouldBeX*=distance.iMagnitude;
       
    77     
       
    78     TReal shouldBeY;
       
    79     Math::Sin( shouldBeY, 2.0*KPi*angle/360.0 );
       
    80     shouldBeY*=-1.0*distance.iMagnitude;
       
    81     
       
    82     STIF_ASSERT_TRUE( FLOAT_COMPARE( dropShadow->iOffset.iX.Now(), shouldBeX ) );
       
    83     STIF_ASSERT_TRUE( FLOAT_COMPARE( dropShadow->iOffset.iY.Now(), shouldBeY ) );
       
    84     STIF_ASSERT_TRUE( FLOAT_COMPARE( dropShadow->iOffsetUnit, distance.iUnit ) );
       
    85     
       
    86     return KErrNone;
       
    87     
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CTestUiAifCoreToolkit::TestTHSetColorL
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 TInt CTestUiAifCoreToolkit::TestTHSetColorL( CStifItemParser& /*aItem*/ )
       
    95     {
       
    96 
       
    97     // Print to UI
       
    98     _LIT( Ktestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
    99     _LIT( KTestTHSetColorLL, "In TestTHSetColorL" );
       
   100     TestModuleIf().Printf( 0, Ktestuiaifcoretoolkit, KTestTHSetColorLL );
       
   101     // Print to log file 
       
   102     iLog->Log( KTestTHSetColorLL );
       
   103     
       
   104     TBool temp = ETrue;
       
   105     CHuiVisual* huiVisual = CHuiVisual::AddNewL( *iHuiControl );
       
   106     huiVisual->EnableDropShadowL( temp );
       
   107     CHuiDropShadow* dropShadow = huiVisual->DropShadowHandler();
       
   108     
       
   109     const TRgb color1( KRgbCyan );
       
   110     dropShadow->SetColor( color1 );
       
   111     
       
   112     return KErrNone;
       
   113     
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // CTestUiAifCoreToolkit::TestTHSetColorTAknsItemIDL
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 TInt CTestUiAifCoreToolkit::TestTHSetColorTAknsItemIDL( CStifItemParser& /*aItem*/ )
       
   121     {
       
   122 
       
   123     // Print to UI
       
   124     _LIT( Ktestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   125     _LIT( KTestTHSetColorTAknsItemIDL, "In TestTHSetColorTAknsItemIDL" );
       
   126     TestModuleIf().Printf( 0, Ktestuiaifcoretoolkit, KTestTHSetColorTAknsItemIDL );
       
   127     // Print to log file 
       
   128     iLog->Log( KTestTHSetColorTAknsItemIDL );
       
   129     
       
   130     TBool temp = ETrue;
       
   131     CHuiVisual* huiVisual = CHuiVisual::AddNewL( *iHuiControl );
       
   132     huiVisual->EnableDropShadowL( temp );
       
   133     CHuiDropShadow* dropShadow = huiVisual->DropShadowHandler();
       
   134     
       
   135     // change timed
       
   136     const TRgb color2( KRgbGreen );
       
   137     const TInt transitionTime = 23;
       
   138     
       
   139     dropShadow->SetColor( color2, transitionTime );
       
   140     
       
   141     const TAknsItemID color1( KAknsIIDQsnTextColors );
       
   142     const TInt index1( EAknsCIQsnTextColorsCG5 );
       
   143     dropShadow->SetColor( color1, index1 );
       
   144     
       
   145     // change timed
       
   146     const TAknsItemID color3( KAknsIIDQsnComponentColors );
       
   147     const TInt index2( EAknsCIQsnComponentColorsCG14 );
       
   148     const TInt transitionTime1 = 23;
       
   149     
       
   150     dropShadow->SetColor( color3, index2, transitionTime1 );
       
   151     
       
   152     return KErrNone;
       
   153     
       
   154     }
       
   155 
       
   156 //  [End of File]