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 |
#include <e32base.h>
|
sl@0
|
24 |
#include <e32cons.h>
|
sl@0
|
25 |
#include <e32test.h>
|
sl@0
|
26 |
#include <e32std.h>
|
sl@0
|
27 |
#include <e32debug.h>
|
sl@0
|
28 |
#include <e32def_private.h>
|
sl@0
|
29 |
#include <graphics/surface.h>
|
sl@0
|
30 |
#include <graphics/surfacemanager.h>
|
sl@0
|
31 |
#include "tsmgmultprocessshared.h"
|
sl@0
|
32 |
|
sl@0
|
33 |
LOCAL_D RTest test(_L("TReceiveSurface"));
|
sl@0
|
34 |
|
sl@0
|
35 |
|
sl@0
|
36 |
class CTestDriverSecondProcess : public CTestDriver
|
sl@0
|
37 |
{
|
sl@0
|
38 |
public:
|
sl@0
|
39 |
CTestDriverSecondProcess();
|
sl@0
|
40 |
~CTestDriverSecondProcess();
|
sl@0
|
41 |
void ConstructL();
|
sl@0
|
42 |
static CTestDriverSecondProcess* NewL();
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
void TestMultipleChannelsInSecondProcess2();
|
sl@0
|
45 |
void TestMultipleChannelsInSecondProcess1();
|
sl@0
|
46 |
void TestCheckSyncOperation();
|
sl@0
|
47 |
void TestCheckHandleInSecondProcess();
|
sl@0
|
48 |
void TestSurfaceInfoUsingSurfaceId();
|
sl@0
|
49 |
void TestOpeningSurfaceUsingSurfaceId();
|
sl@0
|
50 |
void TestOpeningSurfaceInvalidParams();
|
sl@0
|
51 |
void OpenWaitMap();
|
sl@0
|
52 |
void CreateWaitKill();
|
sl@0
|
53 |
void OpenClose();
|
sl@0
|
54 |
void MapSurfaceInfoCantAccess();
|
sl@0
|
55 |
void TestReadFromBufferInSecondProcess();
|
sl@0
|
56 |
void TestGetSurfaceHint();
|
sl@0
|
57 |
void TestSetSurfaceHint();
|
sl@0
|
58 |
void TestAddSurfaceHint();
|
sl@0
|
59 |
void TestOutofMemory();
|
sl@0
|
60 |
private:
|
sl@0
|
61 |
RSurfaceManager iSurfaceManagerTwo;
|
sl@0
|
62 |
};
|
sl@0
|
63 |
|
sl@0
|
64 |
CTestDriverSecondProcess::CTestDriverSecondProcess():CTestDriver()
|
sl@0
|
65 |
{
|
sl@0
|
66 |
}
|
sl@0
|
67 |
|
sl@0
|
68 |
CTestDriverSecondProcess::~CTestDriverSecondProcess()
|
sl@0
|
69 |
{
|
sl@0
|
70 |
iSurfaceManagerTwo.Close();
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
void CTestDriverSecondProcess::ConstructL()
|
sl@0
|
74 |
{
|
sl@0
|
75 |
CTestDriver::ConstructL();
|
sl@0
|
76 |
User::LeaveIfError( iSurfaceManagerTwo.Open());
|
sl@0
|
77 |
}
|
sl@0
|
78 |
|
sl@0
|
79 |
CTestDriverSecondProcess* CTestDriverSecondProcess::NewL()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
CTestDriverSecondProcess * driver = new (ELeave) CTestDriverSecondProcess();
|
sl@0
|
82 |
CleanupStack::PushL(driver);
|
sl@0
|
83 |
driver->ConstructL();
|
sl@0
|
84 |
CleanupStack::Pop(driver);
|
sl@0
|
85 |
return driver;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
void CTestDriverSecondProcess::TestMultipleChannelsInSecondProcess2()
|
sl@0
|
89 |
{
|
sl@0
|
90 |
// Store the attributes used to create the Surface
|
sl@0
|
91 |
RSurfaceManager::TSurfaceCreationAttributesBuf buf;
|
sl@0
|
92 |
RSurfaceManager::TSurfaceCreationAttributes& attributes = buf();
|
sl@0
|
93 |
attributes.iSize = TSize(280,301);
|
sl@0
|
94 |
attributes.iBuffers = 1;
|
sl@0
|
95 |
attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp
|
sl@0
|
96 |
attributes.iStride = 1;
|
sl@0
|
97 |
attributes.iOffsetToFirstBuffer = 1;
|
sl@0
|
98 |
attributes.iAlignment = 1;
|
sl@0
|
99 |
|
sl@0
|
100 |
RSurfaceManager::THintPair hints[2]; // two hint pairs specified
|
sl@0
|
101 |
attributes.iHintCount = 2;
|
sl@0
|
102 |
attributes.iSurfaceHints = hints;
|
sl@0
|
103 |
hints[0].Set(TUid::Uid(0x124578), 25, ETrue);
|
sl@0
|
104 |
hints[1].Set(TUid::Uid(0x237755), 50, ETrue);
|
sl@0
|
105 |
|
sl@0
|
106 |
attributes.iContiguous = ETrue;
|
sl@0
|
107 |
attributes.iCacheAttrib = RSurfaceManager::ECached;
|
sl@0
|
108 |
attributes.iOffsetBetweenBuffers = 0;
|
sl@0
|
109 |
attributes.iMappable = ETrue;
|
sl@0
|
110 |
|
sl@0
|
111 |
// Create the surface
|
sl@0
|
112 |
TSurfaceId surfaceIdOne;
|
sl@0
|
113 |
if(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdOne))
|
sl@0
|
114 |
{
|
sl@0
|
115 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
// Create the surface
|
sl@0
|
119 |
TSurfaceId surfaceIdTwo;
|
sl@0
|
120 |
if(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdTwo))
|
sl@0
|
121 |
{
|
sl@0
|
122 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceIdTwo))
|
sl@0
|
126 |
{
|
sl@0
|
127 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
128 |
}
|
sl@0
|
129 |
|
sl@0
|
130 |
if(KErrNone == iSurfaceManagerTwo.OpenSurface(surfaceIdOne))
|
sl@0
|
131 |
{
|
sl@0
|
132 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
136 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
137 |
// Put the surfaceId onto the shared chunk
|
sl@0
|
138 |
iChunkWrapper->SetId(surfaceIdOne);
|
sl@0
|
139 |
|
sl@0
|
140 |
|
sl@0
|
141 |
// Pass control back to the first process
|
sl@0
|
142 |
RSemaphore sem;
|
sl@0
|
143 |
if(KErrNone == sem.OpenGlobal(KMultiProcessSemaphore))
|
sl@0
|
144 |
{
|
sl@0
|
145 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|
sl@0
|
148 |
sem.Signal();
|
sl@0
|
149 |
|
sl@0
|
150 |
RSemaphore sem2;
|
sl@0
|
151 |
if(KErrNone == sem2.OpenGlobal(KMultiProcessSemaphore2))
|
sl@0
|
152 |
{
|
sl@0
|
153 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
154 |
}
|
sl@0
|
155 |
sem2.Wait();
|
sl@0
|
156 |
|
sl@0
|
157 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
158 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
159 |
// // Put the surfaceId onto the shared chunk
|
sl@0
|
160 |
iChunkWrapper->SetId(surfaceIdTwo);
|
sl@0
|
161 |
|
sl@0
|
162 |
sem.Close();
|
sl@0
|
163 |
sem2.Close();
|
sl@0
|
164 |
}
|
sl@0
|
165 |
|
sl@0
|
166 |
void CTestDriverSecondProcess::TestMultipleChannelsInSecondProcess1()
|
sl@0
|
167 |
{
|
sl@0
|
168 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
169 |
TSurfaceId surfaceIdOne = iChunkWrapper->GetId();
|
sl@0
|
170 |
|
sl@0
|
171 |
// Open the surface using the surfaceId - check that it returns KErrNone
|
sl@0
|
172 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceIdOne))
|
sl@0
|
173 |
{
|
sl@0
|
174 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
175 |
}
|
sl@0
|
176 |
|
sl@0
|
177 |
// Pass control back to the first process
|
sl@0
|
178 |
RSemaphore sem;
|
sl@0
|
179 |
if(KErrNone == sem.OpenGlobal(KMultiProcessSemaphore))
|
sl@0
|
180 |
{
|
sl@0
|
181 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
182 |
}
|
sl@0
|
183 |
|
sl@0
|
184 |
RSemaphore sem2;
|
sl@0
|
185 |
if(KErrNone == sem2.OpenGlobal(KMultiProcessSemaphore2))
|
sl@0
|
186 |
{
|
sl@0
|
187 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
191 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
192 |
|
sl@0
|
193 |
sem.Signal();
|
sl@0
|
194 |
sem2.Wait();
|
sl@0
|
195 |
|
sl@0
|
196 |
// Get the surface info
|
sl@0
|
197 |
RSurfaceManager::TInfoBuf infoBuf;
|
sl@0
|
198 |
if(KErrNone == iSurfaceManager.SurfaceInfo(surfaceIdOne, infoBuf))
|
sl@0
|
199 |
{
|
sl@0
|
200 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
TSurfaceId surfaceIdTwo = iChunkWrapper->GetId();
|
sl@0
|
203 |
|
sl@0
|
204 |
if(KErrArgument == iSurfaceManager.SurfaceInfo(surfaceIdTwo, infoBuf))
|
sl@0
|
205 |
{
|
sl@0
|
206 |
iTestResult |= EFifthTestPassed;
|
sl@0
|
207 |
}
|
sl@0
|
208 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
209 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
210 |
|
sl@0
|
211 |
sem.Close();
|
sl@0
|
212 |
sem2.Close();
|
sl@0
|
213 |
}
|
sl@0
|
214 |
|
sl@0
|
215 |
void CTestDriverSecondProcess::TestCheckSyncOperation()
|
sl@0
|
216 |
{
|
sl@0
|
217 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
218 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
219 |
|
sl@0
|
220 |
// Check it returns KErrAccessDenied when the surface is not Open
|
sl@0
|
221 |
TInt bufferNo = 1;
|
sl@0
|
222 |
|
sl@0
|
223 |
RSurfaceManager::TSyncOperation syncOperation = RSurfaceManager::ESyncBeforeNonCPURead;
|
sl@0
|
224 |
|
sl@0
|
225 |
if(KErrAccessDenied == iSurfaceManager.SynchronizeCache(surfaceId, bufferNo,syncOperation))
|
sl@0
|
226 |
{
|
sl@0
|
227 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
228 |
}
|
sl@0
|
229 |
|
sl@0
|
230 |
// Open the surface using the surfaceId - check that it returns KErrNone
|
sl@0
|
231 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
232 |
{
|
sl@0
|
233 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
// Map the surface
|
sl@0
|
237 |
RChunk handle;
|
sl@0
|
238 |
|
sl@0
|
239 |
if(KErrNone == iSurfaceManager.MapSurface(surfaceId, handle))
|
sl@0
|
240 |
{
|
sl@0
|
241 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
if(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId, bufferNo,syncOperation))
|
sl@0
|
245 |
{
|
sl@0
|
246 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
247 |
}
|
sl@0
|
248 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
249 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
250 |
// Close the chunkwrapper, handle and the surface manager
|
sl@0
|
251 |
handle.Close();
|
sl@0
|
252 |
|
sl@0
|
253 |
}
|
sl@0
|
254 |
void CTestDriverSecondProcess::TestCheckHandleInSecondProcess()
|
sl@0
|
255 |
{
|
sl@0
|
256 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
257 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
258 |
|
sl@0
|
259 |
// Open the surface using the surfaceId - check that it returns KErrNone
|
sl@0
|
260 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
261 |
{
|
sl@0
|
262 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
// Map the surface
|
sl@0
|
266 |
RChunk handle;
|
sl@0
|
267 |
|
sl@0
|
268 |
if(KErrNone == iSurfaceManager.MapSurface(surfaceId, handle))
|
sl@0
|
269 |
{
|
sl@0
|
270 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
271 |
}
|
sl@0
|
272 |
|
sl@0
|
273 |
// Get the surface info
|
sl@0
|
274 |
RSurfaceManager::TInfoBuf infoBuf;
|
sl@0
|
275 |
if(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf))
|
sl@0
|
276 |
{
|
sl@0
|
277 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
278 |
}
|
sl@0
|
279 |
RSurfaceManager::TSurfaceInfoV01& info = infoBuf();
|
sl@0
|
280 |
// Get the adress of this chunk of memory
|
sl@0
|
281 |
TUint8* surfaceAdd = handle.Base();
|
sl@0
|
282 |
TInt offsetToFirstBuffer;
|
sl@0
|
283 |
if(KErrNone == iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer))
|
sl@0
|
284 |
{
|
sl@0
|
285 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
286 |
}
|
sl@0
|
287 |
TUint8* bufferAdd = surfaceAdd + offsetToFirstBuffer;
|
sl@0
|
288 |
|
sl@0
|
289 |
// Write to the first buffer, and test the value is written
|
sl@0
|
290 |
*bufferAdd = 20;
|
sl@0
|
291 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
292 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
293 |
|
sl@0
|
294 |
// Close the chunkwrapper, handle and the surface manager
|
sl@0
|
295 |
handle.Close();
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
/**
|
sl@0
|
299 |
Test 18. Receiving a surface and querying SurfaceInfo for surface properties
|
sl@0
|
300 |
|
sl@0
|
301 |
Process 1: Create the Surface
|
sl@0
|
302 |
Process 2: Receive the Surface Id
|
sl@0
|
303 |
Process 2: Receive the attributes used to create the surface
|
sl@0
|
304 |
Process 2: Open the surface using the id
|
sl@0
|
305 |
Process 2: Map the surface
|
sl@0
|
306 |
Process 2: Call SurfaceInfo to get the attributes of the Surface
|
sl@0
|
307 |
Check if these are equal to the ones received.
|
sl@0
|
308 |
|
sl@0
|
309 |
@see TestSurfaceInfoUsingSurfaceIdL() in tsurfacemanager.cpp
|
sl@0
|
310 |
*/
|
sl@0
|
311 |
void CTestDriverSecondProcess::TestSurfaceInfoUsingSurfaceId()
|
sl@0
|
312 |
{
|
sl@0
|
313 |
// Set attributes for the surface - these are expected attributes in the second process
|
sl@0
|
314 |
RSurfaceManager::TSurfaceCreationAttributesBuf buf;
|
sl@0
|
315 |
RSurfaceManager::TSurfaceCreationAttributes& attributes=buf();
|
sl@0
|
316 |
attributes.iSize = TSize(100,100);
|
sl@0
|
317 |
attributes.iBuffers = 1; // number of buffers in the surface
|
sl@0
|
318 |
attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp
|
sl@0
|
319 |
attributes.iStride = 400; // Number of bytes between start of one line and start of next
|
sl@0
|
320 |
attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data
|
sl@0
|
321 |
attributes.iAlignment = 2; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned
|
sl@0
|
322 |
attributes.iContiguous=ETrue;
|
sl@0
|
323 |
|
sl@0
|
324 |
RSurfaceManager::THintPair hints[2]; // two hint pairs specified
|
sl@0
|
325 |
attributes.iHintCount = 2;
|
sl@0
|
326 |
attributes.iSurfaceHints = hints;
|
sl@0
|
327 |
hints[0].Set(TUid::Uid(0x124545), 50, EFalse);
|
sl@0
|
328 |
hints[1].Set(TUid::Uid(0x237755), 50, EFalse);
|
sl@0
|
329 |
|
sl@0
|
330 |
attributes.iOffsetBetweenBuffers = 0;
|
sl@0
|
331 |
attributes.iCacheAttrib = RSurfaceManager::ENotCached;
|
sl@0
|
332 |
attributes.iMappable = ETrue;
|
sl@0
|
333 |
|
sl@0
|
334 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
335 |
|
sl@0
|
336 |
// Open the surface using the surfaceId - check that it returns KErrNone
|
sl@0
|
337 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
338 |
{
|
sl@0
|
339 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
340 |
}
|
sl@0
|
341 |
|
sl@0
|
342 |
// Map the surface
|
sl@0
|
343 |
RChunk handle;
|
sl@0
|
344 |
|
sl@0
|
345 |
if(KErrNone == iSurfaceManager.MapSurface(surfaceId, handle))
|
sl@0
|
346 |
{
|
sl@0
|
347 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
348 |
}
|
sl@0
|
349 |
|
sl@0
|
350 |
// Get the surface info
|
sl@0
|
351 |
RSurfaceManager::TInfoBuf infoBuf;
|
sl@0
|
352 |
if(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf))
|
sl@0
|
353 |
{
|
sl@0
|
354 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
355 |
}
|
sl@0
|
356 |
RSurfaceManager::TSurfaceInfoV01& info = infoBuf();
|
sl@0
|
357 |
TInt offsetToFirstBuffer;
|
sl@0
|
358 |
if(KErrNone == iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer))
|
sl@0
|
359 |
{
|
sl@0
|
360 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
361 |
}
|
sl@0
|
362 |
|
sl@0
|
363 |
if(info.iSize == attributes.iSize)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
iTestResult |= EFifthTestPassed;
|
sl@0
|
366 |
}
|
sl@0
|
367 |
if(info.iBuffers == attributes.iBuffers)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
iTestResult |= ESixthTestPassed;
|
sl@0
|
370 |
}
|
sl@0
|
371 |
if(info.iPixelFormat == attributes.iPixelFormat)
|
sl@0
|
372 |
{
|
sl@0
|
373 |
iTestResult |= ESeventhTestPassed;
|
sl@0
|
374 |
}
|
sl@0
|
375 |
if(info.iStride == attributes.iStride)
|
sl@0
|
376 |
{
|
sl@0
|
377 |
iTestResult |= EEighthTestPassed;
|
sl@0
|
378 |
}
|
sl@0
|
379 |
if(offsetToFirstBuffer >= attributes.iOffsetToFirstBuffer)
|
sl@0
|
380 |
{
|
sl@0
|
381 |
iTestResult |= ENinthTestPassed;
|
sl@0
|
382 |
}
|
sl@0
|
383 |
if(info.iContiguous == attributes.iContiguous)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
iTestResult |= ETenthTestPassed;
|
sl@0
|
386 |
}
|
sl@0
|
387 |
|
sl@0
|
388 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
389 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
390 |
|
sl@0
|
391 |
// Close handle
|
sl@0
|
392 |
handle.Close();
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
/**
|
sl@0
|
396 |
Test 19. Opening a surface using surfaceId
|
sl@0
|
397 |
|
sl@0
|
398 |
Priocess 1: Create the surface
|
sl@0
|
399 |
Process 2: Receive the Surface id
|
sl@0
|
400 |
Process 2: Open the Surface using the stored Surface id
|
sl@0
|
401 |
Check OpenSurface returns KErrNone
|
sl@0
|
402 |
|
sl@0
|
403 |
@see TestOpeningSurfaceUsingSurfaceIdL() in tsurfacemanager.cpp
|
sl@0
|
404 |
*/
|
sl@0
|
405 |
void CTestDriverSecondProcess::TestOpeningSurfaceUsingSurfaceId()
|
sl@0
|
406 |
{
|
sl@0
|
407 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
408 |
// CChunkWrapper* chunkWrapper = CChunkWrapper::OpenL(KSharedChunkName, ETrue);
|
sl@0
|
409 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
410 |
|
sl@0
|
411 |
// Open the surface using the surfaceId - check that it returns KErrNone
|
sl@0
|
412 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
413 |
{
|
sl@0
|
414 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
418 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
419 |
|
sl@0
|
420 |
}
|
sl@0
|
421 |
|
sl@0
|
422 |
/**
|
sl@0
|
423 |
Test 20. Opening a surface using invalid surfaceId
|
sl@0
|
424 |
|
sl@0
|
425 |
Process 1:Create the surface
|
sl@0
|
426 |
Process 2: Receive a Surface Id
|
sl@0
|
427 |
Change Surface Id by
|
sl@0
|
428 |
1. adding 500 to the SurfaceId
|
sl@0
|
429 |
2. making the Surface ID negative
|
sl@0
|
430 |
3. converting the type of the Surface ID to EInvalidSurface
|
sl@0
|
431 |
Process 2: Call OpenSurface using the new SurfaceId
|
sl@0
|
432 |
Check that the return value of OpenSurface is KErrArgument
|
sl@0
|
433 |
|
sl@0
|
434 |
@see TestOpenSurfaceInvalidParams() in tsurfacemanager.cpp
|
sl@0
|
435 |
*/
|
sl@0
|
436 |
void CTestDriverSecondProcess::TestOpeningSurfaceInvalidParams()
|
sl@0
|
437 |
{
|
sl@0
|
438 |
|
sl@0
|
439 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
440 |
|
sl@0
|
441 |
// Open Surface using the right Id
|
sl@0
|
442 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
443 |
{
|
sl@0
|
444 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
445 |
}
|
sl@0
|
446 |
// Open the surface using the invalid surfaceId - check that it returns KErrArgument
|
sl@0
|
447 |
TSurfaceId invalidSurfaceId = surfaceId;
|
sl@0
|
448 |
//Add 500 to the first field of surfaceId
|
sl@0
|
449 |
invalidSurfaceId.iInternal[0] = surfaceId.iInternal[0]+500;
|
sl@0
|
450 |
if(KErrArgument == iSurfaceManager.OpenSurface(invalidSurfaceId))
|
sl@0
|
451 |
{
|
sl@0
|
452 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
453 |
}
|
sl@0
|
454 |
// Change the surfaceId type to EInvalidSurface
|
sl@0
|
455 |
invalidSurfaceId.iInternal[3] = (surfaceId.iInternal[3] & 0x00FFFFFF) | ( TSurfaceId::EInvalidSurface <<24 ) ;
|
sl@0
|
456 |
if(KErrArgument == iSurfaceManager.OpenSurface(invalidSurfaceId))
|
sl@0
|
457 |
{
|
sl@0
|
458 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
462 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
463 |
|
sl@0
|
464 |
}
|
sl@0
|
465 |
|
sl@0
|
466 |
/**
|
sl@0
|
467 |
Test 22: Create, Open and Close in 3 different processes,
|
sl@0
|
468 |
leaves surface accessible in first 2 processes
|
sl@0
|
469 |
|
sl@0
|
470 |
...
|
sl@0
|
471 |
Process 2: Open Surface
|
sl@0
|
472 |
...
|
sl@0
|
473 |
Process 2: MapSurface - KErrNone (still accessible)
|
sl@0
|
474 |
...
|
sl@0
|
475 |
*/
|
sl@0
|
476 |
void CTestDriverSecondProcess::OpenWaitMap()
|
sl@0
|
477 |
{
|
sl@0
|
478 |
|
sl@0
|
479 |
// Find the surfaceId
|
sl@0
|
480 |
TSurfaceId id = iChunkWrapper->GetId();
|
sl@0
|
481 |
|
sl@0
|
482 |
// Open Surface
|
sl@0
|
483 |
if(KErrNone == iSurfaceManager.OpenSurface(id))
|
sl@0
|
484 |
{
|
sl@0
|
485 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
486 |
}
|
sl@0
|
487 |
|
sl@0
|
488 |
// Pass control back to the first process
|
sl@0
|
489 |
RSemaphore sem;
|
sl@0
|
490 |
if(KErrNone == sem.OpenGlobal(KMultiProcessSemaphore))
|
sl@0
|
491 |
{
|
sl@0
|
492 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
493 |
}
|
sl@0
|
494 |
sem.Signal();
|
sl@0
|
495 |
|
sl@0
|
496 |
RSemaphore sem2;
|
sl@0
|
497 |
if(KErrNone == sem2.OpenGlobal(KMultiProcessSemaphore2))
|
sl@0
|
498 |
{
|
sl@0
|
499 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
500 |
}
|
sl@0
|
501 |
sem2.Wait();
|
sl@0
|
502 |
|
sl@0
|
503 |
// Map surface
|
sl@0
|
504 |
RChunk handle;
|
sl@0
|
505 |
if(KErrNone == iSurfaceManager.MapSurface(id, handle))
|
sl@0
|
506 |
{
|
sl@0
|
507 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
508 |
}
|
sl@0
|
509 |
|
sl@0
|
510 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
511 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
512 |
|
sl@0
|
513 |
sem.Close();
|
sl@0
|
514 |
sem2.Close();
|
sl@0
|
515 |
handle.Close();
|
sl@0
|
516 |
|
sl@0
|
517 |
}
|
sl@0
|
518 |
|
sl@0
|
519 |
|
sl@0
|
520 |
/**
|
sl@0
|
521 |
Test 23/24/25/26: Test surface can be accessed when creating process dies /
|
sl@0
|
522 |
Test surface can be closed when creating process dies /
|
sl@0
|
523 |
Test surface can be closed from third process when
|
sl@0
|
524 |
creating process dies and second process closes /
|
sl@0
|
525 |
Test surface can't be accessed in a second process when open
|
sl@0
|
526 |
and closed in the first process.
|
sl@0
|
527 |
|
sl@0
|
528 |
Process 2: Create Surface
|
sl@0
|
529 |
...
|
sl@0
|
530 |
Process 2: Kill Process
|
sl@0
|
531 |
...
|
sl@0
|
532 |
*/
|
sl@0
|
533 |
void CTestDriverSecondProcess::CreateWaitKill()
|
sl@0
|
534 |
{
|
sl@0
|
535 |
// Setup attributes
|
sl@0
|
536 |
RSurfaceManager::TSurfaceCreationAttributesBuf buf;
|
sl@0
|
537 |
RSurfaceManager::TSurfaceCreationAttributes& attributes = buf();
|
sl@0
|
538 |
|
sl@0
|
539 |
attributes.iSize = TSize(20,80); // w > 0, h > 0
|
sl@0
|
540 |
attributes.iBuffers = 12; // > 0
|
sl@0
|
541 |
attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp
|
sl@0
|
542 |
attributes.iStride = 250; // > 0, < width * bpp
|
sl@0
|
543 |
attributes.iOffsetToFirstBuffer = 200; // > 0, divisible by alignment
|
sl@0
|
544 |
attributes.iAlignment = 4; // 1 || 2 || 4 || 8
|
sl@0
|
545 |
attributes.iContiguous = ETrue;
|
sl@0
|
546 |
|
sl@0
|
547 |
RSurfaceManager::THintPair hints[2]; // two hint pairs specified
|
sl@0
|
548 |
attributes.iHintCount = 2;
|
sl@0
|
549 |
attributes.iSurfaceHints = hints;
|
sl@0
|
550 |
hints[0].Set(TUid::Uid(0x124545), 50, EFalse);
|
sl@0
|
551 |
hints[1].Set(TUid::Uid(0x237755), 50, EFalse);
|
sl@0
|
552 |
|
sl@0
|
553 |
attributes.iOffsetBetweenBuffers = 0;
|
sl@0
|
554 |
attributes.iMappable = ETrue;
|
sl@0
|
555 |
|
sl@0
|
556 |
// Create the surface
|
sl@0
|
557 |
TSurfaceId surfaceId;
|
sl@0
|
558 |
if(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId))
|
sl@0
|
559 |
{
|
sl@0
|
560 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
561 |
}
|
sl@0
|
562 |
// Put the surfaceId onto the shared chunk
|
sl@0
|
563 |
iChunkWrapper->SetId(surfaceId);
|
sl@0
|
564 |
|
sl@0
|
565 |
// Pass control back to the first process
|
sl@0
|
566 |
RSemaphore sem;
|
sl@0
|
567 |
if(KErrNone == sem.OpenGlobal(KMultiProcessSemaphore))
|
sl@0
|
568 |
{
|
sl@0
|
569 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
570 |
}
|
sl@0
|
571 |
sem.Signal();
|
sl@0
|
572 |
|
sl@0
|
573 |
RSemaphore sem2;
|
sl@0
|
574 |
if(KErrNone == sem2.OpenGlobal(KMultiProcessSemaphore2))
|
sl@0
|
575 |
{
|
sl@0
|
576 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
577 |
}
|
sl@0
|
578 |
sem2.Wait();
|
sl@0
|
579 |
|
sl@0
|
580 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
581 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
582 |
|
sl@0
|
583 |
// CleanupStack::PopAndDestroy(2,&sem);
|
sl@0
|
584 |
sem.Close();
|
sl@0
|
585 |
sem2.Close();
|
sl@0
|
586 |
}
|
sl@0
|
587 |
|
sl@0
|
588 |
/**
|
sl@0
|
589 |
Test 27/28/29: Test closing doesn't prevent opening on another process
|
sl@0
|
590 |
Test closing doesn't prevent access on another process
|
sl@0
|
591 |
Test closing a surface in the creating process
|
sl@0
|
592 |
when it has already been closed in a second process returns KErrNone
|
sl@0
|
593 |
|
sl@0
|
594 |
...
|
sl@0
|
595 |
Process 2: Open Surface
|
sl@0
|
596 |
Process 2: Close Surface
|
sl@0
|
597 |
...
|
sl@0
|
598 |
*/
|
sl@0
|
599 |
void CTestDriverSecondProcess::OpenClose()
|
sl@0
|
600 |
{
|
sl@0
|
601 |
|
sl@0
|
602 |
// Find the surfaceId
|
sl@0
|
603 |
TSurfaceId id = iChunkWrapper->GetId();
|
sl@0
|
604 |
|
sl@0
|
605 |
// Open Surface
|
sl@0
|
606 |
if(KErrNone == iSurfaceManager.OpenSurface(id))
|
sl@0
|
607 |
{
|
sl@0
|
608 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
609 |
}
|
sl@0
|
610 |
|
sl@0
|
611 |
// Close Surface
|
sl@0
|
612 |
if(KErrNone == iSurfaceManager.CloseSurface(id))
|
sl@0
|
613 |
{
|
sl@0
|
614 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
// Pass control back to the first process
|
sl@0
|
618 |
RSemaphore sem;
|
sl@0
|
619 |
if(KErrNone == sem.OpenGlobal(KMultiProcessSemaphore))
|
sl@0
|
620 |
{
|
sl@0
|
621 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
622 |
}
|
sl@0
|
623 |
sem.Signal();
|
sl@0
|
624 |
|
sl@0
|
625 |
RSemaphore sem2;
|
sl@0
|
626 |
if(KErrNone == sem2.OpenGlobal(KMultiProcessSemaphore2))
|
sl@0
|
627 |
{
|
sl@0
|
628 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
629 |
}
|
sl@0
|
630 |
sem2.Wait();
|
sl@0
|
631 |
|
sl@0
|
632 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
633 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
634 |
|
sl@0
|
635 |
sem.Close();
|
sl@0
|
636 |
sem2.Close();
|
sl@0
|
637 |
}
|
sl@0
|
638 |
|
sl@0
|
639 |
/**
|
sl@0
|
640 |
Test 30: Test a surface cannot be accessed in a second process if not opened
|
sl@0
|
641 |
|
sl@0
|
642 |
...
|
sl@0
|
643 |
Process 2: Map Surface - KErrAccessDenied
|
sl@0
|
644 |
Process 2: Surface Info - KErrAccessDenied
|
sl@0
|
645 |
*/
|
sl@0
|
646 |
void CTestDriverSecondProcess::MapSurfaceInfoCantAccess()
|
sl@0
|
647 |
{
|
sl@0
|
648 |
// Find the surfaceId
|
sl@0
|
649 |
TSurfaceId id = iChunkWrapper->GetId();
|
sl@0
|
650 |
|
sl@0
|
651 |
// Map surface
|
sl@0
|
652 |
RChunk handle;
|
sl@0
|
653 |
if(KErrAccessDenied == iSurfaceManager.MapSurface(id, handle))
|
sl@0
|
654 |
{
|
sl@0
|
655 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
656 |
}
|
sl@0
|
657 |
|
sl@0
|
658 |
// Surface Info
|
sl@0
|
659 |
RSurfaceManager::TInfoBuf infoBuf;
|
sl@0
|
660 |
if(KErrAccessDenied == iSurfaceManager.SurfaceInfo(id, infoBuf))
|
sl@0
|
661 |
{
|
sl@0
|
662 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
663 |
}
|
sl@0
|
664 |
|
sl@0
|
665 |
// Pass control back to the first process
|
sl@0
|
666 |
RSemaphore sem;
|
sl@0
|
667 |
if(KErrNone == sem.OpenGlobal(KMultiProcessSemaphore))
|
sl@0
|
668 |
{
|
sl@0
|
669 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
670 |
}
|
sl@0
|
671 |
sem.Signal();
|
sl@0
|
672 |
|
sl@0
|
673 |
RSemaphore sem2;
|
sl@0
|
674 |
if(KErrNone == sem2.OpenGlobal(KMultiProcessSemaphore2))
|
sl@0
|
675 |
{
|
sl@0
|
676 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
677 |
}
|
sl@0
|
678 |
sem2.Wait();
|
sl@0
|
679 |
|
sl@0
|
680 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
681 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
682 |
|
sl@0
|
683 |
// CleanupStack::PopAndDestroy(3,&handle);
|
sl@0
|
684 |
sem.Close();
|
sl@0
|
685 |
sem2.Close();
|
sl@0
|
686 |
handle.Close();
|
sl@0
|
687 |
}
|
sl@0
|
688 |
|
sl@0
|
689 |
/**
|
sl@0
|
690 |
Test 31: Test that a buffer written to in one surface can be read from in another
|
sl@0
|
691 |
|
sl@0
|
692 |
Process 1: Create Surface
|
sl@0
|
693 |
Process 1: Map Surface
|
sl@0
|
694 |
Process 1: Write to buffer
|
sl@0
|
695 |
Process 2: Open the surface
|
sl@0
|
696 |
Process 2: Read from buffer
|
sl@0
|
697 |
*/
|
sl@0
|
698 |
void CTestDriverSecondProcess::TestReadFromBufferInSecondProcess()
|
sl@0
|
699 |
{
|
sl@0
|
700 |
// Find the surfaceId
|
sl@0
|
701 |
TSurfaceId id = iChunkWrapper->GetId();
|
sl@0
|
702 |
|
sl@0
|
703 |
// Open Surface
|
sl@0
|
704 |
if(KErrNone == iSurfaceManager.OpenSurface(id))
|
sl@0
|
705 |
{
|
sl@0
|
706 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
707 |
}
|
sl@0
|
708 |
|
sl@0
|
709 |
// Map surface
|
sl@0
|
710 |
RChunk handle;
|
sl@0
|
711 |
if(KErrNone == iSurfaceManager.MapSurface(id, handle))
|
sl@0
|
712 |
{
|
sl@0
|
713 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
714 |
}
|
sl@0
|
715 |
|
sl@0
|
716 |
// Read from the buffer
|
sl@0
|
717 |
RSurfaceManager::TInfoBuf infoBuf;
|
sl@0
|
718 |
if(KErrNone == iSurfaceManager.SurfaceInfo(id, infoBuf))
|
sl@0
|
719 |
{
|
sl@0
|
720 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
721 |
}
|
sl@0
|
722 |
RSurfaceManager::TSurfaceInfoV01& info = infoBuf();
|
sl@0
|
723 |
TUint8* surfaceAdd = handle.Base();
|
sl@0
|
724 |
TInt offsetToFirstBuffer;
|
sl@0
|
725 |
if(KErrNone == iSurfaceManager.GetBufferOffset(id, 0, offsetToFirstBuffer))
|
sl@0
|
726 |
{
|
sl@0
|
727 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
728 |
}
|
sl@0
|
729 |
TUint8* bufferAdd = surfaceAdd + offsetToFirstBuffer;
|
sl@0
|
730 |
if(*bufferAdd == 134)
|
sl@0
|
731 |
{
|
sl@0
|
732 |
iTestResult |= EFifthTestPassed;
|
sl@0
|
733 |
}
|
sl@0
|
734 |
|
sl@0
|
735 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
736 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
737 |
|
sl@0
|
738 |
handle.Close();
|
sl@0
|
739 |
}
|
sl@0
|
740 |
|
sl@0
|
741 |
void CTestDriverSecondProcess::TestGetSurfaceHint()
|
sl@0
|
742 |
{
|
sl@0
|
743 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
744 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
745 |
|
sl@0
|
746 |
RSurfaceManager::THintPair hintPair;
|
sl@0
|
747 |
hintPair.iKey.iUid = 0x124578;
|
sl@0
|
748 |
if (KErrAccessDenied == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair))
|
sl@0
|
749 |
{
|
sl@0
|
750 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
751 |
}
|
sl@0
|
752 |
|
sl@0
|
753 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
754 |
{
|
sl@0
|
755 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
756 |
}
|
sl@0
|
757 |
|
sl@0
|
758 |
if (KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair))
|
sl@0
|
759 |
{
|
sl@0
|
760 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
761 |
}
|
sl@0
|
762 |
|
sl@0
|
763 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
764 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
765 |
|
sl@0
|
766 |
}
|
sl@0
|
767 |
|
sl@0
|
768 |
|
sl@0
|
769 |
void CTestDriverSecondProcess::TestSetSurfaceHint()
|
sl@0
|
770 |
{
|
sl@0
|
771 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
772 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
773 |
|
sl@0
|
774 |
RSurfaceManager::THintPair hintPair;
|
sl@0
|
775 |
hintPair.iKey.iUid = 0x124578;
|
sl@0
|
776 |
hintPair.iValue = 300;
|
sl@0
|
777 |
|
sl@0
|
778 |
if (KErrAccessDenied == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair))
|
sl@0
|
779 |
{
|
sl@0
|
780 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
781 |
}
|
sl@0
|
782 |
|
sl@0
|
783 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
784 |
{
|
sl@0
|
785 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
786 |
}
|
sl@0
|
787 |
|
sl@0
|
788 |
if (KErrNone == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair))
|
sl@0
|
789 |
{
|
sl@0
|
790 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
791 |
}
|
sl@0
|
792 |
RSurfaceManager::THintPair hintPairNew;
|
sl@0
|
793 |
hintPairNew.iKey.iUid = 0x124578;
|
sl@0
|
794 |
|
sl@0
|
795 |
iSurfaceManager.GetSurfaceHint(surfaceId,hintPairNew);
|
sl@0
|
796 |
if (hintPairNew.iValue == hintPair.iValue)
|
sl@0
|
797 |
{
|
sl@0
|
798 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
799 |
}
|
sl@0
|
800 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
801 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
802 |
|
sl@0
|
803 |
}
|
sl@0
|
804 |
|
sl@0
|
805 |
|
sl@0
|
806 |
void CTestDriverSecondProcess::TestAddSurfaceHint()
|
sl@0
|
807 |
{
|
sl@0
|
808 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
809 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
810 |
|
sl@0
|
811 |
RSurfaceManager::THintPair hintPair;
|
sl@0
|
812 |
hintPair.iKey.iUid = 0x124580;
|
sl@0
|
813 |
hintPair.iValue = 300;
|
sl@0
|
814 |
hintPair.iMutable = ETrue;
|
sl@0
|
815 |
if (KErrAccessDenied == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair))
|
sl@0
|
816 |
{
|
sl@0
|
817 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
818 |
}
|
sl@0
|
819 |
|
sl@0
|
820 |
if(KErrNone == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
821 |
{
|
sl@0
|
822 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
823 |
}
|
sl@0
|
824 |
|
sl@0
|
825 |
if (KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair))
|
sl@0
|
826 |
{
|
sl@0
|
827 |
iTestResult |= EThirdTestPassed;
|
sl@0
|
828 |
}
|
sl@0
|
829 |
RSurfaceManager::THintPair hintPairNew;
|
sl@0
|
830 |
hintPairNew.iKey.iUid = 0x124580;
|
sl@0
|
831 |
|
sl@0
|
832 |
iSurfaceManager.GetSurfaceHint(surfaceId,hintPairNew);
|
sl@0
|
833 |
if (hintPairNew.iValue == hintPair.iValue)
|
sl@0
|
834 |
{
|
sl@0
|
835 |
iTestResult |= EFourthTestPassed;
|
sl@0
|
836 |
}
|
sl@0
|
837 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
838 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
839 |
|
sl@0
|
840 |
}
|
sl@0
|
841 |
|
sl@0
|
842 |
|
sl@0
|
843 |
void CTestDriverSecondProcess::TestOutofMemory()
|
sl@0
|
844 |
{
|
sl@0
|
845 |
// Open the chunk wrapper and get the surfaceId
|
sl@0
|
846 |
TSurfaceId surfaceId = iChunkWrapper->GetId();
|
sl@0
|
847 |
// Test OOM in OpenSurface()
|
sl@0
|
848 |
__KHEAP_SETFAIL(RHeap::EDeterministic, 1);
|
sl@0
|
849 |
if (KErrNoMemory == iSurfaceManager.OpenSurface(surfaceId))
|
sl@0
|
850 |
{
|
sl@0
|
851 |
iTestResult |= EFirstTestPassed;
|
sl@0
|
852 |
}
|
sl@0
|
853 |
__KHEAP_RESET;
|
sl@0
|
854 |
// Test OOM in AddConnection()
|
sl@0
|
855 |
RSurfaceManager surfaceManagerTest;
|
sl@0
|
856 |
__KHEAP_SETFAIL(RHeap::EDeterministic, 1);
|
sl@0
|
857 |
if (KErrNoMemory == surfaceManagerTest.Open())
|
sl@0
|
858 |
{
|
sl@0
|
859 |
iTestResult |= ESecondTestPassed;
|
sl@0
|
860 |
}
|
sl@0
|
861 |
__KHEAP_RESET;
|
sl@0
|
862 |
// Set the results so they can be read and tested by the first process
|
sl@0
|
863 |
iChunkWrapper->SetSecondProcessResults(iTestResult);
|
sl@0
|
864 |
}
|
sl@0
|
865 |
// Real main function
|
sl@0
|
866 |
void MainL()
|
sl@0
|
867 |
{
|
sl@0
|
868 |
|
sl@0
|
869 |
test.Title();
|
sl@0
|
870 |
RDebug::Print(_L("marker"));
|
sl@0
|
871 |
|
sl@0
|
872 |
test.Start(_L("Starting 2nd Process"));
|
sl@0
|
873 |
TInt testCase;
|
sl@0
|
874 |
User::GetTIntParameter(EMultiProcessSecondSlot, testCase);
|
sl@0
|
875 |
TInt procHandles1 =0;
|
sl@0
|
876 |
TInt threadHandles1=0;
|
sl@0
|
877 |
RThread().HandleCount(procHandles1, threadHandles1);
|
sl@0
|
878 |
|
sl@0
|
879 |
CTestDriverSecondProcess* testDriver = CTestDriverSecondProcess::NewL();
|
sl@0
|
880 |
CleanupStack::PushL(testDriver);
|
sl@0
|
881 |
|
sl@0
|
882 |
switch(testCase)
|
sl@0
|
883 |
{
|
sl@0
|
884 |
case ETestInfoReceivedSurface:
|
sl@0
|
885 |
testDriver->TestSurfaceInfoUsingSurfaceId();
|
sl@0
|
886 |
break;
|
sl@0
|
887 |
case ETestOpenReceivedSurface:
|
sl@0
|
888 |
testDriver->TestOpeningSurfaceUsingSurfaceId();
|
sl@0
|
889 |
break;
|
sl@0
|
890 |
case ETestOpenSurfaceInvalidParams:
|
sl@0
|
891 |
testDriver->TestOpeningSurfaceInvalidParams();
|
sl@0
|
892 |
break;
|
sl@0
|
893 |
case EOpenWaitMap:
|
sl@0
|
894 |
testDriver->OpenWaitMap();
|
sl@0
|
895 |
break;
|
sl@0
|
896 |
case ECreateWaitKill:
|
sl@0
|
897 |
testDriver->CreateWaitKill();
|
sl@0
|
898 |
break;
|
sl@0
|
899 |
case EOpenClose:
|
sl@0
|
900 |
testDriver->OpenClose();
|
sl@0
|
901 |
break;
|
sl@0
|
902 |
case EMapSurfaceInfoCantAccess:
|
sl@0
|
903 |
testDriver->MapSurfaceInfoCantAccess();
|
sl@0
|
904 |
break;
|
sl@0
|
905 |
case EReadFromBuffer:
|
sl@0
|
906 |
testDriver->TestReadFromBufferInSecondProcess();
|
sl@0
|
907 |
break;
|
sl@0
|
908 |
case ECheckHandle:
|
sl@0
|
909 |
testDriver->TestCheckHandleInSecondProcess();
|
sl@0
|
910 |
break;
|
sl@0
|
911 |
case ESyncOperation:
|
sl@0
|
912 |
testDriver->TestCheckSyncOperation();
|
sl@0
|
913 |
break;
|
sl@0
|
914 |
case ETestChannelMultiProcess1:
|
sl@0
|
915 |
testDriver->TestMultipleChannelsInSecondProcess1();
|
sl@0
|
916 |
break;
|
sl@0
|
917 |
case ETestChannelMultiProcess2:
|
sl@0
|
918 |
testDriver->TestMultipleChannelsInSecondProcess2();
|
sl@0
|
919 |
break;
|
sl@0
|
920 |
case EGetSurfaceHint:
|
sl@0
|
921 |
testDriver->TestGetSurfaceHint();
|
sl@0
|
922 |
break;
|
sl@0
|
923 |
case ESetSurfaceHint:
|
sl@0
|
924 |
testDriver->TestSetSurfaceHint();
|
sl@0
|
925 |
break;
|
sl@0
|
926 |
case EAddSurfaceHint:
|
sl@0
|
927 |
testDriver->TestAddSurfaceHint();
|
sl@0
|
928 |
break;
|
sl@0
|
929 |
case ECheckOutofMemory:
|
sl@0
|
930 |
#ifdef _DEBUG
|
sl@0
|
931 |
testDriver->TestOutofMemory();
|
sl@0
|
932 |
#endif
|
sl@0
|
933 |
break;
|
sl@0
|
934 |
default:
|
sl@0
|
935 |
User::Leave(KErrArgument);
|
sl@0
|
936 |
break;
|
sl@0
|
937 |
}
|
sl@0
|
938 |
CleanupStack::PopAndDestroy(testDriver);
|
sl@0
|
939 |
|
sl@0
|
940 |
// Handle check
|
sl@0
|
941 |
TInt procHandles2 =0;
|
sl@0
|
942 |
TInt threadHandles2=0;
|
sl@0
|
943 |
RThread().HandleCount(procHandles2,threadHandles2);
|
sl@0
|
944 |
if (threadHandles1 != threadHandles2)
|
sl@0
|
945 |
{
|
sl@0
|
946 |
User::Leave(KErrGeneral); // Thread-owned handles not closed
|
sl@0
|
947 |
}
|
sl@0
|
948 |
|
sl@0
|
949 |
|
sl@0
|
950 |
test.End();
|
sl@0
|
951 |
test.Close();
|
sl@0
|
952 |
}
|
sl@0
|
953 |
|
sl@0
|
954 |
// Cleanup stack harness
|
sl@0
|
955 |
GLDEF_C TInt E32Main()
|
sl@0
|
956 |
{
|
sl@0
|
957 |
__UHEAP_MARK;
|
sl@0
|
958 |
CTrapCleanup* cleanupStack = CTrapCleanup::New();
|
sl@0
|
959 |
TRAPD(error, MainL());
|
sl@0
|
960 |
_LIT(KTSecondProcessPanic,"tsecondprocessmain");
|
sl@0
|
961 |
__ASSERT_ALWAYS(!error, User::Panic(KTSecondProcessPanic, error));
|
sl@0
|
962 |
delete cleanupStack;
|
sl@0
|
963 |
__UHEAP_MARKEND;
|
sl@0
|
964 |
return 0;
|
sl@0
|
965 |
}
|