graphicsdeviceinterface/bitgdi/tbit/TDefect2.cpp
changeset 136 62bb7c97884c
parent 121 d72fc2aace31
equal deleted inserted replaced
121:d72fc2aace31 136:62bb7c97884c
    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>
       
    20 #include <s32mem.h>
    19 #include <s32mem.h>
    21 #include <graphics/gdi/gdiconsts.h>
    20 #include <graphics/gdi/gdiconsts.h>
    22 #include <e32cmn.h>
    21 #include <e32cmn.h>
    23 #include "BITPANIC.H"
    22 #include "BITPANIC.H"
    24 #include "TDefect2.h"
    23 #include "TDefect2.h"
   109 	_LIT(KTest2,"SubTest %d: DEF039331");
   108 	_LIT(KTest2,"SubTest %d: DEF039331");
   110 	_LIT(KTest3,"SubTest %d: DEF039650");
   109 	_LIT(KTest3,"SubTest %d: DEF039650");
   111 	_LIT(KTest4,"SubTest %d: CFbsBitmap::GetPixel() performance");
   110 	_LIT(KTest4,"SubTest %d: CFbsBitmap::GetPixel() performance");
   112 	_LIT(KTest5,"SubTest %d: Rotate/Move text");
   111 	_LIT(KTest5,"SubTest %d: Rotate/Move text");
   113 	_LIT(KTest6,"SubTest %d: SwapWidthAndHeight");
   112 	_LIT(KTest6,"SubTest %d: SwapWidthAndHeight");
   114 	_LIT(KTest7,"SubTest %d: Create multiple screens");
       
   115 	_LIT(KTest8,"SubTest %d: Clear with non-zero origin");
   113 	_LIT(KTest8,"SubTest %d: Clear with non-zero origin");
   116 	_LIT(KTest9,"SubTest %d: DEF115395: DrawBitmap & DrawBitmapMasked with a sourceRect out of the Bitmap bounds");
   114 	_LIT(KTest9,"SubTest %d: DEF115395: DrawBitmap & DrawBitmapMasked with a sourceRect out of the Bitmap bounds");
   117 	_LIT(KTest10,"SubTest %d: INC119063: General test CopyRect rewrite for low color depth (8,4,2, pixels per byte)");
   115 	_LIT(KTest10,"SubTest %d: INC119063: General test CopyRect rewrite for low color depth (8,4,2, pixels per byte)");
   118 	_LIT(KTest11,"SubTest %d: INC120917: Dirty Mask Bitmap not remapped in BitBltMasked");
   116 	_LIT(KTest11,"SubTest %d: INC120917: Dirty Mask Bitmap not remapped in BitBltMasked");
   119 	_LIT(KTest12,"SubTest %d: Zero-sized brush pattern bitmaps");
   117 	_LIT(KTest12,"SubTest %d: Zero-sized brush pattern bitmaps");
   153 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0071"));
   151 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0071"));
   154 		INFO_PRINTF2(KTest6,aCurTestCase);
   152 		INFO_PRINTF2(KTest6,aCurTestCase);
   155 		SwapWidthAndHeightL();
   153 		SwapWidthAndHeightL();
   156 		break;
   154 		break;
   157 	case 7:
   155 	case 7:
   158 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0072"));
   156 		// Test case moved to tmultiscreens.cpp
   159 		INFO_PRINTF2(KTest7,aCurTestCase);
       
   160 		CreateScreenDeviceL();
       
   161 		break;
   157 		break;
   162 	case 8:
   158 	case 8:
   163 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0073"));
   159 		((CTDefect2Step*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0073"));
   164 		INFO_PRINTF2(KTest8,aCurTestCase);
   160 		INFO_PRINTF2(KTest8,aCurTestCase);
   165 		NonZeroOriginClearL();
   161 		NonZeroOriginClearL();
  2068 		TInt err = iBmpDevice->SwapWidthAndHeight();
  2064 		TInt err = iBmpDevice->SwapWidthAndHeight();
  2069 		TEST(err == KErrNone);
  2065 		TEST(err == KErrNone);
  2070 		}//end of - for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
  2066 		}//end of - for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++)
  2071 	}
  2067 	}
  2072 
  2068 
  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 	}
       
  2107 
  2069 
  2108 void CTDefect2::CreateScrDevAndContextL()
  2070 void CTDefect2::CreateScrDevAndContextL()
  2109 	{
  2071 	{
  2110 	DeleteGraphicsContext();
  2072 	DeleteGraphicsContext();
  2111 	DeleteScreenDevice();
  2073 	DeleteScreenDevice();
  2411 	const TReal32	KTolerance=0.10; // Percent difference permitted
  2373 	const TReal32	KTolerance=0.10; // Percent difference permitted
  2412 	TInt cFbsScreenDeviceResult = 1;
  2374 	TInt cFbsScreenDeviceResult = 1;
  2413 	TInt cWsScreenDeviceResult = 1;
  2375 	TInt cWsScreenDeviceResult = 1;
  2414 	TReal32 percentDifference = 0.0;
  2376 	TReal32 percentDifference = 0.0;
  2415 	CreateScrDevAndContextL();
  2377 	CreateScrDevAndContextL();
       
  2378 	TBool testResult = EFalse;
  2416 
  2379 
  2417 	RWsSession wsSession;
  2380 	RWsSession wsSession;
  2418 	if (KErrNone == wsSession.Connect())
  2381 	if (KErrNone == wsSession.Connect())
  2419 		{
  2382 		{
  2420 		CWsScreenDevice* wsScrDev = new (ELeave) CWsScreenDevice(wsSession);
  2383 		CWsScreenDevice* wsScrDev = new (ELeave) CWsScreenDevice(wsSession);
  2423 		// first compare results of the two class's HorizontalPixelsToTwips and pass 
  2386 		// first compare results of the two class's HorizontalPixelsToTwips and pass 
  2424 		// the test if they are within tolerance
  2387 		// the test if they are within tolerance
  2425 		cFbsScreenDeviceResult = iScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2388 		cFbsScreenDeviceResult = iScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2426 		cWsScreenDeviceResult = wsScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2389 		cWsScreenDeviceResult = wsScrDev->HorizontalPixelsToTwips(KHorizontalTestPixels);
  2427 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2390 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2428 		TEST(percentDifference < KTolerance);
  2391 		testResult = (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 );
  2429 		
  2398 		
  2430 		// convert the CWsScreenDevice result back again using each class's HorizontalTwipsToPixels
  2399 		// convert the CWsScreenDevice result back again using each class's HorizontalTwipsToPixels
  2431 		// and pass the test if these results are within tolerance
  2400 		// and pass the test if these results are within tolerance
  2432 		cFbsScreenDeviceResult = iScrDev->HorizontalTwipsToPixels(cWsScreenDeviceResult);
  2401 		TInt numTwipsToTest = cWsScreenDeviceResult;
  2433 		cWsScreenDeviceResult = wsScrDev->HorizontalTwipsToPixels(cWsScreenDeviceResult);
  2402 		cFbsScreenDeviceResult = iScrDev->HorizontalTwipsToPixels(numTwipsToTest);
       
  2403 		cWsScreenDeviceResult = wsScrDev->HorizontalTwipsToPixels(numTwipsToTest);
  2434 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2404 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2435 		TEST(percentDifference < KTolerance);
  2405         testResult = (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 );
  2436 
  2412 
  2437 		// next compare results of the two class's VerticalPixelsToTwips and pass the test
  2413 		// next compare results of the two class's VerticalPixelsToTwips and pass the test
  2438 		// if they are within tolerance
  2414 		// if they are within tolerance
  2439 		cFbsScreenDeviceResult = iScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2415 		cFbsScreenDeviceResult = iScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2440 		cWsScreenDeviceResult= wsScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2416 		cWsScreenDeviceResult= wsScrDev->VerticalPixelsToTwips(KVerticalTestPixels);
  2441 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2417 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2442 		TEST(percentDifference < KTolerance);
  2418         testResult = (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 );
  2443 		
  2425 		
  2444 		// convert the CWsScreenDevice result back again using each class's VerticalTwipsToPixels
  2426 		// convert the CWsScreenDevice result back again using each class's VerticalTwipsToPixels
  2445 		// and pass the test if these results are within tolerance
  2427 		// and pass the test if these results are within tolerance
  2446 		cFbsScreenDeviceResult = iScrDev->VerticalTwipsToPixels(cWsScreenDeviceResult);
  2428 		numTwipsToTest = cWsScreenDeviceResult;
  2447 		cWsScreenDeviceResult = wsScrDev->VerticalTwipsToPixels(cWsScreenDeviceResult);
  2429 		cFbsScreenDeviceResult = iScrDev->VerticalTwipsToPixels(numTwipsToTest);
       
  2430 		cWsScreenDeviceResult = wsScrDev->VerticalTwipsToPixels(numTwipsToTest);
  2448 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2431 		percentDifference = Abs((TReal32)(cFbsScreenDeviceResult - cWsScreenDeviceResult)/cFbsScreenDeviceResult*100.0);
  2449 		TEST(percentDifference < KTolerance);
  2432         testResult = (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 );
  2450 		
  2439 		
  2451 		delete wsScrDev;
  2440 		delete wsScrDev;
  2452 		wsSession.Close();
  2441 		wsSession.Close();
  2453 		}
  2442 		}
  2454 	else
  2443 	else