253
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file testcasefactory.cpp
|
|
15 |
// @internalComponent
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
#include "TestCaseFactory.h"
|
|
20 |
#include "testdevicebase.h"
|
253
|
21 |
#include "OstTraceDefinitions.h"
|
|
22 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
23 |
#include "TestCaseFactoryTraces.h"
|
|
24 |
#endif
|
0
|
25 |
#include <e32debug.h>
|
|
26 |
|
|
27 |
namespace NUnitTesting_USBDI
|
|
28 |
{
|
|
29 |
|
|
30 |
RTestFactory& RTestFactory::Instance()
|
|
31 |
{
|
253
|
32 |
OstTraceFunctionEntry1( RTESTFACTORY_INSTANCE_ENTRY, 0 );
|
0
|
33 |
static RTestFactory singleton;
|
253
|
34 |
OstTraceFunctionExitExt( RTESTFACTORY_INSTANCE_EXIT, 0, ( TUint )&( singleton ) );
|
0
|
35 |
return singleton;
|
|
36 |
}
|
|
37 |
|
|
38 |
RTestFactory::~RTestFactory()
|
|
39 |
{
|
253
|
40 |
OstTraceFunctionEntry1( RTESTFACTORY_RTESTFACTORY_ENTRY, this );
|
|
41 |
OstTraceFunctionExit1( RTESTFACTORY_RTESTFACTORY_EXIT, this );
|
0
|
42 |
}
|
|
43 |
|
|
44 |
|
|
45 |
RTestFactory::RTestFactory()
|
|
46 |
: iTestCases(TStringIdentity::Hash,TStringIdentity::Id)
|
|
47 |
{
|
253
|
48 |
OstTraceFunctionEntry1( RTESTFACTORY_RTESTFACTORY_ENTRY_DUP01, this );
|
|
49 |
OstTraceFunctionExit1( RTESTFACTORY_RTESTFACTORY_EXIT_DUP01, this );
|
0
|
50 |
}
|
|
51 |
|
|
52 |
void RTestFactory::RegisterTestCase(const TDesC& aTestCaseId,TBaseTestCaseFunctor const* aFunctor)
|
|
53 |
{
|
253
|
54 |
OstTraceFunctionEntryExt( RTESTFACTORY_REGISTERTESTCASE_ENTRY, 0 );
|
0
|
55 |
|
|
56 |
LOG_INFO((_L("Registering test case '%S'"),&aTestCaseId))
|
|
57 |
|
|
58 |
TStringIdentity key(aTestCaseId);
|
|
59 |
TInt err(Instance().iTestCases.Insert(key,aFunctor));
|
|
60 |
if(err != KErrNone)
|
|
61 |
{
|
|
62 |
// Log that a test case could not be registered due to err
|
253
|
63 |
OstTraceExt1(TRACE_NORMAL, RTESTFACTORY_REGISTERTESTCASE, "Test case '%S' could not be registered with test case factory",aTestCaseId);
|
0
|
64 |
}
|
253
|
65 |
OstTraceFunctionExit1( RTESTFACTORY_REGISTERTESTCASE_EXIT, 0 );
|
0
|
66 |
}
|
|
67 |
|
|
68 |
|
|
69 |
CBaseTestCase* RTestFactory::CreateTestCaseL(const TDesC& aTestCaseId,TBool aHostRole)
|
|
70 |
{
|
253
|
71 |
OstTraceFunctionEntryExt( RTESTFACTORY_CREATETESTCASEL_ENTRY, 0 );
|
0
|
72 |
|
|
73 |
TStringIdentity key(aTestCaseId);
|
|
74 |
const TBaseTestCaseFunctor& functor = *(*Instance().iTestCases.Find(key));
|
|
75 |
return functor(aHostRole);
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
void RTestFactory::ListRegisteredTestCases()
|
|
80 |
{
|
253
|
81 |
OstTraceFunctionEntry1( RTESTFACTORY_LISTREGISTEREDTESTCASES_ENTRY, 0 );
|
0
|
82 |
RFactoryMap::TIter it(Instance().iTestCases);
|
|
83 |
|
253
|
84 |
OstTrace0(TRACE_NORMAL, RTESTFACTORY_LISTREGISTEREDTESTCASES, "-------- F A C T O R Y ---------");
|
0
|
85 |
|
|
86 |
TInt count(0);
|
|
87 |
for(count=0; count<Instance().iTestCases.Count(); count++)
|
|
88 |
{
|
253
|
89 |
OstTrace1(TRACE_NORMAL, RTESTFACTORY_LISTREGISTEREDTESTCASES_DUP01, "%d",count);
|
0
|
90 |
}
|
|
91 |
|
253
|
92 |
OstTrace0(TRACE_NORMAL, RTESTFACTORY_LISTREGISTEREDTESTCASES_DUP02, "--------------------------------");
|
|
93 |
OstTraceFunctionExit1( RTESTFACTORY_LISTREGISTEREDTESTCASES_EXIT, 0 );
|
0
|
94 |
}
|
|
95 |
|
|
96 |
}
|