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