sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include "FNTSTD.H"
|
sl@0
|
21 |
#include "t_linkedfontscapability.h"
|
sl@0
|
22 |
#include <hal.h>
|
sl@0
|
23 |
#include <linkedfonts.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
/**
|
sl@0
|
26 |
@file
|
sl@0
|
27 |
|
sl@0
|
28 |
@SYMPurpose This file is used for tests to check the security capabilities
|
sl@0
|
29 |
of the the calls to the font and bitmap server regarding linked fonts
|
sl@0
|
30 |
|
sl@0
|
31 |
Registering a linked font requires write device data. Fetching a linked
|
sl@0
|
32 |
font requires read device data.
|
sl@0
|
33 |
|
sl@0
|
34 |
The function uses an ini file to indicate to this file what tests should be run.
|
sl@0
|
35 |
There are 3 tests, read and write, read, write. It is important to register a
|
sl@0
|
36 |
the linked font test first so that it can be fetched. The test script does this by
|
sl@0
|
37 |
calling tests which do not panic, initially.
|
sl@0
|
38 |
|
sl@0
|
39 |
*/
|
sl@0
|
40 |
_LIT(KLinkedFontsCapabilityFont,"CapabilityTestFnt");
|
sl@0
|
41 |
_LIT(KLinkedFontsCaseNumber,"CaseNumber");
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
void CTLinkedFontsCapability::TestRegisterL()
|
sl@0
|
46 |
{
|
sl@0
|
47 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iBitmapDevice);
|
sl@0
|
48 |
CleanupStack::PushL(store);
|
sl@0
|
49 |
|
sl@0
|
50 |
// Create typeface to be linked
|
sl@0
|
51 |
CLinkedTypefaceSpecification *typefaceSpec;
|
sl@0
|
52 |
typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedFontsCapabilityFont);
|
sl@0
|
53 |
|
sl@0
|
54 |
CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
|
sl@0
|
55 |
typefaceSpec->AddLinkedTypefaceGroupL(*group1);
|
sl@0
|
56 |
CleanupStack::Pop();
|
sl@0
|
57 |
|
sl@0
|
58 |
// Add first typeface
|
sl@0
|
59 |
CLinkedTypefaceElementSpec *elementSpec1;
|
sl@0
|
60 |
_LIT(KLinkedTypefaceTT, "DejaVu Sans Condensed");
|
sl@0
|
61 |
elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 1);
|
sl@0
|
62 |
elementSpec1->SetCanonical(ETrue);
|
sl@0
|
63 |
|
sl@0
|
64 |
typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
|
sl@0
|
65 |
CleanupStack::Pop(1, elementSpec1);
|
sl@0
|
66 |
|
sl@0
|
67 |
// Now try regstering the linked typeface
|
sl@0
|
68 |
TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
|
sl@0
|
69 |
CleanupStack::PopAndDestroy(2, store);
|
sl@0
|
70 |
|
sl@0
|
71 |
if (ret!=KErrAlreadyExists)
|
sl@0
|
72 |
{
|
sl@0
|
73 |
User::LeaveIfError(ret);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
}
|
sl@0
|
76 |
|
sl@0
|
77 |
void CTLinkedFontsCapability::CheckLinkedFontsRasterizerInstalledL()
|
sl@0
|
78 |
{
|
sl@0
|
79 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iBitmapDevice);
|
sl@0
|
80 |
CleanupStack::PushL(store);
|
sl@0
|
81 |
|
sl@0
|
82 |
// Create typeface to be linked
|
sl@0
|
83 |
CLinkedTypefaceSpecification *typefaceSpec;
|
sl@0
|
84 |
typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedFontsCapabilityFont);
|
sl@0
|
85 |
|
sl@0
|
86 |
CLinkedTypefaceGroup* group1 = CLinkedTypefaceGroup::NewLC(1);
|
sl@0
|
87 |
typefaceSpec->AddLinkedTypefaceGroupL(*group1);
|
sl@0
|
88 |
CleanupStack::Pop();
|
sl@0
|
89 |
|
sl@0
|
90 |
// Add first typeface
|
sl@0
|
91 |
CLinkedTypefaceElementSpec *elementSpec1;
|
sl@0
|
92 |
_LIT(KLinkedTypefaceTT, "DejaVu Sans Condensed");
|
sl@0
|
93 |
elementSpec1 = CLinkedTypefaceElementSpec::NewLC(KLinkedTypefaceTT, 1);
|
sl@0
|
94 |
elementSpec1->SetCanonical(ETrue);
|
sl@0
|
95 |
|
sl@0
|
96 |
typefaceSpec->AddTypefaceAtBackL(*elementSpec1);
|
sl@0
|
97 |
CleanupStack::Pop(1, elementSpec1);
|
sl@0
|
98 |
|
sl@0
|
99 |
// Now try regstering the linked typeface
|
sl@0
|
100 |
TRAPD(ret, typefaceSpec->RegisterLinkedTypefaceL(*store));
|
sl@0
|
101 |
CleanupStack::PopAndDestroy(2, store);
|
sl@0
|
102 |
|
sl@0
|
103 |
switch (ret)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
case KErrAlreadyExists:
|
sl@0
|
106 |
case KErrNone:
|
sl@0
|
107 |
iHaveRasterizer = ETrue;
|
sl@0
|
108 |
default:
|
sl@0
|
109 |
break;
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
if (!iHaveRasterizer)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
INFO_PRINTF1(_L("Linked fonts capability: no linked fonts rasterizer found"));
|
sl@0
|
115 |
}
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
TBool CTLinkedFontsCapability::LinkedFontsRasterizerPresent()
|
sl@0
|
119 |
{
|
sl@0
|
120 |
return iHaveRasterizer;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|
sl@0
|
123 |
|
sl@0
|
124 |
void CTLinkedFontsCapability::TestFetchL()
|
sl@0
|
125 |
{
|
sl@0
|
126 |
CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iBitmapDevice);
|
sl@0
|
127 |
CleanupStack::PushL(store);
|
sl@0
|
128 |
|
sl@0
|
129 |
CLinkedTypefaceSpecification *typefaceSpec;
|
sl@0
|
130 |
typefaceSpec = CLinkedTypefaceSpecification::NewLC(KLinkedFontsCapabilityFont);
|
sl@0
|
131 |
|
sl@0
|
132 |
typefaceSpec->FetchLinkedTypefaceSpecificationL(*store);
|
sl@0
|
133 |
|
sl@0
|
134 |
CleanupStack::PopAndDestroy(2, store);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
|
sl@0
|
137 |
CTLinkedFontsCapability::~CTLinkedFontsCapability()
|
sl@0
|
138 |
{
|
sl@0
|
139 |
delete iGc;
|
sl@0
|
140 |
delete iBitmapDevice;
|
sl@0
|
141 |
delete iBitmap;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
CTLinkedFontsCapability::CTLinkedFontsCapability(CTestStep *aStep):
|
sl@0
|
145 |
CTGraphicsBase(aStep),
|
sl@0
|
146 |
iHaveRasterizer(EFalse)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
/** Create the screen device.
|
sl@0
|
151 |
@param aMode display mode for which device has to be created
|
sl@0
|
152 |
*/
|
sl@0
|
153 |
void CTLinkedFontsCapability::CreateBitmapDeviceL(TDisplayMode aMode)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
iBitmap = new(ELeave) CFbsBitmap;
|
sl@0
|
156 |
//Considering the intersection of the screen size for both hw and emulator so that same
|
sl@0
|
157 |
//baselined hash can be used to test for both
|
sl@0
|
158 |
iBitmap->Create(TSize(40, 40), aMode); //small, bitmap not used
|
sl@0
|
159 |
iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);
|
sl@0
|
160 |
User::LeaveIfError(iBitmapDevice->CreateContext((CGraphicsContext*&)iGc));
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
/**
|
sl@0
|
164 |
@SYMTestCaseID GRAPHICS-FNTSTORE-LINKEDFONTS-0110
|
sl@0
|
165 |
|
sl@0
|
166 |
@SYMTestPriority Critical
|
sl@0
|
167 |
|
sl@0
|
168 |
@SYMPREQ PREQ2146
|
sl@0
|
169 |
|
sl@0
|
170 |
@SYMREQ REQ10924, REQ10925, REQ10926
|
sl@0
|
171 |
|
sl@0
|
172 |
@SYMTestCaseDesc
|
sl@0
|
173 |
Checks security capabilities for linked fonts
|
sl@0
|
174 |
|
sl@0
|
175 |
@SYMTestActions
|
sl@0
|
176 |
1 - Run the test case with read device data and write device data
|
sl@0
|
177 |
2 - Run the test case with write device data
|
sl@0
|
178 |
3 - Run the test case with read device data
|
sl@0
|
179 |
4 - Run the test case with no capabilities
|
sl@0
|
180 |
|
sl@0
|
181 |
@SYMTestExpectedResults
|
sl@0
|
182 |
1- A linked font can be registered or returns KErrAlreadyExists and linked fonts can be fetched.
|
sl@0
|
183 |
2- Registering a linked font fails with panic E32USER-CBase panic 47, and linked fonts can be fetched.
|
sl@0
|
184 |
3- Registering a linked font succeeds or returns KErrAlreadyExists and fetching a linked font fail with panic E32USER-CBase panic 47.
|
sl@0
|
185 |
4- Registering a linked font fails with panic E32USER-CBase panic 47. Fetching a linked font fails with panic E32USER-CBase panic 47.
|
sl@0
|
186 |
|
sl@0
|
187 |
*/
|
sl@0
|
188 |
void CTLinkedFontsCapability::RunTestCaseL(TInt /*aCurTestCase*/)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
INFO_PRINTF1(_L("Linked fonts capability tests" ));
|
sl@0
|
191 |
TInt curTestCase;
|
sl@0
|
192 |
//Read the case number from the ini file
|
sl@0
|
193 |
TBool res = iStep->GetIntFromConfig(iStep->ConfigSection(), KLinkedFontsCaseNumber, curTestCase);
|
sl@0
|
194 |
if(!res)
|
sl@0
|
195 |
{
|
sl@0
|
196 |
TEST(EFalse);
|
sl@0
|
197 |
return ;
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
CreateBitmapDeviceL(EColor16MU);
|
sl@0
|
201 |
TInt err=KErrNone;
|
sl@0
|
202 |
TInt err2=KErrNone;
|
sl@0
|
203 |
|
sl@0
|
204 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
205 |
|
sl@0
|
206 |
switch (curTestCase)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
case 1:
|
sl@0
|
209 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0110"));
|
sl@0
|
210 |
CheckLinkedFontsRasterizerInstalledL();
|
sl@0
|
211 |
break;
|
sl@0
|
212 |
case 2:
|
sl@0
|
213 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0110"));
|
sl@0
|
214 |
if (LinkedFontsRasterizerPresent())
|
sl@0
|
215 |
{
|
sl@0
|
216 |
TestRegisterL();
|
sl@0
|
217 |
TestFetchL();
|
sl@0
|
218 |
}
|
sl@0
|
219 |
break;
|
sl@0
|
220 |
case 3:
|
sl@0
|
221 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0110"));
|
sl@0
|
222 |
if (LinkedFontsRasterizerPresent())
|
sl@0
|
223 |
{
|
sl@0
|
224 |
TestRegisterL();//write only
|
sl@0
|
225 |
}
|
sl@0
|
226 |
break;
|
sl@0
|
227 |
case 4:
|
sl@0
|
228 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0110"));
|
sl@0
|
229 |
if (LinkedFontsRasterizerPresent())
|
sl@0
|
230 |
{
|
sl@0
|
231 |
TestFetchL();//read only
|
sl@0
|
232 |
}
|
sl@0
|
233 |
break;
|
sl@0
|
234 |
|
sl@0
|
235 |
//following are similar to tests 2-4, but leaves if no permission to access the capabilities
|
sl@0
|
236 |
case 5:
|
sl@0
|
237 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0110"));
|
sl@0
|
238 |
if(LinkedFontsRasterizerPresent())
|
sl@0
|
239 |
{
|
sl@0
|
240 |
TRAP(err,TestRegisterL());
|
sl@0
|
241 |
TRAP(err2, TestFetchL());
|
sl@0
|
242 |
TEST((err == KErrPermissionDenied)&&(err2 == KErrPermissionDenied));
|
sl@0
|
243 |
}
|
sl@0
|
244 |
break;
|
sl@0
|
245 |
case 6:
|
sl@0
|
246 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0110"));
|
sl@0
|
247 |
if(LinkedFontsRasterizerPresent())
|
sl@0
|
248 |
{
|
sl@0
|
249 |
TRAP(err,TestRegisterL());//write only
|
sl@0
|
250 |
TEST(err == KErrPermissionDenied);
|
sl@0
|
251 |
}
|
sl@0
|
252 |
break;
|
sl@0
|
253 |
case 7:
|
sl@0
|
254 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(_L("GRAPHICS-FNTSTORE-LINKEDFONTS-0110"));
|
sl@0
|
255 |
if(LinkedFontsRasterizerPresent())
|
sl@0
|
256 |
{
|
sl@0
|
257 |
TRAP(err, TestFetchL());//read only
|
sl@0
|
258 |
TEST(err == KErrPermissionDenied);
|
sl@0
|
259 |
}
|
sl@0
|
260 |
break;
|
sl@0
|
261 |
default:
|
sl@0
|
262 |
{
|
sl@0
|
263 |
((CTLinkedFontsCapabilityStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
264 |
((CTLinkedFontsCapabilityStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
265 |
TEST(EFalse); //nothing should have the default value
|
sl@0
|
266 |
break;
|
sl@0
|
267 |
}
|
sl@0
|
268 |
}
|
sl@0
|
269 |
((CTLinkedFontsCapabilityStep*)iStep)->RecordTestResultL();
|
sl@0
|
270 |
TEST(ETrue);
|
sl@0
|
271 |
((CTLinkedFontsCapabilityStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
272 |
TestComplete();
|
sl@0
|
273 |
}
|
sl@0
|
274 |
|
sl@0
|
275 |
__CONSTRUCT_STEP__(LinkedFontsCapability)
|
sl@0
|
276 |
|