/** Calls CFbsFont::TextWidthInPixels() using SCharWidth output paramter */ void CT_DataFbsFont::DoCmdTextWidthInPixelsWithCharWidth(const TDesC& aSection) { INFO_PRINTF1(_L("Calls CFbsFont::TextWidthInPixels() using SCharWidth output paramter")); // get text from parameters TPtrC text; if (!GetStringFromConfig(aSection, KText(), text)) { ERR_PRINTF2(_L("No %S"), &KText()); SetBlockResult(EFail); } else { // call TextWidthInPixels() SCharWidth charWidth; iFbsFont->TextWidthInPixels(text, charWidth); // validate SCharWidth if (charWidth.iMove != charWidth.iLeftAdjust + charWidth.iWidth + charWidth.iRightAdjust) { ERR_PRINTF5(_L("Move is not equal to left adjust + width + right adjust!, move: %d, leftAdjust: %d, width: %d, rightAdjust: %d"), charWidth.iMove, charWidth.iLeftAdjust, charWidth.iWidth, charWidth.iRightAdjust); SetBlockResult(EFail); } } }
void CLoopbackTestStepBase::TestErrorCodeL(TInt aErrCode, TInt aExpectedErrCode, const TDesC& aMessage) { if(aExpectedErrCode == aErrCode) { INFO_PRINTF3(_L("[%S]. err[%d], as expected. OK."), &aMessage, aErrCode); } else { ERR_PRINTF5(_L("Failed: [%S]. err[%d], expected [%d]. Leaving with [%d])."), &aMessage, aErrCode, aExpectedErrCode, aErrCode); User::Leave(aErrCode); } }
void CPerformanceFunctionalityBase::PrintTestComparisonIteration( const TBool aResult, const TInt aIteration, const TText *aCompare, const TInt aLine, const TText *aFile) { _LIT(KComparePrint, "The comparison: %s failed on iteration: %d, at line: %d in file: %s"); if( !aResult ) { ERR_PRINTF5( KComparePrint, aCompare, aIteration, aLine, aFile ); TEST1( EFalse , ETrue ); } }
void CLoopbackTestStepBase::TestErrorCodeAndDescriptorL(TInt aErrCode, TInt aExpectedErrCode, const TDesC8& aDesC, const TDesC8& aExpectedDesC, const TDesC& aMessage) { if ( (aExpectedErrCode == aErrCode) && (aDesC.Compare(aExpectedDesC) == 0) ) { INFO_PRINTF4(_L("[%S]. err[%d], and string [%S] as expected. OK."), &aMessage, aErrCode, &aExpectedDesC); } else if (aExpectedErrCode == aErrCode) { ERR_PRINTF5(_L("Failed: [%S]. err[%d], expected [%d]. Leaving with [%d])."), &aMessage, aErrCode, aExpectedErrCode, aErrCode); User::Leave(aErrCode); } else { ERR_PRINTF4(_L("Failed: [%S]. String [%S] received, expected [%S]. Leaving with KErrGeneral."), &aMessage, &aDesC, &aExpectedDesC); User::Leave(KErrGeneral); } }
void CRecogStep::TestRecognizeDataL() { TDataRecognitionResult recogResult; TPtrC tmp; GetStringFromConfig(ConfigSection(), _L("fileName"), tmp); iFileName = tmp; TPtrC expectedDataType16; GetStringFromConfig(ConfigSection(), _L("expectedDataType"), expectedDataType16); HBufC8 *expectedDataBuf8 = ConvertDes16toHBufC8LC(expectedDataType16); TInt expectedConfidence; GetIntFromConfig(ConfigSection(), _L("expectedConfidence"), expectedConfidence); TInt maxDataBufSize; if (GetIntFromConfig(ConfigSection(), _L("maxDataBufSize"), maxDataBufSize)) { iLs.SetMaxDataBufSize(maxDataBufSize); } TPtrC method; GetStringFromConfig(ConfigSection(), _L("method"), method); TBool checkSpecific = EFalse; TBool matchedSpecificMimeType = EFalse; TPtrC specificMimeType; if (method == KMethodHandle) { checkSpecific = GetStringFromConfig(ConfigSection(), _L("checkSpecificMimeType"), specificMimeType); } TInt usePrivateFile = 0; GetIntFromConfig(ConfigSection(), _L("usePrivateFile"), usePrivateFile); RDeletefile deletefile(iTheFs, iFileName); if(!usePrivateFile) { // Tweak file modification time to defeat the apparch recognizer result cache.... TTime time; User::LeaveIfError(iTheFs.Modified(iFileName, time)); time += TTimeIntervalSeconds(1); User::LeaveIfError(iTheFs.SetModified(iFileName, time)); } else { // Copy file to private dir, this will make it inaccesible to the recognizer code (except via handle). ConvertFileToPrivateL(); CleanupClosePushL(deletefile); } if (method == KMethodName) { INFO_PRINTF2(_L("Test Recognizing %S by File Name"), &iFileName); User::LeaveIfError(iLs.RecognizeData(iFileName, KEmptyBuffer8, recogResult)); } else if((method == KMethodHandle) || (method == KMethodBuffer)) { RFile fileToRead; User::LeaveIfError(fileToRead.Open(iTheFs, iFileName, EFileShareReadersOrWriters | EFileRead | EFileStream)); CleanupClosePushL(fileToRead); if(method == KMethodHandle) { if (checkSpecific) { HBufC8* specificMimeType8 = ConvertDes16toHBufC8LC(specificMimeType); TDataType mime(*specificMimeType8); INFO_PRINTF2(_L("Test matching specific mime-type %S by Handle"), &iFileName); User::LeaveIfError(iLs.RecognizeSpecificData(fileToRead, mime, matchedSpecificMimeType)); CleanupStack::PopAndDestroy(specificMimeType8); } else { INFO_PRINTF2(_L("Test Recognizing %S by Handle"), &iFileName); User::LeaveIfError(iLs.RecognizeData(fileToRead, recogResult)); } } else { INFO_PRINTF2(_L("Test Recognizing %S by Buffer"), &iFileName); TInt size; User::LeaveIfError(fileToRead.Size(size)); TInt maxBufferSize; if(GetIntFromConfig(ConfigSection(), _L("maxBufferSize"), maxBufferSize)) { if(size > maxBufferSize) { size = maxBufferSize; } } HBufC8* memForFile = HBufC8::NewLC(size); TPtr8 fileContent(memForFile->Des()); User::LeaveIfError(fileToRead.Read(fileContent, size)); User::LeaveIfError(iLs.RecognizeData(iFileName, fileContent, recogResult)); CleanupStack::PopAndDestroy(); //memForFile, } CleanupStack::PopAndDestroy(&fileToRead); } else { ERR_PRINTF1(_L("method not set correctly")); User::Leave(KErrArgument); } if (checkSpecific) { if (matchedSpecificMimeType) { INFO_PRINTF2(_L("Specific type '%S' matched\n"), &specificMimeType); SetTestStepResult(EPass); } else { INFO_PRINTF2(_L("Specific type '%S' not matched\n"), &specificMimeType); SetTestStepResult(EFail); } } else { TPtrC result16 = recogResult.iDataType.Des(); if (// Expected failure ((expectedConfidence == CApaDataRecognizerType::ENotRecognized) && (recogResult.iDataType != expectedDataBuf8->Des())) || // Expected success ((recogResult.iConfidence == expectedConfidence) && (recogResult.iDataType == expectedDataBuf8->Des()))) { INFO_PRINTF3(_L("PASSED - type '%S' confidence=%d\n"), &result16, recogResult.iConfidence); SetTestStepResult(EPass); } else { ERR_PRINTF5(_L("FAILED - expected '%S', got type '%S' - expected confidence=%d got confidence %d\n"), &expectedDataType16, &result16, expectedConfidence, recogResult.iConfidence); SetTestStepResult(EFail); } } if(usePrivateFile) { CleanupStack::PopAndDestroy(&deletefile); } CleanupStack::PopAndDestroy(expectedDataBuf8); INFO_PRINTF1(KCompleted); }