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