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