gssettingsuis/Gs/tsrc/public/basic/GSBackgroundImage/T_GSBackgroundImage.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 23 8bda91a87a00
child 25 7e0eff37aedb
equal deleted inserted replaced
23:8bda91a87a00 24:8ee96d21d9bf
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  CLASS HEADER
       
    20 #include "T_GSBackgroundImage.h"
       
    21 
       
    22 //  EXTERNAL INCLUDES
       
    23 #include <EUnitMacros.h>
       
    24 #include <EUnitDecorators.h>
       
    25 #include <e32base.h>
       
    26 
       
    27 //  INTERNAL INCLUDES
       
    28 //#include "BackgroundImage.cpp"
       
    29 
       
    30 // CONSTANTS
       
    31 _LIT( KGSTestEmptyString, "" );
       
    32 _LIT( KGSTestDestinationPath, "c:\\data\\bin\\test_path");
       
    33 
       
    34 // CONSTRUCTION
       
    35 T_GSBackgroundImage* T_GSBackgroundImage::NewL()
       
    36     {
       
    37     T_GSBackgroundImage* self = T_GSBackgroundImage::NewLC();
       
    38     CleanupStack::Pop();
       
    39 
       
    40     return self;
       
    41     }
       
    42 
       
    43 T_GSBackgroundImage* T_GSBackgroundImage::NewLC()
       
    44     {
       
    45     T_GSBackgroundImage* self = new( ELeave ) T_GSBackgroundImage();
       
    46     CleanupStack::PushL( self );
       
    47 
       
    48     self->ConstructL();
       
    49 
       
    50     return self;
       
    51     }
       
    52 
       
    53 // Destructor (virtual by CBase)
       
    54 T_GSBackgroundImage::~T_GSBackgroundImage()
       
    55     {
       
    56     }
       
    57 
       
    58 // Default constructor
       
    59 T_GSBackgroundImage::T_GSBackgroundImage()
       
    60     {
       
    61     }
       
    62 
       
    63 // Second phase construct
       
    64 void T_GSBackgroundImage::ConstructL()
       
    65     {
       
    66     // The ConstructL from the base class CEUnitTestSuiteClass must be called.
       
    67     // It generates the test case table.
       
    68     CEUnitTestSuiteClass::ConstructL();
       
    69     }
       
    70 
       
    71 //  METHODS
       
    72 
       
    73 
       
    74 void T_GSBackgroundImage::EmptySetupL(  )
       
    75     {
       
    76     }
       
    77 
       
    78 void T_GSBackgroundImage::EmptyTeardown(  )
       
    79 	{
       
    80 	}
       
    81 	
       
    82 void T_GSBackgroundImage::SetupBackgroundImageL()
       
    83     {
       
    84     iFs.Connect();
       
    85     iCGSBackgroundImage = CGSBackgroundImage::NewL();
       
    86     }
       
    87     
       
    88 void T_GSBackgroundImage::SetupBackgroundImageAndAsyncHandlerL()
       
    89     {
       
    90     iFs.Connect();
       
    91     iCGSBackgroundImage = CGSBackgroundImage::NewL();
       
    92     iImgHandler = CGSAsyncImageHandling::NewL( iFs,
       
    93                 this, KGSTestDestinationPath );
       
    94     }
       
    95 
       
    96 void T_GSBackgroundImage::Teardown(  )
       
    97     {
       
    98     if( iCGSBackgroundImage )
       
    99         {
       
   100         delete iCGSBackgroundImage;
       
   101         iCGSBackgroundImage = NULL;
       
   102         }
       
   103     iFs.Close();
       
   104     
       
   105     if( iImgHandler )
       
   106         {
       
   107         iImgHandler->Cancel();
       
   108         delete iImgHandler;
       
   109         iImgHandler = NULL;
       
   110         }
       
   111     }
       
   112     
       
   113 
       
   114 void T_GSBackgroundImage::T_Global_BackgroundImage_NewL(  )
       
   115     {
       
   116     CGSBackgroundImage* image = CGSBackgroundImage::NewL();
       
   117     CleanupStack::PushL( image );
       
   118     EUNIT_ASSERT( image != NULL );
       
   119     CleanupStack::PopAndDestroy( image );
       
   120     }
       
   121     
       
   122 void T_GSBackgroundImage::T_Global_BackgroundImage_GetPlnsStatus()
       
   123     {
       
   124     TInt returnValue;
       
   125     EUNIT_ASSERT_NO_LEAVE( returnValue = iCGSBackgroundImage->GetPlnsStatus() );
       
   126     EUNIT_PRINT( _L("returnValue = %d"), returnValue );
       
   127     }
       
   128 
       
   129 void T_GSBackgroundImage::T_Global_BackgroundImage_BackgroundImageL()
       
   130     {
       
   131     TInt returnValue;
       
   132     EUNIT_ASSERT_NO_LEAVE( returnValue = iCGSBackgroundImage->BackgroundImageL() );
       
   133     EUNIT_PRINT( _L("returnValue = %d"), returnValue );
       
   134     }
       
   135 
       
   136 void T_GSBackgroundImage::T_Global_BackgroundImage_SetBackgroundImageL()
       
   137     {
       
   138     TInt setValue = 1;
       
   139     EUNIT_ASSERT_NO_LEAVE( iCGSBackgroundImage->SetBackgroundImageL( 
       
   140                                                            setValue ) );
       
   141     }
       
   142 
       
   143 void T_GSBackgroundImage::T_Global_BackgroundImage_SetBackgroundImagePathL()
       
   144     {
       
   145     EUNIT_ASSERT_NO_LEAVE( iCGSBackgroundImage->SetBackgroundImagePathL( 
       
   146             KGSTestEmptyString ) );
       
   147     }
       
   148 
       
   149 void T_GSBackgroundImage::T_Global_BackgroundImage_SetBackgroundImagePath2L()
       
   150     {
       
   151     TInt desLenght = 25;
       
   152     RBuf rbuf;
       
   153     rbuf.CreateL( KGSTestDestinationPath );
       
   154     rbuf.CleanupClosePushL();
       
   155     //TBuf<desLenght> destinationPath( KGSTestDestinationPath );
       
   156     EUNIT_ASSERT_NO_LEAVE(iCGSBackgroundImage->SetBackgroundImagePathL( 
       
   157             KGSTestEmptyString, rbuf ) );
       
   158     CleanupStack::PopAndDestroy();
       
   159     }
       
   160 
       
   161 void T_GSBackgroundImage::T_Global_BackgroundImage_SetBackgroundImagePath3L()
       
   162     {
       
   163     TGSWallpaperType wallType = EGSWallpaperIdle;
       
   164     RBuf rbuf;
       
   165     rbuf.CreateL( KGSTestDestinationPath );
       
   166     rbuf.CleanupClosePushL();
       
   167     EUNIT_ASSERT_NO_LEAVE(iCGSBackgroundImage->SetBackgroundImagePathL( 
       
   168             KGSTestEmptyString, rbuf, wallType ) );
       
   169     CleanupStack::PopAndDestroy();
       
   170     }
       
   171 
       
   172 void T_GSBackgroundImage::T_Global_BackgroundImage_CreateImageHandlingAsyncObjectL()
       
   173     {
       
   174     EUNIT_ASSERT_NO_LEAVE( iImgHandler = CGSAsyncImageHandling::NewL( iFs,
       
   175             this, KGSTestDestinationPath ) );
       
   176     }
       
   177 
       
   178 
       
   179 void T_GSBackgroundImage::T_Global_BackgroundImage_SetWelcomeNoteImageL()
       
   180     {
       
   181     EUNIT_ASSERT_NO_LEAVE( iCGSBackgroundImage->
       
   182             SetWelcomeNoteImageL( KGSTestDestinationPath, *iImgHandler ) );
       
   183     }
       
   184 
       
   185 void T_GSBackgroundImage::T_Global_BackgroundImage_SetVtStillImagePathL()
       
   186     {
       
   187     EUNIT_ASSERT_NO_LEAVE( iCGSBackgroundImage->SetVTStillImagePathL( 
       
   188             KGSTestDestinationPath, *iImgHandler ) );
       
   189     }
       
   190 
       
   191 void T_GSBackgroundImage::T_Global_BackgroundImage_IsPersonalisationApplicationL()
       
   192     {
       
   193     EUNIT_ASSERT_NO_LEAVE( iCGSBackgroundImage->
       
   194             IsPersonalisationApplicationL() );
       
   195     }
       
   196 
       
   197 void T_GSBackgroundImage::T_Global_BackgroundImage_DeleteImageL()
       
   198     {
       
   199     EUNIT_ASSERT_LEAVE( iCGSBackgroundImage->
       
   200             DeleteImageL( KGSTestDestinationPath ) );
       
   201     }
       
   202 
       
   203 void T_GSBackgroundImage::ImageHandlingCompleteL( TInt /*aError*/ )
       
   204     {
       
   205     
       
   206     }
       
   207 
       
   208 //  TEST TABLE
       
   209 EUNIT_BEGIN_TEST_TABLE(
       
   210     T_GSBackgroundImage,
       
   211     "Testing BackgroundImage.dll functionality",
       
   212     "UNIT" )
       
   213 
       
   214 EUNIT_TEST(
       
   215     "BackgroundImage - NewL construction", //case description
       
   216     "CGSBackgroundImage",                   //class being tested
       
   217     "NewL",                                 //method being tested
       
   218     "FUNCTIONALITY",                        //FUNCTIONALITY, BOUNDARY, ERRORHANDLING
       
   219     EmptySetupL, T_Global_BackgroundImage_NewL, EmptyTeardown )
       
   220 
       
   221 EUNIT_TEST(
       
   222     "BackgroundImage - GetPlnsStatus()",
       
   223     "CGSBackgroundImage",                
       
   224     "GetPlnsStatus",                     
       
   225     "FUNCTIONALITY",                     
       
   226     SetupBackgroundImageL, T_Global_BackgroundImage_GetPlnsStatus, Teardown )    
       
   227 
       
   228 EUNIT_TEST(
       
   229     "BackgroundImage - BackgroundImage()",
       
   230     "CGSBackgroundImage",                
       
   231     "BackgroundImage",                     
       
   232     "FUNCTIONALITY",                     
       
   233     SetupBackgroundImageL, T_Global_BackgroundImage_BackgroundImageL, Teardown )
       
   234     
       
   235 EUNIT_TEST(
       
   236     "BackgroundImage - SetBackgroundImageL()",
       
   237     "CGSBackgroundImage",                
       
   238     "SetBackgroundImageL",                     
       
   239     "FUNCTIONALITY",                     
       
   240     SetupBackgroundImageL, T_Global_BackgroundImage_SetBackgroundImageL, Teardown )
       
   241     
       
   242 EUNIT_TEST(
       
   243     "BackgroundImage - SetBackgroundImagePathL()",
       
   244     "CGSBackgroundImage",                
       
   245     "SetBackgroundImagePathL",                     
       
   246     "FUNCTIONALITY",                     
       
   247     SetupBackgroundImageL, T_Global_BackgroundImage_SetBackgroundImagePathL, Teardown )
       
   248     
       
   249 EUNIT_TEST(
       
   250     "BackgroundImage - SetBackgroundImagePath2L()",
       
   251     "CGSBackgroundImage",                
       
   252     "Overloaded version of SetBackgroundImagePathL",                     
       
   253     "FUNCTIONALITY",                     
       
   254     SetupBackgroundImageL, T_Global_BackgroundImage_SetBackgroundImagePath2L, Teardown ) 
       
   255     
       
   256 EUNIT_TEST(
       
   257     "BackgroundImage - SetBackgroundImagePath3L()",
       
   258     "CGSBackgroundImage",                
       
   259     "Second overloaded version of SetBackgroundImagePathL",                     
       
   260     "FUNCTIONALITY",                     
       
   261     SetupBackgroundImageL, T_Global_BackgroundImage_SetBackgroundImagePath3L, Teardown )
       
   262     
       
   263 EUNIT_TEST(
       
   264     "BackgroundImage - IsPersonalisationApplicationL()",
       
   265     "CGSBackgroundImage",                
       
   266     "IsPersonalisationApplicationL",                     
       
   267     "FUNCTIONALITY",                     
       
   268     SetupBackgroundImageL, 
       
   269         T_Global_BackgroundImage_IsPersonalisationApplicationL, Teardown )
       
   270         
       
   271 EUNIT_TEST(
       
   272     "BackgroundImage - DeleteImageL()",
       
   273     "CGSBackgroundImage",                
       
   274     "DeleteImageL",                     
       
   275     "FUNCTIONALITY",                     
       
   276     SetupBackgroundImageL, T_Global_BackgroundImage_DeleteImageL, Teardown )        
       
   277     
       
   278 EUNIT_TEST(
       
   279     "BackgroundImage - Creation of AsyncImageHandler()",
       
   280     "CGSAsyncImageHandling",                
       
   281     "NewL",                     
       
   282     "FUNCTIONALITY",                     
       
   283     SetupBackgroundImageL, 
       
   284         T_Global_BackgroundImage_CreateImageHandlingAsyncObjectL, Teardown ) 
       
   285 
       
   286 EUNIT_TEST(
       
   287     "BackgroundImage - SetWelcomeNoteImageL()",
       
   288     "CGSBackgroundImage",                
       
   289     "SetWelcomeNoteImageL",                     
       
   290     "FUNCTIONALITY",                     
       
   291     SetupBackgroundImageAndAsyncHandlerL, 
       
   292         T_Global_BackgroundImage_SetWelcomeNoteImageL, Teardown )
       
   293         
       
   294 EUNIT_TEST(
       
   295     "BackgroundImage - SetVtStillImagePathL()",
       
   296     "CGSBackgroundImage",                
       
   297     "SetVtStillImagePathL",                     
       
   298     "FUNCTIONALITY",                     
       
   299     SetupBackgroundImageAndAsyncHandlerL, 
       
   300         T_Global_BackgroundImage_SetVtStillImagePathL, Teardown )      
       
   301         
       
   302 EUNIT_END_TEST_TABLE
       
   303 
       
   304 //  END OF FILE