os/textandloc/fontservices/textshaperplugin/test/testData.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * This file contains text and glyph data for testing
    16 *
    17 */
    18 
    19 
    20 #include <stdlib.h>
    21 #include <stdarg.h>
    22 #include <e32svr.h>
    23 #include <s32file.h>
    24 
    25 
    26 //class used for holding input and output data for the shaper, for testing purposes.
    27 class CTestData : public CBase
    28 	{
    29 public:
    30 	//ctor
    31 	CTestData(): iTypeFaceName(NULL), iFilename(NULL), iTextInput(NULL), iStart(0), iEnd(0), 
    32 	iGlyphCount(0), iGlyphs(NULL), iIndices(NULL), iPositions(NULL)
    33 			{}
    34 
    35 	~CTestData();
    36 	
    37 	//reads in all the data from the test file
    38 	void Internalize(TPtrC16 aTestDataFilename);
    39 	
    40 	//input parameters
    41 	TBuf16<50> iTypeFaceName;
    42 	TBuf16<100> iFilename;
    43 	TDes16* iTextInput;
    44 	TInt iStart;
    45 	TInt iEnd;
    46 		
    47 	//equivalent expected output
    48 	TInt iGlyphCount;
    49 	CArrayFixFlat<TUint32>* iGlyphs;		// note RArray not used for these members as
    50 	CArrayFixFlat<TUint16>* iIndices;		// is aligned to 4byte boundary
    51 	CArrayFixFlat<TUint16>* iPositions;
    52 	TPoint iAdvance;
    53 	TInt iCharacterCount;
    54 	};
    55 	
    56 CTestData::~CTestData(void)
    57 	{
    58 	delete iTextInput;
    59 	delete iGlyphs;
    60 	delete iIndices;
    61 	delete iPositions;
    62 	}
    63 	
    64 void CTestData::Internalize(TPtrC16 aTestDataFilename)
    65 	{
    66 	// open rfs handle
    67 	RFs fs;
    68 	User::LeaveIfError(fs.Connect());
    69 	CleanupClosePushL(fs);	
    70 	
    71 	// open file
    72 	RFile file;
    73 	file.Open(fs, aTestDataFilename, EFileRead);
    74 	
    75 	// set up file buf and read stream
    76 	RFileBuf buf;
    77 	buf.Attach(file);
    78 	CleanupClosePushL(buf);
    79 	RReadStream stream(&buf);	
    80 	CleanupClosePushL(stream);
    81 	
    82 	//read in from file
    83 	TBuf16<1500> tempBuf;
    84 	TInt count;
    85 	TInt i=0;
    86 	TChar delimiter('|');
    87 	
    88 	//FIRST THE INPUT DATA
    89 	
    90 	//number of input chars
    91 	count = stream.ReadInt16L();
    92 	
    93 	//typeface name
    94 	stream.ReadL(iTypeFaceName,delimiter);
    95 	iTypeFaceName.Delete(iTypeFaceName.Length() - 1, 1);
    96 
    97 	//filename
    98 	stream.ReadL(iFilename,delimiter);
    99 	iFilename.Delete(iFilename.Length() - 1, 1);
   100 
   101 	//start
   102 	iStart = stream.ReadInt16L();
   103 	stream.ReadL(tempBuf,delimiter);
   104 
   105 	//end
   106 	iEnd = stream.ReadInt16L();
   107 	stream.ReadL(tempBuf,delimiter);
   108 
   109 	//text input
   110 	iTextInput = new(ELeave) TBuf16<1500>;
   111 	stream.ReadL(*iTextInput,count);
   112 	stream.ReadL(tempBuf,delimiter);
   113 			
   114 	//NOW THE OUTPUT DATA	
   115 	
   116 	//firt the glyph count
   117 	iGlyphCount = stream.ReadInt16L();
   118 	
   119 	//then the Glyphs
   120 	iGlyphs = new(ELeave) CArrayFixFlat<TUint32>(1);
   121 	for (i=0; i<iGlyphCount; i++)
   122 		{
   123 			iGlyphs->AppendL(stream.ReadInt32L());
   124 		}
   125 	
   126 	//then the x and y positions
   127 	iPositions = new(ELeave) CArrayFixFlat<TUint16>(1);
   128 	for (i=0; i<iGlyphCount*2; i++)
   129 		{
   130 			iPositions->AppendL(stream.ReadInt16L());
   131 		}
   132 
   133 	//then the advance		
   134 	iAdvance.iX = stream.ReadInt16L();
   135 	iAdvance.iY = stream.ReadInt16L();
   136 	
   137 	//and finally the indices
   138 	iIndices = new(ELeave) CArrayFixFlat<TUint16>(1);
   139 	for (i=0; i<iGlyphCount; i++)
   140 		{
   141 			
   142 			iIndices->AppendL(stream.ReadInt16L());
   143 		}
   144 
   145 	//and the character count
   146 	iCharacterCount = stream.ReadInt16L();
   147 
   148 	CleanupStack::PopAndDestroy(3);	//buf, fs
   149 	}
   150 
   151 
   152