sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Screen device test code sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "TSCRDEV.H" sl@0: sl@0: //Define this to get visible pauses (in test 6: DeviceResSwitchL) sl@0: //#define VISIBLE_PAUSES sl@0: sl@0: //Define this to get extra logging which may be useful in tracking down a fail sl@0: //#define EXTRA_LOGGING sl@0: sl@0: CTScreenDevice::CTScreenDevice(CTestStep* aStep) : CTWsGraphicsBase(aStep) sl@0: {} sl@0: sl@0: CTScreenDevice::~CTScreenDevice() sl@0: {} sl@0: sl@0: void CTScreenDevice::ConstructL() sl@0: { sl@0: //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... sl@0: RWsSession aSession; sl@0: CWsScreenDevice *device1; sl@0: CWsScreenDevice *device2; sl@0: CWsScreenDevice *device3; sl@0: sl@0: aSession.Connect(); sl@0: device1=new(ELeave) CWsScreenDevice(aSession); sl@0: device1->Construct(iTest->iScreenNumber); sl@0: delete device1; sl@0: device1=new(ELeave) CWsScreenDevice(aSession); sl@0: device1->Construct(iTest->iScreenNumber); sl@0: device2=new(ELeave) CWsScreenDevice(aSession); sl@0: device2->Construct(iTest->iScreenNumber); sl@0: device3=new(ELeave) CWsScreenDevice(aSession); sl@0: device3->Construct(iTest->iScreenNumber); sl@0: delete device3; sl@0: CFbsFont *font; sl@0: User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); sl@0: RWindowGroup group(aSession); sl@0: group.Construct(777); sl@0: group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); sl@0: RWindow win(aSession); sl@0: win.Construct(group,77); sl@0: CWindowGc *gc=new(ELeave) CWindowGc(device1); sl@0: gc->Construct(); sl@0: gc->Activate(win); sl@0: gc->UseFont(font); sl@0: device1->ReleaseFont(font); sl@0: aSession.Flush(); sl@0: delete gc; sl@0: win.Close(); sl@0: group.Close(); sl@0: delete device1; sl@0: delete device2; sl@0: aSession.Close(); sl@0: } sl@0: sl@0: sl@0: void CTScreenDevice::TestTwipPixelConversions() sl@0: { sl@0: TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234)); sl@0: TEST(result==1234); sl@0: if (result!=1234) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234) return value - Expected: %d, Actual: %d"), 1234, result); sl@0: sl@0: result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234)); sl@0: TEST(result==1234); sl@0: if (result!=1234) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234) return value - Expected: %d, Actual: %d"), 1234, result); sl@0: sl@0: TSize pixels=TheClient->iScreen->SizeInPixels(); sl@0: TSize twips=TheClient->iScreen->SizeInTwips(); sl@0: TInt conv=TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth); sl@0: TEST(conv==twips.iWidth); sl@0: if (conv!=twips.iWidth) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth) return value - Expected: %d, Actual: %d"), twips.iWidth, conv); sl@0: sl@0: conv=TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight); sl@0: TEST(conv==twips.iHeight); sl@0: if (conv!=twips.iHeight) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight) return value - Expected: %d, Actual: %d"), twips.iHeight, conv); sl@0: } sl@0: sl@0: #define TEST_VALUE 100000000 sl@0: void CTScreenDevice::TestTwipPixelOverflow() sl@0: { sl@0: TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE)); sl@0: TEST(result==TEST_VALUE); sl@0: if (result!=TEST_VALUE) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE)) return value - Expected: %d, Actual: %d"), TEST_VALUE, result); sl@0: sl@0: result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE)); sl@0: TEST(result==TEST_VALUE); sl@0: if (result!=TEST_VALUE) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE)) return value - Expected: %d, Actual: %d"), TEST_VALUE, result); sl@0: sl@0: result = TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE); sl@0: TEST(result>0); sl@0: if (!result>0) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); sl@0: sl@0: result = TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE); sl@0: TEST(result>0); sl@0: if (!result>0) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); sl@0: sl@0: result = TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE); sl@0: TEST(result>0); sl@0: if (!result>0) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); sl@0: sl@0: result = TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE); sl@0: TEST(result>0); sl@0: if (!result>0) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE) return value - Expected: %d less than, Actual: %d"), 0, result); sl@0: } sl@0: sl@0: void CTScreenDevice::TwipsCacheFlushL() sl@0: { sl@0: RWsSession session; sl@0: CWsScreenDevice* device; sl@0: CFont* font; sl@0: CFont* font2; sl@0: const TFontSpec fontspec(KTestFontTypefaceName,250); sl@0: TPixelsTwipsAndRotation sizeAndRotation; sl@0: sl@0: // create a CWsScreenDevice instance sl@0: User::LeaveIfError(session.Connect()); sl@0: device=new(ELeave) CWsScreenDevice(session); sl@0: device->Construct(iTest->iScreenNumber); sl@0: sl@0: // Record a font height for use by latter tests sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); sl@0: const TInt height0=font->HeightInPixels(); sl@0: device->ReleaseFont(font); sl@0: sl@0: // 1. find font with best-matching height in twips, sl@0: // 2. change twips size of the screen (leaving pixel-size same), sl@0: // 3. find font with best-matching height in twips, sl@0: // 4. make sure that the newly found font is not the same as previous and has the different height in pixels sl@0: device->GetDefaultScreenSizeAndRotation(sizeAndRotation); sl@0: #if defined(EXTRA_LOGGING) sl@0: _LIT(KLog1,"Font height: %d for unchanged device. pixels=%d,%d twips=%d,%d"); sl@0: LOG_MESSAGE6(KLog1,height0,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight sl@0: ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); sl@0: #endif sl@0: sizeAndRotation.iTwipsSize.iHeight=2000; sl@0: sizeAndRotation.iTwipsSize.iWidth =3000; sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); sl@0: TInt height=font->HeightInPixels(); sl@0: #if defined(EXTRA_LOGGING) sl@0: _LIT(KLog2,"Font height: %d for device with twips set to 2000x3000"); sl@0: LOG_MESSAGE2(KLog2,height); sl@0: #endif sl@0: TFontSpec returnedSpec=font->FontSpecInTwips(); sl@0: sl@0: sizeAndRotation.iTwipsSize.iHeight=4000; sl@0: sizeAndRotation.iTwipsSize.iWidth =6000; sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); sl@0: TInt height2=font2->HeightInPixels(); sl@0: TFontSpec returnedSpec2 = font2->FontSpecInTwips(); sl@0: #if defined(EXTRA_LOGGING) sl@0: _LIT(KLog3,"Font height: %d for device with twips set to 4000x6000"); sl@0: LOG_MESSAGE2(KLog3,height2); sl@0: #endif sl@0: sl@0: TEST(font!=font2); sl@0: TEST(height!=height2); sl@0: _LIT(KLogErrM,"Font Heights in pixels match unexpectantly, height=%d"); sl@0: if (height==height2) sl@0: INFO_PRINTF2(KLogErrM,height); sl@0: sl@0: device->ReleaseFont(font2); sl@0: device->ReleaseFont(font); sl@0: sl@0: // 1. find font with best-matching height in twips, sl@0: // 2. change pixel size of the screen (leaving twip-size same), sl@0: // 3. find font with best-matching height in twips, sl@0: // 4. make sure that the newly found font is not the same as previous and has the different height in pixels sl@0: device->GetDefaultScreenSizeAndRotation(sizeAndRotation); sl@0: sizeAndRotation.iPixelSize.iHeight=240; sl@0: sizeAndRotation.iPixelSize.iWidth =640; sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); sl@0: height=font->HeightInPixels(); sl@0: returnedSpec=font->FontSpecInTwips(); sl@0: #if defined(EXTRA_LOGGING) sl@0: _LIT(KLog4,"Font height: %d for device with pixels set to 240x640 twips=%d,%d"); sl@0: LOG_MESSAGE4(KLog4,height,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); sl@0: #endif sl@0: sl@0: sizeAndRotation.iPixelSize.iHeight=480; sl@0: sizeAndRotation.iPixelSize.iWidth =1280; sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); sl@0: height2=font2->HeightInPixels(); sl@0: returnedSpec2=font2->FontSpecInTwips(); sl@0: #if defined(EXTRA_LOGGING) sl@0: _LIT(KLog5,"Font height: %d for device with pixels set to 480x1280"); sl@0: LOG_MESSAGE2(KLog5,height2); sl@0: #endif sl@0: sl@0: TEST(font!=font2); sl@0: TEST(height!=height2); sl@0: if (height==height2) sl@0: INFO_PRINTF2(KLogErrM,height); sl@0: sl@0: device->ReleaseFont(font2); sl@0: device->ReleaseFont(font); sl@0: sl@0: // 1. double the width and height of screen in both pixels and twips sl@0: // 2. find font with best-matching height in twips, sl@0: // 3. make sure that the newly found font is the same as previous and has the same height in pixels sl@0: device->GetDefaultScreenSizeAndRotation(sizeAndRotation); sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); sl@0: sizeAndRotation.iPixelSize.iHeight*=2; sl@0: sizeAndRotation.iPixelSize.iWidth *=2; sl@0: sizeAndRotation.iTwipsSize.iHeight*=2; sl@0: sizeAndRotation.iTwipsSize.iWidth *=2; sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); sl@0: height2=font2->HeightInPixels(); sl@0: #if defined(EXTRA_LOGGING) sl@0: _LIT(KLog6,"Font height: %d for device doubled size. pixels=%d,%d twips=%d,%d"); sl@0: LOG_MESSAGE6(KLog6,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight sl@0: ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); sl@0: #endif sl@0: sl@0: TEST(font==font2); sl@0: TEST(height0==height2); sl@0: _LIT(KLogErrD,"Font Heights in pixels don't match, expected=%d, actual=%d"); sl@0: if (height0!=height2) sl@0: INFO_PRINTF3(KLogErrD,height0,height2); sl@0: sl@0: device->ReleaseFont(font2); sl@0: device->ReleaseFont(font); sl@0: sl@0: // 1. swap width and height sizes of screen for both pixels and twips sl@0: // 2. find font with best-matching height in twips, sl@0: // 3. make sure that the newly found font is the same as previous and has the same height in pixels sl@0: device->GetDefaultScreenSizeAndRotation(sizeAndRotation); sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); sl@0: TInt swap=sizeAndRotation.iPixelSize.iHeight; sl@0: sizeAndRotation.iPixelSize.iHeight=sizeAndRotation.iPixelSize.iWidth; sl@0: sizeAndRotation.iPixelSize.iWidth =swap; sl@0: swap=sizeAndRotation.iTwipsSize.iHeight; sl@0: sizeAndRotation.iTwipsSize.iHeight=sizeAndRotation.iTwipsSize.iWidth; sl@0: sizeAndRotation.iTwipsSize.iWidth =swap; sl@0: device->SetScreenSizeAndRotation(sizeAndRotation); sl@0: User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); sl@0: height2 = font2->HeightInPixels(); sl@0: #if defined(EXTRA_LOGGING) sl@0: _LIT(KLog7,"Font height: %d for device rotated size. pixels=%d,%d twips=%d,%d"); sl@0: LOG_MESSAGE6(KLog7,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight sl@0: ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); sl@0: #endif sl@0: sl@0: TEST(font==font2); sl@0: TEST(height0==height2); sl@0: if (height0!=height2) sl@0: INFO_PRINTF3(KLogErrD,height0,height2); sl@0: sl@0: device->ReleaseFont(font2); sl@0: device->ReleaseFont(font); sl@0: sl@0: delete device; sl@0: session.Close(); sl@0: } sl@0: sl@0: void CTScreenDevice::CheckBitmapL(CFbsBitmap *aBitmap, const TRect &aRect) sl@0: { sl@0: CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(aBitmap); sl@0: CleanupStack::PushL(device); sl@0: TInt height=Min(aRect.Size().iHeight,aBitmap->SizeInPixels().iHeight); sl@0: TInt width=Min(aRect.Size().iWidth,aBitmap->SizeInPixels().iWidth); sl@0: TPoint pos(0,0); sl@0: TInt bufLen=CFbsBitmap::ScanLineLength(width,EGray4); sl@0: TAny *buf1=User::AllocLC(bufLen); sl@0: TAny *buf2=User::AllocLC(bufLen); sl@0: TPtr8 scanBuf1((TUint8 *)buf1,bufLen); sl@0: TPtr8 scanBuf2((TUint8 *)buf2,bufLen); sl@0: TInt oddPixels=width%4; sl@0: TInt byte1,byte2; sl@0: for(;pos.iYiScreen->GetScanLine(scanBuf1,pos+aRect.iTl,width,EGray4); sl@0: device->GetScanLine(scanBuf2,pos,width,EGray4); sl@0: if (oddPixels>0) sl@0: { sl@0: byte1=(scanBuf1[bufLen-1]<<(2*(4-oddPixels)))%256; sl@0: byte2=(scanBuf2[bufLen-1]<<(2*(4-oddPixels)))%256; sl@0: TEST(byte1==byte2); sl@0: if (byte1!=byte2) sl@0: INFO_PRINTF3(_L("byte1==byte2 - byte1: %d, byte2 Height: %d"), byte1, byte2); sl@0: sl@0: scanBuf1=scanBuf1.Left(bufLen-1); sl@0: scanBuf2=scanBuf2.Left(bufLen-1); sl@0: } sl@0: TBool retVal = !scanBuf1.Compare(scanBuf2); sl@0: TEST(retVal); sl@0: if (!retVal) sl@0: INFO_PRINTF3(_L("!scanBuf1.Compare(scanBuf2) return value - Expected: %d, Actual: %d"), ETrue, retVal); sl@0: } sl@0: CleanupStack::PopAndDestroy(3); sl@0: } sl@0: sl@0: void CTScreenDevice::doTestScreenToBitmapL() sl@0: { sl@0: RBlankWindow shieldWin(TheClient->iWs); sl@0: shieldWin.Construct(*TheClient->iGroup->GroupWin(),1); sl@0: shieldWin.SetOrdinalPosition(0,-1); sl@0: shieldWin.SetColor(TRgb::Gray4(1)); sl@0: shieldWin.Activate(); sl@0: CleanupStack::PushL(TCleanupItem(CleanUpWindow,&shieldWin)); sl@0: TSize scrSize(TheClient->iScreen->SizeInPixels()); sl@0: CWsBitmap *wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(wsBitmap); sl@0: User::LeaveIfError(wsBitmap->Create(scrSize,EGray4)); sl@0: CFbsBitmap *bitmap=new(ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bitmap); sl@0: sl@0: TheClient->iWs.Finish(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: User::LeaveIfError(bitmap->Create(TSize(30,10),EGray4)); sl@0: // sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap)); sl@0: CheckBitmapL(wsBitmap,TRect(scrSize)); sl@0: // sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap)); sl@0: CheckBitmapL(bitmap,TRect(scrSize)); sl@0: // sl@0: TRect rect1(111,10,222,20); sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap,rect1)); sl@0: CheckBitmapL(wsBitmap,rect1); sl@0: // sl@0: TRect rect2(10,20,100,200); sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,rect2)); sl@0: CheckBitmapL(bitmap,rect2); sl@0: // sl@0: // Now some mad values sl@0: // sl@0: // Right edge left of left edge sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(100,20,90,200))); sl@0: // Off the edge of the screen sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(-10,20,-5,200))); sl@0: // Off the edge of the screen again sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(scrSize.AsPoint()+TPoint(5,5),TSize(10,10)))); sl@0: // sl@0: CleanupStack::PopAndDestroy(3); sl@0: } sl@0: sl@0: sl@0: sl@0: void CTScreenDevice::TestScreenToBitmap() sl@0: { sl@0: TRAPD(ret,doTestScreenToBitmapL()); sl@0: TEST(ret==KErrNone); sl@0: if (ret!=KErrNone) sl@0: INFO_PRINTF3(_L("doTestScreenToBitmapL() return value - Expected: %d, Actual: %d"), KErrNone, ret); sl@0: } sl@0: sl@0: sl@0: CCachePanic::~CCachePanic() sl@0: { sl@0: delete iWsScrDev; sl@0: iWs.Close(); sl@0: } sl@0: sl@0: void CCachePanic::ConstructL(TInt aScreenNumber, TInt aInt) sl@0: { sl@0: iScreenNumber = aScreenNumber; sl@0: iInt = aInt; sl@0: sl@0: User::LeaveIfError(iWs.Connect()); sl@0: iWsScrDev=new(ELeave) CWsScreenDevice(iWs); sl@0: User::LeaveIfError(iWsScrDev->Construct(iScreenNumber)); sl@0: } sl@0: sl@0: TInt CCachePanic::DoTest(CCachePanic* aTestClass) sl@0: { sl@0: CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler; sl@0: CActiveScheduler::Install(activeScheduler); sl@0: CleanupStack::PushL(activeScheduler); sl@0: TRAP_IGNORE(aTestClass->TestL()); sl@0: CleanupStack::PopAndDestroy(activeScheduler); sl@0: return EWsExitReasonFinished; sl@0: } sl@0: sl@0: void CCachePanic::TestL() sl@0: { sl@0: AutoPanic(EAutoPanicTestFailed); sl@0: } sl@0: sl@0: TInt CTwipsPanic::RunTest(TInt aInt, TAny* aPtr) sl@0: { sl@0: TInt error = KErrNone; sl@0: sl@0: CTwipsPanic* self=new(ELeave) CTwipsPanic(); sl@0: CleanupStack::PushL(self); sl@0: sl@0: TRAP(error, self->ConstructL((TInt)aPtr, aInt)); sl@0: if (!error) sl@0: { sl@0: error = CCachePanic::DoTest(self); sl@0: } sl@0: CleanupStack::PopAndDestroy(self); sl@0: return error; sl@0: } sl@0: sl@0: void CTwipsPanic::TestL() sl@0: { sl@0: TPixelsTwipsAndRotation sizeAndRotation; sl@0: TFontSpec fontspec(KTestFontTypefaceName,250); sl@0: sl@0: CFbsFont *font; sl@0: CFbsFont *font2; sl@0: sl@0: iWsScrDev->GetDefaultScreenSizeAndRotation(sizeAndRotation); sl@0: sizeAndRotation.iTwipsSize.iHeight = 2000; sl@0: sizeAndRotation.iTwipsSize.iWidth = 3000; sl@0: iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation); sl@0: iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font,fontspec); sl@0: iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fontspec); sl@0: sizeAndRotation.iTwipsSize.iHeight = 4000; sl@0: sizeAndRotation.iTwipsSize.iWidth = 6000; sl@0: iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation); sl@0: iWsScrDev->ReleaseFont(font); sl@0: } sl@0: sl@0: TInt CScanLinePanic::RunTest(TInt aInt, TAny* aPtr) sl@0: { sl@0: TInt error = KErrNone; sl@0: sl@0: CScanLinePanic* self=new(ELeave) CScanLinePanic(); sl@0: CleanupStack::PushL(self); sl@0: sl@0: TRAP(error, self->ConstructL((TInt)aPtr, aInt)); sl@0: if (!error) sl@0: { sl@0: error = CCachePanic::DoTest(self); sl@0: } sl@0: CleanupStack::PopAndDestroy(self); sl@0: return error; sl@0: } sl@0: sl@0: void CScanLinePanic::TestL() sl@0: { sl@0: switch (iInt) sl@0: { sl@0: case TESTCASE_GRAPHICS_WSERV_0473: sl@0: TestLengthInvariant(); sl@0: break; sl@0: case TESTCASE_GRAPHICS_WSERV_0474: sl@0: TestBufferInvariant(); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CScanLinePanic::TestLengthInvariant() sl@0: { sl@0: TInt buffLength=50; sl@0: TInt length=-1; sl@0: TUint8* buffer=new(ELeave) TUint8[buffLength]; sl@0: TPtr8 scanline(buffer, buffLength, buffLength); sl@0: iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K); sl@0: delete buffer; sl@0: } sl@0: sl@0: void CScanLinePanic::TestBufferInvariant() sl@0: { sl@0: TInt buffLength=19; sl@0: TInt length=10; sl@0: TUint8* buffer=new(ELeave) TUint8[buffLength]; sl@0: TPtr8 scanline(buffer, buffLength, buffLength); sl@0: iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K); sl@0: delete buffer; sl@0: } sl@0: sl@0: void CTScreenDevice::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(++iTest->iState) sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0080 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test twips to pixels conversions sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Converts pixels to twips and then back the result back to pixels. Checks screen size request methods both in pixels and twips sl@0: sl@0: @SYMTestExpectedResults Expects that back and forth conversions preserve an original value. sl@0: */ sl@0: case 1: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0080")); sl@0: iTest->LogSubTest(_L("Screen Device 1")); sl@0: TestTwipPixelConversions(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0081 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Tests CWsScreenDevice::CopyScreenToBitmap method sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Creates a blank window on the screen and uses CWsScreenDevice::CopyScreenToBitmap to copy parts of the screen image to either CWsBitmap or CFbsBitmap sl@0: sl@0: @SYMTestExpectedResults Expects that the method will not fail and that the image is copied correctly making pixel-to-pixel comparisons sl@0: */ sl@0: case 2: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0081")); sl@0: iTest->LogSubTest(_L("Copy Screen To Bitmap")); sl@0: TestScreenToBitmap(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0082 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test for integrity of twips to pixels conversions providing big values sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Calls twips to pixels (and backward) conversions for 100000000 value sl@0: sl@0: @SYMTestExpectedResults Expects that back and forth conversions preserve an original value. Make sure that the result is always greater that 0. sl@0: */ sl@0: case 3: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0082")); sl@0: iTest->LogSubTest(_L("Twip To Pixels Overflow")); sl@0: TestTwipPixelOverflow(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0083 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test that twips-in-pixel ratio change for screen size affects twips-in-pixel ratio of font sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Changes number of twips on screen (leaving number of pixels same), changes number of pixels on screen (leaving number of twips same), makes proportional changes of screen size for both twips and pixels sl@0: sl@0: @SYMTestExpectedResults Expects that twips-in-pixel ratio of font leaves the same only when screen size was changed through multipying of width by a coefficient (same for both twips and pixels) and multipying of height by a coefficient (same for both twips and pixels) sl@0: */ sl@0: case 4: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083")); sl@0: iTest->LogSubTest(_L("Twips cache flush after device size change")); sl@0: TwipsCacheFlushL(); sl@0: break; sl@0: case 5: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083")); sl@0: iTest->LogSubTest(_L("Twips cache reset")); sl@0: // not expecting any panic sl@0: TEST(iTest->TestPanicL(CTwipsPanic::RunTest, 0, 0, (TAny*)iTest->iScreenNumber, _L(""))); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0473 sl@0: sl@0: @SYMDEF DEF116127 sl@0: sl@0: @SYMTestCaseDesc Invariant testing length parameter of less then 0 values in CWsScreenDevice::GetScanLine() sl@0: method sl@0: sl@0: @SYMTestActions Calls CWsScreenDevice::GetScanLine with aLength of -1. sl@0: sl@0: **/ sl@0: case 6: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0473")); sl@0: iTest->LogSubTest(_L("Testing ScanLine length invariant")); sl@0: TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter, sl@0: CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0473, sl@0: (TAny*)iTest->iScreenNumber, _L("WSERV"))); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0474 sl@0: sl@0: @SYMDEF DEF116127 sl@0: sl@0: @SYMTestCaseDesc Invariant testing buffer parameter for required size. sl@0: sl@0: @SYMTestActions Calls CWsScreenDevice::GetScanLine with buffer too small to contain requested data. sl@0: **/ sl@0: case 7: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0474")); sl@0: iTest->LogSubTest(_L("Testing ScanLine buffer invariant")); sl@0: TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter, sl@0: CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0474, sl@0: (TAny*)iTest->iScreenNumber, _L("WSERV"))); sl@0: break; sl@0: default: sl@0: ((CTScreenDeviceStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTScreenDeviceStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: } sl@0: ((CTScreenDeviceStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(ScreenDevice)