|
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 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "tsgdriver.h" |
|
23 |
|
24 CTSgDriver::CTSgDriver() |
|
25 { |
|
26 INFO_PRINTF1(_L("Graphics resource component test - SgDriver Tests.\r\n")); |
|
27 } |
|
28 |
|
29 CTSgDriver::~CTSgDriver() |
|
30 { |
|
31 } |
|
32 |
|
33 /** |
|
34 Overrides of base class pure virtual |
|
35 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
36 not leave. That being the case, the current test result value will be EPass. |
|
37 @leave Gets system wide error code |
|
38 @return TVerdict code |
|
39 */ |
|
40 TVerdict CTSgDriver::doTestStepL() |
|
41 { |
|
42 SetTestStepID(_L("GRAPHICS-RESOURCE-0001")); |
|
43 INFO_PRINTF1(_L("Graphics resource component initialization and shutdown.\r\n")); |
|
44 TestInitializationAndShutdown(); |
|
45 RecordTestResultL(); |
|
46 |
|
47 SetTestStepID(_L("GRAPHICS-RESOURCE-0002")); |
|
48 INFO_PRINTF1(_L("Graphics resource component shutdown multiple time.\r\n")); |
|
49 TestInitializeShutdownManyTimes(); |
|
50 RecordTestResultL(); |
|
51 |
|
52 SetTestStepID(_L("GRAPHICS-RESOURCE-0022")); |
|
53 INFO_PRINTF1(_L("Shutting down an uninitialised driver.\r\n")); |
|
54 TestShutdownUninitialized(); |
|
55 RecordTestResultL(); |
|
56 |
|
57 #ifdef _DEBUG |
|
58 SetTestStepID(_L("GRAPHICS-RESOURCE-0078")); |
|
59 INFO_PRINTF1(_L("SgDriver panic test - private heap memory leak.\r\n")); |
|
60 TestDriverMemoryLeakL(); |
|
61 RecordTestResultL(); |
|
62 #ifndef __WINS__ |
|
63 SetTestStepID(_L("GRAPHICS-RESOURCE-0023")); |
|
64 INFO_PRINTF1(_L("Shutting down without closing all resources.\r\n")); |
|
65 TestShutdownMemoryLeakL(); |
|
66 RecordTestResultL(); |
|
67 #endif |
|
68 SetTestStepID(_L("GRAPHICS-RESOURCE-0079")); |
|
69 INFO_PRINTF1(_L("SgDriver panic test - ResourceCount() without initialising the driver.\r\n")); |
|
70 TestPanicResourceCountNoDriverL(); |
|
71 RecordTestResultL(); |
|
72 |
|
73 SetTestStepID(_L("GRAPHICS-RESOURCE-0090")); |
|
74 INFO_PRINTF1(_L("SgDriver panic test - AllocMarkStart() without initialising the driver.\r\n")); |
|
75 TestPanicAllocMarkStartNoDriverL(); |
|
76 RecordTestResultL(); |
|
77 |
|
78 SetTestStepID(_L("GRAPHICS-RESOURCE-0091")); |
|
79 INFO_PRINTF1(_L("SgDriver panic test - AllocMarkEnd() without initialising the driver.\r\n")); |
|
80 TestPanicAllocMarkEndNoDriverL(); |
|
81 RecordTestResultL(); |
|
82 |
|
83 SetTestStepID(_L("GRAPHICS-RESOURCE-0092")); |
|
84 INFO_PRINTF1(_L("SgDriver panic test - SetAllocFail() without initialising the driver.\r\n")); |
|
85 TestPanicSetAllocFailNoDriverL(); |
|
86 RecordTestResultL(); |
|
87 #else |
|
88 INFO_PRINTF1(_L("Warning: Skipping the panic tests. \r\n")); |
|
89 #endif |
|
90 return TestStepResult(); |
|
91 } |
|
92 |
|
93 |
|
94 /** |
|
95 @SYMTestCaseID GRAPHICS-RESOURCE-0001 |
|
96 @SYMTestCaseDesc Initialises and shuts down the graphics resource driver. |
|
97 @SYMPREQ PREQ39 |
|
98 @SYMREQ REQ8809 |
|
99 @SYMREQ REQ9175 |
|
100 @SYMREQ REQ9224 |
|
101 @SYMREQ REQ9233 |
|
102 @SYMREQ REQ9234 |
|
103 @SYMFssID SgDriver::Open()\n |
|
104 RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n |
|
105 SgDriver::Close()\n |
|
106 SgDriver::ResourceCount()\n |
|
107 @SYMTestPriority Critical |
|
108 @SYMTestType Unit Test |
|
109 @SYMTestPurpose To ensure the graphics resource driver can be initialised successfully |
|
110 @SYMTestActions Call SgDriver::Open() to start the graphics resource driver, then try |
|
111 to call RSgImage::Create(). Call SgDriver::Open() the second time |
|
112 and then call RSgImage::Create() again. Close the driver and call |
|
113 RSgImage::Create(). Close the driver. |
|
114 @SYMTestExpectedResults RSgImage::Create() should return:\n |
|
115 \t 1. KErrNone \n |
|
116 \t 2. KErrNone \n |
|
117 \t 3. KErrNone \n |
|
118 SgDriver::Open() should return KErrNone both times. |
|
119 @SYMTestStatus Implemented |
|
120 */ |
|
121 void CTSgDriver::TestInitializationAndShutdown() |
|
122 { |
|
123 __UHEAP_MARK; |
|
124 |
|
125 TSgImageInfo info; |
|
126 info.iSizeInPixels = TSize(8, 8); |
|
127 info.iUsage = ESgUsageDirectGdiSource; |
|
128 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
129 info.iCpuAccess = ESgCpuAccessReadWrite; |
|
130 info.iShareable = ETrue; |
|
131 |
|
132 RSgImage image; |
|
133 TEST(KErrNone == SgDriver::Open()); |
|
134 TEST(KErrNone == image.Create(info, KImageData, 16)); |
|
135 TEST(0 < SgDriver::ResourceCount()); |
|
136 image.Close(); |
|
137 |
|
138 TEST(KErrNone == SgDriver::Open()); |
|
139 TEST(KErrNone == image.Create(info, KImageData, 16)); |
|
140 image.Close(); |
|
141 |
|
142 SgDriver::Close(); |
|
143 TEST(KErrNone == image.Create(info, KImageData, 16)); |
|
144 image.Close(); |
|
145 |
|
146 TEST(0 == SgDriver::ResourceCount()); |
|
147 SgDriver::Close(); |
|
148 |
|
149 __UHEAP_MARKEND; |
|
150 } |
|
151 |
|
152 |
|
153 /** |
|
154 @SYMTestCaseID GRAPHICS-RESOURCE-0002 |
|
155 @SYMTestCaseDesc Shuts down graphics resource driver multiple times. |
|
156 @SYMPREQ PREQ39 |
|
157 @SYMREQ REQ8809 |
|
158 @SYMREQ REQ9175 |
|
159 @SYMREQ REQ9224 |
|
160 @SYMREQ REQ9233 |
|
161 @SYMREQ REQ9234 |
|
162 @SYMFssID SgDriver::Open()\n |
|
163 SgDriver::Close()\n |
|
164 SgDriver::ResourceCount()\n |
|
165 RSgImage::Create(const TSgImageInfo&, const TAny*, TInt) |
|
166 @SYMTestPriority Critical |
|
167 @SYMTestType Unit Test |
|
168 @SYMTestPurpose To ensure the graphics resource driver could be shut down multiple times. |
|
169 @SYMTestActions Initialise the graphics resource driver. Create an image then close it. |
|
170 Shutdown the driver twice. Open and driver and create an image. Close the |
|
171 image and shutdown the driver. |
|
172 @SYMTestExpectedResults The graphics resource driver is successfully shut down. The calls to |
|
173 RSgImage::Create() should return:\n |
|
174 \t 1. KErrNone\n |
|
175 \t 2. KErrNone\n |
|
176 @SYMTestStatus Implemented |
|
177 */ |
|
178 void CTSgDriver::TestInitializeShutdownManyTimes() |
|
179 { |
|
180 __UHEAP_MARK; |
|
181 |
|
182 TEST(KErrNone == SgDriver::Open()); |
|
183 |
|
184 TSgImageInfo info; |
|
185 info.iSizeInPixels = TSize(8, 8); |
|
186 info.iUsage = ESgUsageDirectGdiSource; |
|
187 info.iPixelFormat = EUidPixelFormatRGB_565; |
|
188 info.iCpuAccess = ESgCpuAccessReadWrite; |
|
189 info.iShareable = ETrue; |
|
190 |
|
191 RSgImage image; |
|
192 |
|
193 TEST(KErrNone == image.Create(info, KImageData, 16)); |
|
194 image.Close(); |
|
195 |
|
196 SgDriver::Close(); |
|
197 SgDriver::Close(); |
|
198 |
|
199 TEST(KErrNone == SgDriver::Open()); |
|
200 TEST(KErrNone == image.Create(info, KImageData, 16)); |
|
201 image.Close(); |
|
202 |
|
203 TEST(0 == SgDriver::ResourceCount()); |
|
204 SgDriver::Close(); |
|
205 |
|
206 __UHEAP_MARKEND; |
|
207 } |
|
208 |
|
209 |
|
210 /** |
|
211 @SYMTestCaseID GRAPHICS-RESOURCE-0022 |
|
212 @SYMTestCaseDesc Shuts down an uninitialised driver. |
|
213 @SYMPREQ PREQ39 |
|
214 @SYMREQ REQ8809 |
|
215 @SYMREQ REQ9175 |
|
216 @SYMFssID SgDriver::Close() |
|
217 @SYMTestPriority Critical |
|
218 @SYMTestType Unit Test |
|
219 @SYMTestPurpose To ensure invalid Close() calls on the driver will cause no errors. |
|
220 @SYMTestActions Call SgDriver::Close() several times without calling SgDriver::Open(). |
|
221 @SYMTestExpectedResults No errors should be returned. |
|
222 @SYMTestStatus Implemented |
|
223 */ |
|
224 void CTSgDriver::TestShutdownUninitialized() |
|
225 { |
|
226 __UHEAP_MARK; |
|
227 |
|
228 SgDriver::Close(); |
|
229 SgDriver::Close(); |
|
230 SgDriver::Close(); |
|
231 |
|
232 __UHEAP_MARKEND; |
|
233 } |
|
234 |
|
235 /** |
|
236 @SYMTestCaseID GRAPHICS-RESOURCE-0023 |
|
237 @SYMTestCaseDesc Shuts down the driver without closing all resources. |
|
238 @SYMPREQ PREQ39 |
|
239 @SYMREQ REQ8809 |
|
240 @SYMREQ REQ9175 |
|
241 @SYMREQ REQ9224 |
|
242 @SYMREQ REQ9233 |
|
243 @SYMREQ REQ9234 |
|
244 @SYMFssID SgDriver::Open()\n |
|
245 RSgImage::Create(const TSgImageInfo&, const TAny*, TInt)\n |
|
246 SgDriver::Close() |
|
247 @SYMTestPriority Critical |
|
248 @SYMTestType Unit Test |
|
249 @SYMTestPurpose To ensure calling Close() without closing all resources will cause a panic. |
|
250 @SYMTestActions Initialise the graphics resource component and create an image in a second thread. |
|
251 Try to shutdown the component. |
|
252 @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 1(ESgPanicUnclosedResources). |
|
253 @SYMTestStatus Implemented |
|
254 */ |
|
255 void CTSgDriver::TestShutdownMemoryLeakL() |
|
256 { |
|
257 TestOpenDriverL(); |
|
258 //run the test in another process |
|
259 TSgImageInfo info; |
|
260 TSgresTestInfo processInfo = {KSgNullDrawableId, info, 0, ESgresSecondProcessPanicDriverUnclosedResources, ETrue}; |
|
261 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
262 _LIT(KTestName, "TestShutdownMemoryLeakL"); |
|
263 CreateSecondProcessAndCheckPanicL(processInfo, 1, exitCategoryName, KTestName); |
|
264 TestCloseDriver(); |
|
265 } |
|
266 |
|
267 /** |
|
268 @SYMTestCaseID GRAPHICS-RESOURCE-0078 |
|
269 @SYMTestCaseDesc Calls SgDriver::AllocMarkEnd() without shutting down all the resources. |
|
270 @SYMPREQ PREQ39 |
|
271 @SYMREQ REQ8809 |
|
272 @SYMREQ REQ9175 |
|
273 @SYMREQ REQ9224 |
|
274 @SYMREQ REQ9233 |
|
275 @SYMREQ REQ9234 |
|
276 @SYMFssID SgDriver::AllocMarkStart()\n |
|
277 SgDriver::AllocMarkEnd() |
|
278 @SYMTestPriority Critical |
|
279 @SYMTestType Unit Test |
|
280 @SYMTestPurpose To ensure calling SgDriver::AllocMarkEnd() without closing all resources will cause a panic. |
|
281 @SYMTestActions Initialise the graphics resource component in a second process and call SgDriver::AllocMarkStart(). |
|
282 Create an image and call SgDriver::AllocMarkEnd(). |
|
283 @SYMTestExpectedResults The function should panic in the second process with panic code SGRES-ADAPTER 0. |
|
284 @SYMTestStatus Implemented |
|
285 */ |
|
286 void CTSgDriver::TestDriverMemoryLeakL() |
|
287 { |
|
288 TestOpenDriverL(); |
|
289 //run the test in another process |
|
290 TSgImageInfo info; |
|
291 TSgresTestInfo processInfo = {KSgNullDrawableId, info, 0, ESgresSecondProcessPanicMemoryLeak, ETrue}; |
|
292 TExitCategoryName exitCategoryName(_L("SGALLOC")); |
|
293 _LIT(KTestName, "TestDriverMemoryLeakL"); |
|
294 CreateSecondProcessAndCheckPanicL(processInfo, 0, exitCategoryName, KTestName); |
|
295 TestCloseDriver(); |
|
296 } |
|
297 |
|
298 |
|
299 /** |
|
300 @SYMTestCaseID GRAPHICS-RESOURCE-0079 |
|
301 @SYMTestCaseDesc Calls SgDriver::ResourceCount() without initialising the driver. |
|
302 @SYMPREQ PREQ39 |
|
303 @SYMREQ REQ8809 |
|
304 @SYMREQ REQ9175 |
|
305 @SYMFssID SgDriver::ResourceCount())\n |
|
306 @SYMTestPriority Critical |
|
307 @SYMTestType Unit Test |
|
308 @SYMTestPurpose To ensure calling SgDriver::ResourceCount() without initialising |
|
309 the driver first will cause a panic in the debug mode. |
|
310 @SYMTestActions Do not Initialise the graphics resource component and call |
|
311 SgDriver::ResourceCount() in a second thread. |
|
312 @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). |
|
313 @SYMTestStatus Implemented |
|
314 */ |
|
315 void CTSgDriver::TestPanicResourceCountNoDriverL() |
|
316 { |
|
317 TSgImageInfo info; |
|
318 TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicResourceCountNoDriver, ETrue}; |
|
319 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
320 _LIT(KTestName, "TestPanicResourceCountNoDriverL"); |
|
321 CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); |
|
322 } |
|
323 |
|
324 /** |
|
325 @SYMTestCaseID GRAPHICS-RESOURCE-0090 |
|
326 @SYMTestCaseDesc Calls SgDriver::AllocMarkStart() without initialising the driver. |
|
327 @SYMPREQ PREQ39 |
|
328 @SYMREQ REQ8809 |
|
329 @SYMREQ REQ9175 |
|
330 @SYMFssID SgDriver::AllocMarkStart())\n |
|
331 @SYMTestPriority Critical |
|
332 @SYMTestType Unit Test |
|
333 @SYMTestPurpose To ensure calling SgDriver::AllocMarkStart() without initialising |
|
334 the driver first will cause a panic in the debug mode. |
|
335 @SYMTestActions Do not Initialise the graphics resource component and call |
|
336 SgDriver::AllocMarkStart() in a second thread. |
|
337 @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). |
|
338 @SYMTestStatus Implemented |
|
339 */ |
|
340 void CTSgDriver::TestPanicAllocMarkStartNoDriverL() |
|
341 { |
|
342 TSgImageInfo info; |
|
343 TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicAllocMarkStartNoDriver, ETrue}; |
|
344 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
345 _LIT(KTestName, "TestPanicAllocMarkStartNoDriverL"); |
|
346 CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); |
|
347 } |
|
348 |
|
349 /** |
|
350 @SYMTestCaseID GRAPHICS-RESOURCE-0091 |
|
351 @SYMTestCaseDesc Calls SgDriver::AllocMarkEnd() without initialising the driver. |
|
352 @SYMPREQ PREQ39 |
|
353 @SYMREQ REQ8809 |
|
354 @SYMREQ REQ9175 |
|
355 @SYMFssID SgDriver::AllocMarkEnd())\n |
|
356 @SYMTestPriority Critical |
|
357 @SYMTestType Unit Test |
|
358 @SYMTestPurpose To ensure calling SgDriver::AllocMarkEnd() without initialising |
|
359 the driver first will cause a panic in the debug mode. |
|
360 @SYMTestActions Do not Initialise the graphics resource component and call |
|
361 SgDriver::AllocMarkEnd() in a second thread. |
|
362 @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). |
|
363 @SYMTestStatus Implemented |
|
364 */ |
|
365 void CTSgDriver::TestPanicAllocMarkEndNoDriverL() |
|
366 { |
|
367 TSgImageInfo info; |
|
368 TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicAllocMarkEndNoDriver, ETrue}; |
|
369 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
370 _LIT(KTestName, "TestPanicAllocMarkEndNoDriverL"); |
|
371 CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); |
|
372 } |
|
373 |
|
374 /** |
|
375 @SYMTestCaseID GRAPHICS-RESOURCE-0092 |
|
376 @SYMTestCaseDesc Calls SgDriver::SetAllocFail() without initialising the driver. |
|
377 @SYMPREQ PREQ39 |
|
378 @SYMREQ REQ8809 |
|
379 @SYMREQ REQ9175 |
|
380 @SYMFssID SgDriver::SetAllocFail())\n |
|
381 @SYMTestPriority Critical |
|
382 @SYMTestType Unit Test |
|
383 @SYMTestPurpose To ensure calling SgDriver::SetAllocFail() without initialising |
|
384 the driver first will cause a panic in the debug mode. |
|
385 @SYMTestActions Do not Initialise the graphics resource component and call |
|
386 SgDriver::SetAllocFail() in a second thread. |
|
387 @SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver). |
|
388 @SYMTestStatus Implemented |
|
389 */ |
|
390 void CTSgDriver::TestPanicSetAllocFailNoDriverL() |
|
391 { |
|
392 TSgImageInfo info; |
|
393 TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicSetAllocFailNoDriver, ETrue}; |
|
394 TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory); |
|
395 _LIT(KTestName, "TestPanicSetAllocFailNoDriverL"); |
|
396 CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName); |
|
397 } |