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: // Test multiple level transparent window 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 "TMulTran.H" sl@0: sl@0: sl@0: LOCAL_D TDisplayMode DisplayMode=EColor64K; sl@0: LOCAL_D TSize WinSize; sl@0: sl@0: static const TRgb KRed=TRgb(255, 0, 0, 128); sl@0: static const TRgb KGreen=TRgb(0, 255, 0, 128); sl@0: static const TRgb KYellow=TRgb(255, 255, 0, 128); sl@0: static const TRgb KBlue=TRgb(0, 0, 255, 128); sl@0: static const TRgb KCyan=TRgb(0, 255, 255, 128); sl@0: sl@0: /*CTransWindow*/ sl@0: sl@0: CTransWindow* CTransWindow::NewL(RPointerArray& aWindows,TRgb aColor,TRect aPos) sl@0: { sl@0: CTransWindow* self=NewL(TheClient->iGroup,aColor,aPos,&DisplayMode); sl@0: aWindows.Insert(self,0); sl@0: return self; sl@0: } sl@0: sl@0: CTransWindow* CTransWindow::NewL(CTWinBase* aParent,TRgb aColor,TRect aPos, TDisplayMode* aDisplayMode) sl@0: { sl@0: CTransWindow* self=new(ELeave) CTransWindow(aColor); sl@0: CleanupStack::PushL(self); sl@0: self->SetUpL(aPos.iTl,aPos.Size(),aParent,*TheClient->iGc,aDisplayMode); sl@0: User::LeaveIfError(self->iError); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: //the following function doesn't activate a window sl@0: CTransWindow* CTransWindow::NewL(CTWinBase* aParent,TRgb aColor,TDisplayMode* aDisplayMode) sl@0: { sl@0: CTransWindow* self=new(ELeave) CTransWindow(aColor); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(*aParent); sl@0: if (aDisplayMode) sl@0: { sl@0: self->BaseWin()->SetRequiredDisplayMode(*aDisplayMode); sl@0: } sl@0: User::LeaveIfError((self->iError) && (self->iError != KErrNotSupported)); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CTransWindow::InitWin() sl@0: { sl@0: AdjustShadow(-1); sl@0: iShadowHight=0; sl@0: iWin.SetShadowDisabled(ETrue); sl@0: iShadowing=EFalse; sl@0: iError = iWin.SetTransparencyAlphaChannel(); sl@0: iWin.SetBackgroundColor(iCol); sl@0: iDrawOpaque=EFalse; sl@0: } sl@0: sl@0: void CTransWindow::ToggleVisibility() sl@0: { sl@0: iVisible=!iVisible; sl@0: SetVisible(iVisible); sl@0: } sl@0: sl@0: void CTransWindow::SetOrdinal(RPointerArray& aWindows,TInt aOldPos,TInt aNewPos) sl@0: { sl@0: CTransWindow* win=aWindows[aOldPos]; sl@0: aWindows.Remove(aOldPos); sl@0: aWindows.Insert(win,aNewPos); sl@0: win->iWin.SetOrdinalPosition(aNewPos); sl@0: } sl@0: sl@0: void CTransWindow::SetShadowDisabled(TBool aState) sl@0: { sl@0: iWin.SetShadowDisabled(aState); sl@0: iShadowing=!aState; sl@0: } sl@0: sl@0: void CTransWindow::AdjustShadow(TInt aAdjust) sl@0: { sl@0: CBlankWindow::AdjustShadow(aAdjust); sl@0: iShadowHight+=aAdjust; sl@0: } sl@0: sl@0: TPoint CTransWindow::Position() const sl@0: { sl@0: return CBlankWindow::Position()+iPosOffset; sl@0: } sl@0: sl@0: void CTransWindow::Draw() sl@0: { sl@0: //don't call CBlankWindow::Draw() since the background is already drawn sl@0: sl@0: if(iDrawOpaque) sl@0: { sl@0: iGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: iGc->SetPenSize(TSize(4,4)); sl@0: iGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: iGc->SetPenColor(~iCol); sl@0: iGc->SetOpaque(ETrue); sl@0: iGc->DrawLine(TPoint(0,0),TPoint(1000,1000)); sl@0: iGc->SetOpaque(EFalse); sl@0: } sl@0: } sl@0: sl@0: /*CTMultipleTrans*/ sl@0: sl@0: CTMultipleTrans::CTMultipleTrans(CTestStep* aStep) : CTWsGraphicsBase(aStep), iWindows(5), iShadows(EFalse) sl@0: { sl@0: } sl@0: sl@0: CTMultipleTrans::~CTMultipleTrans() sl@0: { sl@0: ((CTMultipleTransStep*)iStep)->CloseTMSGraphicsStep(); sl@0: delete iBackgroundWin; sl@0: delete iCheckWin; sl@0: delete iCheckBitmap; sl@0: iWindows.ResetAndDestroy(); sl@0: iBlankWin.Close(); sl@0: } sl@0: sl@0: void CTMultipleTrans::ConstructL() sl@0: { sl@0: if(TransparencySupportedL() == KErrNotSupported) sl@0: return; sl@0: iMajorTest=0; sl@0: const TSize scrSize(TheClient->iScreen->SizeInPixels()); sl@0: WinSize.SetSize(scrSize.iWidth/2,scrSize.iHeight); sl@0: iBackgroundWin=new(ELeave) CTBlankWindow(); sl@0: iBackgroundWin->SetUpL(TPoint(),WinSize,TheClient->iGroup,*TheClient->iGc); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(DisplayMode); sl@0: checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(WinSize.iWidth,0),WinSize); sl@0: iCheckWin=checkWin; sl@0: RBackedUpWindow& backWin=*iCheckWin->BackedUpWin(); sl@0: backWin.SetShadowHeight(0); sl@0: iCheckWin->Activate(); sl@0: backWin.MaintainBackup(); sl@0: iCheckBitmap=CBitmap::NewL(backWin.BitmapHandle()); sl@0: iCheckBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); sl@0: iCheckBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: RecreateWindowsL(); sl@0: iBlankWin=RBlankWindow(TheClient->iWs); sl@0: User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); sl@0: iBlankWinVis=EFalse; sl@0: iBlankWin.SetVisible(iBlankWinVis); sl@0: User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256)); sl@0: iBlankWinCol=TRgb(170,170,170); //Grey sl@0: iBlankWin.SetColor(iBlankWinCol); sl@0: iBlankWin.SetOrdinalPosition(0,1); //Set the priority to 1 so that the 4 main windows are the first 4 with priory 0 sl@0: iBlankWin.Activate(); sl@0: iOpacitySupported=EFalse; sl@0: } sl@0: sl@0: void CTMultipleTrans::ShadowRegion(TRegion& aRegion,TInt aWin) sl@0: { sl@0: TRect rect; sl@0: TInt height; sl@0: TInt window; sl@0: aRegion.Clear(); sl@0: RRegion single; sl@0: RRegion noShadow1; sl@0: RRegion noShadow2; sl@0: RRegion temp; sl@0: RRegion temp2; sl@0: for (window=0;windowGc(); sl@0: gc.SetBrushColor(KRgbWhite); sl@0: gc.DrawRect(TRect(WinSize)); sl@0: TInt windows=iWindows.Count(); sl@0: if (iShadows) sl@0: { sl@0: ShadowRegion(shadowRegion,windows); sl@0: gc.ShadowArea(&shadowRegion); sl@0: } sl@0: TInt window; sl@0: for (window=windows;window>0;) sl@0: { sl@0: CTransWindow& win=*iWindows[--window]; sl@0: if (win.IsVisible()) sl@0: { sl@0: gc.SetBrushColor(win.Color()); sl@0: const TPoint& winTopLeft=win.Position(); sl@0: gc.DrawRect(TRect(winTopLeft, win.Size())); sl@0: sl@0: if(win.DrawOpaque()) sl@0: { sl@0: gc.SetPenColor(~(win.Color())); sl@0: gc.SetPenSize(TSize(4,4)); sl@0: gc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc.SetClippingRect(TRect(TPoint(winTopLeft.iX,winTopLeft.iY),TPoint(winTopLeft.iX + win.Size().iWidth, winTopLeft.iY + win.Size().iHeight))); sl@0: gc.DrawLine(TPoint(winTopLeft.iX,winTopLeft.iY),TPoint(winTopLeft.iX+1000, winTopLeft.iY+1000)); sl@0: gc.SetPenStyle(CGraphicsContext::ENullPen); sl@0: gc.SetClippingRect(TRect(WinSize)); sl@0: } sl@0: sl@0: if (iShadows) sl@0: { sl@0: ShadowRegion(shadowRegion,window); sl@0: gc.ShadowArea(&shadowRegion); sl@0: } sl@0: } sl@0: } sl@0: iCheckWin->BackedUpWin()->UpdateScreen(); sl@0: TheClient->Flush(); sl@0: if (windows>=4) sl@0: { sl@0: AdvancedCheckRect(); sl@0: } sl@0: _LIT(KTest,"Multiple Transparent Test, SubTest %d, OpacityOn=%d"); sl@0: TBuf<128> buf; sl@0: buf.Format(KTest,iTest->iState,iMajorTest); sl@0: CheckRect(iBackgroundWin,iCheckWin,TRect(WinSize),buf); sl@0: shadowRegion.Close(); sl@0: } sl@0: sl@0: #define OFFSET 2 sl@0: void CTMultipleTrans::AdvancedCheckRect() sl@0: { sl@0: const TSize compareSize(5,5); sl@0: const TInt OFFSET2=OFFSET+compareSize.iWidth; sl@0: TPoint comparePos=iCheckWin->Position(); sl@0: TPoint checkPos; sl@0: //Check Single Level for Top Left Win sl@0: checkPos=iTopLeft->Position()+TPoint(OFFSET,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Check Single Level for Top Right Win sl@0: checkPos=iTopRight->Position()+TPoint(iTopRight->Size().iWidth-OFFSET2,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Check Single Level for Bottom Left Win sl@0: checkPos=iBotLeft->Position()+TPoint(OFFSET,iBotLeft->Size().iHeight-OFFSET2); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Check Single Level for Bottom Right Win sl@0: checkPos=iBotRight->Position()+TPoint(iBotRight->Size().iWidth-OFFSET2,iBotRight->Size().iHeight-OFFSET2); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Double level top 2 windows sl@0: checkPos=iTopRight->Position()+TPoint(OFFSET,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Double level left 2 windows sl@0: checkPos=iBotLeft->Position()+TPoint(OFFSET,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Double level bot 2 windows sl@0: checkPos=iBotRight->Position()+TPoint(OFFSET,iBotRight->Size().iHeight-OFFSET2); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Double level right 2 windows sl@0: checkPos=iBotRight->Position()+TPoint(iBotRight->Size().iWidth-OFFSET2,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Triple level all but bot right sl@0: checkPos=iTopRight->Position()+TPoint(OFFSET,iTopRight->Size().iHeight-OFFSET2); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Triple level all but bot left sl@0: checkPos=iBotRight->Position()+TPoint(OFFSET,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Triple level all but top right sl@0: checkPos=iTopLeft->Position()+TPoint(iTopLeft->Size().iWidth-OFFSET2,iTopLeft->Size().iHeight-OFFSET2); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Triple level all but top left sl@0: checkPos=iBotLeft->Position()+TPoint(iBotLeft->Size().iWidth-OFFSET2,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: //Quad level sl@0: checkPos=TPoint(iBotRight->Position().iX,iBotLeft->Position().iY)+TPoint(OFFSET,OFFSET); sl@0: CheckRect(checkPos,checkPos+comparePos,compareSize); sl@0: } sl@0: sl@0: void CTMultipleTrans::SimpleTest() sl@0: { sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::ChangeVisibility() sl@0: { sl@0: TUint toggle; sl@0: TUint toggle2; sl@0: TInt win; sl@0: TInt ii=0; sl@0: for (ii=2;ii>0;--ii) sl@0: { sl@0: for (toggle=1;toggle<16;++toggle) sl@0: { sl@0: win=0; sl@0: toggle2=toggle; sl@0: while ((toggle2&0x1)==0) sl@0: { sl@0: ++win; sl@0: toggle2/=2; sl@0: } sl@0: iWindows[win]->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTMultipleTrans::ChangeVisibility2() sl@0: { sl@0: iBlankWin.SetOrdinalPosition(0,0); sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: CheckDisplay(); sl@0: const TInt xSteps=4; sl@0: const TInt ySteps=3; sl@0: iBlankWinSize.SetSize(WinSize.iWidth/xSteps,WinSize.iHeight/ySteps); sl@0: iBlankWin.SetSize(iBlankWinSize); sl@0: TInt ordPos,xx,yy; sl@0: for (ordPos=0;ordPos<=4;++ordPos) sl@0: { sl@0: iBlankWin.SetOrdinalPosition(ordPos); sl@0: for (xx=0;xx=0;--kk) sl@0: { sl@0: for (jj=3;jj>kk;--jj) sl@0: { sl@0: for (ii=jj;ii>=kk;--ii) sl@0: { sl@0: CTransWindow::SetOrdinal(iWindows,jj,kk); sl@0: CheckDisplay(); sl@0: } sl@0: } sl@0: } sl@0: for (kk=2;kk>=0;--kk) sl@0: { sl@0: for (jj=3;jj>kk;--jj) sl@0: { sl@0: for (ii=jj;ii>=kk;--ii) sl@0: { sl@0: CTransWindow::SetOrdinal(iWindows,kk,jj); sl@0: CheckDisplay(); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: TSize CTMultipleTrans::GetSize(TInt aPos) sl@0: { //Comments show values for 640x240 screen sl@0: const TInt halfSize=40; sl@0: const TPoint topLeft=iTopLeft->Position(); //10,10 sl@0: const TInt xLeft=WinSize.iWidth/2-topLeft.iX-halfSize; //110 sl@0: const TInt xRight=xLeft+2*halfSize; //190 sl@0: const TInt yTop=WinSize.iHeight/2-topLeft.iY-halfSize; //70 sl@0: const TInt yBot=yTop+2*halfSize; //150 sl@0: if (aPos<6) sl@0: return TSize(xLeft+16*aPos-8,yTop); //1->118, 5->182 sl@0: if (aPos<11) sl@0: return TSize(xRight,yTop+16*aPos-88); //6->78, 10->142 sl@0: if (aPos<16) sl@0: return TSize(xRight-16*aPos+168,yBot); //11->182, 15->118 sl@0: return TSize(xLeft,yBot-16*aPos+248); //16->142, 20->78 sl@0: } sl@0: sl@0: void CTMultipleTrans::SizeChange(TInt aJump) sl@0: { sl@0: TInt ii=aJump; sl@0: TSize size; sl@0: while (ii<20) sl@0: { sl@0: size=GetSize(ii); sl@0: iTopLeft->SetSize(size); sl@0: if(iTopLeft->DrawOpaque()) sl@0: { sl@0: iTopLeft->CTWin::DrawNow(); sl@0: TheClient->Flush(); sl@0: } sl@0: CheckDisplay(); sl@0: ii+=aJump; sl@0: if (ii>20) sl@0: ii-=20; sl@0: } sl@0: } sl@0: sl@0: void CTMultipleTrans::SizeChange() sl@0: { sl@0: CTransWindow::SetOrdinal(iWindows,2,1); sl@0: TSize size=iBotLeft->Size(); sl@0: TInt change; sl@0: for (change=70;change>=0;change-=14) sl@0: { sl@0: iBotLeft->SetSize(TSize(size.iWidth-change,size.iHeight)); sl@0: if(iBotLeft->DrawOpaque()) sl@0: { sl@0: iBotLeft->CTWin::DrawNow(); sl@0: TheClient->Flush(); sl@0: } sl@0: CheckDisplay(); sl@0: } sl@0: size=iTopRight->Size(); sl@0: for (change=25;change>-50;change-=14) sl@0: { sl@0: iTopRight->SetSize(TSize(size.iWidth,size.iHeight+change)); sl@0: if(iTopRight->DrawOpaque()) sl@0: { sl@0: iTopRight->CTWin::DrawNow(); sl@0: TheClient->Flush(); sl@0: } sl@0: CheckDisplay(); sl@0: } sl@0: iTopRight->SetSize(size); sl@0: if(iTopRight->DrawOpaque()) sl@0: { sl@0: iTopRight->CTWin::DrawNow(); sl@0: TheClient->Flush(); sl@0: } sl@0: CTransWindow::SetOrdinal(iWindows,1,0); sl@0: CheckDisplay(); sl@0: size=iTopLeft->Size(); sl@0: SizeChange(3); sl@0: iTopLeft->SetSize(size); sl@0: if(iTopLeft->DrawOpaque()) sl@0: { sl@0: iTopLeft->CTWin::DrawNow(); sl@0: TheClient->Flush(); sl@0: } sl@0: CheckDisplay(); sl@0: CTransWindow::SetOrdinal(iWindows,0,2); sl@0: CheckDisplay(); sl@0: SizeChange(7); sl@0: iTopLeft->SetSize(size); sl@0: if(iTopLeft->DrawOpaque()) sl@0: { sl@0: iTopLeft->CTWin::DrawNow(); sl@0: TheClient->Flush(); sl@0: } sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::MoveWin() sl@0: { sl@0: const TPoint topLeftPos=iTopLeft->Position(); sl@0: const TPoint topRightPos=iTopRight->Position(); sl@0: const TPoint botLeftPos=iBotLeft->Position(); sl@0: const TPoint botRightPos=iBotRight->Position(); sl@0: const TInt maxMove=Min(topRightPos.iX,botRightPos.iY)-10; sl@0: TInt steps,move; sl@0: for (steps=2;steps>=0;--steps) sl@0: { sl@0: move=maxMove*(3-steps)/3; sl@0: iTopLeft->SetPos(TPoint(topLeftPos.iX+move,topLeftPos.iY+move)); sl@0: CheckDisplay(); sl@0: iTopRight->SetPos(TPoint(topRightPos.iX-move,topRightPos.iY+move)); sl@0: CheckDisplay(); sl@0: iBotRight->SetPos(TPoint(botRightPos.iX-move,botRightPos.iY-move)); sl@0: CheckDisplay(); sl@0: iBotLeft->SetPos(TPoint(botLeftPos.iX+move,botLeftPos.iY-move)); sl@0: CheckDisplay(); sl@0: } sl@0: for (steps=4;steps>=0;--steps) sl@0: { sl@0: move=maxMove*steps/5; sl@0: iBotLeft->SetPos(TPoint(botLeftPos.iX+move,botLeftPos.iY-move)); sl@0: CheckDisplay(); sl@0: iTopLeft->SetPos(TPoint(topLeftPos.iX+move,topLeftPos.iY+move)); sl@0: CheckDisplay(); sl@0: iBotRight->SetPos(TPoint(botRightPos.iX-move,botRightPos.iY-move)); sl@0: CheckDisplay(); sl@0: iTopRight->SetPos(TPoint(topRightPos.iX-move,topRightPos.iY+move)); sl@0: CheckDisplay(); sl@0: } sl@0: } sl@0: sl@0: void CTMultipleTrans::GroupWinL() sl@0: { sl@0: CTWindowGroup* group=new(ELeave) CTWindowGroup(TheClient); sl@0: CleanupStack::PushL(group); sl@0: group->ConstructL(); sl@0: CTransWindow* win=CTransWindow::NewL(group,KCyan,TRect(40,40,WinSize.iWidth-40,WinSize.iHeight-40),&DisplayMode); sl@0: win->CTWin::DrawNow(); sl@0: if(iMajorTest==1) sl@0: { sl@0: win->SetDrawOpaque(ETrue); sl@0: win->Invalidate(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: } sl@0: iWindows.Insert(win,0); sl@0: CheckDisplay(); sl@0: group->GroupWin()->SetOrdinalPosition(1); sl@0: iWindows.Remove(0); sl@0: CheckDisplay(); sl@0: group->GroupWin()->SetOrdinalPosition(0); sl@0: iWindows.Insert(win,0); sl@0: CheckDisplay(); sl@0: iWindows.Remove(0); sl@0: delete win; //Would be better to delete this after the group window but the test window don't support this behaviour currently. sl@0: CleanupStack::PopAndDestroy(group); sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::FadeTranWin() sl@0: { sl@0: // system fade on sl@0: TheClient->iWs.SetSystemFaded(ETrue); sl@0: // system fade off sl@0: TheClient->iWs.SetSystemFaded(EFalse); sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::StartShadows() sl@0: { sl@0: iShadows=ETrue; sl@0: iTopLeft->SetShadowDisabled(EFalse); sl@0: iTopLeft->AdjustShadow(1); sl@0: iTopRight->SetShadowDisabled(EFalse); sl@0: iTopRight->AdjustShadow(1); sl@0: iBotLeft->SetShadowDisabled(EFalse); sl@0: iBotLeft->AdjustShadow(1); sl@0: iBotRight->SetShadowDisabled(EFalse); sl@0: iBotRight->AdjustShadow(1); sl@0: if(!iOpacitySupported) sl@0: { sl@0: iTopRight->ToggleVisibility(); // In 8.1 this isn't needed. sl@0: iTopRight->ToggleVisibility(); sl@0: } sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::ShadowsOnOff() sl@0: { sl@0: if(!iOpacitySupported) sl@0: return; // In 8.1 this isn't needed. sl@0: iBotRight->SetShadowDisabled(EFalse); sl@0: iBotRight->AdjustShadow(1); sl@0: CheckDisplay(); sl@0: iBotRight->SetShadowDisabled(ETrue); sl@0: CheckDisplay(); sl@0: iTopLeft->SetShadowDisabled(EFalse); sl@0: iTopLeft->AdjustShadow(1); sl@0: CheckDisplay(); sl@0: iTopLeft->SetShadowDisabled(ETrue); sl@0: CheckDisplay(); sl@0: iTopRight->SetShadowDisabled(ETrue); sl@0: CheckDisplay(); sl@0: iBotLeft->SetShadowDisabled(EFalse); sl@0: iBotLeft->AdjustShadow(1); sl@0: CheckDisplay(); sl@0: iBotLeft->SetShadowDisabled(ETrue); sl@0: CheckDisplay(); sl@0: iTopLeft->SetShadowDisabled(EFalse); sl@0: iTopRight->SetShadowDisabled(EFalse); sl@0: iBotLeft->SetShadowDisabled(EFalse); sl@0: iBotRight->SetShadowDisabled(EFalse); sl@0: iTopLeft->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: iTopLeft->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: iTopRight->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: iTopRight->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: iBotLeft->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: iBotLeft->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: iBotRight->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: iBotRight->ToggleVisibility(); sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::StartChildL() sl@0: { sl@0: CTransWindow* win; sl@0: TInt windows=iWindows.Count(); sl@0: TInt window; sl@0: //Delete the first 4 windows from the array, could use ResetAndDestroy but would be broken by other uses of the array sl@0: for (window=windows;window>0;--window) sl@0: { sl@0: win=iWindows[0]; sl@0: iWindows.Remove(0); sl@0: delete win; sl@0: } sl@0: RecreateWindowsL(iBackgroundWin); sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::StartChild2L() sl@0: { sl@0: CTransWindow* win; sl@0: TInt windows=iWindows.Count(); sl@0: TInt window; sl@0: //Delete the first 4 windows from the array, could use ResetAndDestroy but would be broken by other uses of the array sl@0: for (window=windows;window>0;--window) sl@0: { sl@0: win=iWindows[0]; sl@0: iWindows.Remove(0); sl@0: delete win; sl@0: } sl@0: iShadows=EFalse; sl@0: TRect rect=WinSize; sl@0: rect.Shrink(10,10); sl@0: iBotRight=CTransWindow::NewL(iBackgroundWin,KBlue,rect,&DisplayMode); sl@0: iBotRight->CTWin::DrawNow(); sl@0: iWindows.Insert(iBotRight,0); sl@0: CheckDisplay(); sl@0: rect.Resize(-20,-20); sl@0: iTopLeft=CTransWindow::NewL(iBotRight,KRed,rect,&DisplayMode); sl@0: iTopLeft->CTWin::DrawNow(); sl@0: iTopLeft->SetPosOffset(TPoint(10,10)); sl@0: iWindows.Insert(iTopLeft,0); sl@0: CheckDisplay(); sl@0: rect.Resize(-20,-20); sl@0: iTopRight=CTransWindow::NewL(iTopLeft,KGreen,rect,&DisplayMode); sl@0: iTopRight->CTWin::DrawNow(); sl@0: iTopRight->SetPosOffset(TPoint(20,20)); sl@0: iWindows.Insert(iTopRight,0); sl@0: CheckDisplay(); sl@0: rect.Resize(-20,-20); sl@0: iBotLeft=CTransWindow::NewL(iTopRight,KYellow,rect,&DisplayMode); sl@0: iBotLeft->CTWin::DrawNow(); sl@0: iBotLeft->SetPosOffset(TPoint(30,30)); sl@0: iWindows.Insert(iBotLeft,0); sl@0: if(iMajorTest==1) sl@0: { sl@0: for (TInt window = 0; window < iWindows.Count(); ++window) sl@0: { sl@0: iWindows[window]->SetDrawOpaque(ETrue); sl@0: iWindows[window]->Invalidate(); sl@0: } sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: } sl@0: CheckDisplay(); sl@0: } sl@0: sl@0: void CTMultipleTrans::RecreateWindowsL(CTWinBase *aParent) sl@0: { sl@0: CTransWindow* win; sl@0: TInt windows=iWindows.Count(); sl@0: TInt window; sl@0: //Delete existing windows: sl@0: for (window=windows;window>0;--window) sl@0: { sl@0: win=iWindows[0]; sl@0: iWindows.Remove(0); sl@0: delete win; sl@0: } sl@0: sl@0: if(!aParent) sl@0: aParent = TheClient->iGroup; sl@0: sl@0: iBotRight=CTransWindow::NewL(aParent,KBlue,TRect(WinSize.iWidth/2-10,WinSize.iHeight/2-30,WinSize.iWidth-20,WinSize.iHeight-20),&DisplayMode); sl@0: iBotRight->CTWin::DrawNow(); sl@0: iWindows.Insert(iBotRight,0); sl@0: iTopLeft=CTransWindow::NewL(aParent,KRed,TRect(10,10,WinSize.iWidth/2+10,WinSize.iHeight/2+30),&DisplayMode); sl@0: iTopLeft->CTWin::DrawNow(); sl@0: iWindows.Insert(iTopLeft,0); sl@0: iTopRight=CTransWindow::NewL(aParent,KGreen,TRect(WinSize.iWidth/2-30,20,WinSize.iWidth-10,WinSize.iHeight/2+10),&DisplayMode); sl@0: iTopRight->CTWin::DrawNow(); sl@0: iWindows.Insert(iTopRight,0); sl@0: iBotLeft=CTransWindow::NewL(aParent,KYellow,TRect(20,WinSize.iHeight/2-10,WinSize.iWidth/2+30,WinSize.iHeight-10),&DisplayMode); sl@0: iBotLeft->CTWin::DrawNow(); sl@0: iWindows.Insert(iBotLeft,0); sl@0: iShadows=EFalse; sl@0: sl@0: if(iMajorTest==1) sl@0: { sl@0: for (TInt window=0;windowSetDrawOpaque(ETrue); sl@0: iWindows[window]->Invalidate(); sl@0: } sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: } sl@0: } sl@0: sl@0: void CTMultipleTrans::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: _LIT(KCheck,"Check"); sl@0: _LIT(KSimple,"Simple Test"); sl@0: _LIT(KVisibility,"Change Visibility"); sl@0: _LIT(KVisibility2,"Change Visibility 2"); sl@0: _LIT(KOrdinal,"Ordinal Position"); sl@0: _LIT(KSizeChange,"Size Change"); sl@0: _LIT(KMoveWin,"Move Window"); sl@0: _LIT(KGroupWin,"Group Window Ordinal"); sl@0: _LIT(KBackground,"Background Color Changes"); sl@0: _LIT(KShadowsOnOff,"Shadows On Off"); sl@0: _LIT(KChild1,"Child 1"); sl@0: _LIT(KChild2,"Child 2"); sl@0: _LIT(KOpacity,"Opaque Drawing"); sl@0: _LIT(KTranWinFade,"Fading Transparent Windows"); sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: sl@0: switch(iTest->iState) sl@0: { sl@0: case 0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0500 sl@0: */ sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0500")); sl@0: // Check to see if Transparency is enabled before running tests sl@0: iTest->LogSubTest(KCheck); sl@0: if (TransparencySupportedL()==KErrNotSupported) sl@0: { sl@0: LOG_MESSAGE(_L("Transparency is not supported\n")); sl@0: TestComplete(); sl@0: return; sl@0: } sl@0: ++iTest->iState; //Fall Through sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0111 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Simple transparent windows test. sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. sl@0: The test draws the windows on the screen's right side using FBS bitmaps direcly. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 1: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0111")); sl@0: iTest->LogSubTest(KSimple); sl@0: SimpleTest(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0112 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc On/off switching of visibility of transparent windows sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. sl@0: The test toggles visibility of those four windows going through all sl@0: combinations. For each combination it draws visible windows on the screen's right side using FBS bitmaps direcly. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 2: sl@0: case 23: sl@0: case 42: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0112")); sl@0: iTest->LogSubTest(KVisibility); sl@0: ChangeVisibility(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0113 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc On/off switching of visibility of a small transparent window on top of existing transparent windows sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. sl@0: Toggles visibility of 5th blank little window making this appear in different places sl@0: with different ordinal position. Draws visible windows on the screen's right side using FBS bitmaps direcly sl@0: each time when the 5th window becomes invisible. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 3: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0113")); sl@0: iTest->LogSubTest(KVisibility2); sl@0: ChangeVisibility2(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0114 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Ordinal positions' switches of intersecting transparent windows sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. sl@0: Switches ordinal positions of the four windows trying all combinations. Draws visible windows on the screen's right side sl@0: using FBS bitmaps direcly each time when a new combination is applied. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 4: sl@0: case 43: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0114")); sl@0: iTest->LogSubTest(KOrdinal); sl@0: OrdinalPos(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0115 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Changing sizes of intersecting transparent windows sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. sl@0: Plays with sizes of each of the four windows to affect overlapping. sl@0: Draws visible windows on the screen's right side using FBS bitmaps direcly sl@0: each time when a new size for a particular window is applied. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 5: sl@0: case 24: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0115")); sl@0: iTest->LogSubTest(KSizeChange); sl@0: SizeChange(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0116 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Moving intersecting transparent windows sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. sl@0: Performs moves of those windows one by one making little steps in direction of the center of intersection and backwards. sl@0: Draws visible windows on the screen's right side using FBS bitmaps direcly sl@0: each time when a position of a particular window changes. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 6: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0116")); sl@0: iTest->LogSubTest(KMoveWin); sl@0: MoveWin(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0117 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test with a second window group sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow, within the same group) are created before the test on the screen's left side. sl@0: Creates a 5th transparent window in a separate window group sl@0: on top of existing windows which covers the intersection area of initial 4 windows. sl@0: Changes the ordinal position of the group to 1, changes ordinal position sl@0: back to 0, removes the new group. sl@0: Redraws visible windows on the screen's right side using FBS bitmaps direcly sl@0: each time when any change on the screen's left side is performed. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 7: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0117")); sl@0: iTest->LogSubTest(KGroupWin); sl@0: GroupWinL(); sl@0: break; sl@0: case 8: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: iTest->LogSubTest(KBackground); sl@0: //Change the background color of the 4 test windows and the window behind them sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0118 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc On/off switching of fading sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) are created before the test on the screen's left side. sl@0: Switches system fading on and right after that back to off. sl@0: Draws visible windows on the screen's right side using FBS bitmaps direcly sl@0: after that. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 9: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0118")); sl@0: iTest->LogSubTest(KTranWinFade); sl@0: FadeTranWin(); sl@0: break; sl@0: case 10: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: iTest->iState=21-1; sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0120 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Shadows' on/off test. sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. sl@0: The test plays with on/off-switching of shadowing and visibility for the windows. sl@0: The test redraws visible windows on the screen's right side using FBS bitmaps direcly sl@0: each time when state of ony window changes. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: The test also repeats GRAPHICS-WSERV-0111 - GRAPHICS-WSERV-015 foor the shadowed windows. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 22: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0120")); sl@0: iTest->LogSubTest(KShadowsOnOff); sl@0: ShadowsOnOff(); sl@0: break; sl@0: case 25: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: iTest->iState=41-1; sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0121 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Transparent child-windows of a bacground window sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. sl@0: The test removes those windows and creates new four overlapping transparent windows sl@0: but as children of existing background window. After that the test redraws visible windows on the screen's right side using FBS bitmaps direcly. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: The test also repeats GRAPHICS-WSERV-0111 - GRAPHICS-WSERV-014 foor the shadowed windows. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 41: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0121")); sl@0: iTest->LogSubTest(KChild1); sl@0: StartChildL(); sl@0: break; sl@0: case 44: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: iTest->iState=61-1; sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0122 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Four overlapping transparent windows (RWindow) with shadowing enabled are created before the test on the screen's left side. sl@0: The test removes those windows and creates new four transparent windows sl@0: so that each one (except first) is a child of prevoiusly created window. sl@0: The test redraws visible windows on the screen's right side using FBS bitmaps direcly sl@0: after each window's creation. sl@0: The test does nothing if transparency is not enabled on the screen. sl@0: sl@0: @SYMTestExpectedResults Expects that left and rightside bitmaps are identical sl@0: */ sl@0: case 61: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0122")); sl@0: iTest->LogSubTest(KChild2); sl@0: StartChild2L(); sl@0: break; sl@0: default: sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0123")); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0123 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions The test draws four overlapping transparent windows (RWindow) on the screen's left side. sl@0: Each window has an opaque diagonal line (\) which goes from the top-left corner of each window. sl@0: The test repeats all tests from GRAPHICS-WSERV-0111 to GRAPHICS-WSERV-0122 sl@0: with those four windows and diagonaly lines on them. sl@0: sl@0: @SYMTestExpectedResults Expects that all tests will obtain results they expected. sl@0: */ sl@0: if (iMajorTest==1 || !iOpacitySupported) sl@0: { sl@0: if (!iOpacitySupported) sl@0: { sl@0: _LIT(KNoOpacity,"Opacity is not supported"); sl@0: LOG_MESSAGE(KNoOpacity); sl@0: } sl@0: ((CTMultipleTransStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: TestComplete(); sl@0: return; sl@0: } sl@0: LOG_MESSAGE(KOpacity); sl@0: iTest->iState=0; sl@0: iMajorTest=1; sl@0: RecreateWindowsL(); sl@0: break; sl@0: } sl@0: ((CTMultipleTransStep*)iStep)->RecordTestResultL(); sl@0: ++iTest->iState; sl@0: } sl@0: sl@0: sl@0: __WS_CONSTRUCT_STEP__(MultipleTrans)