windowing/windowserver/test/tauto/TSCRDEV.CPP
author hgs
Tue, 20 Jul 2010 13:27:44 +0300
changeset 121 d72fc2aace31
parent 103 2717213c588a
permissions -rw-r--r--
201027_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
103
hgs
parents:
diff changeset
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     2
// All rights reserved.
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     7
//
hgs
parents:
diff changeset
     8
// Initial Contributors:
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    10
//
hgs
parents:
diff changeset
    11
// Contributors:
hgs
parents:
diff changeset
    12
//
hgs
parents:
diff changeset
    13
// Description:
hgs
parents:
diff changeset
    14
// Screen device test code
hgs
parents:
diff changeset
    15
// 
hgs
parents:
diff changeset
    16
//
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
/**
hgs
parents:
diff changeset
    19
 @file
hgs
parents:
diff changeset
    20
 @test
hgs
parents:
diff changeset
    21
 @internalComponent - Internal Symbian test code
hgs
parents:
diff changeset
    22
*/
hgs
parents:
diff changeset
    23
hgs
parents:
diff changeset
    24
#include "TSCRDEV.H"
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
//Define this to get visible pauses (in test 6: DeviceResSwitchL)
hgs
parents:
diff changeset
    27
//#define VISIBLE_PAUSES
hgs
parents:
diff changeset
    28
hgs
parents:
diff changeset
    29
//Define this to get extra logging which may be useful in tracking down a fail
hgs
parents:
diff changeset
    30
//#define EXTRA_LOGGING
hgs
parents:
diff changeset
    31
hgs
parents:
diff changeset
    32
CTScreenDevice::CTScreenDevice(CTestStep* aStep) : CTWsGraphicsBase(aStep)
hgs
parents:
diff changeset
    33
	{}
hgs
parents:
diff changeset
    34
hgs
parents:
diff changeset
    35
CTScreenDevice::~CTScreenDevice()
hgs
parents:
diff changeset
    36
	{}
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
void CTScreenDevice::ConstructL()
hgs
parents:
diff changeset
    39
	{
hgs
parents:
diff changeset
    40
	//The following is just another test... it doesn't leave any resources for use by the test class AFAICT...
hgs
parents:
diff changeset
    41
	RWsSession aSession;
hgs
parents:
diff changeset
    42
	CWsScreenDevice *device1;
hgs
parents:
diff changeset
    43
	CWsScreenDevice *device2;
hgs
parents:
diff changeset
    44
	CWsScreenDevice *device3;
hgs
parents:
diff changeset
    45
hgs
parents:
diff changeset
    46
	aSession.Connect();
hgs
parents:
diff changeset
    47
	device1=new(ELeave) CWsScreenDevice(aSession);
hgs
parents:
diff changeset
    48
	device1->Construct(iTest->iScreenNumber);
hgs
parents:
diff changeset
    49
	delete device1;
hgs
parents:
diff changeset
    50
	device1=new(ELeave) CWsScreenDevice(aSession);
hgs
parents:
diff changeset
    51
	device1->Construct(iTest->iScreenNumber);
hgs
parents:
diff changeset
    52
	device2=new(ELeave) CWsScreenDevice(aSession);
hgs
parents:
diff changeset
    53
	device2->Construct(iTest->iScreenNumber);
hgs
parents:
diff changeset
    54
	device3=new(ELeave) CWsScreenDevice(aSession);
hgs
parents:
diff changeset
    55
	device3->Construct(iTest->iScreenNumber);
hgs
parents:
diff changeset
    56
	delete device3;
hgs
parents:
diff changeset
    57
	CFbsFont *font;
hgs
parents:
diff changeset
    58
	User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec()));
hgs
parents:
diff changeset
    59
	RWindowGroup group(aSession);
hgs
parents:
diff changeset
    60
	group.Construct(777);
hgs
parents:
diff changeset
    61
	group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier());
hgs
parents:
diff changeset
    62
	RWindow win(aSession);
hgs
parents:
diff changeset
    63
	win.Construct(group,77);
hgs
parents:
diff changeset
    64
	CWindowGc *gc=new(ELeave) CWindowGc(device1);
hgs
parents:
diff changeset
    65
	gc->Construct();
hgs
parents:
diff changeset
    66
	gc->Activate(win);
hgs
parents:
diff changeset
    67
	gc->UseFont(font);
hgs
parents:
diff changeset
    68
	device1->ReleaseFont(font);
hgs
parents:
diff changeset
    69
	aSession.Flush();
hgs
parents:
diff changeset
    70
	delete gc;
hgs
parents:
diff changeset
    71
	win.Close();
hgs
parents:
diff changeset
    72
	group.Close();
hgs
parents:
diff changeset
    73
	delete device1;
hgs
parents:
diff changeset
    74
	delete device2;
hgs
parents:
diff changeset
    75
	aSession.Close();
hgs
parents:
diff changeset
    76
	}
hgs
parents:
diff changeset
    77
hgs
parents:
diff changeset
    78
hgs
parents:
diff changeset
    79
void CTScreenDevice::TestTwipPixelConversions()
hgs
parents:
diff changeset
    80
	{
hgs
parents:
diff changeset
    81
	TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234));
hgs
parents:
diff changeset
    82
	TEST(result==1234);
hgs
parents:
diff changeset
    83
	if (result!=1234)
hgs
parents:
diff changeset
    84
		INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(1234) return value  - Expected: %d, Actual: %d"), 1234, result);
hgs
parents:
diff changeset
    85
hgs
parents:
diff changeset
    86
	result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234));
hgs
parents:
diff changeset
    87
	TEST(result==1234);
hgs
parents:
diff changeset
    88
	if (result!=1234)
hgs
parents:
diff changeset
    89
		INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(1234) return value  - Expected: %d, Actual: %d"), 1234, result);
hgs
parents:
diff changeset
    90
hgs
parents:
diff changeset
    91
	TSize pixels=TheClient->iScreen->SizeInPixels();
hgs
parents:
diff changeset
    92
	TSize twips=TheClient->iScreen->SizeInTwips();
hgs
parents:
diff changeset
    93
	TInt conv=TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth);
hgs
parents:
diff changeset
    94
	TEST(conv==twips.iWidth);
hgs
parents:
diff changeset
    95
	if (conv!=twips.iWidth)
hgs
parents:
diff changeset
    96
		INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(pixels.iWidth) return value  - Expected: %d, Actual: %d"), twips.iWidth, conv);
hgs
parents:
diff changeset
    97
hgs
parents:
diff changeset
    98
	conv=TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight);
hgs
parents:
diff changeset
    99
	TEST(conv==twips.iHeight);
hgs
parents:
diff changeset
   100
	if (conv!=twips.iHeight)
hgs
parents:
diff changeset
   101
		INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(pixels.iHeight) return value  - Expected: %d, Actual: %d"), twips.iHeight, conv);
hgs
parents:
diff changeset
   102
	}
hgs
parents:
diff changeset
   103
hgs
parents:
diff changeset
   104
#define TEST_VALUE 100000000
hgs
parents:
diff changeset
   105
void CTScreenDevice::TestTwipPixelOverflow()
hgs
parents:
diff changeset
   106
	{
hgs
parents:
diff changeset
   107
	TInt result=TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE));
hgs
parents:
diff changeset
   108
	TEST(result==TEST_VALUE);
hgs
parents:
diff changeset
   109
	if (result!=TEST_VALUE)
hgs
parents:
diff changeset
   110
		INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE)) return value  - Expected: %d, Actual: %d"), TEST_VALUE, result);
hgs
parents:
diff changeset
   111
hgs
parents:
diff changeset
   112
	result=TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE));
hgs
parents:
diff changeset
   113
	TEST(result==TEST_VALUE);
hgs
parents:
diff changeset
   114
	if (result!=TEST_VALUE)
hgs
parents:
diff changeset
   115
		INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE)) return value  - Expected: %d, Actual: %d"), TEST_VALUE, result);
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
	result = TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE);
hgs
parents:
diff changeset
   118
	TEST(result>0);
hgs
parents:
diff changeset
   119
	if (!result>0)
hgs
parents:
diff changeset
   120
		INFO_PRINTF3(_L("TheClient->iScreen->HorizontalPixelsToTwips(TEST_VALUE) return value  - Expected: %d less than, Actual: %d"), 0, result);
hgs
parents:
diff changeset
   121
hgs
parents:
diff changeset
   122
	result = TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE);
hgs
parents:
diff changeset
   123
	TEST(result>0);
hgs
parents:
diff changeset
   124
	if (!result>0)
hgs
parents:
diff changeset
   125
		INFO_PRINTF3(_L("TheClient->iScreen->VerticalPixelsToTwips(TEST_VALUE) return value  - Expected: %d less than, Actual: %d"), 0, result);
hgs
parents:
diff changeset
   126
hgs
parents:
diff changeset
   127
	result = TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE);
hgs
parents:
diff changeset
   128
	TEST(result>0);
hgs
parents:
diff changeset
   129
	if (!result>0)
hgs
parents:
diff changeset
   130
		INFO_PRINTF3(_L("TheClient->iScreen->HorizontalTwipsToPixels(TEST_VALUE) return value  - Expected: %d less than, Actual: %d"), 0, result);
hgs
parents:
diff changeset
   131
hgs
parents:
diff changeset
   132
	result = TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE);
hgs
parents:
diff changeset
   133
	TEST(result>0);
hgs
parents:
diff changeset
   134
	if (!result>0)
hgs
parents:
diff changeset
   135
		INFO_PRINTF3(_L("TheClient->iScreen->VerticalTwipsToPixels(TEST_VALUE) return value  - Expected: %d less than, Actual: %d"), 0, result);
hgs
parents:
diff changeset
   136
	}
hgs
parents:
diff changeset
   137
hgs
parents:
diff changeset
   138
void CTScreenDevice::TwipsCacheFlushL()
hgs
parents:
diff changeset
   139
	{
hgs
parents:
diff changeset
   140
	RWsSession session;
hgs
parents:
diff changeset
   141
	CWsScreenDevice* device;
hgs
parents:
diff changeset
   142
	CFont* font;
hgs
parents:
diff changeset
   143
	CFont* font2;
hgs
parents:
diff changeset
   144
	const TFontSpec fontspec(KTestFontTypefaceName,250);
hgs
parents:
diff changeset
   145
	TPixelsTwipsAndRotation sizeAndRotation;
hgs
parents:
diff changeset
   146
hgs
parents:
diff changeset
   147
	// create a CWsScreenDevice instance
hgs
parents:
diff changeset
   148
	User::LeaveIfError(session.Connect());
hgs
parents:
diff changeset
   149
	device=new(ELeave) CWsScreenDevice(session);
hgs
parents:
diff changeset
   150
	device->Construct(iTest->iScreenNumber);
hgs
parents:
diff changeset
   151
hgs
parents:
diff changeset
   152
	// Record a font height for use by latter tests
hgs
parents:
diff changeset
   153
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
hgs
parents:
diff changeset
   154
	const TInt height0=font->HeightInPixels();
hgs
parents:
diff changeset
   155
	device->ReleaseFont(font);
hgs
parents:
diff changeset
   156
hgs
parents:
diff changeset
   157
	// 1. find font with best-matching height in twips,
hgs
parents:
diff changeset
   158
	// 2. change twips size of the screen (leaving pixel-size same),
hgs
parents:
diff changeset
   159
	// 3. find font with best-matching height in twips,
hgs
parents:
diff changeset
   160
	// 4. make sure that the newly found font is not the same as previous and has the different height in pixels
hgs
parents:
diff changeset
   161
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   162
#if defined(EXTRA_LOGGING)
hgs
parents:
diff changeset
   163
	_LIT(KLog1,"Font height: %d for unchanged device.   pixels=%d,%d  twips=%d,%d");
hgs
parents:
diff changeset
   164
	LOG_MESSAGE6(KLog1,height0,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight
hgs
parents:
diff changeset
   165
						,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
hgs
parents:
diff changeset
   166
#endif
hgs
parents:
diff changeset
   167
	sizeAndRotation.iTwipsSize.iHeight=2000;
hgs
parents:
diff changeset
   168
	sizeAndRotation.iTwipsSize.iWidth =3000;
hgs
parents:
diff changeset
   169
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   170
hgs
parents:
diff changeset
   171
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
hgs
parents:
diff changeset
   172
	TInt height=font->HeightInPixels();
hgs
parents:
diff changeset
   173
#if defined(EXTRA_LOGGING)
hgs
parents:
diff changeset
   174
	_LIT(KLog2,"Font height: %d for device with twips set to 2000x3000");
hgs
parents:
diff changeset
   175
	LOG_MESSAGE2(KLog2,height);
hgs
parents:
diff changeset
   176
#endif
hgs
parents:
diff changeset
   177
	TFontSpec returnedSpec=font->FontSpecInTwips();
hgs
parents:
diff changeset
   178
hgs
parents:
diff changeset
   179
	sizeAndRotation.iTwipsSize.iHeight=4000;
hgs
parents:
diff changeset
   180
	sizeAndRotation.iTwipsSize.iWidth =6000;
hgs
parents:
diff changeset
   181
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   182
hgs
parents:
diff changeset
   183
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
hgs
parents:
diff changeset
   184
	TInt height2=font2->HeightInPixels();
hgs
parents:
diff changeset
   185
	TFontSpec returnedSpec2 = font2->FontSpecInTwips();
hgs
parents:
diff changeset
   186
#if defined(EXTRA_LOGGING)
hgs
parents:
diff changeset
   187
	_LIT(KLog3,"Font height: %d for device with twips set to 4000x6000");
hgs
parents:
diff changeset
   188
	LOG_MESSAGE2(KLog3,height2);
hgs
parents:
diff changeset
   189
#endif
hgs
parents:
diff changeset
   190
hgs
parents:
diff changeset
   191
	TEST(font!=font2);
hgs
parents:
diff changeset
   192
	TEST(height!=height2);
hgs
parents:
diff changeset
   193
	_LIT(KLogErrM,"Font Heights in pixels match unexpectantly, height=%d");
hgs
parents:
diff changeset
   194
	if (height==height2)
hgs
parents:
diff changeset
   195
		INFO_PRINTF2(KLogErrM,height);
hgs
parents:
diff changeset
   196
hgs
parents:
diff changeset
   197
	device->ReleaseFont(font2);
hgs
parents:
diff changeset
   198
	device->ReleaseFont(font);
hgs
parents:
diff changeset
   199
hgs
parents:
diff changeset
   200
	// 1. find font with best-matching height in twips,
hgs
parents:
diff changeset
   201
	// 2. change pixel size of the screen (leaving twip-size same),
hgs
parents:
diff changeset
   202
	// 3. find font with best-matching height in twips,
hgs
parents:
diff changeset
   203
	// 4. make sure that the newly found font is not the same as previous and has the different height in pixels
hgs
parents:
diff changeset
   204
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   205
	sizeAndRotation.iPixelSize.iHeight=240;
hgs
parents:
diff changeset
   206
	sizeAndRotation.iPixelSize.iWidth =640;
hgs
parents:
diff changeset
   207
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   208
hgs
parents:
diff changeset
   209
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
hgs
parents:
diff changeset
   210
	height=font->HeightInPixels();
hgs
parents:
diff changeset
   211
	returnedSpec=font->FontSpecInTwips();
hgs
parents:
diff changeset
   212
#if defined(EXTRA_LOGGING)
hgs
parents:
diff changeset
   213
	_LIT(KLog4,"Font height: %d for device with pixels set to 240x640   twips=%d,%d");
hgs
parents:
diff changeset
   214
	LOG_MESSAGE4(KLog4,height,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
hgs
parents:
diff changeset
   215
#endif
hgs
parents:
diff changeset
   216
hgs
parents:
diff changeset
   217
	sizeAndRotation.iPixelSize.iHeight=480;
hgs
parents:
diff changeset
   218
	sizeAndRotation.iPixelSize.iWidth =1280;
hgs
parents:
diff changeset
   219
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   220
hgs
parents:
diff changeset
   221
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
hgs
parents:
diff changeset
   222
	height2=font2->HeightInPixels();
hgs
parents:
diff changeset
   223
	returnedSpec2=font2->FontSpecInTwips();
hgs
parents:
diff changeset
   224
#if defined(EXTRA_LOGGING)
hgs
parents:
diff changeset
   225
	_LIT(KLog5,"Font height: %d for device with pixels set to 480x1280");
hgs
parents:
diff changeset
   226
	LOG_MESSAGE2(KLog5,height2);
hgs
parents:
diff changeset
   227
#endif
hgs
parents:
diff changeset
   228
hgs
parents:
diff changeset
   229
	TEST(font!=font2);
hgs
parents:
diff changeset
   230
	TEST(height!=height2);
hgs
parents:
diff changeset
   231
	if (height==height2)
hgs
parents:
diff changeset
   232
		INFO_PRINTF2(KLogErrM,height);
hgs
parents:
diff changeset
   233
hgs
parents:
diff changeset
   234
	device->ReleaseFont(font2);
hgs
parents:
diff changeset
   235
	device->ReleaseFont(font);
hgs
parents:
diff changeset
   236
hgs
parents:
diff changeset
   237
	// 1. double the width and height of screen in both pixels and twips
hgs
parents:
diff changeset
   238
	// 2. find font with best-matching height in twips,
hgs
parents:
diff changeset
   239
	// 3. make sure that the newly found font is the same as previous and has the same height in pixels
hgs
parents:
diff changeset
   240
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   241
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   242
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
hgs
parents:
diff changeset
   243
	sizeAndRotation.iPixelSize.iHeight*=2;
hgs
parents:
diff changeset
   244
	sizeAndRotation.iPixelSize.iWidth *=2;
hgs
parents:
diff changeset
   245
	sizeAndRotation.iTwipsSize.iHeight*=2;
hgs
parents:
diff changeset
   246
	sizeAndRotation.iTwipsSize.iWidth *=2;
hgs
parents:
diff changeset
   247
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   248
hgs
parents:
diff changeset
   249
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
hgs
parents:
diff changeset
   250
	height2=font2->HeightInPixels();
hgs
parents:
diff changeset
   251
#if defined(EXTRA_LOGGING)
hgs
parents:
diff changeset
   252
	_LIT(KLog6,"Font height: %d for device doubled size.   pixels=%d,%d  twips=%d,%d");
hgs
parents:
diff changeset
   253
	LOG_MESSAGE6(KLog6,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight
hgs
parents:
diff changeset
   254
							,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
hgs
parents:
diff changeset
   255
#endif
hgs
parents:
diff changeset
   256
hgs
parents:
diff changeset
   257
	TEST(font==font2);
hgs
parents:
diff changeset
   258
	TEST(height0==height2);
hgs
parents:
diff changeset
   259
	_LIT(KLogErrD,"Font Heights in pixels don't match, expected=%d, actual=%d");
hgs
parents:
diff changeset
   260
	if (height0!=height2)
hgs
parents:
diff changeset
   261
		INFO_PRINTF3(KLogErrD,height0,height2);
hgs
parents:
diff changeset
   262
hgs
parents:
diff changeset
   263
	device->ReleaseFont(font2);
hgs
parents:
diff changeset
   264
	device->ReleaseFont(font);
hgs
parents:
diff changeset
   265
hgs
parents:
diff changeset
   266
	// 1. swap width and height sizes of screen for both pixels and twips
hgs
parents:
diff changeset
   267
	// 2. find font with best-matching height in twips,
hgs
parents:
diff changeset
   268
	// 3. make sure that the newly found font is the same as previous and has the same height in pixels
hgs
parents:
diff changeset
   269
	device->GetDefaultScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   270
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   271
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec));
hgs
parents:
diff changeset
   272
	TInt swap=sizeAndRotation.iPixelSize.iHeight;
hgs
parents:
diff changeset
   273
	sizeAndRotation.iPixelSize.iHeight=sizeAndRotation.iPixelSize.iWidth;
hgs
parents:
diff changeset
   274
	sizeAndRotation.iPixelSize.iWidth =swap;
hgs
parents:
diff changeset
   275
	swap=sizeAndRotation.iTwipsSize.iHeight;
hgs
parents:
diff changeset
   276
	sizeAndRotation.iTwipsSize.iHeight=sizeAndRotation.iTwipsSize.iWidth;
hgs
parents:
diff changeset
   277
	sizeAndRotation.iTwipsSize.iWidth =swap;
hgs
parents:
diff changeset
   278
	device->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   279
	User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec));
hgs
parents:
diff changeset
   280
	height2 = font2->HeightInPixels();
hgs
parents:
diff changeset
   281
#if defined(EXTRA_LOGGING)
hgs
parents:
diff changeset
   282
	_LIT(KLog7,"Font height: %d for device rotated size.   pixels=%d,%d  twips=%d,%d");
hgs
parents:
diff changeset
   283
	LOG_MESSAGE6(KLog7,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight
hgs
parents:
diff changeset
   284
							,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight);
hgs
parents:
diff changeset
   285
#endif
hgs
parents:
diff changeset
   286
hgs
parents:
diff changeset
   287
	TEST(font==font2);
hgs
parents:
diff changeset
   288
	TEST(height0==height2);
hgs
parents:
diff changeset
   289
	if (height0!=height2)
hgs
parents:
diff changeset
   290
		INFO_PRINTF3(KLogErrD,height0,height2);
hgs
parents:
diff changeset
   291
hgs
parents:
diff changeset
   292
	device->ReleaseFont(font2);
hgs
parents:
diff changeset
   293
	device->ReleaseFont(font);
hgs
parents:
diff changeset
   294
hgs
parents:
diff changeset
   295
	delete device;
hgs
parents:
diff changeset
   296
	session.Close();
hgs
parents:
diff changeset
   297
	}
hgs
parents:
diff changeset
   298
hgs
parents:
diff changeset
   299
void CTScreenDevice::CheckBitmapL(CFbsBitmap *aBitmap, const TRect &aRect)
hgs
parents:
diff changeset
   300
	{
hgs
parents:
diff changeset
   301
	CFbsBitmapDevice *device=CFbsBitmapDevice::NewL(aBitmap);
hgs
parents:
diff changeset
   302
	CleanupStack::PushL(device);
hgs
parents:
diff changeset
   303
	TInt height=Min(aRect.Size().iHeight,aBitmap->SizeInPixels().iHeight);
hgs
parents:
diff changeset
   304
	TInt width=Min(aRect.Size().iWidth,aBitmap->SizeInPixels().iWidth);
hgs
parents:
diff changeset
   305
	TPoint pos(0,0);
hgs
parents:
diff changeset
   306
	TInt bufLen=CFbsBitmap::ScanLineLength(width,EGray4);
hgs
parents:
diff changeset
   307
	TAny *buf1=User::AllocLC(bufLen);
hgs
parents:
diff changeset
   308
	TAny *buf2=User::AllocLC(bufLen);
hgs
parents:
diff changeset
   309
	TPtr8 scanBuf1((TUint8 *)buf1,bufLen);
hgs
parents:
diff changeset
   310
	TPtr8 scanBuf2((TUint8 *)buf2,bufLen);
hgs
parents:
diff changeset
   311
	TInt oddPixels=width%4;
hgs
parents:
diff changeset
   312
	TInt byte1,byte2;
hgs
parents:
diff changeset
   313
	for(;pos.iY<height;pos.iY++)
hgs
parents:
diff changeset
   314
		{
hgs
parents:
diff changeset
   315
		TheClient->iScreen->GetScanLine(scanBuf1,pos+aRect.iTl,width,EGray4);
hgs
parents:
diff changeset
   316
		device->GetScanLine(scanBuf2,pos,width,EGray4);
hgs
parents:
diff changeset
   317
		if (oddPixels>0)
hgs
parents:
diff changeset
   318
			{
hgs
parents:
diff changeset
   319
			byte1=(scanBuf1[bufLen-1]<<(2*(4-oddPixels)))%256;
hgs
parents:
diff changeset
   320
			byte2=(scanBuf2[bufLen-1]<<(2*(4-oddPixels)))%256;
hgs
parents:
diff changeset
   321
			TEST(byte1==byte2);
hgs
parents:
diff changeset
   322
			if (byte1!=byte2)
hgs
parents:
diff changeset
   323
				INFO_PRINTF3(_L("byte1==byte2  - byte1: %d, byte2 Height: %d"), byte1, byte2);
hgs
parents:
diff changeset
   324
hgs
parents:
diff changeset
   325
			scanBuf1=scanBuf1.Left(bufLen-1);
hgs
parents:
diff changeset
   326
			scanBuf2=scanBuf2.Left(bufLen-1);
hgs
parents:
diff changeset
   327
			}
hgs
parents:
diff changeset
   328
		TBool retVal = !scanBuf1.Compare(scanBuf2);
hgs
parents:
diff changeset
   329
		TEST(retVal);
hgs
parents:
diff changeset
   330
		if (!retVal)
hgs
parents:
diff changeset
   331
			INFO_PRINTF3(_L("!scanBuf1.Compare(scanBuf2) return value  - Expected: %d, Actual: %d"), ETrue, retVal);
hgs
parents:
diff changeset
   332
		}
hgs
parents:
diff changeset
   333
	CleanupStack::PopAndDestroy(3);
hgs
parents:
diff changeset
   334
	}
hgs
parents:
diff changeset
   335
hgs
parents:
diff changeset
   336
void CTScreenDevice::doTestScreenToBitmapL()
hgs
parents:
diff changeset
   337
	{
hgs
parents:
diff changeset
   338
	RBlankWindow shieldWin(TheClient->iWs);
hgs
parents:
diff changeset
   339
	shieldWin.Construct(*TheClient->iGroup->GroupWin(),1);
hgs
parents:
diff changeset
   340
	shieldWin.SetOrdinalPosition(0,-1);
hgs
parents:
diff changeset
   341
	shieldWin.SetColor(TRgb::Gray4(1));
hgs
parents:
diff changeset
   342
	shieldWin.Activate();
hgs
parents:
diff changeset
   343
	CleanupStack::PushL(TCleanupItem(CleanUpWindow,&shieldWin));
hgs
parents:
diff changeset
   344
	TSize scrSize(TheClient->iScreen->SizeInPixels());
hgs
parents:
diff changeset
   345
	CWsBitmap *wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
hgs
parents:
diff changeset
   346
	CleanupStack::PushL(wsBitmap);
hgs
parents:
diff changeset
   347
	User::LeaveIfError(wsBitmap->Create(scrSize,EGray4));
hgs
parents:
diff changeset
   348
	CFbsBitmap *bitmap=new(ELeave) CFbsBitmap;
hgs
parents:
diff changeset
   349
	CleanupStack::PushL(bitmap);
hgs
parents:
diff changeset
   350
hgs
parents:
diff changeset
   351
	TheClient->iWs.Finish();
hgs
parents:
diff changeset
   352
	TheClient->WaitForRedrawsToFinish();
hgs
parents:
diff changeset
   353
	
hgs
parents:
diff changeset
   354
	User::LeaveIfError(bitmap->Create(TSize(30,10),EGray4));
hgs
parents:
diff changeset
   355
//
hgs
parents:
diff changeset
   356
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap));
hgs
parents:
diff changeset
   357
	CheckBitmapL(wsBitmap,TRect(scrSize));
hgs
parents:
diff changeset
   358
//
hgs
parents:
diff changeset
   359
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap));
hgs
parents:
diff changeset
   360
	CheckBitmapL(bitmap,TRect(scrSize));
hgs
parents:
diff changeset
   361
//
hgs
parents:
diff changeset
   362
	TRect rect1(111,10,222,20);
hgs
parents:
diff changeset
   363
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(wsBitmap,rect1));
hgs
parents:
diff changeset
   364
	CheckBitmapL(wsBitmap,rect1);
hgs
parents:
diff changeset
   365
//
hgs
parents:
diff changeset
   366
	TRect rect2(10,20,100,200);
hgs
parents:
diff changeset
   367
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,rect2));
hgs
parents:
diff changeset
   368
	CheckBitmapL(bitmap,rect2);
hgs
parents:
diff changeset
   369
//
hgs
parents:
diff changeset
   370
// Now some mad values
hgs
parents:
diff changeset
   371
//
hgs
parents:
diff changeset
   372
// Right edge left of left edge
hgs
parents:
diff changeset
   373
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(100,20,90,200)));
hgs
parents:
diff changeset
   374
// Off the edge of the screen
hgs
parents:
diff changeset
   375
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(-10,20,-5,200)));
hgs
parents:
diff changeset
   376
// Off the edge of the screen again
hgs
parents:
diff changeset
   377
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap,TRect(scrSize.AsPoint()+TPoint(5,5),TSize(10,10))));
hgs
parents:
diff changeset
   378
//
hgs
parents:
diff changeset
   379
	CleanupStack::PopAndDestroy(3);
hgs
parents:
diff changeset
   380
	}
hgs
parents:
diff changeset
   381
hgs
parents:
diff changeset
   382
hgs
parents:
diff changeset
   383
hgs
parents:
diff changeset
   384
void CTScreenDevice::TestScreenToBitmap()
hgs
parents:
diff changeset
   385
	{
hgs
parents:
diff changeset
   386
	TRAPD(ret,doTestScreenToBitmapL());
hgs
parents:
diff changeset
   387
	TEST(ret==KErrNone);
hgs
parents:
diff changeset
   388
	if (ret!=KErrNone)
hgs
parents:
diff changeset
   389
		INFO_PRINTF3(_L("doTestScreenToBitmapL() return value  - Expected: %d, Actual: %d"), KErrNone, ret);
hgs
parents:
diff changeset
   390
	}
hgs
parents:
diff changeset
   391
	
hgs
parents:
diff changeset
   392
hgs
parents:
diff changeset
   393
CCachePanic::~CCachePanic()
hgs
parents:
diff changeset
   394
	{
hgs
parents:
diff changeset
   395
	delete iWsScrDev;
hgs
parents:
diff changeset
   396
	iWs.Close();
hgs
parents:
diff changeset
   397
	}
hgs
parents:
diff changeset
   398
hgs
parents:
diff changeset
   399
void CCachePanic::ConstructL(TInt aScreenNumber, TInt aInt)
hgs
parents:
diff changeset
   400
	{
hgs
parents:
diff changeset
   401
	iScreenNumber = aScreenNumber;
hgs
parents:
diff changeset
   402
	iInt = aInt;
hgs
parents:
diff changeset
   403
hgs
parents:
diff changeset
   404
	User::LeaveIfError(iWs.Connect());
hgs
parents:
diff changeset
   405
	iWsScrDev=new(ELeave) CWsScreenDevice(iWs);
hgs
parents:
diff changeset
   406
	User::LeaveIfError(iWsScrDev->Construct(iScreenNumber));
hgs
parents:
diff changeset
   407
	}
hgs
parents:
diff changeset
   408
hgs
parents:
diff changeset
   409
TInt CCachePanic::DoTest(CCachePanic* aTestClass)
hgs
parents:
diff changeset
   410
	{
hgs
parents:
diff changeset
   411
	CActiveScheduler* activeScheduler=new(ELeave) CActiveScheduler;
hgs
parents:
diff changeset
   412
	CActiveScheduler::Install(activeScheduler);
hgs
parents:
diff changeset
   413
	CleanupStack::PushL(activeScheduler);
hgs
parents:
diff changeset
   414
	TRAP_IGNORE(aTestClass->TestL());
hgs
parents:
diff changeset
   415
	CleanupStack::PopAndDestroy(activeScheduler);
hgs
parents:
diff changeset
   416
	return EWsExitReasonFinished;
hgs
parents:
diff changeset
   417
	}
hgs
parents:
diff changeset
   418
hgs
parents:
diff changeset
   419
void CCachePanic::TestL()
hgs
parents:
diff changeset
   420
	{
hgs
parents:
diff changeset
   421
	AutoPanic(EAutoPanicTestFailed);
hgs
parents:
diff changeset
   422
	}
hgs
parents:
diff changeset
   423
hgs
parents:
diff changeset
   424
TInt CTwipsPanic::RunTest(TInt aInt, TAny* aPtr)
hgs
parents:
diff changeset
   425
	{
hgs
parents:
diff changeset
   426
	TInt error = KErrNone;
hgs
parents:
diff changeset
   427
hgs
parents:
diff changeset
   428
	CTwipsPanic* self=new(ELeave) CTwipsPanic();
hgs
parents:
diff changeset
   429
	CleanupStack::PushL(self);
hgs
parents:
diff changeset
   430
hgs
parents:
diff changeset
   431
	TRAP(error, self->ConstructL((TInt)aPtr, aInt));
hgs
parents:
diff changeset
   432
	if (!error)
hgs
parents:
diff changeset
   433
		{
hgs
parents:
diff changeset
   434
		error = CCachePanic::DoTest(self);
hgs
parents:
diff changeset
   435
		}
hgs
parents:
diff changeset
   436
	CleanupStack::PopAndDestroy(self);
hgs
parents:
diff changeset
   437
	return error;
hgs
parents:
diff changeset
   438
	}
hgs
parents:
diff changeset
   439
hgs
parents:
diff changeset
   440
void CTwipsPanic::TestL()
hgs
parents:
diff changeset
   441
	{
hgs
parents:
diff changeset
   442
	TPixelsTwipsAndRotation sizeAndRotation;
hgs
parents:
diff changeset
   443
	TFontSpec fontspec(KTestFontTypefaceName,250);
hgs
parents:
diff changeset
   444
hgs
parents:
diff changeset
   445
	CFbsFont *font;
hgs
parents:
diff changeset
   446
	CFbsFont *font2;
hgs
parents:
diff changeset
   447
hgs
parents:
diff changeset
   448
	iWsScrDev->GetDefaultScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   449
	sizeAndRotation.iTwipsSize.iHeight = 2000;
hgs
parents:
diff changeset
   450
	sizeAndRotation.iTwipsSize.iWidth  = 3000;
hgs
parents:
diff changeset
   451
	iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   452
	iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font,fontspec);
hgs
parents:
diff changeset
   453
	iWsScrDev->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fontspec);
hgs
parents:
diff changeset
   454
	sizeAndRotation.iTwipsSize.iHeight = 4000;
hgs
parents:
diff changeset
   455
	sizeAndRotation.iTwipsSize.iWidth  = 6000;
hgs
parents:
diff changeset
   456
	iWsScrDev->SetScreenSizeAndRotation(sizeAndRotation);
hgs
parents:
diff changeset
   457
	iWsScrDev->ReleaseFont(font);
hgs
parents:
diff changeset
   458
	}
hgs
parents:
diff changeset
   459
hgs
parents:
diff changeset
   460
TInt CScanLinePanic::RunTest(TInt aInt, TAny* aPtr)
hgs
parents:
diff changeset
   461
	{
hgs
parents:
diff changeset
   462
	TInt error = KErrNone;
hgs
parents:
diff changeset
   463
hgs
parents:
diff changeset
   464
	CScanLinePanic* self=new(ELeave) CScanLinePanic();
hgs
parents:
diff changeset
   465
	CleanupStack::PushL(self);
hgs
parents:
diff changeset
   466
hgs
parents:
diff changeset
   467
	TRAP(error, self->ConstructL((TInt)aPtr, aInt));
hgs
parents:
diff changeset
   468
	if (!error)
hgs
parents:
diff changeset
   469
		{
hgs
parents:
diff changeset
   470
		error = CCachePanic::DoTest(self);
hgs
parents:
diff changeset
   471
		}
hgs
parents:
diff changeset
   472
	CleanupStack::PopAndDestroy(self);
hgs
parents:
diff changeset
   473
	return error;    
hgs
parents:
diff changeset
   474
	}
hgs
parents:
diff changeset
   475
hgs
parents:
diff changeset
   476
void CScanLinePanic::TestL()
hgs
parents:
diff changeset
   477
	{
hgs
parents:
diff changeset
   478
	switch (iInt)
hgs
parents:
diff changeset
   479
		{
hgs
parents:
diff changeset
   480
		case TESTCASE_GRAPHICS_WSERV_0473:
hgs
parents:
diff changeset
   481
			TestLengthInvariant();
hgs
parents:
diff changeset
   482
			break;
hgs
parents:
diff changeset
   483
		case TESTCASE_GRAPHICS_WSERV_0474:
hgs
parents:
diff changeset
   484
			TestBufferInvariant();
hgs
parents:
diff changeset
   485
			break;
hgs
parents:
diff changeset
   486
		}
hgs
parents:
diff changeset
   487
	}
hgs
parents:
diff changeset
   488
hgs
parents:
diff changeset
   489
void CScanLinePanic::TestLengthInvariant()
hgs
parents:
diff changeset
   490
	{
hgs
parents:
diff changeset
   491
	TInt buffLength=50;
hgs
parents:
diff changeset
   492
	TInt length=-1;
hgs
parents:
diff changeset
   493
	TUint8* buffer=new(ELeave) TUint8[buffLength];
hgs
parents:
diff changeset
   494
	TPtr8 scanline(buffer, buffLength, buffLength);
hgs
parents:
diff changeset
   495
	iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K);
hgs
parents:
diff changeset
   496
	delete buffer;    
hgs
parents:
diff changeset
   497
	}
hgs
parents:
diff changeset
   498
hgs
parents:
diff changeset
   499
void CScanLinePanic::TestBufferInvariant()
hgs
parents:
diff changeset
   500
	{
hgs
parents:
diff changeset
   501
	TInt buffLength=19;
hgs
parents:
diff changeset
   502
	TInt length=10;
hgs
parents:
diff changeset
   503
	TUint8* buffer=new(ELeave) TUint8[buffLength];
hgs
parents:
diff changeset
   504
	TPtr8 scanline(buffer, buffLength, buffLength);
hgs
parents:
diff changeset
   505
	iWsScrDev->GetScanLine(scanline, TPoint(), length, EColor64K);
hgs
parents:
diff changeset
   506
	delete buffer;    
hgs
parents:
diff changeset
   507
	}
hgs
parents:
diff changeset
   508
hgs
parents:
diff changeset
   509
void CTScreenDevice::RunTestCaseL(TInt /*aCurTestCase*/)
hgs
parents:
diff changeset
   510
	{
hgs
parents:
diff changeset
   511
	((CTScreenDeviceStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
hgs
parents:
diff changeset
   512
	switch(++iTest->iState)
hgs
parents:
diff changeset
   513
		{
hgs
parents:
diff changeset
   514
/**
hgs
parents:
diff changeset
   515
@SYMTestCaseID		GRAPHICS-WSERV-0080
hgs
parents:
diff changeset
   516
hgs
parents:
diff changeset
   517
@SYMDEF  			DEF081259
hgs
parents:
diff changeset
   518
hgs
parents:
diff changeset
   519
@SYMTestCaseDesc    Test twips to pixels conversions
hgs
parents:
diff changeset
   520
hgs
parents:
diff changeset
   521
@SYMTestPriority    High
hgs
parents:
diff changeset
   522
hgs
parents:
diff changeset
   523
@SYMTestStatus      Implemented
hgs
parents:
diff changeset
   524
hgs
parents:
diff changeset
   525
@SYMTestActions     Converts pixels to twips and then back the result back to pixels. Checks screen size request methods both in pixels and twips
hgs
parents:
diff changeset
   526
hgs
parents:
diff changeset
   527
@SYMTestExpectedResults Expects that back and forth conversions preserve an original value.
hgs
parents:
diff changeset
   528
*/
hgs
parents:
diff changeset
   529
		case 1:
hgs
parents:
diff changeset
   530
			((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0080"));
hgs
parents:
diff changeset
   531
			iTest->LogSubTest(_L("Screen Device 1"));
hgs
parents:
diff changeset
   532
			TestTwipPixelConversions();
hgs
parents:
diff changeset
   533
			break;
hgs
parents:
diff changeset
   534
/**
hgs
parents:
diff changeset
   535
@SYMTestCaseID		GRAPHICS-WSERV-0081
hgs
parents:
diff changeset
   536
hgs
parents:
diff changeset
   537
@SYMDEF  			DEF081259
hgs
parents:
diff changeset
   538
hgs
parents:
diff changeset
   539
@SYMTestCaseDesc    Tests CWsScreenDevice::CopyScreenToBitmap method
hgs
parents:
diff changeset
   540
hgs
parents:
diff changeset
   541
@SYMTestPriority    High
hgs
parents:
diff changeset
   542
hgs
parents:
diff changeset
   543
@SYMTestStatus      Implemented
hgs
parents:
diff changeset
   544
hgs
parents:
diff changeset
   545
@SYMTestActions     Creates a blank window on the screen and uses CWsScreenDevice::CopyScreenToBitmap to copy parts of the screen image to either CWsBitmap or CFbsBitmap
hgs
parents:
diff changeset
   546
hgs
parents:
diff changeset
   547
@SYMTestExpectedResults Expects that the method will not fail and that the image is copied correctly making pixel-to-pixel comparisons
hgs
parents:
diff changeset
   548
*/
hgs
parents:
diff changeset
   549
		case 2:
hgs
parents:
diff changeset
   550
			((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0081"));
hgs
parents:
diff changeset
   551
			iTest->LogSubTest(_L("Copy Screen To Bitmap"));
hgs
parents:
diff changeset
   552
			TestScreenToBitmap();
hgs
parents:
diff changeset
   553
			break;
hgs
parents:
diff changeset
   554
/**
hgs
parents:
diff changeset
   555
@SYMTestCaseID		GRAPHICS-WSERV-0082
hgs
parents:
diff changeset
   556
hgs
parents:
diff changeset
   557
@SYMDEF  			DEF081259
hgs
parents:
diff changeset
   558
hgs
parents:
diff changeset
   559
@SYMTestCaseDesc    Test for integrity of twips to pixels conversions providing big values
hgs
parents:
diff changeset
   560
hgs
parents:
diff changeset
   561
@SYMTestPriority    High
hgs
parents:
diff changeset
   562
hgs
parents:
diff changeset
   563
@SYMTestStatus      Implemented
hgs
parents:
diff changeset
   564
hgs
parents:
diff changeset
   565
@SYMTestActions     Calls twips to pixels (and backward) conversions for 100000000 value
hgs
parents:
diff changeset
   566
hgs
parents:
diff changeset
   567
@SYMTestExpectedResults Expects that back and forth conversions preserve an original value. Make sure that the result is always greater that 0.
hgs
parents:
diff changeset
   568
*/
hgs
parents:
diff changeset
   569
		case 3:
hgs
parents:
diff changeset
   570
			((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0082"));
hgs
parents:
diff changeset
   571
			iTest->LogSubTest(_L("Twip To Pixels Overflow"));
hgs
parents:
diff changeset
   572
			TestTwipPixelOverflow();
hgs
parents:
diff changeset
   573
			break;
hgs
parents:
diff changeset
   574
/**
hgs
parents:
diff changeset
   575
@SYMTestCaseID		GRAPHICS-WSERV-0083
hgs
parents:
diff changeset
   576
hgs
parents:
diff changeset
   577
@SYMDEF  			DEF081259
hgs
parents:
diff changeset
   578
hgs
parents:
diff changeset
   579
@SYMTestCaseDesc    Test that twips-in-pixel ratio change for screen size affects twips-in-pixel ratio of font
hgs
parents:
diff changeset
   580
hgs
parents:
diff changeset
   581
@SYMTestPriority    High
hgs
parents:
diff changeset
   582
hgs
parents:
diff changeset
   583
@SYMTestStatus      Implemented
hgs
parents:
diff changeset
   584
hgs
parents:
diff changeset
   585
@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
hgs
parents:
diff changeset
   586
hgs
parents:
diff changeset
   587
@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)
hgs
parents:
diff changeset
   588
*/
hgs
parents:
diff changeset
   589
		case 4:
hgs
parents:
diff changeset
   590
			((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083"));
hgs
parents:
diff changeset
   591
			iTest->LogSubTest(_L("Twips cache flush after device size change"));
hgs
parents:
diff changeset
   592
			TwipsCacheFlushL();
hgs
parents:
diff changeset
   593
			break;
hgs
parents:
diff changeset
   594
		case 5:
hgs
parents:
diff changeset
   595
			((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0083"));
hgs
parents:
diff changeset
   596
			iTest->LogSubTest(_L("Twips cache reset"));
hgs
parents:
diff changeset
   597
			// not expecting any panic
hgs
parents:
diff changeset
   598
			TEST(iTest->TestPanicL(CTwipsPanic::RunTest, 0, 0, (TAny*)iTest->iScreenNumber, _L("")));
hgs
parents:
diff changeset
   599
			break;
hgs
parents:
diff changeset
   600
/**
hgs
parents:
diff changeset
   601
@SYMTestCaseID      GRAPHICS-WSERV-0473
hgs
parents:
diff changeset
   602
hgs
parents:
diff changeset
   603
@SYMDEF             DEF116127
hgs
parents:
diff changeset
   604
hgs
parents:
diff changeset
   605
@SYMTestCaseDesc    Invariant testing length parameter of less then 0 values in CWsScreenDevice::GetScanLine()
hgs
parents:
diff changeset
   606
					method
hgs
parents:
diff changeset
   607
hgs
parents:
diff changeset
   608
@SYMTestActions     Calls CWsScreenDevice::GetScanLine with aLength of -1.
hgs
parents:
diff changeset
   609
hgs
parents:
diff changeset
   610
**/            
hgs
parents:
diff changeset
   611
		case 6:
hgs
parents:
diff changeset
   612
			((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0473"));
hgs
parents:
diff changeset
   613
			iTest->LogSubTest(_L("Testing ScanLine length invariant"));
hgs
parents:
diff changeset
   614
			TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter, 
hgs
parents:
diff changeset
   615
				 CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0473,
hgs
parents:
diff changeset
   616
				 (TAny*)iTest->iScreenNumber, _L("WSERV")));
hgs
parents:
diff changeset
   617
			break;
hgs
parents:
diff changeset
   618
/**
hgs
parents:
diff changeset
   619
@SYMTestCaseID      GRAPHICS-WSERV-0474
hgs
parents:
diff changeset
   620
hgs
parents:
diff changeset
   621
@SYMDEF             DEF116127
hgs
parents:
diff changeset
   622
hgs
parents:
diff changeset
   623
@SYMTestCaseDesc    Invariant testing buffer parameter for required size.
hgs
parents:
diff changeset
   624
hgs
parents:
diff changeset
   625
@SYMTestActions     Calls CWsScreenDevice::GetScanLine with buffer too small to contain requested data.
hgs
parents:
diff changeset
   626
**/            
hgs
parents:
diff changeset
   627
		case 7:
hgs
parents:
diff changeset
   628
			((CTScreenDeviceStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0474"));
hgs
parents:
diff changeset
   629
			iTest->LogSubTest(_L("Testing ScanLine buffer invariant"));
hgs
parents:
diff changeset
   630
			TEST(iTest->TestPanicL(CScanLinePanic::RunTest, EWservPanicInvalidParameter,
hgs
parents:
diff changeset
   631
				 CScanLinePanic::TESTCASE_GRAPHICS_WSERV_0474,
hgs
parents:
diff changeset
   632
				 (TAny*)iTest->iScreenNumber, _L("WSERV")));
hgs
parents:
diff changeset
   633
			break;
hgs
parents:
diff changeset
   634
		default:
hgs
parents:
diff changeset
   635
			((CTScreenDeviceStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
hgs
parents:
diff changeset
   636
			((CTScreenDeviceStep*)iStep)->CloseTMSGraphicsStep();
hgs
parents:
diff changeset
   637
			TestComplete();
hgs
parents:
diff changeset
   638
		}
hgs
parents:
diff changeset
   639
	((CTScreenDeviceStep*)iStep)->RecordTestResultL();
hgs
parents:
diff changeset
   640
	}
hgs
parents:
diff changeset
   641
hgs
parents:
diff changeset
   642
__WS_CONSTRUCT_STEP__(ScreenDevice)