author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// Surface manager multi-processed test code |
sl@0 | 15 |
// |
sl@0 | 16 |
// |
sl@0 | 17 |
|
sl@0 | 18 |
/** |
sl@0 | 19 |
@file |
sl@0 | 20 |
@test |
sl@0 | 21 |
@internalComponent - Internal Symbian test code |
sl@0 | 22 |
*/ |
sl@0 | 23 |
|
sl@0 | 24 |
#include <e32test.h> |
sl@0 | 25 |
#include <e32std.h> |
sl@0 | 26 |
#include <graphics/surface.h> |
sl@0 | 27 |
#include <graphics/surfacemanager.h> |
sl@0 | 28 |
#include "tsmgmultprocessshared.h" |
sl@0 | 29 |
|
sl@0 | 30 |
LOCAL_D RTest test(_L("TThirdProcess")); |
sl@0 | 31 |
|
sl@0 | 32 |
|
sl@0 | 33 |
class CTestDriverThirdProcess : public CTestDriver |
sl@0 | 34 |
{ |
sl@0 | 35 |
public: |
sl@0 | 36 |
CTestDriverThirdProcess(); |
sl@0 | 37 |
static CTestDriverThirdProcess* NewL(); |
sl@0 | 38 |
public: |
sl@0 | 39 |
void CloseSurface(); |
sl@0 | 40 |
void SurfaceInfo(); |
sl@0 | 41 |
void OpenWaitCloseOpen(); |
sl@0 | 42 |
void OpenSurface(); |
sl@0 | 43 |
}; |
sl@0 | 44 |
|
sl@0 | 45 |
CTestDriverThirdProcess::CTestDriverThirdProcess():CTestDriver() |
sl@0 | 46 |
{} |
sl@0 | 47 |
|
sl@0 | 48 |
|
sl@0 | 49 |
CTestDriverThirdProcess* CTestDriverThirdProcess::NewL() |
sl@0 | 50 |
{ |
sl@0 | 51 |
CTestDriverThirdProcess * driver = new (ELeave) CTestDriverThirdProcess(); |
sl@0 | 52 |
CleanupStack::PushL(driver); |
sl@0 | 53 |
driver->CTestDriver::ConstructL(); |
sl@0 | 54 |
CleanupStack::Pop(driver); |
sl@0 | 55 |
return driver; |
sl@0 | 56 |
} |
sl@0 | 57 |
|
sl@0 | 58 |
void CTestDriverThirdProcess::CloseSurface() |
sl@0 | 59 |
{ |
sl@0 | 60 |
TSurfaceId id = iChunkWrapper->GetId(); |
sl@0 | 61 |
// Close Surface |
sl@0 | 62 |
if(KErrAccessDenied == iSurfaceManager.CloseSurface(id)) |
sl@0 | 63 |
{ |
sl@0 | 64 |
iTestResult |= EFirstTestPassed; |
sl@0 | 65 |
} |
sl@0 | 66 |
|
sl@0 | 67 |
iChunkWrapper->SetThirdProcessResults(iTestResult); |
sl@0 | 68 |
} |
sl@0 | 69 |
|
sl@0 | 70 |
void CTestDriverThirdProcess::SurfaceInfo() |
sl@0 | 71 |
{ |
sl@0 | 72 |
TSurfaceId id = iChunkWrapper->GetId(); |
sl@0 | 73 |
// SurfaceInfo |
sl@0 | 74 |
// Call Surface Info on the surface in this process |
sl@0 | 75 |
RSurfaceManager::TInfoBuf infoBuf; |
sl@0 | 76 |
if(KErrAccessDenied == iSurfaceManager.SurfaceInfo(id,infoBuf))// This is correct? |
sl@0 | 77 |
{ |
sl@0 | 78 |
iTestResult |= EFirstTestPassed; |
sl@0 | 79 |
} |
sl@0 | 80 |
|
sl@0 | 81 |
iChunkWrapper->SetThirdProcessResults(iTestResult); |
sl@0 | 82 |
} |
sl@0 | 83 |
|
sl@0 | 84 |
/** |
sl@0 | 85 |
Test 25: Test surface can be accessed from third process when creating |
sl@0 | 86 |
process dies and second process closes |
sl@0 | 87 |
|
sl@0 | 88 |
... |
sl@0 | 89 |
Process 3: Open Surface |
sl@0 | 90 |
... |
sl@0 | 91 |
Process 3: Close Surface - KErrNone |
sl@0 | 92 |
Process 3: Open Surface - KErrArgument |
sl@0 | 93 |
*/ |
sl@0 | 94 |
void CTestDriverThirdProcess::OpenWaitCloseOpen() |
sl@0 | 95 |
{ |
sl@0 | 96 |
TSurfaceId id = iChunkWrapper->GetId(); |
sl@0 | 97 |
|
sl@0 | 98 |
// Open the surface using the surfaceId |
sl@0 | 99 |
if(KErrNone == iSurfaceManager.OpenSurface(id)) |
sl@0 | 100 |
{ |
sl@0 | 101 |
iTestResult |= EFirstTestPassed; |
sl@0 | 102 |
} |
sl@0 | 103 |
|
sl@0 | 104 |
// Pass control back to the first process |
sl@0 | 105 |
RSemaphore sem3; |
sl@0 | 106 |
if(KErrNone == sem3.OpenGlobal(KMultiProcessSemaphore3)) |
sl@0 | 107 |
{ |
sl@0 | 108 |
iTestResult |= ESecondTestPassed; |
sl@0 | 109 |
} |
sl@0 | 110 |
|
sl@0 | 111 |
User::After(100000); |
sl@0 | 112 |
sem3.Signal(); |
sl@0 | 113 |
|
sl@0 | 114 |
RSemaphore sem4; |
sl@0 | 115 |
if(KErrNone == sem4.OpenGlobal(KMultiProcessSemaphore4)) |
sl@0 | 116 |
{ |
sl@0 | 117 |
iTestResult |= EThirdTestPassed; |
sl@0 | 118 |
} |
sl@0 | 119 |
|
sl@0 | 120 |
sem4.Wait(); |
sl@0 | 121 |
|
sl@0 | 122 |
// Close the surface |
sl@0 | 123 |
if(KErrNone == iSurfaceManager.CloseSurface(id)) |
sl@0 | 124 |
{ |
sl@0 | 125 |
iTestResult |= EFourthTestPassed; |
sl@0 | 126 |
} |
sl@0 | 127 |
|
sl@0 | 128 |
// Open the surface |
sl@0 | 129 |
if(KErrArgument == iSurfaceManager.CloseSurface(id)) |
sl@0 | 130 |
{ |
sl@0 | 131 |
iTestResult |= EFifthTestPassed; |
sl@0 | 132 |
} |
sl@0 | 133 |
|
sl@0 | 134 |
iChunkWrapper->SetThirdProcessResults(iTestResult); |
sl@0 | 135 |
|
sl@0 | 136 |
sem3.Close(); |
sl@0 | 137 |
sem4.Close(); |
sl@0 | 138 |
} |
sl@0 | 139 |
|
sl@0 | 140 |
/** |
sl@0 | 141 |
Test 27: Test closing on one process doesn't prevent opening on other processes, |
sl@0 | 142 |
provided one process still owns surface |
sl@0 | 143 |
|
sl@0 | 144 |
... |
sl@0 | 145 |
Process 3: Open Surface - KErrNone |
sl@0 | 146 |
... |
sl@0 | 147 |
*/ |
sl@0 | 148 |
void CTestDriverThirdProcess::OpenSurface() |
sl@0 | 149 |
{ |
sl@0 | 150 |
TSurfaceId id = iChunkWrapper->GetId(); |
sl@0 | 151 |
|
sl@0 | 152 |
// Open Surface |
sl@0 | 153 |
if(KErrNone == iSurfaceManager.OpenSurface(id)) |
sl@0 | 154 |
{ |
sl@0 | 155 |
iTestResult |= EFirstTestPassed; |
sl@0 | 156 |
} |
sl@0 | 157 |
|
sl@0 | 158 |
iChunkWrapper->SetThirdProcessResults(iTestResult); |
sl@0 | 159 |
|
sl@0 | 160 |
} |
sl@0 | 161 |
|
sl@0 | 162 |
// Real main function |
sl@0 | 163 |
void MainL() |
sl@0 | 164 |
{ |
sl@0 | 165 |
test.Title(); |
sl@0 | 166 |
|
sl@0 | 167 |
test.Start(_L("Staring 3rd process")); |
sl@0 | 168 |
TInt testCase; |
sl@0 | 169 |
User::GetTIntParameter(EMultiProcessSecondSlot, testCase); |
sl@0 | 170 |
|
sl@0 | 171 |
CTestDriverThirdProcess* testDriver = CTestDriverThirdProcess::NewL(); |
sl@0 | 172 |
|
sl@0 | 173 |
switch(testCase) |
sl@0 | 174 |
{ |
sl@0 | 175 |
case ECloseSurface: |
sl@0 | 176 |
testDriver->CloseSurface(); |
sl@0 | 177 |
break; |
sl@0 | 178 |
case ESurfaceInfo: |
sl@0 | 179 |
testDriver->SurfaceInfo(); |
sl@0 | 180 |
break; |
sl@0 | 181 |
case EOpenWaitCloseOpen: |
sl@0 | 182 |
testDriver->OpenWaitCloseOpen(); |
sl@0 | 183 |
break; |
sl@0 | 184 |
case EOpenSurface: |
sl@0 | 185 |
testDriver->OpenSurface(); |
sl@0 | 186 |
break; |
sl@0 | 187 |
default: |
sl@0 | 188 |
User::Leave(KErrArgument); |
sl@0 | 189 |
break; |
sl@0 | 190 |
} |
sl@0 | 191 |
|
sl@0 | 192 |
delete testDriver; |
sl@0 | 193 |
test.End(); |
sl@0 | 194 |
test.Close(); |
sl@0 | 195 |
} |
sl@0 | 196 |
|
sl@0 | 197 |
// Cleanup stack harness |
sl@0 | 198 |
GLDEF_C TInt E32Main() |
sl@0 | 199 |
{ |
sl@0 | 200 |
__UHEAP_MARK; |
sl@0 | 201 |
CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
sl@0 | 202 |
TRAPD(error, MainL()); |
sl@0 | 203 |
_LIT(KTThirdProcessPanic,"tthirdprocessmain"); |
sl@0 | 204 |
__ASSERT_ALWAYS(!error, User::Panic(KTThirdProcessPanic, error)); |
sl@0 | 205 |
delete cleanupStack; |
sl@0 | 206 |
__UHEAP_MARKEND; |
sl@0 | 207 |
return 0; |
sl@0 | 208 |
} |