os/graphics/printingservices/printerdriversupport/tps/T_PDRLST.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1996-2010 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 //
    15 
    16 #include "T_PDRLST.H"
    17 
    18 
    19 class CTPdrLst : public CTGraphicsBase
    20 	{
    21 public:
    22 	CTPdrLst(CTestStep* aStep);
    23 	~CTPdrLst();
    24 protected:
    25 //from 	CTGraphicsStep
    26 	virtual void RunTestCaseL(TInt aCurTestCase);
    27 	virtual void ConstructL();
    28 private:
    29 	void Test1();
    30 private:
    31 	CPdrModelList* iModelList;
    32 	};
    33 
    34 CTPdrLst::CTPdrLst(CTestStep* aStep) :
    35 	CTGraphicsBase(aStep)
    36 	{
    37 	
    38 	}
    39 
    40 CTPdrLst::~CTPdrLst()
    41 	{
    42 	// clean up
    43 	INFO_PRINTF1( _L( "- Destroy the CPdrModelList" ) );
    44 	delete iModelList;
    45 	}
    46 
    47 void CTPdrLst::ConstructL()
    48 	{
    49 	INFO_PRINTF1( _L( "Testing PdrList" ) );
    50 	INFO_PRINTF1( _L( "- Create a CPdrModelList" ) );
    51 	iModelList = CPdrModelList::NewL();
    52 	}
    53 
    54 
    55 void CTPdrLst::Test1()
    56 	{
    57 	INFO_PRINTF1( _L( "- Check that there are no models in the list" ) );
    58 	TInt numModels = iModelList->ModelCount();
    59 	TEST(numModels == 0);
    60 
    61 	INFO_PRINTF1( _L( "- Add a directory to the search path" ) );
    62 	TFileName dir( _L( "z:" ) );
    63 	dir.Append( KDefaultPrinterDriverPath );
    64 	TRAPD(ret, iModelList->AddDirectoryL(dir) ); 
    65 	INFO_PRINTF2( _L( "ret %d\n" ), ret );
    66 	TEST( ret == KErrNone );
    67 
    68 	INFO_PRINTF1( _L( "- Scan the search path for models" ) );
    69 	TRAP( ret, (void)iModelList->ScanForModelsL() );
    70 	TEST( ret == KErrNone );
    71 	numModels = iModelList->ModelCount();
    72 	INFO_PRINTF2( _L( "   Models found: %d\n" ), numModels );
    73 
    74 	TPrinterModelEntry entry;
    75 	for ( TInt i = 0; i < numModels; i++ )
    76 		{
    77 		entry = (*iModelList)[i];
    78 		INFO_PRINTF2( _L( "ModelName %S\n" ), &entry.iModelName );
    79 		}
    80 
    81 	INFO_PRINTF1( _L( "- Create a new printer driver" ) );
    82 	RDebug::Print( _L( "Drivers: %d\r\n" ), numModels );
    83 	CPrinterDriver* driver = NULL;
    84 	TRAP( ret, driver = iModelList->CreatePrinterDriverL( numModels - 1 ) );
    85 	TEST( ret == KErrNone );
    86 	
    87 	INFO_PRINTF1( _L( "- Get the model name of the new printer device from PdrStore" ) );
    88 	TBuf<256> buf = driver->PrinterDevice()->Model().iModelName.Ptr();
    89 	INFO_PRINTF2( _L( "   Name of current model: %S\n" ), &buf );
    90 
    91 	// tidy up
    92 	delete driver;
    93 	}
    94 
    95 void CTPdrLst::RunTestCaseL(TInt aCurTestCase)
    96 // Test the model list interface to PdrStore.
    97 //
    98     {
    99 	((CTPdrLstStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   100 	switch(aCurTestCase)
   101 		{
   102 	case 1:
   103 /**
   104 @SYMTestCaseID			GRAPHICS-PDRLST-0001
   105 */
   106 		((CTPdrLstStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDRLST-0001"));
   107 		Test1();
   108 		break;	
   109 	case 2:
   110 		((CTPdrLstStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   111 		((CTPdrLstStep*)iStep)->CloseTMSGraphicsStep();
   112 		TestComplete();
   113 		break;	
   114 		}
   115 	((CTPdrLstStep*)iStep)->RecordTestResultL();
   116     }
   117 
   118 //--------------
   119 __CONSTRUCT_STEP__(PdrLst)
   120 
   121