camerasrv_plat/camera_application_engine_api/tsrc/src/TestFrameWork/TestSuite.cpp
branchRCL_3
changeset 20 e3cdd00b5ae3
parent 19 18fa9327a158
child 21 27fe719c32e6
equal deleted inserted replaced
19:18fa9327a158 20:e3cdd00b5ae3
     1 /*
       
     2 * Copyright (c) 2002 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: TestSuite.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "TestFrameWork/testSuite.h"
       
    21 #include <StifTestModule.h>
       
    22 
       
    23 
       
    24 CTestSuite* CTestSuite::NewLC (const TDesC8& aName)
       
    25     {
       
    26     CTestSuite* self=new(ELeave) CTestSuite();
       
    27     CleanupStack::PushL(self);
       
    28     self->ConstructL(aName);
       
    29     return self;
       
    30     }
       
    31 
       
    32 
       
    33 CTestSuite* CTestSuite::NewL (const TDesC8& aName)
       
    34     {
       
    35     CTestSuite* self=NewLC(aName);
       
    36     CleanupStack::Pop();
       
    37     return self;
       
    38     }
       
    39 
       
    40 
       
    41 void CTestSuite::ConstructL (const TDesC8& aName)
       
    42     {
       
    43     iName = aName.AllocL();
       
    44     }
       
    45 
       
    46 
       
    47 CTestSuite::~CTestSuite () 
       
    48     {
       
    49     iTests.ResetAndDestroy();
       
    50     delete iName;
       
    51     }
       
    52 
       
    53 
       
    54 void CTestSuite::addTestL (MTest* aTest)
       
    55     {
       
    56     User::LeaveIfError (iTests.Append(aTest));
       
    57     }
       
    58 
       
    59 
       
    60 // Runs the tests and collects their result in a TestResult.
       
    61 // Deprecated.
       
    62 // Version with index should be used instead.
       
    63 
       
    64 void CTestSuite::ExecuteL (TTestResult& aResult)
       
    65     {
       
    66     for (TInt i=0; i < iTests.Count(); i++)
       
    67         {
       
    68         iTests[i]->ExecuteL(aResult);
       
    69         }
       
    70     }
       
    71 
       
    72 
       
    73 // Counts the number of test cases that will be run by this test.
       
    74 TInt CTestSuite::CountTestCases ()
       
    75     {
       
    76     TInt count = 0;
       
    77     for (TInt i=0; i < iTests.Count(); i++)
       
    78         {
       
    79         count += iTests[i]->CountTestCases ();
       
    80         }
       
    81     return count;
       
    82     }
       
    83 
       
    84 
       
    85 const TDesC8& CTestSuite::Name ()
       
    86     {
       
    87     return *iName;
       
    88     }
       
    89 
       
    90 #if 1
       
    91 void CTestSuite::ExecuteTestL(TTestResult& aResult,
       
    92                               TInt aIndex)
       
    93     { 
       
    94     for (TInt i=0; i< iTests.Count(); i++)
       
    95         {
       
    96         TInt count = iTests[i]->CountTestCases();
       
    97         if ( aIndex > ( count - 1 ) )
       
    98             {
       
    99             aIndex -= count;
       
   100             }
       
   101         else
       
   102             {
       
   103             iTests[i]->ExecuteTestL(aResult, aIndex);
       
   104             return ;
       
   105             }
       
   106         }
       
   107     }
       
   108 
       
   109 const TDesC8& CTestSuite::TestCaseName (TInt aIndex)
       
   110     {
       
   111     for (TInt i=0; i< iTests.Count(); i++)
       
   112         {
       
   113         TInt count = iTests[i]->CountTestCases();
       
   114         if ( aIndex > ( count - 1 ) )
       
   115             {
       
   116             aIndex -= count;
       
   117             }
       
   118         else
       
   119             {
       
   120             return ( iTests[i]->TestCaseName(aIndex) ) ;
       
   121             }
       
   122         }
       
   123     // It's an error if we reached that point.
       
   124     return(KNullDesC8);
       
   125     }
       
   126 #endif