os/graphics/graphicsdeviceinterface/bitgdi/tbit/TBASE.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) 1997-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
//
sl@0
    15
sl@0
    16
sl@0
    17
#include <e32hal.h>
sl@0
    18
#include "TGDI.H"
sl@0
    19
#include <bitdev.h>
sl@0
    20
#include <hal.h>
sl@0
    21
#include "TBMP.H"
sl@0
    22
#include "tbase.h"
sl@0
    23
#include <graphics/fbsdefs.h>
sl@0
    24
sl@0
    25
sl@0
    26
CTGdi::CTGdi(CTestStep* aStep):
sl@0
    27
	CTGraphicsBase(aStep),
sl@0
    28
	iTestGdi()
sl@0
    29
	{
sl@0
    30
	}
sl@0
    31
sl@0
    32
void CTGdi::RunTestCaseL(TInt aCurTestCase)
sl@0
    33
	{
sl@0
    34
	((CTGdiStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
    35
	switch(aCurTestCase)
sl@0
    36
		{
sl@0
    37
	case 1:
sl@0
    38
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    39
		TestScreenL(EGray2);
sl@0
    40
		break;
sl@0
    41
	case 2:
sl@0
    42
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    43
		TestScreenL(EGray4);
sl@0
    44
		break;
sl@0
    45
	case 3:
sl@0
    46
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    47
		TestScreenL(EGray16);
sl@0
    48
		break;
sl@0
    49
	case 4:
sl@0
    50
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    51
		TestScreenL(EGray256);
sl@0
    52
		break;
sl@0
    53
	case 5:
sl@0
    54
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    55
		TestScreenL(EColor16);
sl@0
    56
		break;
sl@0
    57
	case 6:
sl@0
    58
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    59
		TestScreenL(EColor256);
sl@0
    60
		break;
sl@0
    61
	case 7:
sl@0
    62
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    63
		TestScreenL(EColor4K);
sl@0
    64
		break;
sl@0
    65
	case 8:
sl@0
    66
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    67
		TestScreenL(EColor64K);
sl@0
    68
		break;
sl@0
    69
	case 9:
sl@0
    70
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    71
		TestScreenL(EColor16M);
sl@0
    72
		break;
sl@0
    73
	case 10:
sl@0
    74
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0030"));
sl@0
    75
		TestScreenL(EColor16MU);
sl@0
    76
		break;
sl@0
    77
	case 11:
sl@0
    78
		((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
    79
//		Test still failing, see DEF094106	
sl@0
    80
//		TestScreenL(EColor16MA); 
sl@0
    81
		break;
sl@0
    82
	case 12:
sl@0
    83
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
    84
		TestBitmapL(EGray2);
sl@0
    85
		break;
sl@0
    86
	case 13:
sl@0
    87
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
    88
		TestBitmapL(EGray4);
sl@0
    89
		break;
sl@0
    90
	case 14:
sl@0
    91
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
    92
		TestBitmapL(EGray16);
sl@0
    93
		break;
sl@0
    94
	case 15:
sl@0
    95
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
    96
		TestBitmapL(EGray256);
sl@0
    97
		break;
sl@0
    98
	case 16:
sl@0
    99
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
   100
		TestBitmapL(EColor16);
sl@0
   101
		break;
sl@0
   102
	case 17:
sl@0
   103
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
   104
		TestBitmapL(EColor256);
sl@0
   105
		break;
sl@0
   106
	case 18:
sl@0
   107
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
   108
		TestBitmapL(EColor4K);
sl@0
   109
		break;
sl@0
   110
	case 19:
sl@0
   111
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
   112
		TestBitmapL(EColor64K);
sl@0
   113
		break;
sl@0
   114
	case 20:
sl@0
   115
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
   116
		TestBitmapL(EColor16M);
sl@0
   117
		break;
sl@0
   118
	case 21:
sl@0
   119
		((CTGdiStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0031"));
sl@0
   120
		TestBitmapL(EColor16MU);
sl@0
   121
		break;
sl@0
   122
	case 22:  
sl@0
   123
		((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   124
//		Test still failing, see DEF094106
sl@0
   125
//		TestBitmapL(EColor16MA);
sl@0
   126
		break;
sl@0
   127
	case 23:		
sl@0
   128
		((CTGdiStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
   129
		((CTGdiStep*)iStep)->CloseTMSGraphicsStep();
sl@0
   130
		TestComplete();
sl@0
   131
		break;
sl@0
   132
		}
sl@0
   133
	((CTGdiStep*)iStep)->RecordTestResultL();
sl@0
   134
	//
sl@0
   135
	}
sl@0
   136
sl@0
   137
sl@0
   138
/**
sl@0
   139
  @SYMTestCaseID GRAPHICS-BITGDI-0030
sl@0
   140
 
sl@0
   141
  @SYMDEF             
sl@0
   142
sl@0
   143
  @SYMTestCaseDesc Tests screen creation in various colour modes
sl@0
   144
   
sl@0
   145
  @SYMTestPriority High
sl@0
   146
sl@0
   147
  @SYMTestStatus Implemented
sl@0
   148
sl@0
   149
  @SYMTestActions Creates a screen in a certain colour mode, draws a bitmap on it then destroys it 
sl@0
   150
 
sl@0
   151
  @SYMTestExpectedResults Test should pass
sl@0
   152
*/
sl@0
   153
void CTGdi::TestScreenL(TDisplayMode aDispMode)
sl@0
   154
	{
sl@0
   155
	CFbsScreenDevice* device = NULL;
sl@0
   156
	TRAPD(err,device = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
sl@0
   157
	if (err == KErrNotSupported)
sl@0
   158
		return;
sl@0
   159
	else
sl@0
   160
		User::LeaveIfError(err);
sl@0
   161
	CleanupStack::PushL(device);
sl@0
   162
	device->ChangeScreenDevice(NULL);
sl@0
   163
	device->SetAutoUpdate(ETrue);
sl@0
   164
sl@0
   165
	DoTestAndDeleteL(device,ETrue);
sl@0
   166
	CleanupStack::PopAndDestroy(1,device);
sl@0
   167
	}
sl@0
   168
sl@0
   169
sl@0
   170
/**
sl@0
   171
  @SYMTestCaseID GRAPHICS-BITGDI-0031
sl@0
   172
 
sl@0
   173
  @SYMDEF             
sl@0
   174
sl@0
   175
  @SYMTestCaseDesc Tests bitmap creation in various colour modes
sl@0
   176
   
sl@0
   177
  @SYMTestPriority High
sl@0
   178
sl@0
   179
  @SYMTestStatus Implemented
sl@0
   180
sl@0
   181
  @SYMTestActions Creates a bitmap in a certain colour mode, draws a bitmap on it then destroys it 
sl@0
   182
 
sl@0
   183
  @SYMTestExpectedResults Test should pass
sl@0
   184
*/
sl@0
   185
void CTGdi::TestBitmapL(TDisplayMode aDispMode)
sl@0
   186
	{
sl@0
   187
	CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
sl@0
   188
	CleanupStack::PushL(bitmap);
sl@0
   189
	//Creating a Reference Bitmap of screensize to compare the results
sl@0
   190
	CFbsScreenDevice* qdevice = NULL;
sl@0
   191
	TRAPD(error, qdevice = CFbsScreenDevice::NewL(_L("scdv"),aDispMode));
sl@0
   192
sl@0
   193
	if (error == KErrNotSupported)
sl@0
   194
		{
sl@0
   195
		CleanupStack::PopAndDestroy(bitmap);
sl@0
   196
		return;
sl@0
   197
		}
sl@0
   198
	else
sl@0
   199
		{
sl@0
   200
		User::LeaveIfError(error);
sl@0
   201
		}
sl@0
   202
sl@0
   203
	CleanupStack::PushL(qdevice);
sl@0
   204
	qdevice->SetAutoUpdate(ETrue);
sl@0
   205
	TSize screensize=qdevice->SizeInPixels();
sl@0
   206
	TInt ret = bitmap->Create(screensize,aDispMode);
sl@0
   207
	if (ret == KErrNotSupported)
sl@0
   208
		{
sl@0
   209
		CleanupStack::PopAndDestroy(2,bitmap);
sl@0
   210
		return;
sl@0
   211
		}
sl@0
   212
	else
sl@0
   213
		{
sl@0
   214
		User::LeaveIfError(ret);
sl@0
   215
		}
sl@0
   216
sl@0
   217
	CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(bitmap);
sl@0
   218
	CleanupStack::PushL(device);
sl@0
   219
	DoTestAndDeleteL(device, EFalse);
sl@0
   220
	CleanupStack::PopAndDestroy(3,bitmap);
sl@0
   221
	}
sl@0
   222
sl@0
   223
void CTGdi::DoTestAndDeleteL(CFbsDevice* aDevice,TBool aScreen)
sl@0
   224
	{
sl@0
   225
	CFbsBitGc* gc = NULL;
sl@0
   226
	User::LeaveIfError(aDevice->CreateContext(gc));
sl@0
   227
	CleanupStack::PushL(gc);
sl@0
   228
sl@0
   229
	CFbsFont* font = NULL;
sl@0
   230
	User::LeaveIfError(aDevice->GetNearestFontToDesignHeightInTwips(font,TFontSpec()));
sl@0
   231
	gc->UseFont(font);
sl@0
   232
	aDevice->ReleaseFont(font);
sl@0
   233
sl@0
   234
	CFbsBitmap* bmp = new(ELeave) CFbsBitmap;
sl@0
   235
	CleanupStack::PushL(bmp);
sl@0
   236
	TInt ret = bmp->Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTblank);
sl@0
   237
	User::LeaveIfError(ret);
sl@0
   238
	gc->UseBrushPattern(bmp->Handle());
sl@0
   239
sl@0
   240
	if (aScreen)
sl@0
   241
		INFO_PRINTF2(_L("Gdi screen device testing, mode %d\n"),aDevice->DisplayMode());
sl@0
   242
	else
sl@0
   243
		INFO_PRINTF2(_L("Gdi bitmap device testing, mode %d\n"),aDevice->DisplayMode());
sl@0
   244
sl@0
   245
	TBuf<KFailureSectionNameBufferLength> section;
sl@0
   246
	iTestGdi.Construct(aDevice,gc,section);
sl@0
   247
sl@0
   248
	TBool pass = iTestGdi.Test();
sl@0
   249
sl@0
   250
	if (!pass)
sl@0
   251
		{
sl@0
   252
		INFO_PRINTF2(_L("Gdi device test failed section: %S"),&section);
sl@0
   253
		//Getch();
sl@0
   254
		}
sl@0
   255
	TEST(pass);
sl@0
   256
sl@0
   257
	CleanupStack::PopAndDestroy(2,gc);
sl@0
   258
	}
sl@0
   259
sl@0
   260
//--------------
sl@0
   261
__CONSTRUCT_STEP__(Gdi)
sl@0
   262
sl@0
   263
void CTGdiStep::TestSetupL()
sl@0
   264
	{
sl@0
   265
	FbsStartup();
sl@0
   266
	User::LeaveIfError(RFbsSession::Connect());
sl@0
   267
	}
sl@0
   268
sl@0
   269
void CTGdiStep::TestClose()
sl@0
   270
	{
sl@0
   271
	RFbsSession::Disconnect();
sl@0
   272
	}