os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/inc/tgraphicsresourceteststepbase.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsresourceservices/graphicsresourceimplementation/test/inc/tgraphicsresourceteststepbase.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,161 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef TGRAPHICSRESOURCETESTSTEPBASE_H
1.20 +#define TGRAPHICSRESOURCETESTSTEPBASE_H
1.21 +
1.22 +#include <e32base.h>
1.23 +#include <test/testexecutestepbase.h>
1.24 +#include <test/ttmsgraphicsstep.h>
1.25 +#include <sgresource/sgimage.h>
1.26 +#include "tgraphicsresourcemultiprocessthread.h"
1.27 +
1.28 +_LIT(KSgTestGenericPanicCategory, "SGRES");
1.29 +
1.30 +/**
1.31 +Default data stride used by RSgImage Create tests.
1.32 + */
1.33 +const TInt KCrossImageDataStride = 16;
1.34 +
1.35 +const TInt64 KFakeDrawableId = 0xFFFFFFFFFFFFFFFF;
1.36 +
1.37 +const TSgImageInfo KSgImageInfo1(TSize(), 0, 0);
1.38 +const TSgImageInfo KSgImageInfo2(TSize(), 0, 0);
1.39 +const TSgDrawableId KFakeSgDrawableId = {0xFFFFFFFFFFFFFFFF};
1.40 +
1.41 +const TInt KSecondThreadMinHeapSize = 0x1000;
1.42 +const TInt KSecondThreadMaxHeapSize = 0x5000;
1.43 +
1.44 +class CTSgTestStepBase : public CTTMSGraphicsStep
1.45 + {
1.46 +public:
1.47 + CTSgTestStepBase(TBool aConformanceTests);
1.48 + ~CTSgTestStepBase();
1.49 +
1.50 + // common utility functions
1.51 + static TBool CompareInfos(TSgImageInfo& info1, TSgImageInfo& info2);
1.52 + static TInt CreateImageAndReturnCopy(RSgImage& aSgImage);
1.53 +
1.54 + // from CTTMSGraphicsStep
1.55 + inline void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine);
1.56 + inline void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine);
1.57 +
1.58 +protected:
1.59 + // From CTestStep
1.60 + virtual TVerdict doTestStepPreambleL();
1.61 + virtual TVerdict doTestStepPostambleL();
1.62 +
1.63 + //common utility functions
1.64 + void CreateImageL(RSgImage& aImage);
1.65 + TInt CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgProcessTestInfo& aTestInfo);
1.66 + TInt CreateSecondThreadAndDoTestL(TSgThreadTestInfo aTestInfo);
1.67 + void CreateSecondThreadAndCheckPanicL(TSgThreadTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName);
1.68 + void CreateSecondProcessAndCheckPanicL(TSgProcessTestInfo& aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName);
1.69 + void CallGetPixelFormatsL(TUint32 aUsage);
1.70 + void TestGetPixelFormatCompatibilityGuaranteesL();
1.71 + TBool CheckPixelFormatPresent(TSgPixelFormat aPixelFormat);
1.72 + void TestOpenDriverL();
1.73 + void TestCloseDriver();
1.74 + void CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine);
1.75 +
1.76 +protected:
1.77 + RThread iSecondThread;
1.78 + TUint32* iDiagonalImageData;
1.79 + TBool iEnableConformanceTests; //if ETrue runs the conformance tests, otherwise runs the OOM tests
1.80 +private:
1.81 + RArray<TInt> iPixelFormatArray;
1.82 + RSgDriver iSgDriver;
1.83 + };
1.84 +
1.85 +/**
1.86 +Utility class that contains the behaviour for second-thread testing.
1.87 + */
1.88 +class SgTestSecondThread
1.89 + {
1.90 +public:
1.91 + static TInt ThreadMainL(TSgThreadTestInfo* aInfo);
1.92 + static TInt ThreadStart(TAny* aInfo);
1.93 +
1.94 + //Second Thread Test Functions
1.95 + static TInt OpenImage(TSgThreadTestInfo* aInfo, RSgDriver& aSgDriver);
1.96 + static TInt OpenDrawable(TSgThreadTestInfo* aInfo);
1.97 + static TInt OpenImageInvalid(TSgThreadTestInfo* aInfo);
1.98 + static TInt OpenDrawableInvalid(TSgThreadTestInfo* aInfo);
1.99 + static TInt PanicImageGetInterfaceInvalidHandle(RSgDriver& aSgDriver);
1.100 + static TInt PanicImageGetInterfaceNoDriver(RSgDriver& aSgDriver);
1.101 + static TInt PanicImageCloseInvalidHandle(RSgDriver& aSgDriver);
1.102 + static TInt PanicImageCloseNoDriver(RSgDriver& aSgDriver);
1.103 + static TInt PanicImageIdInvalidHandle(RSgDriver& aSgDriver);
1.104 + static TInt PanicImageIdNoDriver(RSgDriver& aSgDriver);
1.105 + static TInt PanicImageDrawableTypeInvalidHandle(RSgDriver& aSgDriver);
1.106 + static TInt PanicImageDrawableTypeNoDriver(RSgDriver& aSgDriver);
1.107 + static TInt PanicImageCreateInvalidHandle(RSgDriver& aSgDriver);
1.108 + static TInt PanicImageGetInfoInvalidHandle(RSgDriver& aSgDriver);
1.109 + static TInt PanicImageGetInfoNoDriver(RSgDriver& aSgDriver);
1.110 + static TInt PanicImageGetAttributeInvalidHandle(RSgDriver& aSgDriver);
1.111 + static TInt PanicImageGetAttributeNoDriver(RSgDriver& aSgDriver);
1.112 + static TInt MultipleThreadStressTest(TSgThreadTestInfo* aInfo);
1.113 + static void PanicAttributeArrayInvalidIndexL();
1.114 + static void PanicAttributeArrayInvalidIndex2L();
1.115 + static TInt CreatePassedImageL(RSgImage* aSgImage);
1.116 + };
1.117 +/**
1.118 +Test Interface used by RSgImage::GetInterface() tests.
1.119 + */
1.120 +class MTSgImage_Interface
1.121 + {
1.122 +public:
1.123 + enum { EInterfaceUid = 0x102858F0 };
1.124 +public:
1.125 + virtual TAny* DataAddress() const = 0;
1.126 + virtual TInt DataStride() const = 0;
1.127 + };
1.128 +
1.129 +//common variables and functions
1.130 +const TInt KDiagonalImageSize = 400; //size in pixels
1.131 +const TInt KDiagonalImageDataStride = 400 * 4;
1.132 +
1.133 +const TUint16 KCrossImageData[] = {
1.134 + 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
1.135 + 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
1.136 + 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
1.137 + 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
1.138 + 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
1.139 + 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
1.140 + 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0,
1.141 + 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0
1.142 + };
1.143 +
1.144 +#define TESTWITHFILENAMEANDLINENUMBERL(a, f, l) \
1.145 + {\
1.146 + testBooleanTrue((a), f, l); \
1.147 + }
1.148 +
1.149 +inline void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine)
1.150 + {
1.151 + MQCTest(aCondition, aFile, aLine);
1.152 + }
1.153 +
1.154 +inline void CTSgTestStepBase::testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine)
1.155 + {
1.156 + MQCTestWithErrorCode(aCondition, aErrorCode, aFile, aLine);
1.157 + }
1.158 +
1.159 +_LIT(KSecondProcess, "tgraphicsresourcesecondprocess2.exe");
1.160 +
1.161 +_LIT(KSecondThread, "Test_GraphicsResource_SecondThread");
1.162 +_LIT(KSecondThreadSemaphore, "Second Thread Semaphore");
1.163 +
1.164 +#endif