lowlevellibsandfws/pluginfw/Framework/RegistryDataTest/RegistryDataTest.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "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 // Demonstrates a simple set of derived class implementations to
       
    15 // test the CRegistryData class using the test bed.
       
    16 // It may be used as a basis to develop a full test bed dll.
       
    17 // For support and comment please contact the authors.
       
    18 // 
       
    19 //
       
    20 
       
    21 #include "StateAccessor.h"
       
    22 #include <test_bed/testbeddefinitions.h>
       
    23 #include <test_bed/unittest.h>
       
    24 #include "LeakTestTransition.h"
       
    25 #include <test_bed/datalogger.h>
       
    26 #include "ComponentTester.h"
       
    27 
       
    28 #include "RegistryData.h"
       
    29 
       
    30 #include "RegistryDataUnitTests.h"
       
    31 
       
    32 RTest test(_L("RegistryDataTest.cpp"));
       
    33 
       
    34 // ______________________________________________________________________________
       
    35 //
       
    36 /**
       
    37 	@internalComponent
       
    38 	Comments : Test the CRegistryData class.
       
    39  */
       
    40 class CRegistryData_ComponentTest : public CComponentTester
       
    41 	{
       
    42 public:
       
    43 	/**
       
    44 		@fn				NewLC(CDataLogger& aDataLogger,
       
    45 							 MComponentTestObserver& aObserver)
       
    46 		Intended Usage	: Standard two-phase construction which leaves nothing on the
       
    47 						cleanup stack.
       
    48 		Error Condition	: Leaves with the error code.
       
    49 		@leave  		KErrNoMemory
       
    50 		@since			7.0
       
    51 		@param			aDataLogger The output logging object.
       
    52 		@param			aObserver The observer of this component test.
       
    53 		@return			CRegistryData_ComponentTest* The constructed object.
       
    54 		@pre 			None.
       
    55 		@post			CRegistryData_ComponentTest is fully constructed.
       
    56 	*/
       
    57 	static CRegistryData_ComponentTest* NewLC(CDataLogger& aDataLogger,
       
    58 							MComponentTestObserver& aObserver);
       
    59 
       
    60 private:
       
    61 	/**
       
    62 		@fn				CRegistryData_ComponentTest(CDataLogger& aDataLogger,
       
    63 											MComponentTestObserver& aObserver)
       
    64 		Intended Usage	: Standard c'tor method.
       
    65 		Error Condition	: None.
       
    66 		@since			7.0
       
    67 		@param			aDataLogger The logging object.
       
    68 		@param			aObserver The observer of this component test.
       
    69 		@pre 			None.
       
    70 		@post			CRegistryData_ComponentTest is fully constructed.
       
    71 	*/
       
    72 	inline CRegistryData_ComponentTest(CDataLogger& aDataLogger,
       
    73 												MComponentTestObserver& aObserver);
       
    74 	/**
       
    75 		@fn				void ConstructL()
       
    76 		Intended Usage	: Second phase of safe two phase construction,
       
    77 						to complete the object initialisation.
       
    78 		Error Condition	: Leaves with an error code.
       
    79 		@leave  		KErrNoMemory.
       
    80 		@since			7.0
       
    81 		@return			None
       
    82 		@pre 			CRegistryData_ComponentTest is fully constructed.
       
    83 		@post			CRegistryData_ComponentTest is fully initialised.
       
    84 	*/
       
    85 	inline void ConstructL();
       
    86 
       
    87 	};	// CRegistryData_ComponentTest
       
    88 
       
    89 // ______________________________________________________________________________
       
    90 //
       
    91 inline CRegistryData_UnitTestContext::CRegistryData_UnitTestContext(CDataLogger& aDataLogger,
       
    92 												MStateAccessor& aStateAccessor,
       
    93 												MTransitionObserver& aObserver,
       
    94 												RFs& aFs)
       
    95 : CUnitTestContext(aDataLogger, aStateAccessor, aObserver), iFs(aFs)
       
    96 	{
       
    97 	//Do nothing
       
    98 	}
       
    99 
       
   100 inline CRegistryData_UnitTestContext::~CRegistryData_UnitTestContext()
       
   101 	{
       
   102 	delete iRegistryData;
       
   103 	delete iDllData;
       
   104 	delete iNewDllData;
       
   105 	}
       
   106 
       
   107 // ______________________________________________________________________________
       
   108 //
       
   109 inline CRegistryData_ComponentTest* CRegistryData_ComponentTest::NewLC(CDataLogger& aDataLogger, MComponentTestObserver& aObserver)
       
   110 	{
       
   111 	CRegistryData_ComponentTest* self = new (ELeave) CRegistryData_ComponentTest(aDataLogger, aObserver);
       
   112 	CleanupStack::PushL(self);
       
   113 	self->ConstructL();
       
   114 	return self;
       
   115 	}
       
   116 
       
   117 inline CRegistryData_ComponentTest::CRegistryData_ComponentTest(CDataLogger& aDataLogger,
       
   118 									MComponentTestObserver& aObserver)
       
   119 : CComponentTester(aDataLogger, aObserver)
       
   120 	{
       
   121 	// Do nothing here.
       
   122 	}
       
   123 
       
   124 inline void CRegistryData_ComponentTest::ConstructL()
       
   125 	{
       
   126 	// Perform base class initialization
       
   127 	ComponentTesterConstructL();
       
   128 
       
   129 	AddUnitTestL(CRegistryData_CreateAndDestroy_UnitTest::NewL(iDataLogger, *this));
       
   130 	AddUnitTestL(CRegistryData_RetrieveInfo_UnitTest::NewL(iDataLogger, *this));
       
   131 
       
   132 	AddUnitTestL(CRegistryData_GetImplInfoWhileDiscovering_UnitTest::NewL(iDataLogger, *this));
       
   133 	AddUnitTestL(CRegistryData_AddData_UnitTest::NewL(iDataLogger, *this));
       
   134 	}
       
   135 
       
   136 // ______________________________________________________________________________
       
   137 //
       
   138 EXPORT_C CComponentTester* NewComponentTestLC(CDataLogger& aDataLogger,
       
   139 									MComponentTestObserver&	aComponentTestObserver)
       
   140 	{
       
   141 	return CRegistryData_ComponentTest::NewLC(aDataLogger, aComponentTestObserver);
       
   142 	}
       
   143 
       
   144 // ___________________________________________________________________________
       
   145 //
       
   146 // This section of the module simply includes the exported test harness template which
       
   147 // makes this a "whole" CPP file with a E32Main entry point below. The test MMP
       
   148 // project file can then produce a EXE for the test project instead of a DLL.
       
   149 
       
   150 #include "ECom/Test_Bed/TestHarnessTemplate.h"
       
   151 
       
   152 GLDEF_C TInt E32Main()
       
   153     {
       
   154 	test.Title();
       
   155 	test.Start(_L(" @SYMTestCaseID:SYSLIB-ECOM-LEGACY-REGISTRYDATATEST-0001 "));
       
   156 
       
   157 	test.End();
       
   158 	test.Close();
       
   159 
       
   160 	return E32Main_TestHarness(NewComponentTestLC);
       
   161 	}
       
   162