textrendering/texthandling/ttext/TEtextDefect.cpp
branchRCL_3
changeset 17 336bee5c2d35
parent 16 748ec5531811
--- a/textrendering/texthandling/ttext/TEtextDefect.cpp	Tue Aug 31 17:01:26 2010 +0300
+++ b/textrendering/texthandling/ttext/TEtextDefect.cpp	Wed Sep 01 12:39:40 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-2009 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"
@@ -16,6 +16,7 @@
 */
 
 
+#include <e32test.h>
 #include <charconv.h>
 #include <gdi.h>
 #include <conpics.h>
@@ -24,41 +25,6 @@
 
 #include "TXTPLAIN.H"
 #include "TxtWriter.h"
-#include "TETextDefect.h"
-
-LOCAL_D CTestStep *pTestStep = NULL;
-#define test(cond)								\
-	{											\
-	TBool __bb = (cond);						\
-	pTestStep->TEST(__bb);						\
-	if (!__bb)									\
-		{										\
-		ERR_PRINTF1(_L("ERROR: Test Failed"));	\
-		User::Leave(1);							\
-		}										\
-	}
-#define test2(cond, line)										\
-	{															\
-	TBool __bb = (cond);										\
-	pTestStep->TEST(__bb);										\
-	if (!__bb)													\
-		{														\
-		ERR_PRINTF2(_L("Line %d, ERROR: Test Failed"), line);	\
-		User::Leave(1);											\
-		}														\
-	}
-#undef INFO_PRINTF1
-#undef INFO_PRINTF2
-#undef ERR_PRINTF1
-#undef ERR_PRINTF2
-#undef ERR_PRINTF3
-// copy from tefexportconst.h
-#define INFO_PRINTF1(p1)        pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1))
-#define INFO_PRINTF2(p1, p2)    pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, (p1), (p2))
-#define ERR_PRINTF1(p1)         pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1)) 
-#define ERR_PRINTF2(p1, p2)     pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2)) 
-#define ERR_PRINTF3(p1, p2, p3) pTestStep->Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, (p1), (p2), (p3)) ;
-
 
 //Used for supressing warning in OOM tests
  #define __UNUSED_VAR(var) var = var
@@ -69,6 +35,7 @@
 #endif
 
 _LIT(KTestName, "Start of Tests...");
+RTest theTest(KTestName);
 
 ///////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////
@@ -77,24 +44,24 @@
 	{
 	if(!aValue)
 		{
-		test2(EFalse, aLine);
+		theTest(EFalse, aLine);
 		}
 	}
 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine)
 	{
 	if(aValue != aExpected)
 		{
-	    ERR_PRINTF3(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
-		test2(EFalse, aLine);
+		theTest.Printf(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
+		theTest(EFalse, aLine);
 		}
 	}
-#define CHECK1(arg) ::Check((arg), __LINE__)
-#define CHECK2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
+#define TEST(arg) ::Check((arg), __LINE__)
+#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
 
 
 LOCAL_C void Inc049456L()
 	{
-   	INFO_PRINTF1(_L("Inc049456L"));
+   	theTest.Next(_L("Inc049456L"));
 
 	CPlainTextConverter* converter = CPlainTextConverter::NewLC();
 	CleanupStack::PopAndDestroy(converter);
@@ -102,7 +69,7 @@
 	
 LOCAL_C void OOM049456L()
 	{
-   	INFO_PRINTF1(_L("OOM049456L"));
+   	theTest.Next(_L("OOM049456L"));
 
 	TInt tryCount=0;
  	TInt error = KErrNone;
@@ -128,15 +95,15 @@
  		TInt endThreadHandleCount;
  		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
  
- 		CHECK1(startProcessHandleCount == endProcessHandleCount);
- 		CHECK1(startThreadHandleCount  == endThreadHandleCount);
+ 		TEST(startProcessHandleCount == endProcessHandleCount);
+ 		TEST(startThreadHandleCount  == endThreadHandleCount);
  				
  		__UHEAP_MARKEND;
  		
  		}while(error==KErrNoMemory);
  		
- 	CHECK2(error, KErrNone);
- 	INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i\n"),tryCount);		
+ 	TEST2(error, KErrNone);
+ 	theTest.Printf(_L("- server succeeded at heap failure rate of %i\n"),tryCount);		
 	}
 
 
@@ -144,7 +111,7 @@
 
 LOCAL_C void Inc051360L()
 	{
-   	INFO_PRINTF1(_L("Inc051360L"));
+   	theTest.Next(_L("Inc051360L"));
    	
 	// Test data to force a remainder of 2 from the charconv unicode conversion.
 	// The etext buffer is 1024 bytes that truncates the last utf-8 character.
@@ -256,7 +223,7 @@
 	const TUint16* ptr = (TUint16*) (ptr8.Ptr());
 	TPtrC16 des16 (ptr, 2);
 
-	CHECK1(unicodeConversion == des16);
+	TEST(unicodeConversion == des16);
 	
 	CleanupStack::PopAndDestroy (&outputStr);	
 	CleanupStack::PopAndDestroy (outbuffer);	
@@ -267,7 +234,7 @@
 	
 LOCAL_C void OOM051360L()
 	{
-   	INFO_PRINTF1(_L("OOM051360L"));
+   	theTest.Next(_L("OOM051360L"));
 
 	TInt tryCount=0;
  	TInt error = KErrNone;
@@ -293,20 +260,20 @@
  		TInt endThreadHandleCount;
  		RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
  
- 		CHECK1(startProcessHandleCount == endProcessHandleCount);
- 		CHECK1(startThreadHandleCount  == endThreadHandleCount);
+ 		TEST(startProcessHandleCount == endProcessHandleCount);
+ 		TEST(startThreadHandleCount  == endThreadHandleCount);
  				
  		__UHEAP_MARKEND;
  		
  		}while(error==KErrNoMemory);
  		
- 	CHECK2(error, KErrNone);
- 	INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i\n"),tryCount);		
+ 	TEST2(error, KErrNone);
+ 	theTest.Printf(_L("- server succeeded at heap failure rate of %i\n"),tryCount);		
 	}
 	
 LOCAL_C void OOM056552L()
 	{
-	INFO_PRINTF1(_L("OOM056552L"));
+	theTest.Next(_L("OOM056552L"));
 
 	TInt tryCount=0;
  	TInt error = KErrNone;
@@ -338,8 +305,8 @@
  		
  		}while(error==KErrNoMemory);
  		
- 	test(error==KErrNone);
- 	INFO_PRINTF2(_L("	richText->InsertL - succeeded at heap failure rate of %i\n"),tryCount);	
+ 	theTest(error==KErrNone);
+ 	theTest.Printf(_L("	richText->InsertL - succeeded at heap failure rate of %i\n"),tryCount);	
 	}
 /////////////////////////////////////////////////////////////////////////////////////////////////
 // Testing the fix for
@@ -385,7 +352,7 @@
 	TBuf<32> testBuf;
 	TOutputChar outputChar;
 
-   	INFO_PRINTF1(_L("INC055971L - OrganiseByParagraph test"));
+   	theTest.Next(_L("INC055971L - OrganiseByParagraph test"));
 
 		{
 		TParagraphTextWriter paragraphTextWriter(outputChar);
@@ -394,43 +361,43 @@
 		testBuf = _L("\xD");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("\xA");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("\xD\xA");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("zz\xD\xA\xD\xA\xAz\xD");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 7);
-		CHECK1(TheOutputTestBuf[0] == 'z');
-		CHECK1(TheOutputTestBuf[1] == 'z');
-		CHECK1(TheOutputTestBuf[2] == CEditableText::EParagraphDelimiter);
-		CHECK1(TheOutputTestBuf[3] == CEditableText::EParagraphDelimiter);
-		CHECK1(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter);
-		CHECK1(TheOutputTestBuf[5] == 'z');
-		CHECK1(TheOutputTestBuf[6] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 7);
+		TEST(TheOutputTestBuf[0] == 'z');
+		TEST(TheOutputTestBuf[1] == 'z');
+		TEST(TheOutputTestBuf[2] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf[3] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf[5] == 'z');
+		TEST(TheOutputTestBuf[6] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("This\xDIs\xATest\xD\xAMessage");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 20);
-		CHECK1(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter);
-		CHECK1(TheOutputTestBuf[7] == CEditableText::EParagraphDelimiter);
-		CHECK1(TheOutputTestBuf[12] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 20);
+		TEST(TheOutputTestBuf[4] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf[7] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf[12] == CEditableText::EParagraphDelimiter);
 		}
 
-   	INFO_PRINTF1(_L("INC055971L - OrganiseByLine test"));
+   	theTest.Next(_L("INC055971L - OrganiseByLine test"));
 
 		{
 		TLineTextWriter lineTextWriter(outputChar);
@@ -439,61 +406,61 @@
 		testBuf = _L("\xD");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == ' ');
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == ' ');
 
 		testBuf = _L("\xA");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == ' ');
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == ' ');
 
 		testBuf = _L("\xD\xA");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == ' ');
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == ' ');
 
 		testBuf = _L("\xD\xA\xD\xA");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("\xD\xD");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("\xA\xA");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("\xA\xD");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("\xD\xA\xA");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 1);
-		CHECK1(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 1);
+		TEST(TheOutputTestBuf[0] == CEditableText::EParagraphDelimiter);
 
 		testBuf = _L("\xD\xAz\xAzz\xA\xD");
 		TheOutputTestBuf.Zero();
 		::TranslateToEofTestL(slbTranslator, testBuf);
-		CHECK1(TheOutputTestBuf.Length() == 6);
-		CHECK1(TheOutputTestBuf[0] == ' ');
-		CHECK1(TheOutputTestBuf[1] == 'z');
-		CHECK1(TheOutputTestBuf[2] == ' ');
-		CHECK1(TheOutputTestBuf[3] == 'z');
-		CHECK1(TheOutputTestBuf[4] == 'z');
-		CHECK1(TheOutputTestBuf[5] == CEditableText::EParagraphDelimiter);
+		TEST(TheOutputTestBuf.Length() == 6);
+		TEST(TheOutputTestBuf[0] == ' ');
+		TEST(TheOutputTestBuf[1] == 'z');
+		TEST(TheOutputTestBuf[2] == ' ');
+		TEST(TheOutputTestBuf[3] == 'z');
+		TEST(TheOutputTestBuf[4] == 'z');
+		TEST(TheOutputTestBuf[5] == CEditableText::EParagraphDelimiter);
 		}
 	}
 
@@ -512,7 +479,7 @@
 */
 LOCAL_C void INC097216L()
 	{
-	INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-ETEXT-CT-3346 INC097216L - Test EOD character is formatted with rest of text "));
+	theTest.Next(_L(" @SYMTestCaseID:SYSLIB-ETEXT-CT-3346 INC097216L - Test EOD character is formatted with rest of text "));
 	
 	__UHEAP_MARK;
 
@@ -537,7 +504,7 @@
 	richText->GetCharFormat(charFormat, formatMask, textLength, 1); // get format info for EOD character
 	TInt EodFontHeight = charFormat.iFontSpec.iHeight;	
 	
-	CHECK1(characterFontHeight == EodFontHeight);
+	TEST(characterFontHeight == EodFontHeight);
 	
 	delete paraLayer; paraLayer = NULL;
 	delete charLayer; charLayer = NULL;
@@ -559,7 +526,7 @@
 */
 LOCAL_C void INC101996L()
 	{
-	INFO_PRINTF1(_L("@SYMTestCaseID:SYSLIB-ETEXT-CT-3386 INC101996 CEikRichTextEditor control don't support anti-aliasing font"));
+	theTest.Next(_L("@SYMTestCaseID:SYSLIB-ETEXT-CT-3386 INC101996 CEikRichTextEditor control don't support anti-aliasing font"));
 
 	__UHEAP_MARK;
 
@@ -598,8 +565,8 @@
 	TGlyphBitmapType startBitmapType = defaultCharFormat.iFontSpec.iFontStyle.BitmapType(); 
 	
 	//Verify the formatting and the contents of the string
-	CHECK2(startBitmapType, EDefaultGlyphBitmap);
-	CHECK1(defaultString == KDefaulFormattedText);
+	TEST2(startBitmapType, EDefaultGlyphBitmap);
+	TEST(defaultString == KDefaulFormattedText);
 		
 	//Get the string portion with antialiased formatting
 	TPtrC antialiasedString;
@@ -608,8 +575,8 @@
 	TGlyphBitmapType endBitmapType = antiAliasedCharFormat.iFontSpec.iFontStyle.BitmapType(); 	
 	
 	//Verify the formatting and the contents of the string
-	CHECK2(endBitmapType,EAntiAliasedGlyphBitmap);
-	CHECK1(antialiasedString == KAntiAliasedText);
+	TEST2(endBitmapType,EAntiAliasedGlyphBitmap);
+	TEST(antialiasedString == KAntiAliasedText);
 	
 	delete paraLayer; paraLayer = NULL;
 	delete charLayer; charLayer = NULL;
@@ -636,28 +603,28 @@
 	
 	__UHEAP_MARKEND;	
    	}
-
-CTEtextDefect::CTEtextDefect()
-    {
-    SetTestStepName(KTestStep_TEtextDefect);
-    pTestStep = this;
-    }
-
-TVerdict CTEtextDefect::doTestStepL()
-    {
-    SetTestStepResult(EFail);
-
-    CTrapCleanup* trapCleanup=CTrapCleanup::New();
+   
+/***
+Main
+*/
+GLDEF_C TInt E32Main()
+	{
+   	CTrapCleanup* trapCleanup=CTrapCleanup::New();
    
-    INFO_PRINTF1(KTestName);
-    TRAPD(error, DoTestsL());
-
-    delete trapCleanup;
+   	theTest.Start(KTestName);
+	TRAPD(error, DoTestsL());
+	TEST2(error, KErrNone);
+ 	
+	delete trapCleanup;
+ 	
+	theTest.End();
+	theTest.Close();
 
-    if (error == KErrNone)
-        {
-        SetTestStepResult(EPass);
-        }
+   	return KErrNone;
+   	}
+   	
+   	
+   	
 
-    return TestStepResult();
-    }
+
+