1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/tdrawresource.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,221 @@
1.4 +// Copyright (c) 2008-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 +#ifndef TDRAWRESOURCE_H_
1.26 +#define TDRAWRESOURCE_H_
1.27 +
1.28 +#include "AUTO.H"
1.29 +#include <graphics/directgdidriver.h>
1.30 +#include <graphics/wsgraphicscontext.h>
1.31 +#include <graphics/directgdicontext.h>
1.32 +#include <graphics/wsdrawablesourceprovider.h>
1.33 +#include <graphics/sgimagecollection.h>
1.34 +#include <graphics/directgdiimagetarget.h>
1.35 +#include <graphics/wsdrawresource.h>
1.36 +#include "RemoteGc.h"
1.37 +#include "CommandBuffer.h"
1.38 +
1.39 +class TSgImageInfo;
1.40 +
1.41 +_LIT(KTDrawResourceStep, "TDrawResource");
1.42 +
1.43 +const TSize KSourceSize(200,200); //The size of the rect to copy from the screen
1.44 +const TPoint KDestPoint(0,0);
1.45 +const TRect KCopyTestRect(TPoint(0,0), TSize(200,200)); //The test rect to copy from the screen
1.46 +const TRect KSourceRect(TPoint(0,0), TSize(50,50));//Rect of the source image to be drawn
1.47 +const TRect KDestRect(TPoint(10,10), TSize(60,60));//Rect of the destination to draw to
1.48 +const CWindowGc::TGraphicsRotation KTestRotation= CWindowGc::EGraphicsRotation90;
1.49 +const TPoint KPlayOffset(0,0);
1.50 +
1.51 +
1.52 +/**
1.53 + * Dummy class used to check the values received by MWsGraphicsContext.
1.54 + * The only funtions overridden with some functionality are the DrawResource functions.
1.55 + * These simply receive the values and then store them in public member variables.
1.56 + */
1.57 +class CTestWsGraphicsContext : public CBase, public MWsGraphicsContext, public MWsDrawableSourceProvider
1.58 + {
1.59 +public:
1.60 + static CTestWsGraphicsContext* NewL(RDirectGdiImageTarget& aTarget);
1.61 + ~CTestWsGraphicsContext();
1.62 +
1.63 +public: //from MWsGraphicsContext
1.64 + void BitBlt(const TPoint&, const CFbsBitmap&){}
1.65 + void BitBlt(const TPoint&, const CFbsBitmap&, const TRect&){}
1.66 + void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, TBool){}
1.67 + void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, const TPoint&){}
1.68 + void ResetClippingRegion(){}
1.69 + void Clear();
1.70 + void Clear(const TRect&){}
1.71 + void ResetBrushPattern(){}
1.72 + void ResetFont(){}
1.73 + void DrawArc(const TRect&, const TPoint&, const TPoint&){}
1.74 + void DrawPie(const TRect&, const TPoint&, const TPoint&){}
1.75 + void DrawBitmap(const TRect&, const CFbsBitmap&){}
1.76 + void DrawBitmap(const TRect&, const CFbsBitmap&, const TRect&){}
1.77 + void DrawBitmapMasked(const TRect&, const CFbsBitmap&,const TRect&, const CFbsBitmap&, TBool){}
1.78 + void DrawRoundRect(const TRect&, const TSize&){}
1.79 + void DrawPolyLine(const TArray<TPoint>&){}
1.80 + void DrawPolyLineNoEndPoint(const TArray<TPoint>&){}
1.81 + void DrawPolygon(const TArray<TPoint>& , TFillRule ){}
1.82 + void DrawEllipse(const TRect&){}
1.83 + void DrawLine(const TPoint&, const TPoint&){}
1.84 + void DrawLineTo(const TPoint&){}
1.85 + void DrawLineBy(const TPoint&){}
1.86 + void DrawRect(const TRect&){}
1.87 + void DrawText(const TDesC& ,const TTextParameters* ){}
1.88 + void DrawText(const TDesC& ,const TTextParameters* ,const TPoint& ){}
1.89 + void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ){}
1.90 + void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TTextAlign ,TInt ){}
1.91 + void DrawTextVertical(const TDesC& ,const TTextParameters* ,TBool ) {}
1.92 + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TPoint& ,TBool ){}
1.93 + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TBool ){}
1.94 + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TBool ,TTextAlign ,TInt ){}
1.95 + void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TInt ,TBool ,TTextAlign ,TInt ){}
1.96 + void MoveTo(const TPoint&){}
1.97 + void MoveBy(const TPoint&){}
1.98 + TPoint Origin() const {return TPoint(0,0);}
1.99 + void Plot(const TPoint&){}
1.100 + void Reset(){}
1.101 + void SetBrushColor(const TRgb&){}
1.102 + void SetBrushOrigin(const TPoint&){}
1.103 + void SetBrushStyle(TBrushStyle ){}
1.104 + void SetClippingRegion(const TRegion&){}
1.105 + void SetDrawMode(TDrawMode){}
1.106 + void SetOrigin(const TPoint&){}
1.107 + void SetPenColor(const TRgb&){}
1.108 + void SetPenStyle(TPenStyle){}
1.109 + void SetPenSize(const TSize& ){}
1.110 + void SetTextShadowColor(const TRgb&){}
1.111 + void SetCharJustification(TInt, TInt){}
1.112 + void SetWordJustification(TInt, TInt){}
1.113 + void SetUnderlineStyle(TFontUnderline){}
1.114 + void SetStrikethroughStyle(TFontStrikethrough){}
1.115 + void SetBrushPattern(const CFbsBitmap&){}
1.116 + void SetBrushPattern(TInt){}
1.117 + void SetFont(const CFont*){}
1.118 + void CopyRect(const TPoint&, const TRect&){}
1.119 + void RectDrawnTo(TRect&){}
1.120 + void UpdateJustification(const TDesC& ,const TTextParameters* ){}
1.121 + void UpdateJustificationVertical(const TDesC& ,const TTextParameters* ,TBool ){}
1.122 + void SetFontNoDuplicate(const CFont* ){}
1.123 + TBool HasBrushPattern() const{return EFalse;}
1.124 + TBool HasFont() const{return EFalse;}
1.125 + void InternalizeL(RReadStream&){}
1.126 + void ExternalizeL(RWriteStream&){}
1.127 + TRgb BrushColor() const {return iContext->BrushColor();}
1.128 + TRgb PenColor() const {return iContext->PenColor();}
1.129 + TRgb TextShadowColor() const {return iContext->TextShadowColor ();}
1.130 +
1.131 + const TRegion& ClippingRegion(){return iRegion;}
1.132 + TInt GetError(){return KErrNone;}
1.133 + TInt Push(){return KErrNone;}
1.134 + void Pop(){}
1.135 + //from MWsObjectProvider
1.136 + TAny* ResolveObjectInterface(TUint aTypeId);
1.137 +
1.138 + //from MWsDrawableSourceProvider
1.139 + TInt CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource);
1.140 + void CloseDrawableSource(TAny* aSource);
1.141 + void DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
1.142 + void DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
1.143 + void DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
1.144 + void DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aParam);
1.145 +
1.146 +private:
1.147 + void ConstructL(RDirectGdiImageTarget& aTarget);
1.148 + void DoCreateDrawableSourceL(const TSgDrawableId& aDrawableId, TAny*& aSource);
1.149 +public:
1.150 + TPoint iPos;
1.151 + TRect iDestRect;
1.152 + TRect iSrcRect;
1.153 + DirectGdi::TGraphicsRotation iRotation;
1.154 + RRegion iRegion;
1.155 +private:
1.156 + CDirectGdiContext* iContext;
1.157 + };
1.158 +
1.159 +/**
1.160 + * Class derived from MWsGraphicResolver. This a dummy implmentation which has no functionality.
1.161 + * An instance of it is passed to CCommandBuffer::Play to make it a valid call.
1.162 + */
1.163 +class CWSGraphicsRes: public CBase, public MWsGraphicResolver
1.164 + {
1.165 +public:
1.166 + void DrawWsGraphic(TInt, TBool, const TRect&, const TDesC8&) const{}
1.167 + };
1.168 +
1.169 +class CTDrawResource : public CTWsGraphicsBase
1.170 + {
1.171 +public:
1.172 + CTDrawResource(CTestStep* aStep);
1.173 + ~CTDrawResource();
1.174 + void ConstructL();
1.175 +protected:
1.176 + //from CTGraphicsStep
1.177 + void RunTestCaseL(TInt aCurTestCase);
1.178 +private:
1.179 + void TestDrawResourcePos();
1.180 + void TestDrawResourceRect();
1.181 + void TestDrawResourceScale();
1.182 + void TestRWsDrawableSourceReferenceCountingL();
1.183 + void TestRemoteGcDrawResourcePosL();
1.184 + void TestRemoteGcDrawResourceRectL();
1.185 + void TestRemoteGcDrawResourceScaleL();
1.186 + void TestDrawResourceScreensL();
1.187 + void TestCopyScreenToBitmapWithDifferentDisplayModesL();
1.188 + //Helper functions
1.189 + TBool CompareBitmapsByPixel(CFbsBitmap* aCandidateBitmap, CFbsBitmap* aReferenceBitmap);
1.190 + void CreateReferenceAndCopyBitmapsL();
1.191 + void CreateSgImageFromBitmapL(RSgImage& aImage);
1.192 + void BitmapLC(CFbsBitmap*& aBmp); //helper function to extract bitmap from the image
1.193 + void CreateReferenceBitmapLC(CFbsBitmap*& aBmpTarget, CFbsBitmap* aBmpSrc, TDisplayMode aDestMode);
1.194 + void CreateBitmapLC(CFbsBitmap*& aBmpTarget, const TSize& aSize, TDisplayMode aDispMode) const;
1.195 +private:
1.196 + RWindow iWindow;
1.197 + CFbsBitmap* iRefBitmap;
1.198 + CFbsBitmap* iRotatedRefBitmap;
1.199 + CFbsBitmap* iScaledBitmap;
1.200 + CFbsBitmap *iScaledCroppedBitmap;
1.201 + CFbsBitmap* iCopyBitmap;
1.202 + CFbsBitmap* iBitmapWrongScreenNumber;
1.203 + CDirectGdiDriver* iDGdiDriver;
1.204 +
1.205 + //Required for RemoteGc testing
1.206 + RSgImageCollection iImageCollection;
1.207 + RSgImage iImage;
1.208 + RDirectGdiImageTarget iImageTarget;
1.209 + RWsDrawableSource iWsDrawableSource;
1.210 + CTestWsGraphicsContext* iGraphicsCon;
1.211 + CWSGraphicsRes* iWsGrapicResolver;
1.212 + };
1.213 +
1.214 +class CTDrawResourceStep : public CTGraphicsStep
1.215 + {
1.216 +public:
1.217 + CTDrawResourceStep();
1.218 +protected:
1.219 + //from CTGraphicsStep
1.220 + CTGraphicsBase* CreateTestL();
1.221 + };
1.222 +
1.223 +
1.224 +#endif /*TDRAWRESOURCE_H_*/