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 <e32test.h>
|
sl@0
|
17 |
#include <bacline.h>
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <ezcompressor.h>
|
sl@0
|
20 |
#include <ezdecompressor.h>
|
sl@0
|
21 |
#include <ezfilebuffer.h>
|
sl@0
|
22 |
#include <ezlib.h>
|
sl@0
|
23 |
#include <hal.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
_LIT(KSeparator,"----------------------------------------------------------------\n");
|
sl@0
|
27 |
|
sl@0
|
28 |
const TInt KNumberOfTests = 38;
|
sl@0
|
29 |
_LIT(KTest1,"Multistep compression & decompression using buffers smaller than source & destination");
|
sl@0
|
30 |
_LIT(KTest2,"Multistep compression & decompression using buffers larger than source & destination");
|
sl@0
|
31 |
_LIT(KTest3,"Test Multistep compression when NeedInput provides no input");
|
sl@0
|
32 |
_LIT(KTest4,"Test Multistep compression when NeedOutput provides no output");
|
sl@0
|
33 |
_LIT(KTest5,"Perform multistep compression 2 with the same CEZCompressor, reseting it\n\
|
sl@0
|
34 |
after the first compression.");
|
sl@0
|
35 |
_LIT(KTest6,"Perform multistep compression 2 with the same CEZCompressor, without reseting it\n\
|
sl@0
|
36 |
after the first compression.");
|
sl@0
|
37 |
_LIT(KTest7,"Performs multistep compression & decompression using a preset dicitonary.");
|
sl@0
|
38 |
_LIT(KTest8,"Performs multistep compression with compression level of 0.");
|
sl@0
|
39 |
_LIT(KTest9,"Performs multistep compression with compression level of 9.");
|
sl@0
|
40 |
_LIT(KTest10,"Performs multistep compression with invalid compression level.");
|
sl@0
|
41 |
_LIT(KTest11,"Performs multistep compression with window bits of 8.");
|
sl@0
|
42 |
_LIT(KTest12,"Performs multistep compression with an invalid value for window bits.");
|
sl@0
|
43 |
_LIT(KTest13,"Performs multistep compression with memory level = 1.");
|
sl@0
|
44 |
_LIT(KTest14,"Performs multistep compression with an invalid memory level.");
|
sl@0
|
45 |
_LIT(KTest15,"Performs multistep compression using only Huffman encoding.");
|
sl@0
|
46 |
_LIT(KTest16,"Performs multistep compression using Filtered strategy.");
|
sl@0
|
47 |
_LIT(KTest17,"Performs multistep compression when Alloc fails randomly.");
|
sl@0
|
48 |
_LIT(KTest18,"Test Multistep decompression when NeedInput provides no input.");
|
sl@0
|
49 |
_LIT(KTest19,"Test Multistep decompression when NeedOutput provides no output.");
|
sl@0
|
50 |
_LIT(KTest20,"Test Multistep decompression when compressed stream is corrupt.");
|
sl@0
|
51 |
_LIT(KTest21,"Test Multistep decompressor construction when Alloc fails randomly.");
|
sl@0
|
52 |
_LIT(KTest22,"Test Multistep decompression when Alloc fails randomly.");
|
sl@0
|
53 |
_LIT(KTest23,"Test Multistep decompression when a dictionary is required and not provided.\n\
|
sl@0
|
54 |
This test should panic.");
|
sl@0
|
55 |
_LIT(KTest24,"Test Multistep decompression when a dictionary when the wrong dictionary is provided.");
|
sl@0
|
56 |
_LIT(KTest25,"Perform multistep decompression twice with the same CEZDecompressor, reseting it\n\
|
sl@0
|
57 |
after the first decompression.");
|
sl@0
|
58 |
_LIT(KTest26,"Perform multistep decompression twice with the same CEZDecompressor, reseting it\n\
|
sl@0
|
59 |
after the first decompression.");
|
sl@0
|
60 |
_LIT(KTest27,"Perform multistep compression and decompression on unicode data.");
|
sl@0
|
61 |
_LIT(KTest28,"Perform multistep compression and decompression on unicode data using a unicode dictionary.");
|
sl@0
|
62 |
_LIT(KTest29,"Perform multistep compression and decompression on unicode data using an ascii dictionary.");
|
sl@0
|
63 |
_LIT(KTest30,"Test percentage of completion during multistep compression/decompression.");
|
sl@0
|
64 |
_LIT(KTest31,"Test single step compression and decompression.");
|
sl@0
|
65 |
_LIT(KTest32,"Test single step compression when indaquate output buffer is provided.");
|
sl@0
|
66 |
_LIT(KTest33,"Test single step decompression when indaquate output buffer is provided.");
|
sl@0
|
67 |
_LIT(KTest34,"Testing graceful exit for zlib 1.1.3 decompression bug. See: INC022729.");
|
sl@0
|
68 |
_LIT(KTest35,"Testing EZlib decompression performance with enforced compiler optimisation");
|
sl@0
|
69 |
_LIT(KTest36,"Testing correct memory deallocation for CEZFileBufferManager. See: DEF109756.");
|
sl@0
|
70 |
_LIT(KTest37,"Test CEZZStream functions through CEZCompressor class.");
|
sl@0
|
71 |
_LIT(KTest38,"Test Calls to Zlibapiwrapper.cpp exported API's like inflate, deflate, compress, decompress");
|
sl@0
|
72 |
|
sl@0
|
73 |
const TPtrC KTest1Des(KTest1);
|
sl@0
|
74 |
const TPtrC KTest2Des(KTest2);
|
sl@0
|
75 |
const TPtrC KTest3Des(KTest3);
|
sl@0
|
76 |
const TPtrC KTest4Des(KTest4);
|
sl@0
|
77 |
const TPtrC KTest5Des(KTest5);
|
sl@0
|
78 |
const TPtrC KTest6Des(KTest6);
|
sl@0
|
79 |
const TPtrC KTest7Des(KTest7);
|
sl@0
|
80 |
const TPtrC KTest8Des(KTest8);
|
sl@0
|
81 |
const TPtrC KTest9Des(KTest9);
|
sl@0
|
82 |
const TPtrC KTest10Des(KTest10);
|
sl@0
|
83 |
const TPtrC KTest11Des(KTest11);
|
sl@0
|
84 |
const TPtrC KTest12Des(KTest12);
|
sl@0
|
85 |
const TPtrC KTest13Des(KTest13);
|
sl@0
|
86 |
const TPtrC KTest14Des(KTest14);
|
sl@0
|
87 |
const TPtrC KTest15Des(KTest15);
|
sl@0
|
88 |
const TPtrC KTest16Des(KTest16);
|
sl@0
|
89 |
const TPtrC KTest17Des(KTest17);
|
sl@0
|
90 |
const TPtrC KTest18Des(KTest18);
|
sl@0
|
91 |
const TPtrC KTest19Des(KTest19);
|
sl@0
|
92 |
const TPtrC KTest20Des(KTest20);
|
sl@0
|
93 |
const TPtrC KTest21Des(KTest21);
|
sl@0
|
94 |
const TPtrC KTest22Des(KTest22);
|
sl@0
|
95 |
const TPtrC KTest23Des(KTest23);
|
sl@0
|
96 |
const TPtrC KTest24Des(KTest24);
|
sl@0
|
97 |
const TPtrC KTest25Des(KTest25);
|
sl@0
|
98 |
const TPtrC KTest26Des(KTest26);
|
sl@0
|
99 |
const TPtrC KTest27Des(KTest27);
|
sl@0
|
100 |
const TPtrC KTest28Des(KTest28);
|
sl@0
|
101 |
const TPtrC KTest29Des(KTest29);
|
sl@0
|
102 |
const TPtrC KTest30Des(KTest30);
|
sl@0
|
103 |
const TPtrC KTest31Des(KTest31);
|
sl@0
|
104 |
const TPtrC KTest32Des(KTest32);
|
sl@0
|
105 |
const TPtrC KTest33Des(KTest33);
|
sl@0
|
106 |
const TPtrC KTest34Des(KTest34);
|
sl@0
|
107 |
const TPtrC KTest35Des(KTest35);
|
sl@0
|
108 |
const TPtrC KTest36Des(KTest36);
|
sl@0
|
109 |
const TPtrC KTest37Des(KTest37);
|
sl@0
|
110 |
const TPtrC KTest38Des(KTest38);
|
sl@0
|
111 |
|
sl@0
|
112 |
void Test1L();
|
sl@0
|
113 |
void Test2L();
|
sl@0
|
114 |
void Test3();
|
sl@0
|
115 |
void Test4();
|
sl@0
|
116 |
void Test5L();
|
sl@0
|
117 |
void Test6();
|
sl@0
|
118 |
void Test7L();
|
sl@0
|
119 |
void Test8L();
|
sl@0
|
120 |
void Test9L();
|
sl@0
|
121 |
void Test10();
|
sl@0
|
122 |
void Test11();
|
sl@0
|
123 |
void Test12();
|
sl@0
|
124 |
void Test13L();
|
sl@0
|
125 |
void Test14();
|
sl@0
|
126 |
void Test15L();
|
sl@0
|
127 |
void Test16L();
|
sl@0
|
128 |
void Test17();
|
sl@0
|
129 |
void Test18L();
|
sl@0
|
130 |
void Test19L();
|
sl@0
|
131 |
void Test20L();
|
sl@0
|
132 |
void Test21L();
|
sl@0
|
133 |
void Test22L();
|
sl@0
|
134 |
void Test23();
|
sl@0
|
135 |
void Test24L();
|
sl@0
|
136 |
void Test25L();
|
sl@0
|
137 |
void Test26L();
|
sl@0
|
138 |
void Test27L();
|
sl@0
|
139 |
void Test28L();
|
sl@0
|
140 |
void Test29L();
|
sl@0
|
141 |
void Test30L();
|
sl@0
|
142 |
void Test31L();
|
sl@0
|
143 |
void Test32();
|
sl@0
|
144 |
void Test33L();
|
sl@0
|
145 |
void Test34L();
|
sl@0
|
146 |
void Test35L();
|
sl@0
|
147 |
void Test36L();
|
sl@0
|
148 |
void TestCEZCompressorMethodsL();
|
sl@0
|
149 |
void TestZlibapiwrapperAPIL();
|
sl@0
|
150 |
|
sl@0
|
151 |
typedef void (*TestPtr)();
|
sl@0
|
152 |
|
sl@0
|
153 |
struct TTests
|
sl@0
|
154 |
{
|
sl@0
|
155 |
TestPtr iFn;
|
sl@0
|
156 |
const TPtrC *iDescription;
|
sl@0
|
157 |
};
|
sl@0
|
158 |
|
sl@0
|
159 |
const TTests testTable[] = {
|
sl@0
|
160 |
{Test1L,&KTest1Des},
|
sl@0
|
161 |
{Test2L,&KTest2Des},
|
sl@0
|
162 |
{Test3,&KTest3Des},
|
sl@0
|
163 |
{Test4,&KTest4Des},
|
sl@0
|
164 |
{Test5L,&KTest5Des},
|
sl@0
|
165 |
{Test6,&KTest6Des},
|
sl@0
|
166 |
{Test7L,&KTest7Des},
|
sl@0
|
167 |
{Test8L,&KTest8Des},
|
sl@0
|
168 |
{Test9L,&KTest9Des},
|
sl@0
|
169 |
{Test10,&KTest10Des},
|
sl@0
|
170 |
{Test11,&KTest11Des},
|
sl@0
|
171 |
{Test12,&KTest12Des},
|
sl@0
|
172 |
{Test13L,&KTest13Des},
|
sl@0
|
173 |
{Test14,&KTest14Des},
|
sl@0
|
174 |
{Test15L,&KTest15Des},
|
sl@0
|
175 |
{Test16L,&KTest16Des},
|
sl@0
|
176 |
{Test17,&KTest17Des},
|
sl@0
|
177 |
{Test18L,&KTest18Des},
|
sl@0
|
178 |
{Test19L,&KTest19Des},
|
sl@0
|
179 |
{Test20L,&KTest20Des},
|
sl@0
|
180 |
{Test21L,&KTest21Des},
|
sl@0
|
181 |
{Test22L,&KTest22Des},
|
sl@0
|
182 |
{Test23,&KTest23Des},
|
sl@0
|
183 |
{Test24L,&KTest24Des},
|
sl@0
|
184 |
{Test25L,&KTest25Des},
|
sl@0
|
185 |
{Test26L,&KTest26Des},
|
sl@0
|
186 |
{Test27L,&KTest27Des},
|
sl@0
|
187 |
{Test28L,&KTest28Des},
|
sl@0
|
188 |
{Test29L,&KTest29Des},
|
sl@0
|
189 |
{Test30L,&KTest30Des},
|
sl@0
|
190 |
{Test31L,&KTest31Des},
|
sl@0
|
191 |
{Test32,&KTest32Des},
|
sl@0
|
192 |
{Test33L,&KTest33Des},
|
sl@0
|
193 |
{Test34L,&KTest34Des},
|
sl@0
|
194 |
{Test35L,&KTest35Des},
|
sl@0
|
195 |
{Test36L,&KTest36Des},
|
sl@0
|
196 |
{TestCEZCompressorMethodsL, &KTest37Des},
|
sl@0
|
197 |
{TestZlibapiwrapperAPIL, &KTest38Des}
|
sl@0
|
198 |
};
|
sl@0
|
199 |
|
sl@0
|
200 |
struct TTestFlags
|
sl@0
|
201 |
{
|
sl@0
|
202 |
enum
|
sl@0
|
203 |
{
|
sl@0
|
204 |
FakeNoInput = 16,
|
sl@0
|
205 |
FakeNoOutput = 32,
|
sl@0
|
206 |
Dictionary = 64,
|
sl@0
|
207 |
AllocFail = 128,
|
sl@0
|
208 |
Corrupt = 256,
|
sl@0
|
209 |
AllocFailInflate = 512,
|
sl@0
|
210 |
Unicode = 1024,
|
sl@0
|
211 |
Percent = 2048
|
sl@0
|
212 |
};
|
sl@0
|
213 |
|
sl@0
|
214 |
|
sl@0
|
215 |
TTestFlags() : iFlags(0), iBufferSize(0) { Defaults(); }
|
sl@0
|
216 |
TTestFlags(TInt aFlags, TInt aBufferSize) : iFlags(aFlags), iBufferSize(aBufferSize) { Defaults(); }
|
sl@0
|
217 |
void Defaults();
|
sl@0
|
218 |
|
sl@0
|
219 |
TInt iFlags;
|
sl@0
|
220 |
TInt iBufferSize;
|
sl@0
|
221 |
TPtrC8 iDictionary;
|
sl@0
|
222 |
TInt iLevel;
|
sl@0
|
223 |
TInt iWindowBits;
|
sl@0
|
224 |
TInt iMemLevel;
|
sl@0
|
225 |
CEZCompressor::TStrategy iStrategy;
|
sl@0
|
226 |
};
|
sl@0
|
227 |
|
sl@0
|
228 |
|
sl@0
|
229 |
void TTestFlags::Defaults()
|
sl@0
|
230 |
{
|
sl@0
|
231 |
iLevel = CEZCompressor::EDefaultCompression;
|
sl@0
|
232 |
iWindowBits = CEZCompressor::EMaxWBits;
|
sl@0
|
233 |
iMemLevel = CEZCompressor::EDefMemLevel;
|
sl@0
|
234 |
iStrategy = CEZCompressor::EDefaultStrategy;
|
sl@0
|
235 |
}
|
sl@0
|
236 |
|
sl@0
|
237 |
TReal FastCountToMilliseconds(TInt aFastCount)
|
sl@0
|
238 |
{
|
sl@0
|
239 |
TInt freqInHz;
|
sl@0
|
240 |
HAL::Get(HAL::EFastCounterFrequency, freqInHz);
|
sl@0
|
241 |
TReal freqInkHz = freqInHz / 1000;
|
sl@0
|
242 |
return (TReal)aFastCount / freqInkHz;
|
sl@0
|
243 |
}
|
sl@0
|
244 |
|
sl@0
|
245 |
|
sl@0
|
246 |
static RTest Test(_L("EZLIB"));
|
sl@0
|
247 |
|
sl@0
|
248 |
static TUint8 original[] = "compression is a constant source of depression and depression leads to multiple regressions in succession";
|
sl@0
|
249 |
static TUint8 dictionary[] = "constant source multiple leads compression ";
|
sl@0
|
250 |
static TUint8 badDictionary[] = "I'm not the dictionary";
|
sl@0
|
251 |
static TUint8 compressed[256];
|
sl@0
|
252 |
static TInt compressedSize; // length of compressed data in compressed.
|
sl@0
|
253 |
static TUint8 uncompressed[256];
|
sl@0
|
254 |
static TText output[256];
|
sl@0
|
255 |
static TText originalU[256];
|
sl@0
|
256 |
static TText dictionaryU[256];
|
sl@0
|
257 |
|
sl@0
|
258 |
static void RunTestL();
|
sl@0
|
259 |
|
sl@0
|
260 |
static void CompressBufferL(const TTestFlags &aFlags, RTest &aTest=Test);
|
sl@0
|
261 |
static void DecompressBufferL(const TTestFlags &aFlags, RTest &aTest=Test);
|
sl@0
|
262 |
static void DblDecompressBufferL(TInt aBufferSize, TBool aReset);
|
sl@0
|
263 |
static void CompressDecompressL(const TTestFlags &aFlags);
|
sl@0
|
264 |
static void DblCompressBufferL(TInt aBufferSize, TBool aReset = EFalse);
|
sl@0
|
265 |
|
sl@0
|
266 |
class CBufferManager : public CBase, public MEZBufferManager
|
sl@0
|
267 |
{
|
sl@0
|
268 |
public:
|
sl@0
|
269 |
~CBufferManager();
|
sl@0
|
270 |
|
sl@0
|
271 |
static CBufferManager *NewLC(TUint8 *aInput, TInt aInputLength, TUint8 *aOutput, TInt aOutputLength, TInt aBufferSize);
|
sl@0
|
272 |
static CBufferManager *NewL(TUint8 *aInput, TInt aInputLength, TUint8 *aOutput, TInt aOutputLength, TInt aBufferSize);
|
sl@0
|
273 |
|
sl@0
|
274 |
void InitializeL(CEZZStream &aZStream);
|
sl@0
|
275 |
void NeedInputL(CEZZStream &aZStream);
|
sl@0
|
276 |
void NeedOutputL(CEZZStream &aZStream);
|
sl@0
|
277 |
void FinalizeL(CEZZStream &aZStream);
|
sl@0
|
278 |
|
sl@0
|
279 |
void FakeNoInput() { iFakeNoInput = ETrue; }
|
sl@0
|
280 |
void FakeNoOutput() { iFakeNoOutput = ETrue; }
|
sl@0
|
281 |
|
sl@0
|
282 |
private:
|
sl@0
|
283 |
CBufferManager(TUint8 *aInput, TInt aInputLength, TUint8 *aOutput, TInt aOutputLength);
|
sl@0
|
284 |
void ConstructL(TInt aBufferSize);
|
sl@0
|
285 |
|
sl@0
|
286 |
private:
|
sl@0
|
287 |
TUint8 *iInput, *iOutput;
|
sl@0
|
288 |
TUint8 *iInputBuffer, *iOutputBuffer;
|
sl@0
|
289 |
TInt iBufferSize;
|
sl@0
|
290 |
TInt iOutputLength, iInputLength;
|
sl@0
|
291 |
TPtr8 iInputDescriptor;
|
sl@0
|
292 |
TPtr8 iOutputDescriptor;
|
sl@0
|
293 |
TBool iFakeNoInput;
|
sl@0
|
294 |
TBool iFakeNoOutput;
|
sl@0
|
295 |
};
|
sl@0
|
296 |
|
sl@0
|
297 |
CBufferManager::CBufferManager(TUint8 *aInput, TInt aInputLength, TUint8 *aOutput, TInt aOutputLength)
|
sl@0
|
298 |
: iInput(aInput),
|
sl@0
|
299 |
iOutput(aOutput),
|
sl@0
|
300 |
iOutputLength(aOutputLength),
|
sl@0
|
301 |
iInputLength(aInputLength),
|
sl@0
|
302 |
iInputDescriptor(NULL,0),
|
sl@0
|
303 |
iOutputDescriptor(NULL,0),
|
sl@0
|
304 |
iFakeNoInput(EFalse),
|
sl@0
|
305 |
iFakeNoOutput(EFalse)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
|
sl@0
|
308 |
}
|
sl@0
|
309 |
|
sl@0
|
310 |
CBufferManager::~CBufferManager()
|
sl@0
|
311 |
{
|
sl@0
|
312 |
delete[] iInputBuffer;
|
sl@0
|
313 |
delete[] iOutputBuffer;
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
CBufferManager *CBufferManager::NewLC(TUint8 *aInput, TInt aInputLength, TUint8 *aOutput, TInt aOutputLength, TInt aBufferSize)
|
sl@0
|
317 |
{
|
sl@0
|
318 |
CBufferManager *bm = new (ELeave) CBufferManager(aInput,aInputLength,aOutput,aOutputLength);
|
sl@0
|
319 |
CleanupStack::PushL(bm);
|
sl@0
|
320 |
bm->ConstructL(aBufferSize);
|
sl@0
|
321 |
return bm;
|
sl@0
|
322 |
}
|
sl@0
|
323 |
|
sl@0
|
324 |
CBufferManager *CBufferManager::NewL(TUint8 *aInput, TInt aInputLength, TUint8 *aOutput, TInt aOutputLength, TInt aBufferSize)
|
sl@0
|
325 |
{
|
sl@0
|
326 |
CBufferManager *bm = new (ELeave) CBufferManager(aInput,aInputLength,aOutput,aOutputLength);
|
sl@0
|
327 |
CleanupStack::PushL(bm);
|
sl@0
|
328 |
bm->ConstructL(aBufferSize);
|
sl@0
|
329 |
CleanupStack::Pop();
|
sl@0
|
330 |
return bm;
|
sl@0
|
331 |
}
|
sl@0
|
332 |
|
sl@0
|
333 |
void CBufferManager::ConstructL(TInt aBufferSize)
|
sl@0
|
334 |
{
|
sl@0
|
335 |
iBufferSize = aBufferSize;
|
sl@0
|
336 |
iInputBuffer = new (ELeave) TUint8[iBufferSize];
|
sl@0
|
337 |
iOutputBuffer = new (ELeave) TUint8[iBufferSize];
|
sl@0
|
338 |
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
void CBufferManager::InitializeL(CEZZStream &aZStream)
|
sl@0
|
342 |
{
|
sl@0
|
343 |
TInt remaining = iInputLength;
|
sl@0
|
344 |
if (remaining > iBufferSize)
|
sl@0
|
345 |
remaining = iBufferSize;
|
sl@0
|
346 |
Mem::Copy(iInputBuffer,iInput,remaining);
|
sl@0
|
347 |
iInputDescriptor.Set(iInputBuffer,remaining,iBufferSize);
|
sl@0
|
348 |
aZStream.SetInput(iInputDescriptor);
|
sl@0
|
349 |
iOutputDescriptor.Set(iOutputBuffer,0,iBufferSize);
|
sl@0
|
350 |
aZStream.SetOutput(iOutputDescriptor);
|
sl@0
|
351 |
iInput += remaining;
|
sl@0
|
352 |
}
|
sl@0
|
353 |
|
sl@0
|
354 |
void CBufferManager::NeedInputL(CEZZStream &aZStream)
|
sl@0
|
355 |
{
|
sl@0
|
356 |
TInt remaining;
|
sl@0
|
357 |
if (iFakeNoInput)
|
sl@0
|
358 |
remaining = 0;
|
sl@0
|
359 |
else
|
sl@0
|
360 |
{
|
sl@0
|
361 |
remaining = iInputLength - aZStream.TotalIn();
|
sl@0
|
362 |
if (remaining > iBufferSize)
|
sl@0
|
363 |
remaining = iBufferSize;
|
sl@0
|
364 |
Mem::Copy(iInputBuffer,iInput,remaining);
|
sl@0
|
365 |
}
|
sl@0
|
366 |
iInputDescriptor.Set(iInputBuffer,remaining,iBufferSize);
|
sl@0
|
367 |
aZStream.SetInput(iInputDescriptor);
|
sl@0
|
368 |
iInput += remaining;
|
sl@0
|
369 |
}
|
sl@0
|
370 |
|
sl@0
|
371 |
|
sl@0
|
372 |
void CBufferManager::NeedOutputL(CEZZStream &aZStream)
|
sl@0
|
373 |
{
|
sl@0
|
374 |
TInt remaining;
|
sl@0
|
375 |
if (iFakeNoOutput)
|
sl@0
|
376 |
{
|
sl@0
|
377 |
remaining = 0;
|
sl@0
|
378 |
iOutputDescriptor.Set(iOutputBuffer,remaining,remaining);
|
sl@0
|
379 |
}
|
sl@0
|
380 |
else
|
sl@0
|
381 |
{
|
sl@0
|
382 |
remaining = iOutputLength - aZStream.TotalOut();
|
sl@0
|
383 |
if (remaining > iBufferSize)
|
sl@0
|
384 |
remaining = iBufferSize;
|
sl@0
|
385 |
}
|
sl@0
|
386 |
TPtrC8 od = aZStream.OutputDescriptor();
|
sl@0
|
387 |
Mem::Copy(iOutput,iOutputBuffer,od.Size());
|
sl@0
|
388 |
aZStream.SetOutput(iOutputDescriptor);
|
sl@0
|
389 |
iOutput += iBufferSize;
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
void CBufferManager::FinalizeL(CEZZStream &aZStream)
|
sl@0
|
393 |
{
|
sl@0
|
394 |
TInt copy = aZStream.OutputDescriptor().Size();
|
sl@0
|
395 |
|
sl@0
|
396 |
if (copy > 0)
|
sl@0
|
397 |
Mem::Copy(iOutput,iOutputBuffer,copy);
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
/**
|
sl@0
|
401 |
@SYMTestCaseID SYSLIB-EZLIB-CT-1328
|
sl@0
|
402 |
@SYMTestCaseDesc Decompression of stream test
|
sl@0
|
403 |
@SYMTestPriority High
|
sl@0
|
404 |
@SYMTestActions Compresses and decompresses a buffer and tests to see whether the orginal and decompression streams
|
sl@0
|
405 |
are the same.
|
sl@0
|
406 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
407 |
@SYMREQ REQ0000
|
sl@0
|
408 |
*/
|
sl@0
|
409 |
|
sl@0
|
410 |
static void CompressDecompressL(const TTestFlags &aFlags)
|
sl@0
|
411 |
{
|
sl@0
|
412 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-1328 "));
|
sl@0
|
413 |
CompressBufferL(aFlags);
|
sl@0
|
414 |
DecompressBufferL(aFlags);
|
sl@0
|
415 |
|
sl@0
|
416 |
if (aFlags.iFlags & TTestFlags::Unicode)
|
sl@0
|
417 |
{
|
sl@0
|
418 |
TPtr s1(REINTERPRET_CAST(TText *, original),sizeof(original));
|
sl@0
|
419 |
TPtr s2(REINTERPRET_CAST(TText *, uncompressed),sizeof(original));
|
sl@0
|
420 |
Test(s1.Compare(s2) == 0,__LINE__);
|
sl@0
|
421 |
}
|
sl@0
|
422 |
else
|
sl@0
|
423 |
{
|
sl@0
|
424 |
TPtrC8 s1(original);
|
sl@0
|
425 |
TPtrC8 s2(uncompressed);
|
sl@0
|
426 |
Test(s1.Compare(s2) == 0,__LINE__);
|
sl@0
|
427 |
}
|
sl@0
|
428 |
}
|
sl@0
|
429 |
|
sl@0
|
430 |
// Compresses the data in original and places it into compressed.
|
sl@0
|
431 |
|
sl@0
|
432 |
//Need to pass in RTest object as this function is called by a seperate thread sometimes
|
sl@0
|
433 |
static void CompressBufferL(const TTestFlags &aFlags, RTest &aTest)
|
sl@0
|
434 |
{
|
sl@0
|
435 |
_LIT(KMsg,"\nTesting multi-step compresssion with buffer size %d\n");
|
sl@0
|
436 |
aTest.Printf(KMsg,aFlags.iBufferSize);
|
sl@0
|
437 |
aTest.Printf(KSeparator);
|
sl@0
|
438 |
CBufferManager *bm;
|
sl@0
|
439 |
TInt sourceSize;
|
sl@0
|
440 |
|
sl@0
|
441 |
if (aFlags.iFlags & TTestFlags::Unicode)
|
sl@0
|
442 |
{
|
sl@0
|
443 |
sourceSize = sizeof(original) * sizeof(TText);
|
sl@0
|
444 |
bm = CBufferManager::NewLC(REINTERPRET_CAST(TUint8*,originalU),sourceSize,compressed,256,aFlags.iBufferSize);
|
sl@0
|
445 |
}
|
sl@0
|
446 |
else
|
sl@0
|
447 |
{
|
sl@0
|
448 |
sourceSize = sizeof(original);
|
sl@0
|
449 |
bm = CBufferManager::NewLC(original,sourceSize,compressed,256,aFlags.iBufferSize);
|
sl@0
|
450 |
}
|
sl@0
|
451 |
|
sl@0
|
452 |
|
sl@0
|
453 |
if (aFlags.iFlags & TTestFlags::FakeNoInput)
|
sl@0
|
454 |
bm->FakeNoInput();
|
sl@0
|
455 |
if (aFlags.iFlags & TTestFlags::FakeNoOutput)
|
sl@0
|
456 |
bm->FakeNoOutput();
|
sl@0
|
457 |
CEZCompressor *def;
|
sl@0
|
458 |
|
sl@0
|
459 |
#if defined(_DEBUG) && defined(__WINS__)
|
sl@0
|
460 |
if (aFlags.iFlags & TTestFlags::AllocFail)
|
sl@0
|
461 |
__UHEAP_SETFAIL(RHeap::ETrueRandom,5);
|
sl@0
|
462 |
#endif
|
sl@0
|
463 |
|
sl@0
|
464 |
if (aFlags.iFlags & TTestFlags::Dictionary)
|
sl@0
|
465 |
def = CEZCompressor::NewLC(*bm,aFlags.iDictionary,aFlags.iLevel,aFlags.iWindowBits,
|
sl@0
|
466 |
aFlags.iMemLevel,aFlags.iStrategy);
|
sl@0
|
467 |
else
|
sl@0
|
468 |
def= CEZCompressor::NewLC(*bm,aFlags.iLevel,aFlags.iWindowBits,aFlags.iMemLevel,
|
sl@0
|
469 |
aFlags.iStrategy);
|
sl@0
|
470 |
|
sl@0
|
471 |
while (def->DeflateL())
|
sl@0
|
472 |
{
|
sl@0
|
473 |
if (aFlags.iFlags & TTestFlags::Percent)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
_LIT(KPer,"%d ");
|
sl@0
|
476 |
aTest.Printf(KPer,def->Progress(sourceSize));
|
sl@0
|
477 |
}
|
sl@0
|
478 |
}
|
sl@0
|
479 |
if (aFlags.iFlags & TTestFlags::Percent)
|
sl@0
|
480 |
aTest.Printf(_L("\n"));
|
sl@0
|
481 |
|
sl@0
|
482 |
compressedSize = def->TotalOut();
|
sl@0
|
483 |
_LIT(KUnMsg,"Uncompressed Size %d\n");
|
sl@0
|
484 |
_LIT(KComMsg,"Compressed Size %d\n");
|
sl@0
|
485 |
|
sl@0
|
486 |
if (aFlags.iFlags & TTestFlags::Corrupt)
|
sl@0
|
487 |
compressed[compressedSize >> 1] = 1;
|
sl@0
|
488 |
|
sl@0
|
489 |
aTest.Printf(KUnMsg,def->TotalIn());
|
sl@0
|
490 |
aTest.Printf(KComMsg,compressedSize);
|
sl@0
|
491 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
492 |
}
|
sl@0
|
493 |
|
sl@0
|
494 |
// Decompresses data stored in compressed and writes it to uncompressed.
|
sl@0
|
495 |
|
sl@0
|
496 |
//Need to pass in RTest object as this function is called by a seperate thread sometimes
|
sl@0
|
497 |
static void DecompressBufferL(const TTestFlags &aFlags, RTest &aTest)
|
sl@0
|
498 |
{
|
sl@0
|
499 |
_LIT(KMsg,"\nTesting multi-step decompresssion with buffer size %d\n");
|
sl@0
|
500 |
aTest.Printf(KMsg,aFlags.iBufferSize);
|
sl@0
|
501 |
aTest.Printf(KSeparator);
|
sl@0
|
502 |
CBufferManager *bm = CBufferManager::NewLC(compressed,compressedSize,uncompressed,256,aFlags.iBufferSize);
|
sl@0
|
503 |
|
sl@0
|
504 |
if (aFlags.iFlags & TTestFlags::FakeNoInput)
|
sl@0
|
505 |
bm->FakeNoInput();
|
sl@0
|
506 |
if (aFlags.iFlags & TTestFlags::FakeNoOutput)
|
sl@0
|
507 |
bm->FakeNoOutput();
|
sl@0
|
508 |
|
sl@0
|
509 |
#if defined(_DEBUG) && defined(__WINS__)
|
sl@0
|
510 |
if (aFlags.iFlags & TTestFlags::AllocFail)
|
sl@0
|
511 |
__UHEAP_SETFAIL(RHeap::ETrueRandom,10);
|
sl@0
|
512 |
#endif
|
sl@0
|
513 |
|
sl@0
|
514 |
CEZDecompressor *in;
|
sl@0
|
515 |
if (aFlags.iFlags & TTestFlags::Dictionary)
|
sl@0
|
516 |
in = CEZDecompressor::NewLC(*bm,aFlags.iDictionary);
|
sl@0
|
517 |
else
|
sl@0
|
518 |
in = CEZDecompressor::NewLC(*bm);
|
sl@0
|
519 |
|
sl@0
|
520 |
#if defined(_DEBUG) && defined(__WINS__)
|
sl@0
|
521 |
if (aFlags.iFlags & TTestFlags::AllocFailInflate)
|
sl@0
|
522 |
__UHEAP_SETFAIL(RHeap::ETrueRandom,10);
|
sl@0
|
523 |
#endif
|
sl@0
|
524 |
|
sl@0
|
525 |
while (in->InflateL())
|
sl@0
|
526 |
{
|
sl@0
|
527 |
if (aFlags.iFlags & TTestFlags::Percent)
|
sl@0
|
528 |
{
|
sl@0
|
529 |
_LIT(KPer,"%d ");
|
sl@0
|
530 |
aTest.Printf(KPer,in->Progress(compressedSize));
|
sl@0
|
531 |
}
|
sl@0
|
532 |
}
|
sl@0
|
533 |
if (aFlags.iFlags & TTestFlags::Percent)
|
sl@0
|
534 |
aTest.Printf(_L("\n"));
|
sl@0
|
535 |
|
sl@0
|
536 |
|
sl@0
|
537 |
if (aFlags.iFlags & TTestFlags::Unicode)
|
sl@0
|
538 |
{
|
sl@0
|
539 |
TPtrC ptr(REINTERPRET_CAST(TText *,uncompressed),in->TotalOut() / sizeof(TText));
|
sl@0
|
540 |
aTest.Printf(ptr);
|
sl@0
|
541 |
aTest.Printf(_L("\n"));
|
sl@0
|
542 |
}
|
sl@0
|
543 |
else
|
sl@0
|
544 |
{
|
sl@0
|
545 |
TPtrC8 ptr8(uncompressed);
|
sl@0
|
546 |
TPtr ptr16(output,256);
|
sl@0
|
547 |
ptr16.Copy(ptr8);
|
sl@0
|
548 |
aTest.Printf(ptr16);
|
sl@0
|
549 |
aTest.Printf(_L("\n"));
|
sl@0
|
550 |
}
|
sl@0
|
551 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
552 |
}
|
sl@0
|
553 |
|
sl@0
|
554 |
static void DblCompressBufferL(TInt aBufferSize, TBool aReset)
|
sl@0
|
555 |
{
|
sl@0
|
556 |
CEZCompressor *def = NULL;
|
sl@0
|
557 |
|
sl@0
|
558 |
_LIT(KMsg,"\nTesting multi-step compresssion with buffer size %d\n");
|
sl@0
|
559 |
_LIT(KUnMsg,"Uncompressed Size %d\n");
|
sl@0
|
560 |
_LIT(KComMsg,"Compressed Size %d\n");
|
sl@0
|
561 |
|
sl@0
|
562 |
Test.Printf(KMsg,aBufferSize);
|
sl@0
|
563 |
Test.Printf(KSeparator,aBufferSize);
|
sl@0
|
564 |
CBufferManager *bm = CBufferManager::NewLC(original,sizeof(original),compressed,256,aBufferSize);
|
sl@0
|
565 |
def = CEZCompressor::NewLC(*bm);
|
sl@0
|
566 |
|
sl@0
|
567 |
while (def->DeflateL()){}
|
sl@0
|
568 |
|
sl@0
|
569 |
compressedSize = def->TotalOut();
|
sl@0
|
570 |
Test.Printf(KUnMsg,sizeof(original));
|
sl@0
|
571 |
Test.Printf(KComMsg,compressedSize);
|
sl@0
|
572 |
|
sl@0
|
573 |
CleanupStack::Pop();
|
sl@0
|
574 |
CleanupStack::PopAndDestroy();
|
sl@0
|
575 |
CleanupStack::PushL(def);
|
sl@0
|
576 |
|
sl@0
|
577 |
if (aReset)
|
sl@0
|
578 |
{
|
sl@0
|
579 |
bm = CBufferManager::NewLC(original,sizeof(original),compressed,256,aBufferSize);
|
sl@0
|
580 |
def->ResetL(*bm);
|
sl@0
|
581 |
}
|
sl@0
|
582 |
|
sl@0
|
583 |
Test.Printf(KMsg,aBufferSize);
|
sl@0
|
584 |
Test.Printf(KSeparator,aBufferSize);
|
sl@0
|
585 |
|
sl@0
|
586 |
while (def->DeflateL()){}
|
sl@0
|
587 |
|
sl@0
|
588 |
compressedSize = def->TotalOut();
|
sl@0
|
589 |
Test.Printf(KUnMsg,sizeof(original));
|
sl@0
|
590 |
Test.Printf(KComMsg,compressedSize);
|
sl@0
|
591 |
|
sl@0
|
592 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
593 |
}
|
sl@0
|
594 |
|
sl@0
|
595 |
static void DblDecompressBufferL(TInt aBufferSize, TBool aReset)
|
sl@0
|
596 |
{
|
sl@0
|
597 |
CEZDecompressor *def = NULL;
|
sl@0
|
598 |
|
sl@0
|
599 |
_LIT(KMsg,"\nTesting multi-step decompresssion with buffer size %d\n");
|
sl@0
|
600 |
Test.Printf(KMsg,aBufferSize);
|
sl@0
|
601 |
Test.Printf(KSeparator);
|
sl@0
|
602 |
CBufferManager *bm = CBufferManager::NewLC(compressed,compressedSize,uncompressed,256,aBufferSize);
|
sl@0
|
603 |
def = CEZDecompressor::NewLC(*bm);
|
sl@0
|
604 |
|
sl@0
|
605 |
while (def->InflateL()){}
|
sl@0
|
606 |
|
sl@0
|
607 |
CleanupStack::Pop();
|
sl@0
|
608 |
CleanupStack::PopAndDestroy();
|
sl@0
|
609 |
CleanupStack::PushL(def);
|
sl@0
|
610 |
|
sl@0
|
611 |
if (aReset)
|
sl@0
|
612 |
{
|
sl@0
|
613 |
bm = CBufferManager::NewLC(compressed,compressedSize,uncompressed,256,aBufferSize);
|
sl@0
|
614 |
def->ResetL(*bm);
|
sl@0
|
615 |
}
|
sl@0
|
616 |
|
sl@0
|
617 |
Test.Printf(KMsg,aBufferSize);
|
sl@0
|
618 |
Test.Printf(KSeparator,aBufferSize);
|
sl@0
|
619 |
|
sl@0
|
620 |
while (def->InflateL()){}
|
sl@0
|
621 |
|
sl@0
|
622 |
TPtrC8 ptr8(uncompressed);
|
sl@0
|
623 |
TPtr ptr16(output,256);
|
sl@0
|
624 |
ptr16.Copy(ptr8);
|
sl@0
|
625 |
Test.Printf(ptr16);
|
sl@0
|
626 |
Test.Printf(_L("\n"));
|
sl@0
|
627 |
|
sl@0
|
628 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
629 |
}
|
sl@0
|
630 |
|
sl@0
|
631 |
/**
|
sl@0
|
632 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0785
|
sl@0
|
633 |
@SYMTestCaseDesc Multistep compression & decompression test using buffers smaller than source & destination
|
sl@0
|
634 |
@SYMTestPriority High
|
sl@0
|
635 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
636 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
637 |
@SYMREQ REQ0000
|
sl@0
|
638 |
*/
|
sl@0
|
639 |
|
sl@0
|
640 |
void Test1L()
|
sl@0
|
641 |
{
|
sl@0
|
642 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0785 "));
|
sl@0
|
643 |
TTestFlags flags(0,8);
|
sl@0
|
644 |
CompressDecompressL(flags);
|
sl@0
|
645 |
}
|
sl@0
|
646 |
|
sl@0
|
647 |
/**
|
sl@0
|
648 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0786
|
sl@0
|
649 |
@SYMTestCaseDesc Multistep compression & decompression test using buffers larger than source & destination
|
sl@0
|
650 |
@SYMTestPriority High
|
sl@0
|
651 |
@SYMTestActions Set the test flags to 0,buffersize to 1024
|
sl@0
|
652 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
653 |
@SYMREQ REQ0000
|
sl@0
|
654 |
*/
|
sl@0
|
655 |
|
sl@0
|
656 |
void Test2L()
|
sl@0
|
657 |
{
|
sl@0
|
658 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0786 "));
|
sl@0
|
659 |
TTestFlags flags(0,1024);
|
sl@0
|
660 |
CompressDecompressL(flags);
|
sl@0
|
661 |
}
|
sl@0
|
662 |
|
sl@0
|
663 |
/**
|
sl@0
|
664 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0787
|
sl@0
|
665 |
@SYMTestCaseDesc Multistep compression test
|
sl@0
|
666 |
@SYMTestPriority High
|
sl@0
|
667 |
@SYMTestActions Set the test flags to TTestFlags::FakeNoInput,buffersize to 8
|
sl@0
|
668 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
669 |
@SYMREQ REQ0000
|
sl@0
|
670 |
*/
|
sl@0
|
671 |
|
sl@0
|
672 |
void Test3()
|
sl@0
|
673 |
{
|
sl@0
|
674 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0787 "));
|
sl@0
|
675 |
TTestFlags flags(TTestFlags::FakeNoInput,8);
|
sl@0
|
676 |
|
sl@0
|
677 |
TRAPD(err,CompressBufferL(flags));
|
sl@0
|
678 |
Test (err==KErrNone); // This test should succeed as providing no Input is a valid thing for
|
sl@0
|
679 |
// NeedInputL to do.
|
sl@0
|
680 |
}
|
sl@0
|
681 |
|
sl@0
|
682 |
/**
|
sl@0
|
683 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0788
|
sl@0
|
684 |
@SYMTestCaseDesc Multistep compression test when NeedOutput provides no output
|
sl@0
|
685 |
@SYMTestPriority High
|
sl@0
|
686 |
@SYMTestActions Set the test flags to TTestFlags::FakeNoOutput,buffersize to 8
|
sl@0
|
687 |
Check for buffer error.
|
sl@0
|
688 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
689 |
@SYMREQ REQ0000
|
sl@0
|
690 |
*/
|
sl@0
|
691 |
|
sl@0
|
692 |
void Test4()
|
sl@0
|
693 |
{
|
sl@0
|
694 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0788 "));
|
sl@0
|
695 |
TTestFlags flags(TTestFlags::FakeNoOutput,8);
|
sl@0
|
696 |
|
sl@0
|
697 |
TRAPD(err,CompressBufferL(flags));
|
sl@0
|
698 |
Test (err==KEZlibErrBuf);
|
sl@0
|
699 |
}
|
sl@0
|
700 |
|
sl@0
|
701 |
/**
|
sl@0
|
702 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0789
|
sl@0
|
703 |
@SYMTestCaseDesc Multistep compression test with the same CEZCompressor,
|
sl@0
|
704 |
resetting it after the first compression
|
sl@0
|
705 |
@SYMTestPriority High
|
sl@0
|
706 |
@SYMTestActions Set the buffersize to 8,reset value to true
|
sl@0
|
707 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
708 |
@SYMREQ REQ0000
|
sl@0
|
709 |
*/
|
sl@0
|
710 |
|
sl@0
|
711 |
void Test5L()
|
sl@0
|
712 |
{
|
sl@0
|
713 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0789 "));
|
sl@0
|
714 |
DblCompressBufferL(8,ETrue);
|
sl@0
|
715 |
}
|
sl@0
|
716 |
|
sl@0
|
717 |
/**
|
sl@0
|
718 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0790
|
sl@0
|
719 |
@SYMTestCaseDesc Multistep compression test with the same CEZCompressor,
|
sl@0
|
720 |
without resetting it after the first compression
|
sl@0
|
721 |
@SYMTestPriority High
|
sl@0
|
722 |
@SYMTestActions Set the buffersize to 8,reset value to false
|
sl@0
|
723 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
724 |
@SYMREQ REQ0000
|
sl@0
|
725 |
*/
|
sl@0
|
726 |
|
sl@0
|
727 |
void Test6()
|
sl@0
|
728 |
{
|
sl@0
|
729 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0790 "));
|
sl@0
|
730 |
//Calling compress twice without reseting (ie passing in EFalse) causes leave
|
sl@0
|
731 |
TRAPD(err,DblCompressBufferL(8,EFalse));
|
sl@0
|
732 |
Test (err==KEZlibErrDeflateTerminated);
|
sl@0
|
733 |
}
|
sl@0
|
734 |
|
sl@0
|
735 |
/**
|
sl@0
|
736 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0791
|
sl@0
|
737 |
@SYMTestCaseDesc Multistep compression & decompression test using a preset dictionary
|
sl@0
|
738 |
@SYMTestPriority High
|
sl@0
|
739 |
@SYMTestActions Set the test flags to TTestFlags::Dictionary,buffersize to 8
|
sl@0
|
740 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
741 |
@SYMREQ REQ0000
|
sl@0
|
742 |
*/
|
sl@0
|
743 |
|
sl@0
|
744 |
void Test7L()
|
sl@0
|
745 |
{
|
sl@0
|
746 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0791 "));
|
sl@0
|
747 |
TTestFlags flags(TTestFlags::Dictionary,8);
|
sl@0
|
748 |
flags.iDictionary.Set(dictionary,sizeof(dictionary));
|
sl@0
|
749 |
|
sl@0
|
750 |
CompressDecompressL(flags);
|
sl@0
|
751 |
}
|
sl@0
|
752 |
|
sl@0
|
753 |
/**
|
sl@0
|
754 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0792
|
sl@0
|
755 |
@SYMTestCaseDesc Multistep compression with compression level of 0 test
|
sl@0
|
756 |
@SYMTestPriority High
|
sl@0
|
757 |
@SYMTestActions Set the test flags to 0,buffersize to 8,compression level to 0
|
sl@0
|
758 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
759 |
@SYMREQ REQ0000
|
sl@0
|
760 |
*/
|
sl@0
|
761 |
|
sl@0
|
762 |
void Test8L()
|
sl@0
|
763 |
{
|
sl@0
|
764 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0792 "));
|
sl@0
|
765 |
TTestFlags flags(0,8);
|
sl@0
|
766 |
flags.iLevel = 0;
|
sl@0
|
767 |
|
sl@0
|
768 |
CompressDecompressL(flags);
|
sl@0
|
769 |
}
|
sl@0
|
770 |
|
sl@0
|
771 |
/**
|
sl@0
|
772 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0793
|
sl@0
|
773 |
@SYMTestCaseDesc Multistep compression test with compression level of 9
|
sl@0
|
774 |
@SYMTestPriority High
|
sl@0
|
775 |
@SYMTestActions Set the test flags to 0,buffersize to 8,compression level to 9
|
sl@0
|
776 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
777 |
@SYMREQ REQ0000
|
sl@0
|
778 |
*/
|
sl@0
|
779 |
|
sl@0
|
780 |
void Test9L()
|
sl@0
|
781 |
{
|
sl@0
|
782 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0793 "));
|
sl@0
|
783 |
TTestFlags flags(0,8);
|
sl@0
|
784 |
flags.iLevel = 9;
|
sl@0
|
785 |
|
sl@0
|
786 |
CompressDecompressL(flags);
|
sl@0
|
787 |
}
|
sl@0
|
788 |
|
sl@0
|
789 |
/**
|
sl@0
|
790 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0794
|
sl@0
|
791 |
@SYMTestCaseDesc Multistep compression test with invalid compression level
|
sl@0
|
792 |
@SYMTestPriority High
|
sl@0
|
793 |
@SYMTestActions Set the test flags to 0,buffersize to 8,compression level to 10.
|
sl@0
|
794 |
Check for stream error when compression level is greater than 9
|
sl@0
|
795 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
796 |
@SYMREQ REQ0000
|
sl@0
|
797 |
*/
|
sl@0
|
798 |
|
sl@0
|
799 |
void Test10()
|
sl@0
|
800 |
{
|
sl@0
|
801 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0794 "));
|
sl@0
|
802 |
TTestFlags flags(0,8);
|
sl@0
|
803 |
flags.iLevel = 10;
|
sl@0
|
804 |
|
sl@0
|
805 |
TRAPD(err, CompressDecompressL(flags));
|
sl@0
|
806 |
//CompressL fails with KEZlibErrStream if level is greater than 9
|
sl@0
|
807 |
Test (err==KEZlibErrStream);
|
sl@0
|
808 |
}
|
sl@0
|
809 |
|
sl@0
|
810 |
/**
|
sl@0
|
811 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0795
|
sl@0
|
812 |
@SYMTestCaseDesc Multistep compression test with window bits of 7
|
sl@0
|
813 |
@SYMTestPriority High
|
sl@0
|
814 |
@SYMTestActions Set the test flags to 0,buffersize to 7
|
sl@0
|
815 |
Check for stream error if window bits is less than 8
|
sl@0
|
816 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
817 |
@SYMREQ REQ0000
|
sl@0
|
818 |
*/
|
sl@0
|
819 |
|
sl@0
|
820 |
void Test11()
|
sl@0
|
821 |
{
|
sl@0
|
822 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0795 "));
|
sl@0
|
823 |
TTestFlags flags(0,7);
|
sl@0
|
824 |
flags.iWindowBits = 7;
|
sl@0
|
825 |
//CompressL fails with KEZlibErrStream if window bits is less than 8
|
sl@0
|
826 |
TRAPD(err, CompressDecompressL(flags));
|
sl@0
|
827 |
Test (err==KEZlibErrStream);
|
sl@0
|
828 |
}
|
sl@0
|
829 |
|
sl@0
|
830 |
/**
|
sl@0
|
831 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0796
|
sl@0
|
832 |
@SYMTestCaseDesc Multistep compression test with window bits of 7
|
sl@0
|
833 |
@SYMTestPriority High
|
sl@0
|
834 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
835 |
Check for stream error if window bits is less than 9
|
sl@0
|
836 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
837 |
@SYMREQ REQ0000
|
sl@0
|
838 |
*/
|
sl@0
|
839 |
|
sl@0
|
840 |
void Test12()
|
sl@0
|
841 |
{
|
sl@0
|
842 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0796 "));
|
sl@0
|
843 |
TTestFlags flags(0,8);
|
sl@0
|
844 |
flags.iWindowBits = 7;
|
sl@0
|
845 |
//CompressL fails with KEZlibErrStream if window bits is less than 9
|
sl@0
|
846 |
TRAPD(err, CompressDecompressL(flags));
|
sl@0
|
847 |
Test (err==KEZlibErrStream);
|
sl@0
|
848 |
}
|
sl@0
|
849 |
|
sl@0
|
850 |
/**
|
sl@0
|
851 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0797
|
sl@0
|
852 |
@SYMTestCaseDesc Multistep compression test with memory level = 1
|
sl@0
|
853 |
@SYMTestPriority High
|
sl@0
|
854 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
855 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
856 |
@SYMREQ REQ0000
|
sl@0
|
857 |
*/
|
sl@0
|
858 |
|
sl@0
|
859 |
void Test13L()
|
sl@0
|
860 |
{
|
sl@0
|
861 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0797 "));
|
sl@0
|
862 |
TTestFlags flags(0,8);
|
sl@0
|
863 |
flags.iMemLevel = 1;
|
sl@0
|
864 |
|
sl@0
|
865 |
CompressDecompressL(flags);
|
sl@0
|
866 |
}
|
sl@0
|
867 |
|
sl@0
|
868 |
/**
|
sl@0
|
869 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0798
|
sl@0
|
870 |
@SYMTestCaseDesc Multistep compression test with memory level = 10
|
sl@0
|
871 |
@SYMTestPriority High
|
sl@0
|
872 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
873 |
Check for stream error if memory level is greater than 8.
|
sl@0
|
874 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
875 |
@SYMREQ REQ0000
|
sl@0
|
876 |
*/
|
sl@0
|
877 |
|
sl@0
|
878 |
void Test14()
|
sl@0
|
879 |
{
|
sl@0
|
880 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0798 "));
|
sl@0
|
881 |
TTestFlags flags(0,8);
|
sl@0
|
882 |
flags.iMemLevel = 10;
|
sl@0
|
883 |
|
sl@0
|
884 |
//CompressL fails with KEZlibErrStream if mem level greater than 8
|
sl@0
|
885 |
TRAPD(err, CompressDecompressL(flags));
|
sl@0
|
886 |
Test (err==KEZlibErrStream);
|
sl@0
|
887 |
}
|
sl@0
|
888 |
|
sl@0
|
889 |
/**
|
sl@0
|
890 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0799
|
sl@0
|
891 |
@SYMTestCaseDesc Multistep compression test using only Huffman encoding
|
sl@0
|
892 |
@SYMTestPriority High
|
sl@0
|
893 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
894 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
895 |
@SYMREQ REQ0000
|
sl@0
|
896 |
*/
|
sl@0
|
897 |
|
sl@0
|
898 |
void Test15L()
|
sl@0
|
899 |
{
|
sl@0
|
900 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0799 "));
|
sl@0
|
901 |
TTestFlags flags(0,8);
|
sl@0
|
902 |
flags.iStrategy = CEZCompressor::EHuffmanOnly;
|
sl@0
|
903 |
|
sl@0
|
904 |
CompressDecompressL(flags);
|
sl@0
|
905 |
}
|
sl@0
|
906 |
|
sl@0
|
907 |
/**
|
sl@0
|
908 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0800
|
sl@0
|
909 |
@SYMTestCaseDesc Multistep compression test using Filtered strategy
|
sl@0
|
910 |
@SYMTestPriority High
|
sl@0
|
911 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
912 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
913 |
@SYMREQ REQ0000
|
sl@0
|
914 |
*/
|
sl@0
|
915 |
|
sl@0
|
916 |
void Test16L()
|
sl@0
|
917 |
{
|
sl@0
|
918 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0800 "));
|
sl@0
|
919 |
TTestFlags flags(0,8);
|
sl@0
|
920 |
flags.iStrategy = CEZCompressor::EFiltered;
|
sl@0
|
921 |
|
sl@0
|
922 |
CompressDecompressL(flags);
|
sl@0
|
923 |
}
|
sl@0
|
924 |
|
sl@0
|
925 |
/**
|
sl@0
|
926 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0801
|
sl@0
|
927 |
@SYMTestCaseDesc Multistep compression test when Alloc fails randomly
|
sl@0
|
928 |
@SYMTestPriority High
|
sl@0
|
929 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
930 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
931 |
@SYMREQ REQ0000
|
sl@0
|
932 |
*/
|
sl@0
|
933 |
|
sl@0
|
934 |
void Test17()
|
sl@0
|
935 |
{
|
sl@0
|
936 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0801 "));
|
sl@0
|
937 |
TTestFlags flags(TTestFlags::AllocFail,8);
|
sl@0
|
938 |
|
sl@0
|
939 |
TRAPD(err,CompressBufferL(flags));
|
sl@0
|
940 |
Test(err == KErrNone||err == KErrNoMemory); //alloc failure is random so no quarantees of failure
|
sl@0
|
941 |
//Need to reset the heap afterwards to avoid problems for next test.
|
sl@0
|
942 |
__UHEAP_RESET;
|
sl@0
|
943 |
}
|
sl@0
|
944 |
|
sl@0
|
945 |
/**
|
sl@0
|
946 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0802
|
sl@0
|
947 |
@SYMTestCaseDesc Multistep decompression test when NeedInput provides no input
|
sl@0
|
948 |
@SYMTestPriority High
|
sl@0
|
949 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
950 |
Check for data error,when no input is given
|
sl@0
|
951 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
952 |
@SYMREQ REQ0000
|
sl@0
|
953 |
*/
|
sl@0
|
954 |
|
sl@0
|
955 |
void Test18L()
|
sl@0
|
956 |
{
|
sl@0
|
957 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0802 "));
|
sl@0
|
958 |
TTestFlags flags(0,8);
|
sl@0
|
959 |
CompressBufferL(flags); // make sure we initialize compressed properly
|
sl@0
|
960 |
|
sl@0
|
961 |
flags.iFlags |= TTestFlags::FakeNoInput;
|
sl@0
|
962 |
TRAPD(err,DecompressBufferL(flags));
|
sl@0
|
963 |
// CEZDecompressor::InflateL has left with KEZlibErrBuf due to buffer error
|
sl@0
|
964 |
Test (err==KEZlibErrBuf);
|
sl@0
|
965 |
}
|
sl@0
|
966 |
|
sl@0
|
967 |
/**
|
sl@0
|
968 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0803
|
sl@0
|
969 |
@SYMTestCaseDesc Multistep decompression test when NeedOutput provides no output
|
sl@0
|
970 |
@SYMTestPriority High
|
sl@0
|
971 |
@SYMTestActions Set the test flags to 0,buffersize to 8
|
sl@0
|
972 |
Check for data error,when no output is given
|
sl@0
|
973 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
974 |
@SYMREQ REQ0000
|
sl@0
|
975 |
*/
|
sl@0
|
976 |
|
sl@0
|
977 |
void Test19L()
|
sl@0
|
978 |
{
|
sl@0
|
979 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0803 "));
|
sl@0
|
980 |
TTestFlags flags(0,8);
|
sl@0
|
981 |
CompressBufferL(flags); // make sure we initialize compressed properly
|
sl@0
|
982 |
|
sl@0
|
983 |
flags.iFlags |= TTestFlags::FakeNoOutput;
|
sl@0
|
984 |
TRAPD(err,DecompressBufferL(flags));
|
sl@0
|
985 |
// CEZDecompressor::InflateL has left with KEZlibErrBuf due to buffer error
|
sl@0
|
986 |
Test (err==KEZlibErrBuf);
|
sl@0
|
987 |
}
|
sl@0
|
988 |
|
sl@0
|
989 |
/**
|
sl@0
|
990 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0804
|
sl@0
|
991 |
@SYMTestCaseDesc Multistep decompression test when NeedOutput provides no output
|
sl@0
|
992 |
@SYMTestPriority High
|
sl@0
|
993 |
@SYMTestActions Set the test flags to TTestFlags::Corrupt, buffersize to 8
|
sl@0
|
994 |
Check for data error
|
sl@0
|
995 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
996 |
@SYMREQ REQ0000
|
sl@0
|
997 |
*/
|
sl@0
|
998 |
|
sl@0
|
999 |
void Test20L()
|
sl@0
|
1000 |
{
|
sl@0
|
1001 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0804 "));
|
sl@0
|
1002 |
TTestFlags flags(TTestFlags::Corrupt,8);
|
sl@0
|
1003 |
CompressBufferL(flags); // make sure we initialize compressed properly
|
sl@0
|
1004 |
|
sl@0
|
1005 |
flags.iFlags = 0;
|
sl@0
|
1006 |
|
sl@0
|
1007 |
TRAPD(err,DecompressBufferL(flags));
|
sl@0
|
1008 |
// CEZDecompressor::InflateL has left with KEZlibErrData due to buffer error
|
sl@0
|
1009 |
Test (err==KEZlibErrData);
|
sl@0
|
1010 |
}
|
sl@0
|
1011 |
|
sl@0
|
1012 |
/**
|
sl@0
|
1013 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0805
|
sl@0
|
1014 |
@SYMTestCaseDesc Multistep decompression construction test when Alloc fails randomly
|
sl@0
|
1015 |
@SYMTestPriority High
|
sl@0
|
1016 |
@SYMTestActions Set the test flags to 0, buffersize to 8
|
sl@0
|
1017 |
Check for data error
|
sl@0
|
1018 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
1019 |
@SYMREQ REQ0000
|
sl@0
|
1020 |
*/
|
sl@0
|
1021 |
|
sl@0
|
1022 |
void Test21L()
|
sl@0
|
1023 |
{
|
sl@0
|
1024 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0805 "));
|
sl@0
|
1025 |
TTestFlags flags(0,8);
|
sl@0
|
1026 |
CompressBufferL(flags); // make sure we initialize compressed properly
|
sl@0
|
1027 |
|
sl@0
|
1028 |
flags.iFlags |= TTestFlags::AllocFail;
|
sl@0
|
1029 |
|
sl@0
|
1030 |
TRAPD(err,DecompressBufferL(flags));
|
sl@0
|
1031 |
Test (err==KErrNone||err==KErrNoMemory); //Alloc failure is random so no guarantee it will always fail.
|
sl@0
|
1032 |
__UHEAP_RESET;
|
sl@0
|
1033 |
}
|
sl@0
|
1034 |
|
sl@0
|
1035 |
/**
|
sl@0
|
1036 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0806
|
sl@0
|
1037 |
@SYMTestCaseDesc Multistep decompression test when Alloc fails randomly
|
sl@0
|
1038 |
@SYMTestPriority High
|
sl@0
|
1039 |
@SYMTestActions Set the test flags to 0, buffersize to 8
|
sl@0
|
1040 |
Check for no memory errors.
|
sl@0
|
1041 |
@SYMTestExpectedResults The test must not fail.
|
sl@0
|
1042 |
@SYMREQ REQ0000
|
sl@0
|
1043 |
*/
|
sl@0
|
1044 |
|
sl@0
|
1045 |
void Test22L()
|
sl@0
|
1046 |
{
|
sl@0
|
1047 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0806 "));
|
sl@0
|
1048 |
TTestFlags flags(0,8);
|
sl@0
|
1049 |
CompressBufferL(flags); // make sure we initialize compressed properly
|
sl@0
|
1050 |
|
sl@0
|
1051 |
flags.iFlags |= TTestFlags::AllocFailInflate;
|
sl@0
|
1052 |
|
sl@0
|
1053 |
TRAPD(err,DecompressBufferL(flags));
|
sl@0
|
1054 |
Test (err==KErrNone||err==KErrNoMemory); //Alloc failure is random so no guarentee it will always fail.
|
sl@0
|
1055 |
__UHEAP_RESET;
|
sl@0
|
1056 |
}
|
sl@0
|
1057 |
|
sl@0
|
1058 |
static void ThreadL()
|
sl@0
|
1059 |
{
|
sl@0
|
1060 |
RTest test2(_L("EZLIB - second thread"));
|
sl@0
|
1061 |
test2.Title();
|
sl@0
|
1062 |
_LIT(KStartMsg,"Starting Tests in second thread");
|
sl@0
|
1063 |
test2.Start(KStartMsg);
|
sl@0
|
1064 |
|
sl@0
|
1065 |
TTestFlags flags(TTestFlags::Dictionary,8);
|
sl@0
|
1066 |
flags.iDictionary.Set(dictionary,sizeof(dictionary));
|
sl@0
|
1067 |
|
sl@0
|
1068 |
TRAPD(err,CompressBufferL(flags, test2));
|
sl@0
|
1069 |
test2 (err == KErrNone);
|
sl@0
|
1070 |
flags.iFlags = 0;
|
sl@0
|
1071 |
//This code leaves (used to panic before the fix for DEF112672)
|
sl@0
|
1072 |
DecompressBufferL(flags, test2);
|
sl@0
|
1073 |
User::Panic(_L("TestFailure failure"),0);
|
sl@0
|
1074 |
test2.End();
|
sl@0
|
1075 |
test2.Close();
|
sl@0
|
1076 |
}
|
sl@0
|
1077 |
|
sl@0
|
1078 |
static TInt TestThread(TAny*)
|
sl@0
|
1079 |
{
|
sl@0
|
1080 |
User::SetJustInTime(EFalse); // disable debugger panic handling
|
sl@0
|
1081 |
CTrapCleanup* cleanup=CTrapCleanup::New();
|
sl@0
|
1082 |
if (!cleanup)
|
sl@0
|
1083 |
return KErrNoMemory;
|
sl@0
|
1084 |
TRAPD(r,ThreadL());
|
sl@0
|
1085 |
delete cleanup;
|
sl@0
|
1086 |
return r;
|
sl@0
|
1087 |
}
|
sl@0
|
1088 |
|
sl@0
|
1089 |
/**
|
sl@0
|
1090 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0807
|
sl@0
|
1091 |
@SYMTestCaseDesc Multistep decompression test when a dictionary is required and not provided.
|
sl@0
|
1092 |
@SYMTestPriority High
|
sl@0
|
1093 |
@SYMTestActions Test for panic and exit reason.
|
sl@0
|
1094 |
@SYMTestExpectedResults This test should pass without panic.
|
sl@0
|
1095 |
(Expected to panic before the fix for DEF112672)
|
sl@0
|
1096 |
@SYMREQ REQ0000
|
sl@0
|
1097 |
*/
|
sl@0
|
1098 |
|
sl@0
|
1099 |
void Test23()
|
sl@0
|
1100 |
{
|
sl@0
|
1101 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0807 "));
|
sl@0
|
1102 |
__UHEAP_MARK;
|
sl@0
|
1103 |
|
sl@0
|
1104 |
RThread t;
|
sl@0
|
1105 |
_LIT(KTestThread,"Panicing thread");
|
sl@0
|
1106 |
Test.Printf(_L("launching thread"));
|
sl@0
|
1107 |
Test (t.Create(KTestThread,&TestThread,0x2000,0x10000,0x100000,0,EOwnerThread) == KErrNone);
|
sl@0
|
1108 |
TRequestStatus s;
|
sl@0
|
1109 |
t.Logon(s);
|
sl@0
|
1110 |
Test (s.Int()==KRequestPending);
|
sl@0
|
1111 |
t.Resume();
|
sl@0
|
1112 |
Test.Printf(_L("Awaiting completion"));
|
sl@0
|
1113 |
User::WaitForRequest(s);
|
sl@0
|
1114 |
User::SetJustInTime(ETrue); // enable debugger panic handling
|
sl@0
|
1115 |
_LIT(KCategory,"zlib");
|
sl@0
|
1116 |
Test (t.ExitType()==EExitKill);
|
sl@0
|
1117 |
Test (t.ExitCategory()!=KCategory);
|
sl@0
|
1118 |
Test (t.ExitReason()==KEZlibErrData);// SetDictionaryL() leaving error code should be KEZlibErrData
|
sl@0
|
1119 |
t.Close();
|
sl@0
|
1120 |
|
sl@0
|
1121 |
__UHEAP_MARKEND;
|
sl@0
|
1122 |
|
sl@0
|
1123 |
}
|
sl@0
|
1124 |
|
sl@0
|
1125 |
/**
|
sl@0
|
1126 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0808
|
sl@0
|
1127 |
@SYMTestCaseDesc Multistep decompression test when the wrong dictionary is provided
|
sl@0
|
1128 |
@SYMTestPriority High
|
sl@0
|
1129 |
@SYMTestActions Check for an error during inflating the dictionary
|
sl@0
|
1130 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1131 |
@SYMREQ REQ0000
|
sl@0
|
1132 |
*/
|
sl@0
|
1133 |
|
sl@0
|
1134 |
void Test24L()
|
sl@0
|
1135 |
{
|
sl@0
|
1136 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0808 "));
|
sl@0
|
1137 |
TTestFlags flags(TTestFlags::Dictionary,8);
|
sl@0
|
1138 |
flags.iDictionary.Set(dictionary,sizeof(dictionary));
|
sl@0
|
1139 |
|
sl@0
|
1140 |
CompressBufferL(flags);
|
sl@0
|
1141 |
|
sl@0
|
1142 |
flags.iDictionary.Set(badDictionary,sizeof(badDictionary));
|
sl@0
|
1143 |
|
sl@0
|
1144 |
TRAPD(err,DecompressBufferL(flags));
|
sl@0
|
1145 |
// CEZDecompressor::SetDictionaryL() has left due to bad data
|
sl@0
|
1146 |
Test (err==KEZlibErrInflateDictionary);
|
sl@0
|
1147 |
}
|
sl@0
|
1148 |
|
sl@0
|
1149 |
/**
|
sl@0
|
1150 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0809
|
sl@0
|
1151 |
@SYMTestCaseDesc Multistep decompression test twice with the same CEZDecompressor,
|
sl@0
|
1152 |
reseting it after the first decompression
|
sl@0
|
1153 |
@SYMTestPriority High
|
sl@0
|
1154 |
@SYMTestActions Set the test flags to 0,buffersize to 8,reset value to TRUE
|
sl@0
|
1155 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1156 |
@SYMREQ REQ0000
|
sl@0
|
1157 |
*/
|
sl@0
|
1158 |
|
sl@0
|
1159 |
void Test25L()
|
sl@0
|
1160 |
{
|
sl@0
|
1161 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0809 "));
|
sl@0
|
1162 |
TTestFlags flags(0,8);
|
sl@0
|
1163 |
CompressBufferL(flags); // make sure we initialize compressed properly
|
sl@0
|
1164 |
|
sl@0
|
1165 |
DblDecompressBufferL(8,ETrue);
|
sl@0
|
1166 |
}
|
sl@0
|
1167 |
|
sl@0
|
1168 |
/**
|
sl@0
|
1169 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0810
|
sl@0
|
1170 |
@SYMTestCaseDesc Multistep decompression test twice with the same CEZDecompressor,
|
sl@0
|
1171 |
resetting it after the first decompression
|
sl@0
|
1172 |
@SYMTestPriority High
|
sl@0
|
1173 |
@SYMTestActions Set the test flags to 0,buffersize to 8,reset value to FALSE
|
sl@0
|
1174 |
Check for deflation already occured.
|
sl@0
|
1175 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1176 |
@SYMREQ REQ0000
|
sl@0
|
1177 |
*/
|
sl@0
|
1178 |
|
sl@0
|
1179 |
void Test26L()
|
sl@0
|
1180 |
{
|
sl@0
|
1181 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0810 "));
|
sl@0
|
1182 |
TTestFlags flags(0,8);
|
sl@0
|
1183 |
CompressBufferL(flags); // make sure we initialize compressed properly
|
sl@0
|
1184 |
|
sl@0
|
1185 |
TRAPD(err,DblDecompressBufferL(8,EFalse));
|
sl@0
|
1186 |
//Calling decompress twice without resenting causes leave
|
sl@0
|
1187 |
Test (err==KEZlibErrInflateTerminated);
|
sl@0
|
1188 |
}
|
sl@0
|
1189 |
|
sl@0
|
1190 |
/**
|
sl@0
|
1191 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0811
|
sl@0
|
1192 |
@SYMTestCaseDesc Multistep compression and decompression test on unicode data
|
sl@0
|
1193 |
@SYMTestPriority High
|
sl@0
|
1194 |
@SYMTestActions Set the test flags to TTestFlags::Unicode,buffersize to 8
|
sl@0
|
1195 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1196 |
@SYMREQ REQ0000
|
sl@0
|
1197 |
*/
|
sl@0
|
1198 |
|
sl@0
|
1199 |
void Test27L()
|
sl@0
|
1200 |
{
|
sl@0
|
1201 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0811 "));
|
sl@0
|
1202 |
TPtrC8 ptr8(original);
|
sl@0
|
1203 |
TPtr ptr16(originalU,256);
|
sl@0
|
1204 |
ptr16.Copy(ptr8);
|
sl@0
|
1205 |
|
sl@0
|
1206 |
TTestFlags flags(TTestFlags::Unicode,8);
|
sl@0
|
1207 |
TPtrC8(REINTERPRET_CAST(TUint8 *,originalU),ptr16.Size());
|
sl@0
|
1208 |
CompressDecompressL(flags);
|
sl@0
|
1209 |
}
|
sl@0
|
1210 |
|
sl@0
|
1211 |
/**
|
sl@0
|
1212 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0812
|
sl@0
|
1213 |
@SYMTestCaseDesc Multistep compression and decompression test on unicode data using a unicode dictionary
|
sl@0
|
1214 |
@SYMTestPriority High
|
sl@0
|
1215 |
@SYMTestActions Set the test flags to TTestFlags::Dictionary|TTestFlags::Unicode,buffersize to 8
|
sl@0
|
1216 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1217 |
@SYMREQ REQ0000
|
sl@0
|
1218 |
*/
|
sl@0
|
1219 |
|
sl@0
|
1220 |
void Test28L()
|
sl@0
|
1221 |
{
|
sl@0
|
1222 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0812 "));
|
sl@0
|
1223 |
TPtrC8 ptr8(original);
|
sl@0
|
1224 |
TPtr ptr16(originalU,256);
|
sl@0
|
1225 |
ptr16.Copy(ptr8);
|
sl@0
|
1226 |
|
sl@0
|
1227 |
TPtrC8 dptr8(dictionary);
|
sl@0
|
1228 |
TPtr dptr16(dictionaryU,256);
|
sl@0
|
1229 |
dptr16.Copy(dptr8);
|
sl@0
|
1230 |
|
sl@0
|
1231 |
|
sl@0
|
1232 |
TTestFlags flags(TTestFlags::Dictionary|TTestFlags::Unicode,8);
|
sl@0
|
1233 |
flags.iDictionary.Set(REINTERPRET_CAST(TUint8*, dictionaryU),dptr16.Size());
|
sl@0
|
1234 |
|
sl@0
|
1235 |
TPtrC8(REINTERPRET_CAST(TUint8 *,originalU),ptr16.Size());
|
sl@0
|
1236 |
CompressDecompressL(flags);
|
sl@0
|
1237 |
}
|
sl@0
|
1238 |
|
sl@0
|
1239 |
/**
|
sl@0
|
1240 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0813
|
sl@0
|
1241 |
@SYMTestCaseDesc Multistep compression and decompression test on unicode data using an ASCII dictionary
|
sl@0
|
1242 |
@SYMTestPriority High
|
sl@0
|
1243 |
@SYMTestActions Set the test flags to TTestFlags::Dictionary|TTestFlags::Unicode,buffersize to 8
|
sl@0
|
1244 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1245 |
@SYMREQ REQ0000
|
sl@0
|
1246 |
*/
|
sl@0
|
1247 |
|
sl@0
|
1248 |
void Test29L()
|
sl@0
|
1249 |
{
|
sl@0
|
1250 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0813 "));
|
sl@0
|
1251 |
TPtrC8 ptr8(original);
|
sl@0
|
1252 |
TPtr ptr16(originalU,256);
|
sl@0
|
1253 |
ptr16.Copy(ptr8);
|
sl@0
|
1254 |
|
sl@0
|
1255 |
TTestFlags flags(TTestFlags::Dictionary|TTestFlags::Unicode,8);
|
sl@0
|
1256 |
flags.iDictionary.Set(dictionary,sizeof(dictionary));
|
sl@0
|
1257 |
|
sl@0
|
1258 |
TPtrC8(REINTERPRET_CAST(TUint8 *,originalU),ptr16.Size());
|
sl@0
|
1259 |
CompressDecompressL(flags);
|
sl@0
|
1260 |
}
|
sl@0
|
1261 |
|
sl@0
|
1262 |
/**
|
sl@0
|
1263 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0814
|
sl@0
|
1264 |
@SYMTestCaseDesc Tests the percentage of completion during multistep compression/decompression
|
sl@0
|
1265 |
@SYMTestPriority High
|
sl@0
|
1266 |
@SYMTestActions Set the test flags to TTestFlags::Percent,buffersize to 8
|
sl@0
|
1267 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1268 |
@SYMREQ REQ0000
|
sl@0
|
1269 |
*/
|
sl@0
|
1270 |
|
sl@0
|
1271 |
void Test30L()
|
sl@0
|
1272 |
{
|
sl@0
|
1273 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0814 "));
|
sl@0
|
1274 |
TTestFlags flags(TTestFlags::Percent,8);
|
sl@0
|
1275 |
|
sl@0
|
1276 |
CompressDecompressL(flags);
|
sl@0
|
1277 |
}
|
sl@0
|
1278 |
|
sl@0
|
1279 |
/**
|
sl@0
|
1280 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0815
|
sl@0
|
1281 |
@SYMTestCaseDesc Single step compression and decompression test
|
sl@0
|
1282 |
@SYMTestPriority High
|
sl@0
|
1283 |
@SYMTestActions Calls up CEZCompressor::CompressL(),CEZCompressor::DecompressL() test
|
sl@0
|
1284 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1285 |
@SYMREQ REQ0000
|
sl@0
|
1286 |
*/
|
sl@0
|
1287 |
|
sl@0
|
1288 |
void Test31L()
|
sl@0
|
1289 |
{
|
sl@0
|
1290 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0815 "));
|
sl@0
|
1291 |
TPtrC8 originalD(original,sizeof(original));
|
sl@0
|
1292 |
TPtr8 compressedD(compressed,0,256);
|
sl@0
|
1293 |
TPtr8 uncompressedD(uncompressed,0,256);
|
sl@0
|
1294 |
CEZCompressor::CompressL(compressedD,originalD);
|
sl@0
|
1295 |
CEZDecompressor::DecompressL(uncompressedD,compressedD);
|
sl@0
|
1296 |
|
sl@0
|
1297 |
Test.Printf(_L("\n"));
|
sl@0
|
1298 |
Test.Printf(KSeparator);
|
sl@0
|
1299 |
TPtr ptr16(output,256);
|
sl@0
|
1300 |
ptr16.Copy(uncompressedD);
|
sl@0
|
1301 |
Test.Printf(ptr16);
|
sl@0
|
1302 |
Test.Printf(_L("\n"));
|
sl@0
|
1303 |
Test(originalD.Compare(uncompressedD) == 0,__LINE__);
|
sl@0
|
1304 |
}
|
sl@0
|
1305 |
|
sl@0
|
1306 |
/**
|
sl@0
|
1307 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0816
|
sl@0
|
1308 |
@SYMTestCaseDesc Single step compression test when inadequate output buffer is provided
|
sl@0
|
1309 |
@SYMTestPriority High
|
sl@0
|
1310 |
@SYMTestActions Check for EZlibErrBuf buffer error flag
|
sl@0
|
1311 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1312 |
@SYMREQ REQ0000
|
sl@0
|
1313 |
*/
|
sl@0
|
1314 |
|
sl@0
|
1315 |
void Test32()
|
sl@0
|
1316 |
{
|
sl@0
|
1317 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0816 "));
|
sl@0
|
1318 |
TPtrC8 originalD(original,sizeof(original));
|
sl@0
|
1319 |
TPtr8 compressedD(compressed,0,1);
|
sl@0
|
1320 |
|
sl@0
|
1321 |
Test.Printf(_L("\n"));
|
sl@0
|
1322 |
Test.Printf(KSeparator);
|
sl@0
|
1323 |
|
sl@0
|
1324 |
TRAPD(err,CEZCompressor::CompressL(compressedD,originalD));
|
sl@0
|
1325 |
// Buffer error
|
sl@0
|
1326 |
Test(err == KEZlibErrBuf);
|
sl@0
|
1327 |
}
|
sl@0
|
1328 |
|
sl@0
|
1329 |
/**
|
sl@0
|
1330 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0817
|
sl@0
|
1331 |
@SYMTestCaseDesc Single step decompression test when inadequate output buffer is provided
|
sl@0
|
1332 |
@SYMTestPriority High
|
sl@0
|
1333 |
@SYMTestActions Check for EZlibErrBuf buffer error flag
|
sl@0
|
1334 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1335 |
@SYMREQ REQ0000
|
sl@0
|
1336 |
*/
|
sl@0
|
1337 |
|
sl@0
|
1338 |
void Test33L()
|
sl@0
|
1339 |
{
|
sl@0
|
1340 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0817 "));
|
sl@0
|
1341 |
Test.Printf(_L("\n"));
|
sl@0
|
1342 |
Test.Printf(KSeparator);
|
sl@0
|
1343 |
TPtrC8 originalD(original,sizeof(original));
|
sl@0
|
1344 |
TPtr8 compressedD(compressed,0,256);
|
sl@0
|
1345 |
TPtr8 uncompressedD(uncompressed,0,1);
|
sl@0
|
1346 |
CEZCompressor::CompressL(compressedD,originalD);
|
sl@0
|
1347 |
TRAPD(err,CEZDecompressor::DecompressL(uncompressedD,compressedD));
|
sl@0
|
1348 |
// Buffer error
|
sl@0
|
1349 |
Test(err == KEZlibErrBuf);
|
sl@0
|
1350 |
}
|
sl@0
|
1351 |
|
sl@0
|
1352 |
/**
|
sl@0
|
1353 |
@SYMTestCaseID SYSLIB-EZLIB-CT-0818
|
sl@0
|
1354 |
@SYMTestCaseDesc Testing graceful exit for zlib 1.1.3 decompression bug
|
sl@0
|
1355 |
@SYMTestPriority High
|
sl@0
|
1356 |
@SYMTestActions Check for buffer error after inflation
|
sl@0
|
1357 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1358 |
@SYMREQ REQ0000
|
sl@0
|
1359 |
*/
|
sl@0
|
1360 |
void Test34L()
|
sl@0
|
1361 |
{
|
sl@0
|
1362 |
Test.Printf(_L("\n"));
|
sl@0
|
1363 |
Test.Printf(KSeparator);
|
sl@0
|
1364 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-0818 "));
|
sl@0
|
1365 |
// 00000720.png contains specially crafted data block that exposes bug in 1.1.3
|
sl@0
|
1366 |
// decompression algorithm. Causes InflateL() to return Z_BUF_ERROR.
|
sl@0
|
1367 |
#if !defined(__WINS__)
|
sl@0
|
1368 |
_LIT(KInputFile, "z:\\test\\png\\00000720.png");
|
sl@0
|
1369 |
#else
|
sl@0
|
1370 |
_LIT(KInputFile, "c:\\test\\png\\00000720.png");
|
sl@0
|
1371 |
#endif
|
sl@0
|
1372 |
_LIT(KTempDirectory, "c:\\test\\temp\\");
|
sl@0
|
1373 |
RFile input, output, tempInput;
|
sl@0
|
1374 |
RFs rfs;
|
sl@0
|
1375 |
rfs.Connect();
|
sl@0
|
1376 |
rfs.MkDirAll(KTempDirectory);
|
sl@0
|
1377 |
|
sl@0
|
1378 |
TInt res = input.Open(rfs, KInputFile, EFileStream | EFileRead | EFileShareAny);
|
sl@0
|
1379 |
Test(res==KErrNone);
|
sl@0
|
1380 |
CleanupClosePushL(input);
|
sl@0
|
1381 |
|
sl@0
|
1382 |
TFileName filename;
|
sl@0
|
1383 |
TBuf8<1024> readBuf;
|
sl@0
|
1384 |
TInt fileLen;
|
sl@0
|
1385 |
input.Size(fileLen);
|
sl@0
|
1386 |
res = input.Read(8,readBuf,fileLen);
|
sl@0
|
1387 |
Test(res==KErrNone);
|
sl@0
|
1388 |
|
sl@0
|
1389 |
res = tempInput.Temp(rfs, KTempDirectory, filename, EFileStream | EFileWrite | EFileShareExclusive);
|
sl@0
|
1390 |
Test(res==KErrNone);
|
sl@0
|
1391 |
CleanupClosePushL(tempInput);
|
sl@0
|
1392 |
res = tempInput.Write(readBuf, fileLen-8); // Create temporary file without the 8 byte PNG header.
|
sl@0
|
1393 |
Test(res==KErrNone);
|
sl@0
|
1394 |
|
sl@0
|
1395 |
CEZFileBufferManager *fb = CEZFileBufferManager::NewLC(tempInput, output, 4096);
|
sl@0
|
1396 |
CEZDecompressor *inf = CEZDecompressor::NewLC(*fb);
|
sl@0
|
1397 |
|
sl@0
|
1398 |
TRAPD(err, while (inf->InflateL()){});
|
sl@0
|
1399 |
//CEZDecompressor::InflateL() leaves
|
sl@0
|
1400 |
Test (err==KEZlibErrBuf);
|
sl@0
|
1401 |
|
sl@0
|
1402 |
tempInput.Close();
|
sl@0
|
1403 |
User::LeaveIfError(rfs.Delete(filename));
|
sl@0
|
1404 |
input.Close();
|
sl@0
|
1405 |
CleanupStack::PopAndDestroy(4);
|
sl@0
|
1406 |
}
|
sl@0
|
1407 |
|
sl@0
|
1408 |
#if !(defined(__WINSCW__) || defined (_DEBUG))
|
sl@0
|
1409 |
void DecompressFileL(const TDesC& aFilePath, RFs& aFs, TInt aTimingLimit)
|
sl@0
|
1410 |
{
|
sl@0
|
1411 |
_LIT(KTempDirectory, "c:\\test\\temp\\");
|
sl@0
|
1412 |
aFs.MkDirAll(KTempDirectory);
|
sl@0
|
1413 |
|
sl@0
|
1414 |
RFile inputFile, tempFile;
|
sl@0
|
1415 |
//open the input compressed file
|
sl@0
|
1416 |
TInt res = inputFile.Open(aFs, aFilePath, EFileStream | EFileRead | EFileShareExclusive);
|
sl@0
|
1417 |
Test(res==KErrNone);
|
sl@0
|
1418 |
CleanupClosePushL(inputFile);
|
sl@0
|
1419 |
|
sl@0
|
1420 |
//create a temporary file to be used as an output of the decompressor
|
sl@0
|
1421 |
TFileName filename;
|
sl@0
|
1422 |
res = tempFile.Temp(aFs, KTempDirectory, filename, EFileStream | EFileWrite | EFileShareExclusive);
|
sl@0
|
1423 |
Test(res==KErrNone);
|
sl@0
|
1424 |
CleanupClosePushL(tempFile);
|
sl@0
|
1425 |
|
sl@0
|
1426 |
//decompress the data from the input file several times
|
sl@0
|
1427 |
TInt startTime = User::FastCounter();
|
sl@0
|
1428 |
for (TInt i = 0; i<10; i++)
|
sl@0
|
1429 |
{
|
sl@0
|
1430 |
TInt position = 0;
|
sl@0
|
1431 |
inputFile.Seek(ESeekStart,position);
|
sl@0
|
1432 |
CEZFileBufferManager *fb = CEZFileBufferManager::NewLC(inputFile, tempFile, 4096);
|
sl@0
|
1433 |
//create a decompressor object based on the file buffer manager
|
sl@0
|
1434 |
CEZDecompressor *decompressor = CEZDecompressor::NewLC(*fb);
|
sl@0
|
1435 |
TRAP(res, while (decompressor->InflateL()){});
|
sl@0
|
1436 |
Test(res==KErrNone);
|
sl@0
|
1437 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
1438 |
}
|
sl@0
|
1439 |
TInt endTime = User::FastCounter();
|
sl@0
|
1440 |
|
sl@0
|
1441 |
//close input and temporary file
|
sl@0
|
1442 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
1443 |
//delete temporary file
|
sl@0
|
1444 |
aFs.Delete(filename);
|
sl@0
|
1445 |
|
sl@0
|
1446 |
TReal netTime = FastCountToMilliseconds(endTime-startTime);
|
sl@0
|
1447 |
_LIT(KLogLine,"netTime =%f\n");
|
sl@0
|
1448 |
Test.Printf(KLogLine,netTime);
|
sl@0
|
1449 |
|
sl@0
|
1450 |
if (aTimingLimit)
|
sl@0
|
1451 |
{
|
sl@0
|
1452 |
Test(netTime <= aTimingLimit);
|
sl@0
|
1453 |
}
|
sl@0
|
1454 |
else
|
sl@0
|
1455 |
{
|
sl@0
|
1456 |
Test.Printf(_L("Timings results are only checked on the RAM configuration of H2 and H4 HRP\n"));
|
sl@0
|
1457 |
}
|
sl@0
|
1458 |
}
|
sl@0
|
1459 |
#endif
|
sl@0
|
1460 |
|
sl@0
|
1461 |
/**
|
sl@0
|
1462 |
@SYMTestCaseID SYSLIB-EZLIB-CT-3426
|
sl@0
|
1463 |
@SYMTestCaseDesc Testing EZlib decompressor performance after enforcing compiler optimisation
|
sl@0
|
1464 |
@SYMTestPriority Medium
|
sl@0
|
1465 |
@SYMTestActions This test uses several typical pieces of compressed
|
sl@0
|
1466 |
image data as an input and inflates them 10 times.
|
sl@0
|
1467 |
The total duration of this operation is measured and
|
sl@0
|
1468 |
compared against a benchmarking limit. Only performed
|
sl@0
|
1469 |
on UREL builds running on H2 and H4 hardware.
|
sl@0
|
1470 |
@SYMTestExpectedResults Time spent on decompression should be less than a preset limit.
|
sl@0
|
1471 |
@SYMREQ REQ7363
|
sl@0
|
1472 |
*/
|
sl@0
|
1473 |
|
sl@0
|
1474 |
void Test35L()
|
sl@0
|
1475 |
{
|
sl@0
|
1476 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-3426 "));
|
sl@0
|
1477 |
#if !(defined(__WINSCW__) || defined (_DEBUG))
|
sl@0
|
1478 |
Test.Printf(_L("\n"));
|
sl@0
|
1479 |
Test.Printf(KSeparator);
|
sl@0
|
1480 |
_LIT(KInputFile1, "z:\\test\\png\\compressed_data1");//A small-sized picture with
|
sl@0
|
1481 |
//transparent background which
|
sl@0
|
1482 |
//represents typical UI component
|
sl@0
|
1483 |
//icon.
|
sl@0
|
1484 |
|
sl@0
|
1485 |
_LIT(KInputFile2, "z:\\test\\png\\compressed_data2");//Medium-sized picture with a
|
sl@0
|
1486 |
//single image typical for a UI
|
sl@0
|
1487 |
//theme background image
|
sl@0
|
1488 |
|
sl@0
|
1489 |
_LIT(KInputFile3, "z:\\test\\png\\compressed_data3");//Medium-sized picture with
|
sl@0
|
1490 |
//multiple small images on it
|
sl@0
|
1491 |
//typical for a sheet of UI
|
sl@0
|
1492 |
//component skins
|
sl@0
|
1493 |
|
sl@0
|
1494 |
_LIT(KInputFile4, "z:\\test\\png\\compressed_data4");//Large-sized photo image
|
sl@0
|
1495 |
|
sl@0
|
1496 |
RFs rfs;
|
sl@0
|
1497 |
rfs.Connect();
|
sl@0
|
1498 |
CleanupClosePushL(rfs);
|
sl@0
|
1499 |
|
sl@0
|
1500 |
// determine media type of C drive
|
sl@0
|
1501 |
TDriveInfo driveInf;
|
sl@0
|
1502 |
TInt res = rfs.Drive(driveInf, EDriveC);
|
sl@0
|
1503 |
Test(res==KErrNone);
|
sl@0
|
1504 |
|
sl@0
|
1505 |
TInt timingLimit1 = 0;
|
sl@0
|
1506 |
TInt timingLimit2 = 0;
|
sl@0
|
1507 |
TInt timingLimit3 = 0;
|
sl@0
|
1508 |
TInt timingLimit4 = 0;
|
sl@0
|
1509 |
// only check benchmarks if running on hardware, with UREL + RAM build (i.e. not NAND)
|
sl@0
|
1510 |
if (driveInf.iType == EMediaRam)
|
sl@0
|
1511 |
{
|
sl@0
|
1512 |
TInt muid = 0;
|
sl@0
|
1513 |
res= HAL::Get(HAL::EMachineUid, muid);
|
sl@0
|
1514 |
Test(res==KErrNone);
|
sl@0
|
1515 |
switch (muid)
|
sl@0
|
1516 |
{
|
sl@0
|
1517 |
case HAL::EMachineUid_OmapH2:
|
sl@0
|
1518 |
timingLimit1 = 350;
|
sl@0
|
1519 |
timingLimit2 = 1650;
|
sl@0
|
1520 |
timingLimit3 = 2900;
|
sl@0
|
1521 |
timingLimit4 = 2750;
|
sl@0
|
1522 |
break;
|
sl@0
|
1523 |
case HAL::EMachineUid_OmapH4:
|
sl@0
|
1524 |
timingLimit1 = 200;
|
sl@0
|
1525 |
timingLimit2 = 850;
|
sl@0
|
1526 |
timingLimit3 = 1400;
|
sl@0
|
1527 |
timingLimit4 = 1500;
|
sl@0
|
1528 |
break;
|
sl@0
|
1529 |
default:
|
sl@0
|
1530 |
break;
|
sl@0
|
1531 |
}
|
sl@0
|
1532 |
}
|
sl@0
|
1533 |
|
sl@0
|
1534 |
DecompressFileL(KInputFile1, rfs, timingLimit1);
|
sl@0
|
1535 |
DecompressFileL(KInputFile2, rfs, timingLimit2);
|
sl@0
|
1536 |
DecompressFileL(KInputFile3, rfs, timingLimit3);
|
sl@0
|
1537 |
DecompressFileL(KInputFile4, rfs, timingLimit4);
|
sl@0
|
1538 |
CleanupStack::PopAndDestroy();
|
sl@0
|
1539 |
#else
|
sl@0
|
1540 |
Test.Printf(_L("This test is only performed on hardware UREL builds\n"));
|
sl@0
|
1541 |
#endif
|
sl@0
|
1542 |
}
|
sl@0
|
1543 |
|
sl@0
|
1544 |
/**
|
sl@0
|
1545 |
@SYMTestCaseID SYSLIB-EZLIB-UT-3684
|
sl@0
|
1546 |
@SYMTestCaseDesc Test the memory deallocation of the CEZFileBufferManager object to ensure that
|
sl@0
|
1547 |
there is no memory leak on success or failure of file compression and decompression
|
sl@0
|
1548 |
@SYMTestPriority High
|
sl@0
|
1549 |
@SYMTestActions Compressing and Decompressing a png image using CEZCompressor::InflateL() and
|
sl@0
|
1550 |
CEZDecompressor::DeflateL()
|
sl@0
|
1551 |
@SYMTestExpectedResults Test must not fail and memory must not leak afterdeallocating CEZFileBufferManager
|
sl@0
|
1552 |
object (fb)
|
sl@0
|
1553 |
@SYMDEF DEF109756
|
sl@0
|
1554 |
*/
|
sl@0
|
1555 |
void Test36L()
|
sl@0
|
1556 |
{
|
sl@0
|
1557 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-CT-3684 "));
|
sl@0
|
1558 |
Test.Printf(_L("\n"));
|
sl@0
|
1559 |
Test.Printf(KSeparator);
|
sl@0
|
1560 |
//Set the path of input file and output files
|
sl@0
|
1561 |
#if !defined(__WINS__)
|
sl@0
|
1562 |
_LIT(KInputFile, "z:\\test\\png\\00000720.png");
|
sl@0
|
1563 |
#else
|
sl@0
|
1564 |
_LIT(KInputFile, "c:\\test\\png\\00000720.png");
|
sl@0
|
1565 |
#endif
|
sl@0
|
1566 |
_LIT(KOutputFile, "c:\\test\\temp\\00000720.z");
|
sl@0
|
1567 |
_LIT(KUncompressedFile, "c:\\test\\temp\\000007201");
|
sl@0
|
1568 |
|
sl@0
|
1569 |
RFs rfs;
|
sl@0
|
1570 |
rfs.Connect();
|
sl@0
|
1571 |
CleanupClosePushL(rfs);
|
sl@0
|
1572 |
|
sl@0
|
1573 |
TPtrC inputFile(KInputFile);
|
sl@0
|
1574 |
TPtrC outputFile(KOutputFile);
|
sl@0
|
1575 |
TPtrC uncompressedFile(KUncompressedFile);
|
sl@0
|
1576 |
|
sl@0
|
1577 |
RFile input;
|
sl@0
|
1578 |
RFile output;
|
sl@0
|
1579 |
TInt err;
|
sl@0
|
1580 |
//Open the PNG file for compressing
|
sl@0
|
1581 |
User::LeaveIfError(input.Open(rfs, inputFile,EFileStream | EFileRead | EFileShareAny));
|
sl@0
|
1582 |
CleanupClosePushL(input);
|
sl@0
|
1583 |
|
sl@0
|
1584 |
//Create file to store output of file compressing
|
sl@0
|
1585 |
err = output.Create(rfs, outputFile,EFileStream | EFileWrite | EFileShareExclusive);
|
sl@0
|
1586 |
if (err == KErrAlreadyExists)//Just in case if the output file already exists then open it.
|
sl@0
|
1587 |
User::LeaveIfError(output.Open(rfs, outputFile,EFileStream | EFileWrite | EFileShareExclusive));
|
sl@0
|
1588 |
else
|
sl@0
|
1589 |
User::LeaveIfError(err);
|
sl@0
|
1590 |
CleanupClosePushL(output);
|
sl@0
|
1591 |
|
sl@0
|
1592 |
__UHEAP_MARK;
|
sl@0
|
1593 |
//Create and assign the CEZFileBufferManager object 'fb' as the compressor's buffer manager
|
sl@0
|
1594 |
CEZFileBufferManager *fb = CEZFileBufferManager::NewLC(input,output,16384);
|
sl@0
|
1595 |
CEZCompressor *def = CEZCompressor::NewLC(*fb);
|
sl@0
|
1596 |
|
sl@0
|
1597 |
while (def->DeflateL()){/*do nothing*/}
|
sl@0
|
1598 |
|
sl@0
|
1599 |
CleanupStack::PopAndDestroy(def);
|
sl@0
|
1600 |
CleanupStack::PopAndDestroy(fb);
|
sl@0
|
1601 |
__UHEAP_MARKEND;
|
sl@0
|
1602 |
|
sl@0
|
1603 |
CleanupStack::PopAndDestroy(&output);
|
sl@0
|
1604 |
CleanupStack::PopAndDestroy(&input);
|
sl@0
|
1605 |
//Now open the compressed file for decompressing
|
sl@0
|
1606 |
User::LeaveIfError(input.Open(rfs, outputFile,EFileStream | EFileRead | EFileShareAny));
|
sl@0
|
1607 |
CleanupClosePushL(input);
|
sl@0
|
1608 |
|
sl@0
|
1609 |
//Create file to store output of decompressing
|
sl@0
|
1610 |
err = output.Create(rfs, uncompressedFile,EFileStream | EFileWrite | EFileShareExclusive);
|
sl@0
|
1611 |
if (err == KErrAlreadyExists)//Just in case if the output file already exists then open it.
|
sl@0
|
1612 |
User::LeaveIfError(output.Open(rfs, uncompressedFile,EFileStream | EFileWrite | EFileShareExclusive));
|
sl@0
|
1613 |
else
|
sl@0
|
1614 |
User::LeaveIfError(err);
|
sl@0
|
1615 |
|
sl@0
|
1616 |
CleanupClosePushL(output);
|
sl@0
|
1617 |
|
sl@0
|
1618 |
__UHEAP_MARK;
|
sl@0
|
1619 |
//Create and assign the CEZFileBufferManager object 'fb' as the decompressor's buffer manager
|
sl@0
|
1620 |
fb = CEZFileBufferManager::NewLC(input,output,16384);
|
sl@0
|
1621 |
CEZDecompressor *inf = CEZDecompressor::NewLC(*fb);
|
sl@0
|
1622 |
|
sl@0
|
1623 |
while (inf->InflateL()){/*do nothing*/}
|
sl@0
|
1624 |
|
sl@0
|
1625 |
CleanupStack::PopAndDestroy(inf);
|
sl@0
|
1626 |
CleanupStack::PopAndDestroy(fb);
|
sl@0
|
1627 |
__UHEAP_MARKEND;
|
sl@0
|
1628 |
input.Close();
|
sl@0
|
1629 |
output.Close();
|
sl@0
|
1630 |
|
sl@0
|
1631 |
CleanupStack::PopAndDestroy(&output);
|
sl@0
|
1632 |
CleanupStack::PopAndDestroy(&input);
|
sl@0
|
1633 |
CleanupStack::PopAndDestroy(&rfs);
|
sl@0
|
1634 |
}
|
sl@0
|
1635 |
|
sl@0
|
1636 |
/**
|
sl@0
|
1637 |
@SYMTestCaseID SYSLIB-EZLIB2-UT-4298
|
sl@0
|
1638 |
@SYMTestCaseDesc Test CEZZStream functions through CEZCompressor class e.g.
|
sl@0
|
1639 |
Adler32(), AvailIn(), AvailOut()
|
sl@0
|
1640 |
@SYMTestPriority High
|
sl@0
|
1641 |
@SYMTestActions 1. Compress stream of data using CEZCompressor::NewLC() & CEZCompressor::DeflateL()
|
sl@0
|
1642 |
2. Call CEZCompressor::Adler32() to get the checksum value of the uncompressed data
|
sl@0
|
1643 |
3. Call CEZCompressor::AvailIn() to get the number of bytes available at the next input byte
|
sl@0
|
1644 |
4. Call CEZCompressor::AvailOut() to get the remaining free space at next output byte target
|
sl@0
|
1645 |
@SYMTestExpectedResults The test succeeds with no errors i.e. KErrNone
|
sl@0
|
1646 |
@SYMDEF REQ8024
|
sl@0
|
1647 |
*/
|
sl@0
|
1648 |
|
sl@0
|
1649 |
void TestCEZCompressorMethodsL()
|
sl@0
|
1650 |
{
|
sl@0
|
1651 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB2-UT-4298 "));
|
sl@0
|
1652 |
CBufferManager *bm;
|
sl@0
|
1653 |
TInt sourceSize;
|
sl@0
|
1654 |
|
sl@0
|
1655 |
sourceSize = sizeof(original);
|
sl@0
|
1656 |
bm = CBufferManager::NewLC(original,sourceSize,compressed,256,8);
|
sl@0
|
1657 |
CEZCompressor *compressor = CEZCompressor::NewLC(*bm);
|
sl@0
|
1658 |
|
sl@0
|
1659 |
TInt32 adler32;
|
sl@0
|
1660 |
TInt availIn;
|
sl@0
|
1661 |
TInt availOut;
|
sl@0
|
1662 |
|
sl@0
|
1663 |
while(compressor->DeflateL()){/*do nothing*/}
|
sl@0
|
1664 |
|
sl@0
|
1665 |
adler32 = compressor->Adler32();
|
sl@0
|
1666 |
Test(adler32 > 0);
|
sl@0
|
1667 |
|
sl@0
|
1668 |
availIn = compressor->AvailIn();
|
sl@0
|
1669 |
Test(availIn == 0);
|
sl@0
|
1670 |
|
sl@0
|
1671 |
availOut = compressor->AvailOut();
|
sl@0
|
1672 |
Test(availOut > 0);
|
sl@0
|
1673 |
|
sl@0
|
1674 |
CleanupStack::PopAndDestroy(compressor);
|
sl@0
|
1675 |
CleanupStack::PopAndDestroy(bm);
|
sl@0
|
1676 |
}
|
sl@0
|
1677 |
|
sl@0
|
1678 |
/**
|
sl@0
|
1679 |
@SYMTestCaseID SYSLIB-EZLIB2-UT-4300
|
sl@0
|
1680 |
@SYMTestCaseDesc TTest Zlibapiwrapper.cpp exported API's like inflate,
|
sl@0
|
1681 |
deflate, compress, decompress
|
sl@0
|
1682 |
@SYMTestPriority High
|
sl@0
|
1683 |
@SYMTestActions Call the exported C APIs of Zlibapiwrapper.cpp
|
sl@0
|
1684 |
Note: This is done to check if the C APIs of zlib.lib
|
sl@0
|
1685 |
are called through ezlib.lib.
|
sl@0
|
1686 |
@SYMTestExpectedResults All exported C API's should be called (i.e. run a basic scenario
|
sl@0
|
1687 |
of compressing some data) & test must not fail
|
sl@0
|
1688 |
@SYMDEF REQ8024
|
sl@0
|
1689 |
*/
|
sl@0
|
1690 |
|
sl@0
|
1691 |
void TestZlibapiwrapperAPIL()
|
sl@0
|
1692 |
{
|
sl@0
|
1693 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB2-UT-4300 "));
|
sl@0
|
1694 |
z_stream deflateStream;
|
sl@0
|
1695 |
const char inputData[] = "inputData!"; // data to compress
|
sl@0
|
1696 |
uLong inputDataLength = (uLong)sizeof(inputData) + 1;
|
sl@0
|
1697 |
Byte *compressedDataBuffer; // output buffer
|
sl@0
|
1698 |
//The buffer size is kept as 50 but incase the input data is changed..
|
sl@0
|
1699 |
//...the buffer size also has to be increased accordingly
|
sl@0
|
1700 |
TInt compressedDataBufferLength = 50;
|
sl@0
|
1701 |
|
sl@0
|
1702 |
// Allocate memory for output buffer
|
sl@0
|
1703 |
compressedDataBuffer = (Byte*)User::AllocZ(compressedDataBufferLength);
|
sl@0
|
1704 |
Test(compressedDataBuffer != Z_NULL);
|
sl@0
|
1705 |
CleanupStack::PushL(compressedDataBuffer);
|
sl@0
|
1706 |
|
sl@0
|
1707 |
// Initialise the stream
|
sl@0
|
1708 |
deflateStream.zalloc = (alloc_func)0;
|
sl@0
|
1709 |
deflateStream.zfree = (free_func)0;
|
sl@0
|
1710 |
deflateStream.opaque = (voidpf)0;
|
sl@0
|
1711 |
|
sl@0
|
1712 |
int level = Z_DEFAULT_COMPRESSION;
|
sl@0
|
1713 |
int err = 0;
|
sl@0
|
1714 |
int flush = 0;
|
sl@0
|
1715 |
|
sl@0
|
1716 |
err = deflateInit(&deflateStream, level);
|
sl@0
|
1717 |
|
sl@0
|
1718 |
if(err != Z_OK)
|
sl@0
|
1719 |
{
|
sl@0
|
1720 |
deflateEnd(&deflateStream);
|
sl@0
|
1721 |
Test(err == Z_OK);
|
sl@0
|
1722 |
}
|
sl@0
|
1723 |
|
sl@0
|
1724 |
|
sl@0
|
1725 |
// Compress data in the input buffer
|
sl@0
|
1726 |
deflateStream.next_in = (Byte*)inputData;
|
sl@0
|
1727 |
deflateStream.next_out = compressedDataBuffer;
|
sl@0
|
1728 |
|
sl@0
|
1729 |
do
|
sl@0
|
1730 |
{
|
sl@0
|
1731 |
if (deflateStream.total_in < inputDataLength)
|
sl@0
|
1732 |
{
|
sl@0
|
1733 |
deflateStream.avail_in = 1; // force small buffer
|
sl@0
|
1734 |
}
|
sl@0
|
1735 |
|
sl@0
|
1736 |
flush = (deflateStream.total_in == inputDataLength) ? Z_FINISH : Z_NO_FLUSH;
|
sl@0
|
1737 |
|
sl@0
|
1738 |
// run deflate() on input until output buffer not full, finish
|
sl@0
|
1739 |
// compression if all of source has been read in
|
sl@0
|
1740 |
do
|
sl@0
|
1741 |
{
|
sl@0
|
1742 |
if (deflateStream.total_out < compressedDataBufferLength)
|
sl@0
|
1743 |
{
|
sl@0
|
1744 |
deflateStream.avail_out = 1; // force small buffer
|
sl@0
|
1745 |
}
|
sl@0
|
1746 |
|
sl@0
|
1747 |
err = deflate(&deflateStream, flush);
|
sl@0
|
1748 |
if(err != Z_OK && err != Z_STREAM_END)
|
sl@0
|
1749 |
{
|
sl@0
|
1750 |
deflateEnd(&deflateStream);
|
sl@0
|
1751 |
Test(err == Z_OK || err == Z_STREAM_END);
|
sl@0
|
1752 |
}
|
sl@0
|
1753 |
} while(deflateStream.avail_out == 0 && err == Z_OK);
|
sl@0
|
1754 |
} while(err != Z_STREAM_END);
|
sl@0
|
1755 |
|
sl@0
|
1756 |
deflateEnd(&deflateStream);
|
sl@0
|
1757 |
CleanupStack::PopAndDestroy(compressedDataBuffer);
|
sl@0
|
1758 |
|
sl@0
|
1759 |
}
|
sl@0
|
1760 |
|
sl@0
|
1761 |
/**
|
sl@0
|
1762 |
@SYMTestCaseID SYSLIB-EZLIB-UT-4001
|
sl@0
|
1763 |
@SYMTestCaseDesc Test for DEF112672 - Panic ZLIB 11 - when installing the sisx file.
|
sl@0
|
1764 |
The test attempts to decompress a buffer with the "Dictionary" flag set
|
sl@0
|
1765 |
but with NULL dictionary buffer. The test should not cause an assert in the EZLib library.
|
sl@0
|
1766 |
@SYMTestPriority Normal
|
sl@0
|
1767 |
@SYMTestActions Test for DEF112672 - Panic ZLIB 11 - when installing the sisx file.
|
sl@0
|
1768 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
1769 |
@SYMDEF DEF112672
|
sl@0
|
1770 |
*/
|
sl@0
|
1771 |
|
sl@0
|
1772 |
void DEF112672L()
|
sl@0
|
1773 |
{
|
sl@0
|
1774 |
Test.Next(_L(" @SYMTestCaseID:SYSLIB-EZLIB-UT-4001 "));
|
sl@0
|
1775 |
TTestFlags flags(TTestFlags::Dictionary, 8);
|
sl@0
|
1776 |
flags.iDictionary.Set(dictionary, sizeof(dictionary));
|
sl@0
|
1777 |
CompressBufferL(flags);
|
sl@0
|
1778 |
flags.iDictionary.Set(0, 0);
|
sl@0
|
1779 |
TRAPD(err, DecompressBufferL(flags));
|
sl@0
|
1780 |
Test(err == KEZlibErrData);
|
sl@0
|
1781 |
}
|
sl@0
|
1782 |
|
sl@0
|
1783 |
void RunTestL()
|
sl@0
|
1784 |
{
|
sl@0
|
1785 |
for (TInt testNum=1; testNum<KNumberOfTests; testNum++)
|
sl@0
|
1786 |
{
|
sl@0
|
1787 |
__UHEAP_MARK;
|
sl@0
|
1788 |
_LIT(KTestNum,"\n\nRunning Test %d\n\n");
|
sl@0
|
1789 |
TBuf<80> buf;
|
sl@0
|
1790 |
buf.Format(KTestNum, testNum);
|
sl@0
|
1791 |
Test.Next(buf);
|
sl@0
|
1792 |
_LIT(KStrMsg,"%S");
|
sl@0
|
1793 |
Test.Printf(KStrMsg, testTable[testNum].iDescription);
|
sl@0
|
1794 |
testTable[testNum].iFn();
|
sl@0
|
1795 |
__UHEAP_MARKEND;
|
sl@0
|
1796 |
}
|
sl@0
|
1797 |
DEF112672L();
|
sl@0
|
1798 |
}
|
sl@0
|
1799 |
|
sl@0
|
1800 |
GLDEF_C TInt E32Main()
|
sl@0
|
1801 |
{
|
sl@0
|
1802 |
CTrapCleanup* cleanup=CTrapCleanup::New();
|
sl@0
|
1803 |
Test.Title();
|
sl@0
|
1804 |
_LIT(KStartMsg,"Starting Tests..");
|
sl@0
|
1805 |
Test.Start(KStartMsg);
|
sl@0
|
1806 |
__UHEAP_MARK;
|
sl@0
|
1807 |
TRAPD(err,RunTestL());
|
sl@0
|
1808 |
Test (err==KErrNone);
|
sl@0
|
1809 |
Test.End();
|
sl@0
|
1810 |
Test.Close();
|
sl@0
|
1811 |
__UHEAP_MARKEND;
|
sl@0
|
1812 |
delete cleanup;
|
sl@0
|
1813 |
return KErrNone;
|
sl@0
|
1814 |
}
|