graphicshwdrivers/surfacemgr/test/inc/tsurfacemanagermultithread.h
changeset 0 5d03bc08d59c
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  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #if !defined(__TSURFACEMANAGERMULTITHREAD_H__)
       
    23 #define __TSURFACEMANAGERMULTITHREAD_H__
       
    24 
       
    25 #include <test/tgraphicsharness.h>
       
    26 #include <graphics/surface.h>
       
    27 #include <graphics/surfacemanager.h>
       
    28 #include "tsmgmultprocessshared.h"
       
    29 
       
    30 /**
       
    31 Enums for passing between the multi-threads within the testing process, 
       
    32 used to define which tests should be run on the sides of other threads.
       
    33 */
       
    34 enum TThreadTestCase
       
    35 	{
       
    36 	ECreateSurfaceMapInfo,
       
    37 	ECreateSurfaceClose,
       
    38 	EOpenCloseSurface,
       
    39 	EOpenKillSurface,
       
    40 	ECreateKillSurface,
       
    41 	EOpenCloseSurfaceMultiThread,
       
    42 	EOpenMapSurfaceInfoMultiThread,
       
    43 	EMapSurfaceInfo,
       
    44 	ECloseSurfaces,
       
    45 	EOpenCloseMapSurfaceInfoMultiThread,
       
    46 	EOpenCloseOpenMultiThread,
       
    47 	ECloseBothSurfaces,
       
    48 	ENoTestCase
       
    49 	};
       
    50 	
       
    51 /**
       
    52 Enums for single test results e.g. OpenSurface
       
    53 */	
       
    54 enum TSingleTestResult
       
    55 	{
       
    56 	EAllZero = 0x00000000,
       
    57 	EOpenSurfaceTestPassed = 0x00000001,
       
    58 	ECloseSurfaceTestPassed = 0x00000010,
       
    59 	EMapSurfaceTestPassed = 0x00000100,
       
    60 	ESurfaceInfoTestPassed = 0x00001000,
       
    61 	ESurfaceInfoTestPassed2 = 0x00004000,
       
    62 	ECreateSurfaceTestPassed = 0x00010000,
       
    63 	EOpenSurfaceTestFailed = 0x00000002,
       
    64 	ECloseSurfaceTestFailed = 0x00000020,
       
    65 	EMapSurfaceTestFailed = 0x00000200,
       
    66 	ESurfaceInfoTestFailed = 0x00002000,
       
    67 	ESurfaceInfoTestFailed2 = 0x00008000,
       
    68 	ECreateSurfaceTestFailed = 0x00020000,
       
    69 	};
       
    70 
       
    71 _LIT(KTSurfaceManagerMultiThreadStep,"TSurfaceManagerMultiThread");
       
    72 
       
    73 
       
    74 /**
       
    75 A class to wrap up the execution in the other threads
       
    76 */
       
    77 class CChildThreadWrapper : public CBase
       
    78 	{
       
    79 public:
       
    80 	CChildThreadWrapper(TAny* aInfo);
       
    81 	CChildThreadWrapper();
       
    82 	~CChildThreadWrapper();
       
    83 	void CreateSurfaceThread();
       
    84 	void MapSurfaceInfo();
       
    85 	void CloseSurface();
       
    86 	void OpenSurface();
       
    87 	void CloseBothSurfaces();
       
    88 public:
       
    89 	RSurfaceManager& iSurfaceManager;
       
    90 	TSurfaceId& iSurfaceId;
       
    91 	TSurfaceId iSurfaceIdNew;
       
    92 	TThreadTestCase iThreadTestCase;
       
    93 	};
       
    94 class CTSurfaceManagerMultiThread : public CTGraphicsBase
       
    95 	{
       
    96 public:
       
    97 	CTSurfaceManagerMultiThread(CTestStep* aStep);
       
    98 	~CTSurfaceManagerMultiThread();
       
    99 	
       
   100 	friend class CChildThreadWrapper;
       
   101 protected:
       
   102 //from 	CTGraphicsStep
       
   103 	virtual void RunTestCaseL(TInt aCurTestCase);
       
   104 private:
       
   105 	void TestAccessSurfaceWithoutOpeningL();
       
   106 	void TestCloseSurfaceWithoutOpeningL();
       
   107 	void TestAccessSurfaceClosedThreadL();
       
   108 	void TestCloseSurfaceClosedThreadL();
       
   109 	void TestAccessSurfaceOpenedClosedThreadL();
       
   110 	void TestCloseSurfaceOpenedClosedThreadL();
       
   111 	void TestAccessSurfaceOpenedKilledThreadL();
       
   112 	void TestCloseSurfaceOpenedKilledThreadL();
       
   113 	void TestAccessSurfaceCreateKilledThreadL();
       
   114 	void TestCloseSurfaceCreateKilledThreadL();
       
   115 	void TestAccessSurfaceThreeThreadsL();
       
   116 	void TestAccessSurfaceDieCloseOtherThreadsL();
       
   117 	void TestOpenSurfaceDieCloseOtherThreadsL();
       
   118 	void TestAccessSurfaceInExistingSharedChunkL();
       
   119 	void TestCloseSurfaceExistingSharedChunkL();
       
   120 	
       
   121 	static void CloseSurfaceWhenLeave(TAny* aSurfaceId) ;
       
   122 public:
       
   123 /**
       
   124 Information to be passed into the rendering threads
       
   125 */
       
   126 struct TInfo
       
   127 	{
       
   128 	RSurfaceManager iSurfaceManager;
       
   129 	TSurfaceId iSurfaceId;
       
   130 	TSurfaceId iSurfaceIdNew;
       
   131 	TThreadTestCase iThreadTestCase;
       
   132 	};
       
   133 	
       
   134 	static TInt ThreadSecondStart(TAny* aInfo);
       
   135 	static TInt ThreadThirdStart(TAny* aInfo);
       
   136 
       
   137 private:
       
   138 	RSurfaceManager iSurfaceManager;
       
   139 	TSurfaceId iSurfaceId;
       
   140 	TSurfaceId iSurfaceIdNew;
       
   141 	TInfo iInfo;
       
   142 	TInfo iInfo2;
       
   143 	
       
   144 	};
       
   145 
       
   146 	
       
   147 class CTSurfaceManagerMultiThreadStep : public CTGraphicsStep
       
   148 	{
       
   149 public:
       
   150 	CTSurfaceManagerMultiThreadStep();
       
   151 protected:	
       
   152 	//from CTGraphicsStep
       
   153 	virtual CTGraphicsBase* CreateTestL();
       
   154 	virtual void TestSetupL();
       
   155 	virtual void TestClose();
       
   156 	};
       
   157 
       
   158 
       
   159 _LIT(KMultiThreadSemaphore, "Multi Thread Semaphore");
       
   160 _LIT(KMainThreadSemaphore, "Main Thread Semaphore");
       
   161 
       
   162 #endif