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