kerneltest/e32test/misc/t_zip.cpp
branchRCL_3
changeset 43 c1f20ce4abcf
parent 0 a41df078684a
child 44 3e88ff8f41d5
--- a/kerneltest/e32test/misc/t_zip.cpp	Thu Aug 19 11:14:22 2010 +0300
+++ b/kerneltest/e32test/misc/t_zip.cpp	Tue Aug 31 16:34:26 2010 +0300
@@ -22,8 +22,10 @@
 
 TInt64 CrashTime() {return 0;}
 
-RFs TheFs;
+RFs gFs;
 RFile TheOutFile;
+CFileMan* gFileMan;
+_LIT(KZipFile,"c:\\out.zip");
 				
 class TCrashTestGzip : public MCrashGzip
 	{
@@ -38,9 +40,10 @@
 
 void TCrashTestGzip::SetOutput()
 	{
-	TInt r=TheOutFile.Replace(TheFs, _L("c:\\out.zip"),EFileWrite);
+	TInt r=TheOutFile.Replace(gFs, KZipFile, EFileWrite);
 	test(r==KErrNone);
-	Init();
+	TBool bOk=Init();
+	test(bOk);
 	}
 
 
@@ -59,14 +62,18 @@
 
 
 _LIT8(KText, "12345");
-
+const TUint32 KTextSize = 5;
 
 GLDEF_C TInt E32Main()
 	{
 	test.Title();
 
 	test.Start(_L("Connect to file server"));
-	TInt r=TheFs.Connect();
+
+	CTrapCleanup* ct = CTrapCleanup::New();
+	test(ct!=0);
+	test(gFs.Connect()==KErrNone);
+	TRAPD(r, gFileMan=CFileMan::NewL(gFs));
 	test(r==KErrNone);
 
 	test.Next(_L("Making zip file"));
@@ -75,8 +82,30 @@
 	zip.Write(KText);
 	zip.FlushEnd();
 
+	// get the number of uncompressed bytes and check that it matches the string
+	TUint32 uncompressedBytes=zip.GetDataCompressed();
+	test(uncompressedBytes==KTextSize);
+
 	TheOutFile.Close();
-	TheFs.Close();
+
+	test.Next(_L("Re-open zip file and check size"));
+	// Check that file exists
+	r=TheOutFile.Open(gFs, KZipFile, EFileRead);
+	test(r==KErrNone);
+	
+	//check size
+	TInt size=0;
+	r=TheOutFile.Size(size);
+	test(r==KErrNone && size>0);
+
+	TheOutFile.Close();
+
+	// Cleanup
+	gFileMan->Delete(KZipFile);
+	delete gFileMan;
+	gFs.Close();
+	delete ct;
+	test.End();
 
 	return KErrNone;
 	}