/** * Reads the value present from the test steps ini file within the mentioned section name and key name * Copies the value to the TInt reference passed in. The value can optionally be prefixed with 0x * @param aSectName - Section within the test steps ini file * @param aKeyName - Name of a key within a section * @return aResult - The integer value of the Hex input * @return TBool - ETrue for found, EFalse for not found */ TBool CDataWrapperBase::GetHexFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TInt& aResult) { TPtrC result; TBool ret=EFalse; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result)); if ( err != KErrNone ) { ret=EFalse; } if ( ret ) { TLex lex; if( result.FindC(KPrefixHex)==KErrNone ) { lex=result.Mid(KPrefixHex().Length()); } else { lex=result; } ret=(lex.Val((TUint &)aResult, EHex)==KErrNone); } return ret; }
/** CheckIfServerMessageExists() Checks if any server message has been added to the Body text returns the position of the server message in the buffer and the length of the server message.This function can be enhanced to check for any other server message encountered. If not found, returns KErrNotFound. @param aBodyText The body text of the message @return Position of the message, if not found returns KErrNotFound */ TInt CT_MsgComparePopEmailMsgs::CheckIfServerMessageExists(TPtrC aBodyText) { _LIT(KServerMessage,"*This message was transferred with a trial version of CommuniGate(tm) Pro*"); TInt pos = aBodyText.FindC(KServerMessage); return pos; }
/** * Reads the value present from the test steps ini file within the mentioned section name and key name * Copies the value to the TUint reference passed in. * If the value is prefixed with 0x the value is read as a hexadecimal value * If the value is suffixed with b the value is read as a binary value * If the value is prefixed with a 0 the value is read as an octal value * If it does not match the above it is read in as an integer * @param aSectName - Section within the test steps ini file * @param aKeyName - Name of a key within a section * @return aResult - The integer value of the Hex input * @return TBool - ETrue for found, EFalse for not found */ TBool CDataWrapperBase::GetUintFromConfig(const TDesC& aSectName, const TDesC& aKeyName, TUint& aResult) { TPtrC result; TBool ret=EFalse; TRAPD(err, ret=GetCommandStringParameterL(aSectName, aKeyName, result)); if ( err != KErrNone ) { ret=EFalse; } if ( ret ) { TLex lex(result); if( result.FindC(KPrefixHex)==KErrNone ) { lex=result.Mid(KPrefixHex().Length()); ret=(lex.Val(aResult, EHex)==KErrNone); } else { TInt binarySuffixPosition=result.Length()-KSuffixBinary().Length(); if ( result.FindC(KSuffixBinary)==binarySuffixPosition ) { lex=result.Left(binarySuffixPosition); ret=(lex.Val(aResult, EBinary)==KErrNone); } else { if( result.FindC(KPrefixOctal)==KErrNone ) { ret=(lex.Val(aResult, EOctal)==KErrNone); } else { TInt intResult; ret=(lex.Val(intResult)==KErrNone); if ( ret ) { aResult=(TUint)intResult; } } } } } return ret; }
LOCAL_C void DistinguishElement(const TPtrC& aElement, RArray<TRange>& aSelectiveCaseRange) { TInt colonOccurance = aElement.FindC(KTEFColon); //we are expecting only a range or a test case ID over here... if( colonOccurance!=KErrNotFound ) { //then this is a range of testcases, split it at the colon TRange newRange(aElement.Left(colonOccurance),aElement.Mid(colonOccurance+1)); aSelectiveCaseRange.Append(newRange); } else { TRange newRange(aElement,aElement); aSelectiveCaseRange.Append(newRange); } }
LOCAL_C void ParseCommandLineForSelectiveTestingOptions(const TDesC& aCommandLine,CTestExecuteIniData& aParseTestExecuteIni,RArray<TRange>& aSelectiveCaseRange, TDesC*& aSelTestCfgFileData) { TLex flagLex(aCommandLine); //first of all navigate the command line arguments to the selective test cases flag... while(!flagLex.Eos()) { TPtrC token(flagLex.NextToken()); if( (token.CompareF(KTestExecuteCommandLineFlagIncludeSelectiveCases) == 0) || (token.CompareF(KTestExecuteCommandLineFlagExcludeSelectiveCases) == 0) ) { break; } } TPtrC argument(flagLex.NextToken()) ; while(argument.Length() > 0 ) { TInt commaOccurance = argument.FindC(KTEFComma) ; TPtrC element ; if(commaOccurance == -1) { //handle the case where no comma is found, //assume only one item in the list element.Set(argument) ; //reset argument to break the while argument.Set(KNull); } else { element.Set(argument.Left(commaOccurance)); //take the remaining in the argument TInt len = argument.Length()-commaOccurance-1 ; argument.Set(argument.Right(len)) ; } TInt cfgExtensionOccurance = element.FindC(KTEFCfgExtension) ; if (cfgExtensionOccurance!=KErrNotFound) //madatory extension to be given { TPtrC cfgFilePath(element); //its probably the cfg file path. TBuf<KBuffSize> tempScriptPath(cfgFilePath); // Check whether cfg name is provided along with folder path in the command line // If not, take the path from testexecute.ini & name from the command line if(cfgFilePath.FindC(KTEFColon)==KErrNotFound) { TBuf<KMaxTestExecuteNameLength> tempBuffer; aParseTestExecuteIni.GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer); cfgFilePath.Set(tempBuffer); // Construct the full file path from the values extracted from command line and ini file TBuf<KBuffSize> storeScriptPathTemp(cfgFilePath); storeScriptPathTemp.Append(tempScriptPath); cfgFilePath.Set(storeScriptPathTemp); tempScriptPath.Copy(cfgFilePath); } // and parse this cfg File to populate our structures TRAP_IGNORE(CreateCfgDataFromFileL(cfgFilePath,aSelectiveCaseRange, aSelTestCfgFileData)); //actually do nothing with the error... } else { DistinguishElement(element,aSelectiveCaseRange ); } } }