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 |
/**
|
sl@0
|
17 |
@file
|
sl@0
|
18 |
@test
|
sl@0
|
19 |
@internalComponent - Internal Symbian test code
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "tsgdrawablegeneric.h"
|
sl@0
|
23 |
#include <graphics/sgresourceinternal.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
CTSgDrawableGeneric::CTSgDrawableGeneric()
|
sl@0
|
26 |
{
|
sl@0
|
27 |
INFO_PRINTF1(_L("Graphics resource component test - RSgDrawable Generic Tests.\r\n"));
|
sl@0
|
28 |
}
|
sl@0
|
29 |
|
sl@0
|
30 |
CTSgDrawableGeneric::~CTSgDrawableGeneric()
|
sl@0
|
31 |
{
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
/**
|
sl@0
|
35 |
Overrides of base class pure virtual
|
sl@0
|
36 |
Our implementation only gets called if the base class doTestStepPreambleL() did
|
sl@0
|
37 |
not leave. That being the case, the current test result value will be EPass.
|
sl@0
|
38 |
@leave Gets system wide error code
|
sl@0
|
39 |
@return TVerdict code
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
TVerdict CTSgDrawableGeneric::doTestStepL()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
SetTestStepID(_L("GRAPHICS-RESOURCE-0013"));
|
sl@0
|
44 |
INFO_PRINTF1(_L("Opening an image in RSgDrawable.\r\n"));
|
sl@0
|
45 |
TestOpenImageAsDrawableL();
|
sl@0
|
46 |
RecordTestResultL();
|
sl@0
|
47 |
|
sl@0
|
48 |
SetTestStepID(_L("GRAPHICS-RESOURCE-0014"));
|
sl@0
|
49 |
INFO_PRINTF1(_L("Retrieving drawable id of an RSgDrawable object.\r\n"));
|
sl@0
|
50 |
TestGetDrawableDrawableIdL();
|
sl@0
|
51 |
RecordTestResultL();
|
sl@0
|
52 |
|
sl@0
|
53 |
SetTestStepID(_L("GRAPHICS-RESOURCE-0032"));
|
sl@0
|
54 |
INFO_PRINTF1(_L("RSgDrawable::Open() with invalid parameters.\r\n"));
|
sl@0
|
55 |
TestOpenDrawableInvalidL();
|
sl@0
|
56 |
RecordTestResultL();
|
sl@0
|
57 |
|
sl@0
|
58 |
SetTestStepID(_L("GRAPHICS-RESOURCE-0033"));
|
sl@0
|
59 |
INFO_PRINTF1(_L("Releasing reference to the image in RSgDrawable without first opening it.\r\n"));
|
sl@0
|
60 |
TestCloseDrawableWithoutOpenL();
|
sl@0
|
61 |
RecordTestResultL();
|
sl@0
|
62 |
|
sl@0
|
63 |
#ifdef _DEBUG
|
sl@0
|
64 |
/**
|
sl@0
|
65 |
@SYMTestCaseID GRAPHICS-RESOURCE-0081
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
SetTestStepID(_L("GRAPHICS-RESOURCE-0081"));
|
sl@0
|
68 |
INFO_PRINTF1(_L("RSgDrawable generic out of memory tests.\r\n"));
|
sl@0
|
69 |
TestOOM();
|
sl@0
|
70 |
RecordTestResultL();
|
sl@0
|
71 |
|
sl@0
|
72 |
SetTestStepID(_L("GRAPHICS-RESOURCE-0080"));
|
sl@0
|
73 |
INFO_PRINTF1(_L("RSgDrawable generic panic test - Open() when the driver is not initialised.\r\n"));
|
sl@0
|
74 |
TestPanicDrawableOpenNoDriverL();
|
sl@0
|
75 |
RecordTestResultL();
|
sl@0
|
76 |
#else
|
sl@0
|
77 |
INFO_PRINTF1(_L("Warning: Skipping the panic tests in release build. \r\n"));
|
sl@0
|
78 |
#endif
|
sl@0
|
79 |
|
sl@0
|
80 |
return TestStepResult();
|
sl@0
|
81 |
}
|
sl@0
|
82 |
|
sl@0
|
83 |
|
sl@0
|
84 |
/**
|
sl@0
|
85 |
@SYMTestCaseID GRAPHICS-RESOURCE-0013
|
sl@0
|
86 |
@SYMTestCaseDesc Opens an RSgImage as an RSgDrawable.
|
sl@0
|
87 |
@SYMPREQ PREQ39
|
sl@0
|
88 |
@SYMREQ REQ9225
|
sl@0
|
89 |
@SYMREQ REQ9224
|
sl@0
|
90 |
@SYMREQ REQ9233
|
sl@0
|
91 |
@SYMREQ REQ9234
|
sl@0
|
92 |
@SYMFssID RSgImage::Id()\n
|
sl@0
|
93 |
RSgDrawable::Open(const TSgDrawableId&)
|
sl@0
|
94 |
@SYMTestPriority Critical
|
sl@0
|
95 |
@SYMTestType Unit Test
|
sl@0
|
96 |
@SYMTestPurpose To ensure an RSgDrawable object can reference an image.
|
sl@0
|
97 |
@SYMTestActions Initialise the graphics resource component. Create an image. Declare an
|
sl@0
|
98 |
RSgDrawable object. Call Open() on the object with the resource ID of the
|
sl@0
|
99 |
image.
|
sl@0
|
100 |
@SYMTestExpectedResults The function should return KErrNone. The RSgDrawable now references an
|
sl@0
|
101 |
image.
|
sl@0
|
102 |
@SYMTestStatus Implemented
|
sl@0
|
103 |
*/
|
sl@0
|
104 |
void CTSgDrawableGeneric::TestOpenImageAsDrawableL()
|
sl@0
|
105 |
{
|
sl@0
|
106 |
TestOpenDriverL();
|
sl@0
|
107 |
RSgImage image;
|
sl@0
|
108 |
CreateImageL(image);
|
sl@0
|
109 |
CleanupClosePushL(image);
|
sl@0
|
110 |
const TSgDrawableId id = image.Id();
|
sl@0
|
111 |
TSgImageInfo imageinfo;
|
sl@0
|
112 |
image.GetInfo(imageinfo);
|
sl@0
|
113 |
|
sl@0
|
114 |
//opening an image as a drawable in the current thread
|
sl@0
|
115 |
RSgImage drawable;
|
sl@0
|
116 |
TEST(drawable.IsNull());
|
sl@0
|
117 |
CheckErrorL(KErrNone, drawable.Open(id), (TText8*)__FILE__, __LINE__);
|
sl@0
|
118 |
TEST(!drawable.IsNull());
|
sl@0
|
119 |
drawable.Close();
|
sl@0
|
120 |
|
sl@0
|
121 |
//opening an image as a drawable in another thread in the same process
|
sl@0
|
122 |
TSgresTestInfo threadInfo = {id, imageinfo, 0, ESgresSecondThreadOpenDrawable};
|
sl@0
|
123 |
TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
|
sl@0
|
124 |
User::LeaveIfError(testResult);
|
sl@0
|
125 |
TEST(testResult & EFirstTestPassed);
|
sl@0
|
126 |
TEST(testResult & ESecondTestPassed);
|
sl@0
|
127 |
TEST(testResult & EThirdTestPassed);
|
sl@0
|
128 |
|
sl@0
|
129 |
//opening an image as drawbale in a different process
|
sl@0
|
130 |
TSgresTestInfo processInfo = {id, imageinfo, 0, ESgresSecondProcessOpenDrawable};
|
sl@0
|
131 |
testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);
|
sl@0
|
132 |
User::LeaveIfError(testResult);
|
sl@0
|
133 |
TEST(testResult & EFirstTestPassed);
|
sl@0
|
134 |
TEST(testResult & ESecondTestPassed);
|
sl@0
|
135 |
TEST(testResult & EThirdTestPassed);
|
sl@0
|
136 |
|
sl@0
|
137 |
CleanupStack::PopAndDestroy();
|
sl@0
|
138 |
TestCloseDriver();
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
/**
|
sl@0
|
142 |
@SYMTestCaseID GRAPHICS-RESOURCE-0014
|
sl@0
|
143 |
@SYMTestCaseDesc Retrieves drawable id of an RSgDrawable.
|
sl@0
|
144 |
@SYMPREQ PREQ39
|
sl@0
|
145 |
@SYMREQ REQ9225
|
sl@0
|
146 |
@SYMREQ REQ9224
|
sl@0
|
147 |
@SYMREQ REQ9233
|
sl@0
|
148 |
@SYMREQ REQ9234
|
sl@0
|
149 |
@SYMFssID RSgImage::Id()\n
|
sl@0
|
150 |
RSgDrawable::Open(const TSgDrawableId&)\n
|
sl@0
|
151 |
RSgDrawable::Id()
|
sl@0
|
152 |
@SYMTestPriority Critical
|
sl@0
|
153 |
@SYMTestType Unit Test
|
sl@0
|
154 |
@SYMTestPurpose To ensure the globally unique drawable id of the RSgDrawable object can be retrieved.
|
sl@0
|
155 |
@SYMTestActions Initialise the graphics resource component. Create an image. Call Id() on the image.
|
sl@0
|
156 |
Construct an RSgDrawable object and open an image in it. Call Id() on the
|
sl@0
|
157 |
RSgDrawable object. Compare the two ids.
|
sl@0
|
158 |
@SYMTestExpectedResults The two drawable ids should be identical.
|
sl@0
|
159 |
@SYMTestStatus Implemented
|
sl@0
|
160 |
*/
|
sl@0
|
161 |
void CTSgDrawableGeneric::TestGetDrawableDrawableIdL()
|
sl@0
|
162 |
{
|
sl@0
|
163 |
TestOpenDriverL();
|
sl@0
|
164 |
RSgImage image;
|
sl@0
|
165 |
CreateImageL(image);
|
sl@0
|
166 |
CleanupClosePushL(image);
|
sl@0
|
167 |
TSgDrawableId id1 = image.Id();
|
sl@0
|
168 |
TEST(id1 != KSgNullDrawableId);
|
sl@0
|
169 |
|
sl@0
|
170 |
RSgDrawable drawable;
|
sl@0
|
171 |
TEST(KErrNone == drawable.Open(id1));
|
sl@0
|
172 |
TSgDrawableId id2 = drawable.Id();
|
sl@0
|
173 |
TEST(id2 != KSgNullDrawableId);
|
sl@0
|
174 |
TEST(id1 == id2);
|
sl@0
|
175 |
|
sl@0
|
176 |
drawable.Close();
|
sl@0
|
177 |
CleanupStack::PopAndDestroy();
|
sl@0
|
178 |
TestCloseDriver();
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
|
sl@0
|
182 |
/**
|
sl@0
|
183 |
@SYMTestCaseID GRAPHICS-RESOURCE-0032
|
sl@0
|
184 |
@SYMTestCaseDesc Calls RSgDrawable::Open() with invalid parameters.
|
sl@0
|
185 |
@SYMPREQ PREQ39
|
sl@0
|
186 |
@SYMREQ REQ9225
|
sl@0
|
187 |
@SYMREQ REQ9224
|
sl@0
|
188 |
@SYMREQ REQ9233
|
sl@0
|
189 |
@SYMREQ REQ9234
|
sl@0
|
190 |
@SYMFssID RSgImage::Id()\n
|
sl@0
|
191 |
RSgDrawable::Open(const TSgDrawableId&)
|
sl@0
|
192 |
@SYMTestPriority Critical
|
sl@0
|
193 |
@SYMTestType Unit Test
|
sl@0
|
194 |
@SYMTestPurpose To check the correct error codes are returned if Open() uses invalid parameters.
|
sl@0
|
195 |
@SYMTestActions Initialise the graphics resource component. Create an image. Declare an RSgDrawable
|
sl@0
|
196 |
object. Call Open() with:\n
|
sl@0
|
197 |
\t 1. null drawable id\n
|
sl@0
|
198 |
\t 2. a non-existing \n
|
sl@0
|
199 |
\t 3. drawable id of a non-sharable image\n
|
sl@0
|
200 |
\t 4. on a RSgDrawable handle that is not null\n
|
sl@0
|
201 |
Do the same tests in a second thread in the same process and in a second process.
|
sl@0
|
202 |
@SYMTestExpectedResults The function should return:\n
|
sl@0
|
203 |
\t 1. KErrArgument\n
|
sl@0
|
204 |
\t 2. KErrNotFound\n
|
sl@0
|
205 |
\t 3. KErrNone in the same process and KErrPermissionDenied or KErrNotFound in the second process\n
|
sl@0
|
206 |
\t 4. KErrInUse
|
sl@0
|
207 |
@SYMTestStatus Implemented
|
sl@0
|
208 |
*/
|
sl@0
|
209 |
void CTSgDrawableGeneric::TestOpenDrawableInvalidL()
|
sl@0
|
210 |
{
|
sl@0
|
211 |
TestOpenDriverL();
|
sl@0
|
212 |
//same thread
|
sl@0
|
213 |
// null drawable id
|
sl@0
|
214 |
RSgDrawable drawable;
|
sl@0
|
215 |
CheckErrorL(KErrArgument, drawable.Open(KSgNullDrawableId), (TText8*)__FILE__, __LINE__);
|
sl@0
|
216 |
drawable.Close();
|
sl@0
|
217 |
|
sl@0
|
218 |
// non-existing drawable id
|
sl@0
|
219 |
TSgDrawableId fakeid = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
|
sl@0
|
220 |
CheckErrorL(KErrNotFound, drawable.Open(fakeid), (TText8*)__FILE__, __LINE__);
|
sl@0
|
221 |
drawable.Close();
|
sl@0
|
222 |
|
sl@0
|
223 |
//create a non-sharable image
|
sl@0
|
224 |
TSgImageInfo info;
|
sl@0
|
225 |
info.iSizeInPixels = TSize(8, 8);
|
sl@0
|
226 |
info.iUsage = ESgUsageDirectGdiTarget;
|
sl@0
|
227 |
info.iPixelFormat = EUidPixelFormatRGB_565;
|
sl@0
|
228 |
info.iCpuAccess = ESgCpuAccessNone;
|
sl@0
|
229 |
info.iShareable = EFalse;
|
sl@0
|
230 |
|
sl@0
|
231 |
RSgImage image;
|
sl@0
|
232 |
CheckErrorL(KErrNone, image.Create(info, KImageData, 16), (TText8*)__FILE__, __LINE__);
|
sl@0
|
233 |
CleanupClosePushL(image);
|
sl@0
|
234 |
const TSgDrawableId id = image.Id();
|
sl@0
|
235 |
|
sl@0
|
236 |
// open a non-sharable image - should succeed
|
sl@0
|
237 |
TEST(KErrNone == drawable.Open(id));
|
sl@0
|
238 |
|
sl@0
|
239 |
// open on a non-null RSgDrawable handle
|
sl@0
|
240 |
TEST(KErrInUse == drawable.Open(id));
|
sl@0
|
241 |
drawable.Close();
|
sl@0
|
242 |
|
sl@0
|
243 |
//different thread in the same process
|
sl@0
|
244 |
TSgresTestInfo threadInfo = {id, info, 0, ESgresSecondThreadOpenDrawableInvalid};
|
sl@0
|
245 |
TInt testResult = CreateSecondThreadAndDoTestL(threadInfo);
|
sl@0
|
246 |
User::LeaveIfError(testResult);
|
sl@0
|
247 |
TEST(testResult & EFirstTestPassed);
|
sl@0
|
248 |
TEST(testResult & ESecondTestPassed);
|
sl@0
|
249 |
TEST(testResult & EThirdTestPassed);
|
sl@0
|
250 |
TEST(testResult & EFourthTestPassed);
|
sl@0
|
251 |
|
sl@0
|
252 |
//different process
|
sl@0
|
253 |
TSgresTestInfo processInfo = {id, info, 0, ESgresSecondProcessOpenDrawableInvalid};
|
sl@0
|
254 |
testResult = CreateSecondProcessAndDoTestL(KSecondProcess, processInfo);
|
sl@0
|
255 |
User::LeaveIfError(testResult);
|
sl@0
|
256 |
TEST(testResult & EFirstTestPassed);
|
sl@0
|
257 |
TEST(testResult & ESecondTestPassed);
|
sl@0
|
258 |
TEST(testResult & EThirdTestPassed);
|
sl@0
|
259 |
TEST(testResult & EFourthTestPassed);
|
sl@0
|
260 |
TEST(testResult & EFifthTestPassed);
|
sl@0
|
261 |
|
sl@0
|
262 |
drawable.Close();
|
sl@0
|
263 |
CleanupStack::PopAndDestroy();
|
sl@0
|
264 |
TestCloseDriver();
|
sl@0
|
265 |
}
|
sl@0
|
266 |
|
sl@0
|
267 |
/**
|
sl@0
|
268 |
@SYMTestCaseID GRAPHICS-RESOURCE-0033
|
sl@0
|
269 |
@SYMTestCaseDesc Closes RSgDrawable without first opening it.
|
sl@0
|
270 |
@SYMPREQ PREQ39
|
sl@0
|
271 |
@SYMREQ REQ9225
|
sl@0
|
272 |
@SYMREQ REQ9224
|
sl@0
|
273 |
@SYMREQ REQ9233
|
sl@0
|
274 |
@SYMREQ REQ9234
|
sl@0
|
275 |
@SYMFssID RSgDrawable::Close()
|
sl@0
|
276 |
@SYMTestPriority Critical
|
sl@0
|
277 |
@SYMTestType Unit Test
|
sl@0
|
278 |
@SYMTestPurpose To check the function does nothing if Open() was not called.
|
sl@0
|
279 |
@SYMTestActions Initialise the graphics resource component. Declare an RSgDrawable object. Call Close().
|
sl@0
|
280 |
@SYMTestExpectedResults The function should not panic or return any error.
|
sl@0
|
281 |
@SYMTestStatus Implemented
|
sl@0
|
282 |
*/
|
sl@0
|
283 |
void CTSgDrawableGeneric::TestCloseDrawableWithoutOpenL()
|
sl@0
|
284 |
{
|
sl@0
|
285 |
TestOpenDriverL();
|
sl@0
|
286 |
RSgDrawable drawable;
|
sl@0
|
287 |
drawable.Close();
|
sl@0
|
288 |
drawable.Close();
|
sl@0
|
289 |
drawable.Close();
|
sl@0
|
290 |
TestCloseDriver();
|
sl@0
|
291 |
}
|
sl@0
|
292 |
|
sl@0
|
293 |
/**
|
sl@0
|
294 |
@SYMTestCaseID GRAPHICS-RESOURCE-0080
|
sl@0
|
295 |
@SYMTestCaseDesc Calls RSgDrawable::Open() when the driver was not initialised.
|
sl@0
|
296 |
@SYMPREQ PREQ39
|
sl@0
|
297 |
@SYMREQ REQ8809
|
sl@0
|
298 |
@SYMREQ REQ9175
|
sl@0
|
299 |
@SYMFssID RSgImage::Open()\n
|
sl@0
|
300 |
@SYMTestPriority Critical
|
sl@0
|
301 |
@SYMTestType Unit Test
|
sl@0
|
302 |
@SYMTestPurpose To ensure calling RSgDrawable::Open() with an uninitialised driver will cause a panic.
|
sl@0
|
303 |
@SYMTestActions Do not Initialise the graphics resource component and call RSgDrawable::Open() in a second thread.
|
sl@0
|
304 |
@SYMTestExpectedResults The function should panic in the second thread with panic code SGRES 5 (ESgPanicNoDriver).
|
sl@0
|
305 |
@SYMTestStatus Implemented
|
sl@0
|
306 |
*/
|
sl@0
|
307 |
void CTSgDrawableGeneric::TestPanicDrawableOpenNoDriverL()
|
sl@0
|
308 |
{
|
sl@0
|
309 |
TSgImageInfo info;
|
sl@0
|
310 |
TSgresTestInfo threadInfo = {KSgNullDrawableId, info, 0, ESgresSecondThreadPanicDrawableOpenNoDriver, ETrue};
|
sl@0
|
311 |
TExitCategoryName exitCategoryName(KSgTestGenericPanicCategory);
|
sl@0
|
312 |
_LIT(KTestName, "TestPanicDrawableOpenNoDriverL");
|
sl@0
|
313 |
CreateSecondThreadAndCheckPanicL(threadInfo, 5, exitCategoryName, KTestName);
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
void CTSgDrawableGeneric::DoMemoryTestsL()
|
sl@0
|
317 |
{
|
sl@0
|
318 |
__UHEAP_MARK; SgDriver::AllocMarkStart();
|
sl@0
|
319 |
TestOpenImageAsDrawableL();
|
sl@0
|
320 |
__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
|
sl@0
|
321 |
|
sl@0
|
322 |
__UHEAP_MARK; SgDriver::AllocMarkStart();
|
sl@0
|
323 |
TestGetDrawableDrawableIdL();
|
sl@0
|
324 |
__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
|
sl@0
|
325 |
|
sl@0
|
326 |
__UHEAP_MARK; SgDriver::AllocMarkStart();
|
sl@0
|
327 |
TestOpenDrawableInvalidL();
|
sl@0
|
328 |
__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
|
sl@0
|
329 |
|
sl@0
|
330 |
__UHEAP_MARK; SgDriver::AllocMarkStart();
|
sl@0
|
331 |
TestCloseDrawableWithoutOpenL();
|
sl@0
|
332 |
__UHEAP_MARKEND; SgDriver::AllocMarkEnd(0);
|
sl@0
|
333 |
}
|