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