imagingext_pub/exif_api/tsrc/src/ExifLibTestStif.cpp
changeset 0 469c91dae73b
equal deleted inserted replaced
-1:000000000000 0:469c91dae73b
       
     1 /*
       
     2 * Copyright (c) 2003-2006 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:  Exif Library Test DLL
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 
       
    23 #include "ExifLibTestStif.h"
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =========================================
       
    26 
       
    27 
       
    28 CTestModule::CTestModule()
       
    29     {
       
    30     }
       
    31 
       
    32 
       
    33 void CTestModule::ConstructL()
       
    34     {  
       
    35     iTestSuite = CTestSuite::NewL( _L8( "ExifLibTest" ) );
       
    36 
       
    37     iTestSuite->addTestL( CExifLibTestInc::suiteL() );
       
    38 
       
    39      /* Install an active scheduler */
       
    40     iScheduler = new(ELeave)CActiveScheduler;
       
    41     CActiveScheduler::Install(iScheduler);
       
    42 
       
    43     }
       
    44 
       
    45 
       
    46 CTestModule* CTestModule::NewL()
       
    47     {
       
    48 
       
    49     // Construct new CTestModule instance.
       
    50     CTestModule* self = new ( ELeave ) CTestModule();    
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop();
       
    54 
       
    55     return self;
       
    56   
       
    57     }
       
    58 
       
    59 
       
    60 CTestModule::~CTestModule()
       
    61     {
       
    62     delete iTestSuite;
       
    63     delete iScheduler;
       
    64     }
       
    65 
       
    66 
       
    67 EXPORT_C TInt SetRequirements( CTestModuleParam*& aTestModuleParam, 
       
    68                                 TUint32& aParameterValid )
       
    69     {
       
    70 
       
    71     /* --------------------------------- NOTE ---------------------------------
       
    72     USER PANICS occurs in test thread creation when:
       
    73 	1) "The panic occurs when the value of the stack size is negative."
       
    74     2) "The panic occurs if the minimum heap size specified is less
       
    75        than KMinHeapSize".
       
    76        KMinHeapSize: "Functions that require a new heap to be allocated will
       
    77        either panic, or will reset the required heap size to this value if
       
    78        a smaller heap size is specified".
       
    79     3) "The panic occurs if the minimum heap size specified is greater than
       
    80        the maximum size to which the heap can grow".
       
    81     Other:
       
    82     1) Make sure that your hardware or Symbian OS is supporting given sizes.
       
    83        e.g. Hardware might support only sizes that are divisible by four.
       
    84     ------------------------------- NOTE end ------------------------------- */
       
    85 
       
    86     // Normally STIF uses default heap and stack sizes for test thread, see:
       
    87     // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
       
    88     // If needed heap and stack sizes can be configured here by user. Remove
       
    89     // comments and define sizes.
       
    90 
       
    91 
       
    92     aParameterValid = KStifTestModuleParameterChanged;
       
    93 
       
    94     CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
       
    95     // Stack size
       
    96     param->iTestThreadStackSize= 2*16384; // 2*16K stack
       
    97     // Heap sizes
       
    98     param->iTestThreadMinHeap = 4096;   // 4K heap min
       
    99     param->iTestThreadMaxHeap = 8*1048576;// 8M heap max
       
   100 
       
   101     aTestModuleParam = param;
       
   102 
       
   103     return KErrNone;
       
   104 
       
   105     }
       
   106 
       
   107 
       
   108 
       
   109 /*
       
   110 -------------------------------------------------------------------------------
       
   111 
       
   112     Class: CTestModule
       
   113 
       
   114     Method: GetTestCases
       
   115 
       
   116     Description: GetTestCases is used to inquire test cases 
       
   117     from the test module. Because this test module have hard coded test cases
       
   118     (i.e cases are not read from file), paramter aConfigFile is not used.
       
   119 
       
   120     This function loops through all cases defined in Cases() function and 
       
   121     adds corresponding items to aTestCases array.
       
   122 
       
   123     Parameters: const TFileName&  : in: Configuration file name. Not used                                                       
       
   124                 RPointerArray<TTestCaseInfo>& aTestCases: out: 
       
   125                       Array of TestCases.
       
   126     
       
   127     Return Values: KErrNone: No error
       
   128 
       
   129     Errors/Exceptions: Function leaves if any memory allocation operation fails
       
   130 
       
   131     Status: Proposal
       
   132     
       
   133 -------------------------------------------------------------------------------
       
   134 */      
       
   135 TInt CTestModule::GetTestCasesL( const TFileName& /*aConfigFile*/, 
       
   136                                      RPointerArray<TTestCaseInfo>& aTestCases )
       
   137     {
       
   138 
       
   139     // Loop through all test cases and create new
       
   140     // TTestCaseInfo items and append items to aTestCase array    
       
   141     for( TInt i = 0; i< iTestSuite->CountTestCases(); i++ )
       
   142         {
       
   143  
       
   144 	    // Allocate new TTestCaseInfo from heap for a testcase definition.
       
   145         TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
       
   146     
       
   147 	    // PushL TTestCaseInfo to CleanupStack.    
       
   148         CleanupStack::PushL( newCase );
       
   149 
       
   150 	    // Set number for the testcase.
       
   151 	    // When the testcase is run, this comes as a parameter to RunTestCaseL.
       
   152         newCase->iCaseNumber = i;
       
   153 
       
   154 	    // Set title for the test case. This is shown in UI to user.
       
   155         newCase->iTitle.Copy( iTestSuite->TestCaseName(i) );
       
   156 
       
   157 	    // Append TTestCaseInfo to the testcase array. After appended 
       
   158 	    // successfully the TTestCaseInfo object is owned (and freed) 
       
   159 	    // by the TestServer. 
       
   160         User::LeaveIfError(aTestCases.Append ( newCase ) );
       
   161         
       
   162 	    // Pop TTestCaseInfo from the CleanupStack.
       
   163         CleanupStack::Pop( newCase );
       
   164 
       
   165         }
       
   166     
       
   167     return KErrNone;
       
   168   
       
   169     }
       
   170 
       
   171 /*
       
   172 -------------------------------------------------------------------------------
       
   173 
       
   174     Class: CTestModule
       
   175 
       
   176     Method: RunTestCase
       
   177 
       
   178     Description: Run a specified testcase.
       
   179 
       
   180     Function runs a test case specified by test case number. Test case file
       
   181     parameter is not used.
       
   182 
       
   183     If case number is valid, this function runs a test case returned by
       
   184     function Cases(). 
       
   185   
       
   186     Parameters: const TInt aCaseNumber: in: Testcase number 
       
   187                 const TFileName& : in: Configuration file name. Not used
       
   188                 TTestResult& aResult: out: Testcase result
       
   189     
       
   190     Return Values: KErrNone: Testcase ran.
       
   191                    KErrNotFound: Unknown testcase
       
   192 
       
   193     Errors/Exceptions: None
       
   194     
       
   195     Status: Proposal
       
   196     
       
   197 -------------------------------------------------------------------------------
       
   198 */
       
   199 TInt CTestModule::RunTestCaseL( const TInt aCaseNumber, 
       
   200                                     const TFileName& /*aConfig*/,
       
   201                                     TTestResult& aResult )
       
   202     {
       
   203 
       
   204     // Return value
       
   205     TInt execStatus = KErrNone;
       
   206     iTestSuite->ExecuteTestL(aResult, aCaseNumber);
       
   207 
       
   208     // Return case execution status (not the result of the case execution)
       
   209     return execStatus;
       
   210       
       
   211     }
       
   212     
       
   213 
       
   214 // ================= OTHER EXPORTED FUNCTIONS =================================
       
   215 
       
   216 /*
       
   217 -------------------------------------------------------------------------------
       
   218    
       
   219     Function: LibEntryL
       
   220 
       
   221     Description: Polymorphic Dll Entry Point
       
   222     
       
   223     Test framework calls this function to obtain new instance of test module
       
   224     class. 
       
   225 
       
   226     Parameters:    None
       
   227     
       
   228     Return Values: CTestModule*    Pointer to CTestModule instance
       
   229     
       
   230     Errors/Exceptions: Leaves if CTestModule::NewL leaves
       
   231     
       
   232     Status: Approved
       
   233 
       
   234 -------------------------------------------------------------------------------
       
   235 */
       
   236 EXPORT_C CTestModule* LibEntryL()
       
   237     {
       
   238     return CTestModule::NewL();
       
   239 
       
   240     }
       
   241 
       
   242