textrendering/textformatting/test/src/TFormBenchmark.cpp
changeset 51 a7c938434754
parent 0 1fb32624e06b
child 55 336bee5c2d35
--- a/textrendering/textformatting/test/src/TFormBenchmark.cpp	Tue Jul 06 16:23:19 2010 +0300
+++ b/textrendering/textformatting/test/src/TFormBenchmark.cpp	Wed Aug 18 11:34:25 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -34,9 +34,21 @@
 #include "TAGMA_INTERNAL.H"
 #endif
 
+#include "tformbenchmark.h"
+
+namespace LocalToTFormBenchmark
+{
+CTFormBenchmarkStep* TestStep = NULL;
+#define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__)
+#define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__)
+}
+using namespace LocalToTFormBenchmark;
+
 RFs fs;
 RFile fileTimeStamps;
 
+_LIT(KFormBenchmark, "TFormBenchmark");
+
 #if ((defined (__WINS__)) || (defined (__X86GCC__)))
 	_LIT(KLogTimeStampsName, "c:\\formtimestamps.csv");
 #else
@@ -67,10 +79,6 @@
 const TInt KDisplayWidth = 100;
 const TInt KDisplayHeight = 120;
 
-
-_LIT(KFormBenchmark, "TFormBenchmark");
-RTest test(KFormBenchmark);
-
 const TInt KInsertDisplayWidth = 200;
 const TInt KChangedDisplayWidth = 150;
 
@@ -421,7 +429,7 @@
 	RArray<TTFTimeStamp>& aTimeStampsDown, RArray<TTFTimeStamp>& aTimeStampsUp,
 	TDocInfo& aDocInfo)
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1897 "));
+    TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1897 "));
 	TInt docLength = KEnglish().Length() * aRepeats;
 	TInt paragraphs = aRepeats/aRepeatsPerParagraph;
 
@@ -436,8 +444,10 @@
 	MeasureCursorL(aTimeStampsDown, TCursorPosition::EFLineDown, o, slowest);
 	MeasureCursorL(aTimeStampsUp, TCursorPosition::EFLineUp, o, slowest);
 
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_Scrolling_Slowest_Doc_with_%d_characters_%d_paragraphs;microseconds: %Ld", docLength, paragraphs, slowest);
-
+	TBuf<256> buf;
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_Scrolling_Slowest_Doc_with_%d_characters_%d_paragraphs;microseconds: %Ld"), docLength, paragraphs, slowest);
+	TESTPRINT(buf);
+	
 	aDocInfo = GetSampleDocInfoL(o);
 	DestroyFormattingObjects(o);
 	}
@@ -452,7 +462,7 @@
 */
 void RunEnglishArabicJapaneseBenchmarksL(TFormattingObjects& aFormattingObjects)
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1898 "));
+    TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1898 "));
 	SetTextL(*aFormattingObjects.iRichText, KEnglish, KEnglishRepeats, KEnglishRepeats);
 	TTimeIntervalMicroSeconds opening = MeasureOpeningL(*aFormattingObjects.iView);
 	TTimeIntervalMicroSeconds rmsCursorDown = MeasureRmsCursorDownL(*aFormattingObjects.iView);
@@ -484,18 +494,32 @@
 		maxLines = japaneseLines;
 
 	//Tests that the number of lines in each test is more or less balanced
-	test(maxLines * 100 <= minLines * 105);
+	TESTPOINT(maxLines * 100 <= minLines * 105);
 
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_OpeningLargeParagraph;microseconds: %d",
+	TBuf<256> buf;
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_OpeningLargeParagraph;microseconds: %d"),
 		static_cast<TInt>(opening.Int64()));
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_RmsCursorDown;microseconds: %d",
+	TESTPRINT(buf);
+	buf.Zero();
+	
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_RmsCursorDown;microseconds: %d"),
 		static_cast<TInt>(rmsCursorDown.Int64()));
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormattingEnglish;microseconds: %d",
+	TESTPRINT(buf);
+	buf.Zero();
+	
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingEnglish;microseconds: %d"),
 		static_cast<TInt>(englishFormatting.Int64()));
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormattingArabic;microseconds: %d",
+	TESTPRINT(buf);
+	buf.Zero();
+	
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingArabic;microseconds: %d"),
 		static_cast<TInt>(arabicFormatting.Int64()));
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormattingJapanese;microseconds: %d",
+	TESTPRINT(buf);
+	buf.Zero();
+	
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormattingJapanese;microseconds: %d"),
 		static_cast<TInt>(japaneseFormatting.Int64()));
+	TESTPRINT(buf);	
 	}
 
 /**
@@ -510,7 +534,7 @@
 void RunInsertTextTestsL(TInt aRepeats, TInt aRepeatsPerParagraph,
 	RArray<TTFTimeStamp>& aTimeStamps, TDocInfo& aDocInfo)
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1896 "));
+    TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1896 "));
 	TFormattingObjects o;
 	CreateFormattingObjectsLC(o);
 	TInt64 slowest = 0;
@@ -519,8 +543,10 @@
 	MeasureInsertTextAtStartL(aRepeats, aRepeatsPerParagraph, aTimeStamps, o, slowest);
 	aDocInfo = GetSampleDocInfoL(o);
 
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_InsertText_Slowest;microseconds: %Ld", slowest);
-
+	TBuf<256> buf;
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_InsertText_Slowest;microseconds: %Ld"), slowest);
+	TESTPRINT(buf);
+	
 	DestroyFormattingObjects(o);
 	}
 
@@ -535,7 +561,7 @@
 */
 void RunDeleteTextFromStartTest(RArray<TTFTimeStamp>& aTimeStamps, TDocInfo& aDocInfo)
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 "));
+    TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 "));
 	TFormattingObjects o;
 	CreateFormattingObjectsLC(o);
 	TInt64 slowest = 0;
@@ -549,7 +575,9 @@
 	MeasureDeleteTextFromStartL(aTimeStamps, o, slowest);
 	aDocInfo = GetSampleDocInfoL(o);
 
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_DeleteText_Slowest;microseconds: %Ld", slowest);
+	TBuf<256> buf;	
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_DeleteText_Slowest;microseconds: %Ld"), slowest);
+	TESTPRINT(buf);	
 
 	CleanupStack::PopAndDestroy();//bigbuf
 	DestroyFormattingObjects(o);
@@ -557,7 +585,7 @@
 
 void GetFormattingBenchmarkL(TInt aNumberOfIterations, TInt& aNumberOfCharacters, TInt64& aNormalisedBenchmark)
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 "));
+    TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1895 "));
 	TFormattingObjects o;
 	CreateFormattingObjectsLC(o);
 	o.iLayout->SetWrapWidth(KInsertDisplayWidth);
@@ -596,46 +624,65 @@
 */
 void RunFormattingBenchmarksL()
 	{
-	test.Next(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1894 "));
+    TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORMA-UT-1894 "));
 	TInt numberOfCharacters = 0;
 	TInt numberOfIterations;
 	TInt64 normalisedBenchmark = 0;
 
+	TBuf<256> buf;
+	
 	numberOfIterations = 1;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
-
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
+	
+	buf.Zero();
 	numberOfIterations = 5;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
-
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
+	
+	buf.Zero();
 	numberOfIterations = 10;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
 
+	buf.Zero();
 	numberOfIterations = 50;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
 
+	buf.Zero();
 	numberOfIterations = 100;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
 
+	buf.Zero();
 	numberOfIterations = 250;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
 
+	buf.Zero();
 	numberOfIterations = 500;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
-
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
+	
+	buf.Zero();
 	numberOfIterations = 750;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
-
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
+	
+	buf.Zero();
 	numberOfIterations = 1000;
 	GetFormattingBenchmarkL(numberOfIterations, numberOfCharacters, normalisedBenchmark);
-	RDebug::Printf("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration", numberOfCharacters, normalisedBenchmark);
+	buf.AppendFormat(_L("PERFORMANCE: Syslibs;Form_FormatText;document contains %d characters: %Ld microseconds per iteration"), numberOfCharacters, normalisedBenchmark);
+	TESTPRINT(buf);
 	}
 
 void RunBenchmarksL()
@@ -685,11 +732,14 @@
 
 	}
 
-TInt E32Main()
+TVerdict CTFormBenchmarkStep::doTestStepL()
 	{
-	test.Title();
-	test.Start(_L("Start Font/Bitmap Server"));
-	static CTrapCleanup* TrapCleanup = CTrapCleanup::New();
+    SetTestStepResult(EPass);
+    TestStep = this;
+    
+    TESTPRINT(KFormBenchmark);
+    TESTPRINT(_L("Start Font/Bitmap Server"));
+
 	TInt error = RFbsSession::Connect();
 	if (error == KErrNotFound)
 		{
@@ -697,26 +747,28 @@
 		error = RFbsSession::Connect();
 		}
 	// Tests that FBServ actually starts
-	test(error == KErrNone);
+	TESTPOINT(error == KErrNone);
 	error = fs.Connect();
-	test(error == KErrNone);
+	TESTPOINT(error == KErrNone);
 
 	error = fileTimeStamps.Replace(fs, KLogTimeStampsName, EFileWrite);
-	RDebug::Printf("> fileTimeStamps.Replace %d", error);
-	test(error == KErrNone);
+	
+	TBuf<256> buf;
+	buf.AppendFormat(_L("> fileTimeStamps.Replace %d"), error);
+	TESTPRINT(buf);
+	
+	TESTPOINT(error == KErrNone);
 
-	test.Next(_L("Run Benchmarks"));
+	TESTPRINT(_L("Run Benchmarks"));
 	TRAP(error, RunBenchmarksL());
 	// Tests that the Benchmarks did not run out of memory
 	// or otherwise leave
-	test(error == KErrNone);
+	TESTPOINT(error == KErrNone);
 
 	fileTimeStamps.Close();
 	fs.Close();
 	RFbsSession::Disconnect();
-	delete TrapCleanup;
-	test.End();
-	test.Close();
-	return error;
+
+	return TestStepResult();
 	}