sl@0
|
1 |
// Copyright (c) 2003-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 <e32std.h>
|
sl@0
|
17 |
#include <e32base.h>
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include <f32file.h>
|
sl@0
|
20 |
#include <bautils.h>
|
sl@0
|
21 |
#include <barsc2.h>
|
sl@0
|
22 |
#include <barsread2.h>
|
sl@0
|
23 |
#include <t_compressed_unicode_1.rsg>
|
sl@0
|
24 |
#include <t_compressed_unicode_2.rsg>
|
sl@0
|
25 |
|
sl@0
|
26 |
RTest test(_L("T_RESOURCE_COMPRESSION2"));
|
sl@0
|
27 |
RFs fileServerSession;
|
sl@0
|
28 |
_LIT8(KRscFileHeaderData, "0123456789ABCDEF");
|
sl@0
|
29 |
_LIT(KRomResourceFileHeader, "z:\\system\\data\\RscHeader.bin");
|
sl@0
|
30 |
|
sl@0
|
31 |
LOCAL_D const TPtrC rsc_files[] =
|
sl@0
|
32 |
{
|
sl@0
|
33 |
_L("T_COMPRESSED_UNICODE_1.RSC")
|
sl@0
|
34 |
, _L("T_COMPRESSED_UNICODE_2.RSC")
|
sl@0
|
35 |
, _L("T_DICTIONARY_COMPRESSED_VERSIO_OF_2.RSC")
|
sl@0
|
36 |
, _L("T_CALYPSO_TEST_RESOURCE_FILE_1.RSC")
|
sl@0
|
37 |
, _L("T_NotRscFile.RSC")
|
sl@0
|
38 |
, _L("TRscROMCalypsoComprNewFmt.rsc")
|
sl@0
|
39 |
};
|
sl@0
|
40 |
_LIT(KZDir, "z:\\system\\data\\");
|
sl@0
|
41 |
_LIT(KCDir, "c:\\");
|
sl@0
|
42 |
|
sl@0
|
43 |
LOCAL_C void DeleteDataFile(const TDesC& aFullName)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
// make sure the file is read/write
|
sl@0
|
46 |
TInt err = fileServerSession.SetAtt(aFullName,0, KEntryAttReadOnly);
|
sl@0
|
47 |
if(err != KErrNone)
|
sl@0
|
48 |
{
|
sl@0
|
49 |
RDebug::Print(_L("error changing attributes file = %d"),err);
|
sl@0
|
50 |
}
|
sl@0
|
51 |
// delete the file
|
sl@0
|
52 |
err = BaflUtils::DeleteFile(fileServerSession, aFullName);
|
sl@0
|
53 |
if(err != KErrNone)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
RDebug::Print(_L("error deleting file = %d"),err);
|
sl@0
|
56 |
}
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
LOCAL_C TInt FileSizeL(const TDesC& aFileName)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
RFile file;
|
sl@0
|
62 |
User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead));
|
sl@0
|
63 |
CleanupClosePushL(file);
|
sl@0
|
64 |
TInt size = 0;
|
sl@0
|
65 |
User::LeaveIfError(file.Size(size));
|
sl@0
|
66 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
67 |
return size;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
LOCAL_C void CreateFileFromL(const TDesC& aDestFileName, const TDesC& aSrcFileName)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
RFile destFile;
|
sl@0
|
73 |
RFile srcFile;
|
sl@0
|
74 |
|
sl@0
|
75 |
CleanupClosePushL(destFile);
|
sl@0
|
76 |
CleanupClosePushL(srcFile);
|
sl@0
|
77 |
|
sl@0
|
78 |
BaflUtils::DeleteFile(fileServerSession, aDestFileName);
|
sl@0
|
79 |
User::LeaveIfError(destFile.Create(fileServerSession, aDestFileName, EFileRead | EFileWrite));
|
sl@0
|
80 |
|
sl@0
|
81 |
User::LeaveIfError(srcFile.Open(fileServerSession, aSrcFileName, EFileRead));
|
sl@0
|
82 |
TInt size = 0;
|
sl@0
|
83 |
User::LeaveIfError(srcFile.Size(size));
|
sl@0
|
84 |
HBufC8* buf = HBufC8::NewMaxLC(size);
|
sl@0
|
85 |
TPtr8 ptr = buf->Des();
|
sl@0
|
86 |
srcFile.Read(ptr);
|
sl@0
|
87 |
|
sl@0
|
88 |
destFile.Write(KRscFileHeaderData);
|
sl@0
|
89 |
destFile.Write(ptr);
|
sl@0
|
90 |
|
sl@0
|
91 |
CleanupStack::PopAndDestroy(buf);
|
sl@0
|
92 |
CleanupStack::PopAndDestroy(&srcFile);
|
sl@0
|
93 |
CleanupStack::PopAndDestroy(&destFile);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
LOCAL_C void CreateFileFromL(TDes& aDestFilePath, const TDesC& aDestFileName, const TDesC& aSrcFilePath)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
aDestFilePath.Copy(KCDir);
|
sl@0
|
99 |
aDestFilePath += _L("N_");
|
sl@0
|
100 |
aDestFilePath += aDestFileName;
|
sl@0
|
101 |
CreateFileFromL(aDestFilePath, aSrcFilePath);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
LOCAL_C void Test1L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize);
|
sl@0
|
107 |
test(resourceFile->UidType()==TUidType(TUid::Uid(0x101f4a6b), TUid::Uid(0x000eb205), TUid::Uid(TUint(T_COMPRESSED_UNICODE_1_RESOURCE_1)>>12)));
|
sl@0
|
108 |
HBufC8* resource = NULL;
|
sl@0
|
109 |
RResourceReader resourceReader;
|
sl@0
|
110 |
|
sl@0
|
111 |
resource=resourceFile->AllocReadLC(1);
|
sl@0
|
112 |
test(resource->Length()%sizeof(TText)==0);
|
sl@0
|
113 |
test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("Gruezi miteinander"));
|
sl@0
|
114 |
CleanupStack::PopAndDestroy(resource);
|
sl@0
|
115 |
resource = NULL;
|
sl@0
|
116 |
|
sl@0
|
117 |
resourceReader.OpenLC(resourceFile, 2);
|
sl@0
|
118 |
test(resourceReader.ReadUint16L()==4);
|
sl@0
|
119 |
test(resourceReader.ReadTPtrCL()==_L("Bonjour"));
|
sl@0
|
120 |
test(resourceReader.ReadTPtrCL()==_L("Ni3 hao3"));
|
sl@0
|
121 |
test(resourceReader.ReadTPtrCL()==_L("Konnichiwa"));
|
sl@0
|
122 |
test(resourceReader.ReadTPtrCL()==_L("Zdravstvuit'e"));
|
sl@0
|
123 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
124 |
resource = NULL;
|
sl@0
|
125 |
|
sl@0
|
126 |
resourceReader.OpenLC(resourceFile, 3);
|
sl@0
|
127 |
test(resourceReader.ReadUint16L()==3);
|
sl@0
|
128 |
test(resourceReader.ReadTPtrCL()==_L("Gamarjoba"));
|
sl@0
|
129 |
test(resourceReader.ReadTPtrCL()==_L("Gasou"));
|
sl@0
|
130 |
test(resourceReader.ReadTPtrCL()==_L("Ola"));
|
sl@0
|
131 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
132 |
resource = NULL;
|
sl@0
|
133 |
|
sl@0
|
134 |
resourceReader.OpenLC(resourceFile, 4);
|
sl@0
|
135 |
test(resourceReader.ReadUint16L()==3);
|
sl@0
|
136 |
test(resourceReader.ReadUint8L()==0xbd);
|
sl@0
|
137 |
test(resourceReader.ReadUint8L()==0x5e);
|
sl@0
|
138 |
test(resourceReader.ReadUint8L()==0xf1);
|
sl@0
|
139 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
140 |
resource = NULL;
|
sl@0
|
141 |
|
sl@0
|
142 |
resourceReader.OpenLC(resourceFile, 5);
|
sl@0
|
143 |
test(resourceReader.ReadUint32L()==4);
|
sl@0
|
144 |
test(resourceReader.ReadUint32L()==T_COMPRESSED_UNICODE_1_RESOURCE_5);
|
sl@0
|
145 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
146 |
resource = NULL;
|
sl@0
|
147 |
|
sl@0
|
148 |
resource=resourceFile->AllocReadLC(6);
|
sl@0
|
149 |
test(resource->Length()%sizeof(TText)==0);
|
sl@0
|
150 |
test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("_"));
|
sl@0
|
151 |
CleanupStack::PopAndDestroy(resource);
|
sl@0
|
152 |
resource = NULL;
|
sl@0
|
153 |
|
sl@0
|
154 |
resourceReader.OpenLC(resourceFile, 7);
|
sl@0
|
155 |
test(resourceReader.ReadUint8L()==9);
|
sl@0
|
156 |
test(resourceReader.ReadTPtrCL()==_L("To"));
|
sl@0
|
157 |
test(resourceReader.ReadUint8L()==97);
|
sl@0
|
158 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
159 |
resource = NULL;
|
sl@0
|
160 |
|
sl@0
|
161 |
resourceReader.OpenLC(resourceFile, 8);
|
sl@0
|
162 |
test(resourceReader.ReadUint16L()==999);
|
sl@0
|
163 |
test(resourceReader.ReadTPtrCL()==_L("To"));
|
sl@0
|
164 |
test(resourceReader.ReadUint8L()==79);
|
sl@0
|
165 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
166 |
resource = NULL;
|
sl@0
|
167 |
|
sl@0
|
168 |
resourceReader.OpenLC(resourceFile, 9);
|
sl@0
|
169 |
test(resourceReader.ReadUint16L()==53132);
|
sl@0
|
170 |
test(resourceReader.ReadTPtrCL()==_L("T"));
|
sl@0
|
171 |
test(resourceReader.ReadUint8L()==62);
|
sl@0
|
172 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
173 |
resource = NULL;
|
sl@0
|
174 |
|
sl@0
|
175 |
resourceReader.OpenLC(resourceFile, 10);
|
sl@0
|
176 |
test(resourceReader.ReadInt32L()==1253869);
|
sl@0
|
177 |
test(resourceReader.ReadInt32L()==-986324);
|
sl@0
|
178 |
test(resourceReader.ReadUint32L()==0x600ddea1u);
|
sl@0
|
179 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
180 |
resource = NULL;
|
sl@0
|
181 |
|
sl@0
|
182 |
CleanupStack::PopAndDestroy(resourceFile);
|
sl@0
|
183 |
}
|
sl@0
|
184 |
|
sl@0
|
185 |
LOCAL_C void Test2L(const TDesC& aResourceFileName, TUid aFirstUid, TUint aFileOffset = 0, TInt aFileSize = 0)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize);
|
sl@0
|
188 |
test(resourceFile->UidType()==TUidType(aFirstUid, TUid::Null(), TUid::Uid(TUint(T_COMPRESSED_UNICODE_2_RESOURCE_1)>>12)));
|
sl@0
|
189 |
HBufC8* resource = NULL;
|
sl@0
|
190 |
RResourceReader resourceReader;
|
sl@0
|
191 |
|
sl@0
|
192 |
resourceReader.OpenLC(resourceFile, 1);
|
sl@0
|
193 |
test(resourceReader.ReadUint32L()==4);
|
sl@0
|
194 |
test(resourceReader.ReadUint32L()==T_COMPRESSED_UNICODE_2_RESOURCE_1);
|
sl@0
|
195 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
196 |
resource = NULL;
|
sl@0
|
197 |
|
sl@0
|
198 |
resource=resourceFile->AllocReadLC(2);
|
sl@0
|
199 |
test(resource->Length()%sizeof(TText)==0);
|
sl@0
|
200 |
test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("My program is cool"));
|
sl@0
|
201 |
CleanupStack::PopAndDestroy(resource);
|
sl@0
|
202 |
resource = NULL;
|
sl@0
|
203 |
|
sl@0
|
204 |
resource=resourceFile->AllocReadLC(3);
|
sl@0
|
205 |
test(resource->Length()%sizeof(TText)==0);
|
sl@0
|
206 |
test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("z:\\system\\data\\eikon.mbm"));
|
sl@0
|
207 |
CleanupStack::PopAndDestroy(resource);
|
sl@0
|
208 |
resource = NULL;
|
sl@0
|
209 |
|
sl@0
|
210 |
resourceReader.OpenLC(resourceFile, 4);
|
sl@0
|
211 |
test(resourceReader.ReadInt32L()==9174804);
|
sl@0
|
212 |
test(resourceReader.ReadUint8L()==6);
|
sl@0
|
213 |
test(resourceReader.ReadInt32L()==-6208493);
|
sl@0
|
214 |
test(resourceReader.ReadUint16L()==0x3176);
|
sl@0
|
215 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
216 |
resource = NULL;
|
sl@0
|
217 |
|
sl@0
|
218 |
resourceReader.OpenLC(resourceFile, 5);
|
sl@0
|
219 |
test(resourceReader.ReadInt32L()==-120727);
|
sl@0
|
220 |
test(resourceReader.ReadInt32L()==-82385253);
|
sl@0
|
221 |
test(resourceReader.ReadUint16L()==0x3176);
|
sl@0
|
222 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
223 |
resource = NULL;
|
sl@0
|
224 |
|
sl@0
|
225 |
resourceReader.OpenLC(resourceFile, 6);
|
sl@0
|
226 |
test(resourceReader.ReadUint8L()==2);
|
sl@0
|
227 |
test(resourceReader.ReadTPtrCL()==_L("z:\\system\\data\\uikon.mbm"));
|
sl@0
|
228 |
test(resourceReader.ReadTPtrCL()==_L("z:\\system\\apps\\my_program\\my_program.mbm"));
|
sl@0
|
229 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
230 |
resource = NULL;
|
sl@0
|
231 |
|
sl@0
|
232 |
CleanupStack::PopAndDestroy(resourceFile);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
LOCAL_C void Test3L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
/* This function tests the calypso resoruce file format loading/reading
|
sl@0
|
238 |
* and was derived from the Test1 function above. Therefore the resource
|
sl@0
|
239 |
* file it reads is also derived from the file used in test 1.
|
sl@0
|
240 |
*/
|
sl@0
|
241 |
|
sl@0
|
242 |
CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize);
|
sl@0
|
243 |
HBufC8* resource = NULL;
|
sl@0
|
244 |
RResourceReader resourceReader;
|
sl@0
|
245 |
|
sl@0
|
246 |
resource=resourceFile->AllocReadLC(1);
|
sl@0
|
247 |
test(resource->Length()%sizeof(TText)==0);
|
sl@0
|
248 |
test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("Gruezi miteinander"));
|
sl@0
|
249 |
CleanupStack::PopAndDestroy(resource);
|
sl@0
|
250 |
resource = NULL;
|
sl@0
|
251 |
|
sl@0
|
252 |
resourceReader.OpenLC(resourceFile, 2);
|
sl@0
|
253 |
test(resourceReader.ReadUint16L()==4);
|
sl@0
|
254 |
test(resourceReader.ReadTPtrCL()==_L("Bonjour"));
|
sl@0
|
255 |
test(resourceReader.ReadTPtrCL()==_L("Ni3 hao3"));
|
sl@0
|
256 |
test(resourceReader.ReadTPtrCL()==_L("Konnichiwa"));
|
sl@0
|
257 |
test(resourceReader.ReadTPtrCL()==_L("Zdravstvuit'e"));
|
sl@0
|
258 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
259 |
resource = NULL;
|
sl@0
|
260 |
|
sl@0
|
261 |
resourceReader.OpenLC(resourceFile, 3);
|
sl@0
|
262 |
test(resourceReader.ReadUint16L()==3);
|
sl@0
|
263 |
test(resourceReader.ReadTPtrCL()==_L("Gamarjoba"));
|
sl@0
|
264 |
test(resourceReader.ReadTPtrCL()==_L("Gasou"));
|
sl@0
|
265 |
test(resourceReader.ReadTPtrCL()==_L("Ola"));
|
sl@0
|
266 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
267 |
resource = NULL;
|
sl@0
|
268 |
|
sl@0
|
269 |
resourceReader.OpenLC(resourceFile, 4);
|
sl@0
|
270 |
test(resourceReader.ReadUint16L()==3);
|
sl@0
|
271 |
test(resourceReader.ReadUint8L()==0xbd);
|
sl@0
|
272 |
test(resourceReader.ReadUint8L()==0x5e);
|
sl@0
|
273 |
test(resourceReader.ReadUint8L()==0xf1);
|
sl@0
|
274 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
275 |
resource = NULL;
|
sl@0
|
276 |
|
sl@0
|
277 |
resourceReader.OpenLC(resourceFile, 5);
|
sl@0
|
278 |
test(resourceReader.ReadUint32L()==4);
|
sl@0
|
279 |
test(resourceReader.ReadUint32L()==T_COMPRESSED_UNICODE_1_RESOURCE_5);
|
sl@0
|
280 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
281 |
resource = NULL;
|
sl@0
|
282 |
|
sl@0
|
283 |
resource=resourceFile->AllocReadLC(6);
|
sl@0
|
284 |
test(resource->Length()%sizeof(TText)==0);
|
sl@0
|
285 |
test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("_"));
|
sl@0
|
286 |
CleanupStack::PopAndDestroy(resource);
|
sl@0
|
287 |
resource = NULL;
|
sl@0
|
288 |
|
sl@0
|
289 |
resourceReader.OpenLC(resourceFile, 7);
|
sl@0
|
290 |
test(resourceReader.ReadUint8L()==9);
|
sl@0
|
291 |
test(resourceReader.ReadTPtrCL()==_L("To"));
|
sl@0
|
292 |
test(resourceReader.ReadUint8L()==97);
|
sl@0
|
293 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
294 |
resource = NULL;
|
sl@0
|
295 |
|
sl@0
|
296 |
resourceReader.OpenLC(resourceFile, 8);
|
sl@0
|
297 |
test(resourceReader.ReadUint16L()==999);
|
sl@0
|
298 |
test(resourceReader.ReadTPtrCL()==_L("To"));
|
sl@0
|
299 |
test(resourceReader.ReadUint8L()==79);
|
sl@0
|
300 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
301 |
resource = NULL;
|
sl@0
|
302 |
|
sl@0
|
303 |
resourceReader.OpenLC(resourceFile, 9);
|
sl@0
|
304 |
test(resourceReader.ReadUint16L()==53132);
|
sl@0
|
305 |
test(resourceReader.ReadTPtrCL()==_L("T"));
|
sl@0
|
306 |
test(resourceReader.ReadUint8L()==62);
|
sl@0
|
307 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
308 |
resource = NULL;
|
sl@0
|
309 |
|
sl@0
|
310 |
resourceReader.OpenLC(resourceFile, 10);
|
sl@0
|
311 |
test(resourceReader.ReadInt32L()==1253869);
|
sl@0
|
312 |
test(resourceReader.ReadInt32L()==-986324);
|
sl@0
|
313 |
test(resourceReader.ReadUint32L()==0x600ddea1u);
|
sl@0
|
314 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
315 |
resource = NULL;
|
sl@0
|
316 |
|
sl@0
|
317 |
// reading resource 11 takes some time, as it is long
|
sl@0
|
318 |
// and gets compressed.
|
sl@0
|
319 |
// This is useful for the timing measurements in TestDef044572L()
|
sl@0
|
320 |
resourceReader.OpenLC(resourceFile, 11);
|
sl@0
|
321 |
CleanupStack::PopAndDestroy(1, &resourceReader);
|
sl@0
|
322 |
resource = NULL;
|
sl@0
|
323 |
|
sl@0
|
324 |
CleanupStack::PopAndDestroy(resourceFile);
|
sl@0
|
325 |
}
|
sl@0
|
326 |
|
sl@0
|
327 |
LOCAL_C void Test4L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0)
|
sl@0
|
328 |
{
|
sl@0
|
329 |
/* This function tests the behaviour of bafl when reading a calypso resource file
|
sl@0
|
330 |
* for a signature. Calypso resource files do not have signatures.
|
sl@0
|
331 |
*/
|
sl@0
|
332 |
|
sl@0
|
333 |
CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize);
|
sl@0
|
334 |
|
sl@0
|
335 |
// Need to pass the TInt as required, but doesn't
|
sl@0
|
336 |
// use it. Legacy for BC sake.
|
sl@0
|
337 |
TInt err = KErrNone;
|
sl@0
|
338 |
TRAP(err, resourceFile->ConfirmSignatureL(1));
|
sl@0
|
339 |
test(err == KErrCorrupt);
|
sl@0
|
340 |
|
sl@0
|
341 |
// New function that has further test to confirm absence of signature
|
sl@0
|
342 |
// Hopefully we can get clients to move over to this in future.
|
sl@0
|
343 |
TRAP(err, resourceFile->ConfirmSignatureL());
|
sl@0
|
344 |
test(err == KErrCorrupt);
|
sl@0
|
345 |
|
sl@0
|
346 |
CleanupStack::PopAndDestroy(resourceFile);
|
sl@0
|
347 |
}
|
sl@0
|
348 |
|
sl@0
|
349 |
LOCAL_C void Test5L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
/* This function tests the behaviour of bafl when reading a resource file
|
sl@0
|
352 |
* for a signature.
|
sl@0
|
353 |
* In this case the signature is present and is NOT the first resource.
|
sl@0
|
354 |
*/
|
sl@0
|
355 |
|
sl@0
|
356 |
CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize);
|
sl@0
|
357 |
|
sl@0
|
358 |
// Need to pass the TInt as required, but doesn't
|
sl@0
|
359 |
// use it. Legacy for BC sake.
|
sl@0
|
360 |
TInt err = KErrNone;
|
sl@0
|
361 |
TRAP(err, resourceFile->ConfirmSignatureL(1));
|
sl@0
|
362 |
test(err == KErrCorrupt);
|
sl@0
|
363 |
|
sl@0
|
364 |
// New function that has further test to confirm absence of signature
|
sl@0
|
365 |
// Hopefully we can get clients to move over to this in future.
|
sl@0
|
366 |
TRAP(err, resourceFile->ConfirmSignatureL());
|
sl@0
|
367 |
test(err == KErrCorrupt);
|
sl@0
|
368 |
|
sl@0
|
369 |
CleanupStack::PopAndDestroy(resourceFile);
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
LOCAL_C void Test6L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0)
|
sl@0
|
373 |
{
|
sl@0
|
374 |
/* This function tests the behaviour of bafl when reading a resource file
|
sl@0
|
375 |
* for a signature.
|
sl@0
|
376 |
* In this case the signature is present and is the first resource.
|
sl@0
|
377 |
*/
|
sl@0
|
378 |
|
sl@0
|
379 |
CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize);
|
sl@0
|
380 |
|
sl@0
|
381 |
// Need to pass the TInt as required, but doesn't
|
sl@0
|
382 |
// use it. Legacy for BC sake.
|
sl@0
|
383 |
TInt err = KErrNone;
|
sl@0
|
384 |
TRAP(err, resourceFile->ConfirmSignatureL(1));
|
sl@0
|
385 |
test(err == KErrNone);
|
sl@0
|
386 |
|
sl@0
|
387 |
// New function that has further test to confirm absence of signature
|
sl@0
|
388 |
// Hopefully we can get clients to move over to this in future.
|
sl@0
|
389 |
TRAP(err, resourceFile->ConfirmSignatureL());
|
sl@0
|
390 |
test(err == KErrNone);
|
sl@0
|
391 |
|
sl@0
|
392 |
CleanupStack::PopAndDestroy(resourceFile);
|
sl@0
|
393 |
}
|
sl@0
|
394 |
|
sl@0
|
395 |
LOCAL_C void Test7L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0)
|
sl@0
|
396 |
{
|
sl@0
|
397 |
/* This function tests the behaviour of bafl when reading a non resource file.
|
sl@0
|
398 |
*/
|
sl@0
|
399 |
TRAPD(err, (void)CResourceFile::NewL(fileServerSession, aResourceFileName, aFileOffset, aFileSize));
|
sl@0
|
400 |
test(err != KErrNotFound && err != KErrNone);
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
/**
|
sl@0
|
404 |
@SYMTestCaseID SYSLIB-BAFL-CT-0480
|
sl@0
|
405 |
@SYMTestCaseDesc Testing resource files containing Unicode-compressed text
|
sl@0
|
406 |
@SYMTestPriority High
|
sl@0
|
407 |
@SYMTestActions Wrapper function calling up Test1L() and Test2L() functions
|
sl@0
|
408 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
409 |
@SYMREQ REQ0000
|
sl@0
|
410 |
*/
|
sl@0
|
411 |
LOCAL_C void SubTest1L()
|
sl@0
|
412 |
{
|
sl@0
|
413 |
test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0480 Testing resource files containing Unicode-compressed text "));
|
sl@0
|
414 |
TBuf<128> z_path;
|
sl@0
|
415 |
TBuf<128> c_path;
|
sl@0
|
416 |
|
sl@0
|
417 |
z_path.Copy(KZDir);
|
sl@0
|
418 |
z_path += rsc_files[0];
|
sl@0
|
419 |
Test1L(z_path);
|
sl@0
|
420 |
CreateFileFromL(c_path, rsc_files[0], z_path);
|
sl@0
|
421 |
Test1L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
422 |
DeleteDataFile(c_path);
|
sl@0
|
423 |
|
sl@0
|
424 |
z_path.Copy(KZDir);
|
sl@0
|
425 |
z_path.Append(rsc_files[1]);
|
sl@0
|
426 |
Test2L(z_path, TUid::Uid(0x101f4a6b));
|
sl@0
|
427 |
CreateFileFromL(c_path, rsc_files[1], z_path);
|
sl@0
|
428 |
Test2L(c_path, TUid::Uid(0x101f4a6b), KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
429 |
DeleteDataFile(c_path);
|
sl@0
|
430 |
}
|
sl@0
|
431 |
|
sl@0
|
432 |
/**
|
sl@0
|
433 |
@SYMTestCaseID SYSLIB-BAFL-CT-0481
|
sl@0
|
434 |
@SYMTestCaseDesc Testing dictionary-compressed resource files
|
sl@0
|
435 |
@SYMTestPriority High
|
sl@0
|
436 |
@SYMTestActions Wrapper function calling up Test2L() function
|
sl@0
|
437 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
438 |
@SYMREQ REQ0000
|
sl@0
|
439 |
*/
|
sl@0
|
440 |
LOCAL_C void SubTest2L()
|
sl@0
|
441 |
{
|
sl@0
|
442 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0481 Testing dictionary-compressed resource files "));
|
sl@0
|
443 |
TBuf<128> z_path;
|
sl@0
|
444 |
TBuf<128> c_path;
|
sl@0
|
445 |
|
sl@0
|
446 |
z_path.Copy(KZDir);
|
sl@0
|
447 |
z_path.Append(rsc_files[2]);
|
sl@0
|
448 |
Test2L(z_path, TUid::Uid(0x101f5010));
|
sl@0
|
449 |
CreateFileFromL(c_path, rsc_files[2], z_path);
|
sl@0
|
450 |
Test2L(c_path, TUid::Uid(0x101f5010), KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
451 |
DeleteDataFile(c_path);
|
sl@0
|
452 |
}
|
sl@0
|
453 |
|
sl@0
|
454 |
/**
|
sl@0
|
455 |
@SYMTestCaseID SYSLIB-BAFL-CT-0482-0001
|
sl@0
|
456 |
@SYMTestCaseDesc Testing Calypso ER5u format dictionary-compressed resource files
|
sl@0
|
457 |
@SYMTestPriority High
|
sl@0
|
458 |
@SYMTestActions Wrapper function calling up Test3L() function
|
sl@0
|
459 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
460 |
@SYMREQ REQ0000
|
sl@0
|
461 |
*/
|
sl@0
|
462 |
LOCAL_C void SubTest3L()
|
sl@0
|
463 |
{
|
sl@0
|
464 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0482-0001 Testing Calypso ER5u format dictionary-compressed resource files "));
|
sl@0
|
465 |
TBuf<128> z_path;
|
sl@0
|
466 |
TBuf<128> c_path;
|
sl@0
|
467 |
|
sl@0
|
468 |
z_path.Copy(KZDir);
|
sl@0
|
469 |
z_path.Append(rsc_files[3]);
|
sl@0
|
470 |
Test3L(z_path);
|
sl@0
|
471 |
CreateFileFromL(c_path, rsc_files[3], z_path);
|
sl@0
|
472 |
Test3L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
473 |
DeleteDataFile(c_path);
|
sl@0
|
474 |
|
sl@0
|
475 |
z_path.Copy(KZDir);
|
sl@0
|
476 |
z_path.Append(rsc_files[5]);
|
sl@0
|
477 |
Test3L(z_path, FileSizeL(KRomResourceFileHeader), FileSizeL(z_path) - FileSizeL(KRomResourceFileHeader));
|
sl@0
|
478 |
}
|
sl@0
|
479 |
|
sl@0
|
480 |
/**
|
sl@0
|
481 |
@SYMTestCaseID SYSLIB-BAFL-CT-0483-0001
|
sl@0
|
482 |
@SYMTestCaseDesc Testing resource file missing signature behaviour
|
sl@0
|
483 |
@SYMTestPriority High
|
sl@0
|
484 |
@SYMTestActions Wrapper function calling up Test4L() function
|
sl@0
|
485 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
486 |
@SYMREQ REQ0000
|
sl@0
|
487 |
*/
|
sl@0
|
488 |
LOCAL_C void SubTest4L()
|
sl@0
|
489 |
{
|
sl@0
|
490 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0483-0001 Testing resource file missing signature behaviour "));
|
sl@0
|
491 |
TBuf<128> z_path;
|
sl@0
|
492 |
TBuf<128> c_path;
|
sl@0
|
493 |
|
sl@0
|
494 |
z_path.Copy(KZDir);
|
sl@0
|
495 |
z_path.Append(rsc_files[3]);
|
sl@0
|
496 |
Test4L(z_path);
|
sl@0
|
497 |
CreateFileFromL(c_path, rsc_files[3], z_path);
|
sl@0
|
498 |
Test4L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
499 |
DeleteDataFile(c_path);
|
sl@0
|
500 |
}
|
sl@0
|
501 |
|
sl@0
|
502 |
/**
|
sl@0
|
503 |
@SYMTestCaseID SYSLIB-BAFL-CT-0484-0001
|
sl@0
|
504 |
@SYMTestCaseDesc Testing resource file signature present and not in order behaviour
|
sl@0
|
505 |
@SYMTestPriority High
|
sl@0
|
506 |
@SYMTestActions Wrapper function calling up Test5() function
|
sl@0
|
507 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
508 |
@SYMREQ REQ0000
|
sl@0
|
509 |
*/
|
sl@0
|
510 |
LOCAL_C void SubTest5L()
|
sl@0
|
511 |
{
|
sl@0
|
512 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0484-0001 Testing resource file signature present and not in order behaviour "));
|
sl@0
|
513 |
TBuf<128> z_path;
|
sl@0
|
514 |
TBuf<128> c_path;
|
sl@0
|
515 |
|
sl@0
|
516 |
z_path.Copy(KZDir);
|
sl@0
|
517 |
z_path.Append(rsc_files[0]);
|
sl@0
|
518 |
Test5L(z_path);
|
sl@0
|
519 |
CreateFileFromL(c_path, rsc_files[0], z_path);
|
sl@0
|
520 |
Test5L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
521 |
DeleteDataFile(c_path);
|
sl@0
|
522 |
}
|
sl@0
|
523 |
|
sl@0
|
524 |
/**
|
sl@0
|
525 |
@SYMTestCaseID SYSLIB-BAFL-CT-0485-0001
|
sl@0
|
526 |
@SYMTestCaseDesc Testing resource file signature present and in order behaviour
|
sl@0
|
527 |
@SYMTestPriority High
|
sl@0
|
528 |
@SYMTestActions Wrapper function calling up Test6L() function
|
sl@0
|
529 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
530 |
@SYMREQ REQ0000
|
sl@0
|
531 |
*/
|
sl@0
|
532 |
LOCAL_C void SubTest6L()
|
sl@0
|
533 |
{
|
sl@0
|
534 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0485-0001 Testing resource file signature present and in order behaviour "));
|
sl@0
|
535 |
TBuf<128> z_path;
|
sl@0
|
536 |
TBuf<128> c_path;
|
sl@0
|
537 |
|
sl@0
|
538 |
z_path.Copy(KZDir);
|
sl@0
|
539 |
z_path.Append(rsc_files[1]);
|
sl@0
|
540 |
Test6L(z_path);
|
sl@0
|
541 |
CreateFileFromL(c_path, rsc_files[1], z_path);
|
sl@0
|
542 |
Test6L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
543 |
DeleteDataFile(c_path);
|
sl@0
|
544 |
}
|
sl@0
|
545 |
|
sl@0
|
546 |
/**
|
sl@0
|
547 |
@SYMTestCaseID SYSLIB-BAFL-CT-0486-0001
|
sl@0
|
548 |
@SYMTestCaseDesc Testing invalid resource file
|
sl@0
|
549 |
@SYMTestPriority High
|
sl@0
|
550 |
@SYMTestActions Wrapper function calling up Test7L() function
|
sl@0
|
551 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
552 |
@SYMREQ REQ0000
|
sl@0
|
553 |
*/
|
sl@0
|
554 |
LOCAL_C void SubTest7L()
|
sl@0
|
555 |
{
|
sl@0
|
556 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0486-0001 Testing invalid resource file "));
|
sl@0
|
557 |
TBuf<128> z_path;
|
sl@0
|
558 |
TBuf<128> c_path;
|
sl@0
|
559 |
|
sl@0
|
560 |
z_path.Copy(KZDir);
|
sl@0
|
561 |
z_path.Append(rsc_files[4]);
|
sl@0
|
562 |
Test7L(z_path);
|
sl@0
|
563 |
CreateFileFromL(c_path, rsc_files[4], z_path);
|
sl@0
|
564 |
Test7L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path));
|
sl@0
|
565 |
DeleteDataFile(c_path);
|
sl@0
|
566 |
}
|
sl@0
|
567 |
|
sl@0
|
568 |
/**
|
sl@0
|
569 |
This test is for measuring the performance improvements from
|
sl@0
|
570 |
compressed resource file dictionary cache (added DEF044572)
|
sl@0
|
571 |
|
sl@0
|
572 |
@SYMTestCaseID SYSLIB-BAFL-CT-0487-0001
|
sl@0
|
573 |
@SYMTestCaseDesc Tests for defect number Def044572L
|
sl@0
|
574 |
@SYMTestPriority High
|
sl@0
|
575 |
@SYMTestActions Attempt for measuring the performance improvements from compressed resource file dictionary cache
|
sl@0
|
576 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
577 |
@SYMREQ REQ0000
|
sl@0
|
578 |
*/
|
sl@0
|
579 |
LOCAL_C void TestDef044572L()
|
sl@0
|
580 |
{
|
sl@0
|
581 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0487-0001 "));
|
sl@0
|
582 |
// measure the time taken to run this test 10 times.
|
sl@0
|
583 |
TTime startTime, stopTime;
|
sl@0
|
584 |
startTime.UniversalTime();
|
sl@0
|
585 |
|
sl@0
|
586 |
// run the test 20 times to make the time easier to measure
|
sl@0
|
587 |
for (TInt repeat=0;repeat<20;repeat++)
|
sl@0
|
588 |
{
|
sl@0
|
589 |
// SubTest3 which uses "Calypso ER5u format dictionary-compressed resource files"
|
sl@0
|
590 |
SubTest3L();
|
sl@0
|
591 |
}
|
sl@0
|
592 |
|
sl@0
|
593 |
// display the time taken
|
sl@0
|
594 |
// for WINSCW this increase from 3.4 to 1.3 seconds when the
|
sl@0
|
595 |
// compressed resource file dictionary cache was added DEF044572
|
sl@0
|
596 |
stopTime.UniversalTime();
|
sl@0
|
597 |
TTimeIntervalMicroSeconds timeTaken = stopTime.MicroSecondsFrom(startTime);
|
sl@0
|
598 |
test.Printf(_L("Time taken for Subtest3:%d microseconds\n"), timeTaken.Int64() );
|
sl@0
|
599 |
}
|
sl@0
|
600 |
|
sl@0
|
601 |
/**
|
sl@0
|
602 |
This test checks reading resource files for memory leaks,
|
sl@0
|
603 |
when running Out Of Memory.(added as part of DEF044572)
|
sl@0
|
604 |
|
sl@0
|
605 |
@SYMTestCaseID SYSLIB-BAFL-CT-0488-0001
|
sl@0
|
606 |
@SYMTestCaseDesc Out of memory tests
|
sl@0
|
607 |
@SYMTestPriority High
|
sl@0
|
608 |
@SYMTestActions Tests for memory leaks while reading resource files.
|
sl@0
|
609 |
@SYMTestExpectedResults Tests must not fail
|
sl@0
|
610 |
@SYMREQ REQ0000
|
sl@0
|
611 |
*/
|
sl@0
|
612 |
LOCAL_C void MemoryLeakTestL()
|
sl@0
|
613 |
{
|
sl@0
|
614 |
test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0488-0001 "));
|
sl@0
|
615 |
TInt ret = KErrNoMemory;
|
sl@0
|
616 |
TInt pass = 1;
|
sl@0
|
617 |
|
sl@0
|
618 |
__UHEAP_MARK;
|
sl@0
|
619 |
// increasing the value of pass until the test completes with KErrNone
|
sl@0
|
620 |
while (ret != KErrNone )
|
sl@0
|
621 |
{
|
sl@0
|
622 |
// check that the test is failing with KErrNoMemory
|
sl@0
|
623 |
test(ret==KErrNoMemory);
|
sl@0
|
624 |
|
sl@0
|
625 |
__UHEAP_FAILNEXT(pass);
|
sl@0
|
626 |
TRAP(ret, SubTest3L());
|
sl@0
|
627 |
__UHEAP_CHECK(0);
|
sl@0
|
628 |
|
sl@0
|
629 |
pass++;
|
sl@0
|
630 |
}
|
sl@0
|
631 |
|
sl@0
|
632 |
// disable the heap fail
|
sl@0
|
633 |
__UHEAP_RESET;
|
sl@0
|
634 |
__UHEAP_MARKEND;
|
sl@0
|
635 |
|
sl@0
|
636 |
}
|
sl@0
|
637 |
|
sl@0
|
638 |
|
sl@0
|
639 |
LOCAL_C void DoE32MainL()
|
sl@0
|
640 |
{
|
sl@0
|
641 |
CleanupClosePushL(fileServerSession);
|
sl@0
|
642 |
User::LeaveIfError(fileServerSession.Connect());
|
sl@0
|
643 |
|
sl@0
|
644 |
SubTest1L();
|
sl@0
|
645 |
SubTest2L();
|
sl@0
|
646 |
SubTest3L();
|
sl@0
|
647 |
SubTest4L();
|
sl@0
|
648 |
SubTest5L();
|
sl@0
|
649 |
SubTest6L();
|
sl@0
|
650 |
SubTest7L();
|
sl@0
|
651 |
TestDef044572L();
|
sl@0
|
652 |
MemoryLeakTestL();
|
sl@0
|
653 |
|
sl@0
|
654 |
CleanupStack::PopAndDestroy(1, &fileServerSession);
|
sl@0
|
655 |
}
|
sl@0
|
656 |
|
sl@0
|
657 |
GLDEF_C TInt E32Main()
|
sl@0
|
658 |
{
|
sl@0
|
659 |
__UHEAP_MARK;
|
sl@0
|
660 |
CTrapCleanup* trapCleanup=CTrapCleanup::New();
|
sl@0
|
661 |
TRAPD(error, DoE32MainL());
|
sl@0
|
662 |
test(error == KErrNone);
|
sl@0
|
663 |
test.Next(_L("/n"));
|
sl@0
|
664 |
test.End();
|
sl@0
|
665 |
test.Close();
|
sl@0
|
666 |
delete trapCleanup;
|
sl@0
|
667 |
__UHEAP_MARKEND;
|
sl@0
|
668 |
return error;
|
sl@0
|
669 |
}
|
sl@0
|
670 |
|