1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/printingservices/printerdriversupport/tps/T_PDRLST.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,121 @@
1.4 +// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "T_PDRLST.H"
1.20 +
1.21 +
1.22 +class CTPdrLst : public CTGraphicsBase
1.23 + {
1.24 +public:
1.25 + CTPdrLst(CTestStep* aStep);
1.26 + ~CTPdrLst();
1.27 +protected:
1.28 +//from CTGraphicsStep
1.29 + virtual void RunTestCaseL(TInt aCurTestCase);
1.30 + virtual void ConstructL();
1.31 +private:
1.32 + void Test1();
1.33 +private:
1.34 + CPdrModelList* iModelList;
1.35 + };
1.36 +
1.37 +CTPdrLst::CTPdrLst(CTestStep* aStep) :
1.38 + CTGraphicsBase(aStep)
1.39 + {
1.40 +
1.41 + }
1.42 +
1.43 +CTPdrLst::~CTPdrLst()
1.44 + {
1.45 + // clean up
1.46 + INFO_PRINTF1( _L( "- Destroy the CPdrModelList" ) );
1.47 + delete iModelList;
1.48 + }
1.49 +
1.50 +void CTPdrLst::ConstructL()
1.51 + {
1.52 + INFO_PRINTF1( _L( "Testing PdrList" ) );
1.53 + INFO_PRINTF1( _L( "- Create a CPdrModelList" ) );
1.54 + iModelList = CPdrModelList::NewL();
1.55 + }
1.56 +
1.57 +
1.58 +void CTPdrLst::Test1()
1.59 + {
1.60 + INFO_PRINTF1( _L( "- Check that there are no models in the list" ) );
1.61 + TInt numModels = iModelList->ModelCount();
1.62 + TEST(numModels == 0);
1.63 +
1.64 + INFO_PRINTF1( _L( "- Add a directory to the search path" ) );
1.65 + TFileName dir( _L( "z:" ) );
1.66 + dir.Append( KDefaultPrinterDriverPath );
1.67 + TRAPD(ret, iModelList->AddDirectoryL(dir) );
1.68 + INFO_PRINTF2( _L( "ret %d\n" ), ret );
1.69 + TEST( ret == KErrNone );
1.70 +
1.71 + INFO_PRINTF1( _L( "- Scan the search path for models" ) );
1.72 + TRAP( ret, (void)iModelList->ScanForModelsL() );
1.73 + TEST( ret == KErrNone );
1.74 + numModels = iModelList->ModelCount();
1.75 + INFO_PRINTF2( _L( " Models found: %d\n" ), numModels );
1.76 +
1.77 + TPrinterModelEntry entry;
1.78 + for ( TInt i = 0; i < numModels; i++ )
1.79 + {
1.80 + entry = (*iModelList)[i];
1.81 + INFO_PRINTF2( _L( "ModelName %S\n" ), &entry.iModelName );
1.82 + }
1.83 +
1.84 + INFO_PRINTF1( _L( "- Create a new printer driver" ) );
1.85 + RDebug::Print( _L( "Drivers: %d\r\n" ), numModels );
1.86 + CPrinterDriver* driver = NULL;
1.87 + TRAP( ret, driver = iModelList->CreatePrinterDriverL( numModels - 1 ) );
1.88 + TEST( ret == KErrNone );
1.89 +
1.90 + INFO_PRINTF1( _L( "- Get the model name of the new printer device from PdrStore" ) );
1.91 + TBuf<256> buf = driver->PrinterDevice()->Model().iModelName.Ptr();
1.92 + INFO_PRINTF2( _L( " Name of current model: %S\n" ), &buf );
1.93 +
1.94 + // tidy up
1.95 + delete driver;
1.96 + }
1.97 +
1.98 +void CTPdrLst::RunTestCaseL(TInt aCurTestCase)
1.99 +// Test the model list interface to PdrStore.
1.100 +//
1.101 + {
1.102 + ((CTPdrLstStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.103 + switch(aCurTestCase)
1.104 + {
1.105 + case 1:
1.106 +/**
1.107 +@SYMTestCaseID GRAPHICS-PDRLST-0001
1.108 +*/
1.109 + ((CTPdrLstStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDRLST-0001"));
1.110 + Test1();
1.111 + break;
1.112 + case 2:
1.113 + ((CTPdrLstStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.114 + ((CTPdrLstStep*)iStep)->CloseTMSGraphicsStep();
1.115 + TestComplete();
1.116 + break;
1.117 + }
1.118 + ((CTPdrLstStep*)iStep)->RecordTestResultL();
1.119 + }
1.120 +
1.121 +//--------------
1.122 +__CONSTRUCT_STEP__(PdrLst)
1.123 +
1.124 +