xml/legacyminidomparser/xmlparser/test/t_smiltranslatortest.cpp
changeset 34 c7e9f1c97567
parent 24 74f0b3eb154c
equal deleted inserted replaced
25:417699dc19c9 34:c7e9f1c97567
       
     1 // Copyright (c) 2003-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 "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 // This file contains the Console Test Harness for testing the SMILTranslator .dll
       
    15 // It carries this out by searching for all files of a certain type (as specified by 
       
    16 // KWildName) that reside in a given set of directories (as specified by KInputPathList)
       
    17 // It then passes each file through a Parser object, picks up the resultant Document
       
    18 // object and passes this straight back to the composer object.  Output is a new XML
       
    19 // file of the same name but different directory (same as initial directory but with 
       
    20 // KTestFindStr replaced by KTestReplaceStr & KTestReplaceStr2) - these directories are  
       
    21 // created automatically.  The application then reports any errors for each file before
       
    22 // moving onto the next one.  These error reports are copied to the console screen (but 
       
    23 // usually too fast to read); to the output window in developer studio; and to a flat
       
    24 // file (named and located as specified in KErrorFileName)
       
    25 // There are 3 types of test that may be run.  The Basic test merely
       
    26 // translates all input files to output files.  The Performance test does the same thing
       
    27 // multiple times (as specified by KPerformanceTestIterations), although the log file
       
    28 // output will only relate to the last run.  Finally the Memory test utilises the Heap
       
    29 // Allocation Failure tool to incrementally run and progressively fail at each and every
       
    30 // attempt to allocate memory, it's finally run should complete successfully to prove
       
    31 // that no memory leaks have occurred in spite of X hundreds of previously failed runs.
       
    32 // Note that this finally test should be done with a much reduced number of files
       
    33 // residing in the input directories.
       
    34 // The application can test ASCII or Unicode input and output (4 combinations possible).
       
    35 // To vary the input you must manually add ASCII or Unicode files to the input
       
    36 // directories.
       
    37 // The tests can be run automatically or interactively:
       
    38 // For interactive tests, run with '-i as follows:
       
    39 // SMILTRANSLATORTEST.EXE -i
       
    40 // To run with out user interaction, please see the following examples:
       
    41 // SMILTRANSLATORTEST.EXE -h                                                 # show command line help
       
    42 // SMILTRANSLATORTEST.EXE                                                    # runs with default options
       
    43 // SMILTRANSLATORTEST.EXE -file_type ascii -data_mode file -test_type basic  # same as above
       
    44 // SMILTRANSLATORTEST.EXE -use_file_handles                                  # msgapi2 only
       
    45 // SMILTRANSLATORTEST.EXE -use_full_paths                                    # msgapi2 only
       
    46 // SMILTRANSLATORTEST.EXE -test_type performance -performance_iteratons 3    # performance test with 3 iterations
       
    47 // 
       
    48 //
       
    49 
       
    50 /**
       
    51  @file
       
    52 */
       
    53 
       
    54 //#define DEBUG_SMILTRANSLATORTEST_
       
    55 
       
    56 #include <e32test.h>
       
    57 #include <e32std.h>
       
    58 #include <f32file.h>
       
    59 #include <txtetext.h>
       
    60 #include <gmxmlparser.h>
       
    61 #include <gmxmlcomposer.h>
       
    62 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    63 #include "t_smildtdenum.h"
       
    64 #endif
       
    65 #include "t_SmilDtd.h"
       
    66 #include <bacline.h>
       
    67 
       
    68 // Constants
       
    69 _LIT(KErrorFileName,"c:\\legacyminidomparsertest\\SMIL_Test_Files\\ErrorLog.txt");
       
    70 _LIT(KParseError,"    Parse File error = ");
       
    71 _LIT(KComposeError,"    Compose File error = ");
       
    72 _LIT(KOutputNewLine,"\r\n");
       
    73 _LIT(KStartFile,"Starting test of file ");
       
    74 _LIT(KTxtAsciiOrUnicode,"Unicode (F1), Ascii (F2) or Utf-8 (F3) output?");
       
    75 _LIT(KTxtBufferOrFile,"\nTest file API (F1), test buffer API (F2)");
       
    76 _LIT(KTxtChooseTest,"\nPress:\nF1 (or any other key) for Basic test\nF2 for Performance test\nF3 for Memory Allocation test");
       
    77 _LIT(KSmilTranslatorTest,"Smil Translator");
       
    78 _LIT(KInputPathList, "c:\\legacyminidomparsertest\\SMIL_Test_Files\\SMIL_Input\\Valid\\;c:\\legacyminidomparsertest\\SMIL_Test_Files\\MMS_Input\\Valid\\;c:\\legacyminidomparsertest\\SMIL_Test_Files\\SMIL_Input\\Invalid\\;c:\\legacyminidomparsertest\\SMIL_Test_Files\\MMS_Input\\Invalid\\;");
       
    79 _LIT(KTestFindStr, "_Input\\");
       
    80 _LIT(KTestReplaceStr, "_Output\\");
       
    81 _LIT(KWildName, "*.txt");                         // read all file that match *.txt
       
    82 _LIT(KOptionI, "-i");                             // unary: interactive mode
       
    83 _LIT(KOptionH, "-h");
       
    84 // note: traditional style args "--file-type" don't work with the CCommandLineArguments class
       
    85 _LIT(KOptionFileType, "-file_type");               // binary: ascii, utf8, unicode
       
    86 _LIT(KOptionDataMode, "-data_mode");               // binary: buffer, file
       
    87 _LIT(KOptionTestType, "-test_type");               // binary: basic, performance, memory
       
    88 _LIT(KOptionPerformanceIterations, "-performance_iterations"); // binary: <number of iterations>
       
    89 _LIT(KOptionUseFileHandles, "-use_file_handles");   // unary: use file handles as input
       
    90 _LIT(KOptionUseFullPaths, "-use_full_paths");       // unary: use full paths as input
       
    91 _LIT(KTxtChooseFileInput, "Choose input file type: Using file path (F1), Using file handle (F2)?");
       
    92 
       
    93 // Globals 
       
    94 LOCAL_D CTrapCleanup* theCleanup;
       
    95 LOCAL_D CActiveScheduler* scheduler;
       
    96 LOCAL_D RTest test(KSmilTranslatorTest);
       
    97 LOCAL_D	RFs fileSystem;
       
    98 class CTestConfig;
       
    99 LOCAL_D CTestConfig* testConfig;
       
   100 
       
   101 //
       
   102 // TestConfig
       
   103 class CTestConfig : public CBase
       
   104 	{
       
   105 public:
       
   106 	typedef enum {EBasic, EPerformance, EMemory} TTestType;
       
   107 	typedef enum {EFileData, EBufferData} TXMLDataMode;
       
   108 	static CTestConfig* NewLC();
       
   109 	~CTestConfig() {}	
       
   110 
       
   111 	TInt ProcessCommandLineL();
       
   112 	void InteractiveMode();
       
   113 
       
   114 	// accessors
       
   115 	TBool NeedsHelp() const {return iNeedsHelp; }
       
   116 	TBool IsInteractive() const {return iIsInteractive; }
       
   117 	TXMLFileType FileType() const {return iFileType; } 
       
   118 	TXMLDataMode DataMode() const {return iDataMode; }
       
   119 	TTestType TestType() const {return iTestType; }
       
   120 	TInt PerformanceTestIterations() const {return iPerformanceTestIterations; }
       
   121 
       
   122 	// display
       
   123 	void DisplayHelp();
       
   124 	void UseageErr();
       
   125 	void Dump();
       
   126 
       
   127 	TBool UseFileHandles() const {return iUseFileHandles; }
       
   128 
       
   129 
       
   130 private:
       
   131 	void ConstructL();
       
   132 	TBool UnaryArgPresent(CCommandLineArguments* aArgs,TInt aArgCount, const TDesC& aOption);
       
   133 	TInt ExtractBinaryArg(CCommandLineArguments* aArgs,TInt aArgCount, const TDesC& aOption,TBuf<32>& aBuf);
       
   134 
       
   135 	TBool FileTypeFromStr(const TBuf<32>& aFileType);
       
   136 	TBool DataModeFromStr(const TBuf<32>& aDataMode);
       
   137 	TBool TestTypeFromStr(const TBuf<32>& aTestType);
       
   138 private:
       
   139 	TBool iNeedsHelp;
       
   140 	TBool iIsInteractive;
       
   141 	TXMLFileType iFileType;
       
   142 	TTestType iTestType;
       
   143 	TXMLDataMode iDataMode;
       
   144 	TInt iPerformanceTestIterations;
       
   145 	TBool iUseFileHandles;
       
   146 	};
       
   147 
       
   148 void CTestConfig::ConstructL()
       
   149 	{
       
   150 	iNeedsHelp=EFalse;
       
   151 	iIsInteractive=EFalse;
       
   152 	iFileType=EAscii;
       
   153 	iTestType=EBasic; 
       
   154 	iDataMode=EFileData;
       
   155 	iPerformanceTestIterations=100; 
       
   156 	iUseFileHandles = EFalse;
       
   157 	}
       
   158 
       
   159 CTestConfig* CTestConfig::NewLC()
       
   160 	{
       
   161 	CTestConfig* self=new(ELeave)CTestConfig();
       
   162 	CleanupStack::PushL(self);
       
   163 	self->ConstructL();
       
   164 	return self;
       
   165 	}
       
   166 
       
   167 TBool CTestConfig::FileTypeFromStr(const TBuf<32>& aFileType)
       
   168 	{
       
   169 	TBool found=ETrue;
       
   170 	if(aFileType.Compare(_L("ascii"))==0)
       
   171 		{
       
   172 		iFileType=EAscii;
       
   173 		}
       
   174 	else if(aFileType.Compare(_L("utf8"))==0)
       
   175 		{
       
   176 		iFileType=EUtf8;
       
   177 		}
       
   178 	else if (aFileType.Compare(_L("unicode"))==0)
       
   179 		{
       
   180 		iFileType=EUnicode;
       
   181 		}
       
   182 	else
       
   183 		{
       
   184 		found=EFalse;
       
   185 		}
       
   186 	return found;
       
   187 	}
       
   188 
       
   189 TBool CTestConfig::DataModeFromStr(const TBuf<32>& aDataMode)
       
   190 	{
       
   191 	TBool found=ETrue;
       
   192 	if(aDataMode.Compare(_L("buffer"))==0)
       
   193 		{
       
   194 		iDataMode=EBufferData;	
       
   195 		}
       
   196 	else if(aDataMode.Compare(_L("file"))==0)
       
   197 		{
       
   198 		iDataMode=EFileData;
       
   199 		}
       
   200 	else 
       
   201 		{
       
   202 		found=EFalse;
       
   203 		}
       
   204 	return found;
       
   205 	}
       
   206 
       
   207 TBool CTestConfig::TestTypeFromStr(const TBuf<32>& aTestType)
       
   208 	{
       
   209 	TBool found=ETrue;
       
   210 	if (aTestType.Compare(_L("basic"))==0) 
       
   211 		{
       
   212 		iTestType=EBasic;
       
   213 		}
       
   214 	else if (aTestType.Compare(_L("performance"))==0)
       
   215 		{
       
   216 		iTestType=EPerformance;
       
   217 		}
       
   218 	else if (aTestType.Compare(_L("memory"))==0)
       
   219 		{
       
   220 		iTestType=EMemory;
       
   221 		}
       
   222 	else 
       
   223 		{
       
   224 		found=EFalse;
       
   225 		}
       
   226 	return found;
       
   227 	}
       
   228 
       
   229 void CTestConfig::DisplayHelp()
       
   230 	{
       
   231 	test.Printf(KOptionH);
       
   232 	test.Printf(_L("\thelp\r\n"));
       
   233 	test.Printf(KOptionI);
       
   234 	test.Printf(_L("\tinteractive mode\r\n"));
       
   235 	test.Printf(KOptionFileType);
       
   236     test.Printf(_L("\tascii|utf8|unicode\r\n"));
       
   237 	test.Printf(KOptionDataMode);
       
   238 	test.Printf(_L("\tbuffer-data|file-data\r\n"));
       
   239 	test.Printf(KOptionTestType);
       
   240 	test.Printf(_L("\tbasic|performance|memory\r\n"));
       
   241 	test.Printf(KOptionPerformanceIterations);
       
   242 	test.Printf(_L(" N\tthe number of iterations to perform\r\n"));
       
   243 	test.Printf(KOptionUseFileHandles);
       
   244 	test.Printf(_L("\tuse file handles for the test\r\n"));
       
   245 	test.Printf(KOptionUseFullPaths);
       
   246 	test.Printf(_L("\tuse file paths for the test\r\n"));
       
   247 	}
       
   248 
       
   249 void CTestConfig::UseageErr()
       
   250 	{
       
   251 		test.Printf(_L("\r\nUseage Err:\r\n"));
       
   252 		DisplayHelp();
       
   253 	}
       
   254 
       
   255 void CTestConfig::Dump() 
       
   256 	{	
       
   257 	RDebug::Print(_L("\r\n"));
       
   258 	RDebug::Print(_L("SMILTRANSLATORTEST Config Settings:\r\n"));
       
   259 	RDebug::Print(_L("===================================\r\n"));
       
   260 	RDebug::Print(_L("iNeedsHelp                 = %d\r\n"),iNeedsHelp);
       
   261 	RDebug::Print(_L("iIsInteractive             = %d\r\n"),iIsInteractive);
       
   262 	RDebug::Print(_L("iFiletype                  = %d\r\n"),iFileType);
       
   263 	RDebug::Print(_L("iTestType                  = %d\r\n"),iTestType);
       
   264 	RDebug::Print(_L("iDataMode                  = %d\r\n"),iDataMode);  
       
   265 	RDebug::Print(_L("iPerformanceTestIterations = %d\r\n"),iPerformanceTestIterations);
       
   266 	RDebug::Print(_L("iUseFileHanldes            = %d\r\n"),iUseFileHandles);
       
   267 	}
       
   268 
       
   269 TBool CTestConfig::UnaryArgPresent(CCommandLineArguments *aArgs, TInt aArgCount, const TDesC& aOption)
       
   270 	{
       
   271 	TInt i = 1;
       
   272 	while ((i<aArgCount)&&aArgs->Arg(i).Compare(aOption))
       
   273 		{
       
   274 		++i;
       
   275 		}
       
   276 	return i<aArgCount;
       
   277 	}
       
   278 
       
   279 TInt CTestConfig::ExtractBinaryArg(CCommandLineArguments *aArgs, TInt aArgCount, const TDesC& aOption,TBuf<32>& aBuf)
       
   280 	{
       
   281 		TInt err=KErrNotFound;
       
   282 		TInt i=0; 
       
   283 
       
   284 		while ((i<aArgCount)&&aArgs->Arg(i).Compare(aOption)) 
       
   285 			{
       
   286 			++i;
       
   287 			}
       
   288 		if (i<aArgCount) 
       
   289 			{
       
   290 			if (++i<aArgCount) 
       
   291 				{
       
   292 				err=KErrNone;
       
   293 				aBuf=aArgs->Arg(i);
       
   294 				}
       
   295 			else
       
   296 				{
       
   297 				err=KErrArgument;
       
   298 				}
       
   299 			}
       
   300 		return err;
       
   301 	}
       
   302 
       
   303 void CTestConfig::InteractiveMode()
       
   304 	{
       
   305 	TKeyCode choice;
       
   306 
       
   307 	test.Printf(KTxtAsciiOrUnicode);
       
   308 	choice=test.Getch();
       
   309 
       
   310 	if(choice==EKeyHelp)
       
   311 		{
       
   312 		iFileType=EAscii;
       
   313 		}
       
   314 	else if(choice==EKeyDial)
       
   315 		{
       
   316 		iFileType=EUtf8;
       
   317 		}
       
   318 	else
       
   319 		{
       
   320 		iFileType=EUnicode;
       
   321 		}
       
   322 	test.Printf(KTxtBufferOrFile);
       
   323 	choice=test.Getch();
       
   324 	if(choice==EKeyHelp)
       
   325 		{
       
   326 		iDataMode=EBufferData;
       
   327 		}
       
   328 	else
       
   329 		{
       
   330 		iDataMode=EFileData;
       
   331 		}
       
   332 		
       
   333 	// Get user's input on whether to use file paths or file handles for the input files
       
   334 	test.Printf(KOutputNewLine());
       
   335 	test.Printf(KTxtChooseFileInput());
       
   336 	choice=test.Getch();
       
   337 	iUseFileHandles=EFalse;
       
   338 	if(choice==EKeyHelp)          // F2
       
   339 		{
       
   340 		iUseFileHandles = ETrue;
       
   341 		}
       
   342 
       
   343 	test.Printf(KTxtChooseTest);
       
   344 	choice=test.Getch();
       
   345 	if(choice==EKeyHelp)        // F2
       
   346 		{
       
   347 		iTestType=EPerformance;
       
   348 		}
       
   349 	else if (choice==EKeyDial)  // F3
       
   350 		{
       
   351 		iTestType=EMemory;
       
   352 		}
       
   353 	else                          // any key
       
   354 		{
       
   355 		iTestType=EBasic;  
       
   356 		}
       
   357 	}
       
   358 
       
   359 TInt CTestConfig::ProcessCommandLineL()
       
   360 	{
       
   361 	// Handle command line arguments
       
   362 	CCommandLineArguments* args=CCommandLineArguments::NewLC();
       
   363 	
       
   364 	TInt argCount=args->Count();
       
   365 
       
   366 	// Search for: "-h"/help parameter
       
   367 	if (UnaryArgPresent(args,argCount,KOptionH))
       
   368 		{
       
   369 			iNeedsHelp = ETrue;
       
   370 			CleanupStack::Pop(args);
       
   371 			delete args;
       
   372 			return KErrNone;
       
   373 		}
       
   374 
       
   375 	// Search for: "-i"/interactive parameter
       
   376 	if(UnaryArgPresent(args,argCount,KOptionI)) 
       
   377 		{
       
   378 		if (argCount==2)
       
   379 			{
       
   380 			iIsInteractive=ETrue;
       
   381 			}
       
   382 		else
       
   383 			{
       
   384 			UseageErr();
       
   385 			}
       
   386 		} 
       
   387 	// Search for: "-usefilehandles" parameter
       
   388 	if(UnaryArgPresent(args,argCount,KOptionUseFileHandles)) 
       
   389 		{
       
   390 		iUseFileHandles=ETrue;		
       
   391 		}
       
   392 	// Search for: "-usefullpaths" parameter
       
   393 	if(UnaryArgPresent(args,argCount,KOptionUseFullPaths))
       
   394 		{
       
   395 		iUseFileHandles=EFalse;
       
   396 		}
       
   397 
       
   398 	// Search for: --file-type, --data-mode, --test-type
       
   399 	TBuf<32> buf;
       
   400 	TInt err;
       
   401 	if (((err=ExtractBinaryArg(args,argCount,KOptionFileType,buf))==KErrNone)&&(!FileTypeFromStr(buf))||
       
   402 		  err==KErrArgument)
       
   403 		{
       
   404 		UseageErr();
       
   405 		CleanupStack::PopAndDestroy(args);
       
   406 		return KErrArgument;
       
   407 		}
       
   408 	if (((err=ExtractBinaryArg(args,argCount,KOptionDataMode,buf))==KErrNone)&&(!DataModeFromStr(buf))||
       
   409 		  err==KErrArgument)
       
   410 		{
       
   411 		UseageErr();			
       
   412 		CleanupStack::PopAndDestroy(args);
       
   413 		return KErrArgument;
       
   414 		}
       
   415     if (((err=ExtractBinaryArg(args,argCount,KOptionTestType,buf))==KErrNone)&&(!TestTypeFromStr(buf))||
       
   416 		 err==KErrArgument)
       
   417 		{
       
   418 		UseageErr();
       
   419 		CleanupStack::PopAndDestroy(args);
       
   420 		return KErrArgument;
       
   421 		}
       
   422     if (((err=ExtractBinaryArg(args,argCount,KOptionPerformanceIterations,buf))==KErrNone))
       
   423 		{
       
   424 		TLex16 lexer(buf.Ptr());
       
   425 		TInt iterations;
       
   426 		lexer.Val(iterations);
       
   427 		iPerformanceTestIterations = iterations;
       
   428 		}
       
   429 	else if (err==KErrArgument)
       
   430 		{
       
   431 		UseageErr();
       
   432 		CleanupStack::PopAndDestroy(args);
       
   433 		return KErrArgument;
       
   434 		}
       
   435 	CleanupStack::PopAndDestroy(args);
       
   436 	return KErrNone;
       
   437 	}
       
   438 
       
   439 //
       
   440 
       
   441 class CTestDataSupplier : public CBase, public MMDXMLParserDataProvider
       
   442 	{
       
   443 public:
       
   444 	static CTestDataSupplier* NewL(RFs &aRFs, const TDesC& aFileName);
       
   445 	~CTestDataSupplier();
       
   446 
       
   447 	// From MMDXMLParserDataProvided
       
   448 	void GetData(TPtrC8 &aPtr, TRequestStatus &aStatus);
       
   449 	void Disconnect();
       
   450 
       
   451 private:
       
   452 	void ConstructL(RFs &aRFs, const TDesC& aFileName);
       
   453 
       
   454 private:
       
   455 	HBufC8* iCurrentChunk;
       
   456 	RFile iFile;
       
   457 	TInt iChunkSize;	// Start at 1, then increment for subsequent chunk
       
   458 	};
       
   459 
       
   460 
       
   461 CTestDataSupplier* CTestDataSupplier::NewL(RFs &aRFs, const TDesC& aFileName)
       
   462 	{
       
   463 	CTestDataSupplier* self = new (ELeave) CTestDataSupplier();
       
   464 	CleanupStack::PushL(self);
       
   465 	self->ConstructL(aRFs, aFileName);
       
   466 	CleanupStack::Pop(self);
       
   467 	return self;
       
   468 	}
       
   469 
       
   470 CTestDataSupplier::~CTestDataSupplier()
       
   471 	{
       
   472 	iFile.Close();
       
   473 	delete iCurrentChunk;
       
   474 	}
       
   475 
       
   476 // From MMDXMLParserDataProvided
       
   477 // TODO: Should GetData be a leaving function? Allows more flexibility to implementations of this funtion?
       
   478 void CTestDataSupplier::GetData(TPtrC8 &aPtr, TRequestStatus &aStatus)
       
   479 	{
       
   480 	// Read the data into the descriptor
       
   481 	delete iCurrentChunk;
       
   482 	iCurrentChunk = NULL;
       
   483 	iCurrentChunk = HBufC8::NewL(iChunkSize);
       
   484 	TPtr8 chunk = iCurrentChunk->Des();
       
   485 	iFile.Read(chunk, iChunkSize); // Ignore the error code, assume end of file if we haven't read any data.
       
   486 
       
   487 	TDataProviderResults result;
       
   488 
       
   489 	if (iCurrentChunk->Length() != 0)
       
   490 		{
       
   491 		aPtr.Set(*iCurrentChunk);
       
   492 		result = KMoreData;
       
   493 		}
       
   494 	else
       
   495 		{
       
   496 		// Assume that if we haven't got any data then we're at the end of the stream.
       
   497 		result = KDataStreamEnd;
       
   498 		}
       
   499 
       
   500 //	iChunkSize++;
       
   501 	TRequestStatus *s = &aStatus;
       
   502 	User::RequestComplete(s, (TInt)result);
       
   503 	return;
       
   504 	}
       
   505 
       
   506 void CTestDataSupplier::Disconnect()
       
   507 	{
       
   508 	// Don't need to do anything here.
       
   509 	}
       
   510 
       
   511 void CTestDataSupplier::ConstructL(RFs &aRFs, const TDesC& aFileName)
       
   512 	{
       
   513 	iChunkSize = 1;
       
   514 	
       
   515 	// Open the file that will supply the data
       
   516 	User::LeaveIfError(iFile.Open(aRFs, aFileName, EFileRead));
       
   517 	}
       
   518 
       
   519 
       
   520 //
       
   521 // CSmilTranslatorTestUtils declaration
       
   522 //
       
   523 
       
   524 class CSmilTranslatorTestUtils : public CActive, public MMDXMLParserObserver, public MMDXMLComposerObserver
       
   525 	{
       
   526 public:
       
   527 	static CSmilTranslatorTestUtils* NewLC();
       
   528 	~CSmilTranslatorTestUtils();
       
   529 	void ConstructL();
       
   530     void RunTestL();
       
   531 	TInt FilesProcessed() const {return iFilesProcessed; }
       
   532 
       
   533 public: // from CActive
       
   534 	void DoCancel();
       
   535 	void RunL();
       
   536 
       
   537 public: // from MMDXMLParserObserver
       
   538 	void ParseFileCompleteL();
       
   539 
       
   540 public: // from MMDXMLComposerObserver
       
   541 	void ComposeFileCompleteL();
       
   542 
       
   543 private:
       
   544 	CSmilTranslatorTestUtils();
       
   545 	void SetOutputFileName();
       
   546 	void AppendErrorStr(TInt aError, TDes& aOutputMsg);
       
   547 	void AppendSeverityStr(TInt aSeverity, TDes& aOutputMsg);
       
   548 
       
   549 private:
       
   550 	enum TComposerState
       
   551 		{
       
   552 		EComposing,
       
   553 		ESizing
       
   554 		};
       
   555 
       
   556     RFs iSession;
       
   557 	CMDXMLDocument* iXMLDoc;
       
   558 
       
   559 
       
   560 	CMDXMLParser* iParser;
       
   561 	CMDXMLComposer* iComposer;
       
   562 	TBuf<255> iInputFileName;
       
   563 	TBuf<255> iOutputFileName;
       
   564 	TComposerState iComposerState;
       
   565 	TInt iSize;
       
   566 	RFile iErrorFile;
       
   567 	CTestDataSupplier* iDataSupplier;
       
   568 
       
   569 	// return list of found files used by TFileFinder class
       
   570 	CDir* iFileList;
       
   571 		
       
   572 	// buffer for composing the error messages for output to the screen and error file
       
   573 	TBuf<255> iOutputMsg;
       
   574 
       
   575 	TFindFile *iFileFinder;
       
   576 
       
   577 	TInt iState;
       
   578 	TInt iErr;
       
   579 	TInt iIndex;
       
   580 
       
   581 	enum TSmilTestStates
       
   582 		{
       
   583 		KInit = 0x00,
       
   584 		KParseFile,
       
   585 		KCheckResults,
       
   586 		KEnd
       
   587 		};
       
   588 
       
   589 	TTime iStartTime;
       
   590 	TTime iStartComposeTime;
       
   591 	TInt64 iComposeTime;
       
   592 	TInt iFilesProcessed;
       
   593 
       
   594 	TBool iUseFileHandle;
       
   595 	};
       
   596 
       
   597 //===================================================================================
       
   598 
       
   599 //
       
   600 // CSmilTranslatorTestUtils definition
       
   601 //
       
   602 
       
   603 CSmilTranslatorTestUtils* CSmilTranslatorTestUtils::NewLC()
       
   604 	{
       
   605 	CSmilTranslatorTestUtils* self = new (ELeave) CSmilTranslatorTestUtils();
       
   606 	CleanupStack::PushL(self);
       
   607 	self->ConstructL();
       
   608 	return self;
       
   609 	}
       
   610 
       
   611 //===================================================================================
       
   612 
       
   613 CSmilTranslatorTestUtils::~CSmilTranslatorTestUtils()
       
   614 	{
       
   615 	delete iFileList;
       
   616 	delete iXMLDoc;
       
   617 	delete iParser;
       
   618 	delete iComposer;
       
   619 	iSession.Close();
       
   620 	}
       
   621 
       
   622 //===================================================================================
       
   623 
       
   624 CSmilTranslatorTestUtils::CSmilTranslatorTestUtils() : CActive(EPriorityStandard), iFileFinder()
       
   625 	{
       
   626 	}
       
   627 
       
   628 //===================================================================================
       
   629 
       
   630 void CSmilTranslatorTestUtils::ConstructL()
       
   631 	{ 
       
   632 
       
   633     iSession.Connect();
       
   634 	iComposer = CMDXMLComposer::NewL(this);
       
   635 #define VALIDATE
       
   636 #ifndef VALIDATE
       
   637 	iParser = CMDXMLParser::NewL(this);
       
   638 #else
       
   639 	CSMILDtd* smil = CSMILDtd::NewLC();
       
   640 	iParser = CMDXMLParser::NewL(this, smil);
       
   641 	CleanupStack::Pop(smil);
       
   642 #endif
       
   643 	
       
   644 	iUseFileHandle = testConfig->UseFileHandles();
       
   645 
       
   646 	iState = KInit;
       
   647 	iErr = KErrNone;
       
   648 	iStartTime.UniversalTime();
       
   649 	iFilesProcessed = 0;
       
   650 
       
   651 	CActiveScheduler::Add(this);
       
   652 
       
   653 	TRequestStatus *s = &iStatus;
       
   654 	User::RequestComplete(s, KErrNone);
       
   655 	SetActive();
       
   656 	}
       
   657 
       
   658 //===================================================================================
       
   659 
       
   660 void CSmilTranslatorTestUtils::RunL()
       
   661 	{
       
   662 	RunTestL();
       
   663 	}
       
   664 
       
   665 //===================================================================================
       
   666 
       
   667 void CSmilTranslatorTestUtils::DoCancel()
       
   668 	{
       
   669 	}
       
   670 
       
   671 //===================================================================================
       
   672 
       
   673 #define DES_AS_8_BIT(str) (TPtrC8((TText8*)((str).Ptr()), (str).Size()))
       
   674 
       
   675 void CSmilTranslatorTestUtils::RunTestL()
       
   676 	{
       
   677 	TRequestStatus *s = &iStatus;
       
   678 
       
   679 	// used to generate a leave if an out of memory error was encountered, specifically
       
   680 	// during the memory test loop in E32Main().  This is necessary because leaves in
       
   681 	// the .dll Active Object RunL() functions do not return to this application, so
       
   682 	// have to be Trapped in the Active objects and translated into an error code.
       
   683 	TBool memoryError = EFalse;
       
   684 
       
   685 	switch(iState)
       
   686 		{
       
   687 	case KInit:
       
   688 		{
       
   689 		// Utility class for file manipulation
       
   690 		iFileFinder = new TFindFile(iSession);
       
   691 
       
   692 		TPtrC errorFileName(KErrorFileName);
       
   693 
       
   694 		// create err dir if doesn't exist - this api ignores the file name (ignores everything after final '/')
       
   695 		fileSystem.MkDirAll(KErrorFileName);
       
   696 
       
   697 		// overwrite any existing file of this name
       
   698 		iErr = iErrorFile.Replace(iSession, errorFileName, EFileWrite | EFileStreamText);
       
   699 
       
   700 		if(iErr == KErrNone)
       
   701 			{
       
   702 			TBuf<1> bom;
       
   703 			bom.Append(CEditableText::EByteOrderMark);
       
   704 			iErrorFile.Write(DES_AS_8_BIT(bom));
       
   705 			// will search multiple directories, but halt after completing current directory
       
   706 			// if at least one match is made.  Remembers which directories have been searched
       
   707 			// in order to continue search using .FindWild() function later
       
   708 			iErr = iFileFinder->FindWildByPath(KWildName, &KInputPathList, iFileList);
       
   709 			iIndex = 0;
       
   710 			}
       
   711 
       
   712 		if(iErr == KErrNone)
       
   713 			{
       
   714 			iState = KParseFile;
       
   715 			}
       
   716 		else
       
   717 			{
       
   718 			iState = KEnd;
       
   719 			}
       
   720 		User::RequestComplete(s, KErrNone);
       
   721 		SetActive();
       
   722 		}
       
   723 		break;
       
   724 
       
   725 	case KParseFile:
       
   726 		{
       
   727 		++iFilesProcessed;
       
   728 		iErr = KErrNone;
       
   729 
       
   730 		TParse fullEntry;
       
   731 		fullEntry.Set((*iFileList)[iIndex++].iName,& iFileFinder->File(),NULL);
       
   732 		iInputFileName = fullEntry.FullName(); // extract individual path + name from list
       
   733 		SetOutputFileName(); // output name is based on input one
       
   734 
       
   735 		iOutputMsg = KStartFile;
       
   736 		iOutputMsg.Append(iInputFileName);		// display full path
       
   737 		test.Start(iOutputMsg);				// print to console
       
   738 
       
   739 		// test console automatically places output on a new line, for output
       
   740 		// to error file we need to add white space ready for next line
       
   741 		iOutputMsg.Append(KOutputNewLine);
       
   742 		iErrorFile.Write(DES_AS_8_BIT(iOutputMsg));	// print to error file
       
   743 
       
   744 		// schedule Parser active object for call to it's RunL function
       
   745 		if (testConfig->DataMode() == CTestConfig::EBufferData)
       
   746 			{
       
   747 			// We're testing the buffering API...
       
   748 			// Create a data supplier object and pass it in to the parser
       
   749 			delete iDataSupplier;
       
   750 			iDataSupplier = NULL;
       
   751 			iDataSupplier = CTestDataSupplier::NewL(iSession, iInputFileName);
       
   752 			iParser->ParseSource(iDataSupplier);
       
   753 			}
       
   754 		else
       
   755 			{
       
   756 			if( iUseFileHandle )
       
   757 				{
       
   758 				RFile file;
       
   759 				User::LeaveIfError(file.Open(iSession, iInputFileName, EFileRead | EFileShareReadersOnly));
       
   760 			// 	No function declaration of ParseFile() that take RFile Object parameter
       
   761 			//	iParser->ParseFile(file);
       
   762 				iParser->ParseFile(iSession, iInputFileName);
       
   763 				}
       
   764 			else
       
   765 				{
       
   766 				// We're testing the file mode so parse the file.
       
   767 				iParser->ParseFile(iSession, iInputFileName);
       
   768 				}
       
   769 			}
       
   770 
       
   771 		iState = KCheckResults;
       
   772 		iStatus = KRequestPending;
       
   773 		SetActive();
       
   774 		}
       
   775 		break;
       
   776 
       
   777 	case KCheckResults:
       
   778 		{
       
   779 		// when execution begins again one parse followed by a compose would have
       
   780 		// completed for the current file, handle any error messages generated here
       
   781 		iErr = iParser->Error();
       
   782 		TInt severity = iParser->ErrorSeverity();
       
   783 		if(iErr != KErrNone)
       
   784 			{
       
   785 			iOutputMsg = KParseError;
       
   786 			AppendErrorStr(iErr, iOutputMsg);
       
   787 			AppendSeverityStr(severity, iOutputMsg);
       
   788 			iOutputMsg.Append(KOutputNewLine);
       
   789 			
       
   790 			// IF there are no more errors for this file bung in an
       
   791 			// extra line to make output more prominent
       
   792 			if(iComposer->Error() == KErrNone)
       
   793 				{
       
   794 				iOutputMsg.Append(KOutputNewLine);
       
   795 				}
       
   796 			test.Printf(iOutputMsg);						// print to console
       
   797 			iErrorFile.Write(DES_AS_8_BIT(iOutputMsg));	// print to error file
       
   798 			
       
   799 			if(iErr == KErrNoMemory)
       
   800 				{
       
   801 				memoryError = ETrue;
       
   802 				}
       
   803 			}
       
   804 
       
   805 		iErr = iComposer->Error();
       
   806 		severity = iComposer->ErrorSeverity();
       
   807 		if(iErr != KErrNone)
       
   808 			{
       
   809 			iOutputMsg = KComposeError;
       
   810 			AppendErrorStr(iErr, iOutputMsg);
       
   811 			AppendSeverityStr(severity, iOutputMsg);
       
   812 			iOutputMsg.Append(KOutputNewLine);
       
   813 			iOutputMsg.Append(KOutputNewLine);								
       
   814 			test.Printf(iOutputMsg);
       
   815 			iErrorFile.Write(DES_AS_8_BIT(iOutputMsg));
       
   816 			
       
   817 			if(iErr == KErrNoMemory)
       
   818 				{
       
   819 				memoryError = ETrue;
       
   820 				}
       
   821 			}
       
   822 
       
   823 		test.End();
       
   824 
       
   825 		// if the OOM condition occured during Parsing or Composing
       
   826 		if(memoryError)
       
   827 			{
       
   828 			User::Leave(KErrNoMemory);
       
   829 			}
       
   830 
       
   831 		iState = KParseFile;
       
   832 
       
   833 		if(iIndex >= iFileList->Count())
       
   834 			{
       
   835 			// fileList must be deleted after each loop prior to being passed
       
   836 			// back to fileFinder (unnecessary after KErrNotFound)
       
   837 			delete iFileList;
       
   838 			iFileList = 0; // Just in case it doesn't get set in the FindWild
       
   839 
       
   840 			// continue wildcard search for next directory in list
       
   841 			iErr = iFileFinder->FindWild(iFileList);
       
   842 			iIndex = 0;
       
   843 			if(iErr != KErrNone)
       
   844 				iState = KEnd;
       
   845 			}
       
   846 
       
   847 		SetActive();
       
   848 		User::RequestComplete(s, KErrNone);
       
   849 		}
       
   850 		break;
       
   851 
       
   852 	default:
       
   853 	case KEnd:
       
   854 		{
       
   855 		TTime endTime;
       
   856 		TTimeIntervalSeconds interval;
       
   857 		endTime.UniversalTime();
       
   858 		endTime.SecondsFrom(iStartTime, interval);
       
   859 
       
   860 		TBuf<100> time;
       
   861 		_LIT(KComposeTime, "Total time for composing: %d microseconds\n");
       
   862 		time.Format(KComposeTime, iComposeTime);
       
   863 		iErrorFile.Write(DES_AS_8_BIT(time));
       
   864 
       
   865 		_LIT(KTimeTaken, "Total time for tests: %d seconds");
       
   866 		time.Format(KTimeTaken, interval.Int());
       
   867 		iErrorFile.Write(DES_AS_8_BIT(time));
       
   868 
       
   869 
       
   870 		delete iFileFinder;
       
   871 		delete iDataSupplier;
       
   872 		CActiveScheduler::Stop();
       
   873 		}
       
   874 		break;
       
   875 		}
       
   876 	}
       
   877 
       
   878 //===================================================================================
       
   879 
       
   880 void CSmilTranslatorTestUtils::AppendErrorStr(TInt aError, TDes& aOutputMsg)
       
   881 	{
       
   882 	switch(aError)
       
   883 		{
       
   884 		case KErrXMLBadAttributeValue:
       
   885 			aOutputMsg.Append(_L("Bad Attribute Value")); break;
       
   886 
       
   887 		case KErrXMLBadAttributeName:
       
   888 			aOutputMsg.Append(_L("Bad Attribute Name")); break;
       
   889 
       
   890 		case KErrXMLInvalidChild:
       
   891 			aOutputMsg.Append(_L("Invalid Child")); break;
       
   892 
       
   893 		case KErrXMLBadNesting:
       
   894 			aOutputMsg.Append(_L("Bad Nesting")); break;
       
   895 
       
   896 		case KErrXMLIncomplete:
       
   897 			aOutputMsg.Append(_L("Incomplete")); break;
       
   898 
       
   899 		case KErrXMLBadElementName:
       
   900 			aOutputMsg.Append(_L("Bad Element Name")); break;
       
   901 
       
   902 		case KErrXMLDuplicateDocTypeTags:
       
   903 			aOutputMsg.Append(_L("Duplicate DocType Tags")); break;
       
   904 
       
   905 		case KErrXMLDuplicateVersionTags:
       
   906 			aOutputMsg.Append(_L("Duplicate Version Tags")); break;
       
   907 
       
   908 		case KErrXMLDuplicateRootElements:
       
   909 			aOutputMsg.Append(_L("Duplicate Root Elements")); break;
       
   910 
       
   911 		case KErrXMLMissingDocTypeTag:
       
   912 			aOutputMsg.Append(_L("Missing DocType Tag")); break;
       
   913 
       
   914 		case KErrXMLMissingVersionTag:
       
   915 			aOutputMsg.Append(_L("Missing Version Tag")); break;
       
   916 
       
   917 		case KErrXMLDuplicateAttributeName:
       
   918 			aOutputMsg.Append(_L("Duplicate Attribute Name")); break;
       
   919 
       
   920 		case KErrXMLMultipleRootElements:
       
   921 			aOutputMsg.Append(_L("Mulitiple Root Elements")); break;
       
   922 
       
   923 		case KErrXMLCorruptFile:
       
   924 			aOutputMsg.Append(_L("Corrupt File")); break;
       
   925 
       
   926 		case KErrXMLIllegalCharacter:
       
   927 			aOutputMsg.Append(_L("Illegal Character")); break;
       
   928 
       
   929 		case KErrXMLBadEntity:
       
   930 			aOutputMsg.Append(_L("Malformed Entity")); break;
       
   931 
       
   932 		case KErrXMLInvalidElement:
       
   933 			aOutputMsg.Append(_L("Invalid Element")); break;
       
   934 
       
   935 		case KErrXMLInvalidAttribute:
       
   936 			aOutputMsg.Append(_L("Invalid Attribute")); break;
       
   937 
       
   938 		case KErrPathNotFound:
       
   939 			aOutputMsg.Append(_L("File Path Not Found")); break;
       
   940 
       
   941 		case KErrNoMemory:
       
   942 			aOutputMsg.Append(_L("Memory Allocation Failure")); break;
       
   943 
       
   944 		case KErrNotSupported:
       
   945 			aOutputMsg.Append(_L("Not Supported")); break;
       
   946 
       
   947 		default:
       
   948 			aOutputMsg.Append(_L("Unknown Error")); break;
       
   949 		}
       
   950 	}
       
   951 
       
   952 //===================================================================================
       
   953 void CSmilTranslatorTestUtils::AppendSeverityStr(TInt aSeverity, TDes& aOutputMsg)
       
   954 	{
       
   955 	aOutputMsg.Append(_L(", Severity ")); 
       
   956 	switch(aSeverity)
       
   957 		{
       
   958 		case EXMLFatal:
       
   959 			aOutputMsg.Append(_L("Fatal")); 
       
   960 			break;
       
   961 		case EXMLIndeterminate:
       
   962 			aOutputMsg.Append(_L("Indeterminate")); 
       
   963 			break;
       
   964 		case EXMLWorkable:
       
   965 			aOutputMsg.Append(_L("Workable")); 
       
   966 			break;
       
   967 		case EXMLNone:
       
   968 			aOutputMsg.Append(_L("None")); 
       
   969 			break;
       
   970 		default:
       
   971 			aOutputMsg.Append(_L("Unknown"));
       
   972 			break;
       
   973 		}
       
   974 	}
       
   975 //===================================================================================
       
   976 
       
   977 void CSmilTranslatorTestUtils::ParseFileCompleteL()
       
   978 // call back function called from Parser::RunL()
       
   979 	{
       
   980 	// iXMLDoc ends up owned by this class, must delete off the old one on each pass.
       
   981 	delete iXMLDoc;
       
   982 	iXMLDoc = NULL;
       
   983 
       
   984 	// get parsed file, don't worry about errors, composer should be robust enough to handle bad files
       
   985 	iXMLDoc = iParser->DetachXMLDoc();
       
   986 
       
   987 	iComposerState = EComposing;
       
   988 	TRequestStatus *s = &iStatus;
       
   989 
       
   990 	iStartComposeTime.UniversalTime();
       
   991 
       
   992 	// create output dir if doesn't exist - this api ignores the file name (ignores everything after final '/')
       
   993 	fileSystem.MkDirAll(iOutputFileName);
       
   994 
       
   995 	// schedule composer active object for call to it's RunL function
       
   996 
       
   997 	if( iUseFileHandle )
       
   998 		{
       
   999 		RFile file;
       
  1000 		TInt fileError = file.Replace(iSession, iOutputFileName, EFileWrite | EFileStream);
       
  1001 
       
  1002 		if( fileError==KErrNone )
       
  1003 			{
       
  1004 		// 	No function declaration of ComposeFile() that take RFile Object parameter
       
  1005 //			iErr = iComposer->ComposeFile(file, iXMLDoc, filetype);
       
  1006 			iErr = iComposer->ComposeFile(iSession, iOutputFileName, iXMLDoc, testConfig->FileType());
       
  1007 			}
       
  1008 		else
       
  1009 			{
       
  1010 			// if a file error has occured, we need to set the internal error state
       
  1011 			// and can only do this by trying to compose again with the filepath so
       
  1012 			// it fails internally
       
  1013 			iErr = iComposer->ComposeFile(iSession, iOutputFileName, iXMLDoc, testConfig->FileType());
       
  1014 			}
       
  1015 		}
       
  1016 	else
       
  1017 		{
       
  1018 		iErr = iComposer->ComposeFile(iSession, iOutputFileName, iXMLDoc, testConfig->FileType());
       
  1019 		}
       
  1020 
       
  1021 	// we are waiting on this event...
       
  1022 	User::RequestComplete(s, KErrNone);
       
  1023 	}
       
  1024 
       
  1025 //===================================================================================
       
  1026 
       
  1027 void CSmilTranslatorTestUtils::ComposeFileCompleteL()
       
  1028 // call back function called from Composer::RunL()
       
  1029 	{
       
  1030 	TTime timeNow;
       
  1031 	timeNow.UniversalTime();
       
  1032 	TTimeIntervalMicroSeconds timeForCompose = timeNow.MicroSecondsFrom(iStartComposeTime);
       
  1033 	iComposeTime += timeForCompose.Int64();
       
  1034 
       
  1035 	if (iComposerState == ESizing)
       
  1036 		{
       
  1037 		// Check the size of the file that has been written against the size calulated by the
       
  1038 		// call to CMDXMLComposer::CalculateFileSize
       
  1039 
       
  1040 		RFile outputXMLFile;
       
  1041 		outputXMLFile.Open(iSession, iOutputFileName, EFileRead);
       
  1042 
       
  1043 		TInt actualSize;
       
  1044 		User::LeaveIfError(outputXMLFile.Size(actualSize));
       
  1045 		
       
  1046 		if (iSize != actualSize)
       
  1047 			{
       
  1048 			// The calculated file size doesn't match the real file size, this test has failed
       
  1049 			TBuf<255> outputMsg;
       
  1050 
       
  1051 			outputMsg.Append(KOutputNewLine);
       
  1052 			outputMsg.Append(_L("Test Failed - The calculated file size doesn't match the actual size."));
       
  1053 			outputMsg.Append(KOutputNewLine);			
       
  1054 			
       
  1055 			test.Printf(outputMsg);						// print to console
       
  1056 			iErrorFile.Write(DES_AS_8_BIT(outputMsg));	// print to error file			
       
  1057 			}
       
  1058 
       
  1059 		outputXMLFile.Close();
       
  1060 
       
  1061 		// If we are sizing then stop the active scheduler. Once the scheduler is stopped
       
  1062 		// and this function exits, program control resumes where the scheduler was started
       
  1063 		// in RunTestL.
       
  1064 //		CActiveScheduler::Stop();
       
  1065 		}
       
  1066 
       
  1067 	else if (iComposerState == EComposing)
       
  1068 		{
       
  1069 		// The XML file has been composed. Now we need to run the sizing function to check
       
  1070 		// that we can calculate the size correctly.
       
  1071 
       
  1072 		// Set the state to sizing and run the sizing operation...
       
  1073 		iComposerState = ESizing;
       
  1074 
       
  1075 		// Calculate the file size and wait for the callback to this function again.
       
  1076 		iComposer->CalculateFileSize(iSize, iXMLDoc, testConfig->FileType());
       
  1077 		}
       
  1078 	}
       
  1079 
       
  1080 //===================================================================================
       
  1081 
       
  1082 void CSmilTranslatorTestUtils::SetOutputFileName()
       
  1083 	{
       
  1084 	TInt offset;
       
  1085 
       
  1086 	iOutputFileName = iInputFileName;
       
  1087 	if((offset = iOutputFileName.Find(KTestFindStr)) != KErrNotFound)
       
  1088 		{
       
  1089 		iOutputFileName.Replace(offset, TPtrC(KTestFindStr).Length(), KTestReplaceStr);
       
  1090 		}
       
  1091 	}
       
  1092 
       
  1093 //===================================================================================
       
  1094 
       
  1095 //
       
  1096 // TestHarness implementation
       
  1097 //
       
  1098 
       
  1099 
       
  1100 
       
  1101 LOCAL_C TInt startTestL()
       
  1102 	{
       
  1103 	TInt err = KErrNone;
       
  1104 
       
  1105 	// we may need to make some output dirs if they don't already exist
       
  1106 	fileSystem.Connect();
       
  1107 
       
  1108 	scheduler = new (ELeave) CActiveScheduler;
       
  1109 	CleanupStack::PushL(scheduler);
       
  1110 	CActiveScheduler::Install( scheduler );
       
  1111 
       
  1112 	CSmilTranslatorTestUtils* ttu=CSmilTranslatorTestUtils::NewLC(); 
       
  1113 	
       
  1114 	// suspend execution until active object scheduler is finished
       
  1115 	CActiveScheduler::Start();
       
  1116 
       
  1117 	if (ttu->FilesProcessed()==0)
       
  1118 		err=KErrNotFound;
       
  1119 
       
  1120 	fileSystem.Close();
       
  1121 	CleanupStack::PopAndDestroy(2, scheduler); //scheduler, as well as the object
       
  1122 			                                   //placed on the stack by CSmilTranslatorTestUtils::NewLC();
       
  1123 	return err;
       
  1124 	}
       
  1125 
       
  1126 LOCAL_C TInt doMainL()
       
  1127 	{
       
  1128 	testConfig = CTestConfig::NewLC();
       
  1129 
       
  1130 	// set command line options
       
  1131 	TInt err=testConfig->ProcessCommandLineL();		
       
  1132 	if(err!=KErrNone)
       
  1133 		return err;
       
  1134 
       
  1135 	// users specified -h: display help to console and abort
       
  1136 	if (testConfig->NeedsHelp())
       
  1137 		{
       
  1138 		testConfig->DisplayHelp();
       
  1139 		test.Getch();
       
  1140 		return KErrNone;
       
  1141 		}
       
  1142 
       
  1143 	// user specified -i: let them override settings inside the console
       
  1144 	if (testConfig->IsInteractive())
       
  1145 		testConfig->InteractiveMode();
       
  1146 
       
  1147 #ifdef DEBUG_SMILTRANSLATORTEST_
       
  1148 	testConfig->Dump();
       
  1149 #endif
       
  1150 
       
  1151 	TInt returnCode = KErrNone;
       
  1152 
       
  1153 	// performance Performance Test
       
  1154 	if (testConfig->TestType() == CTestConfig::EPerformance)
       
  1155 		{
       
  1156 		TInt loopFor = 0;
       
  1157 		do
       
  1158 			{
       
  1159 			loopFor++;
       
  1160 			returnCode=startTestL();	// Qualified: false leavescan error		
       
  1161 			}
       
  1162 		while(loopFor!=testConfig->PerformanceTestIterations() && returnCode == KErrNone);
       
  1163 		}
       
  1164 	else if (testConfig->TestType()==CTestConfig::EMemory)
       
  1165 		{
       
  1166 		TInt after = 0;
       
  1167 		do
       
  1168 			{
       
  1169 			after++;
       
  1170 			User::__DbgSetAllocFail(RHeap::EUser, RHeap::EDeterministic, after);
       
  1171 			returnCode=startTestL();
       
  1172 			}
       
  1173 		while(returnCode != KErrNone);
       
  1174 		}
       
  1175 	// Assume user wants a basic test
       
  1176 	else
       
  1177 		{
       
  1178 		returnCode=startTestL();										
       
  1179 		}	
       
  1180 
       
  1181 	CleanupStack::Pop(testConfig);
       
  1182 	return returnCode;
       
  1183 	}
       
  1184 void CopyFileL()
       
  1185 	{	
       
  1186 	RFs fs;
       
  1187 	fs.Connect();	
       
  1188 	CleanupClosePushL(fs);
       
  1189 
       
  1190 	CFileMan* fileMan = CFileMan::NewL(fs);
       
  1191 	CleanupStack::PushL(fileMan); 
       
  1192 
       
  1193 	// Do the file copy	
       
  1194 	//User::LeaveIfError(fileMan->Copy(_L("z:\\gmxmltest.txt"),_L("c:\\gmxmltest.txt"),CFileMan::EOverWrite));
       
  1195   //User::LeaveIfError(fileMan->Copy(_L("z:\\legacyminidomparsertest"),_L("c:\\legacyminidomparsertest"),CFileMan::EOverWrite|CFileMan::ERecurse));
       
  1196     
       
  1197 	CleanupStack::PopAndDestroy(2); 
       
  1198 	}
       
  1199 
       
  1200 GLDEF_C TInt E32Main()
       
  1201 	{
       
  1202 	__UHEAP_MARK;
       
  1203 	theCleanup=CTrapCleanup::New();
       
  1204 	test.Start(_L("Smil Translator"));
       
  1205 	TRAPD(err,CopyFileL());
       
  1206 	test(err == KErrNone);
       
  1207 	TInt returnCode=KErrNone;
       
  1208 	TRAP(returnCode,returnCode=doMainL());
       
  1209 	test(returnCode==KErrNone);
       
  1210 	delete testConfig;
       
  1211 	delete theCleanup;	
       
  1212 	test.End();
       
  1213 	test.Close();
       
  1214 	__UHEAP_MARKEND;
       
  1215 	User::Heap().Check();
       
  1216 	return(KErrNone);
       
  1217 	}
       
  1218 
       
  1219 // End Of File