|
1 // Copyright (c) 2009-2010 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 @internalComponent - Internal Symbian test code |
|
19 */ |
|
20 |
|
21 #include <graphics/fbsglyphmetricsarray.h> |
|
22 #include <graphics/fbsglyphdataiterator.h> |
|
23 #include "tfbsglyphdatapanic.h" |
|
24 |
|
25 _LIT(KTypefaceName, "DejaVu Sans Condensed"); |
|
26 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 |
|
49 CTFbsGlyphDataPanic::CTFbsGlyphDataPanic(CTestStep* aStep): |
|
50 CTGraphicsBase(aStep) |
|
51 { |
|
52 } |
|
53 |
|
54 CTFbsGlyphDataPanic::~CTFbsGlyphDataPanic() |
|
55 { |
|
56 iSgDriver.Close(); |
|
57 if (iTs) |
|
58 { |
|
59 iTs->ReleaseFont(iFont); |
|
60 delete iTs; |
|
61 } |
|
62 } |
|
63 |
|
64 void CTFbsGlyphDataPanic::ConstructL() |
|
65 { |
|
66 User::LeaveIfNull(iFbs = RFbsSession::GetSession()); |
|
67 User::LeaveIfNull(iTs = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL)); |
|
68 User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont, TFontSpec(KTypefaceName, 15))); |
|
69 User::LeaveIfError(iSgDriver.Open()); |
|
70 |
|
71 //initialize the array with ASCII characters from 0020 to 007F |
|
72 iGlyphCodes = new(ELeave) TUint[KNumGlyphCodes]; |
|
73 for (TInt i = 0; i < KNumGlyphCodes; ++i) |
|
74 { |
|
75 TUint asciiCode = i+0x20; |
|
76 iGlyphCodes[i] = DejaVuASCIIToGlyphCode[asciiCode]; |
|
77 } |
|
78 } |
|
79 |
|
80 void CTFbsGlyphDataPanic::RunTestCaseL(TInt /*aCurTestCase*/) |
|
81 { |
|
82 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
83 TInt testCase = -1; |
|
84 _LIT(KCaseNumber, "CaseNumber"); |
|
85 TEST(iStep->GetIntFromConfig(iStep->ConfigSection(), KCaseNumber, testCase)); |
|
86 |
|
87 switch(testCase) |
|
88 { |
|
89 case 1: |
|
90 TestGlyphDataIteratorNotInitializedNext(); |
|
91 break; |
|
92 case 2: |
|
93 TestGlyphDataIteratorNotInitializedImage(); |
|
94 break; |
|
95 case 3: |
|
96 TestGlyphDataIteratorNotInitializedMetrics(); |
|
97 break; |
|
98 case 4: |
|
99 TestGlyphDataIteratorNotInitializedGlyphCode(); |
|
100 break; |
|
101 case 5: |
|
102 TestGlyphDataIteratorClosedNext(); |
|
103 break; |
|
104 case 6: |
|
105 TestGlyphDataIteratorClosedImage(); |
|
106 break; |
|
107 case 7: |
|
108 TestGlyphDataIteratorClosedMetrics(); |
|
109 break; |
|
110 case 8: |
|
111 TestGlyphDataIteratorClosedGlyphCode(); |
|
112 break; |
|
113 case 9: |
|
114 TestGlyphDataIteratorDiscardUsedFont(); |
|
115 break; |
|
116 case 10: |
|
117 TestGlyphMetricsArrayIndexNegative(); |
|
118 break; |
|
119 case 11: |
|
120 TestGlyphMetricsArrayIndexTooHigh(); |
|
121 break; |
|
122 case 12: |
|
123 TestGlyphDataIteratorOpenFailed(); |
|
124 break; |
|
125 default: |
|
126 break; |
|
127 } |
|
128 TEST(EFalse); // shouldn't reach this point as the test will panic at the end of each test case function |
|
129 |
|
130 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
131 ((CTFbsGlyphDataPanicStep*)iStep)->CloseTMSGraphicsStep(); |
|
132 TestComplete(); |
|
133 ((CTFbsGlyphDataPanicStep*)iStep)->RecordTestResultL(); |
|
134 } |
|
135 |
|
136 /** |
|
137 @SYMTestCaseID GRAPHICS-FBSERV-0651 |
|
138 @SYMTestPriority High |
|
139 @SYMTestType UT |
|
140 @SYMTestStatus Implemented |
|
141 @SYMPREQ PREQ2678 |
|
142 |
|
143 @SYMTestCaseDesc |
|
144 To ensure that calling Next() on an unopened iterator will panic. |
|
145 |
|
146 @SYMTestActions |
|
147 Call Next() on an RFbsGlyphDataIterator instance without opening it. |
|
148 |
|
149 @SYMTestExpectedResults |
|
150 The call to Next() should panic with GDI 4. |
|
151 */ |
|
152 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedNext() |
|
153 { |
|
154 INFO_PRINTF1(_L("Ensure that Next() operation applied on null iterator will panic")); |
|
155 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0651")); |
|
156 RFbsGlyphDataIterator iter; |
|
157 iter.Next(); //expect to panic here |
|
158 } |
|
159 |
|
160 /** |
|
161 @SYMTestCaseID GRAPHICS-FBSERV-0652 |
|
162 @SYMTestPriority High |
|
163 @SYMTestType UT |
|
164 @SYMTestStatus Implemented |
|
165 @SYMPREQ PREQ2678 |
|
166 |
|
167 @SYMTestCaseDesc |
|
168 To ensure that Image() function applied on an unopened iterator will panic. |
|
169 |
|
170 @SYMTestActions |
|
171 Call Image() on an RFbsGlyphDataIterator instance without opening it. |
|
172 |
|
173 @SYMTestExpectedResults |
|
174 The call to Image() should panic with GDI 4. |
|
175 */ |
|
176 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedImage() |
|
177 { |
|
178 INFO_PRINTF1(_L("Ensure that Image() operation applied on null iterator will panic")); |
|
179 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0652")); |
|
180 RFbsGlyphDataIterator iter; |
|
181 iter.Image(); //expect to panic here |
|
182 } |
|
183 |
|
184 /** |
|
185 @SYMTestCaseID GRAPHICS-FBSERV-0653 |
|
186 @SYMTestPriority High |
|
187 @SYMTestType UT |
|
188 @SYMTestStatus Implemented |
|
189 @SYMPREQ PREQ2678 |
|
190 |
|
191 @SYMTestCaseDesc |
|
192 To ensure that Metrics() function applied on null iterator will panic. |
|
193 |
|
194 @SYMTestActions |
|
195 Call Metrics() on an RFbsGlyphDataIterator instance without opening it. |
|
196 |
|
197 @SYMTestExpectedResults |
|
198 The call to Metrics() should panic with GDI 4. |
|
199 */ |
|
200 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedMetrics() |
|
201 { |
|
202 INFO_PRINTF1(_L("Ensure that Metrics() operation applied on null iterator will panic")); |
|
203 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0653")); |
|
204 RFbsGlyphDataIterator iter; |
|
205 iter.Metrics(); //expect to panic here |
|
206 } |
|
207 |
|
208 /** |
|
209 @SYMTestCaseID GRAPHICS-FBSERV-0654 |
|
210 @SYMTestPriority High |
|
211 @SYMTestType UT |
|
212 @SYMTestStatus Implemented |
|
213 @SYMPREQ PREQ2678 |
|
214 |
|
215 @SYMTestCaseDesc |
|
216 To ensure that calling GlyphCode() on an unopened iterator will panic. |
|
217 |
|
218 @SYMTestActions |
|
219 Call GlyphCode() on an RFbsGlyphDataIterator instance without opening it. |
|
220 |
|
221 @SYMTestExpectedResults |
|
222 The call to GlyphCode() should panic with GDI 4. |
|
223 */ |
|
224 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedGlyphCode() |
|
225 { |
|
226 INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on null iterator will panic")); |
|
227 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0654")); |
|
228 RFbsGlyphDataIterator iter; |
|
229 iter.GlyphCode(); //expect to panic here |
|
230 } |
|
231 |
|
232 /** |
|
233 @SYMTestCaseID GRAPHICS-FBSERV-0655 |
|
234 @SYMTestPriority High |
|
235 @SYMTestType UT |
|
236 @SYMTestStatus Implemented |
|
237 @SYMPREQ PREQ2678 |
|
238 |
|
239 @SYMTestCaseDesc |
|
240 To ensure that calling Next() on an iterator which has been closed will panic. |
|
241 |
|
242 @SYMTestActions |
|
243 i. Open the glyph data iterator with 1 glyph code. |
|
244 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. |
|
246 |
|
247 @SYMTestExpectedResults |
|
248 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. |
|
250 */ |
|
251 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedNext() |
|
252 { |
|
253 INFO_PRINTF1(_L("Ensure that Next() operation applied on iterator which has been closed will panic")); |
|
254 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0655")); |
|
255 RFbsGlyphDataIterator iter; |
|
256 TESTNOERROR(iter.Open(*iFont, iGlyphCodes, 1)); |
|
257 TInt iterErr = iter.Next(); |
|
258 TESTE(iterErr == KErrNotFound, iterErr); |
|
259 iter.Close(); |
|
260 iter.Next(); //expect to panic here |
|
261 } |
|
262 |
|
263 /** |
|
264 @SYMTestCaseID GRAPHICS-FBSERV-0656 |
|
265 @SYMTestPriority High |
|
266 @SYMTestType UT |
|
267 @SYMTestStatus Implemented |
|
268 @SYMPREQ PREQ2678 |
|
269 |
|
270 @SYMTestCaseDesc |
|
271 To ensure that calling Image() on an iterator which has been closed will panic. |
|
272 |
|
273 @SYMTestActions |
|
274 i. Open the glyph data iterator. |
|
275 ii. Close the glyph data iterator. |
|
276 iii. Call Image() on an RFbsGlyphDataIterator instance which has been closed. |
|
277 |
|
278 @SYMTestExpectedResults |
|
279 The call to Image() should panic with GDI 4. |
|
280 */ |
|
281 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedImage() |
|
282 { |
|
283 INFO_PRINTF1(_L("Ensure that Image() operation applied on iterator which has been closed will panic")); |
|
284 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0656")); |
|
285 RFbsGlyphDataIterator iter; |
|
286 OpenAndCloseIterator(iter); |
|
287 iter.Image(); //expect to panic here |
|
288 } |
|
289 |
|
290 /** |
|
291 @SYMTestCaseID GRAPHICS-FBSERV-0657 |
|
292 @SYMTestPriority High |
|
293 @SYMTestType UT |
|
294 @SYMTestStatus Implemented |
|
295 @SYMPREQ PREQ2678 |
|
296 |
|
297 @SYMTestCaseDesc |
|
298 To ensure that calling Metrics() on an iterator which has been closed will panic. |
|
299 |
|
300 @SYMTestActions |
|
301 i. Open the glyph data iterator. |
|
302 ii. Close the glyph data iterator. |
|
303 iii. Call Metrics() on an RFbsGlyphDataIterator instance which has been closed. |
|
304 |
|
305 @SYMTestExpectedResults |
|
306 The call to Metrics() should panic with GDI 4. |
|
307 */ |
|
308 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedMetrics() |
|
309 { |
|
310 INFO_PRINTF1(_L("Ensure that Metrics()operation applied on iterator which has been closed will panic")); |
|
311 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0657")); |
|
312 RFbsGlyphDataIterator iter; |
|
313 OpenAndCloseIterator(iter); |
|
314 iter.Metrics(); //expect to panic here |
|
315 } |
|
316 |
|
317 /** |
|
318 @SYMTestCaseID GRAPHICS-FBSERV-0658 |
|
319 @SYMTestPriority High |
|
320 @SYMTestType UT |
|
321 @SYMTestStatus In development |
|
322 @SYMPREQ PREQ2678 |
|
323 |
|
324 @SYMTestCaseDesc |
|
325 To ensure that calling GlyphCode() on an iterator which has been closed will panic. |
|
326 |
|
327 @SYMTestActions |
|
328 i. Open the glyph data iterator. |
|
329 ii. Close the glyph data iterator. |
|
330 iii. Call GlyphCode() on an RFbsGlyphDataIterator instance which has been closed. |
|
331 |
|
332 @SYMTestExpectedResults |
|
333 The call to GlyphCode() should panic with GDI 4. |
|
334 */ |
|
335 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedGlyphCode() |
|
336 { |
|
337 INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on iterator which has been closed will panic")); |
|
338 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0658")); |
|
339 RFbsGlyphDataIterator iter; |
|
340 OpenAndCloseIterator(iter); |
|
341 iter.GlyphCode(); //expect to panic here |
|
342 } |
|
343 |
|
344 // the function opens and then closes an iterator |
|
345 void CTFbsGlyphDataPanic::OpenAndCloseIterator(RFbsGlyphDataIterator& aIterator) |
|
346 { |
|
347 TESTNOERROR(aIterator.Open(*iFont, iGlyphCodes, 1)); |
|
348 aIterator.Close(); |
|
349 } |
|
350 |
|
351 /** |
|
352 @SYMTestCaseID GRAPHICS-FBSERV-0647 |
|
353 @SYMTestPriority High |
|
354 @SYMTestType UT |
|
355 @SYMTestStatus Implemented |
|
356 @SYMPREQ PREQ2678 |
|
357 |
|
358 @SYMTestCaseDesc |
|
359 To ensure that attempting to use an invalid Font handle will cause a panic when iterating through an RFbsGlyphDataIterator. |
|
360 |
|
361 @SYMTestActions |
|
362 i. Open the glyph data iterator. |
|
363 ii. Release the font associated with the iterator. |
|
364 iii. Attempt to use invalid Font handle by iterating through the iterator. |
|
365 |
|
366 @SYMTestExpectedResults |
|
367 The call to Next() after the associated Font has been released should cause panic FBSERV -8 when the invalid Font handle is passed to FBServ. |
|
368 */ |
|
369 void CTFbsGlyphDataPanic::TestGlyphDataIteratorDiscardUsedFont() |
|
370 { |
|
371 INFO_PRINTF1(_L("Ensure that attempting to use an invalid Font handle will cause a panic when iterating through an RFbsGlyphDataIterator")); |
|
372 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0647")); |
|
373 |
|
374 RFbsGlyphDataIterator iter; |
|
375 TESTNOERROR(iter.Open(*iFont, iGlyphCodes, KNumGlyphCodes)); |
|
376 iTs->ReleaseFont(iFont); |
|
377 |
|
378 for (TInt i = 0; i < KNumGlyphCodes; i++) |
|
379 { |
|
380 //should panic when attempt is made to use invalid Font handle |
|
381 iter.Next(); |
|
382 } |
|
383 |
|
384 iter.Close(); //shouldn't reach this line. If for some reason the code doesn't panic test should fail. |
|
385 TEST(EFalse); |
|
386 } |
|
387 |
|
388 |
|
389 /** |
|
390 @SYMTestCaseID GRAPHICS-FBSERV-0648 |
|
391 @SYMTestPriority High |
|
392 @SYMTestType UT |
|
393 @SYMTestStatus Implemented |
|
394 @SYMPREQ PREQ2678 |
|
395 |
|
396 @SYMTestCaseDesc |
|
397 To ensure that accessing the glyph metrics entry with negative index will cause a panic. |
|
398 |
|
399 @SYMTestActions |
|
400 i. Retrieve glyph metrics array. |
|
401 ii. Try to access glyph metrics entry with a negative index. |
|
402 |
|
403 @SYMTestExpectedResults |
|
404 Should panic with GDI 5. |
|
405 */ |
|
406 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexNegative() |
|
407 { |
|
408 INFO_PRINTF1(_L("Ensure that accessing the glyph metrics entry with negative index will cause a panic")); |
|
409 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0648")); |
|
410 RFbsGlyphMetricsArray glyphMetricsArray; |
|
411 |
|
412 // Retrieve list of metrics |
|
413 TESTNOERROR(glyphMetricsArray.Get(*iFont, iGlyphCodes, 2)); |
|
414 TEST(2 == glyphMetricsArray.Count()); |
|
415 glyphMetricsArray[-1]; |
|
416 } |
|
417 |
|
418 /** |
|
419 @SYMTestCaseID GRAPHICS-FBSERV-0649 |
|
420 @SYMTestPriority High |
|
421 @SYMTestType UT |
|
422 @SYMTestStatus Implemented |
|
423 @SYMPREQ PREQ2678 |
|
424 |
|
425 @SYMTestCaseDesc |
|
426 To ensure that accessing the glyph metrics entry with an index greater than number |
|
427 of elements in array will cause a panic. |
|
428 |
|
429 @SYMTestActions |
|
430 i. Retrieve a glyph metrics array with total number of elements equals 2 |
|
431 ii. Try to access glyph metrics entry with index equals 2. |
|
432 |
|
433 @SYMTestExpectedResults |
|
434 Should panic with GDI 5. |
|
435 */ |
|
436 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexTooHigh() |
|
437 { |
|
438 INFO_PRINTF1(_L("Ensure that accessing the glyph metrics entry with index greater than number of elemnets in array will cause a panic")); |
|
439 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0649")); |
|
440 RFbsGlyphMetricsArray glyphMetricsArray; |
|
441 |
|
442 // Retrieve list of metrics |
|
443 TESTNOERROR(glyphMetricsArray.Get(*iFont, iGlyphCodes, 2)); |
|
444 TEST(2 == glyphMetricsArray.Count()); |
|
445 glyphMetricsArray[2]; //expect to panic here as index varies 0..1 |
|
446 } |
|
447 |
|
448 /** |
|
449 @SYMTestCaseID GRAPHICS-FBSERV-0667 |
|
450 @SYMTestPriority High |
|
451 @SYMTestType UT |
|
452 @SYMTestStatus Implemented |
|
453 @SYMPREQ PREQ2678 |
|
454 |
|
455 @SYMTestCaseDesc |
|
456 To ensure that if RFbsGlyphDataIterator::Open() fails, it is still in the closed state |
|
457 and cannot be used. |
|
458 |
|
459 @SYMTestActions |
|
460 i. Open an RFbsGlyphDataIterator on a font. |
|
461 ii. Attempt to open a second RFbsGlyphDataIterator on the same font. |
|
462 ii. Attempt to use the properties of the iterator. |
|
463 |
|
464 @SYMTestExpectedResults |
|
465 The call to GlyphCode() should panic with FBSCLI 31 since the iterator should be in a closed state. |
|
466 */ |
|
467 void CTFbsGlyphDataPanic::TestGlyphDataIteratorOpenFailed() |
|
468 { |
|
469 INFO_PRINTF1(_L("Ensure that if RFbsGlyphDataIterator::Open() fails, it is still in the closed state and cannot be used")); |
|
470 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0667")); |
|
471 |
|
472 CFbsFont* bitmapFont = NULL; |
|
473 TInt err = iTs->GetNearestFontToDesignHeightInPixels((CFont*&)bitmapFont, TFontSpec(_L("Digital"), 14)); |
|
474 TESTNOERROR(err); |
|
475 TEST(!bitmapFont->IsOpenFont()); |
|
476 |
|
477 RFbsGlyphDataIterator iter; |
|
478 err = iter.Open(*bitmapFont, iGlyphCodes, 2); |
|
479 TEST(err == KErrNotSupported); |
|
480 |
|
481 iter.GlyphCode(); // Should panic here as iter should be closed. |
|
482 TEST(EFalse); //shouldn't reach this line. If for some reason the code doesn't panic test should fail. |
|
483 |
|
484 } |
|
485 //-------------- |
|
486 __CONSTRUCT_STEP__(FbsGlyphDataPanic) |
|
487 |