|
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 #include "textendedbitmap.h" |
|
17 #include <s32mem.h> |
|
18 |
|
19 const TUid KUidExampleExtendedBitmap = {0x10285A78}; |
|
20 |
|
21 CTExtendedBitmap::CTExtendedBitmap() |
|
22 { |
|
23 SetTestStepName(KTDirectGdiExtendedBitmapStep); |
|
24 } |
|
25 |
|
26 CTExtendedBitmap::~CTExtendedBitmap() |
|
27 { |
|
28 } |
|
29 |
|
30 /** |
|
31 @SYMTestCaseID |
|
32 GRAPHICS-DIRECTGDI-EXTENDED-BITMAP-0001 |
|
33 |
|
34 @SYMPREQ |
|
35 PREQ2096 |
|
36 |
|
37 @SYMREQ |
|
38 |
|
39 @SYMTestCaseDesc |
|
40 Test all CDirectGdiContext APIs that take CFbsBitmap as a parameter correctly return or set |
|
41 an error code when used with an extended bitmap. |
|
42 |
|
43 @SYMTestPriority |
|
44 High |
|
45 |
|
46 @SYMTestStatus |
|
47 Implemented |
|
48 |
|
49 @SYMTestActions |
|
50 Create a CFbsBitmap using CFbsBitmap::CreateExtendedBitmap(). |
|
51 Call the following CDirectGdiContext APIs passing the extended bitmap as a parameter: |
|
52 - SetBrushPattern() |
|
53 - BitBlt() |
|
54 - BitBltMasked() x 2 |
|
55 - DrawBitmap() |
|
56 - DrawBitmapMasked() |
|
57 |
|
58 @SYMTestExpectedResults |
|
59 Each API should return or set the error KErrNotSupported when called with an extended bitmap. |
|
60 */ |
|
61 void CTExtendedBitmap::TestErrorCodesL() |
|
62 { |
|
63 TBuf<KTestCaseLength> testCaseName; |
|
64 _LIT(KTestName, "ExtendedBitmap-ErrorCodes: source format "); |
|
65 if(!iRunningOomTests) |
|
66 { |
|
67 testCaseName.Append(KTestName); |
|
68 testCaseName.Append(TDisplayModeMapping::ConvertPixelFormatToPixelFormatString(iTestParams.iSourcePixelFormat)); |
|
69 INFO_PRINTF1(testCaseName); |
|
70 } |
|
71 |
|
72 ResetGc(); |
|
73 |
|
74 const TSize sizeInPixels(32,32); |
|
75 const TRect srcRect(TPoint(0,0),sizeInPixels); |
|
76 const TRgb colors[] = {TRgb(0,255,255), TRgb(255,0,255), TRgb(255,255,0)}; |
|
77 TInt dataSize = sizeof(colors)+sizeof(TUint8); // estimate the size to be written |
|
78 TUint8* data = new(ELeave) TUint8[dataSize]; |
|
79 CleanupStack::PushL(data); |
|
80 |
|
81 RMemWriteStream ws; |
|
82 ws.Open(data, dataSize); |
|
83 CleanupClosePushL(ws); |
|
84 ws << colors[0] << colors[1] << colors[2] << static_cast<TUint8>(1); // horizontal stripe |
|
85 dataSize = ws.Sink()->TellL(MStreamBuf::EWrite).Offset(); // get the actual size written |
|
86 CleanupStack::PopAndDestroy(1, &ws); |
|
87 |
|
88 // Create an extended bitmap |
|
89 CFbsBitmap* exBmp = new(ELeave) CFbsBitmap; |
|
90 CleanupStack::PushL(exBmp); |
|
91 TInt err = exBmp->CreateExtendedBitmap(sizeInPixels, |
|
92 TDisplayModeMapping::MapPixelFormatToDisplayMode(iTestParams.iSourcePixelFormat), |
|
93 KUidExampleExtendedBitmap, |
|
94 data, |
|
95 dataSize); |
|
96 TESTNOERRORL(err); |
|
97 |
|
98 // Create a normal bitmap to use when testing cases where the main bitmap being used is a normal |
|
99 // bitmap and the mask is an extended bitmap |
|
100 CFbsBitmap* nmlBmp = new(ELeave) CFbsBitmap; |
|
101 CleanupStack::PushL(nmlBmp); |
|
102 err = nmlBmp->Create(sizeInPixels, TDisplayModeMapping::MapPixelFormatToDisplayMode(iTestParams.iSourcePixelFormat)); |
|
103 TESTNOERRORL(err); |
|
104 |
|
105 // Test that each of the CDirectGdiContext APIs that use CFbsBitmap return or set the |
|
106 // error KErrNotSupported when used with the extended bitmap |
|
107 // SetBrushPattern |
|
108 iGc->SetBrushPattern(*exBmp); |
|
109 TEST(iGc->GetError() == KErrNotSupported); |
|
110 |
|
111 // BitBlt |
|
112 iGc->BitBlt(TPoint(0,0), *exBmp); |
|
113 TEST(iGc->GetError() == KErrNotSupported); |
|
114 iGc->BitBlt(TPoint(0,0), *exBmp, srcRect); |
|
115 TEST(iGc->GetError() == KErrNotSupported); |
|
116 |
|
117 // BitBltMasked |
|
118 iGc->BitBltMasked(TPoint(0,0), *exBmp, srcRect, *nmlBmp, EFalse); |
|
119 TEST(iGc->GetError() == KErrNotSupported); |
|
120 iGc->BitBltMasked(TPoint(0,0), *nmlBmp, srcRect, *exBmp, EFalse); |
|
121 TEST(iGc->GetError() == KErrNotSupported); |
|
122 iGc->BitBltMasked(TPoint(0,0), *exBmp, srcRect, *nmlBmp, TPoint(1,-1)); |
|
123 TEST(iGc->GetError() == KErrNotSupported); |
|
124 iGc->BitBltMasked(TPoint(0,0), *nmlBmp, srcRect, *exBmp, TPoint(1,-1)); |
|
125 TEST(iGc->GetError() == KErrNotSupported); |
|
126 |
|
127 // DrawBitmap |
|
128 iGc->DrawBitmap(srcRect, *exBmp); |
|
129 TEST(iGc->GetError() == KErrNotSupported); |
|
130 iGc->DrawBitmap(srcRect, *exBmp, srcRect); |
|
131 TEST(iGc->GetError() == KErrNotSupported); |
|
132 |
|
133 // DrawBitmapMasked |
|
134 iGc->DrawBitmapMasked(srcRect, *exBmp, srcRect, *nmlBmp, EFalse); |
|
135 TEST(iGc->GetError() == KErrNotSupported); |
|
136 iGc->DrawBitmapMasked(srcRect, *nmlBmp, srcRect, *exBmp, EFalse); |
|
137 TEST(iGc->GetError() == KErrNotSupported); |
|
138 |
|
139 CleanupStack::PopAndDestroy(3, data); |
|
140 } |
|
141 |
|
142 /** |
|
143 Override of base class virtual |
|
144 @leave Gets system wide error code |
|
145 @return - TVerdict code |
|
146 */ |
|
147 TVerdict CTExtendedBitmap::doTestStepPreambleL() |
|
148 { |
|
149 CTDirectGdiStepBase::doTestStepPreambleL(); |
|
150 return TestStepResult(); |
|
151 } |
|
152 |
|
153 /** |
|
154 Override of base class pure virtual |
|
155 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
156 not leave. That being the case, the current test result value will be EPass. |
|
157 @leave Gets system wide error code |
|
158 @return TVerdict code |
|
159 */ |
|
160 TVerdict CTExtendedBitmap::doTestStepL() |
|
161 { |
|
162 for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--) |
|
163 { |
|
164 iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex]; |
|
165 SetTargetL(iTestParams.iTargetPixelFormat); |
|
166 |
|
167 // Test for each pixel format |
|
168 for(TInt sourcePixelFormatIndex = iSourcePixelFormatArray.Count() - 1; sourcePixelFormatIndex >= 0 ; sourcePixelFormatIndex--) |
|
169 { |
|
170 iTestParams.iSourcePixelFormat = iSourcePixelFormatArray[sourcePixelFormatIndex]; |
|
171 |
|
172 RunTestsL(); |
|
173 RunOomTestsL(); |
|
174 } |
|
175 } |
|
176 CloseTMSGraphicsStep(); |
|
177 return TestStepResult(); |
|
178 } |
|
179 |
|
180 /** |
|
181 Override of base class pure virtual |
|
182 Lists the tests to be run |
|
183 */ |
|
184 void CTExtendedBitmap::RunTestsL() |
|
185 { |
|
186 // These tests should only be run when using DirectGdi as the error codes |
|
187 // we are checking for are only returned by DirectGdi. Extended bitmaps are |
|
188 // supported in BitGdi but not in DirectGdi. |
|
189 if (iUseDirectGdi) |
|
190 { |
|
191 SetTestStepID(_L("GRAPHICS-DIRECTGDI-EXTENDED-BITMAP-0001")); |
|
192 TestErrorCodesL(); |
|
193 RecordTestResultL(); |
|
194 } |
|
195 } |