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.
sl@0
     1
// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "T_PDRLST.H"
sl@0
    17
sl@0
    18
sl@0
    19
class CTPdrLst : public CTGraphicsBase
sl@0
    20
	{
sl@0
    21
public:
sl@0
    22
	CTPdrLst(CTestStep* aStep);
sl@0
    23
	~CTPdrLst();
sl@0
    24
protected:
sl@0
    25
//from 	CTGraphicsStep
sl@0
    26
	virtual void RunTestCaseL(TInt aCurTestCase);
sl@0
    27
	virtual void ConstructL();
sl@0
    28
private:
sl@0
    29
	void Test1();
sl@0
    30
private:
sl@0
    31
	CPdrModelList* iModelList;
sl@0
    32
	};
sl@0
    33
sl@0
    34
CTPdrLst::CTPdrLst(CTestStep* aStep) :
sl@0
    35
	CTGraphicsBase(aStep)
sl@0
    36
	{
sl@0
    37
	
sl@0
    38
	}
sl@0
    39
sl@0
    40
CTPdrLst::~CTPdrLst()
sl@0
    41
	{
sl@0
    42
	// clean up
sl@0
    43
	INFO_PRINTF1( _L( "- Destroy the CPdrModelList" ) );
sl@0
    44
	delete iModelList;
sl@0
    45
	}
sl@0
    46
sl@0
    47
void CTPdrLst::ConstructL()
sl@0
    48
	{
sl@0
    49
	INFO_PRINTF1( _L( "Testing PdrList" ) );
sl@0
    50
	INFO_PRINTF1( _L( "- Create a CPdrModelList" ) );
sl@0
    51
	iModelList = CPdrModelList::NewL();
sl@0
    52
	}
sl@0
    53
sl@0
    54
sl@0
    55
void CTPdrLst::Test1()
sl@0
    56
	{
sl@0
    57
	INFO_PRINTF1( _L( "- Check that there are no models in the list" ) );
sl@0
    58
	TInt numModels = iModelList->ModelCount();
sl@0
    59
	TEST(numModels == 0);
sl@0
    60
sl@0
    61
	INFO_PRINTF1( _L( "- Add a directory to the search path" ) );
sl@0
    62
	TFileName dir( _L( "z:" ) );
sl@0
    63
	dir.Append( KDefaultPrinterDriverPath );
sl@0
    64
	TRAPD(ret, iModelList->AddDirectoryL(dir) ); 
sl@0
    65
	INFO_PRINTF2( _L( "ret %d\n" ), ret );
sl@0
    66
	TEST( ret == KErrNone );
sl@0
    67
sl@0
    68
	INFO_PRINTF1( _L( "- Scan the search path for models" ) );
sl@0
    69
	TRAP( ret, (void)iModelList->ScanForModelsL() );
sl@0
    70
	TEST( ret == KErrNone );
sl@0
    71
	numModels = iModelList->ModelCount();
sl@0
    72
	INFO_PRINTF2( _L( "   Models found: %d\n" ), numModels );
sl@0
    73
sl@0
    74
	TPrinterModelEntry entry;
sl@0
    75
	for ( TInt i = 0; i < numModels; i++ )
sl@0
    76
		{
sl@0
    77
		entry = (*iModelList)[i];
sl@0
    78
		INFO_PRINTF2( _L( "ModelName %S\n" ), &entry.iModelName );
sl@0
    79
		}
sl@0
    80
sl@0
    81
	INFO_PRINTF1( _L( "- Create a new printer driver" ) );
sl@0
    82
	RDebug::Print( _L( "Drivers: %d\r\n" ), numModels );
sl@0
    83
	CPrinterDriver* driver = NULL;
sl@0
    84
	TRAP( ret, driver = iModelList->CreatePrinterDriverL( numModels - 1 ) );
sl@0
    85
	TEST( ret == KErrNone );
sl@0
    86
	
sl@0
    87
	INFO_PRINTF1( _L( "- Get the model name of the new printer device from PdrStore" ) );
sl@0
    88
	TBuf<256> buf = driver->PrinterDevice()->Model().iModelName.Ptr();
sl@0
    89
	INFO_PRINTF2( _L( "   Name of current model: %S\n" ), &buf );
sl@0
    90
sl@0
    91
	// tidy up
sl@0
    92
	delete driver;
sl@0
    93
	}
sl@0
    94
sl@0
    95
void CTPdrLst::RunTestCaseL(TInt aCurTestCase)
sl@0
    96
// Test the model list interface to PdrStore.
sl@0
    97
//
sl@0
    98
    {
sl@0
    99
	((CTPdrLstStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
   100
	switch(aCurTestCase)
sl@0
   101
		{
sl@0
   102
	case 1:
sl@0
   103
/**
sl@0
   104
@SYMTestCaseID			GRAPHICS-PDRLST-0001
sl@0
   105
*/
sl@0
   106
		((CTPdrLstStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDRLST-0001"));
sl@0
   107
		Test1();
sl@0
   108
		break;	
sl@0
   109
	case 2:
sl@0
   110
		((CTPdrLstStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   111
		((CTPdrLstStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   112
		TestComplete();
sl@0
   113
		break;	
sl@0
   114
		}
sl@0
   115
	((CTPdrLstStep*)iStep)->RecordTestResultL();
sl@0
   116
    }
sl@0
   117
sl@0
   118
//--------------
sl@0
   119
__CONSTRUCT_STEP__(PdrLst)
sl@0
   120
sl@0
   121