fbs/fontandbitmapserver/tfbs/tfonttableandglyph.cpp
changeset 45 36b2e23a8629
parent 36 01a6848ebfd7
equal deleted inserted replaced
36:01a6848ebfd7 45:36b2e23a8629
   681         }
   681         }
   682     
   682     
   683     implementationArray.ResetAndDestroy();
   683     implementationArray.ResetAndDestroy();
   684     }
   684     }
   685 
   685 
       
   686 /**
       
   687 Worker function that implements the threads executed by SMPAndWDPSafeTest.
       
   688 @leave If a leave occurs, either the test failed to be set-up successfully,
       
   689     or the test itself failed.
       
   690 */
       
   691 static void DoSMPAndWDPSafeTestFunL()
       
   692     {
       
   693     User::LeaveIfError(RFbsSession::Connect());
       
   694     CFbsBitmap* bmp = new (ELeave) CFbsBitmap;
       
   695     CleanupStack::PushL(bmp);
       
   696     User::LeaveIfError(bmp->Create(TSize(100,100), EGray2));
       
   697     CFbsBitmapDevice* bmpDevice = CFbsBitmapDevice::NewL(bmp);
       
   698     CleanupStack::PushL(bmpDevice);
       
   699     CFont* font = NULL;
       
   700     TFontSpec fontSpec(KTestFontFaceName, KFontHeight);
       
   701     User::LeaveIfError(bmpDevice->GetNearestFontToMaxHeightInTwips(font, fontSpec, 0));
       
   702 
       
   703     for(TInt i = 0; i < 100; i++)
       
   704         {
       
   705         RFontTable fontTable;
       
   706         CleanupClosePushL(fontTable);
       
   707         User::LeaveIfError(fontTable.Open(*font, 0x68656164));
       
   708         TUint32* ptr = (TUint32*)fontTable.TableContent();
       
   709         if (!ptr)
       
   710             {
       
   711             User::Leave(KErrGeneral);
       
   712             }
       
   713         CleanupStack::PopAndDestroy(1); // fontTable;
       
   714         }
       
   715     bmpDevice->ReleaseFont(font);
       
   716     CleanupStack::PopAndDestroy(2); // bmpDevice, bmp
       
   717     RFbsSession::Disconnect();
       
   718     }
       
   719 
   686 static TInt SMPAndWDPSafeTestFun(TAny* /*aParam*/)
   720 static TInt SMPAndWDPSafeTestFun(TAny* /*aParam*/)
   687     {
   721     {
   688     CFbsBitmapDevice* device1 = NULL;
   722     CTrapCleanup* trapCleanup = CTrapCleanup::New();
   689     CFont* font;
   723     if (!trapCleanup)
   690     TInt err = 0;
       
   691     CTrapCleanup* trapCleanup=CTrapCleanup::New();
       
   692     
       
   693     err = RFbsSession::Connect();    
       
   694     if(err != KErrNone)
       
   695         User::Panic(_L("FbsSession connection error"), -1);    
       
   696   
       
   697     CFbsBitmap* bmp = NULL;
       
   698     TRAPD(ret1, bmp = new (ELeave) CFbsBitmap);
       
   699     if (bmp == NULL)
       
   700         User::Panic(_L("new CFbsBitmap error"), -1);
       
   701     err = bmp->Create(TSize(100,100),EGray2);
       
   702     if(err != KErrNone)
       
   703             User::Panic(_L("bitmap creation error"), -1);
       
   704     TRAP(err,device1 = CFbsBitmapDevice::NewL(bmp));
       
   705     if(err != KErrNone)
       
   706         User::Panic(_L("fbs device new error"), -1);
       
   707     TFontSpec fontSpec(KTestFontFaceName,KFontHeight); 
       
   708     err = device1->GetNearestFontToMaxHeightInTwips(font,fontSpec,0);  
       
   709     if(err != KErrNone)
       
   710         User::Panic(_L("Get CFont error"), -1);
       
   711     
       
   712     err = KErrNone; 
       
   713     for(TInt i = 0; i < 100; i++)
       
   714     {
       
   715     RFontTable fontTable;
       
   716     err = fontTable.Open(*font, 0x68656164);
       
   717     if (KErrNone != err)
       
   718         {
   724         {
   719         User::Panic(_L("Font table opening failed with error"), err);
   725         return KErrNoMemory;
   720         }
   726         }
   721     TUint32* ptr = (TUint32*)fontTable.TableContent();
   727     TRAPD(err, DoSMPAndWDPSafeTestFunL());
   722     if (ptr == NULL)
       
   723         {
       
   724         User::Panic(_L("Font table content NULL"), -1);
       
   725         }
       
   726     fontTable.Close();
       
   727     }
       
   728 
       
   729     delete device1;
       
   730     delete bmp;
       
   731     delete trapCleanup;
   728     delete trapCleanup;
   732     device1 = NULL;
       
   733     bmp = NULL;
       
   734     return err;
   729     return err;
   735     }
   730     }
   736 
   731 
   737 /**
   732 /**
   738     @SYMTestCaseID    TI18N-GDI-CIT-4090
   733     @SYMTestCaseID    TI18N-GDI-CIT-4090