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