diff -r 000000000000 -r 1fb32624e06b fontservices/textshaperplugin/test/testData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fontservices/textshaperplugin/test/testData.h Tue Feb 02 02:02:46 2010 +0200 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2005-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" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* This file contains text and glyph data for testing +* +*/ + + +#include +#include +#include +#include + + +//class used for holding input and output data for the shaper, for testing purposes. +class CTestData : public CBase + { +public: + //ctor + CTestData(): iTypeFaceName(NULL), iFilename(NULL), iTextInput(NULL), iStart(0), iEnd(0), + iGlyphCount(0), iGlyphs(NULL), iIndices(NULL), iPositions(NULL) + {} + + ~CTestData(); + + //reads in all the data from the test file + void Internalize(TPtrC16 aTestDataFilename); + + //input parameters + TBuf16<50> iTypeFaceName; + TBuf16<100> iFilename; + TDes16* iTextInput; + TInt iStart; + TInt iEnd; + + //equivalent expected output + TInt iGlyphCount; + CArrayFixFlat* iGlyphs; // note RArray not used for these members as + CArrayFixFlat* iIndices; // is aligned to 4byte boundary + CArrayFixFlat* iPositions; + TPoint iAdvance; + TInt iCharacterCount; + }; + +CTestData::~CTestData(void) + { + delete iTextInput; + delete iGlyphs; + delete iIndices; + delete iPositions; + } + +void CTestData::Internalize(TPtrC16 aTestDataFilename) + { + // open rfs handle + RFs fs; + User::LeaveIfError(fs.Connect()); + CleanupClosePushL(fs); + + // open file + RFile file; + file.Open(fs, aTestDataFilename, EFileRead); + + // set up file buf and read stream + RFileBuf buf; + buf.Attach(file); + CleanupClosePushL(buf); + RReadStream stream(&buf); + CleanupClosePushL(stream); + + //read in from file + TBuf16<1500> tempBuf; + TInt count; + TInt i=0; + TChar delimiter('|'); + + //FIRST THE INPUT DATA + + //number of input chars + count = stream.ReadInt16L(); + + //typeface name + stream.ReadL(iTypeFaceName,delimiter); + iTypeFaceName.Delete(iTypeFaceName.Length() - 1, 1); + + //filename + stream.ReadL(iFilename,delimiter); + iFilename.Delete(iFilename.Length() - 1, 1); + + //start + iStart = stream.ReadInt16L(); + stream.ReadL(tempBuf,delimiter); + + //end + iEnd = stream.ReadInt16L(); + stream.ReadL(tempBuf,delimiter); + + //text input + iTextInput = new(ELeave) TBuf16<1500>; + stream.ReadL(*iTextInput,count); + stream.ReadL(tempBuf,delimiter); + + //NOW THE OUTPUT DATA + + //firt the glyph count + iGlyphCount = stream.ReadInt16L(); + + //then the Glyphs + iGlyphs = new(ELeave) CArrayFixFlat(1); + for (i=0; iAppendL(stream.ReadInt32L()); + } + + //then the x and y positions + iPositions = new(ELeave) CArrayFixFlat(1); + for (i=0; iAppendL(stream.ReadInt16L()); + } + + //then the advance + iAdvance.iX = stream.ReadInt16L(); + iAdvance.iY = stream.ReadInt16L(); + + //and finally the indices + iIndices = new(ELeave) CArrayFixFlat(1); + for (i=0; iAppendL(stream.ReadInt16L()); + } + + //and the character count + iCharacterCount = stream.ReadInt16L(); + + CleanupStack::PopAndDestroy(3); //buf, fs + } + + +