Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Surface manager multi-processed test code
21 @internalComponent - Internal Symbian test code
26 #include <graphics/surface.h>
27 #include <graphics/surfacemanager.h>
28 #include "tsmgmultprocessshared.h"
30 LOCAL_D RTest test(_L("TThirdProcess"));
33 class CTestDriverThirdProcess : public CTestDriver
36 CTestDriverThirdProcess();
37 static CTestDriverThirdProcess* NewL();
41 void OpenWaitCloseOpen();
45 CTestDriverThirdProcess::CTestDriverThirdProcess():CTestDriver()
49 CTestDriverThirdProcess* CTestDriverThirdProcess::NewL()
51 CTestDriverThirdProcess * driver = new (ELeave) CTestDriverThirdProcess();
52 CleanupStack::PushL(driver);
53 driver->CTestDriver::ConstructL();
54 CleanupStack::Pop(driver);
58 void CTestDriverThirdProcess::CloseSurface()
60 TSurfaceId id = iChunkWrapper->GetId();
62 if(KErrAccessDenied == iSurfaceManager.CloseSurface(id))
64 iTestResult |= EFirstTestPassed;
67 iChunkWrapper->SetThirdProcessResults(iTestResult);
70 void CTestDriverThirdProcess::SurfaceInfo()
72 TSurfaceId id = iChunkWrapper->GetId();
74 // Call Surface Info on the surface in this process
75 RSurfaceManager::TInfoBuf infoBuf;
76 if(KErrAccessDenied == iSurfaceManager.SurfaceInfo(id,infoBuf))// This is correct?
78 iTestResult |= EFirstTestPassed;
81 iChunkWrapper->SetThirdProcessResults(iTestResult);
85 Test 25: Test surface can be accessed from third process when creating
86 process dies and second process closes
89 Process 3: Open Surface
91 Process 3: Close Surface - KErrNone
92 Process 3: Open Surface - KErrArgument
94 void CTestDriverThirdProcess::OpenWaitCloseOpen()
96 TSurfaceId id = iChunkWrapper->GetId();
98 // Open the surface using the surfaceId
99 if(KErrNone == iSurfaceManager.OpenSurface(id))
101 iTestResult |= EFirstTestPassed;
104 // Pass control back to the first process
106 if(KErrNone == sem3.OpenGlobal(KMultiProcessSemaphore3))
108 iTestResult |= ESecondTestPassed;
115 if(KErrNone == sem4.OpenGlobal(KMultiProcessSemaphore4))
117 iTestResult |= EThirdTestPassed;
123 if(KErrNone == iSurfaceManager.CloseSurface(id))
125 iTestResult |= EFourthTestPassed;
129 if(KErrArgument == iSurfaceManager.CloseSurface(id))
131 iTestResult |= EFifthTestPassed;
134 iChunkWrapper->SetThirdProcessResults(iTestResult);
141 Test 27: Test closing on one process doesn't prevent opening on other processes,
142 provided one process still owns surface
145 Process 3: Open Surface - KErrNone
148 void CTestDriverThirdProcess::OpenSurface()
150 TSurfaceId id = iChunkWrapper->GetId();
153 if(KErrNone == iSurfaceManager.OpenSurface(id))
155 iTestResult |= EFirstTestPassed;
158 iChunkWrapper->SetThirdProcessResults(iTestResult);
162 // Real main function
167 test.Start(_L("Staring 3rd process"));
169 User::GetTIntParameter(EMultiProcessSecondSlot, testCase);
171 CTestDriverThirdProcess* testDriver = CTestDriverThirdProcess::NewL();
176 testDriver->CloseSurface();
179 testDriver->SurfaceInfo();
181 case EOpenWaitCloseOpen:
182 testDriver->OpenWaitCloseOpen();
185 testDriver->OpenSurface();
188 User::Leave(KErrArgument);
197 // Cleanup stack harness
198 GLDEF_C TInt E32Main()
201 CTrapCleanup* cleanupStack = CTrapCleanup::New();
202 TRAPD(error, MainL());
203 _LIT(KTThirdProcessPanic,"tthirdprocessmain");
204 __ASSERT_ALWAYS(!error, User::Panic(KTThirdProcessPanic, error));