sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef TGRAPHICSRESOURCETESTSTEPBASE_H sl@0: #define TGRAPHICSRESOURCETESTSTEPBASE_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "tgraphicsresourcemultiprocessthread.h" sl@0: sl@0: _LIT(KSgTestGenericPanicCategory, "SGRES"); sl@0: sl@0: /** sl@0: Default data stride used by RSgImage Create tests. sl@0: */ sl@0: const TInt KCrossImageDataStride = 16; sl@0: sl@0: const TInt64 KFakeDrawableId = 0xFFFFFFFFFFFFFFFF; sl@0: sl@0: const TSgImageInfo KSgImageInfo1(TSize(), 0, 0); sl@0: const TSgImageInfo KSgImageInfo2(TSize(), 0, 0); sl@0: const TSgDrawableId KFakeSgDrawableId = {0xFFFFFFFFFFFFFFFF}; sl@0: sl@0: const TInt KSecondThreadMinHeapSize = 0x1000; sl@0: const TInt KSecondThreadMaxHeapSize = 0x5000; sl@0: sl@0: class CTSgTestStepBase : public CTTMSGraphicsStep sl@0: { sl@0: public: sl@0: CTSgTestStepBase(TBool aConformanceTests); sl@0: ~CTSgTestStepBase(); sl@0: sl@0: // common utility functions sl@0: static TBool CompareInfos(TSgImageInfo& info1, TSgImageInfo& info2); sl@0: static TInt CreateImageAndReturnCopy(RSgImage& aSgImage); sl@0: sl@0: // from CTTMSGraphicsStep sl@0: inline void testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine); sl@0: inline void testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine); sl@0: sl@0: protected: sl@0: // From CTestStep sl@0: virtual TVerdict doTestStepPreambleL(); sl@0: virtual TVerdict doTestStepPostambleL(); sl@0: sl@0: //common utility functions sl@0: void CreateImageL(RSgImage& aImage); sl@0: TInt CreateSecondProcessAndDoTestL(const TDesC &aProcessName, TSgProcessTestInfo& aTestInfo); sl@0: TInt CreateSecondThreadAndDoTestL(TSgThreadTestInfo aTestInfo); sl@0: void CreateSecondThreadAndCheckPanicL(TSgThreadTestInfo aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aThreadName); sl@0: void CreateSecondProcessAndCheckPanicL(TSgProcessTestInfo& aTestInfo, TInt aPanicCode, TExitCategoryName aExitCategory, const TDesC &aProcessName); sl@0: void CallGetPixelFormatsL(TUint32 aUsage); sl@0: void TestGetPixelFormatCompatibilityGuaranteesL(); sl@0: TBool CheckPixelFormatPresent(TSgPixelFormat aPixelFormat); sl@0: void TestOpenDriverL(); sl@0: void TestCloseDriver(); sl@0: void CheckErrorL(TInt aExpectedErrorCode, TInt aActualErrorCode, const TText8* aFile, TInt aLine); sl@0: sl@0: protected: sl@0: RThread iSecondThread; sl@0: TUint32* iDiagonalImageData; sl@0: TBool iEnableConformanceTests; //if ETrue runs the conformance tests, otherwise runs the OOM tests sl@0: private: sl@0: RArray iPixelFormatArray; sl@0: RSgDriver iSgDriver; sl@0: }; sl@0: sl@0: /** sl@0: Utility class that contains the behaviour for second-thread testing. sl@0: */ sl@0: class SgTestSecondThread sl@0: { sl@0: public: sl@0: static TInt ThreadMainL(TSgThreadTestInfo* aInfo); sl@0: static TInt ThreadStart(TAny* aInfo); sl@0: sl@0: //Second Thread Test Functions sl@0: static TInt OpenImage(TSgThreadTestInfo* aInfo, RSgDriver& aSgDriver); sl@0: static TInt OpenDrawable(TSgThreadTestInfo* aInfo); sl@0: static TInt OpenImageInvalid(TSgThreadTestInfo* aInfo); sl@0: static TInt OpenDrawableInvalid(TSgThreadTestInfo* aInfo); sl@0: static TInt PanicImageGetInterfaceInvalidHandle(RSgDriver& aSgDriver); sl@0: static TInt PanicImageGetInterfaceNoDriver(RSgDriver& aSgDriver); sl@0: static TInt PanicImageCloseInvalidHandle(RSgDriver& aSgDriver); sl@0: static TInt PanicImageCloseNoDriver(RSgDriver& aSgDriver); sl@0: static TInt PanicImageIdInvalidHandle(RSgDriver& aSgDriver); sl@0: static TInt PanicImageIdNoDriver(RSgDriver& aSgDriver); sl@0: static TInt PanicImageDrawableTypeInvalidHandle(RSgDriver& aSgDriver); sl@0: static TInt PanicImageDrawableTypeNoDriver(RSgDriver& aSgDriver); sl@0: static TInt PanicImageCreateInvalidHandle(RSgDriver& aSgDriver); sl@0: static TInt PanicImageGetInfoInvalidHandle(RSgDriver& aSgDriver); sl@0: static TInt PanicImageGetInfoNoDriver(RSgDriver& aSgDriver); sl@0: static TInt PanicImageGetAttributeInvalidHandle(RSgDriver& aSgDriver); sl@0: static TInt PanicImageGetAttributeNoDriver(RSgDriver& aSgDriver); sl@0: static TInt MultipleThreadStressTest(TSgThreadTestInfo* aInfo); sl@0: static void PanicAttributeArrayInvalidIndexL(); sl@0: static void PanicAttributeArrayInvalidIndex2L(); sl@0: static TInt CreatePassedImageL(RSgImage* aSgImage); sl@0: }; sl@0: /** sl@0: Test Interface used by RSgImage::GetInterface() tests. sl@0: */ sl@0: class MTSgImage_Interface sl@0: { sl@0: public: sl@0: enum { EInterfaceUid = 0x102858F0 }; sl@0: public: sl@0: virtual TAny* DataAddress() const = 0; sl@0: virtual TInt DataStride() const = 0; sl@0: }; sl@0: sl@0: //common variables and functions sl@0: const TInt KDiagonalImageSize = 400; //size in pixels sl@0: const TInt KDiagonalImageDataStride = 400 * 4; sl@0: sl@0: const TUint16 KCrossImageData[] = { sl@0: 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0, sl@0: 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0, sl@0: 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0, sl@0: 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, sl@0: 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, sl@0: 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000, sl@0: 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0, sl@0: 0x7E0,0x7E0,0x7E0,0x000,0x000,0x7E0,0x7E0,0x7E0 sl@0: }; sl@0: sl@0: #define TESTWITHFILENAMEANDLINENUMBERL(a, f, l) \ sl@0: {\ sl@0: testBooleanTrue((a), f, l); \ sl@0: } sl@0: sl@0: inline void CTSgTestStepBase::testBooleanTrue(TBool aCondition, const TText8* aFile, TInt aLine) sl@0: { sl@0: MQCTest(aCondition, aFile, aLine); sl@0: } sl@0: sl@0: inline void CTSgTestStepBase::testBooleanTrueWithErrorCode(TBool aCondition, TInt aErrorCode, const TText8* aFile, TInt aLine) sl@0: { sl@0: MQCTestWithErrorCode(aCondition, aErrorCode, aFile, aLine); sl@0: } sl@0: sl@0: _LIT(KSecondProcess, "tgraphicsresourcesecondprocess2.exe"); sl@0: sl@0: _LIT(KSecondThread, "Test_GraphicsResource_SecondThread"); sl@0: _LIT(KSecondThreadSemaphore, "Second Thread Semaphore"); sl@0: sl@0: #endif