textrendering/textformatting/test/src/tformhindi.cpp
changeset 53 11e2bb0d14ba
parent 0 1fb32624e06b
child 55 336bee5c2d35
equal deleted inserted replaced
46:6124ff6478cc 53:11e2bb0d14ba
     1 /*
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    25 #include <txtlaydc.h>
    25 #include <txtlaydc.h>
    26 #include <fbs.h>
    26 #include <fbs.h>
    27 #include <w32std.h>
    27 #include <w32std.h>
    28 #include <bitdev.h>
    28 #include <bitdev.h>
    29 #include <txtrich.h>
    29 #include <txtrich.h>
    30 
    30 #include "tformhindi.h"
    31 namespace LocalToFile {
    31 
       
    32 namespace LocalToTFormHindi {
    32 
    33 
    33 _LIT(KTformhindi, "tformhindi");
    34 _LIT(KTformhindi, "tformhindi");
    34 const TInt KDisplayWidth = 100;
    35 const TInt KDisplayWidth = 100;
    35 const TInt KDisplayHeight = 100;
    36 const TInt KDisplayHeight = 100;
    36 RTest test(KTformhindi);
       
    37 _LIT(KDevanagariFontName, "Devanagari OT Eval");
    37 _LIT(KDevanagariFontName, "Devanagari OT Eval");
    38 
    38 
       
    39 CTFormHindiStep* TestStep = NULL;
       
    40 #define TESTPOINT(p) TestStep->testpoint(p,(TText8*)__FILE__,__LINE__)
       
    41 #define TESTPRINT(p) TestStep->print(p,(TText8*)__FILE__,__LINE__)
       
    42 
    39 }
    43 }
    40 using namespace LocalToFile;
    44 using namespace LocalToTFormHindi;
    41 
    45 
    42 _LIT(KTestDeva, "|\x915\x94d\x92b|\x907|\x920\x94d\x920|");
    46 _LIT(KTestDeva, "|\x915\x94d\x92b|\x907|\x920\x94d\x920|");
    43 _LIT(KTestBidi, "|\x915|\x644|\x920|");
    47 _LIT(KTestBidi, "|\x915|\x644|\x920|");
    44 _LIT(KTestDeva2, "|\x917|\x91c|\x92f\x93f|\x924\x94d\x932\x940|\x917|");
    48 _LIT(KTestDeva2, "|\x917|\x91c|\x92f\x93f|\x924\x94d\x932\x940|\x917|");
    45 
    49 
    80 
    84 
    81 	for (TInt j = 0; j < positionCount - 1; ++j)
    85 	for (TInt j = 0; j < positionCount - 1; ++j)
    82 		{
    86 		{
    83 		aTextView->SetDocPosL(positions[j], EFalse);
    87 		aTextView->SetDocPosL(positions[j], EFalse);
    84 		TInt pos = aTextView->GetForwardDeletePositionL().HigherPos();
    88 		TInt pos = aTextView->GetForwardDeletePositionL().HigherPos();
    85 		test(pos == positions[j + 1]);
    89 		TESTPOINT(pos == positions[j + 1]);
    86 		aTextView->SetDocPosL(positions[j], ETrue);
    90 		aTextView->SetDocPosL(positions[j], ETrue);
    87 		pos = aTextView->GetForwardDeletePositionL().HigherPos();
    91 		pos = aTextView->GetForwardDeletePositionL().HigherPos();
    88 		test(pos == positions[j + 1]);
    92 		TESTPOINT(pos == positions[j + 1]);
    89 		aTextView->SetDocPosL(positions[j + 1], EFalse);
    93 		aTextView->SetDocPosL(positions[j + 1], EFalse);
    90 		pos = aTextView->GetBackwardDeletePositionL().LowerPos();
    94 		pos = aTextView->GetBackwardDeletePositionL().LowerPos();
    91 		test(pos == positions[j]);
    95 		TESTPOINT(pos == positions[j]);
    92 		aTextView->SetDocPosL(positions[j + 1], ETrue);
    96 		aTextView->SetDocPosL(positions[j + 1], ETrue);
    93 		pos = aTextView->GetBackwardDeletePositionL().LowerPos();
    97 		pos = aTextView->GetBackwardDeletePositionL().LowerPos();
    94 		test(pos == positions[j]);
    98 		TESTPOINT(pos == positions[j]);
    95 		}
    99 		}
    96 
   100 
    97 	aRichText->Reset();
   101 	aRichText->Reset();
    98 	}
   102 	}
    99 
   103 
   149 		if (containsZWJ || iChunk > 0)
   153 		if (containsZWJ || iChunk > 0)
   150 			{
   154 			{
   151 			// the first chunk with a LZW should be equal to iLeftChunk
   155 			// the first chunk with a LZW should be equal to iLeftChunk
   152 			if (0 == iChunk)
   156 			if (0 == iChunk)
   153 				{
   157 				{
   154 				test(text == iLeftChunk);
   158                 TESTPOINT(text == iLeftChunk);
   155 				iChunk++;
   159 				iChunk++;
   156 				}
   160 				}
   157 			// the following chunk should be equal to iRightChunk, if it is not-null.
   161 			// the following chunk should be equal to iRightChunk, if it is not-null.
   158 			else if (1 == iChunk && iRightChunk.Size() > 0)
   162 			else if (1 == iChunk && iRightChunk.Size() > 0)
   159 				{
   163 				{
   160 				test(text == iRightChunk);
   164                 TESTPOINT(text == iRightChunk);
   161 				iChunk++;
   165 				iChunk++;
   162 				}
   166 				}
   163 			// just ignore the following chunks
   167 			// just ignore the following chunks
   164 			}
   168 			}
   165 		}
   169 		}
   271 @SYMPREQ PREQ18 */
   275 @SYMPREQ PREQ18 */
   272 void TestTextViewL(CRichText* aRichText,
   276 void TestTextViewL(CRichText* aRichText,
   273 	CTextView* aTextView)
   277 	CTextView* aTextView)
   274 	{
   278 	{
   275 	// Test devanagari delete-by-syllable
   279 	// Test devanagari delete-by-syllable
   276 	test.Start(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1532 Test some simple Hindi "));
   280 	TESTPRINT(_L(" @SYMTestCaseID:SYSLIB-FORM-UT-1532 Test some simple Hindi "));
   277 	TestDeletePosition(KTestDeva, aRichText, aTextView);
   281 	TestDeletePosition(KTestDeva, aRichText, aTextView);
   278 
   282 
   279 	// Test Bidi
   283 	// Test Bidi
   280 	// The Arabic character is not present in this font, not even
   284 	// The Arabic character is not present in this font, not even
   281 	// as a fallback glyph. This allows us to exercise a fixes for
   285 	// as a fallback glyph. This allows us to exercise a fixes for
   282 	// a latent defect.
   286 	// a latent defect.
   283 	test.Next(_L("Test with characters not in font"));
   287 	TESTPRINT(_L("Test with characters not in font"));
   284 	TestDeletePosition(KTestBidi, aRichText, aTextView);
   288 	TestDeletePosition(KTestBidi, aRichText, aTextView);
   285 
   289 
   286 	// Test sample suggested by customer
   290 	// Test sample suggested by customer
   287 	test.Next(_L("Test Hindi #2"));
   291 	TESTPRINT(_L("Test Hindi #2"));
   288 	TestDeletePosition(KTestDeva2, aRichText, aTextView);
   292 	TestDeletePosition(KTestDeva2, aRichText, aTextView);
   289 
   293 
   290 	// regression test for PDEF101617: FORM always splits chunks at ZWJ character
   294 	// regression test for PDEF101617: FORM always splits chunks at ZWJ character
   291 	test.Next(_L("Regression test: PDEF101617"));
   295 	TESTPRINT(_L("Regression test: PDEF101617"));
   292 	PDEF_101617_DefectL(aRichText, aTextView);
   296 	PDEF_101617_DefectL(aRichText, aTextView);
   293 
   297 
   294 	test.End();
       
   295 	}
   298 	}
   296 
   299 
   297 void TestL(CFbsScreenDevice* aDevice)
   300 void TestL(CFbsScreenDevice* aDevice)
   298 	{
   301 	{
   299 	CParaFormatLayer* paraFormat = CParaFormatLayer::NewL();
   302 	CParaFormatLayer* paraFormat = CParaFormatLayer::NewL();
   314 	CleanupStack::PopAndDestroy(text);
   317 	CleanupStack::PopAndDestroy(text);
   315 	CleanupStack::PopAndDestroy(charFormat);
   318 	CleanupStack::PopAndDestroy(charFormat);
   316 	CleanupStack::PopAndDestroy(paraFormat);
   319 	CleanupStack::PopAndDestroy(paraFormat);
   317 	}
   320 	}
   318 
   321 
   319 void MainL()
   322 TVerdict CTFormHindiStep::doTestStepL()
   320 	{
   323 	{
       
   324     SetTestStepResult(EPass);
       
   325     TestStep = this;
       
   326     TESTPRINT(KTformhindi);
       
   327     
   321 	TInt error = RFbsSession::Connect();
   328 	TInt error = RFbsSession::Connect();
   322 	if (error == KErrNotFound)
   329 	if (error == KErrNotFound)
   323 		{
   330 		{
   324 		FbsStartup();
   331 		FbsStartup();
   325 		User::LeaveIfError(RFbsSession::Connect());
   332 		User::LeaveIfError(RFbsSession::Connect());
   368 	CActiveScheduler::Install(scheduler);
   375 	CActiveScheduler::Install(scheduler);
   369 
   376 
   370 	// We know that we have everything we need now, so we'll start the test!
   377 	// We know that we have everything we need now, so we'll start the test!
   371 	// A failure before this point would show up in the logs as "not run" rather
   378 	// A failure before this point would show up in the logs as "not run" rather
   372 	// than "failed".
   379 	// than "failed".
   373 	test.Title();
   380 	TESTPRINT(_L("Test forward/backward delete for Hindi"));
   374 	test.Start(_L("Test forward/backward delete for Hindi"));
       
   375 	TRAP(error, TestL(screenDevice));
   381 	TRAP(error, TestL(screenDevice));
   376 	test.End();
       
   377 	test.Close();
       
   378 	CleanupStack::PopAndDestroy(scheduler);
   382 	CleanupStack::PopAndDestroy(scheduler);
   379 	CleanupStack::PopAndDestroy(gc);
   383 	CleanupStack::PopAndDestroy(gc);
   380 	CleanupStack::PopAndDestroy(screenDevice);
   384 	CleanupStack::PopAndDestroy(screenDevice);
   381 	RFbsSession::Disconnect();
   385 	RFbsSession::Disconnect();
   382 	User::LeaveIfError(error);
   386 	User::LeaveIfError(error);
   383 	}
   387 	return TestStepResult();
   384 
   388 	}
   385 TInt E32Main()
       
   386 	{
       
   387 	static CTrapCleanup* TrapCleanup = CTrapCleanup::New();
       
   388 	if (!TrapCleanup)
       
   389 		return KErrNoMemory;
       
   390 	TRAPD(error, MainL());
       
   391 	delete TrapCleanup;
       
   392 	return error;
       
   393 	}