os/graphics/printingservices/printerdriversupport/tps/T_PDR.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) 2006-2009 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
/**
sl@0
    17
 @file
sl@0
    18
 @test
sl@0
    19
 @internalComponent Internal Symbian test code
sl@0
    20
*/
sl@0
    21
sl@0
    22
#include "T_PDR.H"
sl@0
    23
#include <graphics/fbsdefs.h>
sl@0
    24
sl@0
    25
sl@0
    26
#if defined (__WINS__)
sl@0
    27
#define PDD_NAME _L("ECDRV")
sl@0
    28
#define LDD_NAME _L("ECOMM")
sl@0
    29
#else
sl@0
    30
#define PDD_NAME _L("EUART1")
sl@0
    31
#define LDD_NAME _L("ECOMM")
sl@0
    32
#endif
sl@0
    33
sl@0
    34
// Set KVerboseOutput to "ETrue" if extra INFO_PRINTFx for debug purposes are required
sl@0
    35
const TBool KVerboseOutput = EFalse;
sl@0
    36
sl@0
    37
_LIT( KDriveName, "z:" );
sl@0
    38
_LIT( KEpsonFileName, "epson.pdr" );
sl@0
    39
sl@0
    40
//--------------------------------------------------------------------------------
sl@0
    41
void CPdrTestPrint::RunL()
sl@0
    42
	{
sl@0
    43
	CActiveScheduler::Stop();
sl@0
    44
	}
sl@0
    45
			
sl@0
    46
TRequestStatus& CPdrTestPrint::Queue()
sl@0
    47
	{
sl@0
    48
	SetActive();
sl@0
    49
	return iStatus;
sl@0
    50
	}
sl@0
    51
			
sl@0
    52
TRequestStatus& CPdrTestPrint::Status()
sl@0
    53
	{
sl@0
    54
	return iStatus;
sl@0
    55
	}
sl@0
    56
			
sl@0
    57
//-------------------------------------------------------------------------------
sl@0
    58
sl@0
    59
CTPdr::CTPdr(CTestStep* aStep) :
sl@0
    60
	CTGraphicsBase(aStep)
sl@0
    61
	{
sl@0
    62
	}
sl@0
    63
sl@0
    64
CTPdr::~CTPdr()
sl@0
    65
	{
sl@0
    66
	}
sl@0
    67
sl@0
    68
sl@0
    69
void CTPdr::ConstructL()
sl@0
    70
	{
sl@0
    71
	INFO_PRINTF1(_L( "Start the various bits and pieces of the comms server\n" ));
sl@0
    72
sl@0
    73
	TInt ret;
sl@0
    74
#if !defined(__X86GCC__)
sl@0
    75
	ret=User::LoadPhysicalDevice(PDD_NAME);
sl@0
    76
	TEST(ret==KErrNone || ret==KErrAlreadyExists);
sl@0
    77
sl@0
    78
	ret=User::LoadLogicalDevice(LDD_NAME);
sl@0
    79
	TEST(ret==KErrNone || ret==KErrAlreadyExists);
sl@0
    80
#endif
sl@0
    81
sl@0
    82
	// to avoid alloc heaven with the fbs server
sl@0
    83
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
sl@0
    84
	CleanupStack::PushL(bitmap);
sl@0
    85
	User::LeaveIfError(bitmap->Create(TSize(1024, 1024), EColor16MA));
sl@0
    86
	CleanupStack::PopAndDestroy(bitmap);
sl@0
    87
	
sl@0
    88
  	// to avoid alloc heaven with the fbs server
sl@0
    89
  	CFbsBitmap bmp1;   
sl@0
    90
  	CFbsBitmap bmp2;
sl@0
    91
   	ret=bmp1.Load(_L("z:\\test\\pdrstore.mbm"),0,NULL);	// sheep
sl@0
    92
  	TEST(ret==KErrNone);
sl@0
    93
  	ret=bmp2.Load(_L("z:\\test\\pdrstore.mbm"),1,NULL);	// pslogo
sl@0
    94
  	TEST(ret==KErrNone);
sl@0
    95
  	bmp1.Reset();
sl@0
    96
  	bmp2.Reset();
sl@0
    97
 	}
sl@0
    98
sl@0
    99
sl@0
   100
void CTPdr::testPrint(CPrinterDevice* aDevice)
sl@0
   101
	{
sl@0
   102
	INFO_PRINTF1(_L("calling testPrint()..."));
sl@0
   103
  
sl@0
   104
	CFbsBitmap bmp1;
sl@0
   105
	CFbsBitmap bmp2;
sl@0
   106
sl@0
   107
	TInt ret=bmp1.Load(_L("z:\\test\\pdrstore.mbm"),0,EFalse);	// sheep
sl@0
   108
	TEST(ret==KErrNone);
sl@0
   109
	ret=bmp2.Load(_L("z:\\test\\pdrstore.mbm"),1,EFalse);	// pslogo
sl@0
   110
	TEST(ret==KErrNone);
sl@0
   111
sl@0
   112
	bmp1.SetSizeInTwips(TSize(3000,1500));
sl@0
   113
	bmp2.SetSizeInTwips(TSize(2000,900));
sl@0
   114
sl@0
   115
	TBandAttributes attributes;
sl@0
   116
	CPrinterControl::TMoreOnPage moreonpage=CPrinterControl::EMoreOnPage;
sl@0
   117
sl@0
   118
	TInt h=aDevice->HorizontalPixelsToTwips(1000);
sl@0
   119
	TInt v=aDevice->VerticalPixelsToTwips(1000);
sl@0
   120
	TInt k=4800;
sl@0
   121
sl@0
   122
	TInt i=0;
sl@0
   123
	do
sl@0
   124
		{
sl@0
   125
		if (KVerboseOutput)
sl@0
   126
			{
sl@0
   127
			INFO_PRINTF2(_L("Get band %d"),i+1);
sl@0
   128
			}
sl@0
   129
		moreonpage=aDevice->iControl->QueueGetBand(iStopper->Queue(),attributes);
sl@0
   130
		CActiveScheduler::Start();
sl@0
   131
sl@0
   132
		CGraphicsContext* gc=NULL;
sl@0
   133
		ret=aDevice->CreateContext((CGraphicsContext *&) gc);
sl@0
   134
		TEST(ret==KErrNone);
sl@0
   135
sl@0
   136
		gc->SetPenColor(KRgbBlack);							 
sl@0
   137
		gc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   138
		gc->SetPenSize(TSize(4*k/h,4*k/v));
sl@0
   139
		gc->DrawEllipse(TRect(391,352,1152,601));
sl@0
   140
		gc->DrawEllipse(TRect(391,336,1152,585));
sl@0
   141
		gc->Reset();
sl@0
   142
		gc->DrawEllipse(TRect(727,693,1488,942));
sl@0
   143
		gc->DrawEllipse(TRect(727,677,1488,926));
sl@0
   144
		CFont *font;
sl@0
   145
		TFontSpec spec (_L("CG Times"),300);
sl@0
   146
		spec.iTypeface.SetIsProportional(ETrue);
sl@0
   147
		ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   148
		TEST(ret==KErrNone);
sl@0
   149
sl@0
   150
		if (KVerboseOutput)
sl@0
   151
			{
sl@0
   152
			INFO_PRINTF2(_L("TextWidthInPixels(HELLO WORLD) %d"),font->TextWidthInPixels(_L("HELLO WORLD")));
sl@0
   153
			}
sl@0
   154
			
sl@0
   155
		gc->UseFont(font);
sl@0
   156
		gc->SetUnderlineStyle(EUnderlineOn);
sl@0
   157
		gc->DrawText(_L("HELLO WORLD"),TRect(300*k/h,200*k/v,1800*k/h,300*k/v),100*k/v,CGraphicsContext::ELeft,0);
sl@0
   158
		gc->SetUnderlineStyle(EUnderlineOff);
sl@0
   159
		gc->DrawText(_L("HELLO WORLD"),TRect(300*k/h,200*k/v,1800*k/h,300*k/v),100*k/v,CGraphicsContext::ERight,0);
sl@0
   160
		gc->DrawText(_L("HELLO WORLD"),TRect(300*k/h,200*k/v,1800*k/h,300*k/v),100*k/v,CGraphicsContext::ECenter,0);
sl@0
   161
sl@0
   162
		TBuf<20> text;
sl@0
   163
		text.Format(_L("Test symbols %c %c %c %c"),130,131,132,133);
sl@0
   164
sl@0
   165
		gc->SetPenColor(KRgbBlack);							 
sl@0
   166
		gc->DrawText(text,TRect(1000*k/h,2500*k/v,1800*k/h,2700*k/v),50*k/v,CGraphicsContext::ELeft,0);
sl@0
   167
		gc->SetWordJustification(1200*k/h,4);
sl@0
   168
		gc->DrawText(_L("Bramm an gath"),TRect(1000*k/h,2500*k/v,1800*k/h,2700*k/v),100*k/v,CGraphicsContext::ELeft,0);
sl@0
   169
		gc->DrawText(_L("Bramm an gath"),TRect(1000*k/h,2500*k/v,1800*k/h,2700*k/v),150*k/v,CGraphicsContext::ELeft,0);
sl@0
   170
		aDevice->ReleaseFont(font);
sl@0
   171
sl@0
   172
		ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   173
		TEST(ret==KErrNone);
sl@0
   174
		gc->UseFont(font);
sl@0
   175
		gc->DrawText(_L("BRAMM AN GATH"),TRect(1000*k/h,2800*k/v,1800*k/h,3000*k/v),200*k/v,CGraphicsContext::ELeft,0);
sl@0
   176
		spec.iFontStyle.SetPrintPosition(EPrintPosSuperscript);
sl@0
   177
		aDevice->ReleaseFont(font);
sl@0
   178
		ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   179
		TEST(ret==KErrNone);
sl@0
   180
		gc->UseFont(font);
sl@0
   181
		gc->DrawText(_L("BRAMM AN GATH"),TRect(1000*k/h,2800*k/v,1800*k/h,3000*k/v),200*k/v,CGraphicsContext::ERight,0);
sl@0
   182
		aDevice->ReleaseFont(font);
sl@0
   183
		spec.iFontStyle.SetPrintPosition(EPrintPosSubscript);
sl@0
   184
		ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   185
		TEST(ret==KErrNone);
sl@0
   186
		gc->UseFont(font);
sl@0
   187
		gc->SetBrushColor(KRgbWhite);				   
sl@0
   188
		gc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
   189
		gc->DrawText(_L("BRAMM AN GATH"),TRect(1000*k/h,2800*k/v,1800*k/h,3000*k/v),200*k/v,CGraphicsContext::ECenter,0);
sl@0
   190
		aDevice->ReleaseFont(font);
sl@0
   191
sl@0
   192
		// Draw bitmap
sl@0
   193
		gc->DrawBitmap(TPoint(800*k/h,900*k/v),&bmp1);
sl@0
   194
		gc->DrawBitmap(TPoint(1700*k/h,3100*k/v),&bmp2);
sl@0
   195
		gc->DrawBitmap(TPoint(1000*k/h,1400*k/v),&bmp2);
sl@0
   196
		gc->DrawBitmap(TPoint(100*k/h,1700*k/v),&bmp2);
sl@0
   197
sl@0
   198
		// Draw line
sl@0
   199
		gc->SetPenSize(TSize(30*k/h,30*k/v));
sl@0
   200
		gc->DrawLine(TPoint(800*k/h,100*k/v),TPoint(2000*k/h,100*k/v));
sl@0
   201
		gc->DrawLine(TPoint(1500*k/h,400*k/v),TPoint(1800*k/h,1500*k/v));
sl@0
   202
sl@0
   203
		// Draw rectangle
sl@0
   204
		gc->SetPenSize(TSize(4*k/h,4*k/v));				 
sl@0
   205
		gc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
   206
		gc->SetBrushColor(KRgbWhite);
sl@0
   207
		gc->DrawRect(TRect(300*k/h,200*k/v,1800*k/h,300*k/v));
sl@0
   208
sl@0
   209
		// Draw circle
sl@0
   210
		gc->SetPenSize(TSize(10*k/h,10*k/v));
sl@0
   211
		gc->DrawEllipse(TRect(300*k/h,2600*k/v,700*k/h,3000*k/v));
sl@0
   212
sl@0
   213
		// Plot point
sl@0
   214
		gc->SetPenSize(TSize(20*k/h,20*k/v));
sl@0
   215
		gc->Plot(TPoint(1800*k/h,1600*k/v));
sl@0
   216
sl@0
   217
		delete gc;
sl@0
   218
		
sl@0
   219
		if (KVerboseOutput)
sl@0
   220
			{
sl@0
   221
			INFO_PRINTF2(_L("End of band %d"),i+1);
sl@0
   222
			}
sl@0
   223
		i++;
sl@0
   224
		}
sl@0
   225
sl@0
   226
	while (moreonpage==CPrinterControl::EMoreOnPage);
sl@0
   227
	INFO_PRINTF1(_L("QueueEndPrint"));
sl@0
   228
	aDevice->iControl->QueueEndPrint(iStopper->Queue());
sl@0
   229
	CActiveScheduler::Start();
sl@0
   230
	INFO_PRINTF2(_L("Request status %d"),iStopper->Status().Int());
sl@0
   231
sl@0
   232
	bmp2.Reset();
sl@0
   233
	bmp1.Reset();
sl@0
   234
	
sl@0
   235
	}
sl@0
   236
sl@0
   237
sl@0
   238
//
sl@0
   239
// Test read file handling.
sl@0
   240
//
sl@0
   241
void CTPdr::testPdrStore()
sl@0
   242
	{
sl@0
   243
	__UHEAP_MARK;
sl@0
   244
sl@0
   245
	INFO_PRINTF1(_L("Add to the active scheduler"));
sl@0
   246
	iStopper=new(ELeave) CPdrTestPrint();
sl@0
   247
	CActiveScheduler::Add(iStopper);
sl@0
   248
sl@0
   249
	// Open file
sl@0
   250
	INFO_PRINTF1(_L("OpenPdrL(pdr file)"));
sl@0
   251
	CPrinterDriver* driver=NULL;
sl@0
   252
	TRAPD(ret,driver=CPrinterDriver::NewL());
sl@0
   253
	TEST(ret==KErrNone);
sl@0
   254
	
sl@0
   255
	TFileName filename( KDriveName );
sl@0
   256
	filename.Append( KDefaultPrinterDriverPath );
sl@0
   257
	filename.Append( KEpsonFileName );
sl@0
   258
sl@0
   259
	TRAP(ret,driver->OpenPdrL( filename ));
sl@0
   260
	TEST(ret==KErrNone);
sl@0
   261
	INFO_PRINTF2(_L("NumModels %d"),driver->NumModels());
sl@0
   262
sl@0
   263
	// Get model info
sl@0
   264
	TPrinterModelEntry entry;
sl@0
   265
	TInt i = 0;
sl@0
   266
	iNumModels = driver->NumModels();
sl@0
   267
	for (i=0; i<iNumModels; i++)
sl@0
   268
		{
sl@0
   269
		entry=driver->Model(i);
sl@0
   270
		INFO_PRINTF2(_L("  *********************** ModelName %S"),&entry.iModelName);
sl@0
   271
		}
sl@0
   272
sl@0
   273
	// Create device
sl@0
   274
	INFO_PRINTF1(_L("Create printer device"));
sl@0
   275
	CPrinterDevice* device=NULL;
sl@0
   276
	entry=driver->Model(iModelIndex);
sl@0
   277
	TRAP(ret,device=driver->CreatePrinterDeviceL(entry.iUid));
sl@0
   278
	TEST(ret==KErrNone);
sl@0
   279
	CPrinterDriverUI* driverui=NULL;
sl@0
   280
 	TRAP(ret,driverui=driver->CreatePrinterDriverUIL());
sl@0
   281
	INFO_PRINTF2(_L("DriverUI %d"),driverui);
sl@0
   282
	delete driverui;
sl@0
   283
sl@0
   284
	INFO_PRINTF2(_L("NumTypefaces %d"),device->NumTypefaces());
sl@0
   285
	INFO_PRINTF2(_L("**Model name %S**"),&entry.iModelName);
sl@0
   286
	INFO_PRINTF2(_L("KPixelWidthInTwips %d"),device->HorizontalPixelsToTwips(1000));
sl@0
   287
	INFO_PRINTF2(_L("KPixelHeightInTwips %d"),device->VerticalPixelsToTwips(1000));
sl@0
   288
	TPageSpec pagespec(TPageSpec::EPortrait,KA4PaperSizeInTwips);
sl@0
   289
	device->SelectPageSpecInTwips(pagespec);
sl@0
   290
sl@0
   291
	// Get typeface info
sl@0
   292
	INFO_PRINTF1(_L("Get typeface info"));
sl@0
   293
	TTypefaceSupport support;
sl@0
   294
	device->TypefaceSupport(support,0);
sl@0
   295
	TBuf<KMaxTypefaceNameLength> name;
sl@0
   296
	name.Copy(support.iTypeface.iName);
sl@0
   297
	INFO_PRINTF2(_L("Typeface Name %S"),&name);
sl@0
   298
	INFO_PRINTF2(_L("Typeface serif %d"),support.iTypeface.IsSerif());
sl@0
   299
	INFO_PRINTF2(_L("Typeface proportional %d"),support.iTypeface.IsProportional());
sl@0
   300
	INFO_PRINTF2(_L("Typeface symbol %d"),support.iTypeface.IsSymbol());
sl@0
   301
	INFO_PRINTF2(_L("NumHeights %d"),support.iNumHeights);
sl@0
   302
	INFO_PRINTF2(_L("MinHeightInTwips %d"),support.iMinHeightInTwips);
sl@0
   303
	INFO_PRINTF2(_L("MaxHeightInTwips %d"),support.iMaxHeightInTwips);
sl@0
   304
	INFO_PRINTF2(_L("IsScalable %d"),support.iIsScalable);
sl@0
   305
	
sl@0
   306
	// Get nearest font
sl@0
   307
 	INFO_PRINTF1(_L("Get nearest font"));
sl@0
   308
	CFont *font;
sl@0
   309
	TFontSpec spec;
sl@0
   310
	support.iTypeface.iName=_L("DejaVu Sans Condensed");
sl@0
   311
	support.iTypeface.SetIsProportional(ETrue);
sl@0
   312
	support.iTypeface.SetIsSerif(ETrue);
sl@0
   313
	spec.iTypeface=support.iTypeface;
sl@0
   314
	spec.iHeight=680;
sl@0
   315
	spec.iFontStyle.SetPosture(EPostureUpright);
sl@0
   316
	spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
sl@0
   317
	spec.iFontStyle.SetPrintPosition(EPrintPosNormal);
sl@0
   318
	ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   319
	TEST(ret==KErrNone);
sl@0
   320
	INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels());
sl@0
   321
	INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels());
sl@0
   322
	INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight());
sl@0
   323
	INFO_PRINTF3(_L("Font AlgPosture %d AlgStrokeWeight %d"),((CBitmapFont*)font)->iAlgStyle.IsItalic(),((CBitmapFont*)font)->iAlgStyle.IsBold());
sl@0
   324
	spec=font->FontSpecInTwips();
sl@0
   325
	device->ReleaseFont(font);
sl@0
   326
	ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   327
	TEST(ret==KErrNone);
sl@0
   328
	INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels());
sl@0
   329
	INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels());
sl@0
   330
	INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight());
sl@0
   331
	INFO_PRINTF3(_L("Font AlgPosture %d AlgStrokeWeight %d"),((CBitmapFont*)font)->iAlgStyle.IsItalic(),((CBitmapFont*)font)->iAlgStyle.IsBold());
sl@0
   332
	name.Copy(font->FontSpecInTwips().iTypeface.iName);
sl@0
   333
	INFO_PRINTF2(_L("Typeface Name %S"),&name);
sl@0
   334
	INFO_PRINTF2(_L("Typeface Proportional %d"),font->FontSpecInTwips().iTypeface.IsProportional());
sl@0
   335
	INFO_PRINTF2(_L("Typeface Serif %d"),font->FontSpecInTwips().iTypeface.IsSerif());
sl@0
   336
	INFO_PRINTF2(_L("CharWidthInPixels(32) %d"),font->CharWidthInPixels(TChar(32)));
sl@0
   337
	INFO_PRINTF2(_L("MaxCharWidthInPixels %d"),font->MaxCharWidthInPixels());
sl@0
   338
	INFO_PRINTF2(_L("MaxNormalCharWidthInPixels %d"),font->MaxNormalCharWidthInPixels());
sl@0
   339
	INFO_PRINTF2(_L("HeightInTwips %d"),font->FontSpecInTwips().iHeight);
sl@0
   340
	INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels());
sl@0
   341
	INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels());
sl@0
   342
	INFO_PRINTF2(_L("TextWidthInPixels(HELLO WORLD) %d"),font->TextWidthInPixels(_L("HELLO WORLD")));
sl@0
   343
	device->ReleaseFont(font);
sl@0
   344
sl@0
   345
	spec.iHeight=1000;
sl@0
   346
	spec.iFontStyle.SetPrintPosition(EPrintPosNormal);
sl@0
   347
sl@0
   348
	spec.iFontStyle.SetPrintPosition(EPrintPosNormal);
sl@0
   349
	spec.iFontStyle.SetPosture(EPostureUpright);
sl@0
   350
	spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
sl@0
   351
	for (i=0; i<device->NumTypefaces(); i++)
sl@0
   352
		{
sl@0
   353
		device->TypefaceSupport(support,i);
sl@0
   354
		name.Copy(support.iTypeface.iName);
sl@0
   355
		INFO_PRINTF2(_L("Typeface Name %S"),&name);
sl@0
   356
		for (TInt j=0; j<support.iNumHeights; j++)
sl@0
   357
			{
sl@0
   358
			spec.iTypeface=support.iTypeface;
sl@0
   359
			spec.iHeight=device->FontHeightInTwips(i,j);
sl@0
   360
			ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   361
			TEST(ret==KErrNone);
sl@0
   362
			if (KVerboseOutput)
sl@0
   363
				{
sl@0
   364
				INFO_PRINTF2(_L("Spec HeightInTwips %d"),spec.iHeight);
sl@0
   365
				INFO_PRINTF2(_L("Font HeightInTwipss %d"),font->FontSpecInTwips().iHeight);
sl@0
   366
				INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight());
sl@0
   367
				}
sl@0
   368
			device->ReleaseFont(font);
sl@0
   369
			}
sl@0
   370
		}
sl@0
   371
sl@0
   372
	RFile file;
sl@0
   373
	RFs fs;
sl@0
   374
	ret=fs.Connect();
sl@0
   375
	TEST(ret==KErrNone);
sl@0
   376
	_LIT(KPath,"C:\\system\\data\\");
sl@0
   377
	fs.MkDirAll(KPath);
sl@0
   378
	ret=file.Replace(fs,_L("C:\\system\\data\\WIDTHS.TMP"),EFileStream|EFileWrite);
sl@0
   379
	if (ret!=KErrNone)
sl@0
   380
		{
sl@0
   381
		_LIT(KLog,"Doing Replace on file C:\\system\\data\\WIDTHS.TMP gave error %d");
sl@0
   382
		INFO_PRINTF2(KLog,ret);
sl@0
   383
		}
sl@0
   384
	TEST(ret==KErrNone);
sl@0
   385
sl@0
   386
	TBuf8<120> buf;
sl@0
   387
sl@0
   388
	for (i=0; i<device->NumTypefaces(); i++)
sl@0
   389
		{
sl@0
   390
		device->TypefaceSupport(support,i);
sl@0
   391
		spec.iTypeface=support.iTypeface;
sl@0
   392
		for (TInt k=0; k<support.iNumHeights; k++)
sl@0
   393
			{
sl@0
   394
			spec.iHeight=device->FontHeightInTwips(i,k);
sl@0
   395
			if ((spec.iHeight==1000))
sl@0
   396
				{
sl@0
   397
				for (TInt j=0; j<4; j++)
sl@0
   398
					{
sl@0
   399
					name.Copy(support.iTypeface.iName);
sl@0
   400
					buf.Format(_L8("FontInfo %S"),&support.iTypeface.iName);
sl@0
   401
					ret=file.Write(buf);
sl@0
   402
					TEST(ret==KErrNone);
sl@0
   403
					if (j==0)
sl@0
   404
						{
sl@0
   405
						buf.Format(_L8("Std%d"),spec.iHeight/20);
sl@0
   406
						ret=file.Write(buf);
sl@0
   407
						TEST(ret==KErrNone);
sl@0
   408
						spec.iFontStyle.SetPosture(EPostureUpright);
sl@0
   409
						spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
sl@0
   410
						}
sl@0
   411
					if (j==1)
sl@0
   412
						{
sl@0
   413
						buf.Format(_L8("Bold%d"),spec.iHeight/20);
sl@0
   414
						ret=file.Write(buf);
sl@0
   415
						TEST(ret==KErrNone);
sl@0
   416
						spec.iFontStyle.SetPosture(EPostureUpright);
sl@0
   417
						spec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
sl@0
   418
						}
sl@0
   419
					if (j==2)
sl@0
   420
						{
sl@0
   421
						buf.Format(_L8("Italic%d"),spec.iHeight/20);
sl@0
   422
						ret=file.Write(buf);
sl@0
   423
						TEST(ret==KErrNone);
sl@0
   424
						spec.iFontStyle.SetPosture(EPostureItalic);
sl@0
   425
						spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
sl@0
   426
						}
sl@0
   427
					if (j==3)
sl@0
   428
						{
sl@0
   429
						buf.Format(_L8("BoldItalic%d"),spec.iHeight/20);
sl@0
   430
						ret=file.Write(buf);
sl@0
   431
						TEST(ret==KErrNone);
sl@0
   432
						spec.iFontStyle.SetPosture(EPostureItalic);
sl@0
   433
						spec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
sl@0
   434
						}
sl@0
   435
					ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
sl@0
   436
					TEST(ret==KErrNone);
sl@0
   437
					INFO_PRINTF4(_L("Name %S Height %d CharWidthInPixels(W) %d"),&name,font->FontSpecInTwips().iHeight,font->CharWidthInPixels(TChar('W')));
sl@0
   438
					buf.Format(_L8("MaxNormalCharWidth %dAscent %d"),font->MaxNormalCharWidthInPixels(),font->AscentInPixels());
sl@0
   439
					ret=file.Write(buf);
sl@0
   440
					TEST(ret==KErrNone);
sl@0
   441
					ret=file.Write(_L8("CodeSection 0:255"));
sl@0
   442
					TEST(ret==KErrNone);
sl@0
   443
					for (TInt l=0; l<256; l++)
sl@0
   444
						{
sl@0
   445
						if (font->CharWidthInPixels(k))
sl@0
   446
							{
sl@0
   447
							buf.Format(_L8("%d:%d  "),l,font->CharWidthInPixels(l));
sl@0
   448
							ret=file.Write(buf);
sl@0
   449
							TEST(ret==KErrNone);
sl@0
   450
							}
sl@0
   451
						if (((l/8)*8)==l)
sl@0
   452
							{
sl@0
   453
							ret=file.Write(_L8("\n"));
sl@0
   454
							TEST(ret==KErrNone);
sl@0
   455
							}
sl@0
   456
						}
sl@0
   457
					ret=file.Write(_L8("\nEndCodeSection\nEndFontInfo\n"));
sl@0
   458
					TEST(ret==KErrNone);
sl@0
   459
					device->ReleaseFont(font);
sl@0
   460
					}
sl@0
   461
				}
sl@0
   462
			}
sl@0
   463
		}
sl@0
   464
	file.Flush();
sl@0
   465
	file.Close();
sl@0
   466
	fs.Close();
sl@0
   467
sl@0
   468
	// Create control
sl@0
   469
	INFO_PRINTF1(_L("Create control"));
sl@0
   470
  
sl@0
   471
	CPrinterPort* printerport=NULL;
sl@0
   472
#if defined (__WINS__)
sl@0
   473
	if (device->Model().iRequiresPrinterPort)
sl@0
   474
		{
sl@0
   475
		TRAP(ret,printerport=CFilePrinterPort::NewL(_L("c:\\Printfile")));
sl@0
   476
		}
sl@0
   477
#else 
sl@0
   478
	if (device->Model().iRequiresPrinterPort)
sl@0
   479
		{
sl@0
   480
		TRAP(ret,printerport=CFilePrinterPort::NewL(_L("c:\\temp.prn")));
sl@0
   481
		INFO_PRINTF2(_L("ret %d"),ret);
sl@0
   482
		INFO_PRINTF2(_L("device displaymode %d"),device->DisplayMode());
sl@0
   483
		}
sl@0
   484
#endif
sl@0
   485
sl@0
   486
	TEST(ret==KErrNone);
sl@0
   487
	TRAP(ret,device->CreateControlL(printerport));
sl@0
   488
	INFO_PRINTF2(_L("CreateControlL() returns %d"), ret);
sl@0
   489
	TEST(ret==KErrNone);
sl@0
   490
	
sl@0
   491
	// Create context
sl@0
   492
	TRAP(ret,testPrint(device));
sl@0
   493
	TEST(ret==KErrNone);
sl@0
   494
	INFO_PRINTF2(_L("...testPrint() returns %d"), ret);
sl@0
   495
sl@0
   496
	INFO_PRINTF1(_L("Delete printer driver"));	
sl@0
   497
sl@0
   498
	delete driver;
sl@0
   499
	delete iStopper;
sl@0
   500
sl@0
   501
	__UHEAP_MARKEND;
sl@0
   502
	}
sl@0
   503
	
sl@0
   504
	
sl@0
   505
sl@0
   506
void CTPdr::bandTest(TBandingDirection aBandingDirection, TPtrC aName)
sl@0
   507
	{
sl@0
   508
	CBandedDevice* banded = NULL;
sl@0
   509
	TInt expectedWidth=0;
sl@0
   510
	TInt expectedheight=0;
sl@0
   511
	TInt ret = KErrNone;
sl@0
   512
	TRect rect(0,0,1000,1000);
sl@0
   513
	TSize size;
sl@0
   514
	size.iWidth = size.iHeight = 2000;
sl@0
   515
	TRect outRect;
sl@0
   516
sl@0
   517
	if( aBandingDirection==EBandingLeftToRight || aBandingDirection==EBandingRightToLeft )
sl@0
   518
		{
sl@0
   519
		expectedWidth=32;
sl@0
   520
		expectedheight=1000;
sl@0
   521
		}
sl@0
   522
	else if( aBandingDirection==EBandingBottomToTop || aBandingDirection==EBandingTopToBottom )
sl@0
   523
		{
sl@0
   524
		expectedWidth=1000;
sl@0
   525
		expectedheight=32;
sl@0
   526
		}
sl@0
   527
sl@0
   528
	TRAP(ret, banded=CBandedDevice::NewL(rect,size,EColor256,aBandingDirection,0));
sl@0
   529
	TEST(ret==KErrNone);
sl@0
   530
sl@0
   531
	banded->NextBand();
sl@0
   532
	banded->NextBand();
sl@0
   533
	outRect = banded->BandRect();
sl@0
   534
sl@0
   535
	TEST(outRect.Width() == expectedWidth && outRect.Height() == expectedheight);
sl@0
   536
	
sl@0
   537
	INFO_PRINTF2(_L("*** BandRect call (%s) ***"), &aName[0]);
sl@0
   538
	INFO_PRINTF3(_L("Expected results are Width=%d, Height=%d."), expectedWidth, expectedheight);
sl@0
   539
	INFO_PRINTF3(_L("Actual results are Width=%d, Height=%d."), outRect.Width(), outRect.Height());
sl@0
   540
	INFO_PRINTF5(_L("Tlx: %d, Tly: %d, Brx: %d, Bry: %d"), outRect.iTl.iX, outRect.iTl.iY, outRect.iBr.iX, outRect.iBr.iY);
sl@0
   541
sl@0
   542
	delete banded;
sl@0
   543
	}
sl@0
   544
sl@0
   545
void CTPdr::testPdrBandRect()
sl@0
   546
	{
sl@0
   547
	INFO_PRINTF1(_L("Running BandRect tests"));
sl@0
   548
sl@0
   549
	__UHEAP_MARK;
sl@0
   550
	bandTest(EBandingLeftToRight, _L("EBandingLeftToRight"));
sl@0
   551
	bandTest(EBandingBottomToTop, _L("EBandingBottomToTop"));
sl@0
   552
	bandTest(EBandingRightToLeft, _L("EBandingRightToLeft"));
sl@0
   553
	bandTest(EBandingTopToBottom, _L("EBandingTopToBottom"));
sl@0
   554
	__UHEAP_MARKEND;
sl@0
   555
	
sl@0
   556
	INFO_PRINTF1(_L("BandRect tests completed"));
sl@0
   557
	}
sl@0
   558
sl@0
   559
sl@0
   560
void CTPdr::RunTestCaseL(TInt aCurTestCase)
sl@0
   561
    {
sl@0
   562
	((CTPdrStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
   563
	switch(aCurTestCase)
sl@0
   564
		{
sl@0
   565
		case 1:
sl@0
   566
			{
sl@0
   567
			INFO_PRINTF1(_L("TEST CASE1 - testPdrStore"));
sl@0
   568
/**
sl@0
   569
@SYMTestCaseID			GRAPHICS-PDR-0001
sl@0
   570
*/
sl@0
   571
			((CTPdrStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDR-0001"));
sl@0
   572
			do 
sl@0
   573
				{
sl@0
   574
				testPdrStore();
sl@0
   575
				iModelIndex++;
sl@0
   576
				}
sl@0
   577
			while (iModelIndex < iNumModels);
sl@0
   578
			INFO_PRINTF1(_L("TEST CASE1 - ended!\n"));
sl@0
   579
			break;				
sl@0
   580
			}
sl@0
   581
		case 2:
sl@0
   582
			{
sl@0
   583
			INFO_PRINTF1(_L("TEST CASE2 - testPdrBandRect"));
sl@0
   584
/**
sl@0
   585
@SYMTestCaseID			GRAPHICS-PDR-0002
sl@0
   586
*/
sl@0
   587
			((CTPdrStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDR-0002"));
sl@0
   588
			testPdrBandRect();
sl@0
   589
			INFO_PRINTF1(_L("TEST CASE2 - ended!\n"));
sl@0
   590
			break;	
sl@0
   591
			}
sl@0
   592
		case 3:
sl@0
   593
			{
sl@0
   594
			((CTPdrStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   595
			((CTPdrStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   596
			TestComplete();
sl@0
   597
			break;	
sl@0
   598
			}
sl@0
   599
		}
sl@0
   600
		((CTPdrStep*)iStep)->RecordTestResultL();
sl@0
   601
    }
sl@0
   602
sl@0
   603
sl@0
   604
sl@0
   605
//--------------
sl@0
   606
__CONSTRUCT_STEP__(Pdr)
sl@0
   607
sl@0
   608
void CTPdrStep::TestSetupL()
sl@0
   609
	{
sl@0
   610
	FbsStartup();
sl@0
   611
	User::LeaveIfError(RFbsSession::Connect());
sl@0
   612
	}
sl@0
   613
	
sl@0
   614
void CTPdrStep::TestClose()
sl@0
   615
	{
sl@0
   616
	RFbsSession::Disconnect();
sl@0
   617
	}
sl@0
   618
sl@0
   619