fbs/fontandbitmapserver/tfbs/TBITMAP.CPP
branchRCL_3
changeset 11 fed1595b188e
parent 0 5d03bc08d59c
equal deleted inserted replaced
0:5d03bc08d59c 11:fed1595b188e
   434 	case 45:
   434 	case 45:
   435 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0618"));
   435 		((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0618"));
   436 		TestBitmapWhiteFillL();
   436 		TestBitmapWhiteFillL();
   437 		break;
   437 		break;
   438 	case 46:
   438 	case 46:
       
   439 #ifdef _DEBUG
       
   440 	    ((CTBitmapStep*)iStep)->SetTestStepID(_L("GRAPHICS-FBSERV-0661"));
       
   441 	    TestBitmapUtilWithUnsupportedBitmaps();
       
   442 #endif
       
   443         break;
       
   444 	case 47:
   439 		((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   445 		((CTBitmapStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   440 		((CTBitmapStep*)iStep)->CloseTMSGraphicsStep();
   446 		((CTBitmapStep*)iStep)->CloseTMSGraphicsStep();
   441 		TestComplete();
   447 		TestComplete();
   442 		break;
   448 		break;
   443 	default:
   449 	default:
  5653 	bmp->Reset();
  5659 	bmp->Reset();
  5654 
  5660 
  5655 	CleanupStack::PopAndDestroy(bmp);
  5661 	CleanupStack::PopAndDestroy(bmp);
  5656 	}
  5662 	}
  5657 
  5663 
       
  5664 #ifdef _DEBUG
       
  5665 /*
       
  5666  * Creates an extended bitmap and it tries to use it with TBitmapUtil, which should cause a panic
       
  5667  */
       
  5668 LOCAL_C void DoBitmapUtilWithExtendedBitmapThreadL()
       
  5669     {  
       
  5670     const TUint8 KTestData[]        = "Extended bitmap test data 123456";
       
  5671     const TInt KTestDataSize        = sizeof(KTestData);
       
  5672     const TSize KSizeInPixels       = TSize(50,50);
       
  5673     const TDisplayMode KDisplayMode = EColor64K;
       
  5674 
       
  5675     CFbsBitmap* bmp = new(ELeave)CFbsBitmap;
       
  5676     CleanupStack::PushL(bmp);
       
  5677      
       
  5678     const TUid KUidTestExtendedBitmap   = TUid::Uid(0xFFFFFFFF);
       
  5679     User::LeaveIfError(bmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KUidTestExtendedBitmap, KTestData, KTestDataSize));
       
  5680      
       
  5681     TBitmapUtil util(bmp); // this will cause a panic
       
  5682      
       
  5683     CleanupStack::PopAndDestroy(bmp);
       
  5684     }
       
  5685 
       
  5686 /*
       
  5687  * Creates a compressed bitmap and it tries to use it with TBitmapUtil, which should cause a panic
       
  5688  */
       
  5689 LOCAL_C void DoBitmapUtilWithCompressedBitmapThreadL()
       
  5690     {
       
  5691     CFbsBitmap*  bmp = new (ELeave) CFbsBitmap;
       
  5692     CleanupStack::PushL(bmp);
       
  5693     bmp->Load(KRamBitmap);
       
  5694     User::LeaveIfError(bmp->Compress());
       
  5695     if(!bmp->IsCompressedInRAM())
       
  5696         {
       
  5697         User::Leave(KErrArgument);
       
  5698         }
       
  5699      
       
  5700     TBitmapUtil util(bmp); // this will cause a panic
       
  5701      
       
  5702     CleanupStack::PopAndDestroy(bmp);
       
  5703     }
       
  5704 
       
  5705 typedef void (*TFunctionPtr)();
       
  5706 
       
  5707 LOCAL_C TInt BitmapUtilWithUnsupportedBitmapThreadFunc(TAny* aFunctionPtr)
       
  5708     {
       
  5709     TInt ret = RFbsSession::Connect();
       
  5710     if(ret != KErrNone)
       
  5711         {
       
  5712         return ret;
       
  5713         }
       
  5714     
       
  5715     CTrapCleanup* trap = CTrapCleanup::New();
       
  5716     if (!trap)
       
  5717          {
       
  5718          RFbsSession::Disconnect();
       
  5719          return KErrNoMemory;
       
  5720          }
       
  5721     
       
  5722     TRAP(ret, ((TFunctionPtr)aFunctionPtr)()); // this function can leave
       
  5723     
       
  5724     delete trap;
       
  5725     RFbsSession::Disconnect();
       
  5726     
       
  5727     return ret;
       
  5728     }
       
  5729 /*
       
  5730  * Creates a thread, and the test scenario for GRAPHICS-FBSERV-0661 is run in aThreadFunction, which 
       
  5731  * causes a panic. Checks if the thread has been terminated with panic with correct category and panic code.
       
  5732  */
       
  5733 void CTBitmap::TestBitmapUtilWithUnsupportedBitmap(const TDesC& aThreadName, TAny* aFunctionPtr)
       
  5734     {
       
  5735     RThread thread;
       
  5736     TInt ret = thread.Create(aThreadName, BitmapUtilWithUnsupportedBitmapThreadFunc, KDefaultStackSize, 0x2000, 0x2000, aFunctionPtr);
       
  5737     TEST(ret == KErrNone);
       
  5738     TRequestStatus status;
       
  5739     thread.Logon(status);
       
  5740     thread.Resume();
       
  5741     User::WaitForRequest(status);
       
  5742     TExitType exitType = thread.ExitType();
       
  5743     TExitCategoryName exitCategory = thread.ExitCategory();
       
  5744     TInt exitReason = thread.ExitReason();
       
  5745     TEST(exitType == EExitPanic);
       
  5746     TEST(exitCategory == KFBSERVClientPanicCategory);
       
  5747     TEST(exitReason == EFbsPanicInvalidBitmapType);
       
  5748     thread.Close();   
       
  5749     }
       
  5750 
       
  5751 /**
       
  5752 @SYMTestCaseID          GRAPHICS-FBSERV-0661
       
  5753 
       
  5754 @SYMTestCaseDesc        Test the use of TBitmapUtil with extended and compressed bitmaps. 
       
  5755                         NOTE: this is a debug only test.
       
  5756 
       
  5757 @SYMTestStatus          Implemented
       
  5758 
       
  5759 @SYMTestPriority        High
       
  5760 
       
  5761 @SYMTestActions         Create extended bitmap, and TBitmapUtil to process it. 
       
  5762                         Create bitmap and compress it,and TBitmapUtil to process it. 
       
  5763 
       
  5764 @SYMTestExpectedResults Panic FBSCLI 29
       
  5765 */
       
  5766 void CTBitmap::TestBitmapUtilWithUnsupportedBitmaps()
       
  5767     {
       
  5768     INFO_PRINTF1(_L("Test TBitmapUtil with unsupported bitmaps"));
       
  5769     
       
  5770     // extended bitmap
       
  5771     TestBitmapUtilWithUnsupportedBitmap(_L("BitmapUtilWithExtentedBitmapThread"), (TAny*)&DoBitmapUtilWithExtendedBitmapThreadL);
       
  5772     
       
  5773     // compressed bitmap
       
  5774     TestBitmapUtilWithUnsupportedBitmap(_L("BitmapUtilWithCompressedBitmapThread"), (TAny*)&DoBitmapUtilWithCompressedBitmapThreadL);  
       
  5775     }
       
  5776 #endif //_DEBUG
       
  5777 
  5658 //--------------
  5778 //--------------
  5659 __CONSTRUCT_STEP__(Bitmap)
  5779 __CONSTRUCT_STEP__(Bitmap)
  5660 
  5780 
  5661 void CTBitmapStep::TestSetupL()
  5781 void CTBitmapStep::TestSetupL()
  5662 	{
  5782 	{