Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 @internalComponent - Internal Symbian test code
22 #ifndef TDRAWRESOURCE_H_
23 #define TDRAWRESOURCE_H_
26 #include <graphics/directgdidriver.h>
27 #include <graphics/wsgraphicscontext.h>
28 #include <graphics/directgdicontext.h>
29 #include <graphics/wsdrawablesourceprovider.h>
30 #include <graphics/sgimagecollection.h>
31 #include <graphics/directgdiimagetarget.h>
32 #include <graphics/wsdrawresource.h>
34 #include "CommandBuffer.h"
38 _LIT(KTDrawResourceStep, "TDrawResource");
40 const TSize KSourceSize(200,200); //The size of the rect to copy from the screen
41 const TPoint KDestPoint(0,0);
42 const TRect KCopyTestRect(TPoint(0,0), TSize(200,200)); //The test rect to copy from the screen
43 const TRect KSourceRect(TPoint(0,0), TSize(50,50));//Rect of the source image to be drawn
44 const TRect KDestRect(TPoint(10,10), TSize(60,60));//Rect of the destination to draw to
45 const CWindowGc::TGraphicsRotation KTestRotation= CWindowGc::EGraphicsRotation90;
46 const TPoint KPlayOffset(0,0);
50 * Dummy class used to check the values received by MWsGraphicsContext.
51 * The only funtions overridden with some functionality are the DrawResource functions.
52 * These simply receive the values and then store them in public member variables.
54 class CTestWsGraphicsContext : public CBase, public MWsGraphicsContext, public MWsDrawableSourceProvider
57 static CTestWsGraphicsContext* NewL(RDirectGdiImageTarget& aTarget);
58 ~CTestWsGraphicsContext();
60 public: //from MWsGraphicsContext
61 void BitBlt(const TPoint&, const CFbsBitmap&){}
62 void BitBlt(const TPoint&, const CFbsBitmap&, const TRect&){}
63 void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, TBool){}
64 void BitBltMasked(const TPoint&, const CFbsBitmap&, const TRect&, const CFbsBitmap&, const TPoint&){}
65 void ResetClippingRegion(){}
67 void Clear(const TRect&){}
68 void ResetBrushPattern(){}
70 void DrawArc(const TRect&, const TPoint&, const TPoint&){}
71 void DrawPie(const TRect&, const TPoint&, const TPoint&){}
72 void DrawBitmap(const TRect&, const CFbsBitmap&){}
73 void DrawBitmap(const TRect&, const CFbsBitmap&, const TRect&){}
74 void DrawBitmapMasked(const TRect&, const CFbsBitmap&,const TRect&, const CFbsBitmap&, TBool){}
75 void DrawRoundRect(const TRect&, const TSize&){}
76 void DrawPolyLine(const TArray<TPoint>&){}
77 void DrawPolyLineNoEndPoint(const TArray<TPoint>&){}
78 void DrawPolygon(const TArray<TPoint>& , TFillRule ){}
79 void DrawEllipse(const TRect&){}
80 void DrawLine(const TPoint&, const TPoint&){}
81 void DrawLineTo(const TPoint&){}
82 void DrawLineBy(const TPoint&){}
83 void DrawRect(const TRect&){}
84 void DrawText(const TDesC& ,const TTextParameters* ){}
85 void DrawText(const TDesC& ,const TTextParameters* ,const TPoint& ){}
86 void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ){}
87 void DrawText(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TTextAlign ,TInt ){}
88 void DrawTextVertical(const TDesC& ,const TTextParameters* ,TBool ) {}
89 void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TPoint& ,TBool ){}
90 void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TBool ){}
91 void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TBool ,TTextAlign ,TInt ){}
92 void DrawTextVertical(const TDesC& ,const TTextParameters* ,const TRect& ,TInt ,TInt ,TBool ,TTextAlign ,TInt ){}
93 void MoveTo(const TPoint&){}
94 void MoveBy(const TPoint&){}
95 TPoint Origin() const {return TPoint(0,0);}
96 void Plot(const TPoint&){}
98 void SetBrushColor(const TRgb&){}
99 void SetBrushOrigin(const TPoint&){}
100 void SetBrushStyle(TBrushStyle ){}
101 void SetClippingRegion(const TRegion&){}
102 void SetDrawMode(TDrawMode){}
103 void SetOrigin(const TPoint&){}
104 void SetPenColor(const TRgb&){}
105 void SetPenStyle(TPenStyle){}
106 void SetPenSize(const TSize& ){}
107 void SetTextShadowColor(const TRgb&){}
108 void SetCharJustification(TInt, TInt){}
109 void SetWordJustification(TInt, TInt){}
110 void SetUnderlineStyle(TFontUnderline){}
111 void SetStrikethroughStyle(TFontStrikethrough){}
112 void SetBrushPattern(const CFbsBitmap&){}
113 void SetBrushPattern(TInt){}
114 void SetFont(const CFont*){}
115 void CopyRect(const TPoint&, const TRect&){}
116 void RectDrawnTo(TRect&){}
117 void UpdateJustification(const TDesC& ,const TTextParameters* ){}
118 void UpdateJustificationVertical(const TDesC& ,const TTextParameters* ,TBool ){}
119 void SetFontNoDuplicate(const CFont* ){}
120 TBool HasBrushPattern() const{return EFalse;}
121 TBool HasFont() const{return EFalse;}
122 void InternalizeL(RReadStream&){}
123 void ExternalizeL(RWriteStream&){}
124 TRgb BrushColor() const {return iContext->BrushColor();}
125 TRgb PenColor() const {return iContext->PenColor();}
126 TRgb TextShadowColor() const {return iContext->TextShadowColor ();}
128 const TRegion& ClippingRegion(){return iRegion;}
129 TInt GetError(){return KErrNone;}
130 TInt Push(){return KErrNone;}
132 //from MWsObjectProvider
133 TAny* ResolveObjectInterface(TUint aTypeId);
135 //from MWsDrawableSourceProvider
136 TInt CreateDrawableSource(const TSgDrawableId& aDrawableId, TAny*& aSource);
137 void CloseDrawableSource(TAny* aSource);
138 void DrawResource(const TAny* aSource, const TPoint& aPos, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
139 void DrawResource(const TAny* aSource, const TRect& aRect, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
140 void DrawResource(const TAny* aSource, const TRect& aRectDest, const TRect& aRectSrc, CWindowGc::TGraphicsRotation aRotation = CWindowGc::EGraphicsRotationNone);
141 void DrawResource(const TAny* aSource, const TRect& aRect, const TDesC8& aParam);
144 void ConstructL(RDirectGdiImageTarget& aTarget);
145 void DoCreateDrawableSourceL(const TSgDrawableId& aDrawableId, TAny*& aSource);
150 DirectGdi::TGraphicsRotation iRotation;
153 CDirectGdiContext* iContext;
157 * Class derived from MWsGraphicResolver. This a dummy implmentation which has no functionality.
158 * An instance of it is passed to CCommandBuffer::Play to make it a valid call.
160 class CWSGraphicsRes: public CBase, public MWsGraphicResolver
163 void DrawWsGraphic(TInt, TBool, const TRect&, const TDesC8&) const{}
166 class CTDrawResource : public CTWsGraphicsBase
169 CTDrawResource(CTestStep* aStep);
173 //from CTGraphicsStep
174 void RunTestCaseL(TInt aCurTestCase);
176 void TestDrawResourcePos();
177 void TestDrawResourceRect();
178 void TestDrawResourceScale();
179 void TestRWsDrawableSourceReferenceCountingL();
180 void TestRemoteGcDrawResourcePosL();
181 void TestRemoteGcDrawResourceRectL();
182 void TestRemoteGcDrawResourceScaleL();
183 void TestDrawResourceScreensL();
184 void TestCopyScreenToBitmapWithDifferentDisplayModesL();
186 TBool CompareBitmapsByPixel(CFbsBitmap* aCandidateBitmap, CFbsBitmap* aReferenceBitmap);
187 void CreateReferenceAndCopyBitmapsL();
188 void CreateSgImageFromBitmapL(RSgImage& aImage);
189 void BitmapLC(CFbsBitmap*& aBmp); //helper function to extract bitmap from the image
190 void CreateReferenceBitmapLC(CFbsBitmap*& aBmpTarget, CFbsBitmap* aBmpSrc, TDisplayMode aDestMode);
191 void CreateBitmapLC(CFbsBitmap*& aBmpTarget, const TSize& aSize, TDisplayMode aDispMode) const;
194 CFbsBitmap* iRefBitmap;
195 CFbsBitmap* iRotatedRefBitmap;
196 CFbsBitmap* iScaledBitmap;
197 CFbsBitmap *iScaledCroppedBitmap;
198 CFbsBitmap* iCopyBitmap;
199 CFbsBitmap* iBitmapWrongScreenNumber;
200 CDirectGdiDriver* iDGdiDriver;
202 //Required for RemoteGc testing
203 RSgImageCollection iImageCollection;
205 RDirectGdiImageTarget iImageTarget;
206 RWsDrawableSource iWsDrawableSource;
207 CTestWsGraphicsContext* iGraphicsCon;
208 CWSGraphicsRes* iWsGrapicResolver;
211 class CTDrawResourceStep : public CTGraphicsStep
214 CTDrawResourceStep();
216 //from CTGraphicsStep
217 CTGraphicsBase* CreateTestL();
221 #endif /*TDRAWRESOURCE_H_*/