widgetmanager/tsrc/wmunittest/inc/wmunittest.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2009 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: STIF testclass declaration
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef WMUNITTEST_H
       
    19 #define WMUNITTEST_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <stiflogger.h>
       
    23 #include <testscripterinternal.h>
       
    24 #include <stiftestmodule.h>
       
    25 #include <testclassassert.h>
       
    26 #include <s32file.h> // RFs
       
    27 
       
    28 #include "wmimageconverter.h" // MConverterObserver
       
    29 #include <hscontentcontroller.h>
       
    30 
       
    31 // MACROS
       
    32 #define TEST_CLASS_VERSION_MAJOR 0
       
    33 #define TEST_CLASS_VERSION_MINOR 0
       
    34 #define TEST_CLASS_VERSION_BUILD 0
       
    35 
       
    36 // MACROS FOR THE TEST CASES
       
    37 #define _LOG(a) iLog->Log(_L(a))
       
    38 #define _RETURN(a, b) iLog->Log(_L("\treturn: %d"),b); \
       
    39                      iLog->Log(_L(a)); \
       
    40                      return b; \
       
    41 
       
    42 #define _CLEANUPCHECK_BEGIN \
       
    43     CBase* __check = new (ELeave) CBase(); \
       
    44     CleanupStack::PushL( __check );
       
    45 
       
    46 #define _CLEANUPCHECK_END \
       
    47     CleanupStack::PopAndDestroy( __check );
       
    48 
       
    49 
       
    50 // Logging path & file
       
    51 _LIT( KWmUnitTestLogPath, "\\logs\\testframework\\wmunittest\\" ); 
       
    52 _LIT( KWmUnitTestLogFile, "wmunittest.txt" ); 
       
    53 
       
    54 // FORWARD DECLARATIONS
       
    55 class CWmPlugin;
       
    56 class CWmPersistentWidgetOrder;
       
    57 class CWmImageConverter;
       
    58 class CHsContentInfo;
       
    59 class CHsContentInfoArray;
       
    60 class RWidgetDataValues;
       
    61 
       
    62 
       
    63 // CLASS DECLARATION
       
    64 /**
       
    65 *  test class for STIF Test Framework TestScripter.
       
    66 */
       
    67 NONSHARABLE_CLASS(CWmUnitTest) : public CScriptBase,
       
    68                                  public MConverterObserver,
       
    69                                  public MHsContentController
       
    70     {
       
    71     public: // Constructors and destructor
       
    72         /** static constructor */
       
    73         static CWmUnitTest* NewL( CTestModuleIf& aTestModuleIf );
       
    74         /** desctructor */
       
    75         ~CWmUnitTest();
       
    76 
       
    77     private: // private stuff
       
    78         /** default constructor */
       
    79         CWmUnitTest( CTestModuleIf& aTestModuleIf );
       
    80         /** 2nd phase constructor */
       
    81         void ConstructL();
       
    82         /** version check */
       
    83         void SendTestClassVersion();
       
    84 
       
    85     public: // Test run API
       
    86 
       
    87         /** From CScriptBase Runs a script line. */
       
    88         virtual TInt RunMethodL( CStifItemParser& aItem );
       
    89     
       
    90     public: // from MConverterObserver
       
    91 
       
    92         virtual void NotifyCompletion( TInt aError );
       
    93 
       
    94     public: // from MHsContentController
       
    95 
       
    96         TInt WidgetListL( CHsContentInfoArray& aArray );
       
    97         TInt ViewListL( CHsContentInfoArray& aArray );
       
    98         TInt AppListL( CHsContentInfoArray& aArray );
       
    99         TInt AddWidgetL( CHsContentInfo& aInfo );
       
   100         TInt RemoveWidgetL( CHsContentInfo& aInfo );
       
   101         TInt AddViewL( CHsContentInfo& aInfo );
       
   102         TInt RemoveViewL( CHsContentInfo& aInfo );
       
   103         TInt ActivateViewL( CHsContentInfo& aInfo );
       
   104         TInt ActivateAppL( CHsContentInfo& aInfo );
       
   105         
       
   106     private: // Test methods
       
   107 
       
   108         // GENERAL
       
   109         
       
   110         // sets heap reference value
       
   111         TInt HeapSetL( CStifItemParser& aItem );
       
   112         // Log heap usage to file
       
   113         TInt LogHeapL( CStifItemParser& aItem );
       
   114         // compares heap against reference, logs warning if no match
       
   115         TInt HeapCheckL( CStifItemParser& aItem );
       
   116         // sets the mass of data for next test case
       
   117         TInt SetMassL( CStifItemParser& aItem );
       
   118 		// install and uninstall wrt widget for tests
       
   119 		TInt InstallWrtWidgetL( CStifItemParser& aItem );
       
   120 		TInt UninstallWrtWidgetL( CStifItemParser& aItem );
       
   121 		// test error note
       
   122 		TInt ErrorPopupL( CStifItemParser& aItem );
       
   123 		
       
   124         // TESTING THE PLUGIN
       
   125         
       
   126         // creates the WM plugin
       
   127         TInt PluginCreateL( CStifItemParser& aItem );
       
   128         // deletes WM plugin
       
   129         TInt PluginDeleteL( CStifItemParser& aItem );        
       
   130         // calls Activate method for WM plugin
       
   131         TInt PluginActivateL( CStifItemParser& aItem );
       
   132         // calls Deactivate method for WM plugin
       
   133         TInt PluginDeactivateL( CStifItemParser& aItem );
       
   134         // calls NotifyWidgetListChanged method for WM plugin
       
   135         TInt PluginWidgetsChangedL( CStifItemParser& aItem );
       
   136 
       
   137         // TESTING THE WIDGET SORTING AND ORDER
       
   138         
       
   139         // creates WM persistent widget order object
       
   140         TInt WidgetOrderCreateL( CStifItemParser& aItem );
       
   141         // deletes WM persistent widget order object
       
   142         TInt WidgetOrderDeleteL( CStifItemParser& aItem );
       
   143         // tests WM persistent widget order's LOAD method
       
   144         TInt WidgetOrderLoadL( CStifItemParser& aItem );
       
   145         // tests WM persistent widget order's SAVE method
       
   146         TInt WidgetOrderSaveL( CStifItemParser& aItem );
       
   147         // tests WM persistent widget order's SAVE method
       
   148         TInt WidgetOrderCheckIsEmptyL( CStifItemParser& aItem );
       
   149         // calls WM persistent widget order's API methods
       
   150         TInt WidgetOrderUseL( CStifItemParser& aItem );
       
   151 
       
   152         // TESTING IMAGE CONVERSION ROUTINES
       
   153        
       
   154         // creates image converter object
       
   155         TInt ImageConverterCreateL( CStifItemParser& aItem );
       
   156         // deletes image converter object
       
   157         TInt ImageConverterDeleteL( CStifItemParser& aItem );
       
   158         // calls image converter's main conversion method
       
   159         TInt ImageConverterConvertL( CStifItemParser& aItem );
       
   160         // checks image converter callback and checks its result
       
   161         TInt ImageConverterWaitResultL( CStifItemParser& aItem );
       
   162         // gets and checks the conversion method from image converter
       
   163         TInt ImageConverterConversionMethodL( CStifItemParser& aItem );
       
   164         // cancel ongoing convert
       
   165         TInt CancelConvertL( CStifItemParser& aItem );
       
   166 
       
   167 
       
   168     private: // members used in testing
       
   169 
       
   170         void CreateContentInfoArrayL( CHsContentInfoArray& aArray, TInt aCount );
       
   171         void CreateWidgetDataArrayL( RWidgetDataValues& aArray, TInt aCount );
       
   172 
       
   173         // file server
       
   174         RFs iFs;
       
   175 
       
   176         // the WM plugin instance
       
   177         CWmPlugin* iWmPlugin;
       
   178 
       
   179         // the WM persistent widget order instance
       
   180         CWmPersistentWidgetOrder* iWmWidgetOrder;
       
   181 
       
   182         // the Image converter instance
       
   183         CWmImageConverter* iImageConverter;
       
   184         
       
   185         // amount of heap allocated in HeapSet
       
   186         TInt iHeapSize;
       
   187         
       
   188         // image converter response ready
       
   189         TBool iConversionReady;
       
   190         
       
   191         // image converter result
       
   192         TInt iConversionError;
       
   193         
       
   194         // switch for active schedular wait
       
   195         TBool iWaiting;
       
   196 
       
   197         // multipurpose test data count
       
   198         TInt iMass;
       
   199 
       
   200     };
       
   201 
       
   202 
       
   203 #endif      // WMUNITTEST_H
       
   204 
       
   205 // End of File