|
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 multi-processed test code |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32cons.h> |
|
26 #include <e32test.h> |
|
27 #include <e32std.h> |
|
28 #include <e32cmn.h> |
|
29 #include <e32def.h> |
|
30 #include "tsurfacemanagermultiprocess.h" |
|
31 |
|
32 _LIT(KSecondProcess,"tsecondprocess.exe"); |
|
33 _LIT(KThirdProcess,"tthirdprocess.exe"); |
|
34 |
|
35 |
|
36 CTSurfaceManagerMultiProcess::CTSurfaceManagerMultiProcess(CTestStep* aStep): |
|
37 CTGraphicsBase(aStep) |
|
38 { |
|
39 } |
|
40 |
|
41 CTSurfaceManagerMultiProcess::~CTSurfaceManagerMultiProcess() |
|
42 { |
|
43 } |
|
44 |
|
45 void CTSurfaceManagerMultiProcess::RunTestCaseL(TInt aCurTestCase) |
|
46 { |
|
47 TInt procHandles1 =0; |
|
48 TInt threadHandles1=0; |
|
49 RThread().HandleCount(procHandles1, threadHandles1); |
|
50 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
51 |
|
52 switch(aCurTestCase) |
|
53 { |
|
54 /** |
|
55 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0083 |
|
56 @SYMPREQ PREQ 1879,PREQ1007 |
|
57 @SYMREQ REQ8222,REQ8223 |
|
58 @SYMTestPriority High |
|
59 @SYMTestCaseDesc Test mapping a surface created in the existing shared chunk to a different process |
|
60 Process 1: Create a surface in a new shared chunk with valid attributes |
|
61 Process 1: Map the surface in the current process to get the chunk handle. |
|
62 Process 1: Create another surface in the existing chunk (rotation of the first) |
|
63 Process 2: Open and Map the second surface in and get the second chunk handles |
|
64 Process 2: Check these two chunks handles are different |
|
65 Process 2: Get the pixel start address of the pixel data for the second surface via the second chunk handle and write a number to it |
|
66 Process 1: Get the pixel start address of the pixel data for the first surface via the first chunk handle and read the number. |
|
67 Process 1: Check the number is identical to what we write to in the second process. |
|
68 @SYMTestStatus Implemented |
|
69 @SYMTestActions Call CreateSurface(),OpenSurface(), MapSurface(), SurfaceInfo() |
|
70 @SYMTestExpectedResults Mapping one surface created in the existing shared chunk to the other process will not alter the surface chunk memory |
|
71 */ |
|
72 case 1: |
|
73 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0083")); |
|
74 TestMapSurfaceExistinChunkL(); |
|
75 break; |
|
76 /** |
|
77 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0084 |
|
78 @SYMPREQ PREQ 1879,PREQ1007 |
|
79 @SYMREQ REQ8222,REQ8223 |
|
80 @SYMTestPriority High |
|
81 @SYMTestCaseDesc Test that the API SynchronizeCache() behaves correctly in the multi-process case. |
|
82 Process 1: Create the surface in a new shared chunk with valid creation attributes. The cache attribute is set to ECached. |
|
83 Process 2: Open the surface and map it in the current process to get the chunk handle |
|
84 Process 2: Synchronise the cache before the hardware writes to the buffer. Pass TSyncOperation::ESyncBeforeHandwareWrite, valid buffer number and surfaceID in SynchronizeCache() |
|
85 Process 2: Synchronise again the cache after the hardware write the buffer. Pass TSyncOperation::ESyncAfterHandwareWrite, valid buffer number and surfaceID in SynchronizeCache() |
|
86 Process 1: Synchronise again the cache before the hardware reads the buffer. Pass TSyncOperation::ESyncBeforeHardwareRead, valid buffer number and surfaceID in SynchronizeCache() |
|
87 @SYMTestStatus Implemented |
|
88 @SYMTestActions Call CreateSurface(),OpenSurface(), MapSurface(), SurfaceInfo() |
|
89 @SYMTestExpectedResults All synchronisation operation return KErrNone, the surface memory is synchronised properly with cached contents. |
|
90 */ |
|
91 case 2: |
|
92 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0084")); |
|
93 TestSynchronizeCacheMultiProcessL(); |
|
94 break; |
|
95 /** |
|
96 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0046 |
|
97 @SYMPREQ PREQ 1879,PREQ1007 |
|
98 @SYMREQ REQ8222,REQ8223 |
|
99 @SYMTestPriority High |
|
100 @SYMTestCaseDesc Testing the behaviour of closing driver channels in multiple processes when the last channel to the device driver is closed |
|
101 Process 1: Open a channel called as SurfaceManager1 to the LDD by calling RSurfaceManager::Open() |
|
102 Process 1: Create a surface SurfaceID1 using SurfaceManager1 |
|
103 Process 1: Open another channel called as SurfaceManager2 to the LDD |
|
104 Process 1: Create another surface SurfaceID2 using SurfaceManager2 |
|
105 Process 1: Open SurfaceID1 using both SurfaceManager1 and SurfaceManager2 |
|
106 Process 1: Open SurfaceID2 using both SurfaceManager1 and SurfaceManager2 |
|
107 Process 2: Open a channel to the LDD and open the surfaceID1 in the process |
|
108 Process 1: Close both channels to the LDD SurfaceManager1 and SurfaceManager2 |
|
109 Process 2: Call SurfaceInfo() on surfaceID1 and check the return is KErrNone. Call SurfaceInfo() on surfaceID2 and check it returns KErrArgument. |
|
110 Process 1: Reopen the channel to the LDD. Call SurfaceInfo() on surfaceID1. The return value is KErrNone. Call SurfaceInfo() on surfaceID2. The return value is KErrArgument. |
|
111 @SYMTestStatus Implemented |
|
112 @SYMTestActions Call CreateSurface(),OpenSurface(), MapSurface(), SurfaceInfo() |
|
113 @SYMTestExpectedResults If all the channels to the driver are closed in a process, the surfaces which have been opened in the other process will not be closed. They are still usable when the first process connects to the driver again. |
|
114 */ |
|
115 case 3: |
|
116 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0046")); |
|
117 TestCloseChannelsMultiProcess1L(); |
|
118 break; |
|
119 /** |
|
120 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0047 |
|
121 @SYMPREQ PREQ 1879,PREQ1007 |
|
122 @SYMREQ REQ8222,REQ8223 |
|
123 @SYMTestPriority High |
|
124 @SYMTestCaseDesc Testing the behaviour of closing driver channels and surfaces when the process is killed |
|
125 Process 2: Open a channel called as SurfaceManager1 to the LDD by calling RSurfaceManager::Open() |
|
126 Process 2: Create a surface SurfaceID1 using SurfaceManager1 |
|
127 Process 2: Open another channel called as SurfaceManager2 to the LDD |
|
128 Process 2: Create another surface SurfaceID2 using SurfaceManager2 |
|
129 Process 2: Open SurfaceID1 using both SurfaceManager1 and SurfaceManager2 |
|
130 Process 2: Open SurfaceID2 using both SurfaceManager1 and SurfaceManager2 |
|
131 Process 1: Open a channel called as SurfaceManager3 to the LDD and open the surfaceID1 in the process |
|
132 Process 2: Kill the process |
|
133 Process 1: Call OpenSurface() on surfaceID1 using SurfaceManager3 and check it returns KErrNone, as the surfaceID1 is still open |
|
134 Process 1: Call OpenSurface() on surfaceID2 using SurfaceManager3 and check it returns KErrArgument, as the surfaceID2 is already deleted |
|
135 Process 1: Close surfaceID1 and SurfaceManager3 |
|
136 @SYMTestStatus Implemented |
|
137 @SYMTestActions Call CreateSurface(),OpenSurface(), MapSurface(), SurfaceInfo() |
|
138 @SYMTestExpectedResults When the last channel to the surface manager by the process exiting, the surface manager will automatically close the surfaces which are open in that process. Any surfaces which were only open in that process will be deleted. |
|
139 */ |
|
140 case 4: |
|
141 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0047")); |
|
142 TestCloseChannelsMultiProcess2L(); |
|
143 break; |
|
144 /** |
|
145 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0048 |
|
146 @SYMPREQ PREQ1007 |
|
147 @SYMREQ REQ8222,REQ8223 |
|
148 @SYMTestPriority High |
|
149 @SYMTestCaseDesc Multiprocess API testing for getting information using SurfaceInfo |
|
150 Process 1: Create the Surface |
|
151 Process 2: Receive the Surface Id |
|
152 Process 2: Receive the attributes expected to be used by the surface |
|
153 Process 2: Open the surface using the id |
|
154 Process 2: Map the surface |
|
155 Process 2: Call SurfaceInfo to get the attributes of the Surface |
|
156 Process 2: Check if these are equal to the ones received. |
|
157 @SYMTestStatus Implemented |
|
158 @SYMTestActions Call CreateSurface(),OpenSurface(), MapSurface(), SurfaceInfo() |
|
159 @SYMTestExpectedResults The surface can be successfully transmitted between processes |
|
160 */ |
|
161 case 5: |
|
162 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0048")); |
|
163 TestSurfaceInfoUsingSurfaceIdL(); |
|
164 break; |
|
165 /** |
|
166 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0049 |
|
167 @SYMPREQ PREQ1007 |
|
168 @SYMREQ REQ8222,REQ8223 |
|
169 @SYMTestPriority High |
|
170 @SYMTestCaseDesc Multiprocess API testing for opening the Surface using SurfaceId |
|
171 Priocess 1: Create the surface |
|
172 Process 2: Receive the Surface id |
|
173 Process 2: Open the Surface using the stored SurfaceId |
|
174 Process 2: Check that it returns KErrNone |
|
175 @SYMTestStatus Implemented |
|
176 @SYMTestActions Call CreateSurface(),OpenSurface() |
|
177 @SYMTestExpectedResults Check that opening the surface using a recieved id returns KErrNone |
|
178 */ |
|
179 case 6: |
|
180 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0049")); |
|
181 TestOpeningSurfaceUsingSurfaceIdL(); |
|
182 break; |
|
183 /** |
|
184 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0050 |
|
185 @SYMPREQ PREQ1007 |
|
186 @SYMREQ REQ8222,REQ8223 |
|
187 @SYMTestPriority High |
|
188 @SYMTestCaseDesc Multiprocess test for opening the surface (OpenSurface negative test) |
|
189 Receive a Surface Id from another process |
|
190 Change Surface Id by |
|
191 1. adding 500 to the SurfaceId |
|
192 2. making the Surface ID negative |
|
193 3. converting the type of the Surface ID to EInvalidSurface |
|
194 Call OpenSurface using the new SurfaceId |
|
195 @SYMTestStatus Implemented |
|
196 @SYMTestActions Call CreateSurface(),OpenSurface() |
|
197 @SYMTestExpectedResults Check that opening the surface using a modified id returns KErrArgument |
|
198 */ |
|
199 case 7: |
|
200 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0050")); |
|
201 TestOpenSurfaceInvalidParamsL(); |
|
202 break; |
|
203 /** |
|
204 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0051 |
|
205 @SYMPREQ PREQ1007 |
|
206 @SYMREQ REQ8222,REQ8223 |
|
207 @SYMTestPriority High |
|
208 @SYMTestCaseDesc Closing an unopened surface in a second process |
|
209 Process 1: Create Surface |
|
210 Process 2: Close Surface |
|
211 @SYMTestStatus Implemented |
|
212 @SYMTestActions Call CreateSurface(),CloseSurface() |
|
213 @SYMTestExpectedResults Check that CloseSurface() returns KErrAccessDenied |
|
214 */ |
|
215 case 8: |
|
216 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0051")); |
|
217 TestClosingUnopenedSurfaceL(); |
|
218 break; |
|
219 /** |
|
220 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0052 |
|
221 @SYMPREQ PREQ1007 |
|
222 @SYMREQ REQ8222,REQ8223 |
|
223 @SYMTestPriority High |
|
224 @SYMTestCaseDesc Accessing an unopened surface in a second process give KErrArgument |
|
225 @SYMTestStatus Implemented |
|
226 @SYMTestActions Call CreateSurface(),CloseSurface(), MapSurface(), SurfaceInfo() |
|
227 @SYMTestExpectedResults The surface cant be accessed/closed if it is not opened first in another process. |
|
228 */ |
|
229 case 9: |
|
230 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0052")); |
|
231 TestSurfaceInfoUnopenedSurfaceL(); |
|
232 break; |
|
233 /** |
|
234 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0053 |
|
235 @SYMPREQ PREQ1007 |
|
236 @SYMREQ REQ8222,REQ8223 |
|
237 @SYMTestPriority High |
|
238 @SYMTestCaseDesc Create, Open and Close in 3 different processes, |
|
239 leaves surface accessible in first 2 processes |
|
240 @SYMTestStatus Implemented |
|
241 @SYMTestActions Call CreateSurface(),CloseSurface(), MapSurface(), SurfaceInfo() |
|
242 @SYMTestExpectedResults The surface cant be accessed/closed if it is not opened first in another process. |
|
243 */ |
|
244 case 10: |
|
245 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0053")); |
|
246 CreateOpenCloseThreeProcessL(); |
|
247 break; |
|
248 /** |
|
249 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0054 |
|
250 @SYMPREQ PREQ1007 |
|
251 @SYMREQ REQ8222,REQ8223 |
|
252 @SYMTestPriority High |
|
253 @SYMTestCaseDesc Test surface can be accessed when creating process dies |
|
254 Process 2: Create Surface |
|
255 Process 1: Open Surface |
|
256 Process 2: Kill Process |
|
257 Process 1: Map Surface |
|
258 Process 1: Surface Info |
|
259 @SYMTestStatus Implemented |
|
260 @SYMTestActions Call CreateSurface(),OpenSurface(), MapSurface(), SurfaceInfo() |
|
261 @SYMTestExpectedResults It is expected that the surface can be accessed when creating process dies |
|
262 */ |
|
263 case 11: |
|
264 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0054")); |
|
265 TestSurfaceAccessWhenCreatingProcessDiesL(); |
|
266 break; |
|
267 /** |
|
268 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0055 |
|
269 @SYMPREQ PREQ1007 |
|
270 @SYMREQ REQ8222,REQ8223 |
|
271 @SYMTestPriority High |
|
272 @SYMTestCaseDesc Test surface can be closed when creating process dies |
|
273 Process 2: Create Surface |
|
274 Process 1: Open Surface |
|
275 Process 2: Kill Process |
|
276 Process 1: Close Surface |
|
277 @SYMTestStatus Implemented |
|
278 @SYMTestActions Call CreateSurface(),CloseSurface(), OpenSurface() |
|
279 @SYMTestExpectedResults It is expected that the surface can be closed when creating process dies |
|
280 */ |
|
281 case 12: |
|
282 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0055")); |
|
283 TestClosingSurfaceWhenCreatingProcessDiesL(); |
|
284 break; |
|
285 /** |
|
286 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0056 |
|
287 @SYMPREQ PREQ1007 |
|
288 @SYMREQ REQ8222,REQ8223 |
|
289 @SYMTestPriority High |
|
290 @SYMTestCaseDesc Test surface can be closed from third process when |
|
291 creating process dies and second process closes |
|
292 Process 2: Create Surface |
|
293 Process 1: Open Surface |
|
294 Process 3: Open Surface |
|
295 Process 2: Kill Process |
|
296 Process 1: Close Surface - KErrNone |
|
297 Process 3: Close Surface - KErrNone |
|
298 Process 3: Open Surface - KErrArgument |
|
299 @SYMTestStatus Implemented |
|
300 @SYMTestActions Call CreateSurface(),CloseSurface(), OpenSurface() |
|
301 @SYMTestExpectedResults It is expected that surface can be closed from third process when |
|
302 creating process dies and second process closes |
|
303 */ |
|
304 case 13: |
|
305 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0056")); |
|
306 TestCloseSurfaceInThirdProcessL(); |
|
307 break; |
|
308 /** |
|
309 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0057 |
|
310 @SYMPREQ PREQ1007 |
|
311 @SYMREQ REQ8222,REQ8223 |
|
312 @SYMTestPriority High |
|
313 @SYMTestCaseDesc Test surface can't be accessed in a second process when open |
|
314 and closed in the first process. |
|
315 Process 2: Create Surface |
|
316 Process 1: Open Surface |
|
317 Process 1: Close Surface |
|
318 Process 2: Kill Process |
|
319 Process 1: Open Surface |
|
320 @SYMTestStatus Implemented |
|
321 @SYMTestActions Call CreateSurface(),CloseSurface(), OpenSurface() |
|
322 @SYMTestExpectedResults It is expected that test surface can't be accessed when closed (2process) |
|
323 */ |
|
324 case 14: |
|
325 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0057")); |
|
326 TestNoAccessWhenSurfaceClosedTwoProcessL(); |
|
327 break; |
|
328 /** |
|
329 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0058 |
|
330 @SYMPREQ PREQ1007 |
|
331 @SYMREQ REQ8222,REQ8223 |
|
332 @SYMTestPriority High |
|
333 @SYMTestCaseDesc Test closing on one process doesn't prevent opening on other processes, |
|
334 provided one process still owns surface |
|
335 Process 1: Create Surface |
|
336 Process 2: Open Surface |
|
337 Process 2: Close Surface |
|
338 Process 3: Open Surface - KErrNone |
|
339 @SYMTestStatus Implemented |
|
340 @SYMTestActions Call CreateSurface(),CloseSurface(), OpenSurface() |
|
341 @SYMTestExpectedResults It is expected that closing on one process doesn't prevent opening on other processes, |
|
342 provided one process still owns surface |
|
343 */ |
|
344 case 15: |
|
345 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0058")); |
|
346 TestOpeningOnProcessAfterClosingOnOtherL(); |
|
347 break; |
|
348 /** |
|
349 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0059 |
|
350 @SYMPREQ PREQ1007 |
|
351 @SYMREQ REQ8222,REQ8223 |
|
352 @SYMTestPriority High |
|
353 @SYMTestCaseDesc Test closing on one process doesn't prevent access on other |
|
354 processes, provided one process still owns surface |
|
355 Process 1: Create Surface |
|
356 Process 2: Open Surface |
|
357 Process 2: Close Surface |
|
358 Process 1: Map Surface - KErrNone |
|
359 Process 1: SurfaceInfo - KErrNone |
|
360 @SYMTestStatus Implemented |
|
361 @SYMTestActions Call CreateSurface(),CloseSurface(), OpenSurface(), MapSurface(), SurfaceInfo() |
|
362 @SYMTestExpectedResults It is expected that closing on one process doesn't prevent access on other |
|
363 */ |
|
364 case 16: |
|
365 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0059")); |
|
366 TestAccessAfterClosingL(); |
|
367 break; |
|
368 /** |
|
369 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0060 |
|
370 @SYMPREQ PREQ1007 |
|
371 @SYMREQ REQ8222,REQ8223 |
|
372 @SYMTestPriority High |
|
373 @SYMTestCaseDesc Test closing a surface in the creating process when it |
|
374 has already been closed in a second process |
|
375 Process 1: Create Surface |
|
376 Process 2: Open Surface |
|
377 Process 2: Close Surface |
|
378 Process 1: Close Surface |
|
379 @SYMTestStatus Implemented |
|
380 @SYMTestActions Call CreateSurface(),CloseSurface(), OpenSurface() |
|
381 @SYMTestExpectedResults Check Close Surface in process 1 returns KErrNone |
|
382 */ |
|
383 case 17: |
|
384 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0060")); |
|
385 TestClosingAfterClosingOnOtherProcessL(); |
|
386 break; |
|
387 /** |
|
388 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0061 |
|
389 @SYMPREQ PREQ1007 |
|
390 @SYMREQ REQ8222,REQ8223 |
|
391 @SYMTestPriority High |
|
392 @SYMTestCaseDesc Test a surface cannot be accessed in a second process if not opened |
|
393 Process 1: Create Surface |
|
394 Process 2: Map Surface |
|
395 Process 2: Surface Info |
|
396 @SYMTestStatus Implemented |
|
397 @SYMTestActions Call CreateSurface(),CloseSurface(), OpenSurface() |
|
398 @SYMTestExpectedResults Check Map Surface and SurfaceInfo in the second process return KErrAccessDenied |
|
399 */ |
|
400 case 18: |
|
401 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0061")); |
|
402 TestErrSufaceAccessNotOpenL(); |
|
403 break; |
|
404 /** |
|
405 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0062 |
|
406 @SYMPREQ PREQ1007 |
|
407 @SYMREQ REQ8222,REQ8223 |
|
408 @SYMTestPriority High |
|
409 @SYMTestCaseDesc Test surface buffers written to in one process can be read from in another |
|
410 Process 1: Create Surface |
|
411 Process 1: Map Surface |
|
412 Process 1: Write to buffer |
|
413 Process 2: Open the surface |
|
414 Process 2: Read from buffer |
|
415 @SYMTestStatus Implemented |
|
416 @SYMTestActions Call CreateSurface(),MapSurface(), OpenSurface() |
|
417 @SYMTestExpectedResults Value written to buffer in process 1 is equal to value retrieved from buffer in process 2. |
|
418 */ |
|
419 case 19: |
|
420 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0062")); |
|
421 TestReadFromBufferInSecondProcessL(); |
|
422 break; |
|
423 /** |
|
424 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0063 |
|
425 @SYMPREQ PREQ1007, PREQ 1879 |
|
426 @SYMREQ REQ8222,REQ8223 |
|
427 @SYMTestPriority High |
|
428 @SYMTestCaseDesc Test that the API GetSurfaceHint() behaves correctly in the multi-process case. |
|
429 Process 1: Create the surface in a new shared chunk with valid creation attributes. |
|
430 Process 2: Set a THintPair with a key value set to 0x124580 and value set to 300, iMutable set to ETrue. |
|
431 Process 2: Call GetSurfaceHint()and Check it returns KErrAccessDenied |
|
432 Process 2: Open the surface and then Call SetSurfaceHint(), Check it returns KErrNone. |
|
433 Process 2: Call GetSurfaceHint() to retrieve the THintPair with the key value 0x124578 |
|
434 Check the THintPair has the iValue set to 20 and iMutable set to ETrue. |
|
435 @SYMTestStatus Implemented |
|
436 @SYMTestActions Call CreateSurface(),OpenSurface(), GetSurfaceHint() |
|
437 @SYMTestExpectedResults GetSurfaceHint() behaves properly in the multiprocess. |
|
438 */ |
|
439 case 20: |
|
440 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0063")); |
|
441 TestGetSurfaceHintMultiProcessL(); |
|
442 break; |
|
443 /** |
|
444 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0064 |
|
445 @SYMPREQ PREQ1007, PREQ 1879 |
|
446 @SYMREQ REQ8222,REQ8223 |
|
447 @SYMTestPriority High |
|
448 @SYMTestCaseDesc Test that the API SetSurfaceHint() behaves correctly in the multi-process case. |
|
449 Process 1: Create the surface in a new shared chunk with valid creation attributes. |
|
450 Process 2: Set a THintPair with a key value set to 0x124580 and value set to 300, iMutable set to ETrue. |
|
451 Process 2: Call SetSurfaceHint()and Check it returns KErrAccessDenied |
|
452 Process 2: Open the surface and then Call SetSurfaceHint(), Check it returns KErrNone. |
|
453 Process 2: Call GetSurfaceHint() to retrieve the THintPair with the key value 0x124578 |
|
454 Check the retrieved THintPair has the iValue set to 300. |
|
455 @SYMTestStatus Implemented |
|
456 @SYMTestActions Call CreateSurface(),OpenSurface(), SetSurfaceHint(),GetSurfaceHint() |
|
457 @SYMTestExpectedResults SetSurfaceHint() behaves properly in the multiprocess. |
|
458 */ |
|
459 case 21: |
|
460 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0064")); |
|
461 TestSetSurfaceHintMultiProcessL(); |
|
462 break; |
|
463 /** |
|
464 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0065 |
|
465 @SYMPREQ PREQ1007, PREQ 1879 |
|
466 @SYMREQ REQ8222,REQ8223 |
|
467 @SYMTestPriority High |
|
468 @SYMTestCaseDesc Test that the API AddSurfaceHint() behaves correctly in the multi-process case. |
|
469 Process 1: Process 1: Create the surface in a new shared chunk with valid creation attributes. |
|
470 Process 2: Set a THintPair with a key value set to 0x124580 and value set to 300, iMutable set to ETrue. |
|
471 Process 2: Call AddSurfaceHint()and Check it returns KErrAccessDenied |
|
472 Process 2: Open the surface and then Call AddSurfaceHint(), Check it returns KErrNone. |
|
473 Process 2: Call GetSurfaceHint() to retrieve the THintPair with the key value 0x124580 |
|
474 Check the retrieved THintPair has the iValue set to 300 and iMutable set to ETrue. |
|
475 @SYMTestStatus Implemented |
|
476 @SYMTestActions Call CreateSurface(),OpenSurface(), GetSurfaceHint(), AddSurfaceHint() |
|
477 @SYMTestExpectedResults AddSurfaceHint() behaves properly in the multiprocess. |
|
478 */ |
|
479 case 22: |
|
480 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0065")); |
|
481 TestAddSurfaceHintMultiProcessL(); |
|
482 break; |
|
483 /** |
|
484 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0066 |
|
485 @SYMPREQ PREQ1007, PREQ 1879 |
|
486 @SYMREQ REQ8222,REQ8223 |
|
487 @SYMTestPriority High |
|
488 @SYMTestCaseDesc Testing how OpenSurface() and AddConnection() behanves under out of memory conditions |
|
489 Process 1: Create a surface and pass it in to the second process |
|
490 Process 2: Open the surface manager, inducing a kernel alloc failure on each possible kernel alloc with the use of MACRO(__KHEAP_SETFAIL). |
|
491 Check that returns KerrNoMemory |
|
492 Process 2: Call OpenSurface() on the new shared chunk, inducing a kernel alloc failure on each possible kernel alloc with the use of MACRO(__KHEAP_SETFAIL). |
|
493 Check that returns KerrNoMemory |
|
494 @SYMTestStatus Implemented |
|
495 @SYMTestActions Call CreateSurface(),OpenSurface(), RSurfaceManager::Open() |
|
496 @SYMTestExpectedResults OpenSurface and AddConnection should return KerrNoMemory. |
|
497 */ |
|
498 case 23: |
|
499 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
500 #ifdef _DEBUG |
|
501 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0066")); |
|
502 TestOutofMemoryCasesL(); |
|
503 #endif |
|
504 break; |
|
505 default: |
|
506 ((CTSurfaceManagerMultiProcessStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
507 ((CTSurfaceManagerMultiProcessStep*)iStep)->CloseTMSGraphicsStep(); |
|
508 TestComplete(); |
|
509 break; |
|
510 } |
|
511 ((CTSurfaceManagerMultiProcessStep*)iStep)->RecordTestResultL(); |
|
512 // Handle check |
|
513 TInt procHandles2 =0; |
|
514 TInt threadHandles2=0; |
|
515 RThread().HandleCount(procHandles2,threadHandles2); |
|
516 if (threadHandles1 != threadHandles2) |
|
517 { |
|
518 User::Leave(KErrGeneral); // Thread-owned handles not closed |
|
519 } |
|
520 |
|
521 } |
|
522 |
|
523 void CTSurfaceManagerMultiProcess::TestMapSurfaceExistinChunkL() |
|
524 { |
|
525 // Create a surface in a new shared chunk |
|
526 INFO_PRINTF1(_L("Test mapping a surface created in the existing shared chunk to a different process\r\n")); |
|
527 // Open the surface manager |
|
528 RSurfaceManager surfaceManager; |
|
529 User::LeaveIfError(surfaceManager.Open()); |
|
530 CleanupClosePushL(surfaceManager); |
|
531 |
|
532 TRequestStatus status; |
|
533 // Setup attributes |
|
534 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
535 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
536 attributes.iSize = TSize(100,100); |
|
537 attributes.iBuffers = 1; // number of buffers in the surface |
|
538 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
539 attributes.iStride = 400; // Number of bytes between start of one line and start of next |
|
540 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
541 attributes.iAlignment = 2; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
542 attributes.iMappable = ETrue; |
|
543 |
|
544 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
545 attributes.iHintCount = 2; |
|
546 attributes.iSurfaceHints = hints; |
|
547 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
548 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
549 |
|
550 attributes.iContiguous = ETrue; |
|
551 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
552 attributes.iOffsetBetweenBuffers = 0; |
|
553 |
|
554 // Test create surface doesn't return an error |
|
555 TSurfaceId surfaceId; |
|
556 |
|
557 // Test create surface doesn't return an error |
|
558 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
559 |
|
560 //store all the attributes |
|
561 RSurfaceManager::TInfoBuf infoBuf; |
|
562 TEST(KErrNone == surfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
563 |
|
564 //Map the surface in the current processs |
|
565 RChunk handle; |
|
566 TEST(KErrNone == surfaceManager.MapSurface(surfaceId,handle)); |
|
567 |
|
568 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
569 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
570 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = buff(); |
|
571 |
|
572 attributesNew.iSize = TSize(480,16); |
|
573 attributesNew.iBuffers = 2; // number of buffers in the surface |
|
574 attributesNew.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
575 attributesNew.iStride = 1013; // Number of bytes between start of one line and start of next |
|
576 attributesNew.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
577 attributesNew.iMappable = ETrue; |
|
578 |
|
579 attributes.iHintCount = 1; |
|
580 attributes.iSurfaceHints = hints; |
|
581 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
582 |
|
583 attributesNew.iAlignment = RSurfaceManager::EPageAligned; |
|
584 attributesNew.iOffsetBetweenBuffers = 0; |
|
585 |
|
586 // Test create surface doesn't return an error |
|
587 TSurfaceId surfaceIdNew; |
|
588 // Test create surface doesn't return an error |
|
589 // For the time being KErrArgument will be returned as the core codes are |
|
590 // not ready to check the passed in shared chunk handle. |
|
591 TEST(KErrNone == surfaceManager.CreateSurface(buff, surfaceIdNew, handle)); |
|
592 |
|
593 iInfo2.iSurfaceId = surfaceId; |
|
594 iInfo2.iSurfaceManager = surfaceManager; |
|
595 |
|
596 // Create a TCleanupItem object |
|
597 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
598 |
|
599 // Save the surfaceId to the shared chunk |
|
600 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
601 chunkWrapper->SetId(surfaceId); |
|
602 CleanupStack::Pop(); |
|
603 |
|
604 // Create a second process |
|
605 RProcess process; |
|
606 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
607 |
|
608 // Specify the test for the second process |
|
609 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ECheckHandle)); |
|
610 // Kick off the second process and wait for it to complete |
|
611 // The actual testing is done in the second process |
|
612 process.Logon(status); |
|
613 process.Resume(); |
|
614 User::WaitForRequest(status); |
|
615 |
|
616 // Check the results of the second process tests |
|
617 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
618 TEST(result & EFirstTestPassed); |
|
619 TEST(result & ESecondTestPassed); |
|
620 TEST(result & EThirdTestPassed); |
|
621 |
|
622 |
|
623 // Get the adress of this chunk of memory |
|
624 TUint8* surfaceAdd = handle.Base(); |
|
625 TUint8* bufferAdd = surfaceAdd + attributes.iOffsetToFirstBuffer; |
|
626 |
|
627 // Reads from first buffer, and test the value is written |
|
628 TInt temp = *bufferAdd; |
|
629 TEST(temp == 20); |
|
630 |
|
631 // Delete the chunkWrapper |
|
632 delete chunkWrapper; |
|
633 process.Close(); |
|
634 handle.Close(); |
|
635 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
636 } |
|
637 |
|
638 void CTSurfaceManagerMultiProcess::TestSynchronizeCacheMultiProcessL() |
|
639 { |
|
640 // Create a surface in a new shared chunk |
|
641 INFO_PRINTF1(_L("Test that the API SynchronizeCache() behaves correctly in the multi-process case\r\n")); |
|
642 // Open the surface manager |
|
643 RSurfaceManager surfaceManager; |
|
644 User::LeaveIfError(surfaceManager.Open()); |
|
645 CleanupClosePushL(surfaceManager); |
|
646 |
|
647 TRequestStatus status; |
|
648 // Setup attributes |
|
649 |
|
650 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
651 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
652 |
|
653 attributes.iSize = TSize(480,16); |
|
654 attributes.iBuffers = 2; // number of buffers in the surface |
|
655 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
656 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
657 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
658 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
659 |
|
660 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
661 attributes.iHintCount = 2; |
|
662 attributes.iSurfaceHints = hints; |
|
663 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
664 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
665 |
|
666 attributes.iContiguous = ETrue; |
|
667 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
668 attributes.iOffsetBetweenBuffers = 0; |
|
669 attributes.iMappable = ETrue; |
|
670 |
|
671 // Test create surface doesn't return an error |
|
672 TSurfaceId surfaceId; |
|
673 |
|
674 // Test create surface doesn't return an error |
|
675 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
676 |
|
677 iInfo2.iSurfaceManager = surfaceManager; |
|
678 iInfo2.iSurfaceId = surfaceId; |
|
679 // Create a TCleanupItem object |
|
680 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
681 |
|
682 // Save the surfaceId to the shared chunk |
|
683 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
684 chunkWrapper->SetId(surfaceId); |
|
685 CleanupStack::Pop(); |
|
686 |
|
687 // Create a second process |
|
688 RProcess process; |
|
689 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
690 |
|
691 // Specify the test for the second process |
|
692 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ESyncOperation)); |
|
693 // Kick off the second process and wait for it to complete |
|
694 // The actual testing is done in the second process |
|
695 process.Logon(status); |
|
696 process.Resume(); |
|
697 User::WaitForRequest(status); |
|
698 |
|
699 // Check the results of the second process tests |
|
700 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
701 // Only four tests were carried out in the second process |
|
702 TEST(result & EFirstTestPassed); |
|
703 TEST(result & ESecondTestPassed); |
|
704 TEST(result & EThirdTestPassed); |
|
705 TEST(result & EFourthTestPassed); |
|
706 // Delete the chunkWrapper |
|
707 delete chunkWrapper; |
|
708 process.Close(); |
|
709 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
710 |
|
711 } |
|
712 |
|
713 |
|
714 void CTSurfaceManagerMultiProcess::TestCloseChannelsMultiProcess1L() |
|
715 { |
|
716 // Create a surface in a new shared chunk |
|
717 INFO_PRINTF1(_L("Testing the behaviour of closing driver channels in multiple processes when the last channel to the device driver is closed\r\n")); |
|
718 |
|
719 // Create a semaphore |
|
720 const TInt initCount = 0; |
|
721 RSemaphore sem; |
|
722 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
723 CleanupClosePushL(sem); |
|
724 RSemaphore sem2; |
|
725 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
726 CleanupClosePushL(sem2); |
|
727 |
|
728 // Open the surface manager |
|
729 RSurfaceManager surfaceManagerOne; |
|
730 // Close the surface manager without opening it first |
|
731 INFO_PRINTF1(_L("Close the surface manager without opening it first\r\n")); |
|
732 // Is this Ok? |
|
733 // surfaceManagerOne.Close(); |
|
734 |
|
735 User::LeaveIfError(surfaceManagerOne.Open()); |
|
736 CleanupClosePushL(surfaceManagerOne); |
|
737 // Store the attributes used to create the Surface |
|
738 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
739 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
740 attributes.iSize = TSize(280,301); |
|
741 attributes.iBuffers = 1; |
|
742 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
743 attributes.iStride = 1; |
|
744 attributes.iOffsetToFirstBuffer = 1; |
|
745 attributes.iAlignment = 1; |
|
746 |
|
747 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
748 attributes.iHintCount = 2; |
|
749 attributes.iSurfaceHints = hints; |
|
750 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
751 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
752 |
|
753 attributes.iContiguous = ETrue; |
|
754 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
755 attributes.iOffsetBetweenBuffers = 0; |
|
756 attributes.iMappable = ETrue; |
|
757 |
|
758 // Create a surface |
|
759 TSurfaceId surfaceIdOne; |
|
760 TEST(KErrNone == surfaceManagerOne.CreateSurface(buf, surfaceIdOne)); |
|
761 |
|
762 RSurfaceManager surfaceManagerTwo; |
|
763 User::LeaveIfError(surfaceManagerTwo.Open()); |
|
764 CleanupClosePushL(surfaceManagerTwo); |
|
765 // Create a surface |
|
766 TSurfaceId surfaceIdTwo; |
|
767 TEST(KErrNone == surfaceManagerTwo.CreateSurface(buf,surfaceIdTwo)); |
|
768 |
|
769 TEST(KErrNone == surfaceManagerOne.OpenSurface(surfaceIdTwo)); |
|
770 TEST(KErrNone == surfaceManagerTwo.OpenSurface(surfaceIdOne)); |
|
771 |
|
772 iInfo2.iSurfaceId = surfaceIdOne; |
|
773 iInfo2.iSurfaceManager = surfaceManagerOne; |
|
774 // Create a TCleanupItem object |
|
775 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
776 |
|
777 // Save the surfaceId to the shared chunk |
|
778 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
779 chunkWrapper->SetId(surfaceIdOne); |
|
780 CleanupStack::Pop(); |
|
781 |
|
782 // Create a second process |
|
783 RProcess process; |
|
784 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
785 |
|
786 // Kick off the process and wait for it to complete |
|
787 TRequestStatus status = KRequestPending; |
|
788 process.Logon(status); |
|
789 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ETestChannelMultiProcess1)); |
|
790 process.Resume(); |
|
791 CleanupClosePushL(process); |
|
792 |
|
793 // Passes control to the second process |
|
794 sem.Wait(); |
|
795 |
|
796 // Check the results of the second process tests |
|
797 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
798 TEST(result & EFirstTestPassed); |
|
799 TEST(result & ESecondTestPassed); |
|
800 TEST(result & EThirdTestPassed); |
|
801 |
|
802 surfaceManagerOne.Close(); |
|
803 surfaceManagerTwo.Close(); |
|
804 |
|
805 // Pass control off to the second process again |
|
806 chunkWrapper->SetId(surfaceIdTwo); |
|
807 sem2.Signal(); |
|
808 |
|
809 // Wait for the second process to terminate |
|
810 User::WaitForRequest(status); |
|
811 |
|
812 |
|
813 // Copme back from the second process - find the surfaceId |
|
814 // Check that the tests in the second process have passed |
|
815 result = chunkWrapper->GetSecondProcessResults(); |
|
816 TEST(result & EFourthTestPassed); |
|
817 TEST(result & EFifthTestPassed); |
|
818 //More things to check in here |
|
819 // TEST(KErrNone == surfaceManagerOne.Open())); |
|
820 |
|
821 // Delete the chunkWrapper and the semaphore |
|
822 delete chunkWrapper; |
|
823 CleanupStack::PopAndDestroy(5, &sem); |
|
824 |
|
825 |
|
826 } |
|
827 |
|
828 void CTSurfaceManagerMultiProcess::TestCloseChannelsMultiProcess2L() |
|
829 { |
|
830 // Create a surface in a new shared chunk |
|
831 INFO_PRINTF1(_L("Testing the behaviour of closing driver channels in multiple processes when the last channel to the device driver is closed\r\n")); |
|
832 |
|
833 // Create a semaphore |
|
834 const TInt initCount = 0; |
|
835 RSemaphore sem; |
|
836 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
837 CleanupClosePushL(sem); |
|
838 RSemaphore sem2; |
|
839 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
840 CleanupClosePushL(sem2); |
|
841 |
|
842 // Create a second process |
|
843 RProcess process; |
|
844 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
845 |
|
846 // Kick off the process and wait for it to complete |
|
847 TRequestStatus status = KRequestPending; |
|
848 process.Logon(status); |
|
849 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ETestChannelMultiProcess2)); |
|
850 process.Resume(); |
|
851 CleanupClosePushL(process); |
|
852 |
|
853 // Passes control to the second process |
|
854 sem.Wait(); |
|
855 |
|
856 // Open the chunk wrapper and get the surfaceId |
|
857 CChunkWrapper* chunkWrapper = CChunkWrapper::OpenL(KSharedChunkName, ETrue); |
|
858 TSurfaceId surfaceIdOne = chunkWrapper->GetId(); |
|
859 // Check the results of the second process tests |
|
860 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
861 TEST(result & EFirstTestPassed); |
|
862 TEST(result & ESecondTestPassed); |
|
863 TEST(result & EThirdTestPassed); |
|
864 TEST(result & EFourthTestPassed); |
|
865 |
|
866 // Open the surface manager |
|
867 RSurfaceManager surfaceManagerThree; |
|
868 User::LeaveIfError(surfaceManagerThree.Open()); |
|
869 CleanupClosePushL(surfaceManagerThree); |
|
870 |
|
871 TEST(KErrNone == surfaceManagerThree.OpenSurface(surfaceIdOne)); |
|
872 // Pass control off to the second process again |
|
873 sem2.Signal(); |
|
874 |
|
875 // Wait for the second process to terminate |
|
876 User::WaitForRequest(status); |
|
877 |
|
878 TSurfaceId surfaceIdTwo = chunkWrapper->GetId(); |
|
879 |
|
880 // Call OpenSurface() on surfaceID1 using SurfaceManager3 and check it returns KErrNone, as the surfaceID1 is still open |
|
881 TEST(KErrNone == surfaceManagerThree.OpenSurface(surfaceIdOne)); |
|
882 // Call OpenSurface() on surfaceID1 using SurfaceManager3 and check it returns KErrNone, as the surfaceID1 is still open |
|
883 TEST(KErrArgument == surfaceManagerThree.OpenSurface(surfaceIdTwo)); |
|
884 |
|
885 // Delete the chunkWrapper and the semaphore |
|
886 delete chunkWrapper; |
|
887 CleanupStack::PopAndDestroy(4, &sem); |
|
888 } |
|
889 |
|
890 |
|
891 void CTSurfaceManagerMultiProcess::TestSurfaceInfoUsingSurfaceIdL() |
|
892 { |
|
893 INFO_PRINTF1(_L("Receiving a surface and querying SurfaceInfo for surface properties\r\n")); |
|
894 // Open the surface manager |
|
895 RSurfaceManager surfaceManager; |
|
896 User::LeaveIfError(surfaceManager.Open()); |
|
897 CleanupClosePushL(surfaceManager); |
|
898 |
|
899 TRequestStatus status; |
|
900 |
|
901 // Set attributs for creating the surface |
|
902 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
903 RSurfaceManager::TSurfaceCreationAttributes& attributes=buf(); |
|
904 attributes.iSize = TSize(200,200); |
|
905 attributes.iBuffers = 1; |
|
906 attributes.iPixelFormat = EUidPixelFormatARGB_1555; |
|
907 attributes.iStride = 415; |
|
908 attributes.iOffsetToFirstBuffer = 80; |
|
909 attributes.iAlignment = 8; |
|
910 attributes.iContiguous=ETrue; |
|
911 |
|
912 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
913 attributes.iHintCount = 2; |
|
914 attributes.iSurfaceHints = hints; |
|
915 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
916 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
917 |
|
918 attributes.iOffsetBetweenBuffers = 0; |
|
919 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
920 attributes.iMappable = ETrue; |
|
921 |
|
922 // Create the surface |
|
923 TSurfaceId surfaceId; |
|
924 TEST(KErrNone == surfaceManager.CreateSurface(attributes, surfaceId)); |
|
925 |
|
926 iInfo2.iSurfaceId = surfaceId; |
|
927 iInfo2.iSurfaceManager = surfaceManager; |
|
928 // Create a TCleanupItem object |
|
929 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
930 |
|
931 // Save the surfaceId to the shared chunk |
|
932 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
933 chunkWrapper->SetId(surfaceId); |
|
934 CleanupStack::Pop(); |
|
935 |
|
936 // Create a second process |
|
937 RProcess process; |
|
938 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
939 |
|
940 // Specify the test for the second process |
|
941 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ETestInfoReceivedSurface)); |
|
942 // Kick off the second process and wait for it to complete |
|
943 // The actual testing is done in the second process |
|
944 process.Logon(status); |
|
945 process.Resume(); |
|
946 User::WaitForRequest(status); |
|
947 |
|
948 // Check the results of the second process tests |
|
949 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
950 TEST(result & EFirstTestPassed); |
|
951 TEST(result & ESecondTestPassed); |
|
952 TEST(result & EThirdTestPassed); |
|
953 TEST(result & EFourthTestPassed); |
|
954 TEST(result & EFifthTestPassed); |
|
955 TEST(result & ESixthTestPassed); |
|
956 TEST(result & ESeventhTestPassed); |
|
957 TEST(result & EEighthTestPassed); |
|
958 TEST(result & ENinthTestPassed); |
|
959 |
|
960 // Delete the chunkWrapper |
|
961 delete chunkWrapper; |
|
962 process.Close(); |
|
963 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
964 |
|
965 } |
|
966 |
|
967 void CTSurfaceManagerMultiProcess::TestOpeningSurfaceUsingSurfaceIdL() |
|
968 { |
|
969 INFO_PRINTF1(_L("Test Opening a surface using surfaceId (passed from this to another process)\r\n")); |
|
970 // Open the surface manager |
|
971 RSurfaceManager surfaceManager; |
|
972 User::LeaveIfError(surfaceManager.Open()); |
|
973 CleanupClosePushL(surfaceManager); |
|
974 |
|
975 TRequestStatus status; |
|
976 |
|
977 // Set attributs for creating the surface |
|
978 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
979 RSurfaceManager::TSurfaceCreationAttributes& attributes=buf(); |
|
980 attributes.iSize = TSize(200,200); |
|
981 attributes.iBuffers = 1; |
|
982 attributes.iPixelFormat = EUidPixelFormatARGB_1555; |
|
983 attributes.iStride = 1600; |
|
984 attributes.iOffsetToFirstBuffer = 80; |
|
985 attributes.iAlignment = 8; |
|
986 attributes.iContiguous = ETrue; |
|
987 |
|
988 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
989 attributes.iHintCount = 2; |
|
990 attributes.iSurfaceHints = hints; |
|
991 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
992 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
993 |
|
994 attributes.iOffsetBetweenBuffers = 0; |
|
995 attributes.iMappable = ETrue; |
|
996 |
|
997 // Create the surface |
|
998 TSurfaceId surfaceId; |
|
999 TEST(KErrNone == surfaceManager.CreateSurface(attributes, surfaceId)); |
|
1000 |
|
1001 iInfo2.iSurfaceId = surfaceId; |
|
1002 iInfo2.iSurfaceManager = surfaceManager; |
|
1003 // Create a TCleanupItem object |
|
1004 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1005 |
|
1006 // Save the surfaceId to the shared chunk |
|
1007 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1008 chunkWrapper->SetId(surfaceId); |
|
1009 CleanupStack::Pop(); |
|
1010 |
|
1011 // Create a second process |
|
1012 RProcess process; |
|
1013 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1014 |
|
1015 // Specify the test for the second process |
|
1016 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ETestOpenReceivedSurface)); |
|
1017 process.Logon(status); |
|
1018 process.Resume(); |
|
1019 User::WaitForRequest(status); |
|
1020 |
|
1021 // Check the test results of the second process |
|
1022 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1023 TEST(result & EFirstTestPassed); |
|
1024 |
|
1025 // Delete the chunkWrapper |
|
1026 delete chunkWrapper; |
|
1027 process.Close(); |
|
1028 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
1029 |
|
1030 } |
|
1031 |
|
1032 void CTSurfaceManagerMultiProcess::TestOpenSurfaceInvalidParamsL() |
|
1033 { |
|
1034 INFO_PRINTF1(_L("Opening a surface with invalid parameters\r\n")); |
|
1035 RSurfaceManager surfaceManager; |
|
1036 User::LeaveIfError(surfaceManager.Open()); |
|
1037 CleanupClosePushL(surfaceManager); |
|
1038 |
|
1039 // Store the attributes used to create the Surface |
|
1040 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1041 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1042 |
|
1043 attributes.iSize = TSize(150,412); |
|
1044 attributes.iBuffers = 3; |
|
1045 attributes.iPixelFormat = EUidPixelFormatARGB_1555; // 2bpp |
|
1046 attributes.iStride = 1000; |
|
1047 attributes.iOffsetToFirstBuffer = 5; |
|
1048 attributes.iAlignment = 1; |
|
1049 attributes.iContiguous=EFalse; |
|
1050 |
|
1051 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1052 attributes.iHintCount = 2; |
|
1053 attributes.iSurfaceHints = hints; |
|
1054 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1055 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1056 |
|
1057 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
1058 attributes.iOffsetBetweenBuffers = 0; |
|
1059 attributes.iMappable = ETrue; |
|
1060 |
|
1061 // Create a surface - increments reference count by 1 |
|
1062 TSurfaceId surfaceId; |
|
1063 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1064 |
|
1065 iInfo2.iSurfaceId = surfaceId; |
|
1066 iInfo2.iSurfaceManager = surfaceManager; |
|
1067 // Create a TCleanupItem object |
|
1068 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1069 |
|
1070 // Save the surfaceId to the shared chunk |
|
1071 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1072 chunkWrapper->SetId(surfaceId); |
|
1073 |
|
1074 CleanupStack::Pop(); |
|
1075 |
|
1076 // Create a second process |
|
1077 RProcess process; |
|
1078 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1079 |
|
1080 // Specify the test for the second process |
|
1081 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ETestOpenSurfaceInvalidParams)); |
|
1082 // Kick off the second process and wait for it to complete |
|
1083 // The actual testing is done in the second process |
|
1084 TRequestStatus status; |
|
1085 process.Logon(status); |
|
1086 process.Resume(); |
|
1087 User::WaitForRequest(status); |
|
1088 |
|
1089 // Check the results of the second process tests |
|
1090 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1091 TEST(result & EFirstTestPassed); |
|
1092 TEST(result & ESecondTestPassed); |
|
1093 TEST(result & EThirdTestPassed); |
|
1094 |
|
1095 // Tidy up |
|
1096 delete chunkWrapper; |
|
1097 process.Close(); |
|
1098 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
1099 } |
|
1100 |
|
1101 void CTSurfaceManagerMultiProcess::TestClosingUnopenedSurfaceL() |
|
1102 { |
|
1103 INFO_PRINTF1(_L("Closing an unopened surface in a second process\r\n")); |
|
1104 // Open the surface manager |
|
1105 RSurfaceManager surfaceManager; |
|
1106 User::LeaveIfError(surfaceManager.Open()); |
|
1107 CleanupClosePushL(surfaceManager); |
|
1108 |
|
1109 // Store the attributes used to create the Surface |
|
1110 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1111 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1112 |
|
1113 attributes.iSize = TSize(280,301); |
|
1114 attributes.iBuffers = 3; |
|
1115 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1116 attributes.iStride = 605; |
|
1117 attributes.iOffsetToFirstBuffer = 4; |
|
1118 attributes.iAlignment = 4; |
|
1119 attributes.iContiguous=EFalse; |
|
1120 |
|
1121 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1122 attributes.iHintCount = 2; |
|
1123 attributes.iSurfaceHints = hints; |
|
1124 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1125 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1126 |
|
1127 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
1128 attributes.iOffsetBetweenBuffers = 0; |
|
1129 attributes.iMappable = ETrue; |
|
1130 |
|
1131 // Create the surface |
|
1132 TSurfaceId surfaceId; |
|
1133 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1134 |
|
1135 iInfo2.iSurfaceId = surfaceId; |
|
1136 iInfo2.iSurfaceManager = surfaceManager; |
|
1137 // Create a TCleanupItem object |
|
1138 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1139 |
|
1140 // Save the surfaceId to the shared chunk |
|
1141 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1142 chunkWrapper->SetId(surfaceId); |
|
1143 CleanupStack::Pop(); |
|
1144 |
|
1145 // Create a second process |
|
1146 RProcess process; |
|
1147 TEST(KErrNone == process.Create(KThirdProcess, KNullDesC)); |
|
1148 |
|
1149 // Kick off the process and wait for it to complete |
|
1150 TRequestStatus status = KRequestPending; |
|
1151 process.Logon(status); |
|
1152 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ECloseSurface)); |
|
1153 process.Resume(); |
|
1154 User::WaitForRequest(status); |
|
1155 |
|
1156 // Check the result |
|
1157 TInt result = chunkWrapper->GetThirdProcessResults(); |
|
1158 TEST(result & EFirstTestPassed); |
|
1159 |
|
1160 // Delete the chunkWrapper |
|
1161 delete chunkWrapper; |
|
1162 process.Close(); |
|
1163 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
1164 } |
|
1165 |
|
1166 |
|
1167 void CTSurfaceManagerMultiProcess::TestSurfaceInfoUnopenedSurfaceL() |
|
1168 { |
|
1169 INFO_PRINTF1(_L("Access an unopened surface in a second process\r\n")); |
|
1170 // Open the surface manager |
|
1171 RSurfaceManager surfaceManager; |
|
1172 User::LeaveIfError(surfaceManager.Open()); |
|
1173 CleanupClosePushL(surfaceManager); |
|
1174 |
|
1175 // Store the attributes used to create the Surface |
|
1176 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1177 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1178 |
|
1179 attributes.iSize = TSize(280,301); |
|
1180 attributes.iBuffers = 3; |
|
1181 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1182 attributes.iStride = 605; |
|
1183 attributes.iOffsetToFirstBuffer = 4; |
|
1184 attributes.iAlignment = 4; |
|
1185 attributes.iContiguous=EFalse; |
|
1186 |
|
1187 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1188 attributes.iHintCount = 2; |
|
1189 attributes.iSurfaceHints = hints; |
|
1190 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1191 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1192 |
|
1193 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
1194 attributes.iOffsetBetweenBuffers = 0; |
|
1195 attributes.iMappable = ETrue; |
|
1196 |
|
1197 // Create the surface |
|
1198 TSurfaceId surfaceId; |
|
1199 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1200 |
|
1201 iInfo2.iSurfaceId = surfaceId; |
|
1202 iInfo2.iSurfaceManager = surfaceManager; |
|
1203 // Create a TCleanupItem object |
|
1204 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1205 |
|
1206 // Save the surfaceId to the shared chunk |
|
1207 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1208 chunkWrapper->SetId(surfaceId); |
|
1209 CleanupStack::Pop(); |
|
1210 |
|
1211 // Create a second process |
|
1212 RProcess process; |
|
1213 TEST(KErrNone == process.Create(KThirdProcess, KNullDesC)); |
|
1214 |
|
1215 // Kick off the process and wait for it to complete |
|
1216 TRequestStatus status = KRequestPending; |
|
1217 process.Logon(status); |
|
1218 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ESurfaceInfo)); |
|
1219 process.Resume(); |
|
1220 User::WaitForRequest(status); |
|
1221 |
|
1222 // Check the result |
|
1223 TInt result = chunkWrapper->GetThirdProcessResults(); |
|
1224 TEST(result & EFirstTestPassed); |
|
1225 |
|
1226 // Delete the chunkWrapper |
|
1227 delete chunkWrapper; |
|
1228 process.Close(); |
|
1229 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
1230 |
|
1231 } |
|
1232 |
|
1233 void CTSurfaceManagerMultiProcess::CreateOpenCloseThreeProcessL() |
|
1234 { |
|
1235 INFO_PRINTF1(_L("Create Open close across 3 processes\r\n")); |
|
1236 // Open the surface manager |
|
1237 RSurfaceManager surfaceManager; |
|
1238 User::LeaveIfError(surfaceManager.Open()); |
|
1239 CleanupClosePushL(surfaceManager); |
|
1240 |
|
1241 // Store the attributes used to create the Surface |
|
1242 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1243 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1244 |
|
1245 attributes.iSize = TSize(280,230); |
|
1246 attributes.iBuffers = 3; |
|
1247 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1248 attributes.iStride = 1100; |
|
1249 attributes.iOffsetToFirstBuffer = 4; |
|
1250 attributes.iAlignment = 4; |
|
1251 attributes.iContiguous=EFalse; |
|
1252 |
|
1253 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1254 attributes.iHintCount = 2; |
|
1255 attributes.iSurfaceHints = hints; |
|
1256 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1257 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1258 |
|
1259 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
1260 attributes.iOffsetBetweenBuffers = 0; |
|
1261 attributes.iMappable = ETrue; |
|
1262 |
|
1263 // Create the surface |
|
1264 TSurfaceId surfaceId; |
|
1265 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1266 |
|
1267 // Create a semaphore |
|
1268 const TInt initCount = 0; |
|
1269 RSemaphore sem; |
|
1270 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1271 CleanupClosePushL(sem); |
|
1272 RSemaphore sem2; |
|
1273 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1274 CleanupClosePushL(sem2); |
|
1275 |
|
1276 |
|
1277 iInfo2.iSurfaceId = surfaceId; |
|
1278 iInfo2.iSurfaceManager = surfaceManager; |
|
1279 // Create a TCleanupItem object |
|
1280 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1281 |
|
1282 // Save the surfaceId to the shared chunk |
|
1283 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1284 chunkWrapper->SetId(surfaceId); |
|
1285 CleanupStack::Pop(); |
|
1286 |
|
1287 // Create a second process |
|
1288 RProcess process2; |
|
1289 TEST(KErrNone == process2.Create(KSecondProcess, KNullDesC)); |
|
1290 |
|
1291 // Kick off the process and wait for it to complete |
|
1292 TRequestStatus status2 = KRequestPending; |
|
1293 process2.Logon(status2); |
|
1294 process2.SetParameter(EMultiProcessSecondSlot, EOpenWaitMap); |
|
1295 process2.Resume(); |
|
1296 |
|
1297 // Passes control to the second process |
|
1298 sem.Wait(); |
|
1299 |
|
1300 // Create a third process |
|
1301 RProcess process3; |
|
1302 TEST(KErrNone == process3.Create(KThirdProcess, KNullDesC)); |
|
1303 |
|
1304 // Kick off the process and wait for it to complete |
|
1305 TRequestStatus status3 = KRequestPending; |
|
1306 process3.Logon(status3); |
|
1307 process3.SetParameter(EMultiProcessSecondSlot, ECloseSurface); |
|
1308 process3.Resume(); |
|
1309 |
|
1310 // Let the second process continue its work - calling MapSurface |
|
1311 sem2.Signal(); |
|
1312 |
|
1313 // Call Surface Info on the surface in this process |
|
1314 RSurfaceManager::TInfoBuf infoBuf; |
|
1315 TEST(KErrNone == surfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1316 |
|
1317 // Wait for the second process to terminate |
|
1318 User::WaitForRequest(status2); |
|
1319 |
|
1320 // Check that the tests in the second process have passed |
|
1321 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1322 TEST(result & EFirstTestPassed); |
|
1323 TEST(result & ESecondTestPassed); |
|
1324 TEST(result & EThirdTestPassed); |
|
1325 TEST(result & EFourthTestPassed); |
|
1326 |
|
1327 // Wait for the third process to terminate and chaeck the results |
|
1328 User::WaitForRequest(status3); |
|
1329 result = chunkWrapper->GetThirdProcessResults(); |
|
1330 TEST(result & EFirstTestPassed); |
|
1331 |
|
1332 // Delete the chunkWrapper and the semaphore |
|
1333 delete chunkWrapper; |
|
1334 process2.Close(); |
|
1335 process3.Close(); |
|
1336 |
|
1337 CleanupStack::PopAndDestroy(3, &surfaceManager); |
|
1338 } |
|
1339 |
|
1340 void CTSurfaceManagerMultiProcess::TestSurfaceAccessWhenCreatingProcessDiesL() |
|
1341 { |
|
1342 INFO_PRINTF1(_L("Test surface can be accessed when creating process dies\r\n")); |
|
1343 // Create two semaphores |
|
1344 const TInt initCount = 0; |
|
1345 RSemaphore sem; |
|
1346 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1347 CleanupClosePushL(sem); |
|
1348 RSemaphore sem2; |
|
1349 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1350 CleanupClosePushL(sem2); |
|
1351 |
|
1352 // Create a second process |
|
1353 RProcess process; |
|
1354 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1355 |
|
1356 // Kick off the process and wait for it to complete |
|
1357 TRequestStatus status = KRequestPending; |
|
1358 process.Logon(status); |
|
1359 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ECreateWaitKill)); |
|
1360 process.Resume(); |
|
1361 CleanupClosePushL(process); |
|
1362 |
|
1363 // Passes control to the second process |
|
1364 sem.Wait(); |
|
1365 |
|
1366 // Copme back from the second process - find the surfaceId |
|
1367 CChunkWrapper* chunkWrapper = CChunkWrapper::OpenL(KSharedChunkName, ETrue); |
|
1368 TSurfaceId surfaceId = chunkWrapper->GetId(); |
|
1369 |
|
1370 // Open the surface manager |
|
1371 RSurfaceManager surfaceManager; |
|
1372 User::LeaveIfError(surfaceManager.Open()); |
|
1373 CleanupClosePushL(surfaceManager); |
|
1374 |
|
1375 // Open the surface |
|
1376 TEST(KErrNone == surfaceManager.OpenSurface(surfaceId)); |
|
1377 |
|
1378 // Pass control off to the second process again |
|
1379 sem2.Signal(); |
|
1380 |
|
1381 // Wait for the second process to terminate |
|
1382 User::WaitForRequest(status); |
|
1383 |
|
1384 // Check that the tests in the second process have passed |
|
1385 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1386 TEST(result & EFirstTestPassed); |
|
1387 TEST(result & ESecondTestPassed); |
|
1388 TEST(result & EThirdTestPassed); |
|
1389 |
|
1390 // Map Surface |
|
1391 RChunk handle; |
|
1392 TEST(KErrNone == surfaceManager.MapSurface(surfaceId, handle)); |
|
1393 handle.Close(); |
|
1394 // Surface Info |
|
1395 RSurfaceManager::TInfoBuf infoBuf; |
|
1396 TEST(KErrNone == surfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1397 |
|
1398 TEST(KErrNone == surfaceManager.CloseSurface(surfaceId)); |
|
1399 |
|
1400 // Delete the chunkWrapper and the semaphore |
|
1401 delete chunkWrapper; |
|
1402 CleanupStack::PopAndDestroy(4, &sem); |
|
1403 } |
|
1404 |
|
1405 void CTSurfaceManagerMultiProcess::TestClosingSurfaceWhenCreatingProcessDiesL() |
|
1406 { |
|
1407 INFO_PRINTF1(_L("Test surface can be closed when creating process dies\r\n")); |
|
1408 // Create a semaphore |
|
1409 const TInt initCount = 0; |
|
1410 RSemaphore sem; |
|
1411 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1412 CleanupClosePushL(sem); |
|
1413 RSemaphore sem2; |
|
1414 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1415 CleanupClosePushL(sem2); |
|
1416 |
|
1417 // Create a second process |
|
1418 RProcess process; |
|
1419 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1420 |
|
1421 // Kick off the process and wait for it to complete |
|
1422 TRequestStatus status = KRequestPending; |
|
1423 process.Logon(status); |
|
1424 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ECreateWaitKill)); |
|
1425 process.Resume(); |
|
1426 CleanupClosePushL(process); |
|
1427 |
|
1428 // Passes control to the second process |
|
1429 sem.Wait(); |
|
1430 |
|
1431 // Copme back from the second process - find the surfaceId |
|
1432 CChunkWrapper* chunkWrapper = CChunkWrapper::OpenL(KSharedChunkName, ETrue); |
|
1433 TSurfaceId surfaceId = chunkWrapper->GetId(); |
|
1434 |
|
1435 // Open the surface manager |
|
1436 RSurfaceManager surfaceManager; |
|
1437 User::LeaveIfError(surfaceManager.Open()); |
|
1438 CleanupClosePushL(surfaceManager); |
|
1439 |
|
1440 // Open the surface |
|
1441 TEST(KErrNone == surfaceManager.OpenSurface(surfaceId)); |
|
1442 |
|
1443 // Pass control off to the second process again |
|
1444 sem2.Signal(); |
|
1445 |
|
1446 // Wait for the second process to terminate |
|
1447 User::WaitForRequest(status); |
|
1448 |
|
1449 |
|
1450 // Check that the tests in the second process have passed |
|
1451 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1452 TEST(result & EFirstTestPassed); |
|
1453 TEST(result & ESecondTestPassed); |
|
1454 TEST(result & EThirdTestPassed); |
|
1455 |
|
1456 TEST(KErrNone == surfaceManager.CloseSurface(surfaceId)); |
|
1457 |
|
1458 // Delete the chunkWrapper and the semaphore |
|
1459 delete chunkWrapper; |
|
1460 CleanupStack::PopAndDestroy(4, &sem); |
|
1461 } |
|
1462 |
|
1463 void CTSurfaceManagerMultiProcess::TestCloseSurfaceInThirdProcessL() |
|
1464 { |
|
1465 INFO_PRINTF1(_L("Test surface access in a third process\r\n")); |
|
1466 // Create 2 semaphores for signalling between process 1 and process 2 |
|
1467 const TInt initCount = 0; |
|
1468 RSemaphore sem; |
|
1469 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1470 CleanupClosePushL(sem); |
|
1471 RSemaphore sem2; |
|
1472 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1473 CleanupClosePushL(sem2); |
|
1474 |
|
1475 // Create a second process |
|
1476 RProcess process2; |
|
1477 TEST(KErrNone == process2.Create(KSecondProcess, KNullDesC)); |
|
1478 |
|
1479 // Kick off the process and wait for it to complete |
|
1480 TRequestStatus status2 = KRequestPending; |
|
1481 process2.Logon(status2); |
|
1482 process2.SetParameter(EMultiProcessSecondSlot, ECreateWaitKill); |
|
1483 process2.Resume(); |
|
1484 CleanupClosePushL(process2); |
|
1485 |
|
1486 // Passes control to the second process |
|
1487 sem.Wait(); |
|
1488 |
|
1489 // Come back from the second process - find the surfaceId |
|
1490 CChunkWrapper* chunkWrapper = CChunkWrapper::OpenL(KSharedChunkName, ETrue); |
|
1491 TSurfaceId surfaceId = chunkWrapper->GetId(); |
|
1492 |
|
1493 // Open the surface manager |
|
1494 RSurfaceManager surfaceManager; |
|
1495 User::LeaveIfError(surfaceManager.Open()); |
|
1496 CleanupClosePushL(surfaceManager); |
|
1497 |
|
1498 // Open the surface |
|
1499 TEST(KErrNone == surfaceManager.OpenSurface(surfaceId)); |
|
1500 |
|
1501 // Create another two semaphores for signalling between process 1 and process 3 |
|
1502 RSemaphore sem3; |
|
1503 TEST(KErrNone == sem3.CreateGlobal(KMultiProcessSemaphore3, initCount)); |
|
1504 |
|
1505 RSemaphore sem4; |
|
1506 TEST(KErrNone == sem4.CreateGlobal(KMultiProcessSemaphore4, initCount)); |
|
1507 |
|
1508 // Create a third process |
|
1509 RProcess process3; |
|
1510 TEST(KErrNone == process3.Create(KThirdProcess, KNullDesC)); |
|
1511 |
|
1512 // Kick off the process and wait for it to complete |
|
1513 TRequestStatus status3 = KRequestPending; |
|
1514 process3.Logon(status3); |
|
1515 process3.SetParameter(EMultiProcessSecondSlot, EOpenWaitCloseOpen); |
|
1516 process3.Resume(); |
|
1517 |
|
1518 // Passes control to the third process - opens the surface |
|
1519 sem3.Wait(); |
|
1520 |
|
1521 // Pass control to the second process again - kill the process |
|
1522 sem2.Signal(); |
|
1523 |
|
1524 // Wait for the third process to terminate |
|
1525 User::WaitForRequest(status2); |
|
1526 |
|
1527 // Check that the tests in the second process have passed |
|
1528 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1529 TEST(result & EFirstTestPassed); |
|
1530 TEST(result & ESecondTestPassed); |
|
1531 TEST(result & EThirdTestPassed); |
|
1532 |
|
1533 // Close the surface |
|
1534 TEST(KErrNone == surfaceManager.CloseSurface(surfaceId)); |
|
1535 |
|
1536 // Pass control to the third process - close the surface |
|
1537 sem4.Signal(); |
|
1538 |
|
1539 // Wait for the third process to terminate |
|
1540 User::WaitForRequest(status3); |
|
1541 |
|
1542 // Check that the tests in the third process have passed |
|
1543 result = chunkWrapper->GetThirdProcessResults(); |
|
1544 TEST(result & EFirstTestPassed); |
|
1545 TEST(result & ESecondTestPassed); |
|
1546 TEST(result & EThirdTestPassed); |
|
1547 TEST(result & EFourthTestPassed); |
|
1548 TEST(result & EFifthTestPassed); |
|
1549 // TEST(result & ESixthTestPassed); |
|
1550 |
|
1551 // Cleanup |
|
1552 delete chunkWrapper; |
|
1553 sem3.Close(); |
|
1554 sem4.Close(); |
|
1555 process3.Close(); |
|
1556 |
|
1557 CleanupStack::PopAndDestroy(4, &sem); |
|
1558 } |
|
1559 |
|
1560 void CTSurfaceManagerMultiProcess::TestNoAccessWhenSurfaceClosedTwoProcessL() |
|
1561 { |
|
1562 INFO_PRINTF1(_L("Test surface can't be accessed when closed (2process)\r\n")); |
|
1563 // Create a semaphore |
|
1564 const TInt initCount = 0; |
|
1565 RSemaphore sem; |
|
1566 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1567 CleanupClosePushL(sem); |
|
1568 RSemaphore sem2; |
|
1569 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1570 CleanupClosePushL(sem2); |
|
1571 |
|
1572 // Create a second process |
|
1573 RProcess process; |
|
1574 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1575 |
|
1576 // Kick off the process and wait for it to complete |
|
1577 TRequestStatus status = KRequestPending; |
|
1578 process.Logon(status); |
|
1579 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ECreateWaitKill)); |
|
1580 process.Resume(); |
|
1581 CleanupClosePushL(process); |
|
1582 |
|
1583 // Passes control to the second process |
|
1584 sem.Wait(); |
|
1585 |
|
1586 // Come back from the second process - find the surfaceId |
|
1587 CChunkWrapper* chunkWrapper = CChunkWrapper::OpenL(KSharedChunkName, ETrue); |
|
1588 TSurfaceId surfaceId = chunkWrapper->GetId(); |
|
1589 |
|
1590 // Open the surface manager |
|
1591 RSurfaceManager surfaceManager; |
|
1592 User::LeaveIfError(surfaceManager.Open()); |
|
1593 CleanupClosePushL(surfaceManager); |
|
1594 // Open the surface |
|
1595 TEST(KErrNone == surfaceManager.OpenSurface(surfaceId)); |
|
1596 |
|
1597 // Close the surface |
|
1598 TEST(KErrNone == surfaceManager.CloseSurface(surfaceId)); |
|
1599 |
|
1600 // Pass control off to the second process again |
|
1601 sem2.Signal(); |
|
1602 |
|
1603 // Wait for the third process to terminate |
|
1604 User::WaitForRequest(status); |
|
1605 |
|
1606 // Check that the tests in the second process have passed |
|
1607 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1608 TEST(result & EFirstTestPassed); |
|
1609 TEST(result & ESecondTestPassed); |
|
1610 TEST(result & EThirdTestPassed); |
|
1611 |
|
1612 TEST(KErrArgument == surfaceManager.OpenSurface(surfaceId)); |
|
1613 |
|
1614 // Delete the chunkWrapper and the semaphore |
|
1615 delete chunkWrapper; |
|
1616 CleanupStack::PopAndDestroy(4, &sem); |
|
1617 } |
|
1618 void CTSurfaceManagerMultiProcess::TestOpeningOnProcessAfterClosingOnOtherL() |
|
1619 { |
|
1620 INFO_PRINTF1(_L("Test closing on one process doesn't prevent opening on another\r\n")); |
|
1621 // Open the surface manager |
|
1622 RSurfaceManager surfaceManager; |
|
1623 User::LeaveIfError(surfaceManager.Open()); |
|
1624 CleanupClosePushL(surfaceManager); |
|
1625 |
|
1626 // Store the attributes used to create the Surface |
|
1627 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1628 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1629 |
|
1630 attributes.iSize = TSize(280,15); |
|
1631 attributes.iBuffers = 3; |
|
1632 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1633 attributes.iStride = 901; |
|
1634 attributes.iOffsetToFirstBuffer = 4; |
|
1635 attributes.iAlignment = 4; |
|
1636 attributes.iContiguous=EFalse; |
|
1637 |
|
1638 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1639 attributes.iHintCount = 2; |
|
1640 attributes.iSurfaceHints = hints; |
|
1641 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
1642 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
1643 |
|
1644 attributes.iOffsetBetweenBuffers = 0; |
|
1645 attributes.iMappable = ETrue; |
|
1646 |
|
1647 // Create the surface |
|
1648 TSurfaceId surfaceId; |
|
1649 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1650 |
|
1651 // Create a semaphore |
|
1652 const TInt initCount = 0; |
|
1653 RSemaphore sem; |
|
1654 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1655 CleanupClosePushL(sem); |
|
1656 RSemaphore sem2; |
|
1657 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1658 CleanupClosePushL(sem2); |
|
1659 |
|
1660 iInfo2.iSurfaceId = surfaceId; |
|
1661 iInfo2.iSurfaceManager = surfaceManager; |
|
1662 // Create a TCleanupItem object |
|
1663 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1664 |
|
1665 // Save the surfaceId to the shared chunk |
|
1666 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1667 chunkWrapper->SetId(surfaceId); |
|
1668 CleanupStack::Pop(); |
|
1669 |
|
1670 // Create a second process |
|
1671 RProcess process2; |
|
1672 TEST(KErrNone == process2.Create(KSecondProcess, KNullDesC)); |
|
1673 |
|
1674 // Kick off the process and wait for it to complete |
|
1675 TRequestStatus status2 = KRequestPending; |
|
1676 process2.Logon(status2); |
|
1677 process2.SetParameter(EMultiProcessSecondSlot, EOpenClose); |
|
1678 process2.Resume(); |
|
1679 |
|
1680 // Passes control to the second process |
|
1681 sem.Wait(); |
|
1682 |
|
1683 // Create a third process |
|
1684 RProcess process3; |
|
1685 TEST(KErrNone == process3.Create(KThirdProcess, KNullDesC)); |
|
1686 |
|
1687 // Kick off the process and wait for it to complete |
|
1688 TRequestStatus status3 = KRequestPending; |
|
1689 process3.Logon(status3); |
|
1690 process3.SetParameter(EMultiProcessSecondSlot, EOpenSurface); |
|
1691 process3.Resume(); |
|
1692 |
|
1693 // Pass control off to the second process again |
|
1694 sem2.Signal(); |
|
1695 |
|
1696 // Wait for the second process to terminate |
|
1697 User::WaitForRequest(status2); |
|
1698 |
|
1699 // Check that the tests in the second process have passed |
|
1700 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1701 TEST(result & EFirstTestPassed); |
|
1702 TEST(result & ESecondTestPassed); |
|
1703 TEST(result & EThirdTestPassed); |
|
1704 TEST(result & EFourthTestPassed); |
|
1705 |
|
1706 // Wait for the third process to terminate |
|
1707 User::WaitForRequest(status3); |
|
1708 |
|
1709 // Test results |
|
1710 result = chunkWrapper->GetThirdProcessResults(); |
|
1711 TEST(result & EFirstTestPassed); |
|
1712 |
|
1713 // Delete the chunkWrapper and the semaphore |
|
1714 delete chunkWrapper; |
|
1715 process2.Close(); |
|
1716 process3.Close(); |
|
1717 CleanupStack::PopAndDestroy(3, &surfaceManager); |
|
1718 } |
|
1719 |
|
1720 void CTSurfaceManagerMultiProcess::TestAccessAfterClosingL() |
|
1721 { |
|
1722 INFO_PRINTF1(_L("Test closing doesn't prevent access\r\n")); |
|
1723 // Open the surface manager |
|
1724 RSurfaceManager surfaceManager; |
|
1725 User::LeaveIfError(surfaceManager.Open()); |
|
1726 CleanupClosePushL(surfaceManager); |
|
1727 |
|
1728 // Store the attributes used to create the Surface |
|
1729 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1730 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1731 |
|
1732 attributes.iSize = TSize(280,199); |
|
1733 attributes.iBuffers = 3; |
|
1734 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1735 attributes.iStride = 711; |
|
1736 attributes.iOffsetToFirstBuffer = 4; |
|
1737 attributes.iAlignment = 4; |
|
1738 attributes.iContiguous=EFalse; |
|
1739 |
|
1740 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1741 attributes.iHintCount = 2; |
|
1742 attributes.iSurfaceHints = hints; |
|
1743 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
1744 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
1745 |
|
1746 attributes.iOffsetBetweenBuffers = 0; |
|
1747 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
1748 attributes.iMappable = ETrue; |
|
1749 |
|
1750 // Create the surface |
|
1751 TSurfaceId surfaceId; |
|
1752 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1753 |
|
1754 // Create a semaphore |
|
1755 const TInt initCount = 0; |
|
1756 RSemaphore sem; |
|
1757 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1758 CleanupClosePushL(sem); |
|
1759 RSemaphore sem2; |
|
1760 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1761 CleanupClosePushL(sem2); |
|
1762 |
|
1763 iInfo2.iSurfaceId = surfaceId; |
|
1764 iInfo2.iSurfaceManager = surfaceManager; |
|
1765 // Create a TCleanupItem object |
|
1766 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1767 |
|
1768 // Save the surfaceId to the shared chunk |
|
1769 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1770 chunkWrapper->SetId(surfaceId); |
|
1771 CleanupStack::Pop(); |
|
1772 |
|
1773 // Create a second process |
|
1774 RProcess process; |
|
1775 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1776 |
|
1777 // Kick off the process and wait for it to complete |
|
1778 TRequestStatus status = KRequestPending; |
|
1779 process.Logon(status); |
|
1780 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, EOpenClose)); |
|
1781 process.Resume(); |
|
1782 |
|
1783 // Passes control to the second process |
|
1784 sem.Wait(); |
|
1785 |
|
1786 // Map Surface |
|
1787 RChunk handle; |
|
1788 TEST(KErrNone == surfaceManager.MapSurface(surfaceId, handle)); |
|
1789 handle.Close(); |
|
1790 // Surface Info |
|
1791 RSurfaceManager::TInfoBuf infoBuf; |
|
1792 TEST(KErrNone == surfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1793 |
|
1794 // Pass control off to the second process again |
|
1795 sem2.Signal(); |
|
1796 |
|
1797 // Wait for the second process to terminate |
|
1798 User::WaitForRequest(status); |
|
1799 |
|
1800 // Check that the tests in the second process have passed |
|
1801 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1802 TEST(result & EFirstTestPassed); |
|
1803 TEST(result & ESecondTestPassed); |
|
1804 TEST(result & EThirdTestPassed); |
|
1805 TEST(result & EFourthTestPassed); |
|
1806 |
|
1807 // Delete the chunkWrapper and the semaphore |
|
1808 delete chunkWrapper; |
|
1809 process.Close(); |
|
1810 CleanupStack::PopAndDestroy(3, &surfaceManager); |
|
1811 } |
|
1812 |
|
1813 void CTSurfaceManagerMultiProcess::TestClosingAfterClosingOnOtherProcessL() |
|
1814 { |
|
1815 INFO_PRINTF1(_L("Test can close in two processes\r\n")); |
|
1816 // Open the surface manager |
|
1817 RSurfaceManager surfaceManager; |
|
1818 User::LeaveIfError(surfaceManager.Open()); |
|
1819 CleanupClosePushL(surfaceManager); |
|
1820 |
|
1821 // Store the attributes used to create the Surface |
|
1822 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1823 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1824 |
|
1825 attributes.iSize = TSize(280,301); |
|
1826 attributes.iBuffers = 3; |
|
1827 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1828 attributes.iStride = 768; |
|
1829 attributes.iOffsetToFirstBuffer = 4; |
|
1830 attributes.iAlignment = 4; |
|
1831 attributes.iContiguous=EFalse; |
|
1832 |
|
1833 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1834 attributes.iHintCount = 2; |
|
1835 attributes.iSurfaceHints = hints; |
|
1836 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
1837 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
1838 |
|
1839 attributes.iOffsetBetweenBuffers = 0; |
|
1840 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
1841 attributes.iMappable = ETrue; |
|
1842 |
|
1843 // Create the surface |
|
1844 TSurfaceId surfaceId; |
|
1845 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1846 |
|
1847 // Create a semaphore |
|
1848 const TInt initCount = 0; |
|
1849 RSemaphore sem; |
|
1850 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1851 CleanupClosePushL(sem); |
|
1852 RSemaphore sem2; |
|
1853 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1854 CleanupClosePushL(sem2); |
|
1855 |
|
1856 iInfo2.iSurfaceId = surfaceId; |
|
1857 iInfo2.iSurfaceManager = surfaceManager; |
|
1858 // Create a TCleanupItem object |
|
1859 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1860 |
|
1861 |
|
1862 // Save the surfaceId to the shared chunk |
|
1863 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1864 chunkWrapper->SetId(surfaceId); |
|
1865 CleanupStack::Pop(); |
|
1866 |
|
1867 // Create a second process |
|
1868 RProcess process; |
|
1869 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1870 |
|
1871 // Kick off the process and wait for it to complete |
|
1872 TRequestStatus status = KRequestPending; |
|
1873 process.Logon(status); |
|
1874 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, EOpenClose)); |
|
1875 process.Resume(); |
|
1876 |
|
1877 // Passes control to the second process |
|
1878 sem.Wait(); |
|
1879 |
|
1880 // Test closing the surface manager |
|
1881 TEST(KErrNone == surfaceManager.CloseSurface(surfaceId)); |
|
1882 |
|
1883 // Pass control off to the second process again |
|
1884 sem2.Signal(); |
|
1885 |
|
1886 // Wait for the second process to terminate |
|
1887 User::WaitForRequest(status); |
|
1888 |
|
1889 // Check that the tests in the second process have passed |
|
1890 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1891 TEST(result & EFirstTestPassed); |
|
1892 TEST(result & ESecondTestPassed); |
|
1893 TEST(result & EThirdTestPassed); |
|
1894 TEST(result & EFourthTestPassed); |
|
1895 |
|
1896 // Delete the chunkWrapper and the semaphore |
|
1897 delete chunkWrapper; |
|
1898 process.Close(); |
|
1899 CleanupStack::PopAndDestroy(3, &surfaceManager); |
|
1900 } |
|
1901 |
|
1902 void CTSurfaceManagerMultiProcess::TestErrSufaceAccessNotOpenL() |
|
1903 { |
|
1904 INFO_PRINTF1(_L("Test a surface cannot be accessed in a second process if not opened\r\n")); |
|
1905 // Open the surface manager |
|
1906 RSurfaceManager surfaceManager; |
|
1907 User::LeaveIfError(surfaceManager.Open()); |
|
1908 CleanupClosePushL(surfaceManager); |
|
1909 // Store the attributes used to create the Surface |
|
1910 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1911 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1912 |
|
1913 attributes.iSize = TSize(280,301); |
|
1914 attributes.iBuffers = 3; |
|
1915 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1916 attributes.iStride = 1400; |
|
1917 attributes.iOffsetToFirstBuffer = 4; |
|
1918 attributes.iAlignment = 4; |
|
1919 attributes.iContiguous=EFalse; |
|
1920 |
|
1921 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
1922 attributes.iHintCount = 2; |
|
1923 attributes.iSurfaceHints = hints; |
|
1924 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
1925 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
1926 |
|
1927 attributes.iOffsetBetweenBuffers = 0; |
|
1928 attributes.iMappable = ETrue; |
|
1929 |
|
1930 // Create the surface |
|
1931 TSurfaceId surfaceId; |
|
1932 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
1933 |
|
1934 // Create a semaphore |
|
1935 const TInt initCount = 0; |
|
1936 RSemaphore sem; |
|
1937 TEST(KErrNone == sem.CreateGlobal(KMultiProcessSemaphore, initCount)); |
|
1938 CleanupClosePushL(sem); |
|
1939 RSemaphore sem2; |
|
1940 TEST(KErrNone == sem2.CreateGlobal(KMultiProcessSemaphore2, initCount)); |
|
1941 CleanupClosePushL(sem2); |
|
1942 |
|
1943 iInfo2.iSurfaceId = surfaceId; |
|
1944 iInfo2.iSurfaceManager = surfaceManager; |
|
1945 // Create a TCleanupItem object |
|
1946 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
1947 |
|
1948 |
|
1949 // Save the surfaceId to the shared chunk |
|
1950 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
1951 chunkWrapper->SetId(surfaceId); |
|
1952 CleanupStack::Pop(); |
|
1953 |
|
1954 // Create a second process |
|
1955 RProcess process; |
|
1956 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
1957 // Kick off the process and wait for it to complete |
|
1958 TRequestStatus status = KRequestPending; |
|
1959 process.Logon(status); |
|
1960 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, EMapSurfaceInfoCantAccess)); |
|
1961 process.Resume(); |
|
1962 |
|
1963 // Passes control to the second process - to test MapSurface and SurfaceInfo |
|
1964 sem.Wait(); |
|
1965 |
|
1966 // Pass control off to the second process again - to allow it to terminate |
|
1967 sem2.Signal(); |
|
1968 |
|
1969 // Wait for the second process to terminate |
|
1970 User::WaitForRequest(status); |
|
1971 |
|
1972 // Check that the tests in the second process have passed |
|
1973 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
1974 TEST(result & EFirstTestPassed); |
|
1975 TEST(result & ESecondTestPassed); |
|
1976 TEST(result & EThirdTestPassed); |
|
1977 TEST(result & EFourthTestPassed); |
|
1978 |
|
1979 // Delete the chunkWrapper and the semaphore |
|
1980 delete chunkWrapper; |
|
1981 process.Close(); |
|
1982 CleanupStack::PopAndDestroy(3, &surfaceManager); |
|
1983 } |
|
1984 |
|
1985 void CTSurfaceManagerMultiProcess::TestReadFromBufferInSecondProcessL() |
|
1986 { |
|
1987 INFO_PRINTF1(_L("Writing to a buffer and reading from another process\r\n")); |
|
1988 // Open the surface manager |
|
1989 RSurfaceManager surfaceManager; |
|
1990 User::LeaveIfError(surfaceManager.Open()); |
|
1991 CleanupClosePushL(surfaceManager); |
|
1992 |
|
1993 // Setup attributes, setting iBuffers to 2 |
|
1994 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1995 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1996 |
|
1997 attributes.iSize = TSize(12,80); // w > 0, h > 0 |
|
1998 attributes.iBuffers = 2; // > 0, <= 4 |
|
1999 attributes.iPixelFormat = EUidPixelFormatARGB_1555; // 2bpp |
|
2000 attributes.iStride = 25; // > 0, > width * bpp |
|
2001 attributes.iOffsetToFirstBuffer = 20; // > 0, divisible by alignment |
|
2002 attributes.iAlignment = 4; // 1 || 2 || 4 || 8 |
|
2003 attributes.iContiguous = ETrue; |
|
2004 |
|
2005 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
2006 attributes.iHintCount = 2; |
|
2007 attributes.iSurfaceHints = hints; |
|
2008 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
2009 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
2010 |
|
2011 attributes.iOffsetBetweenBuffers = 0; |
|
2012 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
2013 attributes.iMappable = ETrue; |
|
2014 |
|
2015 // Create the surface |
|
2016 TSurfaceId surfaceId; |
|
2017 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
2018 |
|
2019 // Map the surface to a chunk of memory |
|
2020 RChunk handle; |
|
2021 TEST(KErrNone == surfaceManager.MapSurface(surfaceId, handle)); |
|
2022 CleanupClosePushL(handle); |
|
2023 |
|
2024 // Get the adress of this chunk of memory |
|
2025 TUint8* surfaceAdd = handle.Base(); |
|
2026 TUint8* bufferAdd = surfaceAdd + attributes.iOffsetToFirstBuffer; |
|
2027 |
|
2028 // Write to the buffer |
|
2029 *bufferAdd = 134; |
|
2030 |
|
2031 iInfo2.iSurfaceId = surfaceId; |
|
2032 iInfo2.iSurfaceManager = surfaceManager; |
|
2033 // Create a TCleanupItem object |
|
2034 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
2035 |
|
2036 |
|
2037 // Save the surfaceId to the shared chunk |
|
2038 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
2039 chunkWrapper->SetId(surfaceId); |
|
2040 CleanupStack::Pop(); |
|
2041 |
|
2042 // Create a second process |
|
2043 RProcess process; |
|
2044 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
2045 // Kick off the process and wait for it to complete |
|
2046 TRequestStatus status = KRequestPending; |
|
2047 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, EReadFromBuffer)); |
|
2048 process.Logon(status); |
|
2049 process.Resume(); |
|
2050 |
|
2051 // Wait for the second process to terminate |
|
2052 User::WaitForRequest(status); |
|
2053 |
|
2054 // Check that the tests in the second process have passed |
|
2055 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
2056 TEST(result & EFirstTestPassed); |
|
2057 TEST(result & ESecondTestPassed); |
|
2058 TEST(result & EThirdTestPassed); |
|
2059 TEST(result & EFourthTestPassed); |
|
2060 |
|
2061 // Delete the chunkWrapper and the semaphore |
|
2062 delete chunkWrapper; |
|
2063 process.Close(); |
|
2064 CleanupStack::PopAndDestroy(2, &surfaceManager); |
|
2065 } |
|
2066 |
|
2067 void CTSurfaceManagerMultiProcess::TestGetSurfaceHintMultiProcessL() |
|
2068 { |
|
2069 // Create a surface in a new shared chunk |
|
2070 INFO_PRINTF1(_L("Test that the GetSurfaceHint() behaves properly in the multiprocesses\r\n")); |
|
2071 // Open the surface manager |
|
2072 RSurfaceManager surfaceManager; |
|
2073 User::LeaveIfError(surfaceManager.Open()); |
|
2074 CleanupClosePushL(surfaceManager); |
|
2075 |
|
2076 TRequestStatus status; |
|
2077 // Setup attributes |
|
2078 |
|
2079 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2080 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2081 |
|
2082 attributes.iSize = TSize(480,16); |
|
2083 attributes.iBuffers = 2; // number of buffers in the surface |
|
2084 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
2085 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
2086 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2087 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
2088 |
|
2089 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
2090 attributes.iHintCount = 2; |
|
2091 attributes.iSurfaceHints = hints; |
|
2092 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2093 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
2094 |
|
2095 attributes.iContiguous = ETrue; |
|
2096 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2097 attributes.iOffsetBetweenBuffers = 0; |
|
2098 attributes.iMappable = ETrue; |
|
2099 |
|
2100 // Test create surface doesn't return an error |
|
2101 TSurfaceId surfaceId; |
|
2102 |
|
2103 // Test create surface doesn't return an error |
|
2104 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
2105 |
|
2106 iInfo2.iSurfaceId = surfaceId; |
|
2107 iInfo2.iSurfaceManager = surfaceManager; |
|
2108 // Create a TCleanupItem object |
|
2109 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
2110 |
|
2111 // Save the surfaceId to the shared chunk |
|
2112 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
2113 chunkWrapper->SetId(surfaceId); |
|
2114 CleanupStack::Pop(); |
|
2115 |
|
2116 // Create a second process |
|
2117 RProcess process; |
|
2118 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
2119 |
|
2120 // Specify the test for the second process |
|
2121 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, EGetSurfaceHint)); |
|
2122 // Kick off the second process and wait for it to complete |
|
2123 // The actual testing is done in the second process |
|
2124 process.Logon(status); |
|
2125 process.Resume(); |
|
2126 User::WaitForRequest(status); |
|
2127 |
|
2128 // Check the results of the second process tests |
|
2129 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
2130 // Only four tests were carried out in the second process |
|
2131 TEST(result & EFirstTestPassed); |
|
2132 TEST(result & ESecondTestPassed); |
|
2133 TEST(result & EThirdTestPassed); |
|
2134 |
|
2135 // Delete the chunkWrapper |
|
2136 delete chunkWrapper; |
|
2137 process.Close(); |
|
2138 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
2139 |
|
2140 } |
|
2141 |
|
2142 void CTSurfaceManagerMultiProcess::TestSetSurfaceHintMultiProcessL() |
|
2143 { |
|
2144 // Create a surface in a new shared chunk |
|
2145 INFO_PRINTF1(_L("Test that the SetSurfaceHint() behaves properly in the multiprocesses\r\n")); |
|
2146 // Open the surface manager |
|
2147 RSurfaceManager surfaceManager; |
|
2148 User::LeaveIfError(surfaceManager.Open()); |
|
2149 CleanupClosePushL(surfaceManager); |
|
2150 |
|
2151 TRequestStatus status; |
|
2152 // Setup attributes |
|
2153 |
|
2154 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2155 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2156 |
|
2157 attributes.iSize = TSize(480,16); |
|
2158 attributes.iBuffers = 2; // number of buffers in the surface |
|
2159 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
2160 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
2161 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2162 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
2163 |
|
2164 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
2165 attributes.iHintCount = 2; |
|
2166 attributes.iSurfaceHints = hints; |
|
2167 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2168 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
2169 |
|
2170 attributes.iContiguous = ETrue; |
|
2171 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2172 attributes.iOffsetBetweenBuffers = 0; |
|
2173 attributes.iMappable = ETrue; |
|
2174 |
|
2175 // Test create surface doesn't return an error |
|
2176 TSurfaceId surfaceId; |
|
2177 |
|
2178 // Test create surface doesn't return an error |
|
2179 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
2180 |
|
2181 iInfo2.iSurfaceId = surfaceId; |
|
2182 iInfo2.iSurfaceManager = surfaceManager; |
|
2183 // Create a TCleanupItem object |
|
2184 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
2185 |
|
2186 // Save the surfaceId to the shared chunk |
|
2187 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
2188 chunkWrapper->SetId(surfaceId); |
|
2189 CleanupStack::Pop(); |
|
2190 |
|
2191 // Create a second process |
|
2192 RProcess process; |
|
2193 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
2194 |
|
2195 // Specify the test for the second process |
|
2196 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ESetSurfaceHint)); |
|
2197 // Kick off the second process and wait for it to complete |
|
2198 // The actual testing is done in the second process |
|
2199 process.Logon(status); |
|
2200 process.Resume(); |
|
2201 User::WaitForRequest(status); |
|
2202 |
|
2203 // Check the results of the second process tests |
|
2204 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
2205 // Only four tests were carried out in the second process |
|
2206 TEST(result & EFirstTestPassed); |
|
2207 TEST(result & ESecondTestPassed); |
|
2208 TEST(result & EThirdTestPassed); |
|
2209 TEST(result & EFourthTestPassed); |
|
2210 // Delete the chunkWrapper |
|
2211 delete chunkWrapper; |
|
2212 process.Close(); |
|
2213 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
2214 |
|
2215 } |
|
2216 |
|
2217 void CTSurfaceManagerMultiProcess::TestAddSurfaceHintMultiProcessL() |
|
2218 { |
|
2219 // Create a surface in a new shared chunk |
|
2220 INFO_PRINTF1(_L("Test that the AddSurfaceHint() behaves properly in the multiprocesses\r\n")); |
|
2221 // Open the surface manager |
|
2222 RSurfaceManager surfaceManager; |
|
2223 User::LeaveIfError(surfaceManager.Open()); |
|
2224 CleanupClosePushL(surfaceManager); |
|
2225 |
|
2226 TRequestStatus status; |
|
2227 // Setup attributes |
|
2228 |
|
2229 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2230 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2231 |
|
2232 attributes.iSize = TSize(480,16); |
|
2233 attributes.iBuffers = 2; // number of buffers in the surface |
|
2234 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
2235 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
2236 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2237 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
2238 |
|
2239 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
2240 attributes.iHintCount = 2; |
|
2241 attributes.iSurfaceHints = hints; |
|
2242 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2243 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
2244 |
|
2245 attributes.iContiguous = ETrue; |
|
2246 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2247 attributes.iOffsetBetweenBuffers = 0; |
|
2248 attributes.iMappable = ETrue; |
|
2249 |
|
2250 // Test create surface doesn't return an error |
|
2251 TSurfaceId surfaceId; |
|
2252 |
|
2253 // Test create surface doesn't return an error |
|
2254 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
2255 |
|
2256 iInfo2.iSurfaceId = surfaceId; |
|
2257 iInfo2.iSurfaceManager = surfaceManager; |
|
2258 // Create a TCleanupItem object |
|
2259 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
2260 |
|
2261 // Save the surfaceId to the shared chunk |
|
2262 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
2263 chunkWrapper->SetId(surfaceId); |
|
2264 CleanupStack::Pop(); |
|
2265 |
|
2266 // Create a second process |
|
2267 RProcess process; |
|
2268 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
2269 |
|
2270 // Specify the test for the second process |
|
2271 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, EAddSurfaceHint)); |
|
2272 // Kick off the second process and wait for it to complete |
|
2273 // The actual testing is done in the second process |
|
2274 process.Logon(status); |
|
2275 process.Resume(); |
|
2276 User::WaitForRequest(status); |
|
2277 |
|
2278 // Check the results of the second process tests |
|
2279 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
2280 // Only four tests were carried out in the second process |
|
2281 TEST(result & EFirstTestPassed); |
|
2282 TEST(result & ESecondTestPassed); |
|
2283 TEST(result & EThirdTestPassed); |
|
2284 TEST(result & EFourthTestPassed); |
|
2285 // Delete the chunkWrapper |
|
2286 delete chunkWrapper; |
|
2287 process.Close(); |
|
2288 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
2289 |
|
2290 } |
|
2291 |
|
2292 void CTSurfaceManagerMultiProcess::TestOutofMemoryCasesL() |
|
2293 { |
|
2294 |
|
2295 RDebug::Printf("test 45 start"); |
|
2296 INFO_PRINTF1(_L("Test OutofMemory conditions in OpenSurface()and AddConnection()\r\n")); |
|
2297 // Open the surface manager |
|
2298 RSurfaceManager surfaceManager; |
|
2299 User::LeaveIfError(surfaceManager.Open()); |
|
2300 CleanupClosePushL(surfaceManager); |
|
2301 |
|
2302 TRequestStatus status; |
|
2303 // Setup attributes |
|
2304 |
|
2305 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2306 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2307 |
|
2308 attributes.iSize = TSize(480,16); |
|
2309 attributes.iBuffers = 2; // number of buffers in the surface |
|
2310 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
2311 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
2312 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2313 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
2314 |
|
2315 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
2316 attributes.iHintCount = 2; |
|
2317 attributes.iSurfaceHints = hints; |
|
2318 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2319 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
2320 |
|
2321 attributes.iContiguous = ETrue; |
|
2322 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2323 attributes.iOffsetBetweenBuffers = 0; |
|
2324 attributes.iMappable = ETrue; |
|
2325 |
|
2326 // Test create surface doesn't return an error |
|
2327 TSurfaceId surfaceId; |
|
2328 |
|
2329 // Test create surface doesn't return an error |
|
2330 TEST(KErrNone == surfaceManager.CreateSurface(buf, surfaceId)); |
|
2331 |
|
2332 iInfo2.iSurfaceId = surfaceId; |
|
2333 iInfo2.iSurfaceManager = surfaceManager; |
|
2334 // Create a TCleanupItem object |
|
2335 CleanupStack::PushL(TCleanupItem((TCleanupOperation)CloseSurfaceWhenLeave, &iInfo2)); |
|
2336 |
|
2337 // Save the surfaceId to the shared chunk |
|
2338 CChunkWrapper* chunkWrapper = CChunkWrapper::CreateL(KSharedChunkName, KSharedChunkSize, KSharedChunkSize); |
|
2339 chunkWrapper->SetId(surfaceId); |
|
2340 CleanupStack::Pop(); |
|
2341 |
|
2342 // Create a second process |
|
2343 RProcess process; |
|
2344 TEST(KErrNone == process.Create(KSecondProcess, KNullDesC)); |
|
2345 |
|
2346 // Specify the test for the second process |
|
2347 TEST(KErrNone == process.SetParameter(EMultiProcessSecondSlot, ECheckOutofMemory)); |
|
2348 // Kick off the second process and wait for it to complete |
|
2349 // The actual testing is done in the second process |
|
2350 process.Logon(status); |
|
2351 process.Resume(); |
|
2352 User::WaitForRequest(status); |
|
2353 |
|
2354 // Check the results of the second process tests |
|
2355 TInt result = chunkWrapper->GetSecondProcessResults(); |
|
2356 // Only four tests were carried out in the second process |
|
2357 TEST(result & EFirstTestPassed); |
|
2358 TEST(result & ESecondTestPassed); |
|
2359 |
|
2360 // Delete the chunkWrapper |
|
2361 delete chunkWrapper; |
|
2362 process.Close(); |
|
2363 CleanupStack::PopAndDestroy(1, &surfaceManager); |
|
2364 |
|
2365 } |
|
2366 |
|
2367 //-------------- |
|
2368 __CONSTRUCT_STEP__(SurfaceManagerMultiProcess) |
|
2369 |
|
2370 void CTSurfaceManagerMultiProcessStep::TestSetupL() |
|
2371 { |
|
2372 } |
|
2373 |
|
2374 void CTSurfaceManagerMultiProcessStep::TestClose() |
|
2375 { |
|
2376 } |
|
2377 |