예제 #1
0
/**
	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0054-0001
  
	@SYMPREQ PGM027
  
	@SYMTestCaseDesc Negative Tests RWsSpriteBase::UpdateMember API. 
   
	@SYMTestPriority 1 
  
	@SYMTestStatus Implemented
   
	@SYMTestActions This test calls RWsPointerCursor::UpdateMember
		
	@SYMTestExpectedResults Should run properly with out any Panics.

 */
void CTTSprite::SpriteUpdateMemberNegTestsL()
	{
	RWsPointerCursor iCursor1;
	
	CFbsBitmap bitmap;
	bitmap.Load(TEST_BITMAP_NAME,0);
		
	RWindow win(TheClient->iWs);
	win.Construct(*TheClient->iGroup->GroupWin(),1);
	win.Activate();

	iCursor1=RWsPointerCursor(TheClient->iWs);
	TSpriteMember member;
	SetUpMember(member);
	member.iBitmap=&bitmap;
	User::LeaveIfError(iCursor1.Construct(0));
	User::LeaveIfError(iCursor1.AppendMember(member));
	User::LeaveIfError(iCursor1.Activate());
	win.SetCustomPointerCursor(iCursor1);
	iCursor1.UpdateMember(-100);
	
	RWsPointerCursor iCursor2;
	bitmap.Load(TEST_NEW_BITMAP_NAME,0);
	iCursor2=RWsPointerCursor(TheClient->iWs);
	User::LeaveIfError(iCursor2.Construct(0));
	User::LeaveIfError(iCursor2.AppendMember(member));
	User::LeaveIfError(iCursor2.Activate());
	win.SetCustomPointerCursor(iCursor2);
	iCursor2.UpdateMember(10000);
	
	iCursor1.Close();
	iCursor2.Close();
	win.Close();
	}
// -----------------------------------------------------------------------------
// Ctestsdkindicators::TestIndiCntnerReplaceIndicatorIconL
// -----------------------------------------------------------------------------
//
TInt CTestSDKIndicators::TestIndiCntnerReplaceIndicatorIconL( CStifItemParser& /*aItem*/ )
    {
    // Print to UI
    _LIT( Ktestsdkindicators, "testsdkindicators" );
    _LIT( KTestIndiCntnerReplaceIndicatorIconL, "In TestIndiCntnerReplaceIndicatorIconL" );
    TestModuleIf().Printf( 0, Ktestsdkindicators, KTestIndiCntnerReplaceIndicatorIconL );
    // Print to log file
    iLog->Log( KTestIndiCntnerReplaceIndicatorIconL );
    
    TInt err = KErrNone;

    TUid Id = { EAknIndicatorEnvelope };
    
    _LIT( KFileName, "z:\\resource\\apps\\avkon2.mbm" );

    CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
    bmp->Load( KFileName, EMbmAvkonQgn_stat_cyphering_on );
    CFbsBitmap* bmpMask = new (ELeave) CFbsBitmap();
    bmpMask->Load( KFileName, EMbmAvkonQgn_stat_cyphering_on_mask );
    
    iIndicatorContn->CreateIndicatorFromResourceL( R_TEST_INDICATOR, 
                CAknIndicatorContainer::EMultiColorIndicator );
    
    iIndicatorContn->ReplaceIndicatorIconL( 
            Id, 
            EAknIndicatorStateOn, 
            CAknIndicatorContainer::ELayoutModeUsual, 
            bmp, bmpMask);
    
    return err;
    }
void CAlfPerfAppAvkonTestCaseBasic::ConstructL( 
        CAlfEnv& aEnv, TInt aCaseId, const TRect& aVisibleArea )
    {
    CAlfPerfAppBaseTestCaseControl::ConstructL( aEnv, aCaseId, aVisibleArea );   
    
    iWinRect = aVisibleArea;
    
    iAvkonControl = new(ELeave) CAvkonTestCoeControl();
    iAvkonControl->ConstructL(iWinRect);

    iAnimTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    
    TFontSpec myFontSpec(_L("Arial"), 3*120);
    CCoeEnv::Static()->ScreenDevice()->GetNearestFontInTwips(iFont, myFontSpec);
    
    // Find my private path
    TFileName pathWithoutDrive;
    TFileName driveAndPath;
    CEikonEnv::Static()->FsSession().PrivatePath( pathWithoutDrive );
    driveAndPath.Copy(CEikonEnv::Static()->EikAppUi()->Application()->AppFullName().Left(2));
    driveAndPath.Append(pathWithoutDrive);
    
    // Create pictures
    iPictureBm = new(ELeave) CFbsBitmap;
    driveAndPath.Append(_L("alfperfapp_test1.mbm"));
    User::LeaveIfError(iPictureBm->Load(driveAndPath));
    iMaskBm = new(ELeave) CFbsBitmap;
    User::LeaveIfError(iMaskBm->Create(iPictureBm->SizeInPixels(), EGray256));
 
    iTestCaseStartTime_ys.UniversalTime();
    iTestCaseFrameCount = 0;
   }
void CUnRegisterView::Draw(const TRect& /* aRect */) const
{
	CWindowGc& gc = SystemGc();
	gc.Clear();

	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
	CleanupStack::PushL(bitmap);

	TBuf<128> path;
	path = CRippleVaultAppUi::ApplicationDriveAndPath();
	path.Append(KLogoMbmFileName);

	User::LeaveIfError(bitmap->Load(path, EMbmLogoLogo));
	TPoint pos(50,60);
	gc.BitBlt(pos, bitmap);	
	CleanupStack::PopAndDestroy();

	const CFont* fontUsed;  
	fontUsed = iEikonEnv->TitleFont();
	gc.UseFont(fontUsed);

	//TPoint pos1(50,30);
	//gc.DrawText(*(iEikonEnv->AllocReadResourceL(R_RIPPLE_VAULT)),pos1);
	TPoint pos2(30,180);
	gc.DrawText(*(iEikonEnv->AllocReadResourceL(R_PURPLEACE_WEB)),pos2);
	
    // Finished using the font
	gc.DiscardFont();

}
예제 #5
0
// ---------------------------------------------------------------------------
// CBCTestButtonCase::CreateIconL
// ---------------------------------------------------------------------------
//
CGulIcon* CBCTestButtonCase::CreateIconL()
    {
    CFbsBitmap *bitmap = new( ELeave ) CFbsBitmap();
    bitmap->Load( AknIconUtils::AvkonIconFileName(), 
                  EMbmAvkonQgn_prop_set_button );
    return CGulIcon::NewL( bitmap );
    }
/**
Loads a bitmap from a file

@param aName the filename of the bitmap to load
@param aIndex the index of the bitmap to load in the file
*/
CFbsBitmap* CTe_graphicsperformanceSuiteStepBase::LoadBitmapL(const TDesC& aName, TInt aIndex)
	{
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
	CleanupStack::PushL(bitmap);
	User::LeaveIfError(bitmap->Load(aName, aIndex));
	CleanupStack::Pop(bitmap);
	return bitmap;
	}
void AknBitmapMirrorUtils::LoadPartialBitmapL(CFbsBitmap* aBitmap, const TDesC& aFileName,TInt32 aId, TRect aRect, TBool aMirrorHorizontally)
    {
    CFbsBitmap* destinationBitmap = aBitmap;
    User::LeaveIfNull(destinationBitmap);

    CFbsBitmap* sourceBitmap = new (ELeave) CFbsBitmap();   
    CleanupStack::PushL(sourceBitmap);   
    User::LeaveIfError(sourceBitmap->Load(aFileName, aId, ETrue));    
    TSize sourceBitmapSize = sourceBitmap->SizeInPixels();
    
    TRect sourceRect = TRect(aRect);
    if (sourceRect == KWholeBitmapRect)
        {
        sourceRect.iTl.iX = 0;
        sourceRect.iTl.iY = 0;
        sourceRect.iBr.iX = sourceBitmapSize.iWidth;
        sourceRect.iBr.iY = sourceBitmapSize.iHeight;
        }
      
    TSize destinationBitmapSize(sourceRect.Width(), sourceRect.Height()); 
    User::LeaveIfError(destinationBitmap->Create(destinationBitmapSize, sourceBitmap->DisplayMode()));

    CFbsBitmapDevice* destinationDevice = CFbsBitmapDevice::NewL( destinationBitmap );
    CleanupStack::PushL(destinationDevice);

    CFbsBitGc* destinationGc;
    User::LeaveIfError( destinationDevice->CreateContext( destinationGc ) );

    if (aMirrorHorizontally)
        {
        TRect sourceBitmapBlittingRect( sourceRect.iTl.iX,sourceRect.iTl.iY,sourceRect.iTl.iX + 1,sourceRect.iBr.iY );  
    
        for ( TInt xPos=destinationBitmapSize.iWidth-1; xPos >= 0; xPos-- )
            {
            destinationGc->BitBlt( TPoint(xPos,0), sourceBitmap, sourceBitmapBlittingRect );
            sourceBitmapBlittingRect.iTl.iX++;
            sourceBitmapBlittingRect.iBr.iX++;
            }
        }
    else
        {
        destinationGc->BitBlt( TPoint(0,0), sourceBitmap, sourceRect );
        }

    delete destinationGc;  
    CleanupStack::PopAndDestroy(2); // sourceBitmap, destinationDevice
    }
예제 #8
0
/**
 * Load svg element.
 */
CFbsBitmap* CFuiTheme::SvgElementL( TInt aElementId )
{
	TFileName svgFile;
	SvgFile( svgFile );
	
    CFbsBitmap* a = new (ELeave)CFbsBitmap();
    User::LeaveIfError( a->Load( svgFile, aElementId ) );
    
    TSize contentSize;
    AknIconUtils::PreserveIconData( a );
    AknIconUtils::GetContentDimensions( a, contentSize );
    AknIconUtils::SetSize( a, contentSize );
    AknIconUtils::DestroyIconData( a );
    	
    iElements.Append( a );
    
    return a;
}
// ---------------------------------------------------------
// CUnRegisterContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CUnRegisterContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
	
	gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(KRgbWhite);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	gc.DrawRect(aRect);

	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap();
	CleanupStack::PushL(bitmap);

	TBuf<128> path;
	path = CRippleVaultAppUi::ApplicationDriveAndPath();
	path.Append(KLogoMbmFileName);

	User::LeaveIfError(bitmap->Load(path, EMbmLogoLogo));
	TPoint pos(50,30);
	gc.BitBlt(pos, bitmap);	
	CleanupStack::PopAndDestroy();
    
    }
예제 #10
0
/**
	@SYMTestCaseID
	GRAPHICS-FBSERV-0512

	@SYMTestCaseDesc
	Creates bitmaps in different ways and checks if memory allocation succeeded 

	@SYMTestActions
	Creates normal size bitmaps, large bitmaps, loads bitmaps, loads shared bitmaps,
	duplicated bitmaps, resizes bitmaps, compresses bitmaps, externalized bitmaps to write store, 
	internalizes bitmaps back again from write store. All ways of creating bitmaps are tested
	against Out Of Memory error conditions	

	@SYMTestExpectedResults
	Test should pass
*/
void CTAlloc::BitmapsL()
	{
	TInt heapMarkCheckFlag;	
	if( !iStep->GetIntFromConfig(KDefaultSectionName, KFbsHeapMarkCheckFlag, heapMarkCheckFlag) )
		{
		INFO_PRINTF1(_L("Error reading ini file"));
		User::Leave(KErrNotFound);
		}
	
	CFbsBitmap iBitmap;
	CFbsBitmap iBitmap2;

	iTestBitmapName = KTestBitmapOnZ;
	TInt ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
	TEST2(ret, KErrNone);

	ret = iBitmap.Create(KLargeSize,EColor256); // Expand server caches
	TEST2(ret, KErrNone);
	iBitmap.Reset();

	TInt count;

// Create bitmap
	INFO_PRINTF1(_L("CFbsBitmap::Create()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}
		ret = iBitmap.Create(KSmallSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMark);
				iFbs->SendCommand(EFbsMessUserMark);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMark);
				iFbs->SendCommand(EFbsMessUserMark);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret=iBitmap.Create(KSmallSize,EGray2);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Create (large)
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Create(KLargeSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Create(KLargeSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Load
	INFO_PRINTF1(_L("CFbsBitmap::Load()\r\n"));
	ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
	TEST2(ret, KErrNone);
	iBitmap.Reset();
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
	}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Load (shared)
	INFO_PRINTF1(_L("CFbsBitmap::Load() - shared \r\n"));
	
	// Do an initial load to ensure the StreamId cache does not get updated whilst OOM testing
	ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
	TEST2(ret, KErrNone);
	iBitmap.Reset();
	
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
		
		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret != KErrNone)
			TEST2(ret, KErrNone);
			
		ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);	
			
		if (ret == KErrNoMemory)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();	
			iBitmap2.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);		
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
		
		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret != KErrNone)
			TEST2(ret, KErrNone);
			
		ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);

		if (ret == KErrNoMemory)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			iBitmap2.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
	}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);
	
	
// Duplicate
	CFbsBitmap bmpalt;
	ret = bmpalt.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Duplicate()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Duplicate(bmpalt.Handle());

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==1);
	ret = bmpalt.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Duplicate(bmpalt.Handle());

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	bmpalt.Reset();
	TEST(iFbs->ResourceCount()==0);

// Resize
	// force fbserv to do a resize. This makes the pile to insert an index in it's array
	// If the array is empty when the tests below are run then the insert will look like a mem leak
	ret=iBitmap.Create(KLargeSize,EColor256);
	iBitmap.Resize(KLargeSizeAlt);
	iBitmap.Reset();
	
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Resize()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Resize(KSmallSizeAlt);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);
	
	
	// force fbserv to do a resize. This makes the pile to insert an index in it's array
	// If the array is empty when the tests below are run then the insert will look like a mem leak
	ret=iBitmap.Create(KLargeSize,EColor256);
	iBitmap.Resize(KLargeSizeAlt);
	iBitmap.Reset();
	
	ret=iBitmap.Create(KLargeSize,EColor256);
	TEST2(ret, KErrNone);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Resize(KLargeSizeAlt);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Compress
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Compress();

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	ret=iBitmap.Create(KLargeSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Compress();

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// WriteStore creation
	RFs fs;
	ret=fs.Connect();
	TEST2(ret, KErrNone);
	CDirectFileStore* writestore=NULL;

	//Construct filename using the thread id to enable concurrent test runs.
	_LIT(KSbmFileName,"c:\\tall_");
	TBuf<36> buf(KSbmFileName);
	TThreadId threadId = RThread().Id();
	TUint64 id = threadId.Id();
	TBuf<20> threadIdBuf;
	threadIdBuf.Num(id);
	buf.Append(threadIdBuf);
	buf.Append(_L(".sbm"));
	
	TRAP(ret,writestore=CDirectFileStore::ReplaceL(fs,buf,EFileStream|EFileWrite));
	TEST2(ret, KErrNone);
	TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
	TRAP(ret,writestore->SetTypeL(uidtype));
	TEST2(ret, KErrNone);

	RStoreWriteStream writestrm;
	TStreamId headerid(0);
	TRAP(ret,headerid=writestrm.CreateL(*writestore));
	TEST2(ret, KErrNone);
	TRAP(ret,writestore->SetRootL(headerid));
	TEST2(ret, KErrNone);

// Externalize
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::ExternalizeL()\r\n"));
	for (count = 1; ; count++)
		{
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
		__UHEAP_MARK;

		TRAP(ret,iBitmap.ExternalizeL(writestrm));

		if (ret == KErrNoMemory)
			{
			__UHEAP_MARKEND;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			__UHEAP_MARKEND;
			break;
			}
		else 
			{
			__UHEAP_MARKEND;
			TEST2(ret, KErrNone);
			}
		}

	__UHEAP_RESET;
	TEST(iFbs->ResourceCount()==0);

// ExternalizeRectangle
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::ExternalizeRectangleL()\r\n"));
	for (count = 1; ; count++)
		{
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
		__UHEAP_MARK;

		TRAP(ret,iBitmap.ExternalizeRectangleL(writestrm,TRect(3,3,7,7)));

		if (ret == KErrNoMemory)
			{
			__UHEAP_MARKEND;
			}
		else if (ret == KErrNone)
			{
			__UHEAP_MARKEND;
			break;
			}
		else 
			{
			__UHEAP_MARKEND;
			TEST2(ret, KErrNone);
			}
		}

	__UHEAP_RESET;
	writestrm.Close();
	delete writestore;
	iBitmap.Reset();
	TEST(iFbs->ResourceCount()==0);

// Internalize
	INFO_PRINTF1(_L("CFbsBitmap::InternalizeL()\r\n"));
	for (count = 1; ; count++)
		{
		// ReadStore creation
		CDirectFileStore* readstore=NULL;
		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
		TEST2(ret, KErrNone);
		RStoreReadStream readstrm;
		headerid=readstore->Root();
		TRAP(ret,readstrm.OpenL(*readstore,headerid));
		TEST2(ret, KErrNone);

		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		TRAP(ret,iBitmap.InternalizeL(readstrm));

		readstrm.Close();
		delete readstore;

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		// ReadStore re-creation
		CDirectFileStore* readstore=NULL;
//		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,_L("c:\\tall.sbm"),EFileStream|EFileRead|EFileShareAny));
		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
		TEST2(ret, KErrNone);
		headerid=readstore->Root();
		RStoreReadStream readstrm;
		TRAP(ret,readstrm.OpenL(*readstore,headerid));
		TEST2(ret, KErrNone);

		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		TRAP(ret,iBitmap.InternalizeL(readstrm));

		readstrm.Close();
		delete readstore;

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	fs.Delete(buf);
	fs.Close();
	}
예제 #11
0
/*
-------------------------------------------------------------------------------
internal icon re-sizer function
-------------------------------------------------------------------------------
*/   
CGulIcon* CYBRecognizer1::GetListIconL(const TDesC& aFileName,TInt aImage,TInt aMask, TSize aSize)
{
	CGulIcon* RetIcon(NULL);
	TBool OkToAdd(EFalse);
	
	CFbsBitmap* MyBitmap = new(ELeave)CFbsBitmap();
	CleanupStack::PushL(MyBitmap);
	CFbsBitmap* MyMask = new(ELeave)CFbsBitmap();
	CleanupStack::PushL(MyMask);
	
	if(KErrNone == MyBitmap->Load(aFileName,aImage))
	{
		if(KErrNone == MyMask->Load(aFileName,aMask))
		{
			OkToAdd = ETrue;
		}
	}
	
	if(OkToAdd)
	{
		TSize ImgSiz = MyBitmap->SizeInPixels();
		if(aSize.iWidth != ImgSiz.iWidth
		|| aSize.iHeight!= ImgSiz.iHeight)
		{
			CFbsBitmap* TmpBackBitmap = new(ELeave)CFbsBitmap();
			CleanupStack::PushL(TmpBackBitmap);
			
			if(KErrNone == TmpBackBitmap->Create(aSize,MyBitmap->DisplayMode()))
			{	
				CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(TmpBackBitmap);
				CleanupStack::PushL(bitmapDevice);

				CFbsBitGc* graphicsContext = NULL;
				User::LeaveIfError(bitmapDevice->CreateContext(graphicsContext));
				CleanupStack::PushL(graphicsContext);

				graphicsContext->DrawBitmap(TRect(0,0,aSize.iWidth,aSize.iHeight),MyBitmap);
				
				CleanupStack::PopAndDestroy(2);//graphicsContext,bitmapDevice,
			}
			
			CFbsBitmap* TmpBackMask = new(ELeave)CFbsBitmap();
			CleanupStack::PushL(TmpBackMask);
			if(KErrNone == TmpBackMask->Create(aSize,MyMask->DisplayMode()))
			{	
				CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL(TmpBackMask);
				CleanupStack::PushL(bitmapDevice);

				CFbsBitGc* graphicsContext = NULL;
				User::LeaveIfError(bitmapDevice->CreateContext(graphicsContext));
				CleanupStack::PushL(graphicsContext);

				graphicsContext->DrawBitmap(TRect(0,0,aSize.iWidth,aSize.iHeight),MyMask);
				
				CleanupStack::PopAndDestroy(2);//graphicsContext,bitmapDevice,
			}
		
			CleanupStack::Pop(2);//TmpBackBitmap, TmpBackMask
			RetIcon = CGulIcon::NewL(TmpBackBitmap, TmpBackMask);
		}
	}
	
	if(!RetIcon && OkToAdd)
	{
		CleanupStack::Pop(2);//MyBitmap, MyMask
		RetIcon = CGulIcon::NewL(MyBitmap, MyMask);
	}
	else
	{
		CleanupStack::PopAndDestroy(2);//MyBitmap, MyMask
	}
		
	return RetIcon;
}
예제 #12
0
void CTTSprite::PointerCursorVisibleL()
    {
    if (!TestBase()->ConfigurationSupportsPointerEventTesting())
        {
        INFO_PRINTF1(_L("Test skipped because config does not support pointer event testing"));
        return;
        }
    
    // The pointer events need time to have an affect on the wserv
    static const TInt eventPropagationDelay = 100 * 1000; // 100 ms
    
    TInt screenNumber = TheClient->iScreen->GetScreenNumber();
    
    if(screenNumber != 0) // pointer events only supported on emulator screen 0
        {
        LOG_MESSAGE(_L("Pointer Cursor Visible only runs on screen 0"));
        return;
        }
    
    // set up objects used in test
    // 50x50 red rectangle colour 24
    CFbsBitmap bitmap;
    User::LeaveIfError(bitmap.Load(TEST_BITMAP_NAME, 8));
    
    TSize bmSize = bitmap.SizeInPixels();
    TPoint bmSample = TPoint(bmSize.iWidth / 2, bmSize.iHeight / 2);
    TRgb bmColour;
    bitmap.GetPixel(bmColour, bmSample);
    TEST(bmColour == KRgbRed);

    // single window, size of screen
    RWindow win(TheClient->iWs);
    User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),1));
    win.Activate();

    // setup cursor mode
    TheClient->iWs.SetPointerCursorMode(EPointerCursorWindow);
    
    // setup cursor to contain single 50x50 red bitmap
    RWsPointerCursor iCursor1 = RWsPointerCursor(TheClient->iWs);
    TSpriteMember member;
    SetUpMember(member);
    member.iBitmap=&bitmap;
    User::LeaveIfError(iCursor1.Construct(0));
    User::LeaveIfError(iCursor1.AppendMember(member));
    User::LeaveIfError(iCursor1.Activate());
    win.SetCustomPointerCursor(iCursor1);
    iCursor1.UpdateMember(0);

    // draw a green rect, size of screen as defined background and wait till it is rendered
    win.BeginRedraw();
    TheGc->Activate(win);
    TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
    TheGc->SetBrushColor(KRgbGreen);
    TSize wSize = win.Size();
    TheGc->DrawRect(TRect(TPoint(0,0), wSize));
    TheGc->Deactivate();
    win.EndRedraw();
    TheClient->iWs.Finish();
    
    // #### do test ####
    // define locations of simulated pointer events and sample positions of where we expect to see the cursor
    // The cursor will be moved and a check will be made to see if this has actually happened
    
    TPoint pos1(wSize.iWidth / 2, wSize.iHeight / 2); // top left of cursor at centre screen
    TPoint sample1(pos1 + bmSample); // centre of sprite at pos1
    TPoint pos2 = pos1 - bmSize; // bottom right of cursor at centre screen
    TPoint sample2 = pos2 + bmSample;  // centre of sprite at pos2

    TRgb pixel;
    
    // check initial state of screen at both sample positions
    TheClient->iScreen->GetPixel(pixel, sample1);
    TEST(pixel == KRgbGreen);

    TheClient->iScreen->GetPixel(pixel, sample2);
    TEST(pixel == KRgbGreen);
    
    TRawEvent e; // to simulate pointer events

    // simulate button 1 down event at pos1
    e.Set(TRawEvent::EButton1Down, pos1.iX, pos1.iY);
    e.SetDeviceNumber(screenNumber);
    UserSvr::AddEvent(e);

    User::After(eventPropagationDelay);
    
    // check red cursor visible on top of background
    TheClient->iScreen->GetPixel(pixel, sample1);
    TEST(pixel == KRgbRed);
    
    // simulate button 1 up event
    e.Set(TRawEvent::EButton1Up, pos1.iX, pos1.iY);
    UserSvr::AddEvent(e);
    User::After(eventPropagationDelay);
    
    // Move cursor away to pos2 
    e.Set(TRawEvent::EButton1Down, pos2.iX, pos2.iY);
    e.SetDeviceNumber(screenNumber);
    UserSvr::AddEvent(e);
    
    User::After(eventPropagationDelay);
    
    // check cursor has left this position ...
    TheClient->iScreen->GetPixel(pixel, sample1);
    TEST(pixel == KRgbGreen);
    // and arrived at the correct place
    TheClient->iScreen->GetPixel(pixel, sample2);
    TEST(pixel == KRgbRed);

    // simulate button 1 up event
    e.Set(TRawEvent::EButton1Up, pos2.iX, pos2.iY);
    UserSvr::AddEvent(e);
    User::After(eventPropagationDelay);
    
    // remove the cursor
    win.ClearPointerCursor();
    User::After(eventPropagationDelay);
    
    // check it has gone
    TheClient->iScreen->GetPixel(pixel, sample2);
    TEST(pixel == KRgbGreen);
    
    // #### clean up ####
    iCursor1.Close();
    win.Close();
    }
void CCFbsBitmapAnimation::RedrawSurfaceL()
{
    CFbsBitmap bitmap;
    User::LeaveIfError(bitmap.Load(iBitmapAnimFile, iFrameCounter));

    const TSize nativeSize(bitmap.SizeInPixels());

    const TSize fullScreenSize(iFullSurfaceBitmap->SizeInPixels());

    if(iPixelFormat == EFormatYuv)
    {
        TInt noOfPixels=fullScreenSize.iWidth * fullScreenSize.iHeight;
        TInt counter=noOfPixels;
        TUint32* address = iFullSurfaceBitmap->DataAddress();
        for(TInt i=0; i<counter; i++)
        {
            /* The only supported Yuv format is KPixelFormatYUV422Interleaved */
            /* Paint the surface white */
            address[i] = 0xFF7FFF7F;
        }
    }

    /* Potentially four screen copies will be required in the wrapping case *
     * (1) no wrapping (2) wrap in x co-ord (3) wrap in y co-ord            *
     * (4) wrap in both x and y co-ords                                     *
     * There is no problem with specifying negative co-ordinates for the    *
     * top LH corner as the offscreen section will not be displayed         */

    //Perform blits to the fullscreen bitmap
    //iAnimSize is the size of the square bitmap as it appears on the surface and iDisplayedSize is the size of the
    //rectangulara area limiting the animation

    TSize sz = iAnimSize;
    if(iPixelFormat == EFormatYuv)
    {
        sz = TSize(iAnimSize.iWidth/2, iAnimSize.iHeight);
    }

    iFullSurfaceBitmapGc->DrawBitmap(TRect(TPoint(iXPos, iYPos), sz), &bitmap, TRect(TPoint(0,0), nativeSize));

    //Wrap in x co-ord
    if( (iXPos + iAnimSize.iWidth) > iSurfaceSize.iWidth)
    {
        iFullSurfaceBitmapGc->DrawBitmap(TRect(TPoint(iXPos - iSurfaceSize.iWidth, iYPos), sz),
                                         &bitmap, TRect(TPoint(0,0), nativeSize));
    }

    //Wrap in y co-ord
    if( (iYPos + iAnimSize.iHeight) > iSurfaceSize.iHeight)
    {
        iFullSurfaceBitmapGc->DrawBitmap(TRect(TPoint(iXPos, iYPos - iSurfaceSize.iHeight), sz),
                                         &bitmap, TRect(TPoint(0,0), nativeSize));
    }

    //Wrap in both x and y co-ords
    if( ((iXPos + iAnimSize.iWidth) > iSurfaceSize.iWidth) && ((iYPos + iAnimSize.iHeight) > iSurfaceSize.iHeight) )
    {
        iFullSurfaceBitmapGc->DrawBitmap(TRect(TPoint(iXPos - iSurfaceSize.iWidth, iYPos - iSurfaceSize.iHeight), sz),
                                         &bitmap, TRect(TPoint(0,0), nativeSize));
    }

    //Increment x and y positions and wrap if necessary
    iXPos += iSurfaceSize.iWidth/iHorizontalRate;
    iYPos += iSurfaceSize.iHeight/iVerticalRate;
    iXPos = iXPos % iSurfaceSize.iWidth;
    iYPos = iYPos % iSurfaceSize.iHeight;

    iFrameCounter++;
}
예제 #14
0
// -----------------------------------------------------------------------------
// CLocalizationAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CLocalizationAppUi::HandleCommandL( TInt aCommand )
    {
    switch( aCommand )
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

		// Number
        case ELocalizationCommandNumber:
            {
				// buffer for localized text
				TBuf<50> myBuf;
				
				// Amount to show
				TReal myAmount = 1234.567;
				
				// Real number formatter, initialized with system's current locale settings
				TRealFormat myFormat;

				// Format real with current locales decimal separator setting
				myBuf.AppendNum(myAmount, myFormat);
				
				// Show formatted text
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
            }
            break;
		
		// Currency
		case ELocalizationCommandCurrency:
			{
				// locale is initialized with system's current locale settings
				TLocale myLocale;
				
				// buffer for localized text
				TBuf<50> myBuf;

				// amount is integer, but it is treated as last two digits
				// were decimal digits e.g. 1249 = 12.49, 2 = 0.02 ...
				TInt myAmount = 123456789;
				
				// Format currency according to current locale settings
				myLocale.FormatCurrency(myBuf, myAmount);

				// Show formatted text				
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
			}
			break;
			
		// Date
		case ELocalizationCommandDate:
			{
				// buffer for localized text
				TBuf<50> myBuf;
				
				// Object for datetime data
				TTime myDate;
				
				// Set current datetime to object
				myDate.HomeTime();
				
				// Format date according to current locale settings
				// Format string is universal, so that whatever the locale is,
				// date is always formatted correctly
				myDate.FormatL(myBuf, _L("%/0%1%/1%2%/2%3%/3%X"));
				
				// Show formatted text				
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
			}
			break;
			
		// Time
		case ELocalizationCommandTime:
			{
				// buffer for localized text
				TBuf<50> myBuf;
				
				// Object for datetime data
				TTime myTime;
				
				// Set current datetime to object
				myTime.HomeTime();

				// Format time to current locale
				// Format string is universal, so that whatever the locale is,
				// time is always formatted correctly
				myTime.FormatL(myBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B"));
				
				// Show formatted text			
            	CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( myBuf );
			}
			break;
			
		// Text
		case ELocalizationCommandText:
			{
				// buffer for string parameters that may change order
				CDesCArrayFlat* strings = new CDesCArrayFlat( 2 );
				CleanupStack::PushL( strings );

				// Initialize parameter buffer
				
				// First parameter
				strings->AppendL( _L("Heidi") );
				
				// Second parameter
				strings->AppendL( _L("2") );
				
	            // Load a string from the resource file, and append parameters into it
				HBufC* textResource = StringLoader::LoadL( R_LOC_COMMANDTEXT_TEXT, *strings );
				CleanupStack::PushL( textResource );
	            
				// Show formatted text			
	            CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
	            informationNote->ExecuteLD( *textResource );
	            
	            // Cleanupstack
				CleanupStack::PopAndDestroy( textResource );
				CleanupStack::PopAndDestroy( strings );
			}
			break;
			
		// Image
		case ELocalizationCommandImage:
			{
			    // find the drive where the app has been installed
			    TParse parse;
			    parse.Set(Application()->AppFullName(),0,0);
			    	            
				// Load bitmap name from the resource file
            	HBufC* bmpFile = StringLoader::LoadLC( R_LOC_COMMANDIMAGE_BMPFILE, parse.Drive());
            	
				// bitmap pointer
				CFbsBitmap* bitmap;
				
		        // Create and Load the Bitmap
		        bitmap = new( ELeave )CFbsBitmap;
		        CleanupStack::PushL( bitmap );
		        
		        // Load the first bitmap (index 0) from multi-bitmap file
		        User::LeaveIfError(bitmap->Load( *bmpFile, 0 ));
		        
                CleanupStack::Pop( bitmap );		        
		        // Draw bitmap to screen 
		        // ownership of bitmap is transferred to view
		        iAppView->DrawImage( bitmap );

		        // Cleanupstack
            	CleanupStack::PopAndDestroy( bmpFile );
			}
			break;
		
		// Default case
        default:
            break;
        }
    }