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