103
|
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".
|
|
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 |
#ifndef TDRAWRESOURCE_H_
|
|
23 |
#define TDRAWRESOURCE_H_
|
|
24 |
|
|
25 |
#include "AUTO.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>
|
|
33 |
#include "RemoteGc.h"
|
|
34 |
#include "CommandBuffer.h"
|
|
35 |
|
|
36 |
class TSgImageInfo;
|
|
37 |
|
|
38 |
_LIT(KTDrawResourceStep, "TDrawResource");
|
|
39 |
|
|
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);
|
|
47 |
|
|
48 |
|
|
49 |
/**
|
|
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.
|
|
53 |
*/
|
|
54 |
class CTestWsGraphicsContext : public CBase, public MWsGraphicsContext, public MWsDrawableSourceProvider
|
|
55 |
{
|
|
56 |
public:
|
|
57 |
static CTestWsGraphicsContext* NewL(RDirectGdiImageTarget& aTarget);
|
|
58 |
~CTestWsGraphicsContext();
|
|
59 |
|
|
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(){}
|
|
66 |
void Clear();
|
|
67 |
void Clear(const TRect&){}
|
|
68 |
void ResetBrushPattern(){}
|
|
69 |
void ResetFont(){}
|
|
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&){}
|
|
97 |
void Reset(){}
|
|
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 ();}
|
|
127 |
|
|
128 |
const TRegion& ClippingRegion(){return iRegion;}
|
|
129 |
TInt GetError(){return KErrNone;}
|
|
130 |
TInt Push(){return KErrNone;}
|
|
131 |
void Pop(){}
|
|
132 |
//from MWsObjectProvider
|
|
133 |
TAny* ResolveObjectInterface(TUint aTypeId);
|
|
134 |
|
|
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);
|
|
142 |
|
|
143 |
private:
|
|
144 |
void ConstructL(RDirectGdiImageTarget& aTarget);
|
|
145 |
void DoCreateDrawableSourceL(const TSgDrawableId& aDrawableId, TAny*& aSource);
|
|
146 |
public:
|
|
147 |
TPoint iPos;
|
|
148 |
TRect iDestRect;
|
|
149 |
TRect iSrcRect;
|
|
150 |
DirectGdi::TGraphicsRotation iRotation;
|
|
151 |
RRegion iRegion;
|
|
152 |
private:
|
|
153 |
CDirectGdiContext* iContext;
|
|
154 |
};
|
|
155 |
|
|
156 |
/**
|
|
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.
|
|
159 |
*/
|
|
160 |
class CWSGraphicsRes: public CBase, public MWsGraphicResolver
|
|
161 |
{
|
|
162 |
public:
|
|
163 |
void DrawWsGraphic(TInt, TBool, const TRect&, const TDesC8&) const{}
|
|
164 |
};
|
|
165 |
|
|
166 |
class CTDrawResource : public CTWsGraphicsBase
|
|
167 |
{
|
|
168 |
public:
|
|
169 |
CTDrawResource(CTestStep* aStep);
|
|
170 |
~CTDrawResource();
|
|
171 |
void ConstructL();
|
|
172 |
protected:
|
|
173 |
//from CTGraphicsStep
|
|
174 |
void RunTestCaseL(TInt aCurTestCase);
|
|
175 |
private:
|
|
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();
|
|
185 |
//Helper functions
|
|
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;
|
|
192 |
private:
|
|
193 |
RWindow iWindow;
|
|
194 |
CFbsBitmap* iRefBitmap;
|
|
195 |
CFbsBitmap* iRotatedRefBitmap;
|
|
196 |
CFbsBitmap* iScaledBitmap;
|
|
197 |
CFbsBitmap *iScaledCroppedBitmap;
|
|
198 |
CFbsBitmap* iCopyBitmap;
|
|
199 |
CFbsBitmap* iBitmapWrongScreenNumber;
|
|
200 |
CDirectGdiDriver* iDGdiDriver;
|
|
201 |
|
|
202 |
//Required for RemoteGc testing
|
|
203 |
RSgImageCollection iImageCollection;
|
|
204 |
RSgImage iImage;
|
|
205 |
RDirectGdiImageTarget iImageTarget;
|
|
206 |
RWsDrawableSource iWsDrawableSource;
|
|
207 |
CTestWsGraphicsContext* iGraphicsCon;
|
|
208 |
CWSGraphicsRes* iWsGrapicResolver;
|
|
209 |
};
|
|
210 |
|
|
211 |
class CTDrawResourceStep : public CTGraphicsStep
|
|
212 |
{
|
|
213 |
public:
|
|
214 |
CTDrawResourceStep();
|
|
215 |
protected:
|
|
216 |
//from CTGraphicsStep
|
|
217 |
CTGraphicsBase* CreateTestL();
|
|
218 |
};
|
|
219 |
|
|
220 |
|
|
221 |
#endif /*TDRAWRESOURCE_H_*/
|