/** Function to generate a meaningful hash string from the test attributes

@param aSize the size of the font
@param aAttributes the attributes of the font 
@see TFontEffectsFlags
@param aTypefaceName the typeface name

@return the buffer with a text description, used for inclusion in the hash string
*/
HBufC* CTLinkedFontsComparison::GenerateTestDescriptionLC(TInt aSize,TUint32 aAttributes, const TPtrC &aTypefaceName, const TDesC &aTestDescription)
	{
	TBuf<KLengthOfHashValue> tempBuffer;
		
	//append the name
	tempBuffer.Append(_L("_"));
	tempBuffer.Append(aTypefaceName);
	tempBuffer.Append(_L("_"));
	tempBuffer.Append(aTestDescription);
	tempBuffer.Append(_L("_"));
	
	//append the size 
	tempBuffer.AppendFormat(_L("_size-%d"),aSize);
	if (aAttributes == 0)
		{
		//output no attributes
		tempBuffer.Append(_L("_"));
		tempBuffer.Append(KFontEffectsFlagsString[0]); //no attributes string
		}
	else
		{
		for (TInt counter=0;counter<31;counter++)
			{
			TInt bit = 1<<counter; //1,2,4,8 etc
			if (bit&aAttributes)
				{
				tempBuffer.Append(_L("_"));
				tempBuffer.Append(KFontEffectsFlagsString[counter+1]);
				}
			}
		}
	return tempBuffer.AllocLC();	
	}
Пример #2
0
/**
 *   Return array of string parameters i.e. key=a1,a2,a3 returns array which contains
 *   String a1, a2 and a3.
 *   @return ret - EFalse if can't get a String parameter from Config file.  ETrue if KErrNone
 */
TBool CDataWrapperBase::GetArrayFromConfig(const TDesC& aSectName, const TDesC& aKeyName, RPointerArray<HBufC>& aResult)
	{
	TBool	ret=EFalse;
	TPtrC completeArray;
	
	TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, completeArray));
	if ( err != KErrNone )
		{
		ret=EFalse;
		}

    TLex16 lex(completeArray); // Here we have the array as a string i.e. "a1,a2,a3"
    TBuf<256> buf;
    TChar chr;
    
    while(!lex.Eos())
        {
        chr = lex.Get();
        // Check if there was a list separator
        if (chr == ',')
            {
            HBufC* param = buf.AllocLC();
            buf.Zero();
            aResult.Append(param);
            CleanupStack::Pop(param); // pointer to buf is stored in RPointerArray
            }
        // If not separator character we can store the character into array
        else
            {
            buf.Append(chr);
            }
        }
    // Remember to put last token into array (,a3)
    HBufC* param = buf.AllocLC();
    aResult.Append(param);
    CleanupStack::Pop(param);
    
    return ret;
	}
/**
Auxilary function called to generate Hash ID String based on the parameters (test case ID, subtest etc...) and returns
HashId looks like:Testcasecame_0010_9_Swiss_EGray2_0 (aTestCase = DrawText_0010 or DrawTextVertical_0010, aSubTestNumber = 9, aFontFaceIndex = Swiss, aDisplayMode = EGray2, aOrientation = 0)
@param aTestCase holds the testcase ID
@param aSubTestNumber holds the subtest number
@param aFontFaceIndex holds the font face index (index used in KFontFace[])
@param aDisplayMode holds the display mode
@param aOrientation holds the orientation number
*/
EXPORT_C HBufC* CTHashReferenceImages::GenerateHashIdStringLC(const TDesC& aTestCase, TInt aSubTestNumber, const TPtrC aName[], TInt aNameIndex,
												TInt aDisplayMode, TInt aOrientation)
	{
	//this is here because at file scope there is uninitialised writable data
	const TDesC * KDisplayModeNames[KNumOfDisplayModes] = 
		{
		&KMode0,
		&KMode1,
		&KMode2,
		&KMode3,
		&KMode4,
		&KMode5,
		&KMode6,
		&KMode7,
		&KMode8,
		&KMode9,
		&KMode10,
		&KMode11,
		};	
	
	TBuf<KLengthOfHashValue> tempBuffer;
	tempBuffer.Format(KHashIDFormat, &aTestCase, aSubTestNumber, &aName[aNameIndex], KDisplayModeNames[aDisplayMode], aOrientation);
	return tempBuffer.AllocLC();
	}