egl/egltest/inc/egltestcommonstep.h
changeset 0 5d03bc08d59c
child 26 15986eb6c500
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19 */
       
    20 
       
    21 #ifndef EGLTESTCOMMONSTEP_H
       
    22 #define EGLTESTCOMMONSTEP_H
       
    23 
       
    24 #include <EGL/egl.h>
       
    25 #include <VG/openvg.h>
       
    26 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
    27 #include <sgresource/sgresource.h>
       
    28 #else
       
    29 #include <graphics/sgresource.h>
       
    30 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
       
    31 #include <test/testexecuteserverbase.h>
       
    32 #include <test/ttmsgraphicsstep.h>
       
    33 #include <test/egltestcommonutils.h>
       
    34 #include <test/egltestcommonsession.h>
       
    35 
       
    36 const TInt KDefaultWindowGroupId = 200;
       
    37 const TInt KMaxProcessNumber = 32;
       
    38 const TInt KMaxThreadNumber = 100;
       
    39 const TInt KNumSemaphore = 2;
       
    40 
       
    41 class RWindow;
       
    42 
       
    43 
       
    44 /**
       
    45 Abstract base class for Egl test steps
       
    46 */
       
    47 class CEglTestStep : public CTTMSGraphicsStep
       
    48 	{
       
    49 	friend class EglTestCommonProcess;
       
    50 
       
    51 public:
       
    52 	struct TThreadInfo
       
    53 		{
       
    54 		CEglTestStep*			 iSelf;
       
    55 		TInt 					 iIdx; // << index for example used to identify the thread to semaphores
       
    56 		} iThreadInfos[KMaxThreadNumber];
       
    57 
       
    58 	struct TThreadStatus
       
    59 		{
       
    60 		TThreadStatus();
       
    61 		enum TStatusId{ERendezvous, ELogin, ESize};
       
    62 		RThread			iThread;
       
    63 		TRequestStatus	iStatus[ESize];
       
    64 		};
       
    65 
       
    66 	struct TProcessStatus
       
    67 		{
       
    68 		RProcess		iProcess;
       
    69 		TRequestStatus	iStatus;
       
    70 		} iProcessStatus[KMaxProcessNumber];
       
    71 
       
    72 	// from CTestStep
       
    73 	IMPORT_C TVerdict doTestStepPreambleL();
       
    74 	IMPORT_C TVerdict doTestStepPostambleL();
       
    75 	IMPORT_C virtual ~CEglTestStep();
       
    76     
       
    77 	IMPORT_C void PartialInitialiseL(const TDesC& aStepName);
       
    78 	IMPORT_C void CleanAll();
       
    79 	IMPORT_C void CreateEglSessionL(TInt aIdx=0);
       
    80 	inline CTestEglSession* GetEglSess() {return iEglSess;};
       
    81 	
       
    82 protected:
       
    83 	IMPORT_C  CEglTestStep();
       
    84  
       
    85 	// Initialisation
       
    86 	void SetLoggerForProcessWrapperL();
       
    87 	
       
    88 	// Utility Methods
       
    89 	void HandleMark();
       
    90 	void HandleMarkEnd();
       
    91 	IMPORT_C void OpenWsSessionL(TInt aGroupId);
       
    92 	IMPORT_C void CloseWsSession();
       
    93 	IMPORT_C void ConstructWindowL(RWindow& aWindow, const TRect& aRect);
       
    94     IMPORT_C void PrintUsedPixelConfiguration();
       
    95     IMPORT_C void PrintPixelFormat(TUidPixelFormat aFormat);
       
    96     IMPORT_C void PrintVGImageFormat(VGImageFormat aAttr);
       
    97 
       
    98 	// Multi process test utils
       
    99 	IMPORT_C void Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName);
       
   100 	IMPORT_C void Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName, const TSgDrawableId& aSgId);
       
   101 	IMPORT_C void Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName, const RArray<TSgDrawableId>& aSgIdList);
       
   102 	void CheckProcessStatusL(TInt aIndex, const TRequestStatus& aStatus, const RProcess& aProcess);
       
   103 	inline TInt ImageIndexFromProcessId(TInt aProcess, TInt aImageCount) {return (aProcess % aImageCount);}
       
   104 	
       
   105 	// Multi threaded test utils
       
   106 	IMPORT_C void Test_MultiThreadL(TInt aThreadCount, TBool aWaitForCompletion);
       
   107 	IMPORT_C void Test_MultiThread_WaitL(TBool aCloseThreads, TThreadStatus::TStatusId aStatusId);
       
   108 	void CheckThreadStatusL(TInt aIndex, const TRequestStatus& aStatus, const RThread& aThread);
       
   109 	static TInt ThreadFunction(TAny* aSelf);
       
   110 	void ThreadFunctionL(TThreadInfo& aInfo);
       
   111 
       
   112 	IMPORT_C virtual void doThreadFunctionL(TInt aIdx);
       
   113 	IMPORT_C virtual void doThreadFunctionL(TInt aIdx,const TSgDrawableId& aSgId);
       
   114 	IMPORT_C void Rendezvous(TInt aIdx);
       
   115 	IMPORT_C virtual void doProcessFunctionL(TInt aIdx);
       
   116 	IMPORT_C virtual void doProcessFunctionL(TInt aIdx,const TSgDrawableId& aSgId);
       
   117 
       
   118 	// EGL helpers
       
   119 	IMPORT_C TBool CheckForExtensionL(TInt aExtensions, const TDesC& aExtensionName = KNullDesC);
       
   120 	IMPORT_C void GetDisplayL();
       
   121 	IMPORT_C void TerminateDisplayL();	
       
   122 
       
   123 protected:
       
   124 	// Session object as required for most tests
       
   125 	CTestEglSession* 	iEglSess;
       
   126 
       
   127 	// Whether to output verbose logging
       
   128 	TBool iVerboseLogging;
       
   129 	 
       
   130 	// Whether the test step needs to wait for thread completion during postamble 
       
   131 	TInt  iThreadCount;
       
   132 	TBool iWaitForCompletionOnPostamble;
       
   133 	
       
   134 	// The display is shared between threads.
       
   135 	EGLDisplay	iDisplay;
       
   136 
       
   137 	RSemaphore	iSemaphore[KNumSemaphore];
       
   138 	RArray<TThreadStatus> iThreadStatus;
       
   139 	
       
   140 	// pixel formats the test is run
       
   141 	TUidPixelFormat iSourceFormat;
       
   142 	VGImageFormat iSurfaceFormat;
       
   143 
       
   144 	TInt iProcHandleMark;
       
   145 	TInt iThreadHandleMark;
       
   146 	TInt iProcHandleMarkEnd;
       
   147 	TInt iThreadHandleMarkEnd;
       
   148 
       
   149 	RWsSession iWsSession;
       
   150 	RWindowGroup iWindowGroup;
       
   151 	};
       
   152 	
       
   153 #endif // EGLTESTCOMMONSTEP_H