fbs/fontandbitmapserver/tfbs/tfbsglyphdatapanic.cpp
changeset 136 62bb7c97884c
parent 121 d72fc2aace31
equal deleted inserted replaced
121:d72fc2aace31 136:62bb7c97884c
    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);
   145 
   128 
   146 @SYMTestActions
   129 @SYMTestActions
   147 	Call Next() on an RFbsGlyphDataIterator instance without opening it.
   130 	Call Next() on an RFbsGlyphDataIterator instance without opening it.
   148 
   131 
   149 @SYMTestExpectedResults
   132 @SYMTestExpectedResults
   150 	The call to Next() should panic with GDI 4.
   133 	The call to Next() should panic with FBSCLI 31.
   151 */
   134 */
   152 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedNext()
   135 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedNext()
   153     {
   136     {
   154     INFO_PRINTF1(_L("Ensure that Next() operation applied on null iterator will panic"));
   137     INFO_PRINTF1(_L("Ensure that Next() operation applied on null iterator will panic"));
   155     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0651"));
   138     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0651"));
   169 
   152 
   170 @SYMTestActions
   153 @SYMTestActions
   171 	Call Image() on an RFbsGlyphDataIterator instance without opening it.
   154 	Call Image() on an RFbsGlyphDataIterator instance without opening it.
   172 
   155 
   173 @SYMTestExpectedResults
   156 @SYMTestExpectedResults
   174 	The call to Image() should panic with GDI 4.
   157 	The call to Image() should panic with FBSCLI 31.
   175 */
   158 */
   176 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedImage()
   159 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedImage()
   177     {
   160     {
   178     INFO_PRINTF1(_L("Ensure that Image() operation applied on null iterator will panic"));
   161     INFO_PRINTF1(_L("Ensure that Image() operation applied on null iterator will panic"));
   179     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0652"));
   162     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0652"));
   193 
   176 
   194 @SYMTestActions
   177 @SYMTestActions
   195 	Call Metrics() on an RFbsGlyphDataIterator instance without opening it.
   178 	Call Metrics() on an RFbsGlyphDataIterator instance without opening it.
   196 
   179 
   197 @SYMTestExpectedResults
   180 @SYMTestExpectedResults
   198 	The call to Metrics() should panic with GDI 4.
   181 	The call to Metrics() should panic with FBSCLI 31.
   199 */
   182 */
   200 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedMetrics()
   183 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedMetrics()
   201     {
   184     {
   202     INFO_PRINTF1(_L("Ensure that Metrics() operation applied on null iterator will panic"));
   185     INFO_PRINTF1(_L("Ensure that Metrics() operation applied on null iterator will panic"));
   203     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0653"));
   186     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0653"));
   217 
   200 
   218 @SYMTestActions
   201 @SYMTestActions
   219 	Call GlyphCode() on an RFbsGlyphDataIterator instance without opening it.
   202 	Call GlyphCode() on an RFbsGlyphDataIterator instance without opening it.
   220 
   203 
   221 @SYMTestExpectedResults
   204 @SYMTestExpectedResults
   222 	The call to GlyphCode() should panic with GDI 4.
   205 	The call to GlyphCode() should panic with FBSCLI 31.
   223 */
   206 */
   224 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedGlyphCode()
   207 void CTFbsGlyphDataPanic::TestGlyphDataIteratorNotInitializedGlyphCode()
   225     {
   208     {
   226     INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on null iterator will panic"));
   209     INFO_PRINTF1(_L("Ensure that GlyphCode() operation applied on null iterator will panic"));
   227     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0654"));
   210     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0654"));
   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"));
   399 @SYMTestActions
   382 @SYMTestActions
   400 	i. Retrieve glyph metrics array.
   383 	i. Retrieve glyph metrics array.
   401 	ii. Try to access glyph metrics entry with a negative index.
   384 	ii. Try to access glyph metrics entry with a negative index.
   402 
   385 
   403 @SYMTestExpectedResults
   386 @SYMTestExpectedResults
   404 	Should panic with GDI 5.
   387 	Should panic with FBSCLI 32.
   405 */
   388 */
   406 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexNegative()
   389 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexNegative()
   407     {
   390     {
   408     INFO_PRINTF1(_L("Ensure that accessing the glyph metrics entry with negative index will cause a panic"));
   391     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"));
   392     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0648"));
   429 @SYMTestActions
   412 @SYMTestActions
   430 	i. Retrieve a glyph metrics array with total number of elements equals 2 
   413 	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.
   414 	ii. Try to access glyph metrics entry with index equals 2.
   432 
   415 
   433 @SYMTestExpectedResults
   416 @SYMTestExpectedResults
   434 	Should panic with GDI 5.
   417 	Should panic with FBSCLI 32.
   435 */
   418 */
   436 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexTooHigh()
   419 void CTFbsGlyphDataPanic::TestGlyphMetricsArrayIndexTooHigh()
   437     {
   420     {
   438     INFO_PRINTF1(_L("Ensure that accessing the glyph metrics entry with index greater than number of elemnets in array will cause a panic"));
   421     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"));
   422     ((CTFbsGlyphDataPanicStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0649"));