equal
deleted
inserted
replaced
20 #include "crash_gzip.h" |
20 #include "crash_gzip.h" |
21 |
21 |
22 |
22 |
23 TInt64 CrashTime() {return 0;} |
23 TInt64 CrashTime() {return 0;} |
24 |
24 |
25 RFs TheFs; |
25 RFs gFs; |
26 RFile TheOutFile; |
26 RFile TheOutFile; |
|
27 CFileMan* gFileMan; |
|
28 _LIT(KZipFile,"c:\\out.zip"); |
27 |
29 |
28 class TCrashTestGzip : public MCrashGzip |
30 class TCrashTestGzip : public MCrashGzip |
29 { |
31 { |
30 public: |
32 public: |
31 |
33 |
36 |
38 |
37 RTest test(_L("T_ZIP")); |
39 RTest test(_L("T_ZIP")); |
38 |
40 |
39 void TCrashTestGzip::SetOutput() |
41 void TCrashTestGzip::SetOutput() |
40 { |
42 { |
41 TInt r=TheOutFile.Replace(TheFs, _L("c:\\out.zip"),EFileWrite); |
43 TInt r=TheOutFile.Replace(gFs, KZipFile, EFileWrite); |
42 test(r==KErrNone); |
44 test(r==KErrNone); |
43 Init(); |
45 TBool bOk=Init(); |
|
46 test(bOk); |
44 } |
47 } |
45 |
48 |
46 |
49 |
47 TInt TCrashTestGzip::Out(const TDesC8& aDes) |
50 TInt TCrashTestGzip::Out(const TDesC8& aDes) |
48 { |
51 { |
57 return -1; |
60 return -1; |
58 } |
61 } |
59 |
62 |
60 |
63 |
61 _LIT8(KText, "12345"); |
64 _LIT8(KText, "12345"); |
62 |
65 const TUint32 KTextSize = 5; |
63 |
66 |
64 GLDEF_C TInt E32Main() |
67 GLDEF_C TInt E32Main() |
65 { |
68 { |
66 test.Title(); |
69 test.Title(); |
67 |
70 |
68 test.Start(_L("Connect to file server")); |
71 test.Start(_L("Connect to file server")); |
69 TInt r=TheFs.Connect(); |
72 |
|
73 CTrapCleanup* ct = CTrapCleanup::New(); |
|
74 test(ct!=0); |
|
75 test(gFs.Connect()==KErrNone); |
|
76 TRAPD(r, gFileMan=CFileMan::NewL(gFs)); |
70 test(r==KErrNone); |
77 test(r==KErrNone); |
71 |
78 |
72 test.Next(_L("Making zip file")); |
79 test.Next(_L("Making zip file")); |
73 TCrashTestGzip zip; |
80 TCrashTestGzip zip; |
74 zip.SetOutput(); |
81 zip.SetOutput(); |
75 zip.Write(KText); |
82 zip.Write(KText); |
76 zip.FlushEnd(); |
83 zip.FlushEnd(); |
77 |
84 |
|
85 // get the number of uncompressed bytes and check that it matches the string |
|
86 TUint32 uncompressedBytes=zip.GetDataCompressed(); |
|
87 test(uncompressedBytes==KTextSize); |
|
88 |
78 TheOutFile.Close(); |
89 TheOutFile.Close(); |
79 TheFs.Close(); |
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(); |
80 |
109 |
81 return KErrNone; |
110 return KErrNone; |
82 } |
111 } |
83 |
112 |