|
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 test code |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include "tsurfacemanager.h" |
|
25 #include <e32base.h> |
|
26 #include <e32cons.h> |
|
27 #include <e32test.h> |
|
28 #include <e32std.h> |
|
29 #include <e32cmn.h> |
|
30 #include <hal.h> |
|
31 #include <e32def_private.h> |
|
32 |
|
33 const TInt KCountLimit = 10000; |
|
34 |
|
35 CTSurfaceManager::CTSurfaceManager(CTestStep* aStep): |
|
36 CTGraphicsBase(aStep) |
|
37 { |
|
38 } |
|
39 |
|
40 void CTSurfaceManager::ReAllocHintsArrayL(TUint aNumberOfHints) |
|
41 { |
|
42 if (iHintsArray) |
|
43 { |
|
44 User::Free(iHintsArray); |
|
45 iHintsArray=NULL; |
|
46 } |
|
47 iHintsArray=static_cast<RSurfaceManager::THintPair*>( |
|
48 User::AllocL(aNumberOfHints * sizeof(RSurfaceManager::THintPair))); |
|
49 } |
|
50 |
|
51 CTSurfaceManager::~CTSurfaceManager() |
|
52 { |
|
53 if (iHintsArray) |
|
54 { |
|
55 User::Free(iHintsArray); |
|
56 } |
|
57 } |
|
58 |
|
59 void CTSurfaceManager::RunTestCaseL(TInt aCurTestCase) |
|
60 { |
|
61 TInt procHandles1 =0; |
|
62 TInt threadHandles1=0; |
|
63 RThread().HandleCount(procHandles1, threadHandles1); |
|
64 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
65 |
|
66 switch(aCurTestCase) |
|
67 { |
|
68 /** |
|
69 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0001 |
|
70 @SYMPREQ PREQ 1879,PREQ1007 |
|
71 @SYMREQ REQ8222,REQ8223 |
|
72 @SYMTestPriority High |
|
73 @SYMTestCaseDesc For each alignment conditions, create a Surface in a new shared chunk. |
|
74 All the attributes are correct, no rounding is required. |
|
75 @SYMTestStatus Implemented |
|
76 @SYMTestActions For each alignment conditions, call CreateSurface() then SurfaceInfo(). |
|
77 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
78 */ |
|
79 case 1: |
|
80 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0001")); |
|
81 TestCreateSurfaceNewChunk1L(); |
|
82 break; |
|
83 /** |
|
84 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0002-0001 |
|
85 @SYMPREQ PREQ 1879,PREQ1007 |
|
86 @SYMREQ REQ8222,REQ8223 |
|
87 @SYMTestPriority High |
|
88 @SYMTestCaseDesc For each alignment conditions, create a Surface in a new shared chunk. |
|
89 Rounding is required for iOffsetToFirstBuffer and iOffsetBetweenBuffers. |
|
90 @SYMTestStatus Implemented |
|
91 @SYMTestActions Call CreateSurface(), SurfaceInfo() |
|
92 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
93 */ |
|
94 case 2: |
|
95 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0002-0001")); |
|
96 TestCreateSurfaceNewChunk2L(); |
|
97 break; |
|
98 /** |
|
99 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0002-0002 |
|
100 @SYMPREQ PREQ 1879,PREQ1007 |
|
101 @SYMREQ REQ8222,REQ8223 |
|
102 @SYMTestPriority High |
|
103 @SYMTestCaseDesc This test creates a surface in an exisiting shared chunk |
|
104 Find a valid shared chunk handle returned by a device driver. |
|
105 Create a surface in this existing shared chunk |
|
106 Map the surface in the current process to get a new shared chunk handle |
|
107 @SYMTestStatus Implemented |
|
108 @SYMTestActions Call CreateSurface(), MapSurface(), SurfaceInfo(). |
|
109 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
110 */ |
|
111 case 3: |
|
112 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0002-0002")); |
|
113 TestCreateSurfaceExisitingChunkL(); |
|
114 break; |
|
115 /** |
|
116 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0003 |
|
117 @SYMPREQ PREQ 1879,PREQ1007 |
|
118 @SYMREQ REQ8222,REQ8223 |
|
119 @SYMTestPriority High |
|
120 @SYMTestCaseDesc This test creates a surface with distinct creation attributes in an |
|
121 exisiting shared chunk that already contains a surface. |
|
122 Create a surface in a new shared chunk with valid creation attributes. |
|
123 Map the surface in the current process to get the first chunk handle. |
|
124 Create another surface (different attributes) in this existing chunk. |
|
125 Check that two surfaceIDs are different. |
|
126 Map the second surface in the current process to get the second chunk handle. |
|
127 Check that two chunk handles are different but refer to the same shared chunk. |
|
128 Write a number in the first buffer of the Second surface and read it from the first Surface (the surfaces share the chunk). |
|
129 @SYMTestStatus Implemented |
|
130 @SYMTestActions Call CreateSurface(), MapSurface() and SurfaceInfo(). |
|
131 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
132 */ |
|
133 case 4: |
|
134 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0003")); |
|
135 TestCreateSurfaceExisitingChunk2L(); |
|
136 break; |
|
137 /** |
|
138 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0004 |
|
139 @SYMPREQ PREQ 1879,PREQ1007 |
|
140 @SYMREQ REQ8222,REQ8223 |
|
141 @SYMTestPriority High |
|
142 @SYMTestCaseDesc This test creates a surface with identical creation attributes in an |
|
143 exisiting shared chunk that already contains a surface. |
|
144 @SYMTestStatus Implemented |
|
145 @SYMTestActions Call CreateSurface(), MapSurface() and SurfaceInfo(). |
|
146 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
147 */ |
|
148 case 5: |
|
149 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0004")); |
|
150 TestCreateSurfaceExisitingChunk3L(); |
|
151 break; |
|
152 /** |
|
153 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0005 |
|
154 @SYMPREQ PREQ 1879,PREQ1007 |
|
155 @SYMREQ REQ8222,REQ8223 |
|
156 @SYMTestPriority High |
|
157 @SYMTestCaseDesc This test creates a surface with rotated orientations in an exisiting |
|
158 shared chunk that already contains a surface at the same address. |
|
159 @SYMTestStatus Implemented |
|
160 @SYMTestActions Call CreateSurface(), MapSurface() and SurfaceInfo(). |
|
161 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
162 */ |
|
163 case 6: |
|
164 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0005")); |
|
165 TestCreateSurfaceExisitingChunk4L(); |
|
166 break; |
|
167 /** |
|
168 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0006 |
|
169 @SYMPREQ PREQ 1879,PREQ1007 |
|
170 @SYMREQ REQ8222,REQ8223 |
|
171 @SYMTestPriority High |
|
172 @SYMTestCaseDesc This test creates surfaces with Hint pairs (between 0 and the maximum allowed) |
|
173 @SYMTestStatus Implemented |
|
174 @SYMTestActions Call GetSurfaceManagerAttrib(), CreateSurface(), SurfaceInfo(). |
|
175 @SYMTestExpectedResults One surface can hold maximum of 8 hint pairs |
|
176 */ |
|
177 case 7: |
|
178 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0006")); |
|
179 TestCreateSurfaceAssociatedWithHintPairsL(); |
|
180 break; |
|
181 |
|
182 /** |
|
183 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0007 |
|
184 @SYMPREQ PREQ 1879,PREQ1007 |
|
185 @SYMREQ REQ8222,REQ8223 |
|
186 @SYMTestPriority High |
|
187 @SYMTestCaseDesc This test creates surfaces with all type of alignment in contiguous |
|
188 or fragmented memory. |
|
189 @SYMTestStatus Implemented |
|
190 @SYMTestActions Call CreateSurface(). |
|
191 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
192 */ |
|
193 case 8: |
|
194 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0007")); |
|
195 TestCreateSurfaceAlignmentsMemoryTypeL(); |
|
196 break; |
|
197 |
|
198 /** |
|
199 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0008 |
|
200 @SYMPREQ PREQ 1879,PREQ1007 |
|
201 @SYMREQ REQ8222,REQ8223 |
|
202 @SYMTestPriority High |
|
203 @SYMTestCaseDesc This test creates a surface and opens the surface |
|
204 @SYMTestStatus Implemented |
|
205 @SYMTestActions Call CreateSurface() and OpenSurface() |
|
206 @SYMTestExpectedResults If the return value is KErrNone , it has suceeded |
|
207 */ |
|
208 case 9: |
|
209 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0008")); |
|
210 TestOpenSurfaceL(); |
|
211 break; |
|
212 /** |
|
213 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0009 |
|
214 @SYMPREQ PREQ 1879,PREQ1007 |
|
215 @SYMREQ REQ8222,REQ8223 |
|
216 @SYMTestPriority High |
|
217 @SYMTestCaseDesc This tests CloseSurface (correctly) decrements reference count |
|
218 Create a surface (set the reference count to 1) |
|
219 Get the SurfaceInfo for the Surface. (don't alter the ref count) |
|
220 Close the Surface (ref count =0) |
|
221 Open the Surface (Since the ref count is 0, OpenSurface should fail) |
|
222 @SYMTestStatus Implemented |
|
223 @SYMTestActions Call CreateSurface(), CloseSurface(), OpenSurface() |
|
224 @SYMTestExpectedResults CloseSurface returns KErrNone, OpenSurface returns KErrArgument |
|
225 */ |
|
226 case 10: |
|
227 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0009")); |
|
228 TestClosingSurfaceDecrementsReferenceCountL(); |
|
229 break; |
|
230 /** |
|
231 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0010 |
|
232 @SYMPREQ PREQ 1879,PREQ1007 |
|
233 @SYMREQ REQ8222,REQ8223 |
|
234 @SYMTestPriority High |
|
235 @SYMTestCaseDesc Test that the new CreateSurface()API create the surface and set its reference count to one |
|
236 Create a surface in a new shared chunk with valid creation attributes. |
|
237 Map the surface in the current process to get the chunk handle. |
|
238 Create a new surface in the existing shared chunk with valid creation attributes (ref count is set to 1). |
|
239 Close the second surface (decrement the ref count to 0, the surface is deleted) |
|
240 Close the second surface again |
|
241 Check the return value is KErrArgument as the second surface is already deleted. |
|
242 @SYMTestStatus Implemented |
|
243 @SYMTestActions Call CreateSurface(), MapSurface(), CloseSurface(), OpenSurface() |
|
244 @SYMTestExpectedResults The new surface can be created successfully on the existing shared chunk, and the reference count is set to one. |
|
245 */ |
|
246 case 11: |
|
247 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0010")); |
|
248 TestCreateSurfaceSetReferenceCountL(); |
|
249 break; |
|
250 /** |
|
251 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0011 |
|
252 @SYMPREQ PREQ 1879,PREQ1007 |
|
253 @SYMREQ REQ8222,REQ8223 |
|
254 @SYMTestPriority High |
|
255 @SYMTestCaseDesc Check reading from buffers |
|
256 Set the ‘iBuffers’ of TSurfaceCreationAttributes to two. |
|
257 Create the Surface in the new shared chunk with valid creation attributes |
|
258 Map the Surface in the current process to get the shared chunk handle |
|
259 Get the address of the pixel data and write a number to that. |
|
260 Check that you can read what was written previously. |
|
261 @SYMTestStatus Implemented |
|
262 @SYMTestActions Call CreateSurface() and MapSurface() |
|
263 @SYMTestExpectedResults Upon success, the buffer can be written with valid values |
|
264 */ |
|
265 case 12: |
|
266 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0011")); |
|
267 TestWriteToTwoBuffersL(); |
|
268 break; |
|
269 /** |
|
270 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0012 |
|
271 @SYMPREQ PREQ 1879,PREQ1007 |
|
272 @SYMREQ REQ8222,REQ8223 |
|
273 @SYMTestPriority High |
|
274 @SYMTestCaseDesc This test gets SurfaceInfo of a Surface without mapping it |
|
275 Store the attributes used to create the Surface. |
|
276 Create a surface in a new shared chunk with those valid attributes |
|
277 Call SurfaceInfo to get the attributes of the new Surface. |
|
278 Check if the values are equal to the stored ones. |
|
279 @SYMTestStatus Implemented |
|
280 @SYMTestActions Call CreateSurface(), SurfaceInfo() |
|
281 @SYMTestExpectedResults Upon success,the return values are equal to the stored values |
|
282 */ |
|
283 case 13: |
|
284 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0012")); |
|
285 TestQuerySurfaceInfoWithoutMappingL(); |
|
286 break; |
|
287 /** |
|
288 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0013 |
|
289 @SYMPREQ PREQ 1879,PREQ1007 |
|
290 @SYMREQ REQ8222,REQ8223 |
|
291 @SYMTestPriority High |
|
292 @SYMTestCaseDesc This test queries SurfaceInfo after mapping it in a memory space |
|
293 Store the attributes used to create the Surface. |
|
294 Create a surface |
|
295 Map the surface |
|
296 Call SurfaceInfo to get the attributes of the Surface |
|
297 Check if the values are equal to the stored ones. |
|
298 @SYMTestStatus Implemented |
|
299 @SYMTestActions Call CreateSurface(), MapSurface(), SurfaceInfo() |
|
300 @SYMTestExpectedResults Upon success,the values are equal to the stored values. |
|
301 */ |
|
302 case 14: |
|
303 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0013")); |
|
304 TestQuerySurfaceInfoAfterMappingL(); |
|
305 break; |
|
306 /** |
|
307 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0014 |
|
308 @SYMPREQ PREQ 1879,PREQ1007 |
|
309 @SYMREQ REQ8222,REQ8223 |
|
310 @SYMTestPriority High |
|
311 @SYMTestCaseDesc This tests the MapSurface method |
|
312 Create a surface in a new shared chunk with valid attributes |
|
313 Map the surface in the current process to get the chunk handle |
|
314 Check that it returns KerrNone |
|
315 @SYMTestStatus Implemented |
|
316 @SYMTestActions Call CreateSurface(), MapSurface() |
|
317 @SYMTestExpectedResults Upon success,the return value is KErrNone |
|
318 */ |
|
319 case 15: |
|
320 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0014")); |
|
321 TestMapSurfaceL(); |
|
322 break; |
|
323 /** |
|
324 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0015 |
|
325 @SYMPREQ PREQ 1879,PREQ1007 |
|
326 @SYMREQ REQ8222,REQ8223 |
|
327 @SYMTestPriority High |
|
328 @SYMTestCaseDesc This tests the CloseSurface method |
|
329 Create a surface in a new shared chunk with valid attributes |
|
330 Close the Surface |
|
331 Check that this returns KErrNone |
|
332 Call OpenSurface using the SurfaceID and check it returns KErrArgument as the surface is already deleted. |
|
333 @SYMTestStatus Implemented |
|
334 @SYMTestActions Call CreateSurface(), CloseSurface(), OpenSurface() |
|
335 @SYMTestExpectedResults After closing the surface, Open the same surface again will cause a failure and return value is not KErrNone |
|
336 */ |
|
337 case 16: |
|
338 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0015")); |
|
339 TestClosingSurfaceL(); |
|
340 break; |
|
341 /** |
|
342 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0016 |
|
343 @SYMPREQ PREQ 1879,PREQ1007 |
|
344 @SYMREQ REQ8222,REQ8223 |
|
345 @SYMTestPriority High |
|
346 @SYMTestCaseDesc This test checks the shared Chunk gets deleted after the surface and handle are both closed |
|
347 Create a surface in a new shared chunk with valid attributes |
|
348 Map the Surface in the current process to get the chunk handle |
|
349 Close the Surface |
|
350 Check that KErrNone is returned |
|
351 Call RChunk::Base() to check the chunk is not yet deleted, as the handle is still open |
|
352 Close the chunk handle |
|
353 @SYMTestStatus Implemented |
|
354 @SYMTestActions Call CreateSurface(), CloseSurface(), MapSurface() |
|
355 @SYMTestExpectedResults CloseSurface returns KErrNone, OpenSurface returns KErrArgument |
|
356 */ |
|
357 case 17: |
|
358 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0016")); |
|
359 TestSharedChunkClosedL(); |
|
360 break; |
|
361 |
|
362 case 18: |
|
363 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
364 // Obsolete since cr1649 (it was testing the capabilities of the Surface Manager driver) |
|
365 break; |
|
366 /** |
|
367 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0018 |
|
368 @SYMPREQ PREQ 1879,PREQ1007 |
|
369 @SYMREQ REQ8222,REQ8223 |
|
370 @SYMTestPriority High |
|
371 @SYMTestCaseDesc This test creates multiple channels to surface manager LDD in one process and accesses them individually |
|
372 Open one channel called SurfaceManager1 to the surface manager LDD |
|
373 Create SurfaceID using SurfaceManager1 (ref count is set to 1) |
|
374 Then Open another channel called SurfaceManager2 to LDD in the same process |
|
375 Open SurfaceID using SurfaceManager2 (ref count is incremented to 2) |
|
376 Close SurfaceManager1 |
|
377 Call SurfaceInfo on SurfaceID and check it returns KErrNone, as SurfaceID is still open |
|
378 Call CloseSurface on SurfaceID twice and then call SurfaceInfo to check it returns KErrArgument, as the surface is deleted after being closed twice. |
|
379 Creating another surface using Surfacemanager2 and check that returns KErrNone too as SurfaceManager2 is still open. |
|
380 @SYMTestStatus Implemented |
|
381 @SYMTestActions Call CreateSurface(), OpenSurface(), SurfaceInfo(),CloseSurface() |
|
382 @SYMTestExpectedResults If multiple connections are created to the driver, closing one surface manager channel will not affect other channels and the surfaces opened in the process. |
|
383 */ |
|
384 case 19: |
|
385 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0018")); |
|
386 TestMultipleChannelsL(); |
|
387 break; |
|
388 /** |
|
389 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0019 |
|
390 @SYMPREQ PREQ 1879,PREQ1007 |
|
391 @SYMREQ REQ8222,REQ8223 |
|
392 @SYMTestPriority High |
|
393 @SYMTestCaseDesc This test checks the behaviour of closing driver channels |
|
394 Open a channel called as SurfaceManager1 to the LDD by calling RSurfaceManager::Open() |
|
395 Create one surface called as SurfaceID1 using SurfaceManager1 |
|
396 Then open another channel called as SurfaceManager2 to the LDD |
|
397 Create another surface called as SurfaceID2 using SurfaceManager2 |
|
398 Open SurfaceID1 using both SurfaceManager1 and SurfaceManager2 |
|
399 Open SurfaceID2 using both SurfaceManager1 and SurfaceManager2 |
|
400 Close SurfaceManager1 and SurfaceManager2 |
|
401 Reopen a channel to the surface manger LDD |
|
402 Call SurfaceInfo() to access both SurfaceID1 and SurfaceID2 and check both return KErrArgument, as both are deleted. |
|
403 @SYMTestStatus Implemented |
|
404 @SYMTestActions Call CreateSurface(), OpenSurface(), SurfaceInfo(),CloseSurface() |
|
405 @SYMTestExpectedResults If multiple connections are created to the driver, closing one surface manager channel will not affect other channels and the surfaces opened in the process. |
|
406 */ |
|
407 case 20: |
|
408 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0019")); |
|
409 TestClosingChannelsL(); |
|
410 break; |
|
411 /** |
|
412 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0020 |
|
413 @SYMPREQ PREQ 1879,PREQ1007 |
|
414 @SYMREQ REQ8222,REQ8223 |
|
415 @SYMTestPriority High |
|
416 @SYMTestCaseDesc Finding out the maximum number of surfaces to be created |
|
417 Create a Surface till error occurs |
|
418 Check the maximum number of surfaces created and the last error code |
|
419 @SYMTestActions Call CreateSurface() |
|
420 @SYMTestExpectedResults The maximum number varies between platforms(emulator and h4). The last error code is KErrNoMemory. |
|
421 */ |
|
422 case 21: |
|
423 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0020")); |
|
424 TestSurfaceLimitL(); |
|
425 break; |
|
426 /** |
|
427 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0021 |
|
428 @SYMPREQ PREQ 1879,PREQ1007 |
|
429 @SYMREQ REQ8222,REQ8223 |
|
430 @SYMTestPriority High |
|
431 @SYMTestCaseDesc Test the behaviour of SynchronizeCache() |
|
432 Create the surface in a new shared chunk with valid creation attributes. The cache attribute is set to ECached. |
|
433 Map the surface in the current process to get the chunk handle |
|
434 Synchronise the cache before the hardware writes to the buffer. Pass TSyncOperation::ESyncBeforeHandwareWrite, valid buffer number and valid surfaceID in SynchronizeCache() |
|
435 Synchronise again the cache after the hardware write the buffer. Pass TSyncOperation::ESyncAfterHandwareWrite, valid buffer number and valid surfaceID in SynchronizeCache() |
|
436 Synchronise again the cache before the hardware reads the buffer. Pass TSyncOperation::ESyncBeforeHardwareRead, valid buffer number and valid surfaceID in SynchronizeCache() |
|
437 Check each calls return KErrNone. |
|
438 We can also visually check the result of SynchronizeCache() by investigating the MBX GCE tests. |
|
439 @SYMTestActions Call CreateSurface(), SynchronizeCache() |
|
440 @SYMTestExpectedResults The surface memory is synchronised properly with cached contents. All the synchronize operation returns KErrNone. |
|
441 */ |
|
442 case 22: |
|
443 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0021")); |
|
444 TestSynchronizeCacheL(); |
|
445 break; |
|
446 |
|
447 /** |
|
448 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0022 |
|
449 @SYMPREQ PREQ 1879,PREQ1007 |
|
450 @SYMREQ REQ8222,REQ8223 |
|
451 @SYMTestPriority High |
|
452 @SYMTestCaseDesc Test that when two surfaces are created in the same shared chunk, |
|
453 closing one surface and chunk handle will not cause the chunk to be deleted. |
|
454 @SYMTestActions Call CreateSurface(), MapSurface(), CloseSurface() |
|
455 @SYMTestExpectedResults If two surfaces are created on the same shared chunk. closing one surface and chunk handle will not cause the chunk to be deleted. |
|
456 */ |
|
457 case 23: |
|
458 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0022")); |
|
459 TestSharedChunkClosed2L(); |
|
460 break; |
|
461 |
|
462 /** |
|
463 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0023 |
|
464 @SYMPREQ PREQ 1879,PREQ1007 |
|
465 @SYMREQ REQ8222,REQ8223 |
|
466 @SYMTestPriority High |
|
467 @SYMTestCaseDesc Test that GetSurfaceHint() behaves properly. |
|
468 @SYMTestActions Call CreateSurface(), GetSurfaceHint() |
|
469 @SYMTestExpectedResults GetSurfaceHint () returns KErrNone and retrieve THintPair value correctly |
|
470 */ |
|
471 case 24: |
|
472 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0023")); |
|
473 TestGetSurfaceHintL(); |
|
474 break; |
|
475 |
|
476 /** |
|
477 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0024 |
|
478 @SYMPREQ PREQ 1879,PREQ1007 |
|
479 @SYMREQ REQ8222,REQ8223 |
|
480 @SYMTestPriority High |
|
481 @SYMTestCaseDesc Test that SetSurfaceHint() behaves properly |
|
482 @SYMTestActions Call CreateSurface(), SetSurfaceHint() |
|
483 @SYMTestExpectedResults SetSurfaceHint () can reset value in THintPair if iMutable is ETrue. |
|
484 */ |
|
485 case 25: |
|
486 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0024")); |
|
487 TestSetSurfaceHintL(); |
|
488 break; |
|
489 |
|
490 /** |
|
491 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0025 |
|
492 @SYMPREQ PREQ 1879,PREQ1007 |
|
493 @SYMREQ REQ8222,REQ8223 |
|
494 @SYMTestPriority High |
|
495 @SYMTestCaseDesc Test that AddSurfaceHint() behaves properly |
|
496 @SYMTestActions Call CreateSurface(), AddSurfaceHint() |
|
497 @SYMTestExpectedResults AddSurfaceHint () can add a new surface hint value for the surface. |
|
498 */ |
|
499 case 26: |
|
500 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0025")); |
|
501 TestAddSurfaceHintL(); |
|
502 break; |
|
503 |
|
504 /** |
|
505 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0026 |
|
506 @SYMPREQ PREQ 1879,PREQ1007 |
|
507 @SYMREQ REQ8222,REQ8223 |
|
508 @SYMTestPriority High |
|
509 @SYMTestCaseDesc This test creates a surface with invalid parameters in a new shared chunk |
|
510 Set invalid values for the data members of TSurfaceCreationAttributes, which is used to create a Surface. |
|
511 Call CreateSurface |
|
512 @SYMTestStatus Implemented |
|
513 @SYMTestActions Call CreateSurface() |
|
514 @SYMTestExpectedResults Check that CreateSurface() returns KErrArgument |
|
515 */ |
|
516 case 27: |
|
517 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0026")); |
|
518 TestCreateSurfaceInvalidParamsNewChunkL(); |
|
519 break; |
|
520 /** |
|
521 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0027 |
|
522 @SYMPREQ PREQ 1879,PREQ1007 |
|
523 @SYMREQ REQ8222,REQ8223 |
|
524 @SYMTestPriority High |
|
525 @SYMTestCaseDesc This test creates a surface with invalid parameters in an exisiting shared chunk |
|
526 Set invalid values for the data members of TSurfaceCreationAttributes, which is used to create a Surface. |
|
527 Call CreateSurface and pass it the shared chunk handle. |
|
528 @SYMTestStatus Implemented |
|
529 @SYMTestActions Call CreateSurface() |
|
530 @SYMTestExpectedResults Check that CreateSurface() returns KErrArgument |
|
531 */ |
|
532 case 28: |
|
533 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0027")); |
|
534 TestCreateSurfaceInvalidParamsExisitingChunkL(); |
|
535 break; |
|
536 /** |
|
537 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0028 |
|
538 @SYMPREQ PREQ 1879,PREQ1007 |
|
539 @SYMREQ REQ8222,REQ8223 |
|
540 @SYMTestPriority High |
|
541 @SYMTestCaseDesc This test creates a surface with invalid parameters in an exisiting shared chunk which already contains a surface |
|
542 Create a surface in a new shared chunk |
|
543 Map the surface in the current process to get the shared chunk handle |
|
544 Set invalid values for the data members of TSurfaceCreationAttributes, which is used to create a new Surface in the exising shared chunk. |
|
545 Call CreateSurface and pass it the shared chunk handle. |
|
546 @SYMTestStatus Implemented |
|
547 @SYMTestActions Call CreateSurface() |
|
548 @SYMTestExpectedResults Check that CreateSurface() returns KErrArgument |
|
549 */ |
|
550 case 29: |
|
551 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0028")); |
|
552 TestCreateSurfaceInvalidParamsExisitingChunk2L(); |
|
553 break; |
|
554 |
|
555 /** |
|
556 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0029 |
|
557 @SYMPREQ PREQ 1879,PREQ1007 |
|
558 @SYMREQ REQ8222,REQ8223 |
|
559 @SYMTestPriority High |
|
560 @SYMTestCaseDesc Test that Hint keys can not be duplicated |
|
561 @SYMTestStatus Implemented |
|
562 @SYMTestActions Call CreateSurface() |
|
563 @SYMTestExpectedResults Check that No duplicated Hint keys are allowed in the TSurfaceHints field |
|
564 */ |
|
565 case 30: |
|
566 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0029")); |
|
567 TestDuplicatedHintKeyL(); |
|
568 break; |
|
569 /** |
|
570 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0030 |
|
571 @SYMPREQ PREQ 1879,PREQ1007 |
|
572 @SYMREQ REQ8222,REQ8223 |
|
573 @SYMTestPriority High |
|
574 @SYMTestCaseDesc This test checks that iContiguous is indeed ignored when creating the second surface on the existing shared chunk which already contains a surface |
|
575 @SYMTestStatus Implemented |
|
576 @SYMTestActions Call CreateSurface(), MapSurface(), CreateSurface(), SurfaceInfo() |
|
577 @SYMTestExpectedResults Contiguous attribution in the surface info structure correctly reflects the Contiguous properties of the chunk used. |
|
578 */ |
|
579 case 31: |
|
580 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0030")); |
|
581 TestInvalidContiguousPropertyL(); |
|
582 break; |
|
583 |
|
584 /** |
|
585 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0031 |
|
586 @SYMPREQ PREQ 1879,PREQ1007 |
|
587 @SYMREQ REQ8222,REQ8223 |
|
588 @SYMTestPriority High |
|
589 @SYMTestCaseDesc This test checks that iCacheAttrib is indeed ignored when creating the second surface on the existing shared chunk which already contains a surface |
|
590 |
|
591 @SYMTestStatus Implemented |
|
592 @SYMTestActions Call CreateSurface(), MapSurface, CreateSurface(), SurfaceInfo() |
|
593 @SYMTestExpectedResults Cache attribution in the surface info structure correctly reflects the caching properties of the chunk used. |
|
594 */ |
|
595 case 32: |
|
596 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0031")); |
|
597 TestInvalidCachePropertyL(); |
|
598 break; |
|
599 |
|
600 /** |
|
601 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0032 |
|
602 @SYMPREQ PREQ 1879,PREQ1007 |
|
603 @SYMREQ REQ8222,REQ8223 |
|
604 @SYMTestPriority High |
|
605 @SYMTestCaseDesc This test creates a Surface in an invalid chunk |
|
606 @SYMTestStatus Implemented |
|
607 @SYMTestActions Call CreateSurface(), Mapsurface, CloseSurface() |
|
608 @SYMTestExpectedResults CreateSurface should return KErrBadHandle when the chunk handle is invalid |
|
609 */ |
|
610 case 33: |
|
611 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0032")); |
|
612 TestInvalidSharedChunkL(); |
|
613 break; |
|
614 /** |
|
615 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0033 |
|
616 @SYMPREQ PREQ1007 |
|
617 @SYMREQ REQ8222,REQ8223 |
|
618 @SYMTestPriority High |
|
619 @SYMTestCaseDesc This test create enough surfaces to cause KErrNoMemory |
|
620 Set surface parameters to create a reasonably large (memory) surface |
|
621 Create multiple surfaces using these parameters |
|
622 @SYMTestStatus Implemented |
|
623 @SYMTestActions Call CreateSurface() |
|
624 @SYMTestExpectedResults Check that eventually that KErrNoMemory will be returned. |
|
625 */ |
|
626 case 34: |
|
627 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0033")); |
|
628 TestCreateVeryLargeSurfacesL(); |
|
629 break; |
|
630 /** |
|
631 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0034 |
|
632 @SYMPREQ PREQ1007 |
|
633 @SYMREQ REQ8222,REQ8223 |
|
634 @SYMTestPriority High |
|
635 @SYMTestCaseDesc This tests the MapSurface method with invalid surfaceId |
|
636 Create a Surface |
|
637 Change Surface ID by |
|
638 1. making the Surface ID negative |
|
639 2. converting the type of Surface ID to EInvalidSurface |
|
640 MapSurface with new Surface ID |
|
641 @SYMTestStatus Implemented |
|
642 @SYMTestActions Call CreateSurface(), MapSurface() |
|
643 @SYMTestExpectedResults Check that the return value of MapSurface() is KErrArgument |
|
644 */ |
|
645 case 35: |
|
646 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0034")); |
|
647 TestMapSurfaceInvalidParamsL(); |
|
648 break; |
|
649 /** |
|
650 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0035 |
|
651 @SYMPREQ PREQ1007 |
|
652 @SYMREQ REQ8222,REQ8223 |
|
653 @SYMTestPriority High |
|
654 @SYMTestCaseDesc This tests SurfaceInfo by passing invalid SurfaceID |
|
655 Map the surface |
|
656 Change the type of the SurfaceID |
|
657 Call SurfaceInfo, pass the changed SurfaceID as a parameter |
|
658 @SYMTestStatus Implemented |
|
659 @SYMTestActions Call CreateSurface(), SurfaceInfo() |
|
660 @SYMTestExpectedResults Check that the return value of SurfaceInfo() is KErrArgument. |
|
661 */ |
|
662 case 36: |
|
663 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0035")); |
|
664 TestSurfaceInfoChangedTypeL(); |
|
665 break; |
|
666 /** |
|
667 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0036 |
|
668 @SYMPREQ PREQ1007 |
|
669 @SYMREQ REQ8222,REQ8223 |
|
670 @SYMTestPriority High |
|
671 @SYMTestCaseDesc This tests the Closing surface method with invalid parameters |
|
672 Create a Surface |
|
673 Change Surface Id by |
|
674 1. making the Surface ID negative |
|
675 2. converting the type of the Surface ID to EInvalidSurface |
|
676 Call CloseSurface with the new Surface ID |
|
677 @SYMTestStatus Implemented |
|
678 @SYMTestActions Call CreateSurface(), CloseSurface() |
|
679 @SYMTestExpectedResults Check that CloseSurface() returns KErrArgument |
|
680 */ |
|
681 case 37: |
|
682 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0036")); |
|
683 TestCloseSurfaceInvalidParamsL(); |
|
684 break; |
|
685 /** |
|
686 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0037 |
|
687 @SYMPREQ PREQ1007 |
|
688 @SYMREQ REQ8222,REQ8223 |
|
689 @SYMTestPriority High |
|
690 @SYMTestCaseDesc Test that SynchronizeCache() reacts properly under false conditions |
|
691 @SYMTestStatus Implemented |
|
692 @SYMTestActions Call CreateSurface(), SynchronizeCache(), CloseSurface() |
|
693 @SYMTestExpectedResults SynchronizeCache() returns KErrArgument under false conditions |
|
694 */ |
|
695 case 38: |
|
696 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0037")); |
|
697 TestSynchronizeCacheInvalidParamsL(); |
|
698 break; |
|
699 /** |
|
700 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0038 |
|
701 @SYMPREQ PREQ1007 |
|
702 @SYMREQ REQ8222,REQ8223 |
|
703 @SYMTestPriority High |
|
704 @SYMTestCaseDesc This tests closing a surface with the same ID twice |
|
705 Create a Surface |
|
706 Close the surface |
|
707 Close the surface again |
|
708 @SYMTestStatus Implemented |
|
709 @SYMTestActions Call CreateSurface(), CloseSurface() |
|
710 @SYMTestExpectedResults Check that running CloseSurface() twice returns KErrArgument. |
|
711 */ |
|
712 case 39: |
|
713 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0038")); |
|
714 TestCloseSurfaceSameIDTwiceL(); |
|
715 break; |
|
716 /** |
|
717 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0039 |
|
718 @SYMPREQ PREQ1007 |
|
719 @SYMREQ REQ8222,REQ8223 |
|
720 @SYMTestPriority High |
|
721 @SYMTestCaseDesc Testing CreateSurface in out of memory conditions (for the debug mode only) |
|
722 Open the surface manager |
|
723 Call CreateSurface(), inducing a kernal alloc failure on each possible kernal alloc |
|
724 @SYMTestStatus Implemented |
|
725 @SYMTestActions Call CreateSurface() |
|
726 @SYMTestExpectedResults Check that CreateSurface() returns KErrNoMemory. |
|
727 */ |
|
728 case 40: |
|
729 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
730 #ifdef _DEBUG |
|
731 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0039")); |
|
732 TestCreateSurfaceOomL(); |
|
733 #endif |
|
734 break; |
|
735 /** |
|
736 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0040 |
|
737 @SYMPREQ PREQ1007 |
|
738 @SYMREQ REQ8222,REQ8223 |
|
739 @SYMTestPriority High |
|
740 @SYMTestCaseDesc Testing that GetSurfaceHint()reacts properly under false conditions |
|
741 Create the surface with valid creation attributes in a new shared chunk. |
|
742 Find THintPair, Close the surface |
|
743 Set false conditions and then call GetSurfaceHint() |
|
744 @SYMTestStatus Implemented |
|
745 @SYMTestActions Call CreateSurface(), GetSurfaceHint() |
|
746 @SYMTestExpectedResults Check that GetSurfaceHint()returns KErrArgument under false conditions. |
|
747 */ |
|
748 case 41: |
|
749 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0040")); |
|
750 TestGetSurfaceHintInFalseConditionsL(); |
|
751 break; |
|
752 |
|
753 /** |
|
754 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0041 |
|
755 @SYMPREQ PREQ1007 |
|
756 @SYMREQ REQ8222,REQ8223 |
|
757 @SYMTestPriority High |
|
758 @SYMTestCaseDesc Testing that SetSurfaceHint()reacts properly under false conditions |
|
759 Create the surface with valid creation attributes in a new shared chunk. |
|
760 Set THintPair, Close the surface |
|
761 Set false conditions and then call SetSurfaceHint() |
|
762 @SYMTestStatus Implemented |
|
763 @SYMTestActions Call CreateSurface(), SetSurfaceHint() |
|
764 @SYMTestExpectedResults Check that SetSurfaceHint()returns KErrArgument under false conditions. |
|
765 */ |
|
766 case 42: |
|
767 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0041")); |
|
768 TestSetSurfaceHintInFalseConditionsL(); |
|
769 break; |
|
770 |
|
771 /** |
|
772 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0042 |
|
773 @SYMPREQ PREQ1007 |
|
774 @SYMREQ REQ8222,REQ8223 |
|
775 @SYMTestPriority High |
|
776 @SYMTestCaseDesc Testing that AddSurfaceHint()reacts properly under false conditions |
|
777 Create the surface with valid creation attributes in a new shared chunk. |
|
778 Set THintPair, Close the surface |
|
779 Set false conditions and then call AddSurfaceHint() |
|
780 @SYMTestStatus Implemented |
|
781 @SYMTestActions Call CreateSurface(), AddSurfaceHint() |
|
782 @SYMTestExpectedResults AddSurfaceHint () returns KErrArgument if the surface ID is invalid or not open in this process, |
|
783 KErrAlreadyExists if duplicate hint key used, KErrOverflow if no space to add new pair. |
|
784 */ |
|
785 case 43: |
|
786 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0042")); |
|
787 TestAddSurfaceHintInFalseConditionsL(); |
|
788 break; |
|
789 |
|
790 /** |
|
791 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0043 |
|
792 @SYMPREQ PREQ1007 |
|
793 @SYMREQ REQ8222,REQ8223 |
|
794 @SYMTestPriority High |
|
795 @SYMTestCaseDesc Test AddSurfaceHint, SetSurfaceHint and SynchronizeCache performance |
|
796 Calculate the average time: |
|
797 - for setting surface hints at different location |
|
798 - for adding hints at different location |
|
799 - for synchronizing cache |
|
800 |
|
801 @SYMTestStatus Implemented |
|
802 @SYMTestActions Call CreateSurface(), AddSurfaceHint()and SetSurfaceHint |
|
803 @SYMTestExpectedResults Performance is reasonable |
|
804 */ |
|
805 case 44: |
|
806 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0043")); |
|
807 TestPerformanceOfSurfaceHintAndCacheL(); |
|
808 break; |
|
809 |
|
810 /** |
|
811 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0044 |
|
812 @SYMPREQ PREQ1007 |
|
813 @SYMREQ REQ8222,REQ8223 |
|
814 @SYMTestPriority High |
|
815 @SYMTestCaseDesc Test CreateSurface() and CloseSurface() performance |
|
816 Calculate the average time: |
|
817 - for creating a surface in a new chunk |
|
818 - for closing a surface |
|
819 - for creating a surface in an existing chunk |
|
820 |
|
821 @SYMTestStatus Implemented |
|
822 @SYMTestActions Call CreateSurface() and CloseSurface() |
|
823 @SYMTestExpectedResults Performance is reasonable |
|
824 */ |
|
825 case 45: |
|
826 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0044")); |
|
827 TestPerformanceOfSurfaceCreatingAndClosingL(); |
|
828 break; |
|
829 |
|
830 /** |
|
831 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0045 |
|
832 */ |
|
833 case 46: |
|
834 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0045")); |
|
835 TestZerosInHintsArrayL(); |
|
836 break; |
|
837 |
|
838 /** |
|
839 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0082 |
|
840 @SYMPREQ DEF130006 |
|
841 @SYMREQ |
|
842 @SYMTestPriority High |
|
843 @SYMTestCaseDesc Test that Creating Surface with chunk that has "holes" works. |
|
844 @SYMTestStatus Implemented |
|
845 @SYMTestActions Call CreateSurface() with different sets of pages in the chunk. |
|
846 @SYMTestExpectedResults Test should "pass" - this test has both positive and negative subtests. |
|
847 */ |
|
848 case 47: |
|
849 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0082")); |
|
850 TestCreateSurfaceChunkWithHolesL(); |
|
851 break; |
|
852 /** |
|
853 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0101 |
|
854 @SYMPREQ cr1649 |
|
855 @SYMREQ |
|
856 @SYMTestPriority Low |
|
857 @SYMTestCaseDesc Test that Creating Surface with too many hints imply an error. |
|
858 @SYMTestStatus Implemented |
|
859 @SYMTestActions Call CreateSurface() with too many hints. |
|
860 @SYMTestExpectedResults Negative test for CreateSurface. |
|
861 */ |
|
862 case 48: |
|
863 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0101")); |
|
864 TestCreateSurfaceWithTooManyHintsL(); |
|
865 break; |
|
866 |
|
867 /** |
|
868 @SYMTestCaseID GRAPHICS-SURFACEMANAGER-0102 |
|
869 @SYMPREQ cr1649 |
|
870 @SYMREQ |
|
871 @SYMTestPriority Low |
|
872 @SYMTestCaseDesc Test that Creating Surface that is not mappable can then not be mapped. |
|
873 @SYMTestStatus Implemented |
|
874 @SYMTestActions Call CreateSurface() with attribute iMappable = EFalse, |
|
875 then call MapSurface() and check that it is not successful. |
|
876 same with GetBufferOffset |
|
877 @SYMTestExpectedResults Negative test for MapSurface and GetBufferOffset. |
|
878 */ |
|
879 case 49: |
|
880 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(_L("GRAPHICS-SURFACEMANAGER-0102")); |
|
881 TestCreateSurfaceUnMappableL(); |
|
882 break; |
|
883 |
|
884 default: |
|
885 ((CTSurfaceManagerStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
886 ((CTSurfaceManagerStep*)iStep)->CloseTMSGraphicsStep(); |
|
887 TestComplete(); |
|
888 break; |
|
889 } |
|
890 ((CTSurfaceManagerStep*)iStep)->RecordTestResultL(); |
|
891 TInt procHandles2 =0; |
|
892 TInt threadHandles2=0; |
|
893 RThread().HandleCount(procHandles2,threadHandles2); |
|
894 if (threadHandles1 != threadHandles2) |
|
895 { |
|
896 User::Leave(KErrGeneral); // Thread-owned handles not closed |
|
897 } |
|
898 |
|
899 } |
|
900 |
|
901 void CTSurfaceManager::TestPerformanceOfSurfaceCreatingAndClosingL() |
|
902 { |
|
903 INFO_PRINTF1(_L("Testing Surface Manager Performance\r\n")); |
|
904 // Open the surface manager |
|
905 User::LeaveIfError(iSurfaceManager.Open()); |
|
906 // Store the attributes used to create the Surface |
|
907 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
908 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
909 |
|
910 attributes.iSize = TSize(100,100); |
|
911 attributes.iBuffers = 1; // number of buffers in the surface |
|
912 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
913 attributes.iStride = 400; // Number of bytes between start of one line and start of next |
|
914 attributes.iOffsetToFirstBuffer = 9; // way of reserving space before the surface pixel data |
|
915 attributes.iAlignment = 1; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
916 RSurfaceManager::THintPair hints[2]; |
|
917 attributes.iHintCount=2; |
|
918 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
919 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
920 attributes.iSurfaceHints = hints; |
|
921 attributes.iOffsetBetweenBuffers = 50009; |
|
922 attributes.iContiguous = ETrue; |
|
923 attributes.iCacheAttrib = RSurfaceManager::ECached; // Cache attributes |
|
924 attributes.iMappable = ETrue; |
|
925 |
|
926 // Create a surface |
|
927 TSurfaceId surfaceId; |
|
928 TUint32 timeBefore = 0; |
|
929 TUint32 timeAfter = 0; |
|
930 TReal measure = 0; |
|
931 TReal measureTotal = 0; |
|
932 TInt index = 0; |
|
933 |
|
934 RArray<TSurfaceId> surfaceIDArray; |
|
935 |
|
936 User::LeaveIfError(HAL::Get(HALData::EFastCounterFrequency, iFreq)); |
|
937 // Scenario 1: measure the average time of creating |
|
938 timeBefore = User::FastCounter(); |
|
939 index = 0; |
|
940 TInt r = KErrNone; |
|
941 |
|
942 do |
|
943 { |
|
944 TEST(KErrNone == r); |
|
945 timeBefore = User::FastCounter(); |
|
946 r = iSurfaceManager.CreateSurface(buf, surfaceId); |
|
947 timeAfter = User::FastCounter(); |
|
948 measure= 1000000 * ((TReal)(timeAfter - timeBefore)) / ((TReal) iFreq); |
|
949 // RDebug::Print(_L("Creating a surface [LOG]: \t%d \t%f "), index, measure); |
|
950 measureTotal += measure; |
|
951 surfaceIDArray.Insert(surfaceId,index++); |
|
952 } while (r == KErrNone && index < 500); |
|
953 |
|
954 TInt numberOfSurfaces = surfaceIDArray.Count(); |
|
955 INFO_PRINTF2(_L("the number of surface is %d\r\n"),numberOfSurfaces); |
|
956 INFO_PRINTF2(_L("the average time for creating a surface is %f\r\n"),measureTotal/numberOfSurfaces); |
|
957 index = 0; |
|
958 measureTotal = 0; |
|
959 while (index < numberOfSurfaces -1) |
|
960 { |
|
961 surfaceId = surfaceIDArray[index++]; |
|
962 |
|
963 // to delete the first surface being created |
|
964 timeBefore = User::FastCounter(); |
|
965 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
966 timeAfter = User::FastCounter(); |
|
967 // 1000 for all the opeations, 1000000 for deletion only |
|
968 measure = 1000000 * ((TReal)(timeAfter - timeBefore)) / ((TReal) iFreq); |
|
969 measureTotal += measure; |
|
970 // RDebug::Print(_L("Closing the surface [LOG]: \t%d \t%f "), index, measure); |
|
971 } |
|
972 |
|
973 INFO_PRINTF2(_L("the average time for Closing a surface is %f\r\n"),measureTotal/numberOfSurfaces); |
|
974 |
|
975 surfaceIDArray.Close(); |
|
976 RArray<TSurfaceId> surfaceIDArray2; |
|
977 |
|
978 // For CreateSurface in the existing chunk |
|
979 TEST(KErrNone ==iSurfaceManager.CreateSurface(buf, surfaceId)) ; |
|
980 //Map the surface in the current processs |
|
981 RChunk handle; |
|
982 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
983 |
|
984 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
985 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
986 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = buff(); |
|
987 |
|
988 attributesNew.iSize = TSize(480,16); |
|
989 attributesNew.iBuffers = 2; // number of buffers in the surface |
|
990 attributesNew.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
991 attributesNew.iStride = 1013; // Number of bytes between start of one line and start of next |
|
992 attributesNew.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
993 |
|
994 RSurfaceManager::THintPair hint; |
|
995 attributesNew.iHintCount=1; |
|
996 hint.Set(TUid::Uid(0x124545), 50, EFalse); |
|
997 attributesNew.iSurfaceHints = &hint; |
|
998 attributesNew.iAlignment = RSurfaceManager::EPageAligned; |
|
999 attributesNew.iOffsetBetweenBuffers = 0; |
|
1000 attributesNew.iMappable = ETrue; |
|
1001 |
|
1002 // Test create surface doesn't return an error |
|
1003 TSurfaceId surfaceIdNew; |
|
1004 |
|
1005 r = KErrNone; |
|
1006 index = 0; |
|
1007 measureTotal = 0; |
|
1008 do |
|
1009 { |
|
1010 TEST(KErrNone == r); |
|
1011 timeBefore = User::FastCounter(); |
|
1012 r = iSurfaceManager.CreateSurface(buff, surfaceIdNew, handle); |
|
1013 timeAfter = User::FastCounter(); |
|
1014 measure= 1000000 * ((TReal)(timeAfter - timeBefore)) / ((TReal) iFreq); |
|
1015 // RDebug::Print(_L("CreateSurface in the existing chunk [LOG]: \t%d \t%f "), index, measure); |
|
1016 measureTotal += measure; |
|
1017 surfaceIDArray2.Insert(surfaceIdNew,index++); |
|
1018 } while (r == KErrNone && index < 500); |
|
1019 numberOfSurfaces = surfaceIDArray2.Count(); |
|
1020 |
|
1021 INFO_PRINTF2(_L("the average time for Creating a surface in the existing chunk is %f\r\n"),measureTotal/numberOfSurfaces); |
|
1022 |
|
1023 index = 0; |
|
1024 while (index < numberOfSurfaces) |
|
1025 { |
|
1026 surfaceIdNew = surfaceIDArray2[index++]; |
|
1027 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
1028 } |
|
1029 |
|
1030 handle.Close(); |
|
1031 |
|
1032 surfaceIDArray2.Close(); |
|
1033 iSurfaceManager.Close(); |
|
1034 } |
|
1035 |
|
1036 void CTSurfaceManager::TestPerformanceOfSurfaceHintAndCacheL() |
|
1037 { |
|
1038 INFO_PRINTF1(_L("Testing Surface Manager AddSurfaceHint, SetSurfaceHint, GetSurfaceHint and SynchronizeChace Performance\r\n")); |
|
1039 // Open the surface manager |
|
1040 User::LeaveIfError(iSurfaceManager.Open()); |
|
1041 // Store the attributes used to create the Surface |
|
1042 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1043 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1044 |
|
1045 TInt maxHintsPerSurface; |
|
1046 iSurfaceManager.GetSurfaceManagerAttrib(RSurfaceManager::EMaxNumberOfHints,maxHintsPerSurface); |
|
1047 // For SetSurfaceHint extreme search(binary search takes longest to locate the search if it is at the end) |
|
1048 //Small surfaces |
|
1049 RArray<TInt32> uidArray; |
|
1050 TInt i; |
|
1051 for (TInt i=0;i<maxHintsPerSurface-1;++i) |
|
1052 { |
|
1053 uidArray.Append(0x237750+i); |
|
1054 } |
|
1055 uidArray.Append(0x237778); |
|
1056 |
|
1057 attributes.iSize = TSize(1,1); |
|
1058 attributes.iBuffers = 1; |
|
1059 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1060 attributes.iStride = 1; |
|
1061 attributes.iOffsetToFirstBuffer = 1; |
|
1062 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
1063 //Add 16 surface hints |
|
1064 ReAllocHintsArrayL(maxHintsPerSurface); |
|
1065 attributes.iHintCount=maxHintsPerSurface; |
|
1066 for (i = 0; i<attributes.iHintCount; ++i) |
|
1067 { |
|
1068 iHintsArray[i].Set(TUid::Uid(uidArray[i]), 25, ETrue); |
|
1069 } |
|
1070 attributes.iSurfaceHints=iHintsArray; |
|
1071 |
|
1072 attributes.iOffsetBetweenBuffers = 0; |
|
1073 attributes.iContiguous = ETrue; |
|
1074 attributes.iCacheAttrib = RSurfaceManager::ECached; // Cache attributes |
|
1075 attributes.iMappable = ETrue; |
|
1076 |
|
1077 // Create a surface |
|
1078 TSurfaceId surfaceId; |
|
1079 TInt freq; |
|
1080 User::LeaveIfError(HAL::Get(HALData::EFastCounterFrequency, freq)); |
|
1081 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
1082 TUint32 timeBefore =0; |
|
1083 TUint32 timeAfter= 0; |
|
1084 |
|
1085 TReal measure1=0; |
|
1086 TReal measureTotal = 0; |
|
1087 const TInt numberOfCalculation = 500; |
|
1088 |
|
1089 RSurfaceManager::THintPair hintPair; |
|
1090 RSurfaceManager::THintPair hintPair2; |
|
1091 // Measure the average time of setting surface hints at different location |
|
1092 for (i = 0; i<maxHintsPerSurface; ++i) |
|
1093 { |
|
1094 measure1 = 0; |
|
1095 for (TInt j = 0; j<numberOfCalculation; j++) |
|
1096 { |
|
1097 hintPair.iKey.iUid = uidArray[i]; |
|
1098 hintPair.iValue = 300; |
|
1099 hintPair.iMutable = ETrue; |
|
1100 timeBefore = User::FastCounter(); |
|
1101 TEST(KErrNone == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair)); |
|
1102 timeAfter = User::FastCounter(); |
|
1103 measure1 += 1000 * ((TReal)(timeAfter-timeBefore)) / ((TReal) freq); |
|
1104 hintPair2.iKey.iUid = uidArray[i]; |
|
1105 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
1106 TEST(hintPair2.iValue == 300); |
|
1107 TEST(hintPair2.iMutable == 1); |
|
1108 } |
|
1109 // RDebug::Print(_L("[LOG]: \t%d \t%f "), i, measure1/numberOfCalculation); |
|
1110 measureTotal +=measure1; |
|
1111 } |
|
1112 INFO_PRINTF2(_L("the average time for SetSurfaceHint is %f\r\n"),measureTotal/8); |
|
1113 |
|
1114 RDebug::Print(_L("SetSurfaceHint Test finished")); |
|
1115 iSurfaceManager.CloseSurface(surfaceId); |
|
1116 // For AddSurfaceHint |
|
1117 RSurfaceManager::TSurfaceCreationAttributesBuf bufNew; |
|
1118 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = bufNew(); |
|
1119 attributesNew.iSize = TSize(1,1); |
|
1120 attributesNew.iBuffers = 1; |
|
1121 attributesNew.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
1122 attributesNew.iStride = 1; |
|
1123 attributesNew.iOffsetToFirstBuffer = 1; |
|
1124 attributesNew.iAlignment = RSurfaceManager::EPageAligned; |
|
1125 attributesNew.iOffsetBetweenBuffers = 0; |
|
1126 attributesNew.iContiguous = ETrue; |
|
1127 attributesNew.iCacheAttrib = RSurfaceManager::ECached; // Cache attributes |
|
1128 attributesNew.iMappable = ETrue; |
|
1129 |
|
1130 // Create a surface with no surface hints defined |
|
1131 TSurfaceId surfaceIdNew; |
|
1132 TInt err1 = iSurfaceManager.CreateSurface(bufNew, surfaceIdNew); |
|
1133 TEST(KErrNone == err1); |
|
1134 measureTotal = 0; |
|
1135 // Measure time of adding surface hint of different location |
|
1136 for (i = 0; i<maxHintsPerSurface; ++i) |
|
1137 { |
|
1138 hintPair.iKey.iUid = uidArray[i]; |
|
1139 hintPair.iValue = 300+i; |
|
1140 hintPair.iMutable = ETrue; |
|
1141 timeBefore = User::FastCounter(); |
|
1142 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceIdNew, hintPair)); |
|
1143 timeAfter = User::FastCounter(); |
|
1144 measure1 = 1000 * ((TReal)(timeAfter-timeBefore)) / ((TReal) freq); |
|
1145 measureTotal += measure1; |
|
1146 // RDebug::Print(_L("AddSurfaceHint [LOG]: \t%d \t%f "), i, measure1); |
|
1147 } |
|
1148 INFO_PRINTF2(_L("the average time for AddSurfaceHint is %f\r\n"),measureTotal/8); |
|
1149 |
|
1150 // Check all 8 hint pairs have the right values |
|
1151 measureTotal = 0; |
|
1152 for (i = 0; i<maxHintsPerSurface; ++i) |
|
1153 { |
|
1154 hintPair2.iKey.iUid = uidArray[i]; |
|
1155 timeBefore = User::FastCounter(); |
|
1156 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceIdNew, hintPair2)); |
|
1157 timeAfter = User::FastCounter(); |
|
1158 measure1 = 1000 * ((TReal)(timeAfter-timeBefore)) / ((TReal) freq); |
|
1159 measureTotal += measure1; |
|
1160 // RDebug::Print(_L("GetSurfaceHint [LOG]: \t%d \t%f "), i, measure1); |
|
1161 TEST(hintPair2.iValue == 300+i); |
|
1162 TEST(hintPair2.iMutable == 1); |
|
1163 } |
|
1164 INFO_PRINTF2(_L("the average time for GetSurfaceHint is %f\r\n"),measureTotal/8); |
|
1165 |
|
1166 iSurfaceManager.CloseSurface(surfaceIdNew); |
|
1167 |
|
1168 |
|
1169 // For SynchronizeCache |
|
1170 TEST(KErrNone == iSurfaceManager.CreateSurface(bufNew, surfaceIdNew)); |
|
1171 measureTotal = 0; |
|
1172 TInt index = 0; |
|
1173 do |
|
1174 { |
|
1175 timeBefore = User::FastCounter(); |
|
1176 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceIdNew,0, RSurfaceManager::ESyncBeforeNonCPURead)); |
|
1177 timeAfter = User::FastCounter(); |
|
1178 measure1= 1000000 * ((TReal)(timeAfter - timeBefore)) / ((TReal) freq); |
|
1179 // RDebug::Print(_L("SynchronizeCache [LOG]: \t%d \t%f "), index, measure1); |
|
1180 measureTotal += measure1; |
|
1181 } while ( index++ < numberOfCalculation); |
|
1182 |
|
1183 INFO_PRINTF2(_L("the average time for SynchronizeCache a surface is %f\r\n"),measureTotal/numberOfCalculation); |
|
1184 |
|
1185 iSurfaceManager.CloseSurface(surfaceIdNew); |
|
1186 |
|
1187 uidArray.Close(); |
|
1188 iSurfaceManager.Close(); |
|
1189 |
|
1190 } |
|
1191 |
|
1192 |
|
1193 void CTSurfaceManager::TestCreateSurfaceNewChunk1L() |
|
1194 { |
|
1195 INFO_PRINTF1(_L("Creating a Surface in a new shared chunk\r\n")); |
|
1196 // Open the surface manager |
|
1197 User::LeaveIfError(iSurfaceManager.Open()); |
|
1198 |
|
1199 // Setup attributes |
|
1200 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1201 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1202 |
|
1203 attributes.iSize = TSize(100,100); |
|
1204 attributes.iBuffers = 1; // number of buffers in the surface |
|
1205 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
1206 attributes.iStride = 400; // Number of bytes between start of one line and start of next |
|
1207 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
1208 |
|
1209 RSurfaceManager::THintPair hints[2]; |
|
1210 attributes.iHintCount=2; |
|
1211 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1212 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1213 attributes.iSurfaceHints = hints; |
|
1214 attributes.iOffsetBetweenBuffers = 0; |
|
1215 attributes.iContiguous = ETrue; |
|
1216 attributes.iCacheAttrib = RSurfaceManager::ENotCached; // Cache attributes |
|
1217 attributes.iMappable = ETrue; |
|
1218 |
|
1219 // Test create surface doesn't return an error |
|
1220 SurfaceOperation(buf); |
|
1221 |
|
1222 //cache attribute is not valid on emulator |
|
1223 #ifndef __WINS__ |
|
1224 TEST(iInfo.iCacheAttrib == attributes.iCacheAttrib); |
|
1225 #else |
|
1226 INFO_PRINTF1(_L("Cache attribute test is not valid on emulator\n")); |
|
1227 #endif |
|
1228 |
|
1229 //contiguous attribute is not valid on emulator |
|
1230 #ifndef __WINS__ |
|
1231 TEST(iInfo.iContiguous == attributes.iContiguous); |
|
1232 #else |
|
1233 INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n")); |
|
1234 #endif |
|
1235 |
|
1236 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1237 |
|
1238 //Test different contiguous attricutes |
|
1239 attributes.iContiguous=EFalse; |
|
1240 // Test create surface doesn't return an error |
|
1241 SurfaceOperation(buf); |
|
1242 |
|
1243 //contiguous attribute is not valid on emulator |
|
1244 #ifndef __WINS__ |
|
1245 TEST(iInfo.iContiguous == attributes.iContiguous); |
|
1246 #else |
|
1247 INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n")); |
|
1248 #endif |
|
1249 |
|
1250 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1251 |
|
1252 // Test different cache attributes |
|
1253 attributes.iCacheAttrib = RSurfaceManager::ENotCached; // Cache attributes |
|
1254 // Test create surface doesn't return an error |
|
1255 SurfaceOperation(buf); |
|
1256 |
|
1257 //cache attribute is not valid on emulator |
|
1258 #ifndef __WINS__ |
|
1259 TEST(iInfo.iCacheAttrib == attributes.iCacheAttrib); |
|
1260 #else |
|
1261 INFO_PRINTF1(_L("Cache attribute test is not valid on emulator\n")); |
|
1262 #endif |
|
1263 |
|
1264 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1265 |
|
1266 //Set different alignment for CPU cached and noncached, test create surface doesn't return an error |
|
1267 ChangeAttributes(&attributes, (TInt)RSurfaceManager::EPageAligned, 4096, 53248, RSurfaceManager::ECached); |
|
1268 SurfaceOperation(buf); |
|
1269 CheckAttributesL(attributes); |
|
1270 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1271 |
|
1272 ChangeAttributes(&attributes, (TInt)RSurfaceManager::EPageAligned, 4096, 53248, RSurfaceManager::ENotCached); |
|
1273 SurfaceOperation(buf); |
|
1274 CheckAttributesL(attributes); |
|
1275 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1276 |
|
1277 ChangeAttributes(&attributes, 1, 32, 50016, RSurfaceManager::ECached); |
|
1278 SurfaceOperation(buf); |
|
1279 CheckAttributesL(attributes); |
|
1280 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1281 |
|
1282 ChangeAttributes(&attributes, 1, 10, 50010, RSurfaceManager::ENotCached); |
|
1283 SurfaceOperation(buf); |
|
1284 CheckAttributesL(attributes); |
|
1285 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1286 |
|
1287 ChangeAttributes(&attributes, 2, 32, 50016, RSurfaceManager::ECached); |
|
1288 SurfaceOperation(buf); |
|
1289 CheckAttributesL(attributes); |
|
1290 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1291 |
|
1292 ChangeAttributes(&attributes, 2, 10, 50010, RSurfaceManager::ENotCached); |
|
1293 SurfaceOperation(buf); |
|
1294 CheckAttributesL(attributes); |
|
1295 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1296 |
|
1297 ChangeAttributes(&attributes, 4, 32, 50016, RSurfaceManager::ECached); |
|
1298 SurfaceOperation(buf); |
|
1299 CheckAttributesL(attributes); |
|
1300 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1301 |
|
1302 ChangeAttributes(&attributes, 4, 12, 50012, RSurfaceManager::ENotCached); |
|
1303 SurfaceOperation(buf); |
|
1304 CheckAttributesL(attributes); |
|
1305 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1306 |
|
1307 ChangeAttributes(&attributes, 8, 32, 50016, RSurfaceManager::ECached); |
|
1308 SurfaceOperation(buf); |
|
1309 CheckAttributesL(attributes); |
|
1310 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1311 |
|
1312 ChangeAttributes(&attributes, 8, 16, 50016, RSurfaceManager::ENotCached); |
|
1313 SurfaceOperation(buf); |
|
1314 CheckAttributesL(attributes); |
|
1315 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1316 |
|
1317 ChangeAttributes(&attributes, 16, 32, 50016, RSurfaceManager::ECached); |
|
1318 SurfaceOperation(buf); |
|
1319 CheckAttributesL(attributes); |
|
1320 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1321 |
|
1322 ChangeAttributes(&attributes, 16, 16, 50016, RSurfaceManager::ENotCached); |
|
1323 SurfaceOperation(buf); |
|
1324 CheckAttributesL(attributes); |
|
1325 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1326 |
|
1327 ChangeAttributes(&attributes, 32, 32, 50016, RSurfaceManager::ECached); |
|
1328 SurfaceOperation(buf); |
|
1329 CheckAttributesL(attributes); |
|
1330 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1331 |
|
1332 ChangeAttributes(&attributes, 32, 32, 50016, RSurfaceManager::ENotCached); |
|
1333 SurfaceOperation(buf); |
|
1334 CheckAttributesL(attributes); |
|
1335 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1336 |
|
1337 ChangeAttributes(&attributes, 64, 64, 50048, RSurfaceManager::ECached); |
|
1338 SurfaceOperation(buf); |
|
1339 CheckAttributesL(attributes); |
|
1340 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1341 |
|
1342 ChangeAttributes(&attributes, 64, 64, 50048, RSurfaceManager::ENotCached); |
|
1343 SurfaceOperation(buf); |
|
1344 CheckAttributesL(attributes); |
|
1345 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1346 |
|
1347 // Close the surface manager |
|
1348 iSurfaceManager.Close(); |
|
1349 } |
|
1350 |
|
1351 void CTSurfaceManager::ChangeAttributes(RSurfaceManager::TSurfaceCreationAttributes* aAttributes, TInt aAlignment, TInt aOffsetToFirstBuffer, TInt aOffsetBetweenBuffers, RSurfaceManager::TCacheAttribute aCacheAttrib) |
|
1352 { |
|
1353 aAttributes->iAlignment = aAlignment; |
|
1354 aAttributes->iOffsetToFirstBuffer = aOffsetToFirstBuffer; |
|
1355 aAttributes->iOffsetBetweenBuffers = aOffsetBetweenBuffers; |
|
1356 aAttributes->iCacheAttrib = aCacheAttrib; |
|
1357 } |
|
1358 |
|
1359 void CTSurfaceManager::SurfaceOperation(RSurfaceManager::TSurfaceCreationAttributesBuf& aBuf) |
|
1360 { |
|
1361 TEST(KErrNone == iSurfaceManager.CreateSurface(aBuf, iSurfaceId)); |
|
1362 TEST(KErrNone == iSurfaceManager.SurfaceInfo(iSurfaceId, iInfoBuf)); |
|
1363 iInfo = iInfoBuf(); |
|
1364 } |
|
1365 |
|
1366 void CTSurfaceManager::CheckAttributesL(RSurfaceManager::TSurfaceCreationAttributes& aAttributes) |
|
1367 { |
|
1368 TEST(aAttributes.iSize==iInfo.iSize); |
|
1369 TEST(aAttributes.iBuffers==iInfo.iBuffers); |
|
1370 TEST(aAttributes.iPixelFormat==iInfo.iPixelFormat); |
|
1371 TEST(aAttributes.iStride==iInfo.iStride); |
|
1372 TEST(aAttributes.iContiguous==iInfo.iContiguous); |
|
1373 TEST(aAttributes.iCacheAttrib==iInfo.iCacheAttrib); |
|
1374 |
|
1375 //Test the chunk size is big enough to hold the surface when we create it |
|
1376 //with the offset between buffers |
|
1377 if (aAttributes.iOffsetBetweenBuffers!=0) |
|
1378 { |
|
1379 CheckSizeL(aAttributes.iOffsetToFirstBuffer, aAttributes.iOffsetBetweenBuffers); |
|
1380 } |
|
1381 } |
|
1382 |
|
1383 void CTSurfaceManager::CheckSizeL(TInt aOffsetToFirstBuffer, TInt aOffsetBetweenBuffers) |
|
1384 { |
|
1385 TInt64 bufferSize = iInfo.iBuffers * aOffsetBetweenBuffers; |
|
1386 TInt64 chunkSize = aOffsetToFirstBuffer + bufferSize; |
|
1387 TESTL(KErrNone == iSurfaceManager.MapSurface(iSurfaceId,iHandle)); |
|
1388 TInt64 currChunkSize = iHandle.Size(); |
|
1389 TEST(currChunkSize >= chunkSize); |
|
1390 iHandle.Close(); |
|
1391 } |
|
1392 |
|
1393 void CTSurfaceManager::TestCreateSurfaceNewChunk2L() |
|
1394 { |
|
1395 INFO_PRINTF1(_L("Creating a Surface in a new shared chunk\r\n")); |
|
1396 // Open the surface manager |
|
1397 User::LeaveIfError(iSurfaceManager.Open()); |
|
1398 |
|
1399 // Setup attributes |
|
1400 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1401 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1402 |
|
1403 attributes.iSize = TSize(100,100); |
|
1404 attributes.iBuffers = 1; // number of buffers in the surface |
|
1405 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
1406 attributes.iStride = 400; // Number of bytes between start of one line and start of next |
|
1407 attributes.iOffsetToFirstBuffer = 9; // way of reserving space before the surface pixel data |
|
1408 attributes.iAlignment = 1; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
1409 |
|
1410 RSurfaceManager::THintPair hints[2]; |
|
1411 attributes.iHintCount=2; |
|
1412 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1413 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1414 attributes.iSurfaceHints = hints; |
|
1415 |
|
1416 attributes.iOffsetBetweenBuffers = 50009; |
|
1417 attributes.iContiguous = ETrue; |
|
1418 attributes.iCacheAttrib = RSurfaceManager::ECached; // Cache attributes |
|
1419 attributes.iMappable = ETrue; |
|
1420 |
|
1421 //Test create surface doesn't return an error |
|
1422 SurfaceOperation(buf); |
|
1423 CheckSizeL(32, 50016); |
|
1424 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1425 |
|
1426 // Test different cache attributes |
|
1427 attributes.iCacheAttrib = RSurfaceManager::ENotCached; // Cache attributes |
|
1428 SurfaceOperation(buf); |
|
1429 CheckSizeL(9, 50009); |
|
1430 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1431 |
|
1432 ChangeAttributes(&attributes, 2, 9, 50009, RSurfaceManager::ECached); |
|
1433 SurfaceOperation(buf); |
|
1434 CheckSizeL(32,50016); |
|
1435 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1436 |
|
1437 ChangeAttributes(&attributes, 2, 9, 50009, RSurfaceManager::ENotCached); |
|
1438 SurfaceOperation(buf); |
|
1439 CheckSizeL(10,50010); |
|
1440 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1441 |
|
1442 ChangeAttributes(&attributes, 4, 10, 50010, RSurfaceManager::ECached); |
|
1443 SurfaceOperation(buf); |
|
1444 CheckSizeL(32,50016); |
|
1445 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1446 |
|
1447 ChangeAttributes(&attributes, 4, 10, 50010, RSurfaceManager::ENotCached); |
|
1448 SurfaceOperation(buf); |
|
1449 CheckSizeL(12,50012); |
|
1450 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1451 |
|
1452 ChangeAttributes(&attributes, 8, 10, 50010, RSurfaceManager::ECached); |
|
1453 SurfaceOperation(buf); |
|
1454 CheckSizeL(32,50016); |
|
1455 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1456 |
|
1457 ChangeAttributes(&attributes, 8, 10, 50010, RSurfaceManager::ENotCached); |
|
1458 SurfaceOperation(buf); |
|
1459 CheckSizeL(16,50016); |
|
1460 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1461 |
|
1462 ChangeAttributes(&attributes, 16, 10, 50010, RSurfaceManager::ECached); |
|
1463 SurfaceOperation(buf); |
|
1464 CheckSizeL(32,50016); |
|
1465 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1466 |
|
1467 ChangeAttributes(&attributes, 16, 10, 50010, RSurfaceManager::ENotCached); |
|
1468 SurfaceOperation(buf); |
|
1469 CheckSizeL(16,50016); |
|
1470 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1471 |
|
1472 ChangeAttributes(&attributes, 32, 10, 50010, RSurfaceManager::ECached); |
|
1473 SurfaceOperation(buf); |
|
1474 CheckSizeL(32,50016); |
|
1475 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1476 |
|
1477 ChangeAttributes(&attributes, 32, 10, 50010, RSurfaceManager::ENotCached); |
|
1478 SurfaceOperation(buf); |
|
1479 CheckSizeL(32,50016); |
|
1480 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1481 |
|
1482 ChangeAttributes(&attributes, 64, 10, 50010, RSurfaceManager::ECached); |
|
1483 SurfaceOperation(buf); |
|
1484 CheckSizeL(64,50048); |
|
1485 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1486 |
|
1487 ChangeAttributes(&attributes, 64, 10, 50010, RSurfaceManager::ENotCached); |
|
1488 SurfaceOperation(buf); |
|
1489 CheckSizeL(64,50048); |
|
1490 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1491 |
|
1492 |
|
1493 ChangeAttributes(&attributes, (TInt)RSurfaceManager::EPageAligned, 10, 50010, RSurfaceManager::ECached); |
|
1494 SurfaceOperation(buf); |
|
1495 CheckSizeL(4096,53248); |
|
1496 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1497 |
|
1498 ChangeAttributes(&attributes, (TInt)RSurfaceManager::EPageAligned, 10, 50010, RSurfaceManager::ENotCached); |
|
1499 SurfaceOperation(buf); |
|
1500 CheckSizeL(4096,53248); |
|
1501 TEST(KErrNone == iSurfaceManager.CloseSurface(iSurfaceId)); |
|
1502 |
|
1503 // Close the surface manager |
|
1504 iSurfaceManager.Close(); |
|
1505 } |
|
1506 |
|
1507 void CTSurfaceManager::TestCreateSurfaceExisitingChunkL() |
|
1508 { |
|
1509 INFO_PRINTF1(_L("creating a surface in an exisiting shared chunk\r\n")); |
|
1510 // Call another device driver to get a valid shared chunk handle |
|
1511 RSharedChunkLdd device; |
|
1512 RChunk handle; |
|
1513 TUint ChunkSize = 204800; // bottom 8 bits reserved space for other chunk creation attributes info |
|
1514 TUint ChunkAttribs = ChunkSize|EMultiple|EOwnsMemory|ECached; |
|
1515 TUint ContiguousAttrib = 1; |
|
1516 GetSharedChunkHandleL(device, handle, ChunkSize, ChunkAttribs, ContiguousAttrib); |
|
1517 |
|
1518 INFO_PRINTF1(_L("Creating a Surface in an exisitng shared chunk\r\n")); |
|
1519 // Open the surface manager |
|
1520 User::LeaveIfError(iSurfaceManager.Open()); |
|
1521 |
|
1522 // Setup attributes |
|
1523 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
1524 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1525 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1526 |
|
1527 attributes.iSize = TSize(100,100); |
|
1528 attributes.iBuffers = 1; // number of buffers in the surface |
|
1529 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
1530 attributes.iStride = 400; // Number of bytes between start of one line and start of next |
|
1531 attributes.iOffsetToFirstBuffer = 4096; // way of reserving space before the surface pixel data |
|
1532 attributes.iAlignment = 4; |
|
1533 |
|
1534 RSurfaceManager::THintPair hints[2]; |
|
1535 attributes.iHintCount=2; |
|
1536 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1537 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1538 attributes.iSurfaceHints = hints; |
|
1539 |
|
1540 attributes.iOffsetBetweenBuffers = 0; |
|
1541 |
|
1542 attributes.iMappable = ETrue; |
|
1543 |
|
1544 TSurfaceId surfaceId; |
|
1545 // Test create surface doesn't return an error |
|
1546 TInt err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1547 TEST(KErrNone == err); |
|
1548 |
|
1549 RSurfaceManager::TInfoBuf infoBuf; |
|
1550 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
1551 if (err == KErrNone) |
|
1552 { |
|
1553 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1554 |
|
1555 //cache attribute is not valid on emulator |
|
1556 #ifndef __WINS__ |
|
1557 TEST(info.iCacheAttrib == device.GetCacheAttribute()); |
|
1558 #else |
|
1559 INFO_PRINTF1(_L("Cache attribute test is not valid on emulator\n")); |
|
1560 #endif |
|
1561 |
|
1562 //contiguous attribute is not valid on emulator |
|
1563 #ifndef __WINS__ |
|
1564 TEST(info.iContiguous == device.GetContiguousAttribute()); |
|
1565 #else |
|
1566 INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n")); |
|
1567 #endif |
|
1568 |
|
1569 //Map the surface to get a new shared chunk handle |
|
1570 RChunk handle2; |
|
1571 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle2)); |
|
1572 |
|
1573 //Check the two handles are different but refer to the same shared chunk |
|
1574 TEST(handle.Handle() != handle2.Handle()); |
|
1575 TEST(handle.Base() == handle2.Base()); |
|
1576 |
|
1577 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1578 |
|
1579 handle2.Close(); |
|
1580 } |
|
1581 |
|
1582 //Reset iOffsetBetweenBuffers is 40960 |
|
1583 attributes.iOffsetBetweenBuffers = 40960; |
|
1584 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
1585 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
1586 |
|
1587 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1588 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1589 |
|
1590 //Test different iOffsetBetweenBuffers attributes |
|
1591 attributes.iOffsetBetweenBuffers = 53248; |
|
1592 RChunk handle3; |
|
1593 // Test create surface doesn't return an error |
|
1594 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
1595 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle3)); |
|
1596 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1597 |
|
1598 //Test the chunk size is big enough to hold the surface |
|
1599 TInt64 bufferSize= attributes.iBuffers * attributes.iOffsetBetweenBuffers; |
|
1600 TInt64 chunkSize = attributes.iOffsetToFirstBuffer + bufferSize; |
|
1601 TInt64 currChunkSize = handle3.Size(); |
|
1602 |
|
1603 TEST(currChunkSize >= chunkSize); |
|
1604 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1605 |
|
1606 //set iBuffer is equal to 2 and test iOffsetBetweenBuffers returns the right value, check the chunk size is big enough to hold the surface |
|
1607 attributes.iBuffers = 2; |
|
1608 RChunk handle4; |
|
1609 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
1610 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle4)); |
|
1611 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1612 |
|
1613 bufferSize = attributes.iBuffers * attributes.iOffsetBetweenBuffers; |
|
1614 chunkSize = attributes.iOffsetToFirstBuffer + bufferSize; |
|
1615 currChunkSize = handle4.Size(); |
|
1616 |
|
1617 TInt offsetToFirstBuffer; |
|
1618 TInt offsetBetweenBuffers; |
|
1619 err=iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer); |
|
1620 err=iSurfaceManager.GetBufferOffset(surfaceId, 1, offsetBetweenBuffers); |
|
1621 offsetBetweenBuffers-=offsetToFirstBuffer; |
|
1622 TEST(offsetBetweenBuffers == attributes.iOffsetBetweenBuffers); |
|
1623 TEST(currChunkSize >= chunkSize); |
|
1624 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1625 |
|
1626 handle4.Close(); |
|
1627 handle3.Close(); |
|
1628 handle.Close(); |
|
1629 device.CloseChunkHandle(handle); |
|
1630 // Close the surface manager |
|
1631 iSurfaceManager.Close(); |
|
1632 device.CloseChunk(); |
|
1633 device.Close(); |
|
1634 } |
|
1635 |
|
1636 |
|
1637 void CTSurfaceManager::TestCreateSurfaceChunkWithHolesL() |
|
1638 { |
|
1639 INFO_PRINTF1(_L("creating a surface in an exisiting shared chunk with HOLES\r\n")); |
|
1640 // Call another device driver to get a valid shared chunk handle |
|
1641 RSharedChunkLdd device; |
|
1642 RChunk handle; |
|
1643 TUint ChunkSize = 204800; |
|
1644 TUint ChunkAttribs = ChunkSize|EMultiple|EOwnsMemory|ECached; |
|
1645 TUint ContiguousAttrib = 0; |
|
1646 // We use the same stride everywhere to make life easier. |
|
1647 const TUint KStride = 64; |
|
1648 TInt r; |
|
1649 |
|
1650 INFO_PRINTF1(_L("Load Logical Device\r\n")); |
|
1651 r=User::LoadLogicalDevice(KSharedChunkLddName); |
|
1652 TEST(r==KErrNone || r==KErrAlreadyExists); |
|
1653 |
|
1654 INFO_PRINTF1(_L("Open Device")); |
|
1655 User::LeaveIfError(device.Open()); |
|
1656 |
|
1657 //Create shared chunk and commit the memory |
|
1658 INFO_PRINTF1(_L("Test chunk create")); |
|
1659 |
|
1660 TEST(KErrNone==device.CreateChunk(ChunkAttribs)); |
|
1661 |
|
1662 // Find size of a page. |
|
1663 TInt pageSize; |
|
1664 TEST(KErrNone == UserHal::PageSizeInBytes(pageSize)); |
|
1665 // Fill in one page's worth of memory. |
|
1666 TEST(KErrNone==device.CommitMemory(0 | ContiguousAttrib, pageSize)); |
|
1667 |
|
1668 //Get the chunk handle |
|
1669 INFO_PRINTF1(_L("Open user handle")); |
|
1670 TEST(KErrNone==device.GetChunkHandle(handle)); |
|
1671 |
|
1672 INFO_PRINTF1(_L("Creating a Surface in an exisitng shared chunk with holes\r\n")); |
|
1673 // Open the surface manager |
|
1674 User::LeaveIfError(iSurfaceManager.Open()); |
|
1675 |
|
1676 // Setup attributes |
|
1677 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
1678 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1679 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1680 |
|
1681 attributes.iSize = TSize(10,10); |
|
1682 attributes.iBuffers = 2; // number of buffers in the surface |
|
1683 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
1684 attributes.iStride = KStride; // Number of bytes between start of one line and start of next |
|
1685 attributes.iOffsetToFirstBuffer = pageSize; // Add this to the first address -> fails, since the actual content is |
|
1686 // outside of the chunk. |
|
1687 attributes.iOffsetBetweenBuffers = 0; // 0 => Let CreateSurface calculatet the size by itself. |
|
1688 attributes.iAlignment = 4; // Need to have some alignment. |
|
1689 attributes.iMappable = ETrue; |
|
1690 |
|
1691 TSurfaceId surfaceId; |
|
1692 // This should FAIL. |
|
1693 TInt err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1694 TEST(KErrArgument == err); |
|
1695 |
|
1696 // Use a smaller "user area" so that it will fit. |
|
1697 attributes.iSize = TSize(10,10); |
|
1698 attributes.iOffsetToFirstBuffer = 100; // way of reserving space before the surface pixel data |
|
1699 |
|
1700 // This should PASS. |
|
1701 err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1702 TEST(KErrNone == err); |
|
1703 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1704 |
|
1705 // Now add in another bit of memory 2*pagesize so that a second buffer fits in the page.. |
|
1706 TEST(KErrNone==device.CommitMemory(pageSize * 2 | ContiguousAttrib, pageSize)); |
|
1707 |
|
1708 attributes.iSize = TSize(32,pageSize / KStride); |
|
1709 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
1710 attributes.iOffsetBetweenBuffers = pageSize * 2; |
|
1711 |
|
1712 // This should PASS. |
|
1713 err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1714 TEST(KErrNone == err); |
|
1715 RSurfaceManager::TInfoBuf infoBuf; |
|
1716 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1717 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
1718 // Check that we do NOT get a contiguous surface back - it isn't contiguous when |
|
1719 // there is a hole in it! |
|
1720 TEST(!info.iContiguous); |
|
1721 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1722 |
|
1723 attributes.iSize = TSize(32,(pageSize + pageSize / 2) / KStride); // Use 1.5 pages worth. |
|
1724 |
|
1725 // This should FAIL. |
|
1726 err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1727 TEST(KErrArgument == err); |
|
1728 |
|
1729 attributes.iSize = TSize(32,(pageSize / 2) / KStride); // Half a page of buffer. |
|
1730 attributes.iOffsetToFirstBuffer = pageSize / 2; // Half a page of "user data" at first buffer. |
|
1731 |
|
1732 // This should PASS. |
|
1733 err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1734 TEST(KErrNone == err); |
|
1735 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1736 info = infoBuf(); |
|
1737 // Check that we do NOT get a contiguous surface back - it isn't contiguous when |
|
1738 // there is a hole in it! |
|
1739 TEST(!info.iContiguous); |
|
1740 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1741 |
|
1742 attributes.iSize = TSize(32,((pageSize / 2) / KStride)-1); // Half a page of buffer - minus a tiny bit. |
|
1743 attributes.iOffsetToFirstBuffer = KStride + pageSize / 2; // Half a page of "user data" at first buffer, plus a bit. . |
|
1744 attributes.iAlignment = KStride; |
|
1745 |
|
1746 // This should PASS. |
|
1747 err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1748 TEST(KErrNone == err); |
|
1749 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1750 info = infoBuf(); |
|
1751 // Check that we do NOT get a contiguous surface back - it isn't contiguous when |
|
1752 // there is a hole in it! |
|
1753 TEST(!info.iContiguous); |
|
1754 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1755 |
|
1756 // Half a page of "user data" at first buffer, plus 2 strides to go over the edge |
|
1757 attributes.iOffsetToFirstBuffer = 2 * KStride + pageSize / 2; |
|
1758 attributes.iAlignment = 4; |
|
1759 |
|
1760 // This should FAIL. |
|
1761 err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1762 TEST(KErrArgument == err); |
|
1763 |
|
1764 // Ask for HUGE buffer with no actual memory there. |
|
1765 attributes.iSize = TSize(32, pageSize * pageSize); // A page of pages * stride is several gigabytes at 4K/page. |
|
1766 |
|
1767 // This should FAIL |
|
1768 err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
1769 TEST(KErrArgument == err); |
|
1770 |
|
1771 device.CloseChunkHandle(handle); |
|
1772 // Close the surface manager |
|
1773 iSurfaceManager.Close(); |
|
1774 device.CloseChunk(); |
|
1775 device.Close(); |
|
1776 } |
|
1777 |
|
1778 void CTSurfaceManager::GetSharedChunkHandleL(RSharedChunkLdd& aDevice, RChunk& aHandle, TUint aChunkSize, TUint aChunkAttribs, TUint aContiguousAttrib) |
|
1779 { |
|
1780 TInt r; |
|
1781 |
|
1782 INFO_PRINTF1(_L("Load Logical Device\r\n")); |
|
1783 r=User::LoadLogicalDevice(KSharedChunkLddName); |
|
1784 TEST(r==KErrNone || r==KErrAlreadyExists); |
|
1785 |
|
1786 INFO_PRINTF1(_L("Open Device")); |
|
1787 User::LeaveIfError(aDevice.Open()); |
|
1788 |
|
1789 //Create shared chunk and commit the memory |
|
1790 INFO_PRINTF1(_L("Test chunk create")); |
|
1791 |
|
1792 TEST(KErrNone==aDevice.CreateChunk(aChunkAttribs)); |
|
1793 TEST(KErrNone==aDevice.CommitMemory(aContiguousAttrib, aChunkSize)); |
|
1794 |
|
1795 //Get the chunk handle |
|
1796 INFO_PRINTF1(_L("Open user handle")); |
|
1797 TEST(KErrNone==aDevice.GetChunkHandle(aHandle)); |
|
1798 } |
|
1799 |
|
1800 void CTSurfaceManager::TestCreateSurfaceExisitingChunk2L() |
|
1801 { |
|
1802 // Create a surface in a new shared chunk |
|
1803 INFO_PRINTF1(_L("Creating a Surface with distinct creation attributes in an exisitng shared chunk which already contains a surface\r\n")); |
|
1804 // Open the surface manager |
|
1805 User::LeaveIfError(iSurfaceManager.Open()); |
|
1806 |
|
1807 // Setup attributes |
|
1808 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1809 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1810 |
|
1811 attributes.iSize = TSize(100,100); |
|
1812 attributes.iBuffers = 1; // number of buffers in the surface |
|
1813 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
1814 attributes.iStride = 400; // Number of bytes between start of one line and start of next |
|
1815 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
1816 attributes.iAlignment = 2; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
1817 |
|
1818 ReAllocHintsArrayL(2); |
|
1819 attributes.iHintCount=2; |
|
1820 iHintsArray[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1821 iHintsArray[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
1822 attributes.iSurfaceHints = iHintsArray; |
|
1823 |
|
1824 attributes.iContiguous = ETrue; |
|
1825 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
1826 attributes.iOffsetBetweenBuffers = 0; |
|
1827 attributes.iMappable = ETrue; |
|
1828 |
|
1829 // Test create surface doesn't return an error |
|
1830 TSurfaceId surfaceId; |
|
1831 |
|
1832 // Test create surface doesn't return an error |
|
1833 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
1834 |
|
1835 //store all the attributes |
|
1836 RSurfaceManager::TInfoBuf infoBuf; |
|
1837 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1838 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
1839 |
|
1840 //Map the surface in the current processs |
|
1841 RChunk handle; |
|
1842 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
1843 |
|
1844 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
1845 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
1846 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = buff(); |
|
1847 |
|
1848 attributesNew.iSize = TSize(480,16); |
|
1849 attributesNew.iBuffers = 2; // number of buffers in the surface |
|
1850 attributesNew.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
1851 attributesNew.iStride = 1013; // Number of bytes between start of one line and start of next |
|
1852 attributesNew.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
1853 |
|
1854 RSurfaceManager::THintPair hint; |
|
1855 attributes.iHintCount=1; |
|
1856 hint.Set(TUid::Uid(0x124545), 50, EFalse); |
|
1857 attributes.iSurfaceHints = &hint; |
|
1858 |
|
1859 attributesNew.iAlignment = RSurfaceManager::EPageAligned; |
|
1860 attributesNew.iOffsetBetweenBuffers = 0; |
|
1861 attributesNew.iMappable = ETrue; |
|
1862 |
|
1863 // Test create surface doesn't return an error |
|
1864 TSurfaceId surfaceIdNew; |
|
1865 // Test create surface doesn't return an error |
|
1866 TEST(KErrNone == iSurfaceManager.CreateSurface(buff, surfaceIdNew, handle)); |
|
1867 |
|
1868 //Store all the attributes |
|
1869 RSurfaceManager::TInfoBuf infoBufNew; |
|
1870 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceIdNew, infoBufNew)); |
|
1871 RSurfaceManager::TSurfaceInfoV01& infoNew = infoBufNew(); |
|
1872 |
|
1873 //Map the new surface in the current process |
|
1874 RChunk handleNew; |
|
1875 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceIdNew,handleNew)); |
|
1876 |
|
1877 //cache attribute is not valid on emulator |
|
1878 #ifndef __WINS__ |
|
1879 TEST(info.iCacheAttrib == infoNew.iCacheAttrib); |
|
1880 #else |
|
1881 INFO_PRINTF1(_L("Cache attribute test is not valid on emulator\n")); |
|
1882 #endif |
|
1883 |
|
1884 //contiguous attribute is not valid on emulator |
|
1885 #ifndef __WINS__ |
|
1886 TEST(info.iContiguous == infoNew.iContiguous); |
|
1887 #else |
|
1888 INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n")); |
|
1889 #endif |
|
1890 |
|
1891 //two surfaceIds are different |
|
1892 TEST(surfaceId != surfaceIdNew); |
|
1893 |
|
1894 //check the offset between buffers is valid |
|
1895 TInt offsetToFirstBufferNew; |
|
1896 TInt offsetBetweenBuffersNew; |
|
1897 TInt err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 0, offsetToFirstBufferNew); |
|
1898 err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 1, offsetBetweenBuffersNew); |
|
1899 offsetBetweenBuffersNew-=offsetToFirstBufferNew; |
|
1900 TEST(offsetBetweenBuffersNew >= attributesNew.iSize.iHeight*attributesNew.iStride); |
|
1901 //check the two handles are different but refer to the same shared chunk |
|
1902 TEST(handle.Handle() != handleNew.Handle()); |
|
1903 TEST(handle.Base() == handleNew.Base()); |
|
1904 |
|
1905 // Get the adress of this chunk of memory |
|
1906 TUint8* surfaceAddNew = handleNew.Base(); |
|
1907 TUint8* bufferAddNew = surfaceAddNew + attributes.iOffsetToFirstBuffer; |
|
1908 |
|
1909 // Write to the second surface's buffer, and test the value is written |
|
1910 *bufferAddNew = 20; |
|
1911 TInt temp = *bufferAddNew; |
|
1912 TEST(temp == 20); |
|
1913 |
|
1914 //Read the value from the address of the pixel data for this first surface |
|
1915 TUint8* surfaceAdd = handle.Base(); |
|
1916 TUint8* bufferAdd = surfaceAdd + attributes.iOffsetToFirstBuffer; |
|
1917 TEST(*bufferAdd == 20); |
|
1918 |
|
1919 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
1920 // As the surface is not created properly, closing returns KErrArgument |
|
1921 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
1922 |
|
1923 //Reset iOffsetBetweenBuffers is 20480 |
|
1924 attributesNew.iOffsetBetweenBuffers = 20480; |
|
1925 TEST(KErrNone == iSurfaceManager.CreateSurface(buff, surfaceIdNew, handle)); |
|
1926 |
|
1927 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceIdNew, infoBufNew)); |
|
1928 |
|
1929 //Test that the attribute is returned correctly |
|
1930 err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 0, offsetToFirstBufferNew); |
|
1931 err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 1, offsetBetweenBuffersNew); |
|
1932 offsetBetweenBuffersNew-=offsetToFirstBufferNew; |
|
1933 |
|
1934 TEST(offsetBetweenBuffersNew == attributesNew.iOffsetBetweenBuffers); |
|
1935 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
1936 |
|
1937 handle.Close(); |
|
1938 handleNew.Close(); |
|
1939 // Close the surface manager |
|
1940 iSurfaceManager.Close(); |
|
1941 } |
|
1942 |
|
1943 void CTSurfaceManager::TestCreateSurfaceExisitingChunk3L() |
|
1944 { |
|
1945 // Create a surface in a new shared chunk |
|
1946 INFO_PRINTF1(_L("Creating a Surface with identical creation attributes in an exisitng shared chunk which already contains a surface\r\n")); |
|
1947 // Open the surface manager |
|
1948 User::LeaveIfError(iSurfaceManager.Open()); |
|
1949 |
|
1950 // Setup attributes |
|
1951 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
1952 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
1953 |
|
1954 attributes.iSize = TSize(480,16); |
|
1955 attributes.iBuffers = 2; // number of buffers in the surface |
|
1956 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
1957 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
1958 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
1959 attributes.iAlignment = 4; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
1960 |
|
1961 RSurfaceManager::THintPair hints[2]; |
|
1962 attributes.iHintCount=2; |
|
1963 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
1964 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
1965 attributes.iSurfaceHints = hints; |
|
1966 |
|
1967 attributes.iContiguous = ETrue; |
|
1968 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
1969 attributes.iOffsetBetweenBuffers = 0; |
|
1970 attributes.iMappable = ETrue; |
|
1971 |
|
1972 // Test create surface doesn't return an error |
|
1973 TSurfaceId surfaceId; |
|
1974 |
|
1975 // Test create surface doesn't return an error |
|
1976 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
1977 |
|
1978 //store all the attributes |
|
1979 RSurfaceManager::TInfoBuf infoBuf; |
|
1980 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
1981 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
1982 |
|
1983 RChunk handle; |
|
1984 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
1985 |
|
1986 // Test create surface doesn't return an error |
|
1987 TSurfaceId surfaceIdNew; |
|
1988 // Test create surface doesn't return an error |
|
1989 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdNew, handle)); |
|
1990 |
|
1991 //Store all the attributes |
|
1992 RSurfaceManager::TInfoBuf infoBufNew; |
|
1993 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceIdNew, infoBufNew)); |
|
1994 RSurfaceManager::TSurfaceInfoV01& infoNew = infoBufNew(); |
|
1995 |
|
1996 //Map the new surface in the current process |
|
1997 RChunk handleNew; |
|
1998 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceIdNew,handleNew)); |
|
1999 |
|
2000 //test two sets of attributes are identical for two surfaces |
|
2001 TEST(info.iSize.iHeight == infoNew.iSize.iHeight); |
|
2002 TEST(info.iSize.iWidth == infoNew.iSize.iWidth); |
|
2003 TEST(info.iBuffers == infoNew.iBuffers); |
|
2004 TEST(info.iPixelFormat == infoNew.iPixelFormat); |
|
2005 TEST(info.iStride == infoNew.iStride); |
|
2006 |
|
2007 |
|
2008 TInt offsetToFirstBuffer, offsetToFirstBufferNew; |
|
2009 TInt offsetBetweenBuffers, offsetBetweenBuffersNew; |
|
2010 TInt err=iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer); |
|
2011 err=iSurfaceManager.GetBufferOffset(surfaceId, 1, offsetBetweenBuffers); |
|
2012 offsetBetweenBuffers-=offsetToFirstBuffer; |
|
2013 |
|
2014 err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 0, offsetToFirstBufferNew); |
|
2015 err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 1, offsetBetweenBuffersNew); |
|
2016 offsetBetweenBuffersNew-=offsetToFirstBufferNew; |
|
2017 |
|
2018 |
|
2019 TEST(offsetToFirstBuffer == offsetToFirstBufferNew); |
|
2020 TEST(offsetBetweenBuffers == offsetBetweenBuffersNew); |
|
2021 |
|
2022 //cache attribute is not valid on emulator |
|
2023 #ifndef __WINS__ |
|
2024 TEST(info.iCacheAttrib == infoNew.iCacheAttrib); |
|
2025 #else |
|
2026 INFO_PRINTF1(_L("Cache attribute test is not valid on emulator\n")); |
|
2027 #endif |
|
2028 |
|
2029 //contiguous attribute is not valid on emulator |
|
2030 #ifndef __WINS__ |
|
2031 TEST(info.iContiguous == infoNew.iContiguous); |
|
2032 #else |
|
2033 INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n")); |
|
2034 #endif |
|
2035 |
|
2036 //check that two surfaceIds are different |
|
2037 TEST(surfaceId != surfaceIdNew); |
|
2038 |
|
2039 //check the iOffsetBetweenBuffers return by SurfaceInfo() is valid |
|
2040 TEST((offsetBetweenBuffers >= attributes.iSize.iHeight*attributes.iStride) && (offsetBetweenBuffers % attributes.iAlignment ==0)); |
|
2041 TEST((offsetBetweenBuffersNew >= attributes.iSize.iHeight*attributes.iStride) && (offsetBetweenBuffersNew % attributes.iAlignment ==0)); |
|
2042 |
|
2043 //check the two handles are different but refer to the same shared chunk |
|
2044 TEST(handle.Handle() != handleNew.Handle()); |
|
2045 TEST(handle.Base() == handleNew.Base()); |
|
2046 |
|
2047 // Get the adress of this chunk of memory |
|
2048 TUint8* surfaceAddNew = handleNew.Base(); |
|
2049 TUint8* bufferAddNew = surfaceAddNew + attributes.iOffsetToFirstBuffer; |
|
2050 |
|
2051 // Write to the second surface's buffer, and test the value is written |
|
2052 *bufferAddNew = 20; |
|
2053 TInt temp = *bufferAddNew; |
|
2054 TEST(temp == 20); |
|
2055 |
|
2056 //Read the value from the address of the pixel data for this first surface |
|
2057 TUint8* surfaceAdd = handle.Base(); |
|
2058 TUint8* bufferAdd = surfaceAdd + attributes.iOffsetToFirstBuffer; |
|
2059 TEST(*bufferAdd == 20); |
|
2060 |
|
2061 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2062 // As the surface is not created properly, closing returns KErrArgument |
|
2063 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
2064 |
|
2065 handle.Close(); |
|
2066 handleNew.Close(); |
|
2067 // Close the surface manager |
|
2068 iSurfaceManager.Close(); |
|
2069 } |
|
2070 |
|
2071 void CTSurfaceManager::TestCreateSurfaceExisitingChunk4L() |
|
2072 { |
|
2073 // Create a surface in a new shared chunk |
|
2074 INFO_PRINTF1(_L("Creating a Surface with rotated orientation in an exisitng shared chunk which already contains a surface\r\n")); |
|
2075 // Open the surface manager |
|
2076 User::LeaveIfError(iSurfaceManager.Open()); |
|
2077 |
|
2078 // Setup attributes |
|
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; |
|
2085 attributes.iStride = 1200; // Number of bytes between start of one line and start of next |
|
2086 attributes.iOffsetToFirstBuffer = 10; // way of reserving space before the surface pixel data |
|
2087 attributes.iAlignment = 4; // 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 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2092 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
2093 attributes.iSurfaceHints = hints; |
|
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 == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2105 |
|
2106 //store all the attributes |
|
2107 RSurfaceManager::TInfoBuf infoBuf; |
|
2108 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
2109 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
2110 TInt offsetToFirstBuffer, offsetBetweenBuffers; |
|
2111 TInt err=iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer); |
|
2112 err=iSurfaceManager.GetBufferOffset(surfaceId, 1, offsetBetweenBuffers); |
|
2113 offsetBetweenBuffers-=offsetToFirstBuffer; |
|
2114 |
|
2115 //Map the surface in the current process to get the first chunk handle |
|
2116 RChunk handle; |
|
2117 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
2118 |
|
2119 |
|
2120 // Test create surface doesn't return an error |
|
2121 TSurfaceId surfaceIdNew; |
|
2122 |
|
2123 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
2124 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
2125 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = buff(); |
|
2126 |
|
2127 attributesNew.iSize = TSize(16,480); |
|
2128 attributesNew.iBuffers = 2; // number of buffers in the surface |
|
2129 attributesNew.iPixelFormat =EUidPixelFormatYUV_422Reversed; |
|
2130 attributesNew.iStride = 34; // Number of bytes between start of one line and start of next |
|
2131 attributesNew.iOffsetToFirstBuffer = offsetToFirstBuffer; // way of reserving space before the surface pixel data |
|
2132 |
|
2133 RSurfaceManager::THintPair hint; |
|
2134 attributes.iHintCount=1; |
|
2135 hint.Set(TUid::Uid(0x124578),20,ETrue); |
|
2136 attributesNew.iSurfaceHints = &hint; |
|
2137 |
|
2138 attributesNew.iAlignment = 4; |
|
2139 attributesNew.iOffsetBetweenBuffers = offsetBetweenBuffers; |
|
2140 attributesNew.iMappable = ETrue; |
|
2141 |
|
2142 // Test create surface doesn't return an error |
|
2143 TEST(KErrNone == iSurfaceManager.CreateSurface(buff, surfaceIdNew, handle)); |
|
2144 |
|
2145 //Store all the attributes |
|
2146 RSurfaceManager::TInfoBuf infoBufNew; |
|
2147 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceIdNew, infoBufNew)); |
|
2148 RSurfaceManager::TSurfaceInfoV01& infoNew = infoBufNew(); |
|
2149 TInt offsetToFirstBufferNew, offsetBetweenBuffersNew; |
|
2150 err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 0, offsetToFirstBufferNew); |
|
2151 err=iSurfaceManager.GetBufferOffset(surfaceIdNew, 1, offsetBetweenBuffersNew); |
|
2152 offsetBetweenBuffersNew-=offsetToFirstBufferNew; |
|
2153 |
|
2154 //Map the new surface in the current process |
|
2155 RChunk handleNew; |
|
2156 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceIdNew,handleNew)); |
|
2157 |
|
2158 //cache attribute is not valid on emulator |
|
2159 #ifndef __WINS__ |
|
2160 TEST(info.iCacheAttrib == infoNew.iCacheAttrib); |
|
2161 #else |
|
2162 INFO_PRINTF1(_L("Cache attribute test is not valid on emulator\n")); |
|
2163 #endif |
|
2164 |
|
2165 //contiguous attribute is not valid on emulator |
|
2166 #ifndef __WINS__ |
|
2167 TEST(info.iContiguous == infoNew.iContiguous); |
|
2168 #else |
|
2169 INFO_PRINTF1(_L("Contiguous attribute test is not valid on emulator\n")); |
|
2170 #endif |
|
2171 |
|
2172 //check that two surfaceIds are different |
|
2173 TEST(surfaceId != surfaceIdNew); |
|
2174 |
|
2175 TEST(info.iSize.iHeight == infoNew.iSize.iWidth); |
|
2176 TEST(info.iSize.iWidth == infoNew.iSize.iHeight); |
|
2177 TEST(offsetToFirstBuffer == offsetToFirstBufferNew); |
|
2178 INFO_PRINTF2(_L("The offset to first Buffer is %d\n"),offsetToFirstBuffer); |
|
2179 TEST(offsetBetweenBuffers == offsetBetweenBuffersNew); |
|
2180 INFO_PRINTF2(_L("The offset between Buffers is %d \n"),offsetBetweenBuffers); |
|
2181 |
|
2182 TEST(info.iStride != infoNew.iStride); |
|
2183 |
|
2184 //check the iOffsetBetweenBuffers returned by SurfaceInfo() is valid |
|
2185 TEST((offsetBetweenBuffers >= attributes.iSize.iHeight*attributes.iStride) && (offsetBetweenBuffers % attributes.iAlignment ==0)); |
|
2186 TEST((offsetBetweenBuffersNew >= attributesNew.iSize.iHeight*attributesNew.iStride) && (offsetBetweenBuffersNew % attributesNew.iAlignment ==0)); |
|
2187 |
|
2188 //check the two handles are different but refer to the same shared chunk |
|
2189 TEST(handle.Handle() != handleNew.Handle()); |
|
2190 TEST(handle.Base() == handleNew.Base()); |
|
2191 |
|
2192 // Get the adress of this chunk of memory |
|
2193 TUint8* surfaceAddNew = handleNew.Base(); |
|
2194 TUint8* bufferAddNew = surfaceAddNew + offsetToFirstBufferNew; |
|
2195 |
|
2196 // Write to the second surface's buffer, and test the value is written |
|
2197 *bufferAddNew = 20; |
|
2198 TInt temp = *bufferAddNew; |
|
2199 TEST(temp == 20); |
|
2200 |
|
2201 //Read the value from the address of the pixel data for this first surface |
|
2202 TUint8* surfaceAdd = handle.Base(); |
|
2203 TUint8* bufferAdd = surfaceAdd + offsetToFirstBuffer; |
|
2204 TEST(*bufferAdd == 20); |
|
2205 |
|
2206 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2207 // As the surface is not created properly, closing returns KErrArgument |
|
2208 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
2209 |
|
2210 handle.Close(); |
|
2211 handleNew.Close(); |
|
2212 // Close the surface manager |
|
2213 iSurfaceManager.Close(); |
|
2214 } |
|
2215 |
|
2216 void CTSurfaceManager::SetupAttributesL(RSurfaceManager::TSurfaceCreationAttributes& attributesParams) |
|
2217 { |
|
2218 attributesParams.iSize = TSize(100,100); |
|
2219 attributesParams.iBuffers = 1; // number of buffers in the surface |
|
2220 attributesParams.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
2221 attributesParams.iStride = 400; // Number of bytes between start of one line and start of next |
|
2222 attributesParams.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2223 attributesParams.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
2224 attributesParams.iContiguous=ETrue; |
|
2225 attributesParams.iCacheAttrib = RSurfaceManager::ECached; // Cache attributes |
|
2226 attributesParams.iOffsetBetweenBuffers = 0; |
|
2227 |
|
2228 //Set iSurfaceHints.iHints[0] |
|
2229 ReAllocHintsArrayL(1); |
|
2230 attributesParams.iSurfaceHints = iHintsArray; |
|
2231 attributesParams.iSurfaceHints[0].Set(TUid::Uid(0x124578), 20, ETrue); |
|
2232 attributesParams.iHintCount = 1; |
|
2233 attributesParams.iMappable = ETrue; |
|
2234 } |
|
2235 void CTSurfaceManager::TestCreateSurfaceAssociatedWithHintPairsL() |
|
2236 { |
|
2237 // Open the surface manager |
|
2238 User::LeaveIfError(iSurfaceManager.Open()); |
|
2239 |
|
2240 // Setup attributes |
|
2241 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2242 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2243 |
|
2244 SetupAttributesL(attributes); |
|
2245 TInt maxHintsPerSurface; |
|
2246 iSurfaceManager.GetSurfaceManagerAttrib(RSurfaceManager::EMaxNumberOfHints,maxHintsPerSurface); |
|
2247 |
|
2248 // Create a surface in a new shared chunk |
|
2249 INFO_PRINTF2(_L("Creating a Surface associated with 0 to a maximum of %i hint pairs\r\n"),maxHintsPerSurface); |
|
2250 |
|
2251 ReAllocHintsArrayL(maxHintsPerSurface); |
|
2252 iHintsArray[0].Set(TUid::Uid(0x124578),20,ETrue); |
|
2253 TInt i; |
|
2254 for (i=1;i<maxHintsPerSurface;++i) |
|
2255 { |
|
2256 iHintsArray[i].Set(TUid::Uid(0x124512+i),20,ETrue); |
|
2257 } |
|
2258 attributes.iSurfaceHints = iHintsArray; |
|
2259 |
|
2260 |
|
2261 for (attributes.iHintCount=1;attributes.iHintCount<=maxHintsPerSurface;++attributes.iHintCount) |
|
2262 { |
|
2263 TSurfaceId surfaceId; |
|
2264 // Test create surface doesn't return an error |
|
2265 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2266 // Get the hint values and check them |
|
2267 for (i=1;i<=attributes.iHintCount;++i) |
|
2268 { |
|
2269 RSurfaceManager::THintPair hint; |
|
2270 hint.iKey=iHintsArray[i-1].iKey; |
|
2271 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hint)); |
|
2272 TEST(hint.iValue==iHintsArray[i-1].iValue); |
|
2273 TEST(hint.iMutable==iHintsArray[i-1].iMutable); |
|
2274 } |
|
2275 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2276 } |
|
2277 iSurfaceManager.Close(); |
|
2278 } |
|
2279 |
|
2280 void CTSurfaceManager::CheckAlignment(TSurfaceId& aId, TInt aAlign, RSurfaceManager::TCacheAttribute aCached) |
|
2281 { |
|
2282 RSurfaceManager::TInfoBuf infoBuf; |
|
2283 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
2284 |
|
2285 //cached surfaces are aligned to minimum of cache line which is 32 |
|
2286 if (aCached == RSurfaceManager::ECached && aAlign < 32) |
|
2287 { |
|
2288 // check the aligment is at least 32 for cached surfaces. |
|
2289 aAlign = 32; |
|
2290 } |
|
2291 |
|
2292 TInt mask = (aAlign == RSurfaceManager::EPageAligned) ? 0xFFF : aAlign - 1; |
|
2293 |
|
2294 TInt offsetToFirstBuffer, offsetBetweenBuffers; |
|
2295 TInt err=iSurfaceManager.GetBufferOffset(aId, 0, offsetToFirstBuffer); |
|
2296 err=iSurfaceManager.GetBufferOffset(aId, 1, offsetBetweenBuffers); |
|
2297 offsetBetweenBuffers-=offsetToFirstBuffer; |
|
2298 |
|
2299 TEST((offsetToFirstBuffer & mask) == 0); |
|
2300 TEST((offsetBetweenBuffers & mask) == 0); |
|
2301 |
|
2302 } |
|
2303 |
|
2304 |
|
2305 void CTSurfaceManager::TestCreateSurfaceAlignmentsMemoryTypeL() |
|
2306 { |
|
2307 INFO_PRINTF1(_L("Creating a Surface with all types of alignment in cached and none cached memory\r\n")); |
|
2308 // Open the surface manager |
|
2309 User::LeaveIfError(iSurfaceManager.Open()); |
|
2310 |
|
2311 // Setup attributes |
|
2312 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2313 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2314 |
|
2315 attributes.iSize = TSize(61,47); |
|
2316 attributes.iBuffers = 2; // number of buffers in the surface |
|
2317 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
2318 attributes.iStride = 61; // Number of bytes between start of one line and start of next |
|
2319 attributes.iOffsetToFirstBuffer = 1; // way of reserving space before the surface pixel data |
|
2320 attributes.iContiguous=EFalse; |
|
2321 attributes.iOffsetBetweenBuffers = 0; |
|
2322 attributes.iMappable = ETrue; |
|
2323 |
|
2324 TInt x = 0; |
|
2325 TSurfaceId sid; |
|
2326 for (x = 0; x < 7; x++) |
|
2327 { |
|
2328 attributes.iAlignment = 1 << x; |
|
2329 |
|
2330 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2331 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, sid)); |
|
2332 CheckAlignment(sid, attributes.iAlignment, attributes.iCacheAttrib); |
|
2333 TEST(KErrNone == iSurfaceManager.CloseSurface(sid)); |
|
2334 |
|
2335 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
2336 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, sid)); |
|
2337 CheckAlignment(sid, attributes.iAlignment, attributes.iCacheAttrib); |
|
2338 TEST(KErrNone == iSurfaceManager.CloseSurface(sid)); |
|
2339 } |
|
2340 |
|
2341 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
2342 |
|
2343 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2344 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, sid)); |
|
2345 CheckAlignment(sid, attributes.iAlignment, attributes.iCacheAttrib); |
|
2346 TEST(KErrNone == iSurfaceManager.CloseSurface(sid)); |
|
2347 |
|
2348 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
2349 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, sid)); |
|
2350 CheckAlignment(sid, attributes.iAlignment, attributes.iCacheAttrib); |
|
2351 TEST(KErrNone == iSurfaceManager.CloseSurface(sid)); |
|
2352 |
|
2353 // Close the surface manager |
|
2354 iSurfaceManager.Close(); |
|
2355 } |
|
2356 |
|
2357 |
|
2358 |
|
2359 |
|
2360 void CTSurfaceManager::TestOpenSurfaceL() |
|
2361 { |
|
2362 INFO_PRINTF1(_L("Test opening a surface\r\n")); |
|
2363 // Open the surface manager |
|
2364 User::LeaveIfError(iSurfaceManager.Open()); |
|
2365 |
|
2366 // Setup attributes |
|
2367 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2368 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2369 |
|
2370 SetupAttributesL(attributes); |
|
2371 |
|
2372 // Create surface |
|
2373 TSurfaceId surfaceId; |
|
2374 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2375 // Test OpenSurface returns KErrNone |
|
2376 TEST(KErrNone == iSurfaceManager.OpenSurface(surfaceId)); |
|
2377 |
|
2378 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2379 iSurfaceManager.Close(); |
|
2380 } |
|
2381 |
|
2382 void CTSurfaceManager::TestClosingSurfaceDecrementsReferenceCountL() |
|
2383 { |
|
2384 INFO_PRINTF1(_L("CloseSurface (correctly) decrements reference count\r\n")); |
|
2385 User::LeaveIfError(iSurfaceManager.Open()); |
|
2386 |
|
2387 // Store the attributes used to create the Surface |
|
2388 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2389 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2390 |
|
2391 SetupAttributesL(attributes); |
|
2392 |
|
2393 // Create a surface - sets reference count to 1 |
|
2394 TSurfaceId surfaceId; |
|
2395 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2396 |
|
2397 // Call SurfaceInfo - doesn't alter reference count |
|
2398 RSurfaceManager::TInfoBuf infoBuf; |
|
2399 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
2400 |
|
2401 // Check that CloseSurface returns KErrNone |
|
2402 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2403 |
|
2404 // Check that OpenSurface fails (since ref count == 0) |
|
2405 TEST(KErrArgument == iSurfaceManager.OpenSurface(surfaceId)); |
|
2406 |
|
2407 // Close the manager |
|
2408 iSurfaceManager.Close(); |
|
2409 } |
|
2410 |
|
2411 void CTSurfaceManager::TestCreateSurfaceSetReferenceCountL() |
|
2412 { |
|
2413 // Create a surface in a new shared chunk |
|
2414 INFO_PRINTF1(_L("the new CreateSurface() API create the surface and set its reference count to one \r\n")); |
|
2415 // Open the surface manager |
|
2416 User::LeaveIfError(iSurfaceManager.Open()); |
|
2417 |
|
2418 // Setup attributes |
|
2419 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2420 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2421 |
|
2422 attributes.iSize = TSize(480,16); |
|
2423 attributes.iBuffers = 2; // number of buffers in the surface |
|
2424 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
2425 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
2426 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2427 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8,16,32,64 byte aligned or EPageAligned |
|
2428 |
|
2429 RSurfaceManager::THintPair hints[2]; |
|
2430 attributes.iHintCount=2; |
|
2431 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2432 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
2433 attributes.iSurfaceHints = hints; |
|
2434 |
|
2435 attributes.iContiguous = ETrue; |
|
2436 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2437 attributes.iOffsetBetweenBuffers = 0; |
|
2438 attributes.iMappable = ETrue; |
|
2439 |
|
2440 // Test create surface doesn't return an error |
|
2441 TSurfaceId surfaceId; |
|
2442 |
|
2443 // Test create surface doesn't return an error |
|
2444 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2445 |
|
2446 //Map the new surface |
|
2447 RChunk handle; |
|
2448 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
2449 |
|
2450 |
|
2451 // Test create surface doesn't return an error |
|
2452 TSurfaceId surfaceIdNew; |
|
2453 |
|
2454 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
2455 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
2456 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = buff(); |
|
2457 |
|
2458 attributesNew.iSize = TSize(16,480); |
|
2459 attributesNew.iBuffers = 2; // number of buffers in the surface |
|
2460 attributesNew.iPixelFormat =EUidPixelFormatYUV_422Reversed; |
|
2461 attributesNew.iStride = 34; // Number of bytes between start of one line and start of next |
|
2462 attributesNew.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2463 |
|
2464 RSurfaceManager::THintPair hint; // one hint pairs specified |
|
2465 attributes.iHintCount=1; |
|
2466 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
2467 attributes.iSurfaceHints = &hint; |
|
2468 |
|
2469 attributesNew.iAlignment = RSurfaceManager::EPageAligned; |
|
2470 attributesNew.iOffsetBetweenBuffers = 0; |
|
2471 attributesNew.iMappable = ETrue; |
|
2472 |
|
2473 // Test create surface doesn't return an error |
|
2474 TEST(KErrNone == iSurfaceManager.CreateSurface(buff, surfaceIdNew, handle)); |
|
2475 |
|
2476 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2477 |
|
2478 // As the surface is not created properly, closing returns KErrArgument |
|
2479 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
2480 |
|
2481 TEST(KErrArgument == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
2482 |
|
2483 handle.Close(); |
|
2484 // Close the surface manager |
|
2485 iSurfaceManager.Close(); |
|
2486 } |
|
2487 |
|
2488 |
|
2489 void CTSurfaceManager::TestWriteToTwoBuffersL() |
|
2490 { |
|
2491 INFO_PRINTF1(_L("Writing to two buffers\r\n")); |
|
2492 // Open the surface manager |
|
2493 |
|
2494 User::LeaveIfError(iSurfaceManager.Open()); |
|
2495 |
|
2496 // Setup attributes, setting iBuffers to 2 |
|
2497 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2498 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2499 attributes.iSize = TSize(12,80); // w > 0, h > 0 |
|
2500 attributes.iBuffers = 2; // > 0, <= 4 |
|
2501 attributes.iPixelFormat = EUidPixelFormatARGB_1555; |
|
2502 attributes.iStride = 25; // > 0, > width * bpp |
|
2503 attributes.iOffsetToFirstBuffer = 20; // > 0, divisible by alignment |
|
2504 attributes.iAlignment = 4; // 1 || 2 || 4 || 8 |
|
2505 |
|
2506 RSurfaceManager::THintPair hints[2]; // one hint pairs specified |
|
2507 attributes.iHintCount=2; |
|
2508 hints[0].Set(TUid::Uid(0x124578), 50, ETrue); |
|
2509 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
2510 attributes.iSurfaceHints = hints; |
|
2511 |
|
2512 attributes.iContiguous = ETrue; |
|
2513 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2514 attributes.iOffsetBetweenBuffers = 0; |
|
2515 attributes.iMappable = ETrue; |
|
2516 |
|
2517 // Create the surface |
|
2518 TSurfaceId surfaceId; |
|
2519 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2520 |
|
2521 // Map the surface to a chunk of memory |
|
2522 RChunk handle; |
|
2523 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId, handle)); |
|
2524 |
|
2525 // Get the adress of this chunk of memory |
|
2526 TUint8* surfaceAdd = handle.Base(); |
|
2527 TUint8* bufferAdd = surfaceAdd + attributes.iOffsetToFirstBuffer; |
|
2528 |
|
2529 // Write to the first buffer, and test the value is written |
|
2530 *bufferAdd = 20; |
|
2531 TInt temp = *bufferAdd; |
|
2532 TEST(temp == 20); |
|
2533 |
|
2534 // Write to the second buffer and test the value is written |
|
2535 RSurfaceManager::TInfoBuf infoBuf; |
|
2536 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
2537 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
2538 TInt offsetToFirstBuffer, offsetBetweenBuffers; |
|
2539 TInt err=iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer); |
|
2540 err=iSurfaceManager.GetBufferOffset(surfaceId, 1, offsetBetweenBuffers); |
|
2541 offsetBetweenBuffers-=offsetToFirstBuffer; |
|
2542 bufferAdd += offsetBetweenBuffers; |
|
2543 *bufferAdd = 220; |
|
2544 *(bufferAdd + 1) = 14; |
|
2545 temp = *bufferAdd; |
|
2546 TEST(temp == 220); |
|
2547 temp = *(bufferAdd + 1); |
|
2548 TEST(temp == 14); |
|
2549 |
|
2550 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2551 handle.Close(); |
|
2552 // Close the surface manager |
|
2553 iSurfaceManager.Close(); |
|
2554 } |
|
2555 |
|
2556 void CTSurfaceManager::TestQuerySurfaceInfoWithoutMappingL() |
|
2557 { |
|
2558 INFO_PRINTF1(_L("Getting SurfaceInfo of a Surface without mapping it\r\n")); |
|
2559 // Open the surface manager |
|
2560 |
|
2561 User::LeaveIfError(iSurfaceManager.Open()); |
|
2562 |
|
2563 // Store the attributes used to create the Surface |
|
2564 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2565 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2566 |
|
2567 SetupAttributesL(attributes); |
|
2568 |
|
2569 // Create a surface |
|
2570 TSurfaceId surfaceId; |
|
2571 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2572 |
|
2573 |
|
2574 // Call SurfaceInfo without mapping the surface |
|
2575 RSurfaceManager::TInfoBuf infoBuf; |
|
2576 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
2577 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
2578 |
|
2579 //Check if the values are equal to the stored ones |
|
2580 TEST(info.iSize == attributes.iSize); |
|
2581 TEST(info.iBuffers == attributes.iBuffers); |
|
2582 TEST(info.iPixelFormat == attributes.iPixelFormat); |
|
2583 TEST(info.iStride == attributes.iStride); |
|
2584 TInt offsetToFirstBuffer; |
|
2585 TInt err=iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer); |
|
2586 TEST(offsetToFirstBuffer == attributes.iOffsetToFirstBuffer); |
|
2587 TEST(info.iContiguous == attributes.iContiguous); |
|
2588 TEST(info.iCacheAttrib ==attributes.iCacheAttrib); |
|
2589 |
|
2590 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2591 // Close the surface manager |
|
2592 iSurfaceManager.Close(); |
|
2593 } |
|
2594 |
|
2595 void CTSurfaceManager::TestQuerySurfaceInfoAfterMappingL() |
|
2596 { |
|
2597 INFO_PRINTF1(_L("Getting SurfaceInfo of a Surface after mapping it\r\n")); |
|
2598 // Open the surface manager |
|
2599 |
|
2600 User::LeaveIfError(iSurfaceManager.Open()); |
|
2601 |
|
2602 // Store the attributes used to create the Surface |
|
2603 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2604 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2605 |
|
2606 SetupAttributesL(attributes); |
|
2607 |
|
2608 // Create a surface |
|
2609 TSurfaceId surfaceId; |
|
2610 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2611 |
|
2612 // Map the surface |
|
2613 RChunk handle; |
|
2614 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId, handle)); |
|
2615 |
|
2616 // Call SurfaceInfo to get the attributes of the Surface |
|
2617 RSurfaceManager::TInfoBuf infoBuf; |
|
2618 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
2619 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
2620 |
|
2621 // Test that the attributes are returned correctly |
|
2622 TEST(info.iSize == attributes.iSize); |
|
2623 TEST(info.iBuffers == attributes.iBuffers); |
|
2624 TEST(info.iPixelFormat == attributes.iPixelFormat); |
|
2625 TEST(info.iStride == attributes.iStride); |
|
2626 TInt offsetToFirstBuffer; |
|
2627 TInt err=iSurfaceManager.GetBufferOffset(surfaceId, 0, offsetToFirstBuffer); |
|
2628 TEST(offsetToFirstBuffer == attributes.iOffsetToFirstBuffer); |
|
2629 TEST(info.iContiguous == attributes.iContiguous); |
|
2630 TEST(info.iCacheAttrib ==attributes.iCacheAttrib); |
|
2631 |
|
2632 // Close the surface manager |
|
2633 handle.Close(); |
|
2634 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2635 |
|
2636 iSurfaceManager.Close(); |
|
2637 } |
|
2638 |
|
2639 void CTSurfaceManager::TestMapSurfaceL() |
|
2640 { |
|
2641 INFO_PRINTF1(_L("Basic test of the MapSurface() method\r\n")); |
|
2642 // Open the surface manager |
|
2643 User::LeaveIfError(iSurfaceManager.Open()); |
|
2644 |
|
2645 // Store the attributes used to create the Surface |
|
2646 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2647 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2648 |
|
2649 SetupAttributesL(attributes); |
|
2650 |
|
2651 // Create a surface |
|
2652 TSurfaceId surfaceId; |
|
2653 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2654 // Map the surface |
|
2655 RChunk handle; |
|
2656 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId, handle)); |
|
2657 handle.Close(); |
|
2658 |
|
2659 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2660 iSurfaceManager.Close(); |
|
2661 } |
|
2662 |
|
2663 void CTSurfaceManager::TestClosingSurfaceL() |
|
2664 { |
|
2665 INFO_PRINTF1(_L("Closing a surface which cant be open again\r\n")); |
|
2666 User::LeaveIfError(iSurfaceManager.Open()); |
|
2667 |
|
2668 // Store the attributes used to create the Surface |
|
2669 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2670 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2671 |
|
2672 SetupAttributesL(attributes); |
|
2673 |
|
2674 // Create a surface |
|
2675 TSurfaceId surfaceId; |
|
2676 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2677 // Close the surface |
|
2678 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2679 |
|
2680 // Try to open the surface using the surface id - should fail |
|
2681 TEST(KErrArgument == iSurfaceManager.OpenSurface(surfaceId)); |
|
2682 |
|
2683 // Close the manager |
|
2684 iSurfaceManager.Close(); |
|
2685 } |
|
2686 |
|
2687 void CTSurfaceManager::TestSharedChunkClosedL() |
|
2688 { |
|
2689 // Create a surface in a new shared chunk |
|
2690 INFO_PRINTF1(_L("Checking the chunk gets deleted after the surface and handle are both closed\r\n")); |
|
2691 // Open the surface manager |
|
2692 User::LeaveIfError(iSurfaceManager.Open()); |
|
2693 // Setup attributes |
|
2694 |
|
2695 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2696 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2697 |
|
2698 SetupAttributesL(attributes); |
|
2699 |
|
2700 // Test create surface doesn't return an error |
|
2701 TSurfaceId surfaceId; |
|
2702 |
|
2703 // Test create surface doesn't return an error |
|
2704 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2705 RChunk handle; |
|
2706 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
2707 |
|
2708 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2709 |
|
2710 // Get the adress of this chunk of memory |
|
2711 TUint8* surfaceAdd = handle.Base(); |
|
2712 INFO_PRINTF2(_L("the base address of the chunk is : %x\r\n"),surfaceAdd); |
|
2713 handle.Close(); |
|
2714 |
|
2715 // Close the surface manager |
|
2716 iSurfaceManager.Close(); |
|
2717 } |
|
2718 |
|
2719 void CTSurfaceManager::TestMultipleChannelsL() |
|
2720 { |
|
2721 INFO_PRINTF1(_L("Testing multiple channels to surface manager LDD in one process and accessing them individually\r\n")); |
|
2722 // Open the surface manager |
|
2723 User::LeaveIfError(iSurfaceManager.Open()); |
|
2724 // Store the attributes used to create the Surface |
|
2725 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2726 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2727 |
|
2728 SetupAttributesL(attributes); |
|
2729 |
|
2730 // Create a surface |
|
2731 TSurfaceId surfaceId; |
|
2732 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2733 |
|
2734 RSurfaceManager surfaceManagerTwo; |
|
2735 User::LeaveIfError(surfaceManagerTwo.Open()); |
|
2736 |
|
2737 TEST(KErrNone == surfaceManagerTwo.OpenSurface(surfaceId)); |
|
2738 iSurfaceManager.Close(); |
|
2739 |
|
2740 // Call SurfaceInfo to get the attributes of the Surface |
|
2741 RSurfaceManager::TInfoBuf infoBuf; |
|
2742 // surfaceId is still accessible as surfaceManagerTwo is open |
|
2743 TEST(KErrNone == surfaceManagerTwo.SurfaceInfo(surfaceId,infoBuf)); |
|
2744 |
|
2745 TEST(KErrNone == surfaceManagerTwo.CloseSurface(surfaceId)); |
|
2746 TEST(KErrNone == surfaceManagerTwo.CloseSurface(surfaceId)); |
|
2747 TEST(KErrArgument == surfaceManagerTwo.SurfaceInfo(surfaceId,infoBuf)); |
|
2748 |
|
2749 // Create a surface |
|
2750 TSurfaceId surfaceIdNew; |
|
2751 TEST(KErrNone == surfaceManagerTwo.CreateSurface(buf, surfaceIdNew)); |
|
2752 TEST(KErrNone == surfaceManagerTwo.CloseSurface(surfaceIdNew)); |
|
2753 |
|
2754 surfaceManagerTwo.Close(); |
|
2755 } |
|
2756 |
|
2757 |
|
2758 void CTSurfaceManager::TestClosingChannelsL() |
|
2759 { |
|
2760 INFO_PRINTF1(_L("Testing the behaviour of closing driver channels\r\n")); |
|
2761 // Open the surface manager |
|
2762 User::LeaveIfError(iSurfaceManager.Open()); |
|
2763 // Store the attributes used to create the Surface |
|
2764 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2765 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2766 |
|
2767 SetupAttributesL(attributes); |
|
2768 |
|
2769 // Create a surface |
|
2770 TSurfaceId surfaceId; |
|
2771 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2772 |
|
2773 RSurfaceManager surfaceManagerTwo; |
|
2774 User::LeaveIfError(surfaceManagerTwo.Open()); |
|
2775 |
|
2776 // Create a surface |
|
2777 TSurfaceId surfaceIdNew; |
|
2778 TEST(KErrNone == surfaceManagerTwo.CreateSurface(buf, surfaceIdNew)); |
|
2779 |
|
2780 TEST(KErrNone == iSurfaceManager.OpenSurface(surfaceId)); |
|
2781 TEST(KErrNone == surfaceManagerTwo.OpenSurface(surfaceId)); |
|
2782 |
|
2783 TEST(KErrNone == iSurfaceManager.OpenSurface(surfaceIdNew)); |
|
2784 TEST(KErrNone == surfaceManagerTwo.OpenSurface(surfaceIdNew)); |
|
2785 |
|
2786 iSurfaceManager.Close(); |
|
2787 surfaceManagerTwo.Close(); |
|
2788 |
|
2789 User::LeaveIfError(iSurfaceManager.Open()); |
|
2790 // Call SurfaceInfo to get the attributes of the Surface |
|
2791 RSurfaceManager::TInfoBuf infoBuf; |
|
2792 TEST(KErrArgument == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
2793 |
|
2794 RSurfaceManager::TInfoBuf infoBufNew; |
|
2795 TEST(KErrArgument == iSurfaceManager.SurfaceInfo(surfaceIdNew, infoBuf)); |
|
2796 |
|
2797 iSurfaceManager.Close(); |
|
2798 } |
|
2799 |
|
2800 |
|
2801 void CTSurfaceManager::TestSurfaceLimitL() |
|
2802 { |
|
2803 INFO_PRINTF1(_L("Testing the number limit of surfaces\r\n")); |
|
2804 // Open the surface manager |
|
2805 User::LeaveIfError(iSurfaceManager.Open()); |
|
2806 |
|
2807 // Store the attributes used to create the Surface |
|
2808 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2809 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2810 |
|
2811 attributes.iSize = TSize(1,1); |
|
2812 attributes.iBuffers = 1; |
|
2813 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; |
|
2814 attributes.iStride = 1; |
|
2815 attributes.iOffsetToFirstBuffer = 1; |
|
2816 attributes.iAlignment = 1; |
|
2817 |
|
2818 RSurfaceManager::THintPair hints[2]; |
|
2819 attributes.iHintCount=2; |
|
2820 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2821 hints[1].Set(TUid::Uid(0x237755), 50, ETrue); |
|
2822 attributes.iSurfaceHints = hints; |
|
2823 |
|
2824 attributes.iContiguous = ETrue; |
|
2825 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2826 attributes.iOffsetBetweenBuffers = 0; |
|
2827 attributes.iMappable = ETrue; |
|
2828 |
|
2829 // Create a surface |
|
2830 RArray<TSurfaceId> surfaceIdArray; |
|
2831 TSurfaceId surfaceId; |
|
2832 TInt count=0; |
|
2833 while (iSurfaceManager.CreateSurface(buf, surfaceId)==KErrNone && count < KCountLimit) |
|
2834 { |
|
2835 count++; |
|
2836 if(count == KCountLimit) |
|
2837 { |
|
2838 INFO_PRINTF1(_L("Test hits the count, it is used to limit the number of surfaces used in this test")); |
|
2839 } |
|
2840 surfaceIdArray.Append(surfaceId); |
|
2841 } |
|
2842 INFO_PRINTF2(_L("the maximum number of surface created %d\r\n"),surfaceIdArray.Count()); |
|
2843 TInt err = iSurfaceManager.CreateSurface(buf, surfaceId); |
|
2844 INFO_PRINTF2(_L("the final error result is %d\r\n"),err); |
|
2845 |
|
2846 for(TInt index = 0; index < surfaceIdArray.Count(); ++index) |
|
2847 { |
|
2848 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdArray[index])); |
|
2849 } |
|
2850 surfaceIdArray.Close(); |
|
2851 iSurfaceManager.Close(); |
|
2852 } |
|
2853 |
|
2854 void CTSurfaceManager::TestSynchronizeCacheL() |
|
2855 { |
|
2856 INFO_PRINTF1(_L("Test the behaviour of SynchronizeCache()\r\n")); |
|
2857 // Open the surface manager |
|
2858 User::LeaveIfError(iSurfaceManager.Open()); |
|
2859 |
|
2860 // Store the attributes used to create the Surface |
|
2861 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2862 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2863 |
|
2864 SetupAttributesL(attributes); |
|
2865 |
|
2866 // Create a surface |
|
2867 TSurfaceId surfaceId; |
|
2868 // A surface made up of multiple pages |
|
2869 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2870 |
|
2871 RChunk handle; |
|
2872 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
2873 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPUWrite)); |
|
2874 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncAfterNonCPUWrite)); |
|
2875 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
2876 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2877 handle.Close(); |
|
2878 |
|
2879 //SynchronizeCache when the memory is not contiguous |
|
2880 attributes.iContiguous = EFalse; |
|
2881 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2882 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
2883 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPUWrite)); |
|
2884 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncAfterNonCPUWrite)); |
|
2885 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
2886 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2887 handle.Close(); |
|
2888 |
|
2889 // A surface made up of 1 page |
|
2890 attributes.iContiguous = ETrue; |
|
2891 attributes.iSize = TSize(100,10); |
|
2892 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2893 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
2894 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPUWrite)); |
|
2895 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncAfterNonCPUWrite)); |
|
2896 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
2897 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2898 handle.Close(); |
|
2899 |
|
2900 // Test SynchronizeCache to a non-cached surface |
|
2901 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
2902 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2903 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPUWrite)); |
|
2904 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncAfterNonCPUWrite)); |
|
2905 TEST(KErrNone == iSurfaceManager.SynchronizeCache(surfaceId,0,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
2906 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2907 handle.Close(); |
|
2908 |
|
2909 iSurfaceManager.Close(); |
|
2910 } |
|
2911 |
|
2912 void CTSurfaceManager::TestSharedChunkClosed2L() |
|
2913 { |
|
2914 INFO_PRINTF1(_L("Test that when two surfaces are created in the same shared chunk, closing one surface and chunk handle will not cause the chunk to be deleted.\r\n")); |
|
2915 // Open the surface manager |
|
2916 User::LeaveIfError(iSurfaceManager.Open()); |
|
2917 |
|
2918 // Store the attributes used to create the Surface |
|
2919 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
2920 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
2921 |
|
2922 attributes.iSize = TSize(480,16); |
|
2923 attributes.iBuffers = 2; |
|
2924 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
2925 attributes.iStride = 1013; |
|
2926 attributes.iOffsetToFirstBuffer = 1; |
|
2927 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
2928 |
|
2929 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
2930 attributes.iHintCount=2; |
|
2931 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
2932 hints[1].Set(TUid::Uid(0x124523), 50, ETrue); |
|
2933 attributes.iSurfaceHints = hints; |
|
2934 |
|
2935 attributes.iContiguous = ETrue; |
|
2936 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
2937 attributes.iOffsetBetweenBuffers = 0; |
|
2938 attributes.iMappable = ETrue; |
|
2939 |
|
2940 // Create a surface |
|
2941 TSurfaceId surfaceId; |
|
2942 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
2943 |
|
2944 RChunk handle; |
|
2945 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
2946 |
|
2947 // Get the adress of this chunk of memory |
|
2948 TUint8* surfaceAdd = handle.Base(); |
|
2949 |
|
2950 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
2951 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
2952 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = buff(); |
|
2953 |
|
2954 attributesNew.iSize = TSize(480,10); |
|
2955 attributesNew.iBuffers = 2; // number of buffers in the surface |
|
2956 attributesNew.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
2957 attributesNew.iStride = 1013; // Number of bytes between start of one line and start of next |
|
2958 attributesNew.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
2959 |
|
2960 RSurfaceManager::THintPair hint; // one hint pairs specified |
|
2961 attributes.iHintCount=1; |
|
2962 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); |
|
2963 attributes.iSurfaceHints = &hint; |
|
2964 |
|
2965 attributesNew.iAlignment = RSurfaceManager::EPageAligned; |
|
2966 attributesNew.iOffsetBetweenBuffers = 0; |
|
2967 attributesNew.iMappable = ETrue; |
|
2968 |
|
2969 // Test create surface doesn't return an error |
|
2970 TSurfaceId surfaceIdNew; |
|
2971 // Test create surface doesn't return an error |
|
2972 // For the time being KErrArgument will be returned as the core codes are |
|
2973 // not ready to check the passed in shared chunk handle. |
|
2974 TEST(KErrNone == iSurfaceManager.CreateSurface(buff, surfaceIdNew, handle)); |
|
2975 |
|
2976 |
|
2977 // Close the first handle |
|
2978 handle.Close(); |
|
2979 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
2980 |
|
2981 RChunk handle2; |
|
2982 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceIdNew,handle2)); |
|
2983 // Get the adress of this chunk of memory |
|
2984 TUint8* surfaceAddNew = handle2.Base(); |
|
2985 |
|
2986 TEST(surfaceAddNew == surfaceAdd); |
|
2987 |
|
2988 // Close the second handle |
|
2989 handle2.Close(); |
|
2990 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
2991 iSurfaceManager.Close(); |
|
2992 } |
|
2993 |
|
2994 void CTSurfaceManager::SetAttributesForHintTestL(RSurfaceManager::TSurfaceCreationAttributes& attributesParamsForHintTest) |
|
2995 { |
|
2996 attributesParamsForHintTest.iSize = TSize(16,480); |
|
2997 attributesParamsForHintTest.iBuffers = 2; |
|
2998 attributesParamsForHintTest.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
2999 attributesParamsForHintTest.iStride = 50; |
|
3000 attributesParamsForHintTest.iOffsetToFirstBuffer = 0; |
|
3001 attributesParamsForHintTest.iAlignment = RSurfaceManager::EPageAligned; |
|
3002 |
|
3003 ReAllocHintsArrayL(2); |
|
3004 attributesParamsForHintTest.iSurfaceHints = iHintsArray; |
|
3005 attributesParamsForHintTest.iSurfaceHints[0].Set(TUid::Uid(0x124578), 20, ETrue); |
|
3006 attributesParamsForHintTest.iSurfaceHints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
3007 attributesParamsForHintTest.iHintCount = 2; |
|
3008 |
|
3009 attributesParamsForHintTest.iContiguous = ETrue; |
|
3010 attributesParamsForHintTest.iCacheAttrib = RSurfaceManager::ECached; |
|
3011 attributesParamsForHintTest.iOffsetBetweenBuffers = 0; |
|
3012 attributesParamsForHintTest.iMappable = ETrue; |
|
3013 } |
|
3014 void CTSurfaceManager::TestGetSurfaceHintL() |
|
3015 { |
|
3016 INFO_PRINTF1(_L("Test that GetSurfaceHint() behaves properly.\r\n")); |
|
3017 // Open the surface manager |
|
3018 User::LeaveIfError(iSurfaceManager.Open()); |
|
3019 // Store the attributes used to create the Surface |
|
3020 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3021 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3022 |
|
3023 SetAttributesForHintTestL(attributes); |
|
3024 |
|
3025 // Create a surface |
|
3026 TSurfaceId surfaceId; |
|
3027 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3028 |
|
3029 RSurfaceManager::THintPair hintPair; |
|
3030 hintPair.iKey.iUid = 0x124578; |
|
3031 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair)); |
|
3032 TEST(hintPair.iValue == 20); |
|
3033 TEST(hintPair.iMutable == 1); |
|
3034 |
|
3035 RSurfaceManager::THintPair hintPair2; |
|
3036 hintPair2.iKey.iUid = 0x237755; |
|
3037 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3038 |
|
3039 TEST(hintPair2.iValue == 50); |
|
3040 TEST(hintPair2.iMutable == EFalse); |
|
3041 |
|
3042 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3043 iSurfaceManager.Close(); |
|
3044 } |
|
3045 |
|
3046 void CTSurfaceManager::TestSetSurfaceHintL() |
|
3047 { |
|
3048 INFO_PRINTF1(_L("Test that SetSurfaceHint() behaves properly.\r\n")); |
|
3049 // Open the surface manager |
|
3050 User::LeaveIfError(iSurfaceManager.Open()); |
|
3051 // Store the attributes used to create the Surface |
|
3052 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3053 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3054 |
|
3055 SetAttributesForHintTestL(attributes); |
|
3056 |
|
3057 // Create a surface |
|
3058 TSurfaceId surfaceId; |
|
3059 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3060 |
|
3061 RSurfaceManager::THintPair hintPair; |
|
3062 hintPair.iKey.iUid = 0x124578; |
|
3063 hintPair.iValue = 300; |
|
3064 hintPair.iMutable = ETrue; |
|
3065 TEST(KErrNone == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair)); |
|
3066 |
|
3067 RSurfaceManager::THintPair hintPair2; |
|
3068 hintPair2.iKey.iUid = 0x124578; |
|
3069 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3070 TEST(hintPair2.iValue == 300); |
|
3071 TEST(hintPair2.iMutable == 1); |
|
3072 // Check the other value unchanged |
|
3073 hintPair2.iKey.iUid = 0x237755; |
|
3074 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3075 TEST(hintPair2.iValue == 50); |
|
3076 TEST(hintPair2.iMutable == 0); |
|
3077 // Add 5 more hint pairs, then set one of them to another value, check all 8 values |
|
3078 RSurfaceManager::THintPair hintPair1; |
|
3079 hintPair1.iKey.iUid = 0x124612; |
|
3080 hintPair1.iValue = 100; |
|
3081 hintPair1.iMutable = ETrue; |
|
3082 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair1)); |
|
3083 |
|
3084 hintPair2.iKey.iUid = 0x124613; |
|
3085 hintPair2.iValue = 200; |
|
3086 hintPair2.iMutable = EFalse; |
|
3087 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair2)); |
|
3088 |
|
3089 RSurfaceManager::THintPair hintPair3; |
|
3090 hintPair3.iKey.iUid = 0x124614; |
|
3091 hintPair3.iValue = 300; |
|
3092 hintPair3.iMutable = ETrue; |
|
3093 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair3)); |
|
3094 |
|
3095 RSurfaceManager::THintPair hintPair4; |
|
3096 hintPair4.iKey.iUid = -0x124615; |
|
3097 hintPair4.iValue = 400; |
|
3098 hintPair4.iMutable = EFalse; |
|
3099 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair4)); |
|
3100 |
|
3101 RSurfaceManager::THintPair hintPair5; |
|
3102 hintPair5.iKey.iUid = 0x124616; |
|
3103 hintPair5.iValue = 500; |
|
3104 hintPair5.iMutable = ETrue; |
|
3105 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair5)); |
|
3106 // Set one of them to a new value |
|
3107 hintPair.iKey.iUid = 0x124578; |
|
3108 hintPair.iValue = 300; |
|
3109 hintPair.iMutable = ETrue; |
|
3110 TEST(KErrNone == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair)); |
|
3111 |
|
3112 // Check all 8 pairs |
|
3113 hintPair2.iKey.iUid = 0x124578; |
|
3114 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3115 TEST(hintPair2.iValue == 300); |
|
3116 TEST(hintPair2.iMutable == 1); |
|
3117 // Check the other value unchanged |
|
3118 hintPair2.iKey.iUid = 0x237755; |
|
3119 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3120 TEST(hintPair2.iValue == 50); |
|
3121 TEST(hintPair2.iMutable == 0); |
|
3122 |
|
3123 hintPair2.iKey.iUid = 0x124612; |
|
3124 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3125 TEST(hintPair2.iValue == 100); |
|
3126 TEST(hintPair2.iMutable == 1); |
|
3127 |
|
3128 hintPair2.iKey.iUid = 0x124613; |
|
3129 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3130 TEST(hintPair2.iValue == 200); |
|
3131 TEST(hintPair2.iMutable == 0); |
|
3132 |
|
3133 hintPair2.iKey.iUid = 0x124614; |
|
3134 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3135 TEST(hintPair2.iValue == 300); |
|
3136 TEST(hintPair2.iMutable == 1); |
|
3137 |
|
3138 hintPair2.iKey.iUid = -0x124615; |
|
3139 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3140 TEST(hintPair2.iValue == 400); |
|
3141 TEST(hintPair2.iMutable == 0); |
|
3142 |
|
3143 hintPair2.iKey.iUid = 0x124616; |
|
3144 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
3145 TEST(hintPair2.iValue == 500); |
|
3146 TEST(hintPair2.iMutable == 1); |
|
3147 |
|
3148 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3149 iSurfaceManager.Close(); |
|
3150 } |
|
3151 |
|
3152 void CTSurfaceManager::CheckHintPair(TSurfaceId& aSurfaceId, RSurfaceManager::THintPair& aHintPairToCheck, RSurfaceManager::THintPair& aHintPairCompareWith) |
|
3153 { |
|
3154 TEST(KErrNone == iSurfaceManager.GetSurfaceHint(aSurfaceId, aHintPairToCheck)); |
|
3155 TEST(aHintPairToCheck.iValue == aHintPairCompareWith.iValue); |
|
3156 TEST(aHintPairToCheck.iMutable == aHintPairCompareWith.iMutable); |
|
3157 } |
|
3158 void CTSurfaceManager::TestAddSurfaceHintL() |
|
3159 { |
|
3160 INFO_PRINTF1(_L("Test that AddSurfaceHint behaves properly.\r\n")); |
|
3161 |
|
3162 // Open the surface manager |
|
3163 User::LeaveIfError(iSurfaceManager.Open()); |
|
3164 |
|
3165 // Store the attributes used to create the Surface |
|
3166 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3167 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3168 attributes.iSize = TSize(16,480); |
|
3169 attributes.iBuffers = 2; |
|
3170 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
3171 attributes.iStride = 50; |
|
3172 attributes.iOffsetToFirstBuffer = 0; |
|
3173 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
3174 attributes.iContiguous = ETrue; |
|
3175 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
3176 attributes.iOffsetBetweenBuffers = 0; |
|
3177 attributes.iMappable = ETrue; |
|
3178 |
|
3179 // Create a surface |
|
3180 TSurfaceId surfaceId; |
|
3181 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3182 |
|
3183 //Add HintPair1 |
|
3184 RSurfaceManager::THintPair hintPair1; |
|
3185 hintPair1.iKey.iUid = 0x123257; |
|
3186 hintPair1.iValue = 300; |
|
3187 hintPair1.iMutable = ETrue; |
|
3188 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair1)); |
|
3189 |
|
3190 RSurfaceManager::THintPair hintPairCheck1; |
|
3191 hintPairCheck1.iKey.iUid = 0x123257; |
|
3192 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3193 |
|
3194 //Add HintPair2 |
|
3195 RSurfaceManager::THintPair hintPair2; |
|
3196 hintPair2.iKey.iUid = 0x123267; |
|
3197 hintPair2.iValue = 100; |
|
3198 hintPair2.iMutable = EFalse; |
|
3199 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair2)); |
|
3200 |
|
3201 RSurfaceManager::THintPair hintPairCheck2; |
|
3202 hintPairCheck2.iKey.iUid = 0x123267; |
|
3203 CheckHintPair(surfaceId, hintPairCheck2, hintPair2); |
|
3204 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3205 |
|
3206 //Add HintPair3 |
|
3207 RSurfaceManager::THintPair hintPair3; |
|
3208 hintPair3.iKey.iUid = 0x123324; |
|
3209 hintPair3.iValue = 500; |
|
3210 hintPair3.iMutable = ETrue; |
|
3211 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair3)); |
|
3212 |
|
3213 RSurfaceManager::THintPair hintPairCheck3; |
|
3214 hintPairCheck3.iKey.iUid = 0x123324; |
|
3215 CheckHintPair(surfaceId, hintPairCheck3, hintPair3); |
|
3216 CheckHintPair(surfaceId, hintPairCheck2, hintPair2); |
|
3217 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3218 |
|
3219 //Add HintPair4 |
|
3220 RSurfaceManager::THintPair hintPair4; |
|
3221 hintPair4.iKey.iUid = 0x125678; |
|
3222 hintPair4.iValue = 150; |
|
3223 hintPair4.iMutable = EFalse; |
|
3224 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair4)); |
|
3225 |
|
3226 RSurfaceManager::THintPair hintPairCheck4; |
|
3227 hintPairCheck4.iKey.iUid = 0x125678; |
|
3228 CheckHintPair(surfaceId, hintPairCheck4, hintPair4); |
|
3229 CheckHintPair(surfaceId, hintPairCheck3, hintPair3); |
|
3230 CheckHintPair(surfaceId, hintPairCheck2, hintPair2); |
|
3231 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3232 |
|
3233 //Add HintPair5 |
|
3234 RSurfaceManager::THintPair hintPair5; |
|
3235 hintPair5.iKey.iUid = 0x233506; |
|
3236 hintPair5.iValue = 270; |
|
3237 hintPair5.iMutable = ETrue; |
|
3238 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair5)); |
|
3239 |
|
3240 RSurfaceManager::THintPair hintPairCheck5; |
|
3241 hintPairCheck5.iKey.iUid = 0x233506; |
|
3242 CheckHintPair(surfaceId, hintPairCheck5, hintPair5); |
|
3243 CheckHintPair(surfaceId, hintPairCheck4, hintPair4); |
|
3244 CheckHintPair(surfaceId, hintPairCheck3, hintPair3); |
|
3245 CheckHintPair(surfaceId, hintPairCheck2, hintPair2); |
|
3246 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3247 |
|
3248 //Add HintPair6 |
|
3249 RSurfaceManager::THintPair hintPair6; |
|
3250 hintPair6.iKey.iUid = -0x128899; |
|
3251 hintPair6.iValue = 310; |
|
3252 hintPair6.iMutable = ETrue; |
|
3253 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair6)); |
|
3254 |
|
3255 RSurfaceManager::THintPair hintPairCheck6; |
|
3256 hintPairCheck6.iKey.iUid = -0x128899; |
|
3257 CheckHintPair(surfaceId, hintPairCheck6, hintPair6); |
|
3258 CheckHintPair(surfaceId, hintPairCheck5, hintPair5); |
|
3259 CheckHintPair(surfaceId, hintPairCheck4, hintPair4); |
|
3260 CheckHintPair(surfaceId, hintPairCheck3, hintPair3); |
|
3261 CheckHintPair(surfaceId, hintPairCheck2, hintPair2); |
|
3262 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3263 |
|
3264 //Add HintPair7 |
|
3265 RSurfaceManager::THintPair hintPair7; |
|
3266 hintPair7.iKey.iUid = 0x225377; |
|
3267 hintPair7.iValue = 70; |
|
3268 hintPair7.iMutable = ETrue; |
|
3269 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair7)); |
|
3270 |
|
3271 RSurfaceManager::THintPair hintPairCheck7; |
|
3272 hintPairCheck7.iKey.iUid = 0x225377; |
|
3273 CheckHintPair(surfaceId, hintPairCheck7, hintPair7); |
|
3274 CheckHintPair(surfaceId, hintPairCheck6, hintPair6); |
|
3275 CheckHintPair(surfaceId, hintPairCheck5, hintPair5); |
|
3276 CheckHintPair(surfaceId, hintPairCheck4, hintPair4); |
|
3277 CheckHintPair(surfaceId, hintPairCheck3, hintPair3); |
|
3278 CheckHintPair(surfaceId, hintPairCheck2, hintPair2); |
|
3279 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3280 |
|
3281 //Add HintPair8 |
|
3282 RSurfaceManager::THintPair hintPair8; |
|
3283 hintPair8.iKey.iUid = -0x257936; |
|
3284 hintPair8.iValue = 560; |
|
3285 hintPair8.iMutable = EFalse; |
|
3286 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair8)); |
|
3287 |
|
3288 RSurfaceManager::THintPair hintPairCheck8; |
|
3289 hintPairCheck8.iKey.iUid = -0x257936; |
|
3290 CheckHintPair(surfaceId, hintPairCheck8, hintPair8); |
|
3291 CheckHintPair(surfaceId, hintPairCheck7, hintPair7); |
|
3292 CheckHintPair(surfaceId, hintPairCheck6, hintPair6); |
|
3293 CheckHintPair(surfaceId, hintPairCheck5, hintPair5); |
|
3294 CheckHintPair(surfaceId, hintPairCheck4, hintPair4); |
|
3295 CheckHintPair(surfaceId, hintPairCheck3, hintPair3); |
|
3296 CheckHintPair(surfaceId, hintPairCheck2, hintPair2); |
|
3297 CheckHintPair(surfaceId, hintPairCheck1, hintPair1); |
|
3298 |
|
3299 |
|
3300 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3301 iSurfaceManager.Close(); |
|
3302 } |
|
3303 |
|
3304 void CTSurfaceManager::SetupAttributesForNegativeTestL(RSurfaceManager::TSurfaceCreationAttributes& attributesForNegativeTest) |
|
3305 { |
|
3306 attributesForNegativeTest.iSize = TSize(480,16); |
|
3307 attributesForNegativeTest.iBuffers = 2; // number of buffers in the surface |
|
3308 attributesForNegativeTest.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
3309 attributesForNegativeTest.iStride = 1013; // Number of bytes between start of one line and start of next |
|
3310 attributesForNegativeTest.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
3311 attributesForNegativeTest.iAlignment = 32; |
|
3312 |
|
3313 // two hint pairs specified |
|
3314 ReAllocHintsArrayL(2); |
|
3315 attributesForNegativeTest.iSurfaceHints = iHintsArray; |
|
3316 attributesForNegativeTest.iHintCount=2; |
|
3317 attributesForNegativeTest.iSurfaceHints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
3318 attributesForNegativeTest.iSurfaceHints[1].Set(TUid::Uid(0x124523), 30, EFalse); |
|
3319 |
|
3320 attributesForNegativeTest.iContiguous = ETrue; |
|
3321 attributesForNegativeTest.iCacheAttrib = RSurfaceManager::ECached; |
|
3322 attributesForNegativeTest.iOffsetBetweenBuffers = 0; |
|
3323 attributesForNegativeTest.iMappable = ETrue; |
|
3324 } |
|
3325 |
|
3326 void CTSurfaceManager::TestCreateSurfaceInvalidParamsNewChunkL() |
|
3327 { |
|
3328 INFO_PRINTF1(_L("Creating a surface with invalid parameters in a new shared chunk\r\n")); |
|
3329 // Open the surface manager |
|
3330 User::LeaveIfError(iSurfaceManager.Open()); |
|
3331 // Setup valid attributes initially |
|
3332 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3333 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3334 |
|
3335 SetupAttributesForNegativeTestL(attributes); |
|
3336 |
|
3337 TSurfaceId surfaceId; |
|
3338 // Test create surface doesn't return an error |
|
3339 TInt err = iSurfaceManager.CreateSurface(buf, surfaceId); |
|
3340 TEST(KErrNone == err); |
|
3341 if (err == KErrNone) |
|
3342 { |
|
3343 // No need to close the surface as it is not created properly. |
|
3344 // Test with negative width |
|
3345 attributes.iSize.iWidth = -2; |
|
3346 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3347 attributes.iSize.iWidth = 480; // reset width |
|
3348 // Test with negative height |
|
3349 attributes.iSize.iHeight = -56; |
|
3350 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3351 attributes.iSize.iHeight = 16; // reset |
|
3352 |
|
3353 // Test with invalid buffers |
|
3354 attributes.iBuffers = 0; // no buffers |
|
3355 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3356 attributes.iBuffers = -5; // negative buffers |
|
3357 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3358 attributes.iBuffers = 2; // reset |
|
3359 |
|
3360 // Test with invalid stride |
|
3361 attributes.iStride = -200; // negative |
|
3362 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3363 attributes.iStride = 0; //smaller than required |
|
3364 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3365 attributes.iStride = 1013; //reset |
|
3366 |
|
3367 //Test with invalid offset |
|
3368 attributes.iOffsetToFirstBuffer = -14; // negative |
|
3369 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3370 |
|
3371 attributes.iOffsetToFirstBuffer = 2147483647; // invalid offset |
|
3372 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3373 attributes.iOffsetToFirstBuffer = 0; // restore |
|
3374 |
|
3375 // Test with invalid alignment (valid parameters: 1:2:4:8) |
|
3376 attributes.iAlignment = 0; |
|
3377 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3378 attributes.iAlignment = 3; |
|
3379 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3380 attributes.iAlignment = 5; |
|
3381 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3382 attributes.iAlignment = 12; |
|
3383 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3384 attributes.iAlignment = -2; |
|
3385 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3386 attributes.iAlignment = 32; // restore |
|
3387 |
|
3388 //Test with invalid iOffsetBetweenBuffers |
|
3389 attributes.iOffsetBetweenBuffers = 50 ; //smaller than required |
|
3390 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3391 |
|
3392 attributes.iOffsetBetweenBuffers = -5; // negative offset |
|
3393 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3394 attributes.iOffsetBetweenBuffers = 0; |
|
3395 |
|
3396 //Test invalid surface hint |
|
3397 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3398 RSurfaceManager::THintPair hintPair; |
|
3399 hintPair.iKey.iUid = 0; |
|
3400 hintPair.iValue = 30; |
|
3401 hintPair.iMutable = ETrue; |
|
3402 TEST(KErrArgument == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair)); |
|
3403 } |
|
3404 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3405 iSurfaceManager.Close(); |
|
3406 } |
|
3407 |
|
3408 void CTSurfaceManager::TestCreateSurfaceInvalidParamsExisitingChunkL() |
|
3409 { |
|
3410 INFO_PRINTF1(_L("Creating a surface with invalid parameters in the existing shared chunk\r\n")); |
|
3411 |
|
3412 // Call another device driver to get a valid shared chunk handle |
|
3413 RSharedChunkLdd device; |
|
3414 RChunk handle; |
|
3415 TUint ChunkSize = 40960; // bottom 8 bits reserved space for other chunk creation attributes info |
|
3416 TUint ChunkAttribs = ChunkSize|EMultiple|EOwnsMemory; |
|
3417 TUint ContiguousAttrib = 1; |
|
3418 GetSharedChunkHandleL(device, handle, ChunkSize, ChunkAttribs, ContiguousAttrib); |
|
3419 |
|
3420 // Open the surface manager |
|
3421 User::LeaveIfError(iSurfaceManager.Open()); |
|
3422 // Setup valid attributes initially |
|
3423 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3424 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3425 |
|
3426 SetupAttributesForNegativeTestL(attributes); |
|
3427 |
|
3428 TSurfaceId surfaceId; |
|
3429 // Test create surface doesn't return an error |
|
3430 TInt err = iSurfaceManager.CreateSurface(buf, surfaceId, handle); |
|
3431 TEST(KErrNone == err); |
|
3432 if (err == KErrNone) |
|
3433 { |
|
3434 // No need to close the surface as it is not created properly. |
|
3435 // Test with negative width |
|
3436 attributes.iSize.iWidth = -2; |
|
3437 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3438 attributes.iSize.iWidth = 480; // reset width |
|
3439 // 12.2: Test with negative height |
|
3440 attributes.iSize.iHeight = -56; |
|
3441 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3442 attributes.iSize.iHeight = 16; // reset |
|
3443 |
|
3444 //Test with invalid buffers |
|
3445 attributes.iBuffers = 0; // no buffers |
|
3446 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3447 attributes.iBuffers = -5; // negative buffers |
|
3448 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3449 attributes.iBuffers = 2; // reset |
|
3450 |
|
3451 //Test with invalid stride |
|
3452 attributes.iStride = -200; // negative |
|
3453 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3454 attributes.iStride = 0; //smaller than required |
|
3455 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3456 attributes.iStride = 1013; //reset |
|
3457 |
|
3458 //Test with invalid offset |
|
3459 attributes.iOffsetToFirstBuffer = -14; //negative offset |
|
3460 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3461 attributes.iOffsetToFirstBuffer = 5; //not divisable by iAlignment |
|
3462 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3463 attributes.iOffsetToFirstBuffer = 2147483647; //invalid setting |
|
3464 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3465 attributes.iOffsetToFirstBuffer = 0; |
|
3466 |
|
3467 //Test with invalid alignment (valid parameters: 1:2:4:8) |
|
3468 attributes.iAlignment = 0; |
|
3469 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3470 attributes.iAlignment = 3; |
|
3471 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3472 attributes.iAlignment = 5; |
|
3473 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3474 attributes.iAlignment = 12; |
|
3475 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3476 attributes.iAlignment = -2; |
|
3477 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3478 attributes.iAlignment = 32; // restore |
|
3479 |
|
3480 attributes.iOffsetBetweenBuffers = attributes.iSize.iHeight*attributes.iStride -1 ; //smaller than required |
|
3481 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId,handle)); |
|
3482 attributes.iOffsetBetweenBuffers = 20010; // not devisible by alignment |
|
3483 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3484 attributes.iOffsetBetweenBuffers = -5; // negative offset |
|
3485 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3486 attributes.iOffsetBetweenBuffers = 50000; // iOffsetBetweenBuffers is too big |
|
3487 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3488 attributes.iOffsetBetweenBuffers = 0; |
|
3489 |
|
3490 //Test invalid surface hint |
|
3491 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3492 RSurfaceManager::THintPair hintPair; |
|
3493 hintPair.iKey.iUid = 0; |
|
3494 hintPair.iValue = 30; |
|
3495 hintPair.iMutable = ETrue; |
|
3496 TEST(KErrArgument == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair)); |
|
3497 |
|
3498 //Reset the alignment is page aligned, if iOffsetToFirstBuffer or iOffsetBetweenBuffers is not page aligned, then the surface can't be created |
|
3499 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
3500 attributes.iOffsetToFirstBuffer = 4092; |
|
3501 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3502 |
|
3503 attributes.iOffsetToFirstBuffer = 4096; |
|
3504 attributes.iOffsetBetweenBuffers = 4092; |
|
3505 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId, handle)); |
|
3506 } |
|
3507 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3508 device.CloseChunkHandle(handle); |
|
3509 device.CloseChunk(); |
|
3510 iSurfaceManager.Close(); |
|
3511 device.Close(); |
|
3512 } |
|
3513 |
|
3514 void CTSurfaceManager::TestCreateSurfaceInvalidParamsExisitingChunk2L() |
|
3515 { |
|
3516 INFO_PRINTF1(_L("Creating a surface with invalid parameters in the existing shared chunk which already contains a surface\r\n")); |
|
3517 |
|
3518 // Open the surface manager |
|
3519 User::LeaveIfError(iSurfaceManager.Open()); |
|
3520 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3521 RSurfaceManager::TSurfaceCreationAttributes& attributesOld = buf(); |
|
3522 |
|
3523 SetupAttributesForNegativeTestL(attributesOld); |
|
3524 |
|
3525 TSurfaceId surfaceIdOld; |
|
3526 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdOld)); |
|
3527 |
|
3528 //Map the surface in the current process |
|
3529 RChunk handle; |
|
3530 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceIdOld,handle)); |
|
3531 |
|
3532 // Setup valid attributes initially |
|
3533 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
3534 RSurfaceManager::TSurfaceCreationAttributes& attributes = buff(); |
|
3535 |
|
3536 SetupAttributesForNegativeTestL(attributes); |
|
3537 |
|
3538 TSurfaceId surfaceId; |
|
3539 // No need to close the surface as it is not created properly. |
|
3540 // Test with negative width |
|
3541 attributes.iSize.iWidth = -2; |
|
3542 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3543 attributes.iSize.iWidth = 480; // reset width |
|
3544 // 12.2: Test with negative height |
|
3545 attributes.iSize.iHeight = -56; |
|
3546 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3547 attributes.iSize.iHeight = 16; // reset |
|
3548 |
|
3549 //Test with invalid buffers |
|
3550 attributes.iBuffers = 0; // no buffers |
|
3551 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3552 attributes.iBuffers = -5; // negative buffers |
|
3553 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3554 attributes.iBuffers = 1; // reset |
|
3555 |
|
3556 //Test with invalid stride |
|
3557 attributes.iStride = -200; // negative |
|
3558 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3559 attributes.iStride = 1040; // restore |
|
3560 |
|
3561 //Test with invalid offset |
|
3562 attributes.iOffsetToFirstBuffer = -14; // negative |
|
3563 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3564 attributes.iOffsetToFirstBuffer = 5; // not divisible by iAlignment |
|
3565 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3566 attributes.iOffsetToFirstBuffer = 2147483647; // invalid offset |
|
3567 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3568 attributes.iOffsetToFirstBuffer = 100; // restore |
|
3569 |
|
3570 //Test with invalid alignment (valid parameters: 1:2:4:8) |
|
3571 attributes.iAlignment = 0; |
|
3572 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3573 attributes.iAlignment = 3; |
|
3574 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3575 attributes.iAlignment = 5; |
|
3576 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3577 attributes.iAlignment = 12; |
|
3578 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3579 attributes.iAlignment = -2; |
|
3580 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3581 attributes.iAlignment = 32; // restore |
|
3582 |
|
3583 //Test with invalid iOffsetBetweenBuffers |
|
3584 attributes.iOffsetBetweenBuffers = attributes.iSize.iHeight*attributes.iStride -1 ; //smaller than required |
|
3585 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3586 attributes.iOffsetBetweenBuffers = attributes.iAlignment +1 ; // 1 (iAlignment must not be set to 1) // not devisible by alignment |
|
3587 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3588 attributes.iOffsetBetweenBuffers = -5; // negative offset |
|
3589 TEST(KErrArgument == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3590 attributes.iOffsetBetweenBuffers = 0; |
|
3591 |
|
3592 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdOld)); |
|
3593 handle.Close(); |
|
3594 iSurfaceManager.Close(); |
|
3595 } |
|
3596 |
|
3597 void CTSurfaceManager::TestDuplicatedHintKeyL() |
|
3598 { |
|
3599 INFO_PRINTF1(_L("Test that Hint keys cant not be duplicated\r\n")); |
|
3600 |
|
3601 // Open the surface manager |
|
3602 User::LeaveIfError(iSurfaceManager.Open()); |
|
3603 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3604 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3605 |
|
3606 attributes.iSize = TSize(480,16); |
|
3607 attributes.iBuffers = 2; // number of buffers in the surface |
|
3608 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
3609 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
3610 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
3611 attributes.iAlignment = RSurfaceManager::EPageAligned; // alignment, 1,2,4,8 byte aligned |
|
3612 attributes.iContiguous = ETrue; |
|
3613 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
3614 attributes.iOffsetBetweenBuffers = 0; |
|
3615 attributes.iMappable = ETrue; |
|
3616 |
|
3617 //Set duplicated Hint keys |
|
3618 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
3619 attributes.iHintCount=2; |
|
3620 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
3621 hints[1].Set(TUid::Uid(0x124578), 50, ETrue); |
|
3622 attributes.iSurfaceHints = hints; |
|
3623 |
|
3624 TSurfaceId surfaceId; |
|
3625 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3626 iSurfaceManager.Close(); |
|
3627 } |
|
3628 void CTSurfaceManager::TestInvalidContiguousPropertyL() |
|
3629 { |
|
3630 //This test is only valid on hardware |
|
3631 INFO_PRINTF1(_L("Test that iContiguous is indeed ignored when creating the second surface on the existing shared chunk which already contains a surface\r\n")); |
|
3632 |
|
3633 // Open the surface manager |
|
3634 User::LeaveIfError(iSurfaceManager.Open()); |
|
3635 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3636 RSurfaceManager::TSurfaceCreationAttributes& attributesOld = buf(); |
|
3637 |
|
3638 SetupAttributesForNegativeTestL(attributesOld); |
|
3639 |
|
3640 TSurfaceId surfaceIdOld; |
|
3641 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdOld)); |
|
3642 RChunk handle; |
|
3643 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceIdOld,handle)); |
|
3644 |
|
3645 // Setup valid attributes initially |
|
3646 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
3647 RSurfaceManager::TSurfaceCreationAttributes& attributes = buff(); |
|
3648 |
|
3649 SetupAttributesForNegativeTestL(attributes); |
|
3650 //Reset iContiguous |
|
3651 attributes.iContiguous = EFalse; |
|
3652 |
|
3653 TSurfaceId surfaceId; |
|
3654 TEST(KErrNone == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3655 RSurfaceManager::TInfoBuf infoBuf; |
|
3656 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
3657 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
3658 |
|
3659 //Check the iContiguous is identical to that of the first surface info structure |
|
3660 TEST(info.iContiguous == 1); |
|
3661 |
|
3662 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdOld)); |
|
3663 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3664 handle.Close(); |
|
3665 iSurfaceManager.Close(); |
|
3666 } |
|
3667 |
|
3668 void CTSurfaceManager::TestInvalidCachePropertyL() |
|
3669 { |
|
3670 //This test is only valid on hardware |
|
3671 INFO_PRINTF1(_L("Test that iCacheAttrib is indeed ignored when creating the second surface on the existing shared chunk which already contains a surface\r\n")); |
|
3672 |
|
3673 // Open the surface manager |
|
3674 User::LeaveIfError(iSurfaceManager.Open()); |
|
3675 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3676 RSurfaceManager::TSurfaceCreationAttributes& attributesOld = buf(); |
|
3677 |
|
3678 SetupAttributesForNegativeTestL(attributesOld); |
|
3679 |
|
3680 TSurfaceId surfaceIdOld; |
|
3681 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdOld)); |
|
3682 RChunk handle; |
|
3683 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceIdOld,handle)); |
|
3684 |
|
3685 // Setup valid attributes initially |
|
3686 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
3687 RSurfaceManager::TSurfaceCreationAttributes& attributes = buff(); |
|
3688 |
|
3689 SetupAttributesForNegativeTestL(attributes); |
|
3690 attributes.iCacheAttrib = RSurfaceManager::ENotCached; |
|
3691 |
|
3692 TSurfaceId surfaceId; |
|
3693 TEST(KErrNone == iSurfaceManager.CreateSurface(buff, surfaceId,handle)); |
|
3694 RSurfaceManager::TInfoBuf infoBuf; |
|
3695 TEST(KErrNone == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
3696 RSurfaceManager::TSurfaceInfoV01& info = infoBuf(); |
|
3697 |
|
3698 //cache attribute is not valid on the emulator |
|
3699 INFO_PRINTF2(_L("cache attribute is: %d"), info.iCacheAttrib); |
|
3700 #ifndef __WINS__ |
|
3701 TEST(info.iCacheAttrib == RSurfaceManager::ECached); |
|
3702 INFO_PRINTF2(_L("cache attribute is: %d"), info.iCacheAttrib); |
|
3703 #endif |
|
3704 |
|
3705 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdOld)); |
|
3706 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3707 handle.Close(); |
|
3708 iSurfaceManager.Close(); |
|
3709 } |
|
3710 |
|
3711 void CTSurfaceManager::TestInvalidSharedChunkL() |
|
3712 { |
|
3713 INFO_PRINTF1(_L("Creating a Surface in an invalid chunk\r\n")); |
|
3714 |
|
3715 // Open the surface manager |
|
3716 User::LeaveIfError(iSurfaceManager.Open()); |
|
3717 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3718 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3719 |
|
3720 attributes.iSize = TSize(480,16); |
|
3721 attributes.iBuffers = 2; // number of buffers in the surface |
|
3722 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
3723 attributes.iStride = 1013; // Number of bytes between start of one line and start of next |
|
3724 attributes.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
3725 attributes.iOffsetBetweenBuffers = 0; |
|
3726 attributes.iAlignment = 4; |
|
3727 attributes.iMappable = ETrue; |
|
3728 |
|
3729 ReAllocHintsArrayL(2); |
|
3730 attributes.iHintCount=2; |
|
3731 iHintsArray[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
3732 iHintsArray[1].Set(TUid::Uid(0x124523), 30, EFalse); |
|
3733 attributes.iSurfaceHints = iHintsArray; |
|
3734 |
|
3735 |
|
3736 //Call another device driver to get another shared chunk handle |
|
3737 RChunk handle; |
|
3738 TSurfaceId surfaceId; |
|
3739 |
|
3740 //Test when the chunk handle is NULL, the surface can't be created |
|
3741 TEST(KErrBadHandle == iSurfaceManager.CreateSurface(buf, surfaceId,handle)); |
|
3742 handle.Close(); |
|
3743 |
|
3744 //Test when the chunk is not shared chunk, the surface can't be created |
|
3745 RChunk handle2; |
|
3746 const TInt KCommitSize = 32768; |
|
3747 const TInt KMaxSize = 40960; |
|
3748 User::LeaveIfError(handle2.CreateLocal(KCommitSize, KMaxSize)); |
|
3749 TEST(KErrBadHandle == iSurfaceManager.CreateSurface(buf, surfaceId,handle2)); |
|
3750 handle2.Close(); |
|
3751 |
|
3752 //Test when the chunk is created by the device driver but has the chunk type ESharedKernelSingle, the surface can't be created |
|
3753 RSharedChunkLdd device; |
|
3754 RChunk handle3; |
|
3755 TUint ChunkSize = 40960; // bottom 8 bits reserved space for other chunk creation attributes info |
|
3756 TUint ChunkAttribs = ChunkSize|ESingle|EOwnsMemory; |
|
3757 TUint ContiguousAttrib = 1; |
|
3758 GetSharedChunkHandleL(device, handle3, ChunkSize, ChunkAttribs, ContiguousAttrib); |
|
3759 TEST(KErrBadHandle == iSurfaceManager.CreateSurface(buf, surfaceId,handle3)); |
|
3760 device.CloseChunkHandle(handle3); |
|
3761 device.CloseChunk(); |
|
3762 |
|
3763 //Test when the chunk is created by the device driver but the chunk size in bytes is too small for the new surfaces, then the surface can't be created |
|
3764 RChunk handle4; |
|
3765 //The chunk size is too small for the new surface |
|
3766 ChunkSize = 4096; // bottom 8 bits reserved space for other chunk creation attributes info |
|
3767 ChunkAttribs = ChunkSize|EMultiple|EOwnsMemory; |
|
3768 TEST(KErrNone==device.CreateChunk(ChunkAttribs)); |
|
3769 TEST(KErrNone==device.CommitMemory(0, ChunkSize)); |
|
3770 TEST(KErrNone==device.GetChunkHandle(handle4)); |
|
3771 |
|
3772 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId,handle4)); |
|
3773 device.CloseChunkHandle(handle4); |
|
3774 device.CloseChunk(); |
|
3775 |
|
3776 //Test when the chunk is created by the device driver but the chunk memory is not commited, then the surface can't be created |
|
3777 RChunk handle5; |
|
3778 ChunkSize = 40960; // bottom 8 bits reserved space for other chunk creation attributes info |
|
3779 ChunkAttribs = ChunkSize|EMultiple|EOwnsMemory; |
|
3780 TEST(KErrNone==device.CreateChunk(ChunkAttribs)); |
|
3781 TEST(KErrNone==device.GetChunkHandle(handle5)); |
|
3782 |
|
3783 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId,handle5)); |
|
3784 |
|
3785 device.CloseChunkHandle(handle5); |
|
3786 device.CloseChunk(); |
|
3787 iSurfaceManager.Close(); |
|
3788 device.Close(); |
|
3789 } |
|
3790 |
|
3791 void CTSurfaceManager::TestCreateVeryLargeSurfacesL() |
|
3792 { |
|
3793 INFO_PRINTF1(_L("Creating lots of surfaces\r\n")); |
|
3794 // Open the surface manager |
|
3795 |
|
3796 User::LeaveIfError(iSurfaceManager.Open()); |
|
3797 // Setup valid attributes initially |
|
3798 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3799 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3800 |
|
3801 TSurfaceId surfaceId; |
|
3802 attributes.iSize = TSize(5000,5000); // w > 0, h > 0 |
|
3803 attributes.iBuffers = 5; // > 0 |
|
3804 attributes.iPixelFormat = EUidPixelFormatARGB_1555; // 2bpp |
|
3805 attributes.iStride = 100000; // > 0, > width * bpp |
|
3806 attributes.iOffsetToFirstBuffer = 1024; // > 0, divisible by alignment |
|
3807 attributes.iAlignment = RSurfaceManager::EPageAligned; // 1 || 2 || 4 || 8 |
|
3808 attributes.iMappable = ETrue; |
|
3809 |
|
3810 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
3811 attributes.iHintCount=2; |
|
3812 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
3813 hints[1].Set(TUid::Uid(0x124523), 30, EFalse); |
|
3814 attributes.iSurfaceHints = hints; |
|
3815 |
|
3816 attributes.iContiguous = ETrue; |
|
3817 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
3818 attributes.iOffsetBetweenBuffers = 0; |
|
3819 const TInt numAttempts = 10; |
|
3820 TInt ii = 0; |
|
3821 TInt ret = KErrNone; |
|
3822 do |
|
3823 { |
|
3824 ret = iSurfaceManager.CreateSurface(buf, surfaceId); |
|
3825 if(ret != KErrNone) |
|
3826 break; |
|
3827 } |
|
3828 while(ii < numAttempts); |
|
3829 |
|
3830 // If we create 10 surfaces, we should get KErrNoMemory |
|
3831 TEST(ii != numAttempts); |
|
3832 TEST(KErrArgument == ret); |
|
3833 |
|
3834 attributes.iSize = TSize(5000, 25000); |
|
3835 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3836 |
|
3837 attributes.iSize = TSize(5000, 4294); |
|
3838 attributes.iOffsetToFirstBuffer = 483613; |
|
3839 attributes.iAlignment = 32; |
|
3840 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3841 |
|
3842 iSurfaceManager.Close(); |
|
3843 } |
|
3844 |
|
3845 void CTSurfaceManager::TestMapSurfaceInvalidParamsL() |
|
3846 { |
|
3847 INFO_PRINTF1(_L("Testing the MapSurface method with invalid surfaceId\r\n")); |
|
3848 // Open the surface manager |
|
3849 User::LeaveIfError(iSurfaceManager.Open()); |
|
3850 // Store the attributes used to create the Surface |
|
3851 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3852 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3853 |
|
3854 SetupAttributesForNegativeTestL(attributes); |
|
3855 |
|
3856 // Create a surface |
|
3857 TSurfaceId surfaceId; |
|
3858 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3859 |
|
3860 // Set an invalid surfaceId |
|
3861 TSurfaceId invalidSurfaceId = surfaceId; |
|
3862 // Change the surfaceId type to EInvalidSurface |
|
3863 invalidSurfaceId.iInternal[3] = (surfaceId.iInternal[3] & 0x00FFFFFF) | ( TSurfaceId::EInvalidSurface <<24 ) ; |
|
3864 |
|
3865 RChunk handle; |
|
3866 // Map the surface |
|
3867 TEST(KErrArgument == iSurfaceManager.MapSurface(invalidSurfaceId, handle)); |
|
3868 handle.Close(); |
|
3869 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3870 iSurfaceManager.Close(); |
|
3871 } |
|
3872 |
|
3873 void CTSurfaceManager::TestSurfaceInfoChangedTypeL() |
|
3874 { |
|
3875 INFO_PRINTF1(_L("Calling SurfaceInfo on surfaceId with a changed 'type'\r\n")); |
|
3876 // Open the surface manager |
|
3877 User::LeaveIfError(iSurfaceManager.Open()); |
|
3878 // Store the attributes used to create the Surface |
|
3879 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3880 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3881 |
|
3882 attributes.iSize = TSize(361,341); // w > 0, h > 0 |
|
3883 attributes.iBuffers = 4; // > 0, <= 4 |
|
3884 attributes.iPixelFormat = EUidPixelFormatYUV_422Planar; // 2bpp |
|
3885 attributes.iStride = 1400; // > 0, width * bpp |
|
3886 attributes.iOffsetToFirstBuffer = 184; // > 0, divisible by alignment |
|
3887 attributes.iAlignment = 4; // 1 || 2 || 4 || 8 |
|
3888 attributes.iContiguous = EFalse; |
|
3889 attributes.iMappable = ETrue; |
|
3890 |
|
3891 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
3892 attributes.iHintCount=2; |
|
3893 hints[0].Set(TUid::Uid(0x124578), 20, ETrue); |
|
3894 hints[1].Set(TUid::Uid(0x237755), 50, EFalse); |
|
3895 attributes.iSurfaceHints = hints; |
|
3896 |
|
3897 attributes.iOffsetBetweenBuffers = 0; |
|
3898 |
|
3899 // Create a surface |
|
3900 TSurfaceId surfaceId; |
|
3901 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3902 |
|
3903 // Map the surface |
|
3904 RChunk handle; |
|
3905 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId, handle)); |
|
3906 handle.Close(); |
|
3907 |
|
3908 TSurfaceId surfaceIdBackup = surfaceId; |
|
3909 // Call SurfaceInfo to get the attributes of the Surface |
|
3910 RSurfaceManager::TInfoBuf infoBuf; |
|
3911 // Want to change the type - replace it with twice the value of the old type |
|
3912 TInt shiftedType = surfaceId.Type() << 25; |
|
3913 // Mask out the top 8 bits and replace with the new type |
|
3914 surfaceId.iInternal[3] = (surfaceId.iInternal[3] & 0x00FFFFFF) + shiftedType; |
|
3915 |
|
3916 TEST(KErrArgument == iSurfaceManager.SurfaceInfo(surfaceId, infoBuf)); |
|
3917 |
|
3918 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdBackup)); |
|
3919 // Close the surface manager |
|
3920 iSurfaceManager.Close(); |
|
3921 } |
|
3922 |
|
3923 void CTSurfaceManager::TestCloseSurfaceInvalidParamsL() |
|
3924 { |
|
3925 INFO_PRINTF1(_L("Closing a surface with invalid parameters\r\n")); |
|
3926 User::LeaveIfError(iSurfaceManager.Open()); |
|
3927 // Store the attributes used to create the Surface |
|
3928 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3929 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3930 |
|
3931 SetupAttributesForNegativeTestL(attributes); |
|
3932 |
|
3933 // Create a surface - increments reference count by 1 |
|
3934 TSurfaceId surfaceId; |
|
3935 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3936 // Set a negative surfaceId |
|
3937 TSurfaceId invalidSurfaceId; |
|
3938 invalidSurfaceId = surfaceId; |
|
3939 // Change the surfaceId type to EInvalidSurface |
|
3940 invalidSurfaceId.iInternal[3] = (surfaceId.iInternal[3] & 0x00FFFFFF) | ( TSurfaceId::EInvalidSurface <<24 ) ; |
|
3941 TEST(KErrArgument == iSurfaceManager.CloseSurface(invalidSurfaceId)); |
|
3942 |
|
3943 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3944 iSurfaceManager.Close(); |
|
3945 } |
|
3946 |
|
3947 |
|
3948 void CTSurfaceManager::TestSynchronizeCacheInvalidParamsL() |
|
3949 { |
|
3950 INFO_PRINTF1(_L("Test that SynchronizeCache() reacts properly under false conditions\r\n")); |
|
3951 User::LeaveIfError(iSurfaceManager.Open()); |
|
3952 // Store the attributes used to create the Surface |
|
3953 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3954 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3955 |
|
3956 SetupAttributesForNegativeTestL(attributes); //2 buffers in this surface |
|
3957 |
|
3958 // Create a surface - increments reference count by 1 |
|
3959 TSurfaceId surfaceId; |
|
3960 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
3961 |
|
3962 //Close the surface |
|
3963 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
3964 |
|
3965 TEST(KErrArgument == iSurfaceManager.SynchronizeCache(surfaceId,1,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
3966 |
|
3967 TSurfaceId surfaceIdNew; |
|
3968 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdNew)); |
|
3969 // Check invalid operation |
|
3970 TEST(KErrArgument == iSurfaceManager.SynchronizeCache(surfaceIdNew,1,(RSurfaceManager::TSyncOperation)4)); |
|
3971 // Check invalid buffer number |
|
3972 TEST(KErrArgument == iSurfaceManager.SynchronizeCache(surfaceIdNew, attributes.iBuffers, RSurfaceManager::ESyncBeforeNonCPURead)); |
|
3973 // Check invalid buffer number |
|
3974 TEST(KErrArgument == iSurfaceManager.SynchronizeCache(surfaceIdNew,KMaxTInt,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
3975 // Check negative buffer number |
|
3976 TEST(KErrArgument == iSurfaceManager.SynchronizeCache(surfaceIdNew,-1,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
3977 |
|
3978 // Change the surfaceId type to EInvalidSurface |
|
3979 TSurfaceId surfaceIdBackup = surfaceIdNew; |
|
3980 surfaceIdNew.iInternal[3] = (surfaceId.iInternal[3] & 0x00FFFFFF) | ( TSurfaceId::EInvalidSurface <<24 ) ; |
|
3981 TEST(KErrArgument == iSurfaceManager.SynchronizeCache(surfaceIdNew,1,RSurfaceManager::ESyncBeforeNonCPURead)); |
|
3982 |
|
3983 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdBackup)); |
|
3984 iSurfaceManager.Close(); |
|
3985 } |
|
3986 |
|
3987 void CTSurfaceManager::TestCloseSurfaceSameIDTwiceL() |
|
3988 { |
|
3989 INFO_PRINTF1(_L("Closing a surface with the same ID twice\r\n")); |
|
3990 User::LeaveIfError(iSurfaceManager.Open()); |
|
3991 // Store the attributes used to create the Surface |
|
3992 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
3993 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
3994 |
|
3995 attributes.iSize = TSize(150,412); |
|
3996 attributes.iBuffers = 3; |
|
3997 attributes.iPixelFormat = EUidPixelFormatARGB_1555; // 2bpp |
|
3998 attributes.iStride = 301; |
|
3999 attributes.iOffsetToFirstBuffer = 5; |
|
4000 attributes.iAlignment = 1; |
|
4001 attributes.iContiguous=EFalse; |
|
4002 attributes.iMappable = ETrue; |
|
4003 |
|
4004 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
4005 attributes.iHintCount=2; |
|
4006 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
4007 hints[1].Set(TUid::Uid(0x124523), 50, EFalse); |
|
4008 attributes.iSurfaceHints = hints; |
|
4009 |
|
4010 attributes.iOffsetBetweenBuffers = 0; |
|
4011 |
|
4012 // Create a surface - increments reference count by 1 |
|
4013 TSurfaceId surfaceId; |
|
4014 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4015 |
|
4016 // Close the same surface twice |
|
4017 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
4018 TEST(KErrArgument == iSurfaceManager.CloseSurface(surfaceId)); |
|
4019 |
|
4020 iSurfaceManager.Close(); |
|
4021 } |
|
4022 |
|
4023 void CTSurfaceManager::TestCreateSurfaceOomL() |
|
4024 { |
|
4025 INFO_PRINTF1(_L("Testing CreateSurface in out of memory conditions\r\n")); |
|
4026 // Open the surface manager |
|
4027 User::LeaveIfError(iSurfaceManager.Open()); |
|
4028 // Store the attributes used to create the Surface |
|
4029 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
4030 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
4031 |
|
4032 attributes.iSize = TSize(280,301); |
|
4033 attributes.iBuffers = 3; |
|
4034 attributes.iPixelFormat = EUidPixelFormatYUV_422SemiPlanar; // 2bpp |
|
4035 attributes.iStride = 710; |
|
4036 attributes.iOffsetToFirstBuffer = 4; |
|
4037 attributes.iAlignment = 4; |
|
4038 attributes.iContiguous=EFalse; |
|
4039 attributes.iMappable = ETrue; |
|
4040 |
|
4041 RSurfaceManager::THintPair hints[2]; // two hint pairs specified |
|
4042 attributes.iHintCount=2; |
|
4043 hints[0].Set(TUid::Uid(0x124578), 25, ETrue); |
|
4044 hints[1].Set(TUid::Uid(0x124523), 50, EFalse); |
|
4045 attributes.iSurfaceHints = hints; |
|
4046 |
|
4047 attributes.iOffsetBetweenBuffers = 0; |
|
4048 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
4049 // Create a surface |
|
4050 TSurfaceId surfaceId; |
|
4051 |
|
4052 // There are 6 kernal allocs, so test that KErrNoMemory is returned if we fail at each |
|
4053 const TInt numKernalAllocs = 6; |
|
4054 for(TInt ii = numKernalAllocs; ii > 0; --ii) |
|
4055 { |
|
4056 __KHEAP_SETFAIL(RHeap::EDeterministic, ii); |
|
4057 TEST(KErrNoMemory == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4058 } |
|
4059 __KHEAP_RESET; |
|
4060 |
|
4061 // Test create surface doesn't return an error |
|
4062 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4063 |
|
4064 //Map the surface in the current processs |
|
4065 RChunk handle; |
|
4066 TEST(KErrNone == iSurfaceManager.MapSurface(surfaceId,handle)); |
|
4067 |
|
4068 // Cache, Contiguous and Alignment attributes are ignored for the already existing chunks |
|
4069 RSurfaceManager::TSurfaceCreationAttributesBuf buff; |
|
4070 RSurfaceManager::TSurfaceCreationAttributes& attributesNew = buff(); |
|
4071 |
|
4072 attributesNew.iSize = TSize(480,16); |
|
4073 attributesNew.iBuffers = 2; // number of buffers in the surface |
|
4074 attributesNew.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
4075 attributesNew.iStride = 1013; // Number of bytes between start of one line and start of next |
|
4076 attributesNew.iOffsetToFirstBuffer = 0; // way of reserving space before the surface pixel data |
|
4077 |
|
4078 hints[0].Set(TUid::Uid(0x124545), 50, EFalse); // two hint pairs specified |
|
4079 |
|
4080 attributesNew.iAlignment = 8; |
|
4081 attributesNew.iOffsetBetweenBuffers = 0; |
|
4082 attributesNew.iMappable = ETrue; |
|
4083 |
|
4084 // Test create surface doesn't return an error |
|
4085 TSurfaceId surfaceIdNew; |
|
4086 |
|
4087 __KHEAP_SETFAIL(RHeap::EDeterministic, 1); |
|
4088 TEST(KErrNoMemory == iSurfaceManager.CreateSurface(buff, surfaceIdNew, handle)); |
|
4089 __KHEAP_RESET; |
|
4090 |
|
4091 handle.Close(); |
|
4092 iSurfaceManager.Close(); |
|
4093 } |
|
4094 |
|
4095 void CTSurfaceManager::SetAttributesForNegativeHintTestL(RSurfaceManager::TSurfaceCreationAttributes& attributesForNegativeHintTest) |
|
4096 { |
|
4097 attributesForNegativeHintTest.iSize = TSize(16,480); |
|
4098 attributesForNegativeHintTest.iBuffers = 2; |
|
4099 attributesForNegativeHintTest.iPixelFormat = EUidPixelFormatYUV_422Reversed; // 2bpp |
|
4100 attributesForNegativeHintTest.iStride = 50; |
|
4101 attributesForNegativeHintTest.iOffsetToFirstBuffer = 0; |
|
4102 attributesForNegativeHintTest.iAlignment = RSurfaceManager::EPageAligned; |
|
4103 ReAllocHintsArrayL(2); |
|
4104 attributesForNegativeHintTest.iSurfaceHints = iHintsArray; |
|
4105 attributesForNegativeHintTest.iHintCount = 2; |
|
4106 attributesForNegativeHintTest.iSurfaceHints[0].Set(TUid::Uid(0x124578),20, ETrue); |
|
4107 attributesForNegativeHintTest.iSurfaceHints[1].Set(TUid::Uid(0x237755),50, EFalse); |
|
4108 attributesForNegativeHintTest.iContiguous = ETrue; |
|
4109 attributesForNegativeHintTest.iCacheAttrib = RSurfaceManager::ECached; |
|
4110 attributesForNegativeHintTest.iOffsetBetweenBuffers = 0; |
|
4111 attributesForNegativeHintTest.iMappable = ETrue; |
|
4112 } |
|
4113 |
|
4114 void CTSurfaceManager::TestGetSurfaceHintInFalseConditionsL() |
|
4115 { |
|
4116 INFO_PRINTF1(_L("GetSurfaceHint()reacts properly under false conditions\r\n")); |
|
4117 User::LeaveIfError(iSurfaceManager.Open()); |
|
4118 // Store the attributes used to create the Surface |
|
4119 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
4120 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
4121 attributes.iSize = TSize(16,480); |
|
4122 attributes.iBuffers = 2; |
|
4123 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
4124 attributes.iStride = 50; |
|
4125 attributes.iOffsetToFirstBuffer = 0; |
|
4126 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
4127 attributes.iContiguous = ETrue; |
|
4128 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
4129 attributes.iOffsetBetweenBuffers = 0; |
|
4130 attributes.iMappable = ETrue; |
|
4131 |
|
4132 TSurfaceId surfaceId; |
|
4133 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4134 // No hint pair |
|
4135 RSurfaceManager::THintPair hintPair2; |
|
4136 hintPair2.iKey.iUid = 0x123257; |
|
4137 TEST(KErrArgument == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair2)); |
|
4138 |
|
4139 |
|
4140 SetAttributesForNegativeHintTestL(attributes); |
|
4141 |
|
4142 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4143 |
|
4144 RSurfaceManager::THintPair hintPair; |
|
4145 //Test GetSurfaceHint() returns KErrArgument if the hint pair has 0 UID |
|
4146 hintPair.iKey.iUid = 0; |
|
4147 TEST(KErrArgument == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair)); |
|
4148 |
|
4149 hintPair.iKey.iUid = 0x124578; |
|
4150 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
4151 TEST(KErrArgument == iSurfaceManager.GetSurfaceHint(surfaceId, hintPair)); |
|
4152 |
|
4153 TSurfaceId surfaceIdNew; |
|
4154 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdNew)); |
|
4155 |
|
4156 //Convert the type of this surfaceId to EInvalidSurface |
|
4157 TSurfaceId surfaceIdTemp; |
|
4158 surfaceIdTemp = surfaceIdNew; |
|
4159 // Change the surfaceId type to EInvalidSurface |
|
4160 surfaceIdNew.iInternal[3] = (surfaceIdNew.iInternal[3] & 0x00FFFFFF) | ( TSurfaceId::EInvalidSurface <<24 ) ; |
|
4161 TEST(KErrArgument == iSurfaceManager.GetSurfaceHint(surfaceIdNew, hintPair)); |
|
4162 |
|
4163 //Change the surfaceId back to valid one and find a new THintPair with no keys defined |
|
4164 hintPair2.iKey.iUid = 0x166778; |
|
4165 surfaceIdNew = surfaceIdTemp; |
|
4166 TEST(KErrArgument == iSurfaceManager.GetSurfaceHint(surfaceIdNew, hintPair2)); |
|
4167 |
|
4168 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
4169 iSurfaceManager.Close(); |
|
4170 } |
|
4171 |
|
4172 void CTSurfaceManager::TestSetSurfaceHintInFalseConditionsL() |
|
4173 { |
|
4174 INFO_PRINTF1(_L("SetSurfaceHint()reacts properly under false conditions\r\n")); |
|
4175 User::LeaveIfError(iSurfaceManager.Open()); |
|
4176 // Store the attributes used to create the Surface |
|
4177 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
4178 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
4179 attributes.iSize = TSize(16,480); |
|
4180 attributes.iBuffers = 2; |
|
4181 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
4182 attributes.iStride = 50; |
|
4183 attributes.iOffsetToFirstBuffer = 0; |
|
4184 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
4185 attributes.iContiguous = ETrue; |
|
4186 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
4187 attributes.iOffsetBetweenBuffers = 0; |
|
4188 attributes.iMappable = ETrue; |
|
4189 |
|
4190 TSurfaceId surfaceId; |
|
4191 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4192 // No hint pair, Setting a null UID hint pair still returns KErrArgument |
|
4193 RSurfaceManager::THintPair hintPair2; |
|
4194 hintPair2.iKey.iUid = 0; |
|
4195 TEST(KErrArgument == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair2)); |
|
4196 |
|
4197 |
|
4198 SetAttributesForNegativeHintTestL(attributes); |
|
4199 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4200 |
|
4201 //Set a THintPair with a key value set to 0x124578 and value set to 300 |
|
4202 RSurfaceManager::THintPair hintPair; |
|
4203 hintPair.iKey.iUid = 0x124578; |
|
4204 hintPair.iValue = 300; |
|
4205 |
|
4206 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
4207 |
|
4208 TEST(KErrArgument == iSurfaceManager.SetSurfaceHint(surfaceId, hintPair)); |
|
4209 |
|
4210 TSurfaceId surfaceIdNew; |
|
4211 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceIdNew)); |
|
4212 |
|
4213 //Convert the type of this surfaceId to EInvalidSurface |
|
4214 TSurfaceId surfaceIdTemp; |
|
4215 surfaceIdTemp = surfaceIdNew; |
|
4216 // Change the surfaceId type to EInvalidSurface |
|
4217 surfaceIdNew.iInternal[3] = (surfaceIdNew.iInternal[3] & 0x00FFFFFF) | ( TSurfaceId::EInvalidSurface <<24 ) ; |
|
4218 TEST(KErrArgument == iSurfaceManager.SetSurfaceHint(surfaceIdNew, hintPair)); |
|
4219 |
|
4220 //Change the surfaceId back to valid one and try to access a hint pair which is not mutable |
|
4221 hintPair2.iKey.iUid = 0x237755; |
|
4222 hintPair2.iValue = 300; |
|
4223 surfaceIdNew = surfaceIdTemp; |
|
4224 TEST(KErrNone == iSurfaceManager.OpenSurface(surfaceIdNew)); |
|
4225 TEST(KErrAccessDenied == iSurfaceManager.SetSurfaceHint(surfaceIdNew, hintPair2)); |
|
4226 |
|
4227 //find a new THintPair with no keys defined |
|
4228 RSurfaceManager::THintPair hintPair3; |
|
4229 hintPair3.iValue = 300; |
|
4230 TEST(KErrArgument == iSurfaceManager.SetSurfaceHint(surfaceIdNew, hintPair3)); |
|
4231 |
|
4232 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceIdNew)); |
|
4233 iSurfaceManager.Close(); |
|
4234 } |
|
4235 |
|
4236 void CTSurfaceManager::TestAddSurfaceHintInFalseConditionsL() |
|
4237 { |
|
4238 INFO_PRINTF1(_L("AddSurfaceHint()reacts properly under false conditions\r\n")); |
|
4239 |
|
4240 User::LeaveIfError(iSurfaceManager.Open()); |
|
4241 // Store the attributes used to create the Surface |
|
4242 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
4243 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
4244 attributes.iSize = TSize(16,480); |
|
4245 attributes.iBuffers = 2; |
|
4246 attributes.iPixelFormat = EUidPixelFormatYUV_422Reversed; |
|
4247 attributes.iStride = 50; |
|
4248 attributes.iOffsetToFirstBuffer = 0; |
|
4249 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
4250 attributes.iContiguous = ETrue; |
|
4251 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
4252 attributes.iOffsetBetweenBuffers = 0; |
|
4253 attributes.iMappable = ETrue; |
|
4254 |
|
4255 TSurfaceId surfaceId; |
|
4256 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4257 // No hint pair, adding a null UID hint pair still returns KErrArgument |
|
4258 RSurfaceManager::THintPair hintPair2; |
|
4259 hintPair2.iKey.iUid = 0; |
|
4260 TEST(KErrArgument == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair2)); |
|
4261 |
|
4262 |
|
4263 SetAttributesForNegativeHintTestL(attributes); |
|
4264 |
|
4265 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4266 |
|
4267 //Set a THintPair with a key value set to 0x124578 and value set to 300 |
|
4268 RSurfaceManager::THintPair hintPair; |
|
4269 |
|
4270 //Test AddSurfaceHint() returns KErrArgument if the hint pair has 0 UID |
|
4271 hintPair.iKey.iUid = 0; |
|
4272 TEST(KErrArgument == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair)); |
|
4273 hintPair.iKey.iUid = 0x124256; //restore |
|
4274 |
|
4275 //Test AddSurfaceHint () returns KErrArgument if the surface ID is not open in this process |
|
4276 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
4277 TEST(KErrArgument == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair)); |
|
4278 |
|
4279 //Test AddSurfaceHint () returns KErrArgument if the surface ID is invalid |
|
4280 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4281 TSurfaceId surfaceIdTemp; |
|
4282 surfaceIdTemp = surfaceId; |
|
4283 surfaceId.iInternal[3] = (surfaceId.iInternal[3] & 0x00FFFFFF) | ( TSurfaceId::EInvalidSurface <<24 ) ; |
|
4284 TEST(KErrArgument == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair)); |
|
4285 |
|
4286 //Test AddSurfaceHint () returns KErrAlreadyExists if duplicate hint key used |
|
4287 surfaceId = surfaceIdTemp; |
|
4288 TEST(KErrNone == iSurfaceManager.OpenSurface(surfaceId)); |
|
4289 RSurfaceManager::THintPair hintPairDup; |
|
4290 hintPairDup.iKey.iUid = 0x124578; |
|
4291 hintPairDup.iValue = 300; |
|
4292 TEST(KErrAlreadyExists == iSurfaceManager.AddSurfaceHint(surfaceId, hintPairDup)); |
|
4293 |
|
4294 //AddSurfaceHint () returns KErrOverflow if no space to add new pair. |
|
4295 TInt k=1; |
|
4296 |
|
4297 TInt maxHintsPerSurface; |
|
4298 iSurfaceManager.GetSurfaceManagerAttrib(RSurfaceManager::EMaxNumberOfHints,maxHintsPerSurface); |
|
4299 |
|
4300 for (k=1;k<maxHintsPerSurface-1;++k) |
|
4301 { |
|
4302 hintPair2.Set(TUid::Uid(0x124611+k),100*k,(k%2==0)?ETrue:EFalse); |
|
4303 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair2)); |
|
4304 } |
|
4305 |
|
4306 hintPair2.Set(TUid::Uid(0x124611+k),100*k,(k%2==0)?ETrue:EFalse); |
|
4307 TEST(KErrOverflow == iSurfaceManager.AddSurfaceHint(surfaceId, hintPair2)); |
|
4308 |
|
4309 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
4310 iSurfaceManager.Close(); |
|
4311 } |
|
4312 |
|
4313 |
|
4314 void CTSurfaceManager::TestZerosInHintsArrayL() |
|
4315 { |
|
4316 INFO_PRINTF1(_L("Creating a surface with only last hint set, then add hint\r\n")); |
|
4317 User::LeaveIfError(iSurfaceManager.Open()); |
|
4318 |
|
4319 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
4320 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
4321 |
|
4322 attributes.iSize = TSize(100,100); |
|
4323 attributes.iBuffers = 2; |
|
4324 attributes.iPixelFormat = EUidPixelFormatARGB_8888; |
|
4325 attributes.iStride = 400; |
|
4326 attributes.iOffsetToFirstBuffer = 10; |
|
4327 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
4328 attributes.iOffsetBetweenBuffers = 0; |
|
4329 attributes.iContiguous = ETrue; |
|
4330 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
4331 attributes.iMappable = ETrue; |
|
4332 |
|
4333 RSurfaceManager::THintPair hints[8]; // one hint pairs specified |
|
4334 attributes.iHintCount=2; |
|
4335 memclr(hints, sizeof(hints)); |
|
4336 hints[7].Set(TUid::Uid(3), 25, ETrue); |
|
4337 attributes.iSurfaceHints = hints; |
|
4338 |
|
4339 TSurfaceId surfaceId; |
|
4340 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4341 |
|
4342 RSurfaceManager::THintPair hintPair; |
|
4343 hintPair.iKey.iUid = 0x124570; |
|
4344 hintPair.iValue = 50; |
|
4345 hintPair.iMutable = ETrue; |
|
4346 TEST(KErrNone == iSurfaceManager.AddSurfaceHint(surfaceId,hintPair)); |
|
4347 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
4348 |
|
4349 iSurfaceManager.Close(); |
|
4350 } |
|
4351 |
|
4352 |
|
4353 |
|
4354 void CTSurfaceManager::TestCreateSurfaceWithTooManyHintsL() |
|
4355 { |
|
4356 User::LeaveIfError(iSurfaceManager.Open()); |
|
4357 TInt maxHintsPerSurface; |
|
4358 iSurfaceManager.GetSurfaceManagerAttrib(RSurfaceManager::EMaxNumberOfHints,maxHintsPerSurface); |
|
4359 INFO_PRINTF2(_L("Creating a surface with more than the Maximum of Hints (%d)\r\n"),maxHintsPerSurface); |
|
4360 |
|
4361 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
4362 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
4363 |
|
4364 attributes.iSize = TSize(100,100); |
|
4365 attributes.iBuffers = 2; |
|
4366 attributes.iPixelFormat = EUidPixelFormatARGB_8888; |
|
4367 attributes.iStride = 400; |
|
4368 attributes.iOffsetToFirstBuffer = 10; |
|
4369 attributes.iAlignment = RSurfaceManager::EPageAligned; |
|
4370 attributes.iOffsetBetweenBuffers = 0; |
|
4371 attributes.iContiguous = ETrue; |
|
4372 attributes.iCacheAttrib = RSurfaceManager::ECached; |
|
4373 attributes.iMappable = ETrue; |
|
4374 |
|
4375 ReAllocHintsArrayL(maxHintsPerSurface+2); |
|
4376 for (TInt k=0;k<maxHintsPerSurface+2;++k) |
|
4377 { |
|
4378 iHintsArray[k].Set(TUid::Uid(0x124611+k),100*k,(k%2==0)?ETrue:EFalse); |
|
4379 } |
|
4380 |
|
4381 attributes.iSurfaceHints = iHintsArray; |
|
4382 attributes.iHintCount=maxHintsPerSurface+2; |
|
4383 |
|
4384 TSurfaceId surfaceId; |
|
4385 TEST(KErrArgument == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4386 iSurfaceManager.Close(); |
|
4387 } |
|
4388 |
|
4389 |
|
4390 void CTSurfaceManager::TestCreateSurfaceUnMappableL() |
|
4391 { |
|
4392 INFO_PRINTF1(_L("Create an UNmappable surface and try to map it or get the offset of the first buffer\r\n")); |
|
4393 // Open the surface manager |
|
4394 User::LeaveIfError(iSurfaceManager.Open()); |
|
4395 |
|
4396 // Store the attributes used to create the Surface |
|
4397 RSurfaceManager::TSurfaceCreationAttributesBuf buf; |
|
4398 RSurfaceManager::TSurfaceCreationAttributes& attributes = buf(); |
|
4399 SetupAttributesL(attributes); |
|
4400 attributes.iMappable = EFalse; |
|
4401 |
|
4402 // Create a surface |
|
4403 TSurfaceId surfaceId; |
|
4404 TEST(KErrNone == iSurfaceManager.CreateSurface(buf, surfaceId)); |
|
4405 // Map the surface |
|
4406 RChunk handle; |
|
4407 TEST(KErrNotSupported == iSurfaceManager.MapSurface(surfaceId, handle)); |
|
4408 handle.Close(); |
|
4409 |
|
4410 TInt offsetToFirstBuffer; |
|
4411 TEST(KErrNotSupported == iSurfaceManager.GetBufferOffset(surfaceId,0,offsetToFirstBuffer)); |
|
4412 |
|
4413 TEST(KErrNone == iSurfaceManager.CloseSurface(surfaceId)); |
|
4414 iSurfaceManager.Close(); |
|
4415 } |
|
4416 |
|
4417 |
|
4418 //-------------- |
|
4419 __CONSTRUCT_STEP__(SurfaceManager) |
|
4420 |
|
4421 void CTSurfaceManagerStep::TestSetupL() |
|
4422 { |
|
4423 } |
|
4424 |
|
4425 void CTSurfaceManagerStep::TestClose() |
|
4426 { |
|
4427 } |
|
4428 |
|
4429 void CTSurfaceManager::testBooleanTrueL(TBool aCondition, const TText8* aFile, TInt aLine) |
|
4430 { |
|
4431 |
|
4432 testBooleanTrue(aCondition, aFile, aLine); |
|
4433 if(!aCondition) |
|
4434 User::Leave(TEST_ERROR_CODE); // leave with standard error code |
|
4435 } |
|
4436 |