16 /** |
16 /** |
17 @file |
17 @file |
18 @internalComponent - Internal Symbian test code |
18 @internalComponent - Internal Symbian test code |
19 */ |
19 */ |
20 |
20 |
|
21 #include <test/graphicsfontutils.h> |
21 #include <graphics/fbsglyphmetricsarray.h> |
22 #include <graphics/fbsglyphmetricsarray.h> |
22 #include <graphics/fbsglyphdataiterator.h> |
23 #include <graphics/fbsglyphdataiterator.h> |
23 #include "tfbsglyphdatapanic.h" |
24 #include "tfbsglyphdatapanic.h" |
24 |
25 |
25 _LIT(KTypefaceName, "DejaVu Sans Condensed"); |
26 _LIT(KTypefaceName, "DejaVu Sans Condensed"); |
26 const TInt KNumGlyphCodes = 96; |
27 const TInt KNumGlyphCodes = 96; |
27 |
|
28 /* |
|
29 Lookup table to convert from ascii code to |
|
30 glyph code for the Deja Vu family of fonts. |
|
31 */ |
|
32 const TUint DejaVuASCIIToGlyphCode[] = |
|
33 { |
|
34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
36 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
|
37 0, 0, 3, 4, 5, 6, 7, 8, 9, 10, |
|
38 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
|
39 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
|
40 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
|
41 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, |
|
42 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, |
|
43 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, |
|
44 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
|
45 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
|
46 91, 92, 93, 94, 95, 96, 97, 98, |
|
47 }; |
|
48 |
28 |
49 CTFbsGlyphDataPanic::CTFbsGlyphDataPanic(CTestStep* aStep): |
29 CTFbsGlyphDataPanic::CTFbsGlyphDataPanic(CTestStep* aStep): |
50 CTGraphicsBase(aStep) |
30 CTGraphicsBase(aStep) |
51 { |
31 { |
52 } |
32 } |
67 User::LeaveIfNull(iTs = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL)); |
47 User::LeaveIfNull(iTs = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL)); |
68 User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont, TFontSpec(KTypefaceName, 15))); |
48 User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont, TFontSpec(KTypefaceName, 15))); |
69 User::LeaveIfError(iSgDriver.Open()); |
49 User::LeaveIfError(iSgDriver.Open()); |
70 |
50 |
71 //initialize the array with ASCII characters from 0020 to 007F |
51 //initialize the array with ASCII characters from 0020 to 007F |
|
52 CCharCodeConverter* converter = CCharCodeConverter::NewLC(); |
|
53 converter->UseFontL(iFont); |
72 iGlyphCodes = new(ELeave) TUint[KNumGlyphCodes]; |
54 iGlyphCodes = new(ELeave) TUint[KNumGlyphCodes]; |
73 for (TInt i = 0; i < KNumGlyphCodes; ++i) |
55 for (TInt i = 0; i < KNumGlyphCodes; ++i) |
74 { |
56 { |
75 TUint asciiCode = i+0x20; |
57 TUint asciiCode = i + 0x20; |
76 iGlyphCodes[i] = DejaVuASCIIToGlyphCode[asciiCode]; |
58 iGlyphCodes[i] = converter->GlyphCodeL(asciiCode); |
77 } |
59 } |
|
60 CleanupStack::PopAndDestroy(1); // converter |
78 } |
61 } |
79 |
62 |
80 void CTFbsGlyphDataPanic::RunTestCaseL(TInt /*aCurTestCase*/) |
63 void CTFbsGlyphDataPanic::RunTestCaseL(TInt /*aCurTestCase*/) |
81 { |
64 { |
82 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
65 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
244 ii. Call Next() to attempt to move the iterator past the end of the array of glyph codes. |
227 ii. Call Next() to attempt to move the iterator past the end of the array of glyph codes. |
245 iii. Call Close() and repeat ii. |
228 iii. Call Close() and repeat ii. |
246 |
229 |
247 @SYMTestExpectedResults |
230 @SYMTestExpectedResults |
248 The call to Next() should fail with KErrNotFound, signifying the iterator is still open. |
231 The call to Next() should fail with KErrNotFound, signifying the iterator is still open. |
249 The final call to Next() should panic with GDI 4. |
232 The final call to Next() should panic with FBSCLI 31. |
250 */ |
233 */ |
251 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedNext() |
234 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedNext() |
252 { |
235 { |
253 INFO_PRINTF1(_L("Ensure that Next() operation applied on iterator which has been closed will panic")); |
236 INFO_PRINTF1(_L("Ensure that Next() operation applied on iterator which has been closed will panic")); |
254 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0655")); |
237 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0655")); |
274 i. Open the glyph data iterator. |
257 i. Open the glyph data iterator. |
275 ii. Close the glyph data iterator. |
258 ii. Close the glyph data iterator. |
276 iii. Call Image() on an RFbsGlyphDataIterator instance which has been closed. |
259 iii. Call Image() on an RFbsGlyphDataIterator instance which has been closed. |
277 |
260 |
278 @SYMTestExpectedResults |
261 @SYMTestExpectedResults |
279 The call to Image() should panic with GDI 4. |
262 The call to Image() should panic with FBSCLI 31. |
280 */ |
263 */ |
281 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedImage() |
264 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedImage() |
282 { |
265 { |
283 INFO_PRINTF1(_L("Ensure that Image() operation applied on iterator which has been closed will panic")); |
266 INFO_PRINTF1(_L("Ensure that Image() operation applied on iterator which has been closed will panic")); |
284 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0656")); |
267 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0656")); |
301 i. Open the glyph data iterator. |
284 i. Open the glyph data iterator. |
302 ii. Close the glyph data iterator. |
285 ii. Close the glyph data iterator. |
303 iii. Call Metrics() on an RFbsGlyphDataIterator instance which has been closed. |
286 iii. Call Metrics() on an RFbsGlyphDataIterator instance which has been closed. |
304 |
287 |
305 @SYMTestExpectedResults |
288 @SYMTestExpectedResults |
306 The call to Metrics() should panic with GDI 4. |
289 The call to Metrics() should panic with FBSCLI 31. |
307 */ |
290 */ |
308 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedMetrics() |
291 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedMetrics() |
309 { |
292 { |
310 INFO_PRINTF1(_L("Ensure that Metrics()operation applied on iterator which has been closed will panic")); |
293 INFO_PRINTF1(_L("Ensure that Metrics()operation applied on iterator which has been closed will panic")); |
311 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0657")); |
294 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0657")); |
328 i. Open the glyph data iterator. |
311 i. Open the glyph data iterator. |
329 ii. Close the glyph data iterator. |
312 ii. Close the glyph data iterator. |
330 iii. Call GlyphCode() on an RFbsGlyphDataIterator instance which has been closed. |
313 iii. Call GlyphCode() on an RFbsGlyphDataIterator instance which has been closed. |
331 |
314 |
332 @SYMTestExpectedResults |
315 @SYMTestExpectedResults |
333 The call to GlyphCode() should panic with GDI 4. |
316 The call to GlyphCode() should panic with FBSCLI 31. |
334 */ |
317 */ |
335 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedGlyphCode() |
318 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedGlyphCode() |
336 { |
319 { |
337 INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on iterator which has been closed will panic")); |
320 INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on iterator which has been closed will panic")); |
338 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0658")); |
321 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0658")); |