graphicsdeviceinterface/bitgdi/tbit/TDefect2.cpp
branchRCL_3
changeset 164 25ffed67c7ef
parent 163 bbf46f59e123
equal deleted inserted replaced
163:bbf46f59e123 164:25ffed67c7ef
     1 // Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    14 //
    14 //
    15 
    15 
    16 #include <random.h>
    16 #include <random.h>
    17 #include <s32file.h>
    17 #include <s32file.h>
    18 #include <e32math.h>
    18 #include <e32math.h>
       
    19 #include <hal.h>
    19 #include <s32mem.h>
    20 #include <s32mem.h>
    20 #include <graphics/gdi/gdiconsts.h>
    21 #include <graphics/gdi/gdiconsts.h>
    21 #include <e32cmn.h>
    22 #include <e32cmn.h>
    22 #include "BITPANIC.H"
    23 #include "BITPANIC.H"
    23 #include "TDefect2.h"
    24 #include "TDefect2.h"
   108 	_LIT(KTest2,"SubTest %d: DEF039331");
   109 	_LIT(KTest2,"SubTest %d: DEF039331");
   109 	_LIT(KTest3,"SubTest %d: DEF039650");
   110 	_LIT(KTest3,"SubTest %d: DEF039650");
   110 	_LIT(KTest4,"SubTest %d: CFbsBitmap::GetPixel() performance");
   111 	_LIT(KTest4,"SubTest %d: CFbsBitmap::GetPixel() performance");
   111 	_LIT(KTest5,"SubTest %d: Rotate/Move text");
   112 	_LIT(KTest5,"SubTest %d: Rotate/Move text");
   112 	_LIT(KTest6,"SubTest %d: SwapWidthAndHeight");
   113 	_LIT(KTest6,"SubTest %d: SwapWidthAndHeight");
       
   114 	_LIT(KTest7,"SubTest %d: Create multiple screens");
   113 	_LIT(KTest8,"SubTest %d: Clear with non-zero origin");
   115 	_LIT(KTest8,"SubTest %d: Clear with non-zero origin");
   114 	_LIT(KTest9,"SubTest %d: DEF115395: DrawBitmap & DrawBitmapMasked with a sourceRect out of the Bitmap bounds");
   116 	_LIT(KTest9,"SubTest %d: DEF115395: DrawBitmap & DrawBitmapMasked with a sourceRect out of the Bitmap bounds");
   115 	_LIT(KTest10,"SubTest %d: INC119063: General test CopyRect rewrite for low color depth (8,4,2, pixels per byte)");
   117 	_LIT(KTest10,"SubTest %d: INC119063: General test CopyRect rewrite for low color depth (8,4,2, pixels per byte)");
   116 	_LIT(KTest11,"SubTest %d: INC120917: Dirty Mask Bitmap not remapped in BitBltMasked");
   118 	_LIT(KTest11,"SubTest %d: INC120917: Dirty Mask Bitmap not remapped in BitBltMasked");
   117 	_LIT(KTest12,"SubTest %d: Zero-sized brush pattern bitmaps");
   119 	_LIT(KTest12,"SubTest %d: Zero-sized brush pattern bitmaps");
   151 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0071"));
   153 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0071"));
   152 		INFO_PRINTF2(KTest6,aCurTestCase);
   154 		INFO_PRINTF2(KTest6,aCurTestCase);
   153 		SwapWidthAndHeightL();
   155 		SwapWidthAndHeightL();
   154 		break;
   156 		break;
   155 	case 7:
   157 	case 7:
   156 		// Test case moved to tmultiscreens.cpp
   158 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0072"));
       
   159 		INFO_PRINTF2(KTest7,aCurTestCase);
       
   160 		CreateScreenDeviceL();
   157 		break;
   161 		break;
   158 	case 8:
   162 	case 8:
   159 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0073"));
   163 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0073"));
   160 		INFO_PRINTF2(KTest8,aCurTestCase);
   164 		INFO_PRINTF2(KTest8,aCurTestCase);
   161 		NonZeroOriginClearL();
   165 		NonZeroOriginClearL();
  2064 		TInt err = iBmpDevice->SwapWidthAndHeight();
  2068 		TInt err = iBmpDevice->SwapWidthAndHeight();
  2065 		TEST(err == KErrNone);
  2069 		TEST(err == KErrNone);
  2066 		}//end of - for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
  2070 		}//end of - for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
  2067 	}
  2071 	}
  2068 
  2072 
       
  2073 /**
       
  2074   @SYMTestCaseID GRAPHICS-BITGDI-0072
       
  2075  
       
  2076   @SYMDEF             
       
  2077 
       
  2078   @SYMTestCaseDesc Multiple screen test
       
  2079    
       
  2080   @SYMTestPriority High
       
  2081 
       
  2082   @SYMTestStatus Implemented
       
  2083 
       
  2084   @SYMTestActions creates some screens in different modes then writes some rotated text to them and test.
       
  2085  
       
  2086   @SYMTestExpectedResults Test should perform graphics operations succesfully. 
       
  2087 */	
       
  2088 void CTDefect2::CreateScreenDeviceL()
       
  2089 	{
       
  2090 	TDisplayMode testMode[] =  {EColor4K, EColor64K, EColor16M, EColor16MU, EColor256, EColor16MA, EColor16MAP};//tested display modes
       
  2091 	for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
       
  2092 		{
       
  2093 		TInt screenCnt = 0;
       
  2094 		TEST(HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCnt) == KErrNone);
       
  2095 		for(TInt screenNo=0;screenNo<screenCnt;++screenNo)
       
  2096 			{
       
  2097 			TInt err = CreateScrDevAndContext(screenNo, testMode[ii]);
       
  2098 			if(err == KErrNone)
       
  2099 				{
       
  2100 				DoRotateMoveTextL();
       
  2101 				}
       
  2102 			DeleteGraphicsContext();
       
  2103 			DeleteScreenDevice();
       
  2104 			}
       
  2105 		}
       
  2106 	}
  2069 
  2107 
  2070 void CTDefect2::CreateScrDevAndContextL()
  2108 void CTDefect2::CreateScrDevAndContextL()
  2071 	{
  2109 	{
  2072 	DeleteGraphicsContext();
  2110 	DeleteGraphicsContext();
  2073 	DeleteScreenDevice();
  2111 	DeleteScreenDevice();
  2085 TInt CTDefect2::CreateScrDevAndContext(TInt aScreenNo, TDisplayMode aDisplayMode)
  2123 TInt CTDefect2::CreateScrDevAndContext(TInt aScreenNo, TDisplayMode aDisplayMode)
  2086 	{
  2124 	{
  2087 	DeleteGraphicsContext();
  2125 	DeleteGraphicsContext();
  2088 	DeleteScreenDevice();
  2126 	DeleteScreenDevice();
  2089 	TRAPD(err, iScrDev = CFbsScreenDevice::NewL(aScreenNo, aDisplayMode));
  2127 	TRAPD(err, iScrDev = CFbsScreenDevice::NewL(aScreenNo, aDisplayMode));
  2090 	if ( !iScrDev )
  2128 	if(err == KErrNotSupported)
  2091 		{
  2129 		{
  2092 		TESTE( err == KErrNotSupported, err );
       
  2093 		return err;
  2130 		return err;
  2094 		}
  2131 		}
  2095 	TEST(err == KErrNone);
  2132 	TEST(err == KErrNone);
  2096 	TEST(iScrDev->ScreenNo() == aScreenNo);
  2133 	TEST(iScrDev->ScreenNo() == aScreenNo);
  2097 	err = iScrDev->CreateContext((CGraphicsContext*&)iGc);
  2134 	err = iScrDev->CreateContext((CGraphicsContext*&)iGc);
  2098 	if ( !iGc )
       
  2099 		{
       
  2100 		return err;
       
  2101 		}
       
  2102 	TEST(err == KErrNone);
  2135 	TEST(err == KErrNone);
  2103 	iGc->SetUserDisplayMode(aDisplayMode);
  2136 	iGc->SetUserDisplayMode(aDisplayMode);
  2104 	iScrDev->ChangeScreenDevice(NULL);
  2137 	iScrDev->ChangeScreenDevice(NULL);
  2105 	iScrDev->SetAutoUpdate(EFalse);
  2138 	iScrDev->SetAutoUpdate(EFalse);
  2106 	iSize = iScrDev->SizeInPixels();
  2139 	iSize = iScrDev->SizeInPixels();
  2373 	const TReal32	KTolerance=0.10; // Percent difference permitted
  2406 	const TReal32	KTolerance=0.10; // Percent difference permitted
  2374 	TInt cFbsScreenDeviceResult = 1;
  2407 	TInt cFbsScreenDeviceResult = 1;
  2375 	TInt cWsScreenDeviceResult = 1;
  2408 	TInt cWsScreenDeviceResult = 1;
  2376 	TReal32 percentDifference = 0.0;
  2409 	TReal32 percentDifference = 0.0;
  2377 	CreateScrDevAndContextL();
  2410 	CreateScrDevAndContextL();
  2378 	TBool testResult = EFalse;
       
  2379 
  2411 
  2380 	RWsSession wsSession;
  2412 	RWsSession wsSession;
  2381 	if (KErrNone == wsSession.Connect())
  2413 	if (KErrNone == wsSession.Connect())
  2382 		{
  2414 		{
  2383 		CWsScreenDevice* wsScrDev = new (ELeave) CWsScreenDevice(wsSession);
  2415 		CWsScreenDevice* wsScrDev = new (ELeave) CWsScreenDevice(wsSession);
  2386 		// first compare results of the two class's HorizontalPixelsToTwips and pass 
  2418 		// first compare results of the two class's HorizontalPixelsToTwips and pass 
  2387 		// the test if they are within tolerance
  2419 		// the test if they are within tolerance
  2388 		cFbsScreenDeviceResult = iScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2420 		cFbsScreenDeviceResult = iScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2389 		cWsScreenDeviceResult = wsScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2421 		cWsScreenDeviceResult = wsScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2390 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2422 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2391 		testResult = (percentDifference < KTolerance);
  2423 		TEST(percentDifference < KTolerance);
  2392 		if ( !testResult )
       
  2393 			{
       
  2394 			_LIT(KHorizPixelsToTwipsDesc, "%d horizontal pixels converted to twips by screen device: FBS=%d, WS=%d");
       
  2395 			WARN_PRINTF4(KHorizPixelsToTwipsDesc, KHorizontalTestPixels, cFbsScreenDeviceResult, cWsScreenDeviceResult);
       
  2396 			}
       
  2397 		TEST( testResult );
       
  2398 		
  2424 		
  2399 		// convert the CWsScreenDevice result back again using each class's HorizontalTwipsToPixels
  2425 		// convert the CWsScreenDevice result back again using each class's HorizontalTwipsToPixels
  2400 		// and pass the test if these results are within tolerance
  2426 		// and pass the test if these results are within tolerance
  2401 		TInt numTwipsToTest = cWsScreenDeviceResult;
  2427 		cFbsScreenDeviceResult = iScrDev->HorizontalTwipsToPixels(cWsScreenDeviceResult);
  2402 		cFbsScreenDeviceResult = iScrDev->HorizontalTwipsToPixels(numTwipsToTest);
  2428 		cWsScreenDeviceResult = wsScrDev->HorizontalTwipsToPixels(cWsScreenDeviceResult);
  2403 		cWsScreenDeviceResult = wsScrDev->HorizontalTwipsToPixels(numTwipsToTest);
       
  2404 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2429 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2405         testResult = (percentDifference < KTolerance);
  2430 		TEST(percentDifference < KTolerance);
  2406         if ( !testResult )
       
  2407 			{
       
  2408 			_LIT(KHorizTwipsToPixelsDesc, "%d horizontal twips converted to pixels by screen device: FBS=%d, WS=%d");
       
  2409 			WARN_PRINTF4(KHorizTwipsToPixelsDesc, numTwipsToTest, cFbsScreenDeviceResult, cWsScreenDeviceResult);
       
  2410             }
       
  2411         TEST( testResult );
       
  2412 
  2431 
  2413 		// next compare results of the two class's VerticalPixelsToTwips and pass the test
  2432 		// next compare results of the two class's VerticalPixelsToTwips and pass the test
  2414 		// if they are within tolerance
  2433 		// if they are within tolerance
  2415 		cFbsScreenDeviceResult = iScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2434 		cFbsScreenDeviceResult = iScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2416 		cWsScreenDeviceResult= wsScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2435 		cWsScreenDeviceResult= wsScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2417 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2436 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2418         testResult = (percentDifference < KTolerance);
  2437 		TEST(percentDifference < KTolerance);
  2419         if ( !testResult )
       
  2420             {
       
  2421             _LIT(KVertPixelsToTwipsDesc, "%d vertical pixels converted to twips by screen device: FBS=%d, WS=%d");
       
  2422             WARN_PRINTF4(KVertPixelsToTwipsDesc, KVerticalTestPixels, cFbsScreenDeviceResult, cWsScreenDeviceResult);
       
  2423             }
       
  2424         TEST( testResult );
       
  2425 		
  2438 		
  2426 		// convert the CWsScreenDevice result back again using each class's VerticalTwipsToPixels
  2439 		// convert the CWsScreenDevice result back again using each class's VerticalTwipsToPixels
  2427 		// and pass the test if these results are within tolerance
  2440 		// and pass the test if these results are within tolerance
  2428 		numTwipsToTest = cWsScreenDeviceResult;
  2441 		cFbsScreenDeviceResult = iScrDev->VerticalTwipsToPixels(cWsScreenDeviceResult);
  2429 		cFbsScreenDeviceResult = iScrDev->VerticalTwipsToPixels(numTwipsToTest);
  2442 		cWsScreenDeviceResult = wsScrDev->VerticalTwipsToPixels(cWsScreenDeviceResult);
  2430 		cWsScreenDeviceResult = wsScrDev->VerticalTwipsToPixels(numTwipsToTest);
       
  2431 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2443 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2432         testResult = (percentDifference < KTolerance);
  2444 		TEST(percentDifference < KTolerance);
  2433         if ( !testResult )
       
  2434             {
       
  2435             _LIT(KVertTwipsToPixelsDesc, "%d vertical twips converted to pixels by screen device: FBS=%d, WS=%d");
       
  2436             WARN_PRINTF4(KVertTwipsToPixelsDesc, numTwipsToTest, cFbsScreenDeviceResult, cWsScreenDeviceResult);
       
  2437             }
       
  2438         TEST( testResult );
       
  2439 		
  2445 		
  2440 		delete wsScrDev;
  2446 		delete wsScrDev;
  2441 		wsSession.Close();
  2447 		wsSession.Close();
  2442 		}
  2448 		}
  2443 	else
  2449 	else