sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent Internal Symbian test code sl@0: */ sl@0: sl@0: #include "T_PDR.H" sl@0: #include sl@0: sl@0: sl@0: #if defined (__WINS__) sl@0: #define PDD_NAME _L("ECDRV") sl@0: #define LDD_NAME _L("ECOMM") sl@0: #else sl@0: #define PDD_NAME _L("EUART1") sl@0: #define LDD_NAME _L("ECOMM") sl@0: #endif sl@0: sl@0: // Set KVerboseOutput to "ETrue" if extra INFO_PRINTFx for debug purposes are required sl@0: const TBool KVerboseOutput = EFalse; sl@0: sl@0: _LIT( KDriveName, "z:" ); sl@0: _LIT( KEpsonFileName, "epson.pdr" ); sl@0: sl@0: //-------------------------------------------------------------------------------- sl@0: void CPdrTestPrint::RunL() sl@0: { sl@0: CActiveScheduler::Stop(); sl@0: } sl@0: sl@0: TRequestStatus& CPdrTestPrint::Queue() sl@0: { sl@0: SetActive(); sl@0: return iStatus; sl@0: } sl@0: sl@0: TRequestStatus& CPdrTestPrint::Status() sl@0: { sl@0: return iStatus; sl@0: } sl@0: sl@0: //------------------------------------------------------------------------------- sl@0: sl@0: CTPdr::CTPdr(CTestStep* aStep) : sl@0: CTGraphicsBase(aStep) sl@0: { sl@0: } sl@0: sl@0: CTPdr::~CTPdr() sl@0: { sl@0: } sl@0: sl@0: sl@0: void CTPdr::ConstructL() sl@0: { sl@0: INFO_PRINTF1(_L( "Start the various bits and pieces of the comms server\n" )); sl@0: sl@0: TInt ret; sl@0: #if !defined(__X86GCC__) sl@0: ret=User::LoadPhysicalDevice(PDD_NAME); sl@0: TEST(ret==KErrNone || ret==KErrAlreadyExists); sl@0: sl@0: ret=User::LoadLogicalDevice(LDD_NAME); sl@0: TEST(ret==KErrNone || ret==KErrAlreadyExists); sl@0: #endif sl@0: sl@0: // to avoid alloc heaven with the fbs server sl@0: CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bitmap); sl@0: User::LeaveIfError(bitmap->Create(TSize(1024, 1024), EColor16MA)); sl@0: CleanupStack::PopAndDestroy(bitmap); sl@0: sl@0: // to avoid alloc heaven with the fbs server sl@0: CFbsBitmap bmp1; sl@0: CFbsBitmap bmp2; sl@0: ret=bmp1.Load(_L("z:\\test\\pdrstore.mbm"),0,NULL); // sheep sl@0: TEST(ret==KErrNone); sl@0: ret=bmp2.Load(_L("z:\\test\\pdrstore.mbm"),1,NULL); // pslogo sl@0: TEST(ret==KErrNone); sl@0: bmp1.Reset(); sl@0: bmp2.Reset(); sl@0: } sl@0: sl@0: sl@0: void CTPdr::testPrint(CPrinterDevice* aDevice) sl@0: { sl@0: INFO_PRINTF1(_L("calling testPrint()...")); sl@0: sl@0: CFbsBitmap bmp1; sl@0: CFbsBitmap bmp2; sl@0: sl@0: TInt ret=bmp1.Load(_L("z:\\test\\pdrstore.mbm"),0,EFalse); // sheep sl@0: TEST(ret==KErrNone); sl@0: ret=bmp2.Load(_L("z:\\test\\pdrstore.mbm"),1,EFalse); // pslogo sl@0: TEST(ret==KErrNone); sl@0: sl@0: bmp1.SetSizeInTwips(TSize(3000,1500)); sl@0: bmp2.SetSizeInTwips(TSize(2000,900)); sl@0: sl@0: TBandAttributes attributes; sl@0: CPrinterControl::TMoreOnPage moreonpage=CPrinterControl::EMoreOnPage; sl@0: sl@0: TInt h=aDevice->HorizontalPixelsToTwips(1000); sl@0: TInt v=aDevice->VerticalPixelsToTwips(1000); sl@0: TInt k=4800; sl@0: sl@0: TInt i=0; sl@0: do sl@0: { sl@0: if (KVerboseOutput) sl@0: { sl@0: INFO_PRINTF2(_L("Get band %d"),i+1); sl@0: } sl@0: moreonpage=aDevice->iControl->QueueGetBand(iStopper->Queue(),attributes); sl@0: CActiveScheduler::Start(); sl@0: sl@0: CGraphicsContext* gc=NULL; sl@0: ret=aDevice->CreateContext((CGraphicsContext *&) gc); sl@0: TEST(ret==KErrNone); sl@0: sl@0: gc->SetPenColor(KRgbBlack); sl@0: gc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc->SetPenSize(TSize(4*k/h,4*k/v)); sl@0: gc->DrawEllipse(TRect(391,352,1152,601)); sl@0: gc->DrawEllipse(TRect(391,336,1152,585)); sl@0: gc->Reset(); sl@0: gc->DrawEllipse(TRect(727,693,1488,942)); sl@0: gc->DrawEllipse(TRect(727,677,1488,926)); sl@0: CFont *font; sl@0: TFontSpec spec (_L("CG Times"),300); sl@0: spec.iTypeface.SetIsProportional(ETrue); sl@0: ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: sl@0: if (KVerboseOutput) sl@0: { sl@0: INFO_PRINTF2(_L("TextWidthInPixels(HELLO WORLD) %d"),font->TextWidthInPixels(_L("HELLO WORLD"))); sl@0: } sl@0: sl@0: gc->UseFont(font); sl@0: gc->SetUnderlineStyle(EUnderlineOn); sl@0: 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: gc->SetUnderlineStyle(EUnderlineOff); sl@0: 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: 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: sl@0: TBuf<20> text; sl@0: text.Format(_L("Test symbols %c %c %c %c"),130,131,132,133); sl@0: sl@0: gc->SetPenColor(KRgbBlack); sl@0: gc->DrawText(text,TRect(1000*k/h,2500*k/v,1800*k/h,2700*k/v),50*k/v,CGraphicsContext::ELeft,0); sl@0: gc->SetWordJustification(1200*k/h,4); sl@0: 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: 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: aDevice->ReleaseFont(font); sl@0: sl@0: ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: gc->UseFont(font); sl@0: 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: spec.iFontStyle.SetPrintPosition(EPrintPosSuperscript); sl@0: aDevice->ReleaseFont(font); sl@0: ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: gc->UseFont(font); sl@0: 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: aDevice->ReleaseFont(font); sl@0: spec.iFontStyle.SetPrintPosition(EPrintPosSubscript); sl@0: ret=aDevice->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: gc->UseFont(font); sl@0: gc->SetBrushColor(KRgbWhite); sl@0: gc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: 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: aDevice->ReleaseFont(font); sl@0: sl@0: // Draw bitmap sl@0: gc->DrawBitmap(TPoint(800*k/h,900*k/v),&bmp1); sl@0: gc->DrawBitmap(TPoint(1700*k/h,3100*k/v),&bmp2); sl@0: gc->DrawBitmap(TPoint(1000*k/h,1400*k/v),&bmp2); sl@0: gc->DrawBitmap(TPoint(100*k/h,1700*k/v),&bmp2); sl@0: sl@0: // Draw line sl@0: gc->SetPenSize(TSize(30*k/h,30*k/v)); sl@0: gc->DrawLine(TPoint(800*k/h,100*k/v),TPoint(2000*k/h,100*k/v)); sl@0: gc->DrawLine(TPoint(1500*k/h,400*k/v),TPoint(1800*k/h,1500*k/v)); sl@0: sl@0: // Draw rectangle sl@0: gc->SetPenSize(TSize(4*k/h,4*k/v)); sl@0: gc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: gc->SetBrushColor(KRgbWhite); sl@0: gc->DrawRect(TRect(300*k/h,200*k/v,1800*k/h,300*k/v)); sl@0: sl@0: // Draw circle sl@0: gc->SetPenSize(TSize(10*k/h,10*k/v)); sl@0: gc->DrawEllipse(TRect(300*k/h,2600*k/v,700*k/h,3000*k/v)); sl@0: sl@0: // Plot point sl@0: gc->SetPenSize(TSize(20*k/h,20*k/v)); sl@0: gc->Plot(TPoint(1800*k/h,1600*k/v)); sl@0: sl@0: delete gc; sl@0: sl@0: if (KVerboseOutput) sl@0: { sl@0: INFO_PRINTF2(_L("End of band %d"),i+1); sl@0: } sl@0: i++; sl@0: } sl@0: sl@0: while (moreonpage==CPrinterControl::EMoreOnPage); sl@0: INFO_PRINTF1(_L("QueueEndPrint")); sl@0: aDevice->iControl->QueueEndPrint(iStopper->Queue()); sl@0: CActiveScheduler::Start(); sl@0: INFO_PRINTF2(_L("Request status %d"),iStopper->Status().Int()); sl@0: sl@0: bmp2.Reset(); sl@0: bmp1.Reset(); sl@0: sl@0: } sl@0: sl@0: sl@0: // sl@0: // Test read file handling. sl@0: // sl@0: void CTPdr::testPdrStore() sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: INFO_PRINTF1(_L("Add to the active scheduler")); sl@0: iStopper=new(ELeave) CPdrTestPrint(); sl@0: CActiveScheduler::Add(iStopper); sl@0: sl@0: // Open file sl@0: INFO_PRINTF1(_L("OpenPdrL(pdr file)")); sl@0: CPrinterDriver* driver=NULL; sl@0: TRAPD(ret,driver=CPrinterDriver::NewL()); sl@0: TEST(ret==KErrNone); sl@0: sl@0: TFileName filename( KDriveName ); sl@0: filename.Append( KDefaultPrinterDriverPath ); sl@0: filename.Append( KEpsonFileName ); sl@0: sl@0: TRAP(ret,driver->OpenPdrL( filename )); sl@0: TEST(ret==KErrNone); sl@0: INFO_PRINTF2(_L("NumModels %d"),driver->NumModels()); sl@0: sl@0: // Get model info sl@0: TPrinterModelEntry entry; sl@0: TInt i = 0; sl@0: iNumModels = driver->NumModels(); sl@0: for (i=0; iModel(i); sl@0: INFO_PRINTF2(_L(" *********************** ModelName %S"),&entry.iModelName); sl@0: } sl@0: sl@0: // Create device sl@0: INFO_PRINTF1(_L("Create printer device")); sl@0: CPrinterDevice* device=NULL; sl@0: entry=driver->Model(iModelIndex); sl@0: TRAP(ret,device=driver->CreatePrinterDeviceL(entry.iUid)); sl@0: TEST(ret==KErrNone); sl@0: CPrinterDriverUI* driverui=NULL; sl@0: TRAP(ret,driverui=driver->CreatePrinterDriverUIL()); sl@0: INFO_PRINTF2(_L("DriverUI %d"),driverui); sl@0: delete driverui; sl@0: sl@0: INFO_PRINTF2(_L("NumTypefaces %d"),device->NumTypefaces()); sl@0: INFO_PRINTF2(_L("**Model name %S**"),&entry.iModelName); sl@0: INFO_PRINTF2(_L("KPixelWidthInTwips %d"),device->HorizontalPixelsToTwips(1000)); sl@0: INFO_PRINTF2(_L("KPixelHeightInTwips %d"),device->VerticalPixelsToTwips(1000)); sl@0: TPageSpec pagespec(TPageSpec::EPortrait,KA4PaperSizeInTwips); sl@0: device->SelectPageSpecInTwips(pagespec); sl@0: sl@0: // Get typeface info sl@0: INFO_PRINTF1(_L("Get typeface info")); sl@0: TTypefaceSupport support; sl@0: device->TypefaceSupport(support,0); sl@0: TBuf name; sl@0: name.Copy(support.iTypeface.iName); sl@0: INFO_PRINTF2(_L("Typeface Name %S"),&name); sl@0: INFO_PRINTF2(_L("Typeface serif %d"),support.iTypeface.IsSerif()); sl@0: INFO_PRINTF2(_L("Typeface proportional %d"),support.iTypeface.IsProportional()); sl@0: INFO_PRINTF2(_L("Typeface symbol %d"),support.iTypeface.IsSymbol()); sl@0: INFO_PRINTF2(_L("NumHeights %d"),support.iNumHeights); sl@0: INFO_PRINTF2(_L("MinHeightInTwips %d"),support.iMinHeightInTwips); sl@0: INFO_PRINTF2(_L("MaxHeightInTwips %d"),support.iMaxHeightInTwips); sl@0: INFO_PRINTF2(_L("IsScalable %d"),support.iIsScalable); sl@0: sl@0: // Get nearest font sl@0: INFO_PRINTF1(_L("Get nearest font")); sl@0: CFont *font; sl@0: TFontSpec spec; sl@0: support.iTypeface.iName=_L("DejaVu Sans Condensed"); sl@0: support.iTypeface.SetIsProportional(ETrue); sl@0: support.iTypeface.SetIsSerif(ETrue); sl@0: spec.iTypeface=support.iTypeface; sl@0: spec.iHeight=680; sl@0: spec.iFontStyle.SetPosture(EPostureUpright); sl@0: spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); sl@0: spec.iFontStyle.SetPrintPosition(EPrintPosNormal); sl@0: ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels()); sl@0: INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels()); sl@0: INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight()); sl@0: INFO_PRINTF3(_L("Font AlgPosture %d AlgStrokeWeight %d"),((CBitmapFont*)font)->iAlgStyle.IsItalic(),((CBitmapFont*)font)->iAlgStyle.IsBold()); sl@0: spec=font->FontSpecInTwips(); sl@0: device->ReleaseFont(font); sl@0: ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels()); sl@0: INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels()); sl@0: INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight()); sl@0: INFO_PRINTF3(_L("Font AlgPosture %d AlgStrokeWeight %d"),((CBitmapFont*)font)->iAlgStyle.IsItalic(),((CBitmapFont*)font)->iAlgStyle.IsBold()); sl@0: name.Copy(font->FontSpecInTwips().iTypeface.iName); sl@0: INFO_PRINTF2(_L("Typeface Name %S"),&name); sl@0: INFO_PRINTF2(_L("Typeface Proportional %d"),font->FontSpecInTwips().iTypeface.IsProportional()); sl@0: INFO_PRINTF2(_L("Typeface Serif %d"),font->FontSpecInTwips().iTypeface.IsSerif()); sl@0: INFO_PRINTF2(_L("CharWidthInPixels(32) %d"),font->CharWidthInPixels(TChar(32))); sl@0: INFO_PRINTF2(_L("MaxCharWidthInPixels %d"),font->MaxCharWidthInPixels()); sl@0: INFO_PRINTF2(_L("MaxNormalCharWidthInPixels %d"),font->MaxNormalCharWidthInPixels()); sl@0: INFO_PRINTF2(_L("HeightInTwips %d"),font->FontSpecInTwips().iHeight); sl@0: INFO_PRINTF2(_L("HeightInPixels %d"),font->HeightInPixels()); sl@0: INFO_PRINTF2(_L("AscentInPixels %d"),font->AscentInPixels()); sl@0: INFO_PRINTF2(_L("TextWidthInPixels(HELLO WORLD) %d"),font->TextWidthInPixels(_L("HELLO WORLD"))); sl@0: device->ReleaseFont(font); sl@0: sl@0: spec.iHeight=1000; sl@0: spec.iFontStyle.SetPrintPosition(EPrintPosNormal); sl@0: sl@0: spec.iFontStyle.SetPrintPosition(EPrintPosNormal); sl@0: spec.iFontStyle.SetPosture(EPostureUpright); sl@0: spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); sl@0: for (i=0; iNumTypefaces(); i++) sl@0: { sl@0: device->TypefaceSupport(support,i); sl@0: name.Copy(support.iTypeface.iName); sl@0: INFO_PRINTF2(_L("Typeface Name %S"),&name); sl@0: for (TInt j=0; jFontHeightInTwips(i,j); sl@0: ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: if (KVerboseOutput) sl@0: { sl@0: INFO_PRINTF2(_L("Spec HeightInTwips %d"),spec.iHeight); sl@0: INFO_PRINTF2(_L("Font HeightInTwipss %d"),font->FontSpecInTwips().iHeight); sl@0: INFO_PRINTF3(_L("Font Posture %d StrokeWeight %d"),font->FontSpecInTwips().iFontStyle.Posture(),font->FontSpecInTwips().iFontStyle.StrokeWeight()); sl@0: } sl@0: device->ReleaseFont(font); sl@0: } sl@0: } sl@0: sl@0: RFile file; sl@0: RFs fs; sl@0: ret=fs.Connect(); sl@0: TEST(ret==KErrNone); sl@0: _LIT(KPath,"C:\\system\\data\\"); sl@0: fs.MkDirAll(KPath); sl@0: ret=file.Replace(fs,_L("C:\\system\\data\\WIDTHS.TMP"),EFileStream|EFileWrite); sl@0: if (ret!=KErrNone) sl@0: { sl@0: _LIT(KLog,"Doing Replace on file C:\\system\\data\\WIDTHS.TMP gave error %d"); sl@0: INFO_PRINTF2(KLog,ret); sl@0: } sl@0: TEST(ret==KErrNone); sl@0: sl@0: TBuf8<120> buf; sl@0: sl@0: for (i=0; iNumTypefaces(); i++) sl@0: { sl@0: device->TypefaceSupport(support,i); sl@0: spec.iTypeface=support.iTypeface; sl@0: for (TInt k=0; kFontHeightInTwips(i,k); sl@0: if ((spec.iHeight==1000)) sl@0: { sl@0: for (TInt j=0; j<4; j++) sl@0: { sl@0: name.Copy(support.iTypeface.iName); sl@0: buf.Format(_L8("FontInfo %S"),&support.iTypeface.iName); sl@0: ret=file.Write(buf); sl@0: TEST(ret==KErrNone); sl@0: if (j==0) sl@0: { sl@0: buf.Format(_L8("Std%d"),spec.iHeight/20); sl@0: ret=file.Write(buf); sl@0: TEST(ret==KErrNone); sl@0: spec.iFontStyle.SetPosture(EPostureUpright); sl@0: spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); sl@0: } sl@0: if (j==1) sl@0: { sl@0: buf.Format(_L8("Bold%d"),spec.iHeight/20); sl@0: ret=file.Write(buf); sl@0: TEST(ret==KErrNone); sl@0: spec.iFontStyle.SetPosture(EPostureUpright); sl@0: spec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); sl@0: } sl@0: if (j==2) sl@0: { sl@0: buf.Format(_L8("Italic%d"),spec.iHeight/20); sl@0: ret=file.Write(buf); sl@0: TEST(ret==KErrNone); sl@0: spec.iFontStyle.SetPosture(EPostureItalic); sl@0: spec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); sl@0: } sl@0: if (j==3) sl@0: { sl@0: buf.Format(_L8("BoldItalic%d"),spec.iHeight/20); sl@0: ret=file.Write(buf); sl@0: TEST(ret==KErrNone); sl@0: spec.iFontStyle.SetPosture(EPostureItalic); sl@0: spec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); sl@0: } sl@0: ret=device->GetNearestFontToDesignHeightInTwips((CFont *&) font,spec); sl@0: TEST(ret==KErrNone); sl@0: INFO_PRINTF4(_L("Name %S Height %d CharWidthInPixels(W) %d"),&name,font->FontSpecInTwips().iHeight,font->CharWidthInPixels(TChar('W'))); sl@0: buf.Format(_L8("MaxNormalCharWidth %dAscent %d"),font->MaxNormalCharWidthInPixels(),font->AscentInPixels()); sl@0: ret=file.Write(buf); sl@0: TEST(ret==KErrNone); sl@0: ret=file.Write(_L8("CodeSection 0:255")); sl@0: TEST(ret==KErrNone); sl@0: for (TInt l=0; l<256; l++) sl@0: { sl@0: if (font->CharWidthInPixels(k)) sl@0: { sl@0: buf.Format(_L8("%d:%d "),l,font->CharWidthInPixels(l)); sl@0: ret=file.Write(buf); sl@0: TEST(ret==KErrNone); sl@0: } sl@0: if (((l/8)*8)==l) sl@0: { sl@0: ret=file.Write(_L8("\n")); sl@0: TEST(ret==KErrNone); sl@0: } sl@0: } sl@0: ret=file.Write(_L8("\nEndCodeSection\nEndFontInfo\n")); sl@0: TEST(ret==KErrNone); sl@0: device->ReleaseFont(font); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: file.Flush(); sl@0: file.Close(); sl@0: fs.Close(); sl@0: sl@0: // Create control sl@0: INFO_PRINTF1(_L("Create control")); sl@0: sl@0: CPrinterPort* printerport=NULL; sl@0: #if defined (__WINS__) sl@0: if (device->Model().iRequiresPrinterPort) sl@0: { sl@0: TRAP(ret,printerport=CFilePrinterPort::NewL(_L("c:\\Printfile"))); sl@0: } sl@0: #else sl@0: if (device->Model().iRequiresPrinterPort) sl@0: { sl@0: TRAP(ret,printerport=CFilePrinterPort::NewL(_L("c:\\temp.prn"))); sl@0: INFO_PRINTF2(_L("ret %d"),ret); sl@0: INFO_PRINTF2(_L("device displaymode %d"),device->DisplayMode()); sl@0: } sl@0: #endif sl@0: sl@0: TEST(ret==KErrNone); sl@0: TRAP(ret,device->CreateControlL(printerport)); sl@0: INFO_PRINTF2(_L("CreateControlL() returns %d"), ret); sl@0: TEST(ret==KErrNone); sl@0: sl@0: // Create context sl@0: TRAP(ret,testPrint(device)); sl@0: TEST(ret==KErrNone); sl@0: INFO_PRINTF2(_L("...testPrint() returns %d"), ret); sl@0: sl@0: INFO_PRINTF1(_L("Delete printer driver")); sl@0: sl@0: delete driver; sl@0: delete iStopper; sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: sl@0: sl@0: void CTPdr::bandTest(TBandingDirection aBandingDirection, TPtrC aName) sl@0: { sl@0: CBandedDevice* banded = NULL; sl@0: TInt expectedWidth=0; sl@0: TInt expectedheight=0; sl@0: TInt ret = KErrNone; sl@0: TRect rect(0,0,1000,1000); sl@0: TSize size; sl@0: size.iWidth = size.iHeight = 2000; sl@0: TRect outRect; sl@0: sl@0: if( aBandingDirection==EBandingLeftToRight || aBandingDirection==EBandingRightToLeft ) sl@0: { sl@0: expectedWidth=32; sl@0: expectedheight=1000; sl@0: } sl@0: else if( aBandingDirection==EBandingBottomToTop || aBandingDirection==EBandingTopToBottom ) sl@0: { sl@0: expectedWidth=1000; sl@0: expectedheight=32; sl@0: } sl@0: sl@0: TRAP(ret, banded=CBandedDevice::NewL(rect,size,EColor256,aBandingDirection,0)); sl@0: TEST(ret==KErrNone); sl@0: sl@0: banded->NextBand(); sl@0: banded->NextBand(); sl@0: outRect = banded->BandRect(); sl@0: sl@0: TEST(outRect.Width() == expectedWidth && outRect.Height() == expectedheight); sl@0: sl@0: INFO_PRINTF2(_L("*** BandRect call (%s) ***"), &aName[0]); sl@0: INFO_PRINTF3(_L("Expected results are Width=%d, Height=%d."), expectedWidth, expectedheight); sl@0: INFO_PRINTF3(_L("Actual results are Width=%d, Height=%d."), outRect.Width(), outRect.Height()); sl@0: 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: sl@0: delete banded; sl@0: } sl@0: sl@0: void CTPdr::testPdrBandRect() sl@0: { sl@0: INFO_PRINTF1(_L("Running BandRect tests")); sl@0: sl@0: __UHEAP_MARK; sl@0: bandTest(EBandingLeftToRight, _L("EBandingLeftToRight")); sl@0: bandTest(EBandingBottomToTop, _L("EBandingBottomToTop")); sl@0: bandTest(EBandingRightToLeft, _L("EBandingRightToLeft")); sl@0: bandTest(EBandingTopToBottom, _L("EBandingTopToBottom")); sl@0: __UHEAP_MARKEND; sl@0: sl@0: INFO_PRINTF1(_L("BandRect tests completed")); sl@0: } sl@0: sl@0: sl@0: void CTPdr::RunTestCaseL(TInt aCurTestCase) sl@0: { sl@0: ((CTPdrStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(aCurTestCase) sl@0: { sl@0: case 1: sl@0: { sl@0: INFO_PRINTF1(_L("TEST CASE1 - testPdrStore")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-PDR-0001 sl@0: */ sl@0: ((CTPdrStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDR-0001")); sl@0: do sl@0: { sl@0: testPdrStore(); sl@0: iModelIndex++; sl@0: } sl@0: while (iModelIndex < iNumModels); sl@0: INFO_PRINTF1(_L("TEST CASE1 - ended!\n")); sl@0: break; sl@0: } sl@0: case 2: sl@0: { sl@0: INFO_PRINTF1(_L("TEST CASE2 - testPdrBandRect")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-PDR-0002 sl@0: */ sl@0: ((CTPdrStep*)iStep)->SetTestStepID(_L("GRAPHICS-PDR-0002")); sl@0: testPdrBandRect(); sl@0: INFO_PRINTF1(_L("TEST CASE2 - ended!\n")); sl@0: break; sl@0: } sl@0: case 3: sl@0: { sl@0: ((CTPdrStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTPdrStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: } sl@0: } sl@0: ((CTPdrStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: sl@0: sl@0: //-------------- sl@0: __CONSTRUCT_STEP__(Pdr) sl@0: sl@0: void CTPdrStep::TestSetupL() sl@0: { sl@0: FbsStartup(); sl@0: User::LeaveIfError(RFbsSession::Connect()); sl@0: } sl@0: sl@0: void CTPdrStep::TestClose() sl@0: { sl@0: RFbsSession::Disconnect(); sl@0: } sl@0: sl@0: