0
|
1 |
// Copyright (c) 2007-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 the License "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 |
// e32test\misc\t_zip.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32test.h>
|
|
19 |
#include <f32file.h>
|
|
20 |
#include "crash_gzip.h"
|
|
21 |
|
|
22 |
|
|
23 |
TInt64 CrashTime() {return 0;}
|
|
24 |
|
231
|
25 |
RFs gFs;
|
0
|
26 |
RFile TheOutFile;
|
231
|
27 |
CFileMan* gFileMan;
|
|
28 |
_LIT(KZipFile,"c:\\out.zip");
|
0
|
29 |
|
|
30 |
class TCrashTestGzip : public MCrashGzip
|
|
31 |
{
|
|
32 |
public:
|
|
33 |
|
|
34 |
void SetOutput();
|
|
35 |
virtual TBool Out(const TDesC8& aDes);
|
|
36 |
virtual TInt32 GetMaxLength();
|
|
37 |
};
|
|
38 |
|
|
39 |
RTest test(_L("T_ZIP"));
|
|
40 |
|
|
41 |
void TCrashTestGzip::SetOutput()
|
|
42 |
{
|
231
|
43 |
TInt r=TheOutFile.Replace(gFs, KZipFile, EFileWrite);
|
0
|
44 |
test(r==KErrNone);
|
231
|
45 |
TBool bOk=Init();
|
|
46 |
test(bOk);
|
0
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
TInt TCrashTestGzip::Out(const TDesC8& aDes)
|
|
51 |
{
|
|
52 |
TInt r = TheOutFile.Write(aDes);
|
|
53 |
test(r==KErrNone);
|
|
54 |
return KErrNone;
|
|
55 |
}
|
|
56 |
|
|
57 |
|
|
58 |
TInt32 TCrashTestGzip::GetMaxLength()
|
|
59 |
{
|
|
60 |
return -1;
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
_LIT8(KText, "12345");
|
231
|
65 |
const TUint32 KTextSize = 5;
|
0
|
66 |
|
|
67 |
GLDEF_C TInt E32Main()
|
|
68 |
{
|
|
69 |
test.Title();
|
|
70 |
|
|
71 |
test.Start(_L("Connect to file server"));
|
231
|
72 |
|
|
73 |
CTrapCleanup* ct = CTrapCleanup::New();
|
|
74 |
test(ct!=0);
|
|
75 |
test(gFs.Connect()==KErrNone);
|
|
76 |
TRAPD(r, gFileMan=CFileMan::NewL(gFs));
|
0
|
77 |
test(r==KErrNone);
|
|
78 |
|
|
79 |
test.Next(_L("Making zip file"));
|
|
80 |
TCrashTestGzip zip;
|
|
81 |
zip.SetOutput();
|
|
82 |
zip.Write(KText);
|
|
83 |
zip.FlushEnd();
|
|
84 |
|
231
|
85 |
// get the number of uncompressed bytes and check that it matches the string
|
|
86 |
TUint32 uncompressedBytes=zip.GetDataCompressed();
|
|
87 |
test(uncompressedBytes==KTextSize);
|
|
88 |
|
0
|
89 |
TheOutFile.Close();
|
231
|
90 |
|
|
91 |
test.Next(_L("Re-open zip file and check size"));
|
|
92 |
// Check that file exists
|
|
93 |
r=TheOutFile.Open(gFs, KZipFile, EFileRead);
|
|
94 |
test(r==KErrNone);
|
|
95 |
|
|
96 |
//check size
|
|
97 |
TInt size=0;
|
|
98 |
r=TheOutFile.Size(size);
|
|
99 |
test(r==KErrNone && size>0);
|
|
100 |
|
|
101 |
TheOutFile.Close();
|
|
102 |
|
|
103 |
// Cleanup
|
|
104 |
gFileMan->Delete(KZipFile);
|
|
105 |
delete gFileMan;
|
|
106 |
gFs.Close();
|
|
107 |
delete ct;
|
|
108 |
test.End();
|
0
|
109 |
|
|
110 |
return KErrNone;
|
|
111 |
}
|
|
112 |
|