sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "tpanictests.h"
|
sl@0
|
17 |
#include <graphics/directgdicontext.h>
|
sl@0
|
18 |
#include <graphics/directgdiimagetarget.h>
|
sl@0
|
19 |
|
sl@0
|
20 |
_LIT(KPanicCategory, "DGDI");
|
sl@0
|
21 |
|
sl@0
|
22 |
CTPanicTests::CTPanicTests()
|
sl@0
|
23 |
{
|
sl@0
|
24 |
SetTestStepName(KTDirectGdiPanicTestsStep);
|
sl@0
|
25 |
}
|
sl@0
|
26 |
|
sl@0
|
27 |
CTPanicTests::~CTPanicTests()
|
sl@0
|
28 |
{
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
/**
|
sl@0
|
32 |
@SYMTestCaseID
|
sl@0
|
33 |
GRAPHICS-DIRECTGDI-PANIC-0001
|
sl@0
|
34 |
|
sl@0
|
35 |
@SYMTestPriority
|
sl@0
|
36 |
Medium
|
sl@0
|
37 |
|
sl@0
|
38 |
@SYMPREQ
|
sl@0
|
39 |
PREQ39
|
sl@0
|
40 |
|
sl@0
|
41 |
@SYMREQ
|
sl@0
|
42 |
REQ9195
|
sl@0
|
43 |
REQ9201
|
sl@0
|
44 |
REQ9202
|
sl@0
|
45 |
REQ9222
|
sl@0
|
46 |
REQ9223
|
sl@0
|
47 |
REQ9236
|
sl@0
|
48 |
REQ9237
|
sl@0
|
49 |
|
sl@0
|
50 |
@SYMTestCaseDesc
|
sl@0
|
51 |
Tests if DirectGDI methods panic when called on a inactivated context.
|
sl@0
|
52 |
|
sl@0
|
53 |
@SYMTestActions
|
sl@0
|
54 |
Construct CDirectGdiDriver.
|
sl@0
|
55 |
Construct CDirectGdiContext.
|
sl@0
|
56 |
Construct RSgImage.
|
sl@0
|
57 |
Construct MDirectGdiImageTarget.
|
sl@0
|
58 |
Create MDirectGdiImageTarget, using RSgImage.
|
sl@0
|
59 |
|
sl@0
|
60 |
Do not Activate CDirectGdiContext.
|
sl@0
|
61 |
Call any API on the context.
|
sl@0
|
62 |
|
sl@0
|
63 |
Destroy RSgImage.
|
sl@0
|
64 |
Destroy MDirectGdiImageTarget.
|
sl@0
|
65 |
Destroy CDirectGdiContext.
|
sl@0
|
66 |
Close CDirectGdiDriver.
|
sl@0
|
67 |
|
sl@0
|
68 |
@SYMTestExpectedResults
|
sl@0
|
69 |
It should panic with panic code DGDI 7, EDirectGdiPanicContextNotActivated
|
sl@0
|
70 |
|
sl@0
|
71 |
@SYMTestStatus
|
sl@0
|
72 |
Implemented
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
void CTPanicTests::TestContextNotActivatedL()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
if (iUseDirectGdi)
|
sl@0
|
77 |
{
|
sl@0
|
78 |
TInt result = CDirectGdiDriver::Open();
|
sl@0
|
79 |
TESTNOERRORL(result);
|
sl@0
|
80 |
|
sl@0
|
81 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
82 |
TEST(dgdiDriver != NULL);
|
sl@0
|
83 |
CleanupClosePushL(*dgdiDriver);
|
sl@0
|
84 |
|
sl@0
|
85 |
CDirectGdiContext* gc = CDirectGdiContext::NewL(*dgdiDriver);
|
sl@0
|
86 |
|
sl@0
|
87 |
RSgImage* rsgImage1 = new RSgImage();
|
sl@0
|
88 |
TESTL(rsgImage1 != NULL);
|
sl@0
|
89 |
|
sl@0
|
90 |
// Set the bitmap up...
|
sl@0
|
91 |
TSgImageInfo imageInfo;
|
sl@0
|
92 |
imageInfo.iSizeInPixels = TSize (320, 240);
|
sl@0
|
93 |
imageInfo.iPixelFormat = iTestParams.iTargetPixelFormat;
|
sl@0
|
94 |
|
sl@0
|
95 |
imageInfo.iUsage = ESgUsageDirectGdiTarget;
|
sl@0
|
96 |
result = rsgImage1->Create(imageInfo, NULL,0);
|
sl@0
|
97 |
TESTNOERRORL(result);
|
sl@0
|
98 |
|
sl@0
|
99 |
RDirectGdiImageTarget* dgdiImageTarget1 = new RDirectGdiImageTarget(*dgdiDriver);
|
sl@0
|
100 |
TESTL(dgdiImageTarget1 != NULL);
|
sl@0
|
101 |
result = dgdiImageTarget1->Create(*rsgImage1);
|
sl@0
|
102 |
TESTNOERRORL(result);
|
sl@0
|
103 |
|
sl@0
|
104 |
TRect rect(10, 15, 100, 100);
|
sl@0
|
105 |
gc->DrawEllipse(rect);
|
sl@0
|
106 |
|
sl@0
|
107 |
dgdiImageTarget1->Close();
|
sl@0
|
108 |
delete(dgdiImageTarget1);
|
sl@0
|
109 |
rsgImage1->Close();
|
sl@0
|
110 |
delete(rsgImage1);
|
sl@0
|
111 |
delete(gc);
|
sl@0
|
112 |
CleanupStack::PopAndDestroy(1);
|
sl@0
|
113 |
}
|
sl@0
|
114 |
else //BitGDI
|
sl@0
|
115 |
User::Panic(KPanicCategory, 7);
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
/**
|
sl@0
|
119 |
@SYMTestCaseID
|
sl@0
|
120 |
GRAPHICS-DIRECTGDI-PANIC-0002
|
sl@0
|
121 |
|
sl@0
|
122 |
@SYMTestPriority
|
sl@0
|
123 |
Medium
|
sl@0
|
124 |
|
sl@0
|
125 |
@SYMPREQ
|
sl@0
|
126 |
PREQ39
|
sl@0
|
127 |
|
sl@0
|
128 |
@SYMREQ
|
sl@0
|
129 |
REQ9195
|
sl@0
|
130 |
REQ9201
|
sl@0
|
131 |
REQ9202
|
sl@0
|
132 |
REQ9222
|
sl@0
|
133 |
REQ9223
|
sl@0
|
134 |
REQ9236
|
sl@0
|
135 |
REQ9237
|
sl@0
|
136 |
|
sl@0
|
137 |
@SYMTestCaseDesc
|
sl@0
|
138 |
Testing if a panic is raised during text drawing functions usage without valid font set.
|
sl@0
|
139 |
|
sl@0
|
140 |
@SYMTestActions
|
sl@0
|
141 |
Context is created and activated.
|
sl@0
|
142 |
|
sl@0
|
143 |
Set font in context.
|
sl@0
|
144 |
Call any DrawText() API on the context.
|
sl@0
|
145 |
|
sl@0
|
146 |
Reset font in context.
|
sl@0
|
147 |
Call any DrawText() API on the context.
|
sl@0
|
148 |
|
sl@0
|
149 |
@SYMTestExpectedResults
|
sl@0
|
150 |
It should panic with panic code DGDI 11, EDirectGdiPanicNoFontSelected.
|
sl@0
|
151 |
|
sl@0
|
152 |
@SYMTestStatus
|
sl@0
|
153 |
Implemented
|
sl@0
|
154 |
*/
|
sl@0
|
155 |
|
sl@0
|
156 |
void CTPanicTests::TestFontNotSetL()
|
sl@0
|
157 |
{
|
sl@0
|
158 |
if(iUseDirectGdi)
|
sl@0
|
159 |
{
|
sl@0
|
160 |
_LIT(KText, "test");
|
sl@0
|
161 |
|
sl@0
|
162 |
ResetGc();
|
sl@0
|
163 |
|
sl@0
|
164 |
CFont* font = GetFont();
|
sl@0
|
165 |
TESTL(font != NULL);
|
sl@0
|
166 |
|
sl@0
|
167 |
iGc->SetPenColor(TRgb(0, 0, 0));
|
sl@0
|
168 |
|
sl@0
|
169 |
iGc->SetFont(font);
|
sl@0
|
170 |
iGc->DrawText(KText, NULL, TPoint(10, 30));
|
sl@0
|
171 |
|
sl@0
|
172 |
iGc->ResetFont();
|
sl@0
|
173 |
iGc->DrawText(KText, NULL, TPoint(10, 50));
|
sl@0
|
174 |
|
sl@0
|
175 |
ReleaseFont(font);
|
sl@0
|
176 |
}
|
sl@0
|
177 |
else //BitGDI
|
sl@0
|
178 |
User::Panic( KPanicCategory, 11);
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
/**
|
sl@0
|
182 |
@SYMTestCaseID
|
sl@0
|
183 |
GRAPHICS-DIRECTGDI-PANIC-0003
|
sl@0
|
184 |
|
sl@0
|
185 |
@SYMTestPriority
|
sl@0
|
186 |
Medium
|
sl@0
|
187 |
|
sl@0
|
188 |
@SYMPREQ
|
sl@0
|
189 |
PREQ39
|
sl@0
|
190 |
|
sl@0
|
191 |
@SYMREQ
|
sl@0
|
192 |
REQ9195
|
sl@0
|
193 |
REQ9201
|
sl@0
|
194 |
REQ9202
|
sl@0
|
195 |
REQ9222
|
sl@0
|
196 |
REQ9223
|
sl@0
|
197 |
REQ9236
|
sl@0
|
198 |
REQ9237
|
sl@0
|
199 |
|
sl@0
|
200 |
@SYMTestCaseDesc
|
sl@0
|
201 |
Tests the negative conditions that can only be reached by creating RSgImage with an invalid pixel type, to
|
sl@0
|
202 |
improve the code coverage.
|
sl@0
|
203 |
|
sl@0
|
204 |
@SYMTestActions
|
sl@0
|
205 |
Construct CDirectGdiDriver.
|
sl@0
|
206 |
Construct CDirectGdiContext.
|
sl@0
|
207 |
|
sl@0
|
208 |
Construct RSgImage with unsupported pixel type and do not check for the return error code.
|
sl@0
|
209 |
Construct MDirectGdiImageTarget.
|
sl@0
|
210 |
Create MDirectGdiImageTarget, using RSgImage, ignoring the return error code.
|
sl@0
|
211 |
|
sl@0
|
212 |
Activate CDirectGdiContext using MDirectGdiImageTarget.
|
sl@0
|
213 |
|
sl@0
|
214 |
Destroy RSgImage.
|
sl@0
|
215 |
Destroy MDirectGdiImageTarget.
|
sl@0
|
216 |
|
sl@0
|
217 |
Destroy CDirectGdiContext.
|
sl@0
|
218 |
Close CDirectGdiDriver.
|
sl@0
|
219 |
|
sl@0
|
220 |
@SYMTestExpectedResults
|
sl@0
|
221 |
It should panic with panic code DGDI 21, EDirectGdiImageTargetInfoError
|
sl@0
|
222 |
|
sl@0
|
223 |
@SYMTestStatus
|
sl@0
|
224 |
Implemented
|
sl@0
|
225 |
*/
|
sl@0
|
226 |
void CTPanicTests::TestInvalidTargetL()
|
sl@0
|
227 |
{
|
sl@0
|
228 |
if(iUseDirectGdi)
|
sl@0
|
229 |
{
|
sl@0
|
230 |
TInt err = CDirectGdiDriver::Open();
|
sl@0
|
231 |
TESTNOERROR(err);
|
sl@0
|
232 |
|
sl@0
|
233 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
234 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
235 |
CleanupClosePushL(*dgdiDriver);
|
sl@0
|
236 |
|
sl@0
|
237 |
CDirectGdiContext* gc = CDirectGdiContext::NewL(*dgdiDriver);
|
sl@0
|
238 |
RSgImage rsgImage;
|
sl@0
|
239 |
|
sl@0
|
240 |
// Set the bitmap up...
|
sl@0
|
241 |
TSgImageInfo imageInfo;
|
sl@0
|
242 |
imageInfo.iSizeInPixels = TSize (320, 240);
|
sl@0
|
243 |
imageInfo.iPixelFormat = EUidPixelFormatA_8;
|
sl@0
|
244 |
imageInfo.iUsage = ESgUsageDirectGdiTarget;
|
sl@0
|
245 |
rsgImage.Create(imageInfo, NULL,0);
|
sl@0
|
246 |
|
sl@0
|
247 |
RDirectGdiImageTarget dgdiImageTarget(*dgdiDriver);
|
sl@0
|
248 |
dgdiImageTarget.Create(rsgImage);
|
sl@0
|
249 |
gc->Activate (dgdiImageTarget);
|
sl@0
|
250 |
|
sl@0
|
251 |
rsgImage.Close();
|
sl@0
|
252 |
dgdiImageTarget.Close();
|
sl@0
|
253 |
delete gc;
|
sl@0
|
254 |
CleanupStack::PopAndDestroy(1);
|
sl@0
|
255 |
}
|
sl@0
|
256 |
else //BitGDI
|
sl@0
|
257 |
User::Panic( KPanicCategory, 21);
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
/**
|
sl@0
|
261 |
@SYMTestCaseID
|
sl@0
|
262 |
GRAPHICS-DIRECTGDI-PANIC-0004
|
sl@0
|
263 |
|
sl@0
|
264 |
@SYMTestPriority
|
sl@0
|
265 |
Medium
|
sl@0
|
266 |
|
sl@0
|
267 |
@SYMPREQ
|
sl@0
|
268 |
PREQ39
|
sl@0
|
269 |
|
sl@0
|
270 |
@SYMREQ
|
sl@0
|
271 |
REQ9195
|
sl@0
|
272 |
REQ9201
|
sl@0
|
273 |
REQ9202
|
sl@0
|
274 |
REQ9222
|
sl@0
|
275 |
REQ9223
|
sl@0
|
276 |
REQ9236
|
sl@0
|
277 |
REQ9237
|
sl@0
|
278 |
|
sl@0
|
279 |
@SYMTestCaseDesc
|
sl@0
|
280 |
Test that the adapter panics when an attempt is made to activate a target with an invalid handle.
|
sl@0
|
281 |
|
sl@0
|
282 |
@SYMTestActions
|
sl@0
|
283 |
Create an RSgImage.
|
sl@0
|
284 |
Make it a target for the driver.
|
sl@0
|
285 |
Change the target's handle so it has an erroneous handle.
|
sl@0
|
286 |
Attempt to activate the target.
|
sl@0
|
287 |
(This test only works in _DEBUG mode as the handle check only happens in _DEBUG mode)
|
sl@0
|
288 |
|
sl@0
|
289 |
@SYMTestExpectedResults
|
sl@0
|
290 |
The test should panic when the target is activated DGDIAdapter 32, EDirectGdiPanicResourceHandleNotFound.
|
sl@0
|
291 |
|
sl@0
|
292 |
@SYMTestStatus
|
sl@0
|
293 |
Implemented
|
sl@0
|
294 |
*/
|
sl@0
|
295 |
void CTPanicTests::TestImageInvalidTargetHandleL()
|
sl@0
|
296 |
{
|
sl@0
|
297 |
#ifdef _DEBUG
|
sl@0
|
298 |
TInt err = CDirectGdiDriver::Open();
|
sl@0
|
299 |
TESTNOERROR(err);
|
sl@0
|
300 |
|
sl@0
|
301 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
302 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
303 |
CleanupClosePushL(*dgdiDriver);
|
sl@0
|
304 |
|
sl@0
|
305 |
CDirectGdiContext* gc = CDirectGdiContext::NewL(*dgdiDriver);
|
sl@0
|
306 |
RSgImage rsgImage;
|
sl@0
|
307 |
|
sl@0
|
308 |
// Set the bitmap up...
|
sl@0
|
309 |
TSgImageInfo imageInfo;
|
sl@0
|
310 |
imageInfo.iSizeInPixels = TSize (320, 240);
|
sl@0
|
311 |
imageInfo.iPixelFormat = iTestParams.iTargetPixelFormat;
|
sl@0
|
312 |
imageInfo.iUsage = ESgUsageDirectGdiTarget;
|
sl@0
|
313 |
rsgImage.Create(imageInfo, NULL,0);
|
sl@0
|
314 |
|
sl@0
|
315 |
RDirectGdiImageTarget dgdiImageTarget(*dgdiDriver);
|
sl@0
|
316 |
dgdiImageTarget.Create(rsgImage);
|
sl@0
|
317 |
|
sl@0
|
318 |
// Set the target's handle to a non-null invalid handle.
|
sl@0
|
319 |
dgdiImageTarget.iHandle = 0x12345678;
|
sl@0
|
320 |
|
sl@0
|
321 |
// Activate should panic (DGDIAdapter EDirectGdiTargetHandleNotFound 32)
|
sl@0
|
322 |
gc->Activate (dgdiImageTarget);
|
sl@0
|
323 |
|
sl@0
|
324 |
rsgImage.Close();
|
sl@0
|
325 |
dgdiImageTarget.Close();
|
sl@0
|
326 |
delete gc;
|
sl@0
|
327 |
CleanupStack::PopAndDestroy(1);
|
sl@0
|
328 |
#else
|
sl@0
|
329 |
User::Panic(KPanicCategory, 32);
|
sl@0
|
330 |
#endif
|
sl@0
|
331 |
}
|
sl@0
|
332 |
|
sl@0
|
333 |
/**
|
sl@0
|
334 |
@SYMTestCaseID
|
sl@0
|
335 |
GRAPHICS-DIRECTGDI-PANIC-0005
|
sl@0
|
336 |
|
sl@0
|
337 |
@SYMTestPriority
|
sl@0
|
338 |
Medium
|
sl@0
|
339 |
|
sl@0
|
340 |
@SYMPREQ
|
sl@0
|
341 |
PREQ39
|
sl@0
|
342 |
|
sl@0
|
343 |
@SYMTestCaseDesc
|
sl@0
|
344 |
Tests the negative conditions that the same RDirectGdiImageTarget object
|
sl@0
|
345 |
is created twice.
|
sl@0
|
346 |
|
sl@0
|
347 |
@SYMTestActions
|
sl@0
|
348 |
Construct CDirectGdiDriver.
|
sl@0
|
349 |
Construct RDirectGdiImageTarget twice.
|
sl@0
|
350 |
|
sl@0
|
351 |
@SYMTestExpectedResults
|
sl@0
|
352 |
It should panic with panic code DGDIAdapter 17, EDirectGdiImageTargetAlreadyExists
|
sl@0
|
353 |
|
sl@0
|
354 |
@SYMTestStatus
|
sl@0
|
355 |
Implemented
|
sl@0
|
356 |
*/
|
sl@0
|
357 |
void CTPanicTests::TestImageTargetActivatedTwiceL()
|
sl@0
|
358 |
{
|
sl@0
|
359 |
if(iUseDirectGdi)
|
sl@0
|
360 |
{
|
sl@0
|
361 |
TInt err = CDirectGdiDriver::Open();
|
sl@0
|
362 |
TESTNOERRORL(err);
|
sl@0
|
363 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
364 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
365 |
CleanupClosePushL(*dgdiDriver);
|
sl@0
|
366 |
|
sl@0
|
367 |
TSgImageInfo info2;
|
sl@0
|
368 |
info2.iSizeInPixels = TSize(8, 8);
|
sl@0
|
369 |
info2.iUsage = ESgUsageDirectGdiTarget;
|
sl@0
|
370 |
info2.iPixelFormat = EUidPixelFormatRGB_565;
|
sl@0
|
371 |
info2.iCpuAccess = ESgCpuAccessNone;
|
sl@0
|
372 |
info2.iShareable = ETrue;
|
sl@0
|
373 |
RSgImage image2;
|
sl@0
|
374 |
User::LeaveIfError(image2.Create(info2, NULL, 0));
|
sl@0
|
375 |
CleanupClosePushL(image2);
|
sl@0
|
376 |
|
sl@0
|
377 |
RDirectGdiImageTarget dgdiImageTarget(*dgdiDriver);
|
sl@0
|
378 |
TESTNOERRORL(dgdiImageTarget.Create(image2));
|
sl@0
|
379 |
CleanupClosePushL(dgdiImageTarget);
|
sl@0
|
380 |
dgdiImageTarget.Create(image2); //should panic here
|
sl@0
|
381 |
CleanupClosePushL(dgdiImageTarget);
|
sl@0
|
382 |
|
sl@0
|
383 |
CleanupStack::PopAndDestroy(4, dgdiDriver);
|
sl@0
|
384 |
}
|
sl@0
|
385 |
else //BitGDI
|
sl@0
|
386 |
{
|
sl@0
|
387 |
User::Panic( KPanicCategory, 17);
|
sl@0
|
388 |
}
|
sl@0
|
389 |
}
|
sl@0
|
390 |
|
sl@0
|
391 |
/**
|
sl@0
|
392 |
@SYMTestCaseID
|
sl@0
|
393 |
GRAPHICS-DIRECTGDI-PANIC-0006
|
sl@0
|
394 |
|
sl@0
|
395 |
@SYMTestPriority
|
sl@0
|
396 |
Medium
|
sl@0
|
397 |
|
sl@0
|
398 |
@SYMPREQ
|
sl@0
|
399 |
PREQ39
|
sl@0
|
400 |
|
sl@0
|
401 |
@SYMTestCaseDesc
|
sl@0
|
402 |
Tests the negative conditions that the same RDirectGdiDrawableSource object
|
sl@0
|
403 |
is created twice.
|
sl@0
|
404 |
|
sl@0
|
405 |
@SYMTestActions
|
sl@0
|
406 |
Construct CDirectGdiDriver.
|
sl@0
|
407 |
Construct RDirectGdiDrawableSource twice.
|
sl@0
|
408 |
|
sl@0
|
409 |
@SYMTestExpectedResults
|
sl@0
|
410 |
It should panic with panic code DGDI 18, EDirectGdiImageSourceAlreadyExists
|
sl@0
|
411 |
|
sl@0
|
412 |
@SYMTestStatus
|
sl@0
|
413 |
Implemented
|
sl@0
|
414 |
*/
|
sl@0
|
415 |
void CTPanicTests::TestImageSourceActivatedTwiceL()
|
sl@0
|
416 |
{
|
sl@0
|
417 |
if(iUseDirectGdi)
|
sl@0
|
418 |
{
|
sl@0
|
419 |
TInt err = CDirectGdiDriver::Open();
|
sl@0
|
420 |
TESTNOERRORL(err);
|
sl@0
|
421 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
422 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
423 |
CleanupClosePushL(*dgdiDriver);
|
sl@0
|
424 |
|
sl@0
|
425 |
TSgImageInfo info1;
|
sl@0
|
426 |
info1.iSizeInPixels = TSize(8, 8);
|
sl@0
|
427 |
info1.iUsage = ESgUsageDirectGdiSource;
|
sl@0
|
428 |
info1.iPixelFormat = EUidPixelFormatRGB_565;
|
sl@0
|
429 |
info1.iCpuAccess = ESgCpuAccessReadWrite;
|
sl@0
|
430 |
info1.iShareable = ETrue;
|
sl@0
|
431 |
RSgImage image1;
|
sl@0
|
432 |
User::LeaveIfError(image1.Create(info1, NULL, 0));
|
sl@0
|
433 |
CleanupClosePushL(image1);
|
sl@0
|
434 |
|
sl@0
|
435 |
RDirectGdiDrawableSource dgdiImageSource(*dgdiDriver);
|
sl@0
|
436 |
TESTNOERRORL(dgdiImageSource.Create(image1));
|
sl@0
|
437 |
CleanupClosePushL(dgdiImageSource);
|
sl@0
|
438 |
dgdiImageSource.Create(image1); //should panic here
|
sl@0
|
439 |
CleanupClosePushL(dgdiImageSource);
|
sl@0
|
440 |
|
sl@0
|
441 |
CleanupStack::PopAndDestroy(4, dgdiDriver);
|
sl@0
|
442 |
}
|
sl@0
|
443 |
else //BitGDI
|
sl@0
|
444 |
{
|
sl@0
|
445 |
User::Panic( KPanicCategory, 18);
|
sl@0
|
446 |
}
|
sl@0
|
447 |
}
|
sl@0
|
448 |
|
sl@0
|
449 |
/**
|
sl@0
|
450 |
@SYMTestCaseID
|
sl@0
|
451 |
GRAPHICS-DIRECTGDI-PANIC-0007
|
sl@0
|
452 |
|
sl@0
|
453 |
@SYMTestPriority
|
sl@0
|
454 |
Medium
|
sl@0
|
455 |
|
sl@0
|
456 |
@SYMPREQ
|
sl@0
|
457 |
PREQ39
|
sl@0
|
458 |
|
sl@0
|
459 |
@SYMREQ
|
sl@0
|
460 |
REQ9195
|
sl@0
|
461 |
REQ9201
|
sl@0
|
462 |
REQ9202
|
sl@0
|
463 |
REQ9222
|
sl@0
|
464 |
REQ9223
|
sl@0
|
465 |
REQ9236
|
sl@0
|
466 |
REQ9237
|
sl@0
|
467 |
|
sl@0
|
468 |
@SYMTestCaseDesc
|
sl@0
|
469 |
Tests the negative conditions that the same RDirectGdiDrawableSource object
|
sl@0
|
470 |
is created twice.
|
sl@0
|
471 |
|
sl@0
|
472 |
@SYMTestActions
|
sl@0
|
473 |
Construct CDirectGdiDriver.
|
sl@0
|
474 |
Construct RDirectGdiDrawableSource twice.
|
sl@0
|
475 |
|
sl@0
|
476 |
@SYMTestExpectedResults
|
sl@0
|
477 |
It should panic with panic code DGDIAdapter 19, EDirectGdiDrawableSourceAlreadyExists
|
sl@0
|
478 |
|
sl@0
|
479 |
@SYMTestStatus
|
sl@0
|
480 |
Implemented
|
sl@0
|
481 |
*/
|
sl@0
|
482 |
void CTPanicTests::TestDrawableSourceActivatedTwiceL()
|
sl@0
|
483 |
{
|
sl@0
|
484 |
if(iUseDirectGdi)
|
sl@0
|
485 |
{
|
sl@0
|
486 |
TInt err = CDirectGdiDriver::Open();
|
sl@0
|
487 |
TESTNOERRORL(err);
|
sl@0
|
488 |
CDirectGdiDriver* dgdiDriver = CDirectGdiDriver::Static();
|
sl@0
|
489 |
TESTL(dgdiDriver != NULL);
|
sl@0
|
490 |
CleanupClosePushL(*dgdiDriver);
|
sl@0
|
491 |
|
sl@0
|
492 |
TSgImageInfo info1;
|
sl@0
|
493 |
info1.iSizeInPixels = TSize(8, 8);
|
sl@0
|
494 |
info1.iUsage = ESgUsageDirectGdiSource;
|
sl@0
|
495 |
info1.iPixelFormat = EUidPixelFormatARGB_8888_PRE;
|
sl@0
|
496 |
info1.iCpuAccess = ESgCpuAccessReadWrite;
|
sl@0
|
497 |
info1.iShareable = ETrue;
|
sl@0
|
498 |
RSgImage image1;
|
sl@0
|
499 |
TESTNOERRORL(image1.Create(info1, NULL, 0));
|
sl@0
|
500 |
CleanupClosePushL(image1);
|
sl@0
|
501 |
|
sl@0
|
502 |
RDirectGdiDrawableSource dgdiDrawableSource(*dgdiDriver);
|
sl@0
|
503 |
TESTNOERRORL(dgdiDrawableSource.Create(image1));
|
sl@0
|
504 |
CleanupClosePushL(dgdiDrawableSource);
|
sl@0
|
505 |
dgdiDrawableSource.Create(image1); //should panic here
|
sl@0
|
506 |
CleanupClosePushL(dgdiDrawableSource);
|
sl@0
|
507 |
|
sl@0
|
508 |
CleanupStack::PopAndDestroy(4, dgdiDriver);
|
sl@0
|
509 |
}
|
sl@0
|
510 |
else //BitGDI
|
sl@0
|
511 |
{
|
sl@0
|
512 |
User::Panic( KPanicCategory, 19);
|
sl@0
|
513 |
}
|
sl@0
|
514 |
}
|
sl@0
|
515 |
|
sl@0
|
516 |
/**
|
sl@0
|
517 |
@SYMTestCaseID
|
sl@0
|
518 |
GRAPHICS-DIRECTGDI-PANIC-0008
|
sl@0
|
519 |
|
sl@0
|
520 |
@SYMTestPriority
|
sl@0
|
521 |
Medium
|
sl@0
|
522 |
|
sl@0
|
523 |
@SYMPREQ
|
sl@0
|
524 |
PREQ39
|
sl@0
|
525 |
|
sl@0
|
526 |
@SYMREQ
|
sl@0
|
527 |
REQ9195
|
sl@0
|
528 |
REQ9201
|
sl@0
|
529 |
REQ9202
|
sl@0
|
530 |
REQ9222
|
sl@0
|
531 |
REQ9223
|
sl@0
|
532 |
REQ9236
|
sl@0
|
533 |
REQ9237
|
sl@0
|
534 |
|
sl@0
|
535 |
@SYMTestCaseDesc
|
sl@0
|
536 |
Make sure a panic occurs when calling SetBrushStyle() with EPatternedBrush when no brush pattern has been set.
|
sl@0
|
537 |
|
sl@0
|
538 |
@SYMTestActions
|
sl@0
|
539 |
Set brush style to EPatternedBrush.
|
sl@0
|
540 |
|
sl@0
|
541 |
@SYMTestExpectedResults
|
sl@0
|
542 |
It should panic with panic code DGDI 9, EDirectGdiBrushPatternNotSet.
|
sl@0
|
543 |
|
sl@0
|
544 |
@SYMTestStatus
|
sl@0
|
545 |
Implemented
|
sl@0
|
546 |
*/
|
sl@0
|
547 |
void CTPanicTests::TestBrushPatternNotSetL()
|
sl@0
|
548 |
{
|
sl@0
|
549 |
if(iUseDirectGdi)
|
sl@0
|
550 |
{
|
sl@0
|
551 |
ResetGc();
|
sl@0
|
552 |
iGc->SetBrushStyle(DirectGdi::EPatternedBrush);
|
sl@0
|
553 |
}
|
sl@0
|
554 |
else //BitGDI
|
sl@0
|
555 |
User::Panic( KPanicCategory, 9);
|
sl@0
|
556 |
}
|
sl@0
|
557 |
|
sl@0
|
558 |
/**
|
sl@0
|
559 |
Override of base class virtual
|
sl@0
|
560 |
@leave Gets system wide error code
|
sl@0
|
561 |
@return - TVerdict code
|
sl@0
|
562 |
*/
|
sl@0
|
563 |
TVerdict CTPanicTests::doTestStepPreambleL()
|
sl@0
|
564 |
{
|
sl@0
|
565 |
CTDirectGdiStepBase::doTestStepPreambleL();
|
sl@0
|
566 |
return TestStepResult();
|
sl@0
|
567 |
}
|
sl@0
|
568 |
|
sl@0
|
569 |
/**
|
sl@0
|
570 |
Override of base class pure virtual
|
sl@0
|
571 |
Our implementation only gets called if the base class doTestStepPreambleL() did
|
sl@0
|
572 |
not leave. That being the case, the current test result value will be EPass.
|
sl@0
|
573 |
@leave Gets system wide error code
|
sl@0
|
574 |
@return TVerdict code
|
sl@0
|
575 |
*/
|
sl@0
|
576 |
TVerdict CTPanicTests::doTestStepL()
|
sl@0
|
577 |
{
|
sl@0
|
578 |
// Test for each pixel format
|
sl@0
|
579 |
for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--)
|
sl@0
|
580 |
{
|
sl@0
|
581 |
iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex];
|
sl@0
|
582 |
SetTargetL(iTestParams.iTargetPixelFormat);
|
sl@0
|
583 |
RunTestsL();
|
sl@0
|
584 |
RunOomTestsL();
|
sl@0
|
585 |
}
|
sl@0
|
586 |
|
sl@0
|
587 |
return TestStepResult();
|
sl@0
|
588 |
}
|
sl@0
|
589 |
|
sl@0
|
590 |
/**
|
sl@0
|
591 |
Override of base class pure virtual
|
sl@0
|
592 |
Lists the tests to be run
|
sl@0
|
593 |
*/
|
sl@0
|
594 |
void CTPanicTests::RunTestsL()
|
sl@0
|
595 |
{
|
sl@0
|
596 |
INFO_PRINTF1(_L("DirectGdi Panic Tests" ));
|
sl@0
|
597 |
TInt aCurTestCase;
|
sl@0
|
598 |
//Read the case number from the ini file
|
sl@0
|
599 |
TBool res = GetIntFromConfig(ConfigSection(), KCaseNumber, aCurTestCase);
|
sl@0
|
600 |
if(!res)
|
sl@0
|
601 |
{
|
sl@0
|
602 |
return ;
|
sl@0
|
603 |
}
|
sl@0
|
604 |
SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
605 |
switch(aCurTestCase)
|
sl@0
|
606 |
{
|
sl@0
|
607 |
case 1:
|
sl@0
|
608 |
INFO_PRINTF1(_L("TestContextNotActivatedL\n"));
|
sl@0
|
609 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0001"));
|
sl@0
|
610 |
TestContextNotActivatedL();
|
sl@0
|
611 |
break;
|
sl@0
|
612 |
case 2:
|
sl@0
|
613 |
INFO_PRINTF1(_L("TestFontNotSetL\r\n"));
|
sl@0
|
614 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0002"));
|
sl@0
|
615 |
TestFontNotSetL();
|
sl@0
|
616 |
break;
|
sl@0
|
617 |
case 3:
|
sl@0
|
618 |
INFO_PRINTF1(_L("TestInvalidTargetL\r\n"));
|
sl@0
|
619 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0003"));
|
sl@0
|
620 |
TestInvalidTargetL();
|
sl@0
|
621 |
break;
|
sl@0
|
622 |
case 4:
|
sl@0
|
623 |
INFO_PRINTF1(_L("TestImageInvalidTargetHandleL\r\n"));
|
sl@0
|
624 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0004"));
|
sl@0
|
625 |
TestImageInvalidTargetHandleL();
|
sl@0
|
626 |
break;
|
sl@0
|
627 |
case 5:
|
sl@0
|
628 |
INFO_PRINTF1(_L("TestImageTargetActivatedTwiceL\r\n"));
|
sl@0
|
629 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0005"));
|
sl@0
|
630 |
TestImageTargetActivatedTwiceL();
|
sl@0
|
631 |
break;
|
sl@0
|
632 |
case 6:
|
sl@0
|
633 |
INFO_PRINTF1(_L("TestImageSourceActivatedTwiceL\r\n"));
|
sl@0
|
634 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0006"));
|
sl@0
|
635 |
TestImageSourceActivatedTwiceL();
|
sl@0
|
636 |
break;
|
sl@0
|
637 |
case 7:
|
sl@0
|
638 |
INFO_PRINTF1(_L("TestDrawableSourceActivatedTwiceL\r\n"));
|
sl@0
|
639 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0007"));
|
sl@0
|
640 |
TestDrawableSourceActivatedTwiceL();
|
sl@0
|
641 |
break;
|
sl@0
|
642 |
case 8:
|
sl@0
|
643 |
INFO_PRINTF1(_L("TestBrushPatternNotSetL\r\n"));
|
sl@0
|
644 |
SetTestStepID(_L("GRAPHICS-DIRECTGDI-PANIC-0008"));
|
sl@0
|
645 |
TestBrushPatternNotSetL();
|
sl@0
|
646 |
break;
|
sl@0
|
647 |
}
|
sl@0
|
648 |
RecordTestResultL();
|
sl@0
|
649 |
}
|