Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 @internalComponent - Internal Symbian test code
21 #include <test/graphicsfontutils.h>
22 #include <graphics/fbsglyphmetricsarray.h>
23 #include <graphics/fbsglyphdataiterator.h>
24 #include "tfbsglyphdatapanic.h"
26 _LIT(KTypefaceName, "DejaVu Sans Condensed");
27 const TInt KNumGlyphCodes = 96;
29 CTFbsGlyphDataPanic::CTFbsGlyphDataPanic(CTestStep* aStep):
34 CTFbsGlyphDataPanic::~CTFbsGlyphDataPanic()
39 iTs->ReleaseFont(iFont);
44 void CTFbsGlyphDataPanic::ConstructL()
46 User::LeaveIfNull(iFbs = RFbsSession::GetSession());
47 User::LeaveIfNull(iTs = (CFbsTypefaceStore*)CFbsTypefaceStore::NewL(NULL));
48 User::LeaveIfError(iTs->GetNearestFontToDesignHeightInPixels((CFont*&)iFont, TFontSpec(KTypefaceName, 15)));
49 User::LeaveIfError(iSgDriver.Open());
51 //initialize the array with ASCII characters from 0020 to 007F
52 CCharCodeConverter* converter = CCharCodeConverter::NewLC();
53 converter->UseFontL(iFont);
54 iGlyphCodes = new(ELeave) TUint[KNumGlyphCodes];
55 for (TInt i = 0; i < KNumGlyphCodes; ++i)
57 TUint asciiCode = i + 0x20;
58 iGlyphCodes[i] = converter->GlyphCodeL(asciiCode);
60 CleanupStack::PopAndDestroy(1); // converter
63 void CTFbsGlyphDataPanic::RunTestCaseL(TInt /*aCurTestCase*/)
65 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
67 _LIT(KCaseNumber, "CaseNumber");
68 TEST(iStep->GetIntFromConfig(iStep->ConfigSection(), KCaseNumber, testCase));
73 TestGlyphDataIteratorNotInitializedNext();
76 TestGlyphDataIteratorNotInitializedImage();
79 TestGlyphDataIteratorNotInitializedMetrics();
82 TestGlyphDataIteratorNotInitializedGlyphCode();
85 TestGlyphDataIteratorClosedNext();
88 TestGlyphDataIteratorClosedImage();
91 TestGlyphDataIteratorClosedMetrics();
94 TestGlyphDataIteratorClosedGlyphCode();
97 TestGlyphDataIteratorDiscardUsedFont();
100 TestGlyphMetricsArrayIndexNegative();
103 TestGlyphMetricsArrayIndexTooHigh();
106 TestGlyphDataIteratorOpenFailed();
111 TEST(EFalse); // shouldn't reach this point as the test will panic at the end of each test case function
113 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
114 ((CTFbsGlyphDataPanicStep*)iStep)->CloseTMSGraphicsStep();
116 ((CTFbsGlyphDataPanicStep*)iStep)->RecordTestResultL();
120 @SYMTestCaseID GRAPHICS-FBSERV-0651
121 @SYMTestPriority High
123 @SYMTestStatus Implemented
127 To ensure that calling Next() on an unopened iterator will panic.
130 Call Next() on an RFbsGlyphDataIterator instance without opening it.
132 @SYMTestExpectedResults
133 The call to Next() should panic with FBSCLI 31.
135 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedNext()
137 INFO_PRINTF1(_L("Ensure that Next() operation applied on null iterator will panic"));
138 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0651"));
139 RFbsGlyphDataIterator iter;
140 iter.Next(); //expect to panic here
144 @SYMTestCaseID GRAPHICS-FBSERV-0652
145 @SYMTestPriority High
147 @SYMTestStatus Implemented
151 To ensure that Image() function applied on an unopened iterator will panic.
154 Call Image() on an RFbsGlyphDataIterator instance without opening it.
156 @SYMTestExpectedResults
157 The call to Image() should panic with FBSCLI 31.
159 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedImage()
161 INFO_PRINTF1(_L("Ensure that Image() operation applied on null iterator will panic"));
162 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0652"));
163 RFbsGlyphDataIterator iter;
164 iter.Image(); //expect to panic here
168 @SYMTestCaseID GRAPHICS-FBSERV-0653
169 @SYMTestPriority High
171 @SYMTestStatus Implemented
175 To ensure that Metrics() function applied on null iterator will panic.
178 Call Metrics() on an RFbsGlyphDataIterator instance without opening it.
180 @SYMTestExpectedResults
181 The call to Metrics() should panic with FBSCLI 31.
183 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedMetrics()
185 INFO_PRINTF1(_L("Ensure that Metrics() operation applied on null iterator will panic"));
186 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0653"));
187 RFbsGlyphDataIterator iter;
188 iter.Metrics(); //expect to panic here
192 @SYMTestCaseID GRAPHICS-FBSERV-0654
193 @SYMTestPriority High
195 @SYMTestStatus Implemented
199 To ensure that calling GlyphCode() on an unopened iterator will panic.
202 Call GlyphCode() on an RFbsGlyphDataIterator instance without opening it.
204 @SYMTestExpectedResults
205 The call to GlyphCode() should panic with FBSCLI 31.
207 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedGlyphCode()
209 INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on null iterator will panic"));
210 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0654"));
211 RFbsGlyphDataIterator iter;
212 iter.GlyphCode(); //expect to panic here
216 @SYMTestCaseID GRAPHICS-FBSERV-0655
217 @SYMTestPriority High
219 @SYMTestStatus Implemented
223 To ensure that calling Next() on an iterator which has been closed will panic.
226 i. Open the glyph data iterator with 1 glyph code.
227 ii. Call Next() to attempt to move the iterator past the end of the array of glyph codes.
228 iii. Call Close() and repeat ii.
230 @SYMTestExpectedResults
231 The call to Next() should fail with KErrNotFound, signifying the iterator is still open.
232 The final call to Next() should panic with FBSCLI 31.
234 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedNext()
236 INFO_PRINTF1(_L("Ensure that Next() operation applied on iterator which has been closed will panic"));
237 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0655"));
238 RFbsGlyphDataIterator iter;
239 TESTNOERROR(iter.Open(*iFont, iGlyphCodes, 1));
240 TInt iterErr = iter.Next();
241 TESTE(iterErr == KErrNotFound, iterErr);
243 iter.Next(); //expect to panic here
247 @SYMTestCaseID GRAPHICS-FBSERV-0656
248 @SYMTestPriority High
250 @SYMTestStatus Implemented
254 To ensure that calling Image() on an iterator which has been closed will panic.
257 i. Open the glyph data iterator.
258 ii. Close the glyph data iterator.
259 iii. Call Image() on an RFbsGlyphDataIterator instance which has been closed.
261 @SYMTestExpectedResults
262 The call to Image() should panic with FBSCLI 31.
264 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedImage()
266 INFO_PRINTF1(_L("Ensure that Image() operation applied on iterator which has been closed will panic"));
267 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0656"));
268 RFbsGlyphDataIterator iter;
269 OpenAndCloseIterator(iter);
270 iter.Image(); //expect to panic here
274 @SYMTestCaseID GRAPHICS-FBSERV-0657
275 @SYMTestPriority High
277 @SYMTestStatus Implemented
281 To ensure that calling Metrics() on an iterator which has been closed will panic.
284 i. Open the glyph data iterator.
285 ii. Close the glyph data iterator.
286 iii. Call Metrics() on an RFbsGlyphDataIterator instance which has been closed.
288 @SYMTestExpectedResults
289 The call to Metrics() should panic with FBSCLI 31.
291 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedMetrics()
293 INFO_PRINTF1(_L("Ensure that Metrics()operation applied on iterator which has been closed will panic"));
294 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0657"));
295 RFbsGlyphDataIterator iter;
296 OpenAndCloseIterator(iter);
297 iter.Metrics(); //expect to panic here
301 @SYMTestCaseID GRAPHICS-FBSERV-0658
302 @SYMTestPriority High
304 @SYMTestStatus In development
308 To ensure that calling GlyphCode() on an iterator which has been closed will panic.
311 i. Open the glyph data iterator.
312 ii. Close the glyph data iterator.
313 iii. Call GlyphCode() on an RFbsGlyphDataIterator instance which has been closed.
315 @SYMTestExpectedResults
316 The call to GlyphCode() should panic with FBSCLI 31.
318 void CTFbsGlyphDataPanic::TestGlyphDataIteratorClosedGlyphCode()
320 INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on iterator which has been closed will panic"));
321 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0658"));
322 RFbsGlyphDataIterator iter;
323 OpenAndCloseIterator(iter);
324 iter.GlyphCode(); //expect to panic here
327 // the function opens and then closes an iterator
328 void CTFbsGlyphDataPanic::OpenAndCloseIterator(RFbsGlyphDataIterator& aIterator)
330 TESTNOERROR(aIterator.Open(*iFont, iGlyphCodes, 1));
335 @SYMTestCaseID GRAPHICS-FBSERV-0647
336 @SYMTestPriority High
338 @SYMTestStatus Implemented
342 To ensure that attempting to use an invalid Font handle will cause a panic when iterating through an RFbsGlyphDataIterator.
345 i. Open the glyph data iterator.
346 ii. Release the font associated with the iterator.
347 iii. Attempt to use invalid Font handle by iterating through the iterator.
349 @SYMTestExpectedResults
350 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.
352 void CTFbsGlyphDataPanic::TestGlyphDataIteratorDiscardUsedFont()
354 INFO_PRINTF1(_L("Ensure that attempting to use an invalid Font handle will cause a panic when iterating through an RFbsGlyphDataIterator"));
355 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0647"));
357 RFbsGlyphDataIterator iter;
358 TESTNOERROR(iter.Open(*iFont, iGlyphCodes, KNumGlyphCodes));
359 iTs->ReleaseFont(iFont);
361 for (TInt i = 0; i < KNumGlyphCodes; i++)
363 //should panic when attempt is made to use invalid Font handle
367 iter.Close(); //shouldn't reach this line. If for some reason the code doesn't panic test should fail.
373 @SYMTestCaseID GRAPHICS-FBSERV-0648
374 @SYMTestPriority High
376 @SYMTestStatus Implemented
380 To ensure that accessing the glyph metrics entry with negative index will cause a panic.
383 i. Retrieve glyph metrics array.
384 ii. Try to access glyph metrics entry with a negative index.
386 @SYMTestExpectedResults
387 Should panic with FBSCLI 32.
389 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexNegative()
391 INFO_PRINTF1(_L("Ensure that accessing the glyph metrics entry with negative index will cause a panic"));
392 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0648"));
393 RFbsGlyphMetricsArray glyphMetricsArray;
395 // Retrieve list of metrics
396 TESTNOERROR(glyphMetricsArray.Get(*iFont, iGlyphCodes, 2));
397 TEST(2 == glyphMetricsArray.Count());
398 glyphMetricsArray[-1];
402 @SYMTestCaseID GRAPHICS-FBSERV-0649
403 @SYMTestPriority High
405 @SYMTestStatus Implemented
409 To ensure that accessing the glyph metrics entry with an index greater than number
410 of elements in array will cause a panic.
413 i. Retrieve a glyph metrics array with total number of elements equals 2
414 ii. Try to access glyph metrics entry with index equals 2.
416 @SYMTestExpectedResults
417 Should panic with FBSCLI 32.
419 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexTooHigh()
421 INFO_PRINTF1(_L("Ensure that accessing the glyph metrics entry with index greater than number of elemnets in array will cause a panic"));
422 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0649"));
423 RFbsGlyphMetricsArray glyphMetricsArray;
425 // Retrieve list of metrics
426 TESTNOERROR(glyphMetricsArray.Get(*iFont, iGlyphCodes, 2));
427 TEST(2 == glyphMetricsArray.Count());
428 glyphMetricsArray[2]; //expect to panic here as index varies 0..1
432 @SYMTestCaseID GRAPHICS-FBSERV-0667
433 @SYMTestPriority High
435 @SYMTestStatus Implemented
439 To ensure that if RFbsGlyphDataIterator::Open() fails, it is still in the closed state
443 i. Open an RFbsGlyphDataIterator on a font.
444 ii. Attempt to open a second RFbsGlyphDataIterator on the same font.
445 ii. Attempt to use the properties of the iterator.
447 @SYMTestExpectedResults
448 The call to GlyphCode() should panic with FBSCLI 31 since the iterator should be in a closed state.
450 void CTFbsGlyphDataPanic::TestGlyphDataIteratorOpenFailed()
452 INFO_PRINTF1(_L("Ensure that if RFbsGlyphDataIterator::Open() fails, it is still in the closed state and cannot be used"));
453 ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0667"));
455 CFbsFont* bitmapFont = NULL;
456 TInt err = iTs->GetNearestFontToDesignHeightInPixels((CFont*&)bitmapFont, TFontSpec(_L("Digital"), 14));
458 TEST(!bitmapFont->IsOpenFont());
460 RFbsGlyphDataIterator iter;
461 err = iter.Open(*bitmapFont, iGlyphCodes, 2);
462 TEST(err == KErrNotSupported);
464 iter.GlyphCode(); // Should panic here as iter should be closed.
465 TEST(EFalse); //shouldn't reach this line. If for some reason the code doesn't panic test should fail.
469 __CONSTRUCT_STEP__(FbsGlyphDataPanic)