|
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 "textendedbitmapcommon.h" |
|
17 #include "textendedbitmaplegacy.h" |
|
18 #include "tfbs.h" |
|
19 #include <s32mem.h> |
|
20 #include <bautils.h> |
|
21 |
|
22 const TUint8 KTestData[] = "Extended bitmap test data 123456"; |
|
23 const TInt KTestDataSize = sizeof(KTestData); |
|
24 const TInt KTestWidth = 50; |
|
25 const TInt KTestHeight = 50; |
|
26 const TSize KSizeInPixels = TSize(KTestWidth,KTestHeight); |
|
27 const TDisplayMode KDisplayMode = EColor64K; |
|
28 const TInt KBpp = 2; // 2 bpp for EColor64K |
|
29 |
|
30 // Test mbm files used by CTExtendedBitmapLegacy::TestApisThatCallResetL(). |
|
31 // These are used to check the operation of CFbsBitmap::Load() when used with |
|
32 // extended bitmaps. |
|
33 _LIT(KRomBmpFilename, "z:\\system\\data\\rf1.mbm"); |
|
34 _LIT(KRamBitmapFilenameOnZ, "z:\\system\\data\\16RAM2.mbm"); |
|
35 _LIT(KRamBitmapFilename, "c:\\textendedbitmaplegacy_16RAM2.mbm"); |
|
36 |
|
37 LOCAL_D RFs TheFs; |
|
38 |
|
39 CTExtendedBitmapLegacy::CTExtendedBitmapLegacy(CTestStep* aStep): |
|
40 CTFbsBase(aStep, ETrue) |
|
41 { |
|
42 } |
|
43 |
|
44 CTExtendedBitmapLegacy::~CTExtendedBitmapLegacy() |
|
45 { |
|
46 ((CTExtendedBitmapLegacyStep*)iStep)->CloseTMSGraphicsStep(); |
|
47 } |
|
48 |
|
49 void CTExtendedBitmapLegacy::RunFbsTestL(TInt aCurTestCase) |
|
50 { |
|
51 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
52 switch(aCurTestCase) |
|
53 { |
|
54 case 1: |
|
55 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0030")); |
|
56 TestDuplicateL(); |
|
57 break; |
|
58 case 2: |
|
59 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0031")); |
|
60 TestAccessDeniedL(); |
|
61 break; |
|
62 case 3: |
|
63 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0032")); |
|
64 TestNotSupportedL(); |
|
65 break; |
|
66 case 4: |
|
67 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0033")); |
|
68 TestTwipsL(); |
|
69 break; |
|
70 case 5: |
|
71 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0034")); |
|
72 TestGettersL(); |
|
73 break; |
|
74 case 6: |
|
75 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0035")); |
|
76 TestGetScanLineL(); |
|
77 break; |
|
78 case 7: |
|
79 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0036")); |
|
80 TestApisThatCallResetL(); |
|
81 break; |
|
82 case 8: |
|
83 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0037")); |
|
84 TestApisThatLeaveL(); |
|
85 break; |
|
86 case 9: |
|
87 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0038")); |
|
88 TestNotSupportedNoReturnL(); |
|
89 break; |
|
90 case 10: |
|
91 ((CTExtendedBitmapLegacyStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-EXTENDEDBITMAP-0039")); |
|
92 TestGetPixelL(); |
|
93 // Fall through as last test case |
|
94 default: |
|
95 SetLastTestCase(); |
|
96 break; |
|
97 } |
|
98 ((CTExtendedBitmapLegacyStep*)iStep)->RecordTestResultL(); |
|
99 } |
|
100 |
|
101 |
|
102 /** |
|
103 @SYMTestCaseID |
|
104 GRAPHICS-FBSERV-EXTENDEDBITMAP-0030 |
|
105 |
|
106 @SYMTestCaseDesc |
|
107 Create an extended bitmap then duplicate it by calling CFbsBitmap::Duplicate() |
|
108 |
|
109 @SYMPREQ |
|
110 PREQ2096 |
|
111 |
|
112 @SYMREQ |
|
113 REQ10847 |
|
114 |
|
115 @SYMTestPriority |
|
116 High |
|
117 |
|
118 @SYMTestStatus |
|
119 Implemented |
|
120 |
|
121 @SYMTestActions |
|
122 Create an extended bitmap using test data and test Uid. |
|
123 Call Duplicate() on the extended bitmap. |
|
124 Retrieves and validates the bitmap size, display mode, Uid, data and data size. |
|
125 |
|
126 @SYMTestExpectedResults |
|
127 Extended bitmap created and duplicated and information should match exactly. |
|
128 */ |
|
129 void CTExtendedBitmapLegacy::TestDuplicateL() |
|
130 { |
|
131 INFO_PRINTF1(_L("Duplicate - create a duplicate of an extended bitmap")); |
|
132 |
|
133 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
134 CleanupStack::PushL(bmp); |
|
135 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
136 TESTNOERRORL(err); |
|
137 |
|
138 CFbsBitmap* duplicateBmp = new(ELeave) CFbsBitmap; |
|
139 CleanupStack::PushL(duplicateBmp); |
|
140 err = duplicateBmp->Duplicate(bmp->Handle()); |
|
141 TESTNOERRORL(err); |
|
142 |
|
143 // check that the size, display mode etc are all correct |
|
144 TESTSIZEEQUALL(duplicateBmp->SizeInPixels(), KSizeInPixels); |
|
145 TESTEQUALL(duplicateBmp->DisplayMode(), KDisplayMode); |
|
146 TESTEQUALL(duplicateBmp->DisplayMode(), KDisplayMode); |
|
147 TESTEQUALL(duplicateBmp->ExtendedBitmapType(), KUidTestExtendedBitmap); |
|
148 |
|
149 duplicateBmp->BeginDataAccess(); |
|
150 |
|
151 const TUint8* returnedDataAddress = reinterpret_cast<TUint8*>(duplicateBmp->DataAddress()); |
|
152 TESTNOTEQUALL(returnedDataAddress, NULL); |
|
153 |
|
154 // compare the size of the data in the duplicate bitmap with the size of the original data, they should be the same |
|
155 TInt returnedDataSize = duplicateBmp->DataSize(); |
|
156 TESTEQUALL(returnedDataSize, KTestDataSize); |
|
157 |
|
158 // compare the data returned from the duplicate bitmap with the original data, they should be the same |
|
159 TInt res = Mem::Compare(returnedDataAddress, returnedDataSize, KTestData, KTestDataSize); |
|
160 TESTEQUALL(res, 0); |
|
161 |
|
162 duplicateBmp->EndDataAccess(ETrue); |
|
163 |
|
164 CleanupStack::PopAndDestroy(2, bmp); |
|
165 } |
|
166 |
|
167 /** |
|
168 @SYMTestCaseID |
|
169 GRAPHICS-FBSERV-EXTENDEDBITMAP-0031 |
|
170 |
|
171 @SYMTestCaseDesc |
|
172 Test that all the legacy CFbsBitmap APIs (i.e. APIs that existed before PREQ2096) |
|
173 that should return KErrAccessDenied for an extended bitmap do so correctly. |
|
174 |
|
175 @SYMPREQ |
|
176 PREQ2096 |
|
177 |
|
178 @SYMREQ |
|
179 REQ10847 |
|
180 REQ10856 |
|
181 REQ10857 |
|
182 |
|
183 @SYMTestPriority |
|
184 High |
|
185 |
|
186 @SYMTestStatus |
|
187 Implemented |
|
188 |
|
189 @SYMTestActions |
|
190 Create an extended bitmap using test data and test Uid. |
|
191 Call all the legacy APIs that should return KErrAccessDenied: |
|
192 - Resize() |
|
193 - Compress() |
|
194 - CompressInBackground() |
|
195 - SwapWidthAndHeight() |
|
196 |
|
197 @SYMTestExpectedResults |
|
198 The legacy APIs tested should all return KErrAccessDenied. |
|
199 */ |
|
200 void CTExtendedBitmapLegacy::TestAccessDeniedL() |
|
201 { |
|
202 INFO_PRINTF1(_L("AccessDenied - test legacy CFbsBitmap APIs that should return KErrAccessDenied when used with an extended bitmap")); |
|
203 |
|
204 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
205 CleanupStack::PushL(bmp); |
|
206 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
207 TESTNOERRORL(err); |
|
208 |
|
209 INFO_PRINTF1(_L("Resize()")); |
|
210 err = bmp->Resize(TSize(100,100)); |
|
211 TESTEXPECTEDERRORL(err, KErrAccessDenied); |
|
212 |
|
213 // This covers both versions of Compress() as one calls the other |
|
214 INFO_PRINTF1(_L("Compress()")); |
|
215 err = bmp->Compress(); |
|
216 TESTEXPECTEDERRORL(err, KErrAccessDenied); |
|
217 |
|
218 // This covers both synchronous versions of CompressInBackground() as one calls the other |
|
219 INFO_PRINTF1(_L("CompressInBackground()")); |
|
220 err = bmp->CompressInBackground(); |
|
221 TESTEXPECTEDERRORL(err, KErrAccessDenied); |
|
222 |
|
223 // This covers both asynchronous versions of CompressInBackground() as one calls the other |
|
224 INFO_PRINTF1(_L("CompressInBackground() (asynchronous)")); |
|
225 TRequestStatus requestStatus; |
|
226 bmp->CompressInBackground(requestStatus); |
|
227 User::WaitForRequest(requestStatus); |
|
228 TESTEXPECTEDERRORL(requestStatus.Int(), KErrAccessDenied); |
|
229 |
|
230 INFO_PRINTF1(_L("SwapWidthAndHeight()")); |
|
231 err = bmp->SwapWidthAndHeight(); |
|
232 TESTEXPECTEDERRORL(err, KErrAccessDenied); |
|
233 |
|
234 CleanupStack::PopAndDestroy(bmp); |
|
235 } |
|
236 |
|
237 /** |
|
238 @SYMTestCaseID |
|
239 GRAPHICS-FBSERV-EXTENDEDBITMAP-0032 |
|
240 |
|
241 @SYMTestCaseDesc |
|
242 Test that all the legacy CFbsBitmap APIs (i.e. APIs that existted before PREQ2096) |
|
243 that should return KErrNotSupported for an extended bitmap do so correctly, or |
|
244 if they have no return value and are not supported that they return cleanly. |
|
245 |
|
246 @SYMPREQ |
|
247 PREQ2096 |
|
248 |
|
249 @SYMREQ |
|
250 REQ10847 |
|
251 REQ10856 |
|
252 REQ10857 |
|
253 |
|
254 @SYMTestPriority |
|
255 High |
|
256 |
|
257 @SYMTestStatus |
|
258 Implemented |
|
259 |
|
260 @SYMTestActions |
|
261 Create an extended bitmap using test data and test Uid. |
|
262 Call all the legacy APIs that should return KErrNotSupported: |
|
263 - Save() |
|
264 - GetPalette() |
|
265 - SetDisplayMode() |
|
266 |
|
267 @SYMTestExpectedResults |
|
268 The legacy APIs tested should all return KErrNotSupported where they have return |
|
269 values, they should not cause errors where they are not supported but don't return |
|
270 an error value. |
|
271 */ |
|
272 void CTExtendedBitmapLegacy::TestNotSupportedL() |
|
273 { |
|
274 INFO_PRINTF1(_L("NotSupported - test legacy CFbsBitmap APIs that are not supported when used with an extended bitmap")); |
|
275 |
|
276 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
277 CleanupStack::PushL(bmp); |
|
278 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
279 TESTNOERRORL(err); |
|
280 |
|
281 // Methods that should return KErrNotSupported |
|
282 INFO_PRINTF1(_L("Save() - filename")); |
|
283 _LIT(KFilename, "C:\\temp.mbm"); |
|
284 TESTEXPECTEDERRORL(bmp->Save(KFilename), KErrNotSupported); |
|
285 |
|
286 INFO_PRINTF1(_L("Save() - RFile")); |
|
287 RFile file; |
|
288 err = file.Open(TheFs, KFilename, EFileWrite); |
|
289 TESTNOERRORL(err); |
|
290 CleanupClosePushL(file); |
|
291 TESTEXPECTEDERRORL(bmp->Save(file), KErrNotSupported); |
|
292 CleanupStack::PopAndDestroy(&file); |
|
293 |
|
294 INFO_PRINTF1(_L("GetPalette()")); |
|
295 CPalette* palette; |
|
296 TESTEXPECTEDERRORL(bmp->GetPalette(palette), KErrNotSupported); |
|
297 |
|
298 INFO_PRINTF1(_L("SetDisplayMode()")); |
|
299 err = bmp->SetDisplayMode(EColor16MU); |
|
300 TESTEXPECTEDERRORL(err, KErrNotSupported); |
|
301 |
|
302 |
|
303 CleanupStack::PopAndDestroy(bmp); |
|
304 } |
|
305 |
|
306 /** |
|
307 @SYMTestCaseID |
|
308 GRAPHICS-FBSERV-EXTENDEDBITMAP-0033 |
|
309 |
|
310 @SYMTestCaseDesc |
|
311 Test that all CFbsBitmap methods that mention Twips work correctly with extended bitmaps. |
|
312 |
|
313 @SYMPREQ |
|
314 PREQ2096 |
|
315 |
|
316 @SYMREQ |
|
317 REQ10847 |
|
318 REQ10857 |
|
319 REQ10858 |
|
320 |
|
321 @SYMTestPriority |
|
322 High |
|
323 |
|
324 @SYMTestStatus |
|
325 Implemented |
|
326 |
|
327 @SYMTestActions |
|
328 Create an extended bitmap using test data and test Uid. |
|
329 Call all the legacy APIs that mention Twips: |
|
330 - SetSizeInTwips() |
|
331 - SizeInTwips() |
|
332 - HorizontalPixelsToTwips() |
|
333 - HorizontalTwipsToPixels() |
|
334 - VerticalPixelsToTwips() |
|
335 - VerticalTwipsToPixels() |
|
336 |
|
337 @SYMTestExpectedResults |
|
338 All methods should work correctly with extended bitmaps. |
|
339 */ |
|
340 void CTExtendedBitmapLegacy::TestTwipsL() |
|
341 { |
|
342 INFO_PRINTF1(_L("Twips - test legacy CFbsBitmap Twips APIs work correctly when used with an extended bitmap")); |
|
343 const TSize KSizeInTwips(20,30); |
|
344 |
|
345 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
346 CleanupStack::PushL(bmp); |
|
347 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
348 TESTNOERRORL(err); |
|
349 |
|
350 INFO_PRINTF1(_L("SetSizeInTwips()")); |
|
351 bmp->SetSizeInTwips(KSizeInTwips); |
|
352 |
|
353 INFO_PRINTF1(_L("SizeInTwips()")); |
|
354 TESTSIZEEQUALL(bmp->SizeInTwips(), KSizeInTwips); |
|
355 |
|
356 INFO_PRINTF1(_L("HorizontalPixelsToTwips()")); |
|
357 TESTEQUALL(bmp->HorizontalPixelsToTwips(KSizeInPixels.iWidth), KSizeInTwips.iWidth); |
|
358 |
|
359 INFO_PRINTF1(_L("HorizontalTwipsToPixels()")); |
|
360 TESTEQUALL(bmp->HorizontalTwipsToPixels(KSizeInTwips.iWidth), KSizeInPixels.iWidth); |
|
361 |
|
362 INFO_PRINTF1(_L("VerticalPixelsToTwips()")); |
|
363 TESTEQUALL(bmp->VerticalPixelsToTwips(KSizeInPixels.iHeight), KSizeInTwips.iHeight); |
|
364 |
|
365 INFO_PRINTF1(_L("VerticalTwipsToPixels()")); |
|
366 TESTEQUALL(bmp->VerticalTwipsToPixels(KSizeInTwips.iHeight), KSizeInPixels.iHeight); |
|
367 |
|
368 const TDisplayMode displayMode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, |
|
369 EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP}; |
|
370 TInt ii = 0; |
|
371 err = KErrNotSupported; |
|
372 CFbsScreenDevice* scd = NULL; |
|
373 for(;(ii<TInt(sizeof(displayMode)/sizeof(displayMode[0]))) && (err == KErrNotSupported);++ii) |
|
374 { |
|
375 TRAP(err, scd = CFbsScreenDevice::NewL(_L("scdv"),displayMode[ii])); |
|
376 } |
|
377 if (err != KErrNone) |
|
378 { |
|
379 _LIT(KLog,"Failed to create screen device %S return value %d"); |
|
380 INFO_PRINTF3(KLog,&ColorModeName(displayMode[ii]),err); |
|
381 } |
|
382 else |
|
383 { |
|
384 _LIT(KLog,"Created Screen Device with mode %S"); |
|
385 INFO_PRINTF2(KLog,&ColorModeName(displayMode[ii])); |
|
386 } |
|
387 TESTNOERRORL(err); |
|
388 // The size of screen that this is tested on will be different depending on where it is |
|
389 // tested, so just check that this does not cause an error, don't check the result |
|
390 INFO_PRINTF1(_L("SetSizeInTwips() (screen device)")); |
|
391 bmp->SetSizeInTwips(scd); |
|
392 |
|
393 delete scd; |
|
394 CleanupStack::PopAndDestroy(1, bmp); |
|
395 } |
|
396 |
|
397 /** |
|
398 @SYMTestCaseID |
|
399 GRAPHICS-FBSERV-EXTENDEDBITMAP-0034 |
|
400 |
|
401 @SYMTestCaseDesc |
|
402 Test the simple getter CFbsBitmap APIs such as Handle(). |
|
403 |
|
404 @SYMPREQ |
|
405 PREQ2096 |
|
406 |
|
407 @SYMREQ |
|
408 REQ10847 |
|
409 REQ10857 |
|
410 REQ10858 |
|
411 |
|
412 @SYMTestPriority |
|
413 High |
|
414 |
|
415 @SYMTestStatus |
|
416 Implemented |
|
417 |
|
418 @SYMTestActions |
|
419 Create an extended bitmap using test data and test Uid. |
|
420 Call the following simple getter APIs: |
|
421 - InitialDisplayMode() |
|
422 - IsRomBitmap() |
|
423 - Handle() |
|
424 - Header() |
|
425 - IsLargeBitmap() |
|
426 - DataStride() |
|
427 - HardwareBitmapHandle() |
|
428 - SerialNumber() |
|
429 - IsCompressedInRAM() |
|
430 - GetAllBitmapHandles() |
|
431 |
|
432 @SYMTestExpectedResults |
|
433 No errors should occur. |
|
434 */ |
|
435 void CTExtendedBitmapLegacy::TestGettersL() |
|
436 { |
|
437 INFO_PRINTF1(_L("Test simple getter APIs")); |
|
438 |
|
439 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
440 CleanupStack::PushL(bmp); |
|
441 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
442 TESTNOERRORL(err); |
|
443 |
|
444 INFO_PRINTF1(_L("InitialDisplayMode()")); |
|
445 TESTEQUALL(bmp->InitialDisplayMode(), KDisplayMode); |
|
446 |
|
447 INFO_PRINTF1(_L("IsRomBitmap()")); |
|
448 TESTTRUEL(bmp->IsRomBitmap()); |
|
449 |
|
450 INFO_PRINTF1(_L("Handle()")); |
|
451 TESTNOTEQUALL(bmp->Handle(), 0); |
|
452 |
|
453 INFO_PRINTF1(_L("Header()")); |
|
454 SEpocBitmapHeader header = bmp->Header(); |
|
455 TESTSIZEEQUALL(header.iSizeInPixels, KSizeInPixels); |
|
456 TESTSIZEEQUALL(header.iSizeInTwips, TSize(0,0)); |
|
457 TESTEQUALL(header.iBitsPerPixel, 16); |
|
458 TESTEQUALL(header.iColor, 1); |
|
459 TESTEQUALL(header.iPaletteEntries, 0); |
|
460 TESTEQUALL(header.iCompression, EProprietaryCompression); |
|
461 |
|
462 INFO_PRINTF1(_L("IsLargeBitmap()")); |
|
463 TESTTRUEL(bmp->IsLargeBitmap()); |
|
464 |
|
465 INFO_PRINTF1(_L("DataStride()")); |
|
466 TESTEQUALL(bmp->DataStride(), KSizeInPixels.iWidth*KBpp); |
|
467 |
|
468 INFO_PRINTF1(_L("HardwareBitmapHandle()")); |
|
469 TESTEQUALL(bmp->HardwareBitmapHandle(), 0); |
|
470 |
|
471 INFO_PRINTF1(_L("SerialNumber()")); |
|
472 TESTNOTEQUALL(bmp->SerialNumber(), 0); |
|
473 |
|
474 INFO_PRINTF1(_L("IsCompressedInRAM()")); |
|
475 TESTEQUALL(bmp->IsCompressedInRAM(), EFalse); |
|
476 |
|
477 // The touch count changes for a bitmap (not a ROM bitmap) when it is resized etc, it should not change |
|
478 // when Resize() is called on an extended bitmap |
|
479 INFO_PRINTF1(_L("TouchCount()")); |
|
480 TESTEQUALL(bmp->TouchCount(), 0); |
|
481 bmp->Resize(TSize(100,100)); |
|
482 TESTEQUALL(bmp->TouchCount(), 0); |
|
483 |
|
484 // Bitmaps (not ROM bitmaps) become volatile if DataAddress() is called outside BeginDataAccess() and EndDataAccess(), |
|
485 // should never be set for extended bitmaps |
|
486 INFO_PRINTF1(_L("IsVolatile()")); |
|
487 TESTEQUALL(bmp->IsVolatile(), EFalse); |
|
488 bmp->DataAddress(); |
|
489 TESTEQUALL(bmp->IsVolatile(), EFalse); |
|
490 |
|
491 RArray<TInt> handles; |
|
492 CleanupClosePushL(handles); |
|
493 INFO_PRINTF1(_L("GetAllBitmapHandles()")); |
|
494 TESTNOERRORL(bmp->GetAllBitmapHandles(handles)); |
|
495 TESTTRUEL(handles.Count() > 0); |
|
496 |
|
497 CleanupStack::PopAndDestroy(2, bmp); |
|
498 } |
|
499 |
|
500 /** |
|
501 @SYMTestCaseID |
|
502 GRAPHICS-FBSERV-EXTENDEDBITMAP-0035 |
|
503 |
|
504 @SYMTestCaseDesc |
|
505 Test GetScanLine with extended bitmaps where no rasterizer is present. |
|
506 |
|
507 @SYMPREQ |
|
508 PREQ2096 |
|
509 |
|
510 @SYMREQ |
|
511 REQ10847 |
|
512 REQ10857 |
|
513 REQ10858 |
|
514 |
|
515 @SYMTestPriority |
|
516 High |
|
517 |
|
518 @SYMTestStatus |
|
519 Implemented |
|
520 |
|
521 @SYMTestActions |
|
522 Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. |
|
523 Call GetScanLine(). |
|
524 |
|
525 @SYMTestExpectedResults |
|
526 GetScanLine() should return a white scanline of the length requested, no errors should occur. |
|
527 */ |
|
528 void CTExtendedBitmapLegacy::TestGetScanLineL() |
|
529 { |
|
530 INFO_PRINTF1(_L("Test CFbsBitmap::GetScanLine() where there is no supported rasterizer for the passed extended bitmap Uid")); |
|
531 |
|
532 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
533 CleanupStack::PushL(bmp); |
|
534 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
535 TESTNOERRORL(err); |
|
536 |
|
537 const TInt KScanlineLength = KTestWidth*KBpp; |
|
538 TBuf8<KScanlineLength> buf; |
|
539 bmp->GetScanLine(buf, TPoint(0,0), KTestWidth, KDisplayMode); |
|
540 TESTEQUALL(buf.Size(), KScanlineLength); |
|
541 |
|
542 // Check that the scanline has been set to white |
|
543 for (TInt i = 0; i < KScanlineLength; i++) |
|
544 { |
|
545 TESTEQUALL(buf[i], 255); |
|
546 } |
|
547 |
|
548 CleanupStack::PopAndDestroy(bmp); |
|
549 } |
|
550 |
|
551 /** |
|
552 @SYMTestCaseID |
|
553 GRAPHICS-FBSERV-EXTENDEDBITMAP-0036 |
|
554 |
|
555 @SYMTestCaseDesc |
|
556 Test an extended bitmap with all of the CFbsBitmap APIs that call Reset(). |
|
557 |
|
558 @SYMPREQ |
|
559 PREQ2096 |
|
560 |
|
561 @SYMREQ |
|
562 REQ10847 |
|
563 |
|
564 @SYMTestPriority |
|
565 High |
|
566 |
|
567 @SYMTestStatus |
|
568 Implemented |
|
569 |
|
570 @SYMTestActions |
|
571 For each API: |
|
572 - Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. |
|
573 - Call the API. |
|
574 The following APIs are tested: |
|
575 - Load() |
|
576 - LoadAndCompress() |
|
577 - Internalize() |
|
578 - SetRomBitmapL() |
|
579 |
|
580 @SYMTestExpectedResults |
|
581 All APIs tested should complete with no errors, the resultant CFbsBitmap |
|
582 should not be an extended bitmap as it will have been reset. |
|
583 */ |
|
584 void CTExtendedBitmapLegacy::TestApisThatCallResetL() |
|
585 { |
|
586 INFO_PRINTF1(_L("Test CFbsBitmap APIs that Call Reset()")); |
|
587 |
|
588 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
589 CleanupStack::PushL(bmp); |
|
590 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
591 TESTNOERRORL(err); |
|
592 TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); |
|
593 |
|
594 INFO_PRINTF1(_L("Load()")); |
|
595 err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
596 TESTNOERRORL(err); |
|
597 TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again |
|
598 TESTNOERRORL(bmp->Load(KRamBitmapFilename)); |
|
599 TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap |
|
600 |
|
601 INFO_PRINTF1(_L("LoadAndCompress()")); |
|
602 err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
603 TESTNOERRORL(err); |
|
604 TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again |
|
605 TESTNOERRORL(bmp->LoadAndCompress(KRamBitmapFilename)); |
|
606 TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap |
|
607 |
|
608 INFO_PRINTF1(_L("InternalizeL()")); |
|
609 CBufFlat* buf = CBufFlat::NewL(512); |
|
610 CleanupStack::PushL(buf); |
|
611 RBufWriteStream writeStream(*buf,0); |
|
612 bmp->ExternalizeL(writeStream); // externalize a normal bitmap |
|
613 writeStream.Close(); |
|
614 err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
615 TESTNOERRORL(err); |
|
616 TESTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should be an extended bitmap again |
|
617 RBufReadStream readStream(*buf,0); |
|
618 bmp->InternalizeL(readStream); |
|
619 readStream.Close(); |
|
620 TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap |
|
621 |
|
622 TUint32* romAddress = NULL; |
|
623 if(!CFbsBitmap::IsFileInRom(KRomBmpFilename, romAddress)) //check any rom bitmap |
|
624 { |
|
625 INFO_PRINTF2(_L("Skipping tests of ROM bitmaps since file \"%S\" is reported to not be a ROM bitmap."), &KRomBmpFilename); |
|
626 INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported.")); |
|
627 } |
|
628 else |
|
629 { |
|
630 INFO_PRINTF1(_L("SetRomBitmapL()")); |
|
631 CFbsBitmapEx* romBitmap = new(ELeave) CFbsBitmapEx; |
|
632 CleanupStack::PushL(romBitmap); |
|
633 INFO_PRINTF2(_L("... attempting to load %S"), &KRomBmpFilename); |
|
634 err = romBitmap->Load(KRomBmpFilename); |
|
635 TESTNOERRORL(err); |
|
636 TInt size = 0; |
|
637 INFO_PRINTF1(_L("... calling SetRomBitmapL()")); |
|
638 bmp->SetRomBitmapL(romBitmap->BitmapAddress(), size); |
|
639 TESTNOTEQUALL(bmp->ExtendedBitmapType(), KUidTestExtendedBitmap); // should no longer be an extended bitmap |
|
640 TEST(bmp->SerialNumber() == -TInt64(static_cast<TUint32>(bmp->Handle()))); // A ROM bitmap's handle is its address pointer, its serial number is -ve the address pointer |
|
641 |
|
642 CleanupStack::PopAndDestroy(1, romBitmap); |
|
643 } |
|
644 |
|
645 CleanupStack::PopAndDestroy(2, bmp); |
|
646 } |
|
647 |
|
648 /** |
|
649 @SYMTestCaseID |
|
650 GRAPHICS-FBSERV-EXTENDEDBITMAP-0037 |
|
651 |
|
652 @SYMTestCaseDesc |
|
653 Test the CFbsBitmap APIs that should leave when called by an extended bitmap. |
|
654 |
|
655 @SYMPREQ |
|
656 PREQ2096 |
|
657 |
|
658 @SYMREQ |
|
659 REQ10847 |
|
660 REQ10856 |
|
661 REQ10857 |
|
662 |
|
663 @SYMTestPriority |
|
664 High |
|
665 |
|
666 @SYMTestStatus |
|
667 Implemented |
|
668 |
|
669 @SYMTestActions |
|
670 For each API: |
|
671 - Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. |
|
672 - Call the API. |
|
673 The following APIs are tested: |
|
674 - ExternalizeL() |
|
675 - ExternalizeRectangleL() |
|
676 |
|
677 @SYMTestExpectedResults |
|
678 All APIs tested should leave with the error KErrNotSupported. |
|
679 */ |
|
680 void CTExtendedBitmapLegacy::TestApisThatLeaveL() |
|
681 { |
|
682 INFO_PRINTF1(_L("ApisThatLeave - test legacy CFbsBitmap APIs that leave when used with an extended bitmap")); |
|
683 |
|
684 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
685 CleanupStack::PushL(bmp); |
|
686 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
687 TESTNOERRORL(err); |
|
688 |
|
689 INFO_PRINTF1(_L("ExternalizeL()")); |
|
690 CBufFlat* buf = CBufFlat::NewL(512); |
|
691 CleanupStack::PushL(buf); |
|
692 RBufWriteStream writeStream(*buf,0); |
|
693 CleanupClosePushL(writeStream); |
|
694 TRAP(err, bmp->ExternalizeL(writeStream)); |
|
695 TESTEXPECTEDERRORL(err, KErrNotSupported); |
|
696 |
|
697 INFO_PRINTF1(_L("ExternalizeRectangleL()")); |
|
698 RBufWriteStream writeStream2(*buf,0); |
|
699 CleanupClosePushL(writeStream2); |
|
700 TRAP(err, bmp->ExternalizeRectangleL(writeStream2, TRect(10,10,100,100))); |
|
701 TESTEXPECTEDERRORL(err, KErrNotSupported); |
|
702 |
|
703 CleanupStack::PopAndDestroy(4, bmp); |
|
704 } |
|
705 |
|
706 /** |
|
707 @SYMTestCaseID |
|
708 GRAPHICS-FBSERV-EXTENDEDBITMAP-0038 |
|
709 |
|
710 @SYMTestCaseDesc |
|
711 Test that APIs that do not return an error value or leave, yet are not supported |
|
712 for extended bitmaps, do not cause an error. |
|
713 |
|
714 @SYMPREQ |
|
715 PREQ2096 |
|
716 |
|
717 @SYMREQ |
|
718 REQ10847 |
|
719 REQ10856 |
|
720 REQ10857 |
|
721 |
|
722 @SYMTestPriority |
|
723 High |
|
724 |
|
725 @SYMTestStatus |
|
726 Implemented |
|
727 |
|
728 @SYMTestActions |
|
729 For each API: |
|
730 - Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. |
|
731 - Call the API. |
|
732 The following APIs are tested: |
|
733 - PaletteAttributes() |
|
734 - SetPalette() |
|
735 |
|
736 @SYMTestExpectedResults |
|
737 All APIs tested should complete with no errors. |
|
738 */ |
|
739 void CTExtendedBitmapLegacy::TestNotSupportedNoReturnL() |
|
740 { |
|
741 INFO_PRINTF1(_L("NotSupportedNoReturn - test legacy CFbsBitmap APIs that are not supported when used with an extended bitmap but do not return errors")); |
|
742 |
|
743 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
744 CleanupStack::PushL(bmp); |
|
745 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
746 TESTNOERRORL(err); |
|
747 |
|
748 // Methods that are not supported and do not return errors values |
|
749 INFO_PRINTF1(_L("PaletteAttributes()")); |
|
750 TBool modifiable; |
|
751 TInt numEntries; |
|
752 bmp->PaletteAttributes(modifiable, numEntries); |
|
753 |
|
754 INFO_PRINTF1(_L("SetPalette()")); |
|
755 bmp->SetPalette(NULL); |
|
756 |
|
757 CleanupStack::PopAndDestroy(bmp); |
|
758 } |
|
759 |
|
760 /** |
|
761 @SYMTestCaseID |
|
762 GRAPHICS-FBSERV-EXTENDEDBITMAP-0039 |
|
763 |
|
764 @SYMTestCaseDesc |
|
765 Test GetPixel with extended bitmaps where no rasterizer is present |
|
766 that supports the extended bitmap type. |
|
767 |
|
768 @SYMCR |
|
769 CR1804 |
|
770 |
|
771 @SYMREQ |
|
772 REQ10858 |
|
773 |
|
774 @SYMTestPriority |
|
775 High |
|
776 |
|
777 @SYMTestStatus |
|
778 Implemented |
|
779 |
|
780 @SYMTestActions |
|
781 Create an extended bitmap using test data and test Uid that is not supported by a rasterizer. |
|
782 Call GetPixel(). |
|
783 |
|
784 @SYMTestExpectedResults |
|
785 GetPixel() should return white pixels at the points requested, no errors should occur. |
|
786 */ |
|
787 void CTExtendedBitmapLegacy::TestGetPixelL() |
|
788 { |
|
789 INFO_PRINTF1(_L("Test CFbsBitmap::GetPixel() where there is no supported rasterizer for the passed extended bitmap Uid")); |
|
790 |
|
791 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
792 CleanupStack::PushL(bmp); |
|
793 TInt err = bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize); |
|
794 TESTNOERRORL(err); |
|
795 |
|
796 // Check that the absence of a rasteriser causes legacy off-screen rendering to |
|
797 // treat the extended bitmap as if all pixels were white. |
|
798 TRgb color; |
|
799 for (TInt y = 0; y < KTestHeight; ++y) |
|
800 { |
|
801 for (TInt x = 0; x < KTestWidth; ++x) |
|
802 { |
|
803 bmp->GetPixel(color, TPoint(x,y)); |
|
804 TESTTRUEL(color == KRgbWhite); |
|
805 } |
|
806 } |
|
807 |
|
808 CleanupStack::PopAndDestroy(bmp); |
|
809 } |
|
810 |
|
811 __CONSTRUCT_STEP__(ExtendedBitmapLegacy) |
|
812 |
|
813 void CTExtendedBitmapLegacyStep::TestSetupL() |
|
814 { |
|
815 // Copy files needed by the tests to c: |
|
816 TheFs.Connect(); |
|
817 TInt err = BaflUtils::CopyFile(TheFs, KRamBitmapFilenameOnZ, KRamBitmapFilename); |
|
818 if (err != KErrNone) |
|
819 { |
|
820 ERR_PRINTF2(_L("Error copying test mbm file from rom to ram: %d"), err); |
|
821 User::Leave(err); |
|
822 } |
|
823 } |
|
824 |
|
825 void CTExtendedBitmapLegacyStep::TestClose() |
|
826 { |
|
827 // Delete files used by the tests from c: |
|
828 BaflUtils::DeleteFile(TheFs, KRamBitmapFilename); |
|
829 TheFs.Close(); |
|
830 } |