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