os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/inc/tgraphicsresourceteststepbase.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-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
#ifndef TGRAPHICSRESOURCETESTSTEPBASE_H
sl@0
    17
#define TGRAPHICSRESOURCETESTSTEPBASE_H
sl@0
    18
sl@0
    19
#include <e32base.h>
sl@0
    20
#include <test/testexecutestepbase.h>
sl@0
    21
#include <test/ttmsgraphicsstep.h>
sl@0
    22
#include <sgresource/sgimage.h>
sl@0
    23
#include "tgraphicsresourcemultiprocessthread.h"
sl@0
    24
sl@0
    25
_LIT(KSgTestGenericPanicCategory, "SGRES");
sl@0
    26
sl@0
    27
/**
sl@0
    28
Default data stride used by RSgImage Create tests. 
sl@0
    29
 */
sl@0
    30
const TInt KCrossImageDataStride = 16;
sl@0
    31
sl@0
    32
const TInt64 KFakeDrawableId = 0xFFFFFFFFFFFFFFFF;
sl@0
    33
sl@0
    34
const TSgImageInfo KSgImageInfo1(TSize(), 0, 0);
sl@0
    35
const TSgImageInfo KSgImageInfo2(TSize(), 0, 0);
sl@0
    36
const TSgDrawableId KFakeSgDrawableId = {0xFFFFFFFFFFFFFFFF};
sl@0
    37
sl@0
    38
const TInt KSecondThreadMinHeapSize = 0x1000;
sl@0
    39
const TInt KSecondThreadMaxHeapSize = 0x5000;
sl@0
    40
sl@0
    41
class CTSgTestStepBase : public CTTMSGraphicsStep
sl@0
    42
	{
sl@0
    43
public:
sl@0
    44
	CTSgTestStepBase(TBool aConformanceTests);
sl@0
    45
	~CTSgTestStepBase();
sl@0
    46
	
sl@0
    47
	// common utility functions
sl@0
    48
	static TBool CompareInfos(TSgImageInfo& info1, TSgImageInfo& info2);
sl@0
    49
	static TInt CreateImageAndReturnCopy(RSgImage& aSgImage);
sl@0
    50
		
sl@0
    51
	// from CTTMSGraphicsStep
sl@0
    52
	inline void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine);
sl@0
    53
	inline void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine);
sl@0
    54
	
sl@0
    55
protected:
sl@0
    56
	// From CTestStep
sl@0
    57
	virtual TVerdict doTestStepPreambleL(); 
sl@0
    58
	virtual TVerdict doTestStepPostambleL();	
sl@0
    59
	
sl@0
    60
	//common utility functions
sl@0
    61
	void CreateImageL(RSgImage& aImage);
sl@0
    62
	TInt CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgProcessTestInfo& aTestInfo);
sl@0
    63
	TInt CreateSecondThreadAndDoTestL(TSgThreadTestInfo aTestInfo);
sl@0
    64
	void CreateSecondThreadAndCheckPanicL(TSgThreadTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName);
sl@0
    65
	void CreateSecondProcessAndCheckPanicL(TSgProcessTestInfo& aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName);
sl@0
    66
	void CallGetPixelFormatsL(TUint32 aUsage);
sl@0
    67
	void TestGetPixelFormatCompatibilityGuaranteesL();
sl@0
    68
	TBool CheckPixelFormatPresent(TSgPixelFormat aPixelFormat);
sl@0
    69
	void TestOpenDriverL();
sl@0
    70
	void TestCloseDriver();
sl@0
    71
	void CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine);
sl@0
    72
sl@0
    73
protected:	
sl@0
    74
	RThread iSecondThread;
sl@0
    75
	TUint32* iDiagonalImageData;
sl@0
    76
	TBool iEnableConformanceTests; //if ETrue runs the conformance tests, otherwise runs the OOM tests
sl@0
    77
private:
sl@0
    78
	RArray<TInt> iPixelFormatArray;
sl@0
    79
	RSgDriver iSgDriver;
sl@0
    80
	};
sl@0
    81
sl@0
    82
/**
sl@0
    83
Utility class that contains the behaviour for second-thread testing.
sl@0
    84
 */
sl@0
    85
class SgTestSecondThread 
sl@0
    86
	{
sl@0
    87
public:
sl@0
    88
	static TInt ThreadMainL(TSgThreadTestInfo* aInfo);
sl@0
    89
	static TInt ThreadStart(TAny* aInfo);
sl@0
    90
sl@0
    91
	//Second Thread Test Functions	
sl@0
    92
	static TInt OpenImage(TSgThreadTestInfo* aInfo, RSgDriver& aSgDriver);
sl@0
    93
	static TInt OpenDrawable(TSgThreadTestInfo* aInfo);
sl@0
    94
	static TInt OpenImageInvalid(TSgThreadTestInfo* aInfo);
sl@0
    95
	static TInt OpenDrawableInvalid(TSgThreadTestInfo* aInfo);
sl@0
    96
	static TInt PanicImageGetInterfaceInvalidHandle(RSgDriver& aSgDriver);
sl@0
    97
	static TInt PanicImageGetInterfaceNoDriver(RSgDriver& aSgDriver);
sl@0
    98
	static TInt PanicImageCloseInvalidHandle(RSgDriver& aSgDriver);
sl@0
    99
	static TInt PanicImageCloseNoDriver(RSgDriver& aSgDriver);
sl@0
   100
	static TInt PanicImageIdInvalidHandle(RSgDriver& aSgDriver);
sl@0
   101
	static TInt PanicImageIdNoDriver(RSgDriver& aSgDriver);
sl@0
   102
	static TInt PanicImageDrawableTypeInvalidHandle(RSgDriver& aSgDriver);
sl@0
   103
	static TInt PanicImageDrawableTypeNoDriver(RSgDriver& aSgDriver);
sl@0
   104
	static TInt PanicImageCreateInvalidHandle(RSgDriver& aSgDriver);
sl@0
   105
	static TInt PanicImageGetInfoInvalidHandle(RSgDriver& aSgDriver);
sl@0
   106
	static TInt PanicImageGetInfoNoDriver(RSgDriver& aSgDriver);
sl@0
   107
	static TInt PanicImageGetAttributeInvalidHandle(RSgDriver& aSgDriver);
sl@0
   108
	static TInt PanicImageGetAttributeNoDriver(RSgDriver& aSgDriver);
sl@0
   109
	static TInt MultipleThreadStressTest(TSgThreadTestInfo* aInfo);
sl@0
   110
	static void PanicAttributeArrayInvalidIndexL();
sl@0
   111
	static void PanicAttributeArrayInvalidIndex2L();
sl@0
   112
	static TInt CreatePassedImageL(RSgImage* aSgImage);
sl@0
   113
	};
sl@0
   114
/**
sl@0
   115
Test Interface used by RSgImage::GetInterface() tests.
sl@0
   116
 */
sl@0
   117
class MTSgImage_Interface
sl@0
   118
	{
sl@0
   119
public:
sl@0
   120
	enum { EInterfaceUid = 0x102858F0 };
sl@0
   121
public:
sl@0
   122
	virtual TAny* DataAddress() const = 0;
sl@0
   123
	virtual TInt DataStride() const = 0;
sl@0
   124
	};
sl@0
   125
sl@0
   126
//common variables and functions
sl@0
   127
const TInt KDiagonalImageSize = 400; //size in pixels
sl@0
   128
const TInt KDiagonalImageDataStride = 400 * 4;
sl@0
   129
sl@0
   130
const TUint16 KCrossImageData[] = {
sl@0
   131
			0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
sl@0
   132
			0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
sl@0
   133
			0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
sl@0
   134
			0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
sl@0
   135
			0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
sl@0
   136
			0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
sl@0
   137
			0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
sl@0
   138
			0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0
sl@0
   139
			};
sl@0
   140
sl@0
   141
#define TESTWITHFILENAMEANDLINENUMBERL(a, f, l) \
sl@0
   142
	{\
sl@0
   143
	testBooleanTrue((a), f, l); \
sl@0
   144
	}
sl@0
   145
sl@0
   146
inline void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine) 
sl@0
   147
	{
sl@0
   148
	MQCTest(aCondition, aFile, aLine);
sl@0
   149
	}
sl@0
   150
sl@0
   151
inline void CTSgTestStepBase::testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine)
sl@0
   152
	{
sl@0
   153
	MQCTestWithErrorCode(aCondition, aErrorCode, aFile, aLine);
sl@0
   154
	}
sl@0
   155
sl@0
   156
_LIT(KSecondProcess, "tgraphicsresourcesecondprocess2.exe");
sl@0
   157
sl@0
   158
_LIT(KSecondThread, "Test_GraphicsResource_SecondThread");
sl@0
   159
_LIT(KSecondThreadSemaphore, "Second Thread Semaphore");
sl@0
   160
sl@0
   161
#endif