1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/printingservices/printerdriversupport/tps/T_PDR.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,619 @@
1.4 +// Copyright (c) 2006-2009 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 +/**
1.20 + @file
1.21 + @test
1.22 + @internalComponent Internal Symbian test code
1.23 +*/
1.24 +
1.25 +#include "T_PDR.H"
1.26 +#include <graphics/fbsdefs.h>
1.27 +
1.28 +
1.29 +#if defined (__WINS__)
1.30 +#define PDD_NAME _L("ECDRV")
1.31 +#define LDD_NAME _L("ECOMM")
1.32 +#else
1.33 +#define PDD_NAME _L("EUART1")
1.34 +#define LDD_NAME _L("ECOMM")
1.35 +#endif
1.36 +
1.37 +// Set KVerboseOutput to "ETrue" if extra INFO_PRINTFx for debug purposes are required
1.38 +const TBool KVerboseOutput = EFalse;
1.39 +
1.40 +_LIT( KDriveName, "z:" );
1.41 +_LIT( KEpsonFileName, "epson.pdr" );
1.42 +
1.43 +//--------------------------------------------------------------------------------
1.44 +void CPdrTestPrint::RunL()
1.45 + {
1.46 + CActiveScheduler::Stop();
1.47 + }
1.48 +
1.49 +TRequestStatus& CPdrTestPrint::Queue()
1.50 + {
1.51 + SetActive();
1.52 + return iStatus;
1.53 + }
1.54 +
1.55 +TRequestStatus& CPdrTestPrint::Status()
1.56 + {
1.57 + return iStatus;
1.58 + }
1.59 +
1.60 +//-------------------------------------------------------------------------------
1.61 +
1.62 +CTPdr::CTPdr(CTestStep* aStep) :
1.63 + CTGraphicsBase(aStep)
1.64 + {
1.65 + }
1.66 +
1.67 +CTPdr::~CTPdr()
1.68 + {
1.69 + }
1.70 +
1.71 +
1.72 +void CTPdr::ConstructL()
1.73 + {
1.74 + INFO_PRINTF1(_L( "Start the various bits and pieces of the comms server\n" ));
1.75 +
1.76 + TInt ret;
1.77 +#if !defined(__X86GCC__)
1.78 + ret=User::LoadPhysicalDevice(PDD_NAME);
1.79 + TEST(ret==KErrNone || ret==KErrAlreadyExists);
1.80 +
1.81 + ret=User::LoadLogicalDevice(LDD_NAME);
1.82 + TEST(ret==KErrNone || ret==KErrAlreadyExists);
1.83 +#endif
1.84 +
1.85 + // to avoid alloc heaven with the fbs server
1.86 + CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
1.87 + CleanupStack::PushL(bitmap);
1.88 + User::LeaveIfError(bitmap->Create(TSize(1024, 1024), EColor16MA));
1.89 + CleanupStack::PopAndDestroy(bitmap);
1.90 +
1.91 + // to avoid alloc heaven with the fbs server
1.92 + CFbsBitmap bmp1;
1.93 + CFbsBitmap bmp2;
1.94 + ret=bmp1.Load(_L("z:\\test\\pdrstore.mbm"),0,NULL); // sheep
1.95 + TEST(ret==KErrNone);
1.96 + ret=bmp2.Load(_L("z:\\test\\pdrstore.mbm"),1,NULL); // pslogo
1.97 + TEST(ret==KErrNone);
1.98 + bmp1.Reset();
1.99 + bmp2.Reset();
1.100 + }
1.101 +
1.102 +
1.103 +void CTPdr::testPrint(CPrinterDevice* aDevice)
1.104 + {
1.105 + INFO_PRINTF1(_L("calling testPrint()..."));
1.106 +
1.107 + CFbsBitmap bmp1;
1.108 + CFbsBitmap bmp2;
1.109 +
1.110 + TInt ret=bmp1.Load(_L("z:\\test\\pdrstore.mbm"),0,EFalse); // sheep
1.111 + TEST(ret==KErrNone);
1.112 + ret=bmp2.Load(_L("z:\\test\\pdrstore.mbm"),1,EFalse); // pslogo
1.113 + TEST(ret==KErrNone);
1.114 +
1.115 + bmp1.SetSizeInTwips(TSize(3000,1500));
1.116 + bmp2.SetSizeInTwips(TSize(2000,900));
1.117 +
1.118 + TBandAttributes attributes;
1.119 + CPrinterControl::TMoreOnPage moreonpage=CPrinterControl::EMoreOnPage;
1.120 +
1.121 + TInt h=aDevice->HorizontalPixelsToTwips(1000);
1.122 + TInt v=aDevice->VerticalPixelsToTwips(1000);
1.123 + TInt k=4800;
1.124 +
1.125 + TInt i=0;
1.126 + do
1.127 + {
1.128 + if (KVerboseOutput)
1.129 + {
1.130 + INFO_PRINTF2(_L("Get band %d"),i+1);
1.131 + }
1.132 + moreonpage=aDevice->iControl->QueueGetBand(iStopper->Queue(),attributes);
1.133 + CActiveScheduler::Start();
1.134 +
1.135 + CGraphicsContext* gc=NULL;
1.136 + ret=aDevice->CreateContext((CGraphicsContext *&) gc);
1.137 + TEST(ret==KErrNone);
1.138 +
1.139 + gc->SetPenColor(KRgbBlack);
1.140 + gc->SetPenStyle(CGraphicsContext::ESolidPen);
1.141 + gc->SetPenSize(TSize(4*k/h,4*k/v));
1.142 + gc->DrawEllipse(TRect(391,352,1152,601));
1.143 + gc->DrawEllipse(TRect(391,336,1152,585));
1.144 + gc->Reset();
1.145 + gc->DrawEllipse(TRect(727,693,1488,942));
1.146 + gc->DrawEllipse(TRect(727,677,1488,926));
1.147 + CFont *font;
1.148 + TFontSpec spec (_L("CG Times"),300);
1.149 + spec.iTypeface.SetIsProportional(ETrue);
1.150 + ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.151 + TEST(ret==KErrNone);
1.152 +
1.153 + if (KVerboseOutput)
1.154 + {
1.155 + INFO_PRINTF2(_L("TextWidthInPixels(HELLO WORLD) %d"),font->TextWidthInPixels(_L("HELLO WORLD")));
1.156 + }
1.157 +
1.158 + gc->UseFont(font);
1.159 + gc->SetUnderlineStyle(EUnderlineOn);
1.160 + gc->DrawText(_L("HELLO WORLD"),TRect(300*k/h,200*k/v,1800*k/h,300*k/v),100*k/v,CGraphicsContext::ELeft,0);
1.161 + gc->SetUnderlineStyle(EUnderlineOff);
1.162 + gc->DrawText(_L("HELLO WORLD"),TRect(300*k/h,200*k/v,1800*k/h,300*k/v),100*k/v,CGraphicsContext::ERight,0);
1.163 + gc->DrawText(_L("HELLO WORLD"),TRect(300*k/h,200*k/v,1800*k/h,300*k/v),100*k/v,CGraphicsContext::ECenter,0);
1.164 +
1.165 + TBuf<20> text;
1.166 + text.Format(_L("Test symbols %c %c %c %c"),130,131,132,133);
1.167 +
1.168 + gc->SetPenColor(KRgbBlack);
1.169 + gc->DrawText(text,TRect(1000*k/h,2500*k/v,1800*k/h,2700*k/v),50*k/v,CGraphicsContext::ELeft,0);
1.170 + gc->SetWordJustification(1200*k/h,4);
1.171 + 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);
1.172 + 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);
1.173 + aDevice->ReleaseFont(font);
1.174 +
1.175 + ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.176 + TEST(ret==KErrNone);
1.177 + gc->UseFont(font);
1.178 + 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);
1.179 + spec.iFontStyle.SetPrintPosition(EPrintPosSuperscript);
1.180 + aDevice->ReleaseFont(font);
1.181 + ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.182 + TEST(ret==KErrNone);
1.183 + gc->UseFont(font);
1.184 + 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);
1.185 + aDevice->ReleaseFont(font);
1.186 + spec.iFontStyle.SetPrintPosition(EPrintPosSubscript);
1.187 + ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.188 + TEST(ret==KErrNone);
1.189 + gc->UseFont(font);
1.190 + gc->SetBrushColor(KRgbWhite);
1.191 + gc->SetBrushStyle(CGraphicsContext::ENullBrush);
1.192 + 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);
1.193 + aDevice->ReleaseFont(font);
1.194 +
1.195 + // Draw bitmap
1.196 + gc->DrawBitmap(TPoint(800*k/h,900*k/v),&bmp1);
1.197 + gc->DrawBitmap(TPoint(1700*k/h,3100*k/v),&bmp2);
1.198 + gc->DrawBitmap(TPoint(1000*k/h,1400*k/v),&bmp2);
1.199 + gc->DrawBitmap(TPoint(100*k/h,1700*k/v),&bmp2);
1.200 +
1.201 + // Draw line
1.202 + gc->SetPenSize(TSize(30*k/h,30*k/v));
1.203 + gc->DrawLine(TPoint(800*k/h,100*k/v),TPoint(2000*k/h,100*k/v));
1.204 + gc->DrawLine(TPoint(1500*k/h,400*k/v),TPoint(1800*k/h,1500*k/v));
1.205 +
1.206 + // Draw rectangle
1.207 + gc->SetPenSize(TSize(4*k/h,4*k/v));
1.208 + gc->SetBrushStyle(CGraphicsContext::ENullBrush);
1.209 + gc->SetBrushColor(KRgbWhite);
1.210 + gc->DrawRect(TRect(300*k/h,200*k/v,1800*k/h,300*k/v));
1.211 +
1.212 + // Draw circle
1.213 + gc->SetPenSize(TSize(10*k/h,10*k/v));
1.214 + gc->DrawEllipse(TRect(300*k/h,2600*k/v,700*k/h,3000*k/v));
1.215 +
1.216 + // Plot point
1.217 + gc->SetPenSize(TSize(20*k/h,20*k/v));
1.218 + gc->Plot(TPoint(1800*k/h,1600*k/v));
1.219 +
1.220 + delete gc;
1.221 +
1.222 + if (KVerboseOutput)
1.223 + {
1.224 + INFO_PRINTF2(_L("End of band %d"),i+1);
1.225 + }
1.226 + i++;
1.227 + }
1.228 +
1.229 + while (moreonpage==CPrinterControl::EMoreOnPage);
1.230 + INFO_PRINTF1(_L("QueueEndPrint"));
1.231 + aDevice->iControl->QueueEndPrint(iStopper->Queue());
1.232 + CActiveScheduler::Start();
1.233 + INFO_PRINTF2(_L("Request status %d"),iStopper->Status().Int());
1.234 +
1.235 + bmp2.Reset();
1.236 + bmp1.Reset();
1.237 +
1.238 + }
1.239 +
1.240 +
1.241 +//
1.242 +// Test read file handling.
1.243 +//
1.244 +void CTPdr::testPdrStore()
1.245 + {
1.246 + __UHEAP_MARK;
1.247 +
1.248 + INFO_PRINTF1(_L("Add to the active scheduler"));
1.249 + iStopper=new(ELeave) CPdrTestPrint();
1.250 + CActiveScheduler::Add(iStopper);
1.251 +
1.252 + // Open file
1.253 + INFO_PRINTF1(_L("OpenPdrL(pdr file)"));
1.254 + CPrinterDriver* driver=NULL;
1.255 + TRAPD(ret,driver=CPrinterDriver::NewL());
1.256 + TEST(ret==KErrNone);
1.257 +
1.258 + TFileName filename( KDriveName );
1.259 + filename.Append( KDefaultPrinterDriverPath );
1.260 + filename.Append( KEpsonFileName );
1.261 +
1.262 + TRAP(ret,driver->OpenPdrL( filename ));
1.263 + TEST(ret==KErrNone);
1.264 + INFO_PRINTF2(_L("NumModels %d"),driver->NumModels());
1.265 +
1.266 + // Get model info
1.267 + TPrinterModelEntry entry;
1.268 + TInt i = 0;
1.269 + iNumModels = driver->NumModels();
1.270 + for (i=0; i<iNumModels; i++)
1.271 + {
1.272 + entry=driver->Model(i);
1.273 + INFO_PRINTF2(_L(" *********************** ModelName %S"),&entry.iModelName);
1.274 + }
1.275 +
1.276 + // Create device
1.277 + INFO_PRINTF1(_L("Create printer device"));
1.278 + CPrinterDevice* device=NULL;
1.279 + entry=driver->Model(iModelIndex);
1.280 + TRAP(ret,device=driver->CreatePrinterDeviceL(entry.iUid));
1.281 + TEST(ret==KErrNone);
1.282 + CPrinterDriverUI* driverui=NULL;
1.283 + TRAP(ret,driverui=driver->CreatePrinterDriverUIL());
1.284 + INFO_PRINTF2(_L("DriverUI %d"),driverui);
1.285 + delete driverui;
1.286 +
1.287 + INFO_PRINTF2(_L("NumTypefaces %d"),device->NumTypefaces());
1.288 + INFO_PRINTF2(_L("**Model name %S**"),&entry.iModelName);
1.289 + INFO_PRINTF2(_L("KPixelWidthInTwips %d"),device->HorizontalPixelsToTwips(1000));
1.290 + INFO_PRINTF2(_L("KPixelHeightInTwips %d"),device->VerticalPixelsToTwips(1000));
1.291 + TPageSpec pagespec(TPageSpec::EPortrait,KA4PaperSizeInTwips);
1.292 + device->SelectPageSpecInTwips(pagespec);
1.293 +
1.294 + // Get typeface info
1.295 + INFO_PRINTF1(_L("Get typeface info"));
1.296 + TTypefaceSupport support;
1.297 + device->TypefaceSupport(support,0);
1.298 + TBuf<KMaxTypefaceNameLength> name;
1.299 + name.Copy(support.iTypeface.iName);
1.300 + INFO_PRINTF2(_L("Typeface Name %S"),&name);
1.301 + INFO_PRINTF2(_L("Typeface serif %d"),support.iTypeface.IsSerif());
1.302 + INFO_PRINTF2(_L("Typeface proportional %d"),support.iTypeface.IsProportional());
1.303 + INFO_PRINTF2(_L("Typeface symbol %d"),support.iTypeface.IsSymbol());
1.304 + INFO_PRINTF2(_L("NumHeights %d"),support.iNumHeights);
1.305 + INFO_PRINTF2(_L("MinHeightInTwips %d"),support.iMinHeightInTwips);
1.306 + INFO_PRINTF2(_L("MaxHeightInTwips %d"),support.iMaxHeightInTwips);
1.307 + INFO_PRINTF2(_L("IsScalable %d"),support.iIsScalable);
1.308 +
1.309 + // Get nearest font
1.310 + INFO_PRINTF1(_L("Get nearest font"));
1.311 + CFont *font;
1.312 + TFontSpec spec;
1.313 + support.iTypeface.iName=_L("DejaVu Sans Condensed");
1.314 + support.iTypeface.SetIsProportional(ETrue);
1.315 + support.iTypeface.SetIsSerif(ETrue);
1.316 + spec.iTypeface=support.iTypeface;
1.317 + spec.iHeight=680;
1.318 + spec.iFontStyle.SetPosture(EPostureUpright);
1.319 + spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
1.320 + spec.iFontStyle.SetPrintPosition(EPrintPosNormal);
1.321 + ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.322 + TEST(ret==KErrNone);
1.323 + INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels());
1.324 + INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels());
1.325 + INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight());
1.326 + INFO_PRINTF3(_L("Font AlgPosture %d AlgStrokeWeight %d"),((CBitmapFont*)font)->iAlgStyle.IsItalic(),((CBitmapFont*)font)->iAlgStyle.IsBold());
1.327 + spec=font->FontSpecInTwips();
1.328 + device->ReleaseFont(font);
1.329 + ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.330 + TEST(ret==KErrNone);
1.331 + INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels());
1.332 + INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels());
1.333 + INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight());
1.334 + INFO_PRINTF3(_L("Font AlgPosture %d AlgStrokeWeight %d"),((CBitmapFont*)font)->iAlgStyle.IsItalic(),((CBitmapFont*)font)->iAlgStyle.IsBold());
1.335 + name.Copy(font->FontSpecInTwips().iTypeface.iName);
1.336 + INFO_PRINTF2(_L("Typeface Name %S"),&name);
1.337 + INFO_PRINTF2(_L("Typeface Proportional %d"),font->FontSpecInTwips().iTypeface.IsProportional());
1.338 + INFO_PRINTF2(_L("Typeface Serif %d"),font->FontSpecInTwips().iTypeface.IsSerif());
1.339 + INFO_PRINTF2(_L("CharWidthInPixels(32) %d"),font->CharWidthInPixels(TChar(32)));
1.340 + INFO_PRINTF2(_L("MaxCharWidthInPixels %d"),font->MaxCharWidthInPixels());
1.341 + INFO_PRINTF2(_L("MaxNormalCharWidthInPixels %d"),font->MaxNormalCharWidthInPixels());
1.342 + INFO_PRINTF2(_L("HeightInTwips %d"),font->FontSpecInTwips().iHeight);
1.343 + INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels());
1.344 + INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels());
1.345 + INFO_PRINTF2(_L("TextWidthInPixels(HELLO WORLD) %d"),font->TextWidthInPixels(_L("HELLO WORLD")));
1.346 + device->ReleaseFont(font);
1.347 +
1.348 + spec.iHeight=1000;
1.349 + spec.iFontStyle.SetPrintPosition(EPrintPosNormal);
1.350 +
1.351 + spec.iFontStyle.SetPrintPosition(EPrintPosNormal);
1.352 + spec.iFontStyle.SetPosture(EPostureUpright);
1.353 + spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
1.354 + for (i=0; i<device->NumTypefaces(); i++)
1.355 + {
1.356 + device->TypefaceSupport(support,i);
1.357 + name.Copy(support.iTypeface.iName);
1.358 + INFO_PRINTF2(_L("Typeface Name %S"),&name);
1.359 + for (TInt j=0; j<support.iNumHeights; j++)
1.360 + {
1.361 + spec.iTypeface=support.iTypeface;
1.362 + spec.iHeight=device->FontHeightInTwips(i,j);
1.363 + ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.364 + TEST(ret==KErrNone);
1.365 + if (KVerboseOutput)
1.366 + {
1.367 + INFO_PRINTF2(_L("Spec HeightInTwips %d"),spec.iHeight);
1.368 + INFO_PRINTF2(_L("Font HeightInTwipss %d"),font->FontSpecInTwips().iHeight);
1.369 + INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight());
1.370 + }
1.371 + device->ReleaseFont(font);
1.372 + }
1.373 + }
1.374 +
1.375 + RFile file;
1.376 + RFs fs;
1.377 + ret=fs.Connect();
1.378 + TEST(ret==KErrNone);
1.379 + _LIT(KPath,"C:\\system\\data\\");
1.380 + fs.MkDirAll(KPath);
1.381 + ret=file.Replace(fs,_L("C:\\system\\data\\WIDTHS.TMP"),EFileStream|EFileWrite);
1.382 + if (ret!=KErrNone)
1.383 + {
1.384 + _LIT(KLog,"Doing Replace on file C:\\system\\data\\WIDTHS.TMP gave error %d");
1.385 + INFO_PRINTF2(KLog,ret);
1.386 + }
1.387 + TEST(ret==KErrNone);
1.388 +
1.389 + TBuf8<120> buf;
1.390 +
1.391 + for (i=0; i<device->NumTypefaces(); i++)
1.392 + {
1.393 + device->TypefaceSupport(support,i);
1.394 + spec.iTypeface=support.iTypeface;
1.395 + for (TInt k=0; k<support.iNumHeights; k++)
1.396 + {
1.397 + spec.iHeight=device->FontHeightInTwips(i,k);
1.398 + if ((spec.iHeight==1000))
1.399 + {
1.400 + for (TInt j=0; j<4; j++)
1.401 + {
1.402 + name.Copy(support.iTypeface.iName);
1.403 + buf.Format(_L8("FontInfo %S"),&support.iTypeface.iName);
1.404 + ret=file.Write(buf);
1.405 + TEST(ret==KErrNone);
1.406 + if (j==0)
1.407 + {
1.408 + buf.Format(_L8("Std%d"),spec.iHeight/20);
1.409 + ret=file.Write(buf);
1.410 + TEST(ret==KErrNone);
1.411 + spec.iFontStyle.SetPosture(EPostureUpright);
1.412 + spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
1.413 + }
1.414 + if (j==1)
1.415 + {
1.416 + buf.Format(_L8("Bold%d"),spec.iHeight/20);
1.417 + ret=file.Write(buf);
1.418 + TEST(ret==KErrNone);
1.419 + spec.iFontStyle.SetPosture(EPostureUpright);
1.420 + spec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
1.421 + }
1.422 + if (j==2)
1.423 + {
1.424 + buf.Format(_L8("Italic%d"),spec.iHeight/20);
1.425 + ret=file.Write(buf);
1.426 + TEST(ret==KErrNone);
1.427 + spec.iFontStyle.SetPosture(EPostureItalic);
1.428 + spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
1.429 + }
1.430 + if (j==3)
1.431 + {
1.432 + buf.Format(_L8("BoldItalic%d"),spec.iHeight/20);
1.433 + ret=file.Write(buf);
1.434 + TEST(ret==KErrNone);
1.435 + spec.iFontStyle.SetPosture(EPostureItalic);
1.436 + spec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
1.437 + }
1.438 + ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec);
1.439 + TEST(ret==KErrNone);
1.440 + INFO_PRINTF4(_L("Name %S Height %d CharWidthInPixels(W) %d"),&name,font->FontSpecInTwips().iHeight,font->CharWidthInPixels(TChar('W')));
1.441 + buf.Format(_L8("MaxNormalCharWidth %dAscent %d"),font->MaxNormalCharWidthInPixels(),font->AscentInPixels());
1.442 + ret=file.Write(buf);
1.443 + TEST(ret==KErrNone);
1.444 + ret=file.Write(_L8("CodeSection 0:255"));
1.445 + TEST(ret==KErrNone);
1.446 + for (TInt l=0; l<256; l++)
1.447 + {
1.448 + if (font->CharWidthInPixels(k))
1.449 + {
1.450 + buf.Format(_L8("%d:%d "),l,font->CharWidthInPixels(l));
1.451 + ret=file.Write(buf);
1.452 + TEST(ret==KErrNone);
1.453 + }
1.454 + if (((l/8)*8)==l)
1.455 + {
1.456 + ret=file.Write(_L8("\n"));
1.457 + TEST(ret==KErrNone);
1.458 + }
1.459 + }
1.460 + ret=file.Write(_L8("\nEndCodeSection\nEndFontInfo\n"));
1.461 + TEST(ret==KErrNone);
1.462 + device->ReleaseFont(font);
1.463 + }
1.464 + }
1.465 + }
1.466 + }
1.467 + file.Flush();
1.468 + file.Close();
1.469 + fs.Close();
1.470 +
1.471 + // Create control
1.472 + INFO_PRINTF1(_L("Create control"));
1.473 +
1.474 + CPrinterPort* printerport=NULL;
1.475 +#if defined (__WINS__)
1.476 + if (device->Model().iRequiresPrinterPort)
1.477 + {
1.478 + TRAP(ret,printerport=CFilePrinterPort::NewL(_L("c:\\Printfile")));
1.479 + }
1.480 +#else
1.481 + if (device->Model().iRequiresPrinterPort)
1.482 + {
1.483 + TRAP(ret,printerport=CFilePrinterPort::NewL(_L("c:\\temp.prn")));
1.484 + INFO_PRINTF2(_L("ret %d"),ret);
1.485 + INFO_PRINTF2(_L("device displaymode %d"),device->DisplayMode());
1.486 + }
1.487 +#endif
1.488 +
1.489 + TEST(ret==KErrNone);
1.490 + TRAP(ret,device->CreateControlL(printerport));
1.491 + INFO_PRINTF2(_L("CreateControlL() returns %d"), ret);
1.492 + TEST(ret==KErrNone);
1.493 +
1.494 + // Create context
1.495 + TRAP(ret,testPrint(device));
1.496 + TEST(ret==KErrNone);
1.497 + INFO_PRINTF2(_L("...testPrint() returns %d"), ret);
1.498 +
1.499 + INFO_PRINTF1(_L("Delete printer driver"));
1.500 +
1.501 + delete driver;
1.502 + delete iStopper;
1.503 +
1.504 + __UHEAP_MARKEND;
1.505 + }
1.506 +
1.507 +
1.508 +
1.509 +void CTPdr::bandTest(TBandingDirection aBandingDirection, TPtrC aName)
1.510 + {
1.511 + CBandedDevice* banded = NULL;
1.512 + TInt expectedWidth=0;
1.513 + TInt expectedheight=0;
1.514 + TInt ret = KErrNone;
1.515 + TRect rect(0,0,1000,1000);
1.516 + TSize size;
1.517 + size.iWidth = size.iHeight = 2000;
1.518 + TRect outRect;
1.519 +
1.520 + if( aBandingDirection==EBandingLeftToRight || aBandingDirection==EBandingRightToLeft )
1.521 + {
1.522 + expectedWidth=32;
1.523 + expectedheight=1000;
1.524 + }
1.525 + else if( aBandingDirection==EBandingBottomToTop || aBandingDirection==EBandingTopToBottom )
1.526 + {
1.527 + expectedWidth=1000;
1.528 + expectedheight=32;
1.529 + }
1.530 +
1.531 + TRAP(ret, banded=CBandedDevice::NewL(rect,size,EColor256,aBandingDirection,0));
1.532 + TEST(ret==KErrNone);
1.533 +
1.534 + banded->NextBand();
1.535 + banded->NextBand();
1.536 + outRect = banded->BandRect();
1.537 +
1.538 + TEST(outRect.Width() == expectedWidth && outRect.Height() == expectedheight);
1.539 +
1.540 + INFO_PRINTF2(_L("*** BandRect call (%s) ***"), &aName[0]);
1.541 + INFO_PRINTF3(_L("Expected results are Width=%d, Height=%d."), expectedWidth, expectedheight);
1.542 + INFO_PRINTF3(_L("Actual results are Width=%d, Height=%d."), outRect.Width(), outRect.Height());
1.543 + INFO_PRINTF5(_L("Tlx: %d, Tly: %d, Brx: %d, Bry: %d"), outRect.iTl.iX, outRect.iTl.iY, outRect.iBr.iX, outRect.iBr.iY);
1.544 +
1.545 + delete banded;
1.546 + }
1.547 +
1.548 +void CTPdr::testPdrBandRect()
1.549 + {
1.550 + INFO_PRINTF1(_L("Running BandRect tests"));
1.551 +
1.552 + __UHEAP_MARK;
1.553 + bandTest(EBandingLeftToRight, _L("EBandingLeftToRight"));
1.554 + bandTest(EBandingBottomToTop, _L("EBandingBottomToTop"));
1.555 + bandTest(EBandingRightToLeft, _L("EBandingRightToLeft"));
1.556 + bandTest(EBandingTopToBottom, _L("EBandingTopToBottom"));
1.557 + __UHEAP_MARKEND;
1.558 +
1.559 + INFO_PRINTF1(_L("BandRect tests completed"));
1.560 + }
1.561 +
1.562 +
1.563 +void CTPdr::RunTestCaseL(TInt aCurTestCase)
1.564 + {
1.565 + ((CTPdrStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.566 + switch(aCurTestCase)
1.567 + {
1.568 + case 1:
1.569 + {
1.570 + INFO_PRINTF1(_L("TEST CASE1 - testPdrStore"));
1.571 +/**
1.572 +@SYMTestCaseID GRAPHICS-PDR-0001
1.573 +*/
1.574 + ((CTPdrStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDR-0001"));
1.575 + do
1.576 + {
1.577 + testPdrStore();
1.578 + iModelIndex++;
1.579 + }
1.580 + while (iModelIndex < iNumModels);
1.581 + INFO_PRINTF1(_L("TEST CASE1 - ended!\n"));
1.582 + break;
1.583 + }
1.584 + case 2:
1.585 + {
1.586 + INFO_PRINTF1(_L("TEST CASE2 - testPdrBandRect"));
1.587 +/**
1.588 +@SYMTestCaseID GRAPHICS-PDR-0002
1.589 +*/
1.590 + ((CTPdrStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDR-0002"));
1.591 + testPdrBandRect();
1.592 + INFO_PRINTF1(_L("TEST CASE2 - ended!\n"));
1.593 + break;
1.594 + }
1.595 + case 3:
1.596 + {
1.597 + ((CTPdrStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.598 + ((CTPdrStep*)iStep)->CloseTMSGraphicsStep();
1.599 + TestComplete();
1.600 + break;
1.601 + }
1.602 + }
1.603 + ((CTPdrStep*)iStep)->RecordTestResultL();
1.604 + }
1.605 +
1.606 +
1.607 +
1.608 +//--------------
1.609 +__CONSTRUCT_STEP__(Pdr)
1.610 +
1.611 +void CTPdrStep::TestSetupL()
1.612 + {
1.613 + FbsStartup();
1.614 + User::LeaveIfError(RFbsSession::Connect());
1.615 + }
1.616 +
1.617 +void CTPdrStep::TestClose()
1.618 + {
1.619 + RFbsSession::Disconnect();
1.620 + }
1.621 +
1.622 +