uiaccelerator_plat/alf_core_toolkit_api/tsrc/src/testuiaifctkitblockshuiimage.cpp
branchRCL_3
changeset 20 31fccae4f8a7
parent 10 7c5dd702d6d3
equal deleted inserted replaced
19:e5af45d51884 20: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 
       
    20 // [INCLUDE FILES]
       
    21 #include <e32svr.h>
       
    22 #include <stifparser.h>
       
    23 #include <fbs.h>
       
    24 #include <stiftestinterface.h>
       
    25 #include <uiacceltk/huienv.h>
       
    26 #include <uiacceltk/huicontrol.h>
       
    27 #include <uiacceltk/huiimage.h>
       
    28 #include <uiacceltk/huitexturehandle.h>
       
    29 
       
    30 #include "testuiaifcoretoolkit.h"
       
    31 #include "testuiaifblockstexturechild.h"
       
    32 #include "testuiaifblocksmanagerchild.h"
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CTestUiAifCoreToolkit::TestTHIConstructor
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 TInt CTestUiAifCoreToolkit::TestTHIConstructor( CStifItemParser& /*aItem*/ )
       
    39     {
       
    40 
       
    41     // Print to UI
       
    42     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
    43     _LIT( KHuiImage, "In TestTHIConstructor" );
       
    44     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
    45     // Print to log file
       
    46     iLog->Log( KHuiImage );
       
    47 
       
    48     THuiImage image;
       
    49 
       
    50     return KErrNone;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CTestUiAifCoreToolkit::TestTHIConstructorWithParaL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 TInt CTestUiAifCoreToolkit::TestTHIConstructorWithParaL( CStifItemParser& /*aItem*/ )
       
    58     {
       
    59 
       
    60     // Print to UI
       
    61     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
    62     _LIT( KHuiImage, "In TestTHIConstructorWithParaL" );
       
    63     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
    64     // Print to log file
       
    65     iLog->Log( KHuiImage );
       
    66 
       
    67     CHuiTexture* texture = CHuiTexture::NewL();
       
    68     CleanupStack::PushL( texture );
       
    69     THuiImage image( *texture );
       
    70     CleanupStack::PopAndDestroy( texture );
       
    71 
       
    72     return KErrNone;
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CTestUiAifCoreToolkit::TestTHISegmentCountL
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TInt CTestUiAifCoreToolkit::TestTHISegmentCountL( CStifItemParser& /*aItem*/ )
       
    80     {
       
    81 
       
    82     // Print to UI
       
    83     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
    84     _LIT( KHuiImage, "In TestTHISegmentCountL" );
       
    85     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
    86     // Print to log file
       
    87     iLog->Log( KHuiImage );
       
    88 
       
    89     THuiImage image;
       
    90     TInt count = image.SegmentCount();
       
    91     STIF_ASSERT_EQUALS( count, 0 );
       
    92 
       
    93     THuiTextureHandle* handle = new( ELeave ) THuiTextureHandle();
       
    94     CHuiTexture* texture = CHuiTexture::NewL( handle );
       
    95     CleanupStack::PushL( texture );
       
    96     THuiImage image1( *texture );
       
    97     count = image1.SegmentCount();
       
    98     STIF_ASSERT_EQUALS( count, 0 );
       
    99     CleanupStack::PopAndDestroy( texture );
       
   100 
       
   101     return KErrNone;
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CTestUiAifCoreToolkit::TestTHIGetVertexCoordsL
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 TInt CTestUiAifCoreToolkit::TestTHIGetVertexCoordsL( CStifItemParser& /*aItem*/ )
       
   109     {
       
   110 
       
   111     // Print to UI
       
   112     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   113     _LIT( KHuiImage, "In TestTHIGetVertexCoordsL" );
       
   114     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   115     // Print to log file
       
   116     iLog->Log( KHuiImage );
       
   117 
       
   118     THuiImage image;
       
   119     TInt16* coords = new( ELeave ) TInt16;
       
   120     image.GetVertexCoords( coords );
       
   121 
       
   122     THuiTextureHandle* handle = new( ELeave ) THuiTextureHandle();
       
   123     CHuiTexture* texture = CHuiTexture::NewL( handle );
       
   124     CleanupStack::PushL( texture );
       
   125     THuiImage image1( *texture );
       
   126     image1.GetVertexCoords( coords );
       
   127     CleanupStack::PopAndDestroy( texture );
       
   128 
       
   129     return KErrNone;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CTestUiAifCoreToolkit::TestTHIGetTexCoordsL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TInt CTestUiAifCoreToolkit::TestTHIGetTexCoordsL( CStifItemParser& /*aItem*/ )
       
   137     {
       
   138 
       
   139     // Print to UI
       
   140     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   141     _LIT( KHuiImage, "In TestTHIGetTexCoordsL" );
       
   142     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   143     // Print to log file
       
   144     iLog->Log( KHuiImage );
       
   145 
       
   146     THuiImage image;
       
   147     TReal32* coords = new( ELeave ) TReal32;
       
   148     image.GetTexCoords( coords );
       
   149 
       
   150     THuiTextureHandle* handle = new( ELeave ) THuiTextureHandle();
       
   151     CHuiTexture* texture = CHuiTexture::NewL( handle );
       
   152     CleanupStack::PushL( texture );
       
   153     THuiImage image1( *texture );
       
   154     image1.GetTexCoords( coords );
       
   155     CleanupStack::PopAndDestroy( texture );
       
   156 
       
   157     return KErrNone;
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CTestUiAifCoreToolkit::TestTHISetTexCoords
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TInt CTestUiAifCoreToolkit::TestTHISetTexCoordsL( CStifItemParser& /*aItem*/ )
       
   165     {
       
   166 
       
   167     // Print to UI
       
   168     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   169     _LIT( KHuiImage, "In TestTHISetTexCoords" );
       
   170     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   171     // Print to log file
       
   172     iLog->Log( KHuiImage );
       
   173 
       
   174     THuiImage image;
       
   175     TReal32* coords = new( ELeave ) TReal32;
       
   176     image.SetTexCoords();
       
   177 
       
   178     return KErrNone;
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CTestUiAifCoreToolkit::TestTHITopLeft
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 TInt CTestUiAifCoreToolkit::TestTHITopLeftL( CStifItemParser& /*aItem*/ )
       
   186     {
       
   187 
       
   188     // Print to UI
       
   189     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   190     _LIT( KHuiImage, "In TestTHITopLeft" );
       
   191     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   192     // Print to log file
       
   193     iLog->Log( KHuiImage );
       
   194 
       
   195     THuiImage image;
       
   196     TReal32* coords = new( ELeave ) TReal32;
       
   197     image.TopLeft();
       
   198 
       
   199     return KErrNone;
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CTestUiAifCoreToolkit::TestTHIBottomRight
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 TInt CTestUiAifCoreToolkit::TestTHIBottomRightL( CStifItemParser& /*aItem*/ )
       
   207     {
       
   208 
       
   209     // Print to UI
       
   210     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   211     _LIT( KHuiImage, "In TestTHIBottomRight" );
       
   212     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   213     // Print to log file
       
   214     iLog->Log( KHuiImage );
       
   215 
       
   216     THuiImage image;
       
   217     TReal32* coords = new( ELeave ) TReal32;
       
   218     image.BottomRight();
       
   219 
       
   220     return KErrNone;
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CTestUiAifCoreToolkit::TestTHIHasTexture
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 TInt CTestUiAifCoreToolkit::TestTHIHasTextureL( CStifItemParser& /*aItem*/ )
       
   228     {
       
   229 
       
   230     // Print to UI
       
   231     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   232     _LIT( KHuiImage, "In TestTHIHasTexture" );
       
   233     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   234     // Print to log file
       
   235     iLog->Log( KHuiImage );
       
   236 
       
   237     THuiImage image;
       
   238     TReal32* coords = new( ELeave ) TReal32;
       
   239     TBool has = image.HasTexture();
       
   240     STIF_ASSERT_FALSE( has );
       
   241 
       
   242     return KErrNone;
       
   243     }
       
   244 
       
   245 // -----------------------------------------------------------------------------
       
   246 // CTestUiAifCoreToolkit::TestTHISetTextureL
       
   247 // -----------------------------------------------------------------------------
       
   248 //
       
   249 TInt CTestUiAifCoreToolkit::TestTHISetTextureL( CStifItemParser& /*aItem*/ )
       
   250     {
       
   251 
       
   252     // Print to UI
       
   253     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   254     _LIT( KHuiImage, "In TestTHISetTextureL" );
       
   255     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   256     // Print to log file
       
   257     iLog->Log( KHuiImage );
       
   258 
       
   259     THuiImage image;
       
   260     CTestUiAifBlocksManagerChild* managerChild =new ( ELeave ) CTestUiAifBlocksManagerChild;
       
   261     CleanupStack::PushL( managerChild );
       
   262     CTestUiAifBlocksTextureChild* textureChild = CTestUiAifBlocksTextureChild::NewL( *managerChild );
       
   263     CleanupStack::PushL( textureChild );
       
   264     image.SetTexture( *textureChild );
       
   265     CleanupStack::PopAndDestroy( textureChild );
       
   266 
       
   267     return KErrNone;
       
   268     }
       
   269 
       
   270 // -----------------------------------------------------------------------------
       
   271 // CTestUiAifCoreToolkit::TestTHITextureL
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 TInt CTestUiAifCoreToolkit::TestTHITextureL( CStifItemParser& /*aItem*/ )
       
   275     {
       
   276 
       
   277     // Print to UI
       
   278     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   279     _LIT( KHuiImage, "In TestTHITextureL" );
       
   280     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   281     // Print to log file
       
   282     iLog->Log( KHuiImage );
       
   283 
       
   284     THuiImage image;
       
   285     CTestUiAifBlocksManagerChild* managerChild =new ( ELeave ) CTestUiAifBlocksManagerChild;
       
   286     CleanupStack::PushL( managerChild );
       
   287     CTestUiAifBlocksTextureChild* textureChild = CTestUiAifBlocksTextureChild::NewL( *managerChild );
       
   288     CleanupStack::PushL( textureChild );
       
   289     image.SetTexture( *textureChild );
       
   290     image.Texture();
       
   291     CleanupStack::PopAndDestroy( textureChild );
       
   292 
       
   293     return KErrNone;
       
   294     }
       
   295 
       
   296 // -----------------------------------------------------------------------------
       
   297 // CTestUiAifCoreToolkit::TestTHITextureIfL
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 TInt CTestUiAifCoreToolkit::TestTHITextureIfL( CStifItemParser& /*aItem*/ )
       
   301     {
       
   302 
       
   303     // Print to UI
       
   304     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   305     _LIT( KHuiImage, "In TestTHITextureIfL" );
       
   306     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   307     // Print to log file
       
   308     iLog->Log( KHuiImage );
       
   309 
       
   310     THuiImage image;
       
   311     CTestUiAifBlocksManagerChild* managerChild =new ( ELeave ) CTestUiAifBlocksManagerChild;
       
   312     CleanupStack::PushL( managerChild );
       
   313     CTestUiAifBlocksTextureChild* textureChild = CTestUiAifBlocksTextureChild::NewL( *managerChild );
       
   314     CleanupStack::PushL( textureChild );
       
   315     image.SetTexture( *textureChild );
       
   316     image.TextureIf();
       
   317     CleanupStack::PopAndDestroy( textureChild );
       
   318 
       
   319     return KErrNone;
       
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // CTestUiAifCoreToolkit::TestTHIHasShadow
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 TInt CTestUiAifCoreToolkit::TestTHIHasShadow( CStifItemParser& /*aItem*/ )
       
   327     {
       
   328 
       
   329     // Print to UI
       
   330     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   331     _LIT( KHuiImage, "In TestTHIHasShadow" );
       
   332     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   333     // Print to log file
       
   334     iLog->Log( KHuiImage );
       
   335 
       
   336     THuiImage image;
       
   337     image.HasShadow();
       
   338 
       
   339     return KErrNone;
       
   340     }
       
   341 
       
   342 // -----------------------------------------------------------------------------
       
   343 // CTestUiAifCoreToolkit::TestTHIShadowTexture
       
   344 // -----------------------------------------------------------------------------
       
   345 //
       
   346 TInt CTestUiAifCoreToolkit::TestTHIShadowTexture( CStifItemParser& /*aItem*/ )
       
   347     {
       
   348 
       
   349     // Print to UI
       
   350     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   351     _LIT( KHuiImage, "In TestTHIShadowTexture" );
       
   352     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   353     // Print to log file
       
   354     iLog->Log( KHuiImage );
       
   355 
       
   356     THuiImage image;
       
   357     image.ShadowTexture();
       
   358 
       
   359     return KErrNone;
       
   360     }
       
   361 
       
   362 // -----------------------------------------------------------------------------
       
   363 // CTestUiAifCoreToolkit::TestTHITranslate
       
   364 // -----------------------------------------------------------------------------
       
   365 //
       
   366 TInt CTestUiAifCoreToolkit::TestTHITranslate( CStifItemParser& /*aItem*/ )
       
   367     {
       
   368 
       
   369     // Print to UI
       
   370     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   371     _LIT( KHuiImage, "In TestTHITranslate" );
       
   372     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   373     // Print to log file
       
   374     iLog->Log( KHuiImage );
       
   375 
       
   376     THuiImage image;
       
   377     image.Translate( 1, 1 );
       
   378 
       
   379     return KErrNone;
       
   380     }
       
   381 
       
   382 // -----------------------------------------------------------------------------
       
   383 // CTestUiAifCoreToolkit::TestTHIScale
       
   384 // -----------------------------------------------------------------------------
       
   385 //
       
   386 TInt CTestUiAifCoreToolkit::TestTHIScale( CStifItemParser& /*aItem*/ )
       
   387     {
       
   388 
       
   389     // Print to UI
       
   390     _LIT( KTestuiaifcoretoolkit, "testuiaifcoretoolkit" );
       
   391     _LIT( KHuiImage, "In TestTHIScale" );
       
   392     TestModuleIf().Printf( 0, KTestuiaifcoretoolkit, KHuiImage );
       
   393     // Print to log file
       
   394     iLog->Log( KHuiImage );
       
   395 
       
   396     THuiImage image;
       
   397     image.Scale( 1, 1 );
       
   398 
       
   399     return KErrNone;
       
   400     }