graphicshwdrivers/surfacemgr/test/inc/tsmgmultprocessshared.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 // surface manager API
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __SHARED_H__
       
    19 #define __SHARED_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <e32cmn.h>
       
    23 #include <graphics/surface.h>
       
    24 #include <graphics/surfacemanager.h>
       
    25 #include <test/tgraphicsharness.h>
       
    26 
       
    27 struct TLeaveInfo
       
    28 	{
       
    29 	RSurfaceManager iSurfaceManager;
       
    30 	TSurfaceId iSurfaceId;
       
    31 	};
       
    32 
       
    33 static void CloseSurfaceWhenLeave(TAny* aInfo)
       
    34 	{
       
    35 	TInt err = ((TLeaveInfo*)aInfo)->iSurfaceManager.CloseSurface(((TLeaveInfo*)aInfo)->iSurfaceId);
       
    36 	if (err != KErrNone)
       
    37 		RDebug::Print(_L("Error closing surface = %d\n"),err);	
       
    38 	};
       
    39  
       
    40 
       
    41 /**
       
    42 Enum for the slots for inter-process communication
       
    43 */
       
    44 enum TIPCSlot
       
    45 	{
       
    46 	EMultiProcessFirstSlot = 0,
       
    47 	EMultiProcessSecondSlot,
       
    48 	EMultiProcessThirdSlot,
       
    49 	EMultiProcessFourthSlot,
       
    50 	};
       
    51 
       
    52 /**
       
    53 Enums for passing between the test process and the second process used in testing,
       
    54 used to define which test should be run on the side of the second process.
       
    55 */
       
    56 enum TMultiProcessTestCase
       
    57 	{
       
    58 	// Second process opcodes
       
    59 	ETestOpenReceivedSurface,
       
    60 	ETestInfoReceivedSurface,
       
    61 	ETestOpenSurfaceInvalidParams,
       
    62 	ECreateWaitKill,
       
    63 	EOpenClose,
       
    64 	EMapSurfaceInfoCantAccess,
       
    65 	EOpenWaitMap,
       
    66 	EReadFromBuffer,
       
    67 	ECheckHandle,
       
    68 	ESyncOperation,
       
    69 	ETestChannelMultiProcess1,
       
    70 	ETestChannelMultiProcess2,
       
    71 	EGetSurfaceHint,
       
    72 	ESetSurfaceHint,
       
    73 	EAddSurfaceHint,
       
    74 	ECheckOutofMemory,
       
    75 	// Third process opcodes
       
    76 	ECloseSurface = 0x00010000,
       
    77 	EOpenWaitCloseOpen,
       
    78 	EOpenSurface,
       
    79 	ESurfaceInfo
       
    80 	};
       
    81 
       
    82 /**
       
    83 Enums for panics between my testing process and my second process
       
    84 */
       
    85 enum TCrossProcessPanics
       
    86 	{
       
    87 	EInvalidTestCase,
       
    88 	};
       
    89 
       
    90 /**
       
    91 Enums for the test results
       
    92 */
       
    93 enum TTestResult
       
    94 	{
       
    95 	EFirstTestPassed = 0x00000001,
       
    96 	ESecondTestPassed = 0x00000002,
       
    97 	EThirdTestPassed = 0x00000004,
       
    98 	EFourthTestPassed = 0x00000008,
       
    99 	EFifthTestPassed = 0x00000010,
       
   100 	ESixthTestPassed = 0x00000020,
       
   101 	ESeventhTestPassed = 0x00000040,
       
   102 	EEighthTestPassed = 0x00000080,
       
   103 	ENinthTestPassed = 0x00000100,
       
   104 	ETenthTestPassed = 0x00000200,
       
   105 	};
       
   106 
       
   107 _LIT(KMultiProcessSemaphore, "Multi Process Semaphore");
       
   108 _LIT(KMultiProcessSemaphore2, "Multi Process Semaphore 2");
       
   109 _LIT(KMultiProcessSemaphore3, "Multi Process Semaphore 3");
       
   110 _LIT(KMultiProcessSemaphore4, "Multi Process Semaphore 4");
       
   111 _LIT(KSharedChunkName, "Surfaces test shared chunk");
       
   112 
       
   113 
       
   114 const TInt KSharedChunkSize = ((4 * sizeof(TUint32)) + (2 * sizeof(TInt)));
       
   115 	
       
   116 /**
       
   117 Wraps a shared chunk for communication between the processes
       
   118 */
       
   119 class CChunkWrapper : public CBase
       
   120 	{
       
   121 public:
       
   122 	~CChunkWrapper();
       
   123 	static CChunkWrapper* CreateL(const TDesC& aName, TInt aSize, TInt aMaxSize);
       
   124 	void CreateConstructL(const TDesC& aName, TInt aSize, TInt aMaxSize);
       
   125 	static CChunkWrapper* OpenL(const TDesC& aName, TBool aIsReadOnly);
       
   126 	void OpenConstructL(const TDesC& aName, TBool aIsReadOnly);
       
   127 	void SetSecondProcessResults(TInt aResult);
       
   128 	TInt GetSecondProcessResults();
       
   129 	void SetThirdProcessResults(TInt aResult);
       
   130 	TInt GetThirdProcessResults();
       
   131 	void SetId(const TSurfaceId& aId);
       
   132 	TSurfaceId GetId();
       
   133 	void CloseD();
       
   134 private:	
       
   135 	CChunkWrapper();
       
   136 private:
       
   137 	RChunk iChunk;
       
   138 	};
       
   139 
       
   140 
       
   141 class CTestDriver : public CBase
       
   142 	{
       
   143 public:
       
   144 	CTestDriver();
       
   145 	virtual ~CTestDriver();
       
   146 	void ConstructL();
       
   147 protected:
       
   148 	RSurfaceManager iSurfaceManager;
       
   149 	CChunkWrapper* iChunkWrapper;
       
   150 	TInt iTestResult;
       
   151 	};
       
   152 
       
   153 #endif