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