windowing/windowserver/tauto/TBLANK.CPP
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Test blank windows
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @test
       
    21  @internalComponent - Internal Symbian test code
       
    22 */
       
    23 
       
    24 
       
    25 #include "TBLANK.H"
       
    26 
       
    27 
       
    28 CBaseWindow::CBaseWindow() : CTWin()
       
    29 	{}
       
    30 
       
    31 void CBaseWindow::ConstructL(CTWinBase &parent)
       
    32 	{
       
    33 	CTWin::ConstructL(parent);
       
    34 	}
       
    35 
       
    36 void CBaseWindow::Draw()
       
    37 	{
       
    38 	iGc->SetBrushColor(iRgb);
       
    39 	iGc->Clear();
       
    40 	}
       
    41 
       
    42 void CBaseWindow::SetColor(const TRgb &aRgb)
       
    43 	{
       
    44 	iRgb=aRgb;
       
    45 	iGc->Activate(iWin);
       
    46 	Draw();
       
    47 	iGc->Deactivate();
       
    48 	}
       
    49 
       
    50 //
       
    51 
       
    52 TInt DestructCallbackBlank(TAny *aParam)
       
    53 	{
       
    54 	((CTBlank *)aParam)->doDestruct();
       
    55 	return(0);
       
    56 	}
       
    57 
       
    58 
       
    59 CTBlank::CTBlank(CTestStep* aStep):
       
    60 	CTWsGraphicsBase(aStep)
       
    61 	{
       
    62 	INFO_PRINTF1(_L("Testing TBlank functions"));
       
    63 	}
       
    64 
       
    65 void CTBlank::doDestruct()
       
    66 	{
       
    67 	BaseWin->SetVisible(ETrue);
       
    68 	TestWin->SetVisible(ETrue);
       
    69 	delete iBaseWin;
       
    70 	delete iTestWin;
       
    71 	iBaseWin = NULL;
       
    72 	iTestWin = NULL;
       
    73 //	CActiveScheduler::Stop();
       
    74 	}
       
    75 
       
    76 CTBlank::~CTBlank()
       
    77 	{
       
    78 	TCallBack callBack(DestructCallbackBlank,this);
       
    79 	TheClient->SetRedrawCancelFunction(callBack);
       
    80 //	CActiveScheduler::Start();
       
    81 	}
       
    82 
       
    83 void CTBlank::ConstructL()
       
    84 	{
       
    85 	BaseWin->SetVisible(EFalse);
       
    86 	TestWin->SetVisible(EFalse);
       
    87 	}
       
    88 
       
    89 void CTBlank::SetColor(const TRgb &aRgb)
       
    90 	{
       
    91 	iTestWin->SetColor(aRgb);
       
    92 	iBaseWin->SetColor(aRgb);
       
    93 	}
       
    94 
       
    95 void CTBlank::InvalidateTestWin(const TRect &aRect)
       
    96 	{
       
    97 	TRect rect(aRect);
       
    98 	rect.Move(iTestWin->BaseWin()->InquireOffset(*(TheClient->iGroup->WinTreeNode())));
       
    99 	CTUser::Splat(TheClient, rect,TRgb(0,0,0));
       
   100 	}
       
   101 
       
   102 void CTBlank::CheckBlankWindows()
       
   103 	{
       
   104 	User::Heap().Check();
       
   105 	CheckRect(iBaseWin,iTestWin,TRect(BaseWin->Size()),_L("CheckBlankWindows - CheckRect(iBaseWin,iTestWin,TRect(BaseWin->Size()) failed"));
       
   106 	}
       
   107 
       
   108 void CTBlank::RunTestCaseL(TInt /*aCurTestCase*/)
       
   109 	{
       
   110 	TSize screenSize;
       
   111 	TInt winWidth;
       
   112 	TInt winHeight;
       
   113 	((CTBlankStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
   114 
       
   115 	switch(++iTest->iState)
       
   116 		{
       
   117 /**
       
   118 @SYMTestCaseID		GRAPHICS-WSERV-0022
       
   119 
       
   120 @SYMDEF             DEF081259
       
   121 
       
   122 @SYMTestCaseDesc    Create a base and test blank windows and invalidate an
       
   123 					area of the test window
       
   124 
       
   125 @SYMTestPriority    High
       
   126 
       
   127 @SYMTestStatus      Implemented
       
   128 
       
   129 @SYMTestActions     Two windows are created and an area of a window is 
       
   130 					invalidated
       
   131 
       
   132 @SYMTestExpectedResults Windows create and invalidate without error
       
   133 */
       
   134 	case 1:
       
   135 		((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0022"));
       
   136 		iTest->LogSubTest(_L("Blank 1"));
       
   137 		screenSize=TheClient->iGroup->Size();
       
   138 		winWidth=(screenSize.iWidth/3)-10;
       
   139 		winHeight=screenSize.iHeight-10;
       
   140 		iBaseWin=new(ELeave) CBaseWindow();
       
   141 		iBaseWin->SetUpL(TPoint(screenSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
       
   142 		iBaseWin->SetColor(TRgb(255,255,255));
       
   143 		iTestWin=new(ELeave) CTBlankWindow();	
       
   144 		iTestWin->SetUpL(TPoint(screenSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);				
       
   145 		SetColor(TRgb::Gray4(2));
       
   146 		InvalidateTestWin(TRect(10,10,50,50));
       
   147 		break;
       
   148 /**
       
   149 @SYMTestCaseID		GRAPHICS-WSERV-0023
       
   150 
       
   151 @SYMDEF             DEF081259
       
   152 
       
   153 @SYMTestCaseDesc    Check that a base blank window is the same as a
       
   154 					test window which has had an area invalidated
       
   155 
       
   156 @SYMTestPriority    High
       
   157 
       
   158 @SYMTestStatus      Implemented
       
   159 
       
   160 @SYMTestActions     Check the test window is the same as the base window 
       
   161 
       
   162 @SYMTestExpectedResults The windows are identical
       
   163 */
       
   164 	case 2:
       
   165 		((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0023"));
       
   166 		iTest->LogSubTest(_L("Check Blank 1"));
       
   167 		CheckBlankWindows();
       
   168 		break;
       
   169 /**
       
   170 @SYMTestCaseID		GRAPHICS-WSERV-0024
       
   171 
       
   172 @SYMDEF             DEF081259
       
   173 
       
   174 @SYMTestCaseDesc    Set a color and invalidate two areas of a test blank
       
   175 					window
       
   176 
       
   177 @SYMTestPriority    High
       
   178 
       
   179 @SYMTestStatus      Implemented
       
   180 
       
   181 @SYMTestActions     Invalidate two areas of a test blank window 
       
   182 
       
   183 @SYMTestExpectedResults The window areas are invalidated without error
       
   184 */
       
   185 	case 3:
       
   186 		((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0024"));
       
   187 		iTest->LogSubTest(_L("Blank 2"));
       
   188 		SetColor(TRgb(0,0,0));
       
   189 		InvalidateTestWin(TRect(1,1,150,20));
       
   190 		InvalidateTestWin(TRect(10,-10,20,90));
       
   191 		break;
       
   192 /**
       
   193 @SYMTestCaseID		GRAPHICS-WSERV-0025
       
   194 
       
   195 @SYMDEF             DEF081259
       
   196 
       
   197 @SYMTestCaseDesc    Check a base blank window is identical to a test 
       
   198 					blank window which has had two areas invalidated
       
   199 
       
   200 @SYMTestPriority    High
       
   201 
       
   202 @SYMTestStatus      Implemented
       
   203 
       
   204 @SYMTestActions     Check the test window is the same as the base window 
       
   205 
       
   206 @SYMTestExpectedResults The windows are identical
       
   207 */
       
   208 	case 4:
       
   209 		((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0025"));
       
   210 		iTest->LogSubTest(_L("Check Blank 2"));
       
   211 		CheckBlankWindows();
       
   212 		break;
       
   213 /**
       
   214 @SYMTestCaseID		GRAPHICS-WSERV-0026
       
   215 
       
   216 @SYMDEF             DEF081259
       
   217 
       
   218 @SYMTestCaseDesc    Set a color and invalidate three areas of a test blank
       
   219 					window
       
   220 
       
   221 @SYMTestPriority    High
       
   222 
       
   223 @SYMTestStatus      Implemented
       
   224 
       
   225 @SYMTestActions     Invalidate three areas of a test blank window 
       
   226 
       
   227 @SYMTestExpectedResults The window areas are invalidated without error
       
   228 */
       
   229 	case 5:
       
   230 		((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0026"));
       
   231 		iTest->LogSubTest(_L("Blank 3"));
       
   232 		SetColor(TRgb(255,255,255));
       
   233 		InvalidateTestWin(TRect(-1000,100,1000,120));
       
   234 		InvalidateTestWin(TRect(1,1,150,20));
       
   235 		InvalidateTestWin(TRect(10,30,20,60));
       
   236 		break;
       
   237 /**
       
   238 @SYMTestCaseID		GRAPHICS-WSERV-0027
       
   239 
       
   240 @@SYMDEF            DEF081259
       
   241 
       
   242 @SYMTestCaseDesc    Check a base blank window is identical to a test 
       
   243 					blank window which has had three areas invalidated
       
   244 
       
   245 @SYMTestPriority    High
       
   246 
       
   247 @SYMTestStatus      Implemented
       
   248 
       
   249 @SYMTestActions     Check the test window is the same as the base window 
       
   250 
       
   251 @SYMTestExpectedResults The windows are identical
       
   252 */
       
   253 	case 6:
       
   254 		((CTBlankStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0027"));
       
   255 		iTest->LogSubTest(_L("Check Blank 3"));
       
   256 		CheckBlankWindows();
       
   257 		delete iBaseWin;
       
   258 		delete iTestWin;
       
   259 		iBaseWin = NULL;
       
   260 		iTestWin = NULL;
       
   261 		break;	
       
   262 	case 7:
       
   263 		((CTBlankStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
   264 		((CTBlankStep*)iStep)->CloseTMSGraphicsStep();
       
   265 		TestComplete();
       
   266 		break;
       
   267 		}
       
   268 	((CTBlankStep*)iStep)->RecordTestResultL();
       
   269 	}
       
   270 
       
   271 __WS_CONSTRUCT_STEP__(Blank)