appinstall_plat/sifui_api/tsrc/inc/sifuitest.h
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 /*
       
     2 * Copyright (c) 2010 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 hardcoded module declaration
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef SIFUITEST_H
       
    19 #define SIFUITEST_H
       
    20 
       
    21 #include <StifTestModule.h>             // CTestModuleBase
       
    22 #include <StifLogger.h>                 // CStifLogger
       
    23 #include <w32std.h>                     // TKeyEvent
       
    24 
       
    25 
       
    26 // Definitions defined in STIF test module template
       
    27 #define TEST_MODULE_VERSION_MAJOR 0
       
    28 #define TEST_MODULE_VERSION_MINOR 0
       
    29 #define TEST_MODULE_VERSION_BUILD 0
       
    30 
       
    31 _LIT( KSifUiTestLogPath, "\\logs\\testframework\\SifUiTest\\" );
       
    32 _LIT( KSifUiTestLogFile, "SifUiTest.txt" );
       
    33 _LIT( KSifUiTestLogFileWithTitle, "SifUiTest_[%S].txt" );
       
    34 
       
    35 #define GETPTR &
       
    36 #define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
       
    37 #define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
       
    38 #define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
       
    39 #define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
       
    40 
       
    41 class CX509Certificate;
       
    42 class CSifUiTest;
       
    43 class CSifUi;
       
    44 
       
    45 // Pointer to test function (that does the actual testing) type definition
       
    46 typedef TInt (CSifUiTest::* TestFunction)(TTestResult&);
       
    47 
       
    48 // Structure containing test case name and pointer to test function
       
    49 class TCaseInfo
       
    50     {
       
    51     public:
       
    52         TPtrC           iCaseName;
       
    53         TestFunction    iMethod;
       
    54         TBool           iIsOOMTest;
       
    55         TInt            iFirstMemoryAllocation;
       
    56         TInt            iLastMemoryAllocation;
       
    57 
       
    58     TCaseInfo( const TDesC& aDes ) : iCaseName( aDes )
       
    59         {
       
    60         };
       
    61     };
       
    62 
       
    63 
       
    64 
       
    65 /**
       
    66  *  SifUiTest class.
       
    67  *
       
    68  */
       
    69 NONSHARABLE_CLASS(CSifUiTest) : public CTestModuleBase
       
    70     {
       
    71     public:     // constructors and destructor
       
    72         static CSifUiTest* NewL();
       
    73         ~CSifUiTest();
       
    74 
       
    75     public:     // from CTestModuleBase
       
    76         /**
       
    77         * InitL is used to initialize the test module.
       
    78         * @param aIniFile Initialization file for the test module (optional)
       
    79         * @param aFirstTime Flag is true when InitL is executed for first
       
    80         *   created instance of CSifUiTest.
       
    81         * @return Symbian OS error code
       
    82         */
       
    83         TInt InitL( TFileName& aIniFile, TBool aFirstTime );
       
    84 
       
    85         /**
       
    86         * GetTestCasesL is used to inquiry test cases.
       
    87         * @param aTestCaseFile Test case file (optional)
       
    88         * @param aTestCases  Array of TestCases returned to test framework
       
    89         * @return Symbian OS error code
       
    90         */
       
    91         TInt GetTestCasesL( const TFileName& aTestCaseFile,
       
    92                             RPointerArray<TTestCaseInfo>& aTestCases );
       
    93 
       
    94         /**
       
    95         * RunTestCaseL is used to run an individual test case.
       
    96         * @param aCaseNumber Test case number
       
    97         * @param aTestCaseFile Test case file (optional)
       
    98         * @param aResult Test case result returned to test framework (PASS/FAIL)
       
    99         * @return Symbian OS error code (test case execution error, which is
       
   100         *   not reported in aResult parameter as test case failure).
       
   101         */
       
   102         TInt RunTestCaseL( const TInt aCaseNumber,
       
   103                            const TFileName& aTestCaseFile,
       
   104                            TTestResult& aResult );
       
   105 
       
   106         /**
       
   107          * Method used to log version of test module
       
   108          */
       
   109         void SendTestModuleVersion();
       
   110 
       
   111     private:
       
   112         CSifUiTest();
       
   113         void ConstructL();
       
   114 
       
   115         /**
       
   116         * Function returning test case name and pointer to test case function.
       
   117         * @param aCaseNumber test case number
       
   118         * @return TCaseInfo
       
   119         */
       
   120         const TCaseInfo Case ( const TInt aCaseNumber ) const;
       
   121 
       
   122         /**
       
   123          * Helper function that returns aErrorCode as string.
       
   124          * @param aErrorCode - Symbian OS error code
       
   125          * @return name of the error code
       
   126          */
       
   127         TPtrC ErrorCodeString( TInt aErrorCode ) const;
       
   128 
       
   129         /**
       
   130          * Helper function that sets aReturnCode result to aResult.
       
   131          * @param aResult - test case result to be set
       
   132          * @param aReturnCode - Symbian OS error code
       
   133          */
       
   134         void SetResult( TTestResult& aResult, const TInt aReturnCode ) const;
       
   135 
       
   136         /**
       
   137          * Helper function that sends key event after given time delay.
       
   138          * Note that this function returns immediately, but it still sends
       
   139          * the key event after given delay.
       
   140          * @param aDelay - time to wait in microseconds
       
   141          * @param aKey - key event to send
       
   142          */
       
   143         void AsyncWaitAndSendKeyEventL( TTimeIntervalMicroSeconds32 aDelay,
       
   144                 const TKeyEvent& aKeyEvent ) const;
       
   145 
       
   146         /**
       
   147          * Helper function to create Swi::CCertificateInfo objects.
       
   148          */
       
   149         CX509Certificate* ReadCertificateL( const TDesC& aFileName );
       
   150 
       
   151 
       
   152         // --- TEST CASE FUNCTIONS ---
       
   153 
       
   154         /**
       
   155          * Creates CSifUi objects in very low-memory until create succeeds.
       
   156          * @param aResult - test case result (PASS/FAIL)
       
   157          * @return Symbian OS error code (other than test result)
       
   158          */
       
   159         TInt CreateLowMemTest( TTestResult& aResult );
       
   160 
       
   161         /**
       
   162          * Run drive selection test case.
       
   163          * @param aResult - test case result (PASS/FAIL)
       
   164          * @return Symbian OS error code (other than test result)
       
   165          */
       
   166         TInt MemorySelectionTest( TTestResult& aResult );
       
   167 
       
   168         /**
       
   169          * Helper function for MemorySelectionTest()
       
   170          */
       
   171         void DoMemorySelectionTestL( TTestResult& aResult );
       
   172 
       
   173         /**
       
   174          * Run certificate info test case.
       
   175          * @param aResult - test case result (PASS/FAIL)
       
   176          * @return Symbian OS error code (other than test result)
       
   177          */
       
   178         TInt CertificateInfoTest( TTestResult& aResult );
       
   179 
       
   180         /**
       
   181          * Helper function for CertificateInfoTest()
       
   182          */
       
   183         void DoCertificateInfoTestL( TTestResult& aResult );
       
   184 
       
   185         /**
       
   186          * Run application info test case.
       
   187          * @param aResult - test case result (PASS/FAIL)
       
   188          * @return Symbian OS error code (other than test result)
       
   189          */
       
   190         TInt AppInfoTest( TTestResult& aResult );
       
   191 
       
   192         /**
       
   193          * Helper function for AppInfoTest()
       
   194          */
       
   195         void DoAppInfoTestL( TTestResult& aResult );
       
   196         
       
   197         /**
       
   198          * Run progress dialogs test case.
       
   199          * @param aResult - test case result (PASS/FAIL)
       
   200          * @return Symbian OS error code (other than test result)
       
   201          */
       
   202         TInt ProgressDialogsTest( TTestResult& aResult );
       
   203 
       
   204         /**
       
   205          * Helper function for ProgressDialogsTest()
       
   206          */
       
   207         void DoProgressDialogsTestL( TTestResult& aResult );
       
   208 
       
   209     private:        // data
       
   210         TestFunction iMethod;
       
   211         CStifLogger* iLog;
       
   212         CStifLogger* iStdLog;
       
   213         CStifLogger* iTCLog;
       
   214         TBool iAddTestCaseTitleToLogName;
       
   215         TBool iVersionLogged;
       
   216         RFs iFs;
       
   217         CActiveScheduler* iScheduler;
       
   218     };
       
   219 
       
   220 #endif      // SIFUITEST_H
       
   221