void CTmsTestStep::CleanUpAndWriteResults() { RFs fs; fs.Connect(); CleanupClosePushL(fs); iTestStepPositions.Close(); if (iTestStepNames != NULL) { iTestStepNames->Reset(); delete iTestStepNames; iTestStepNames = NULL; if (BaflUtils::FolderExists(fs, KLogLocation)) { RFile file; if (BaflUtils::FileExists( fs, KLogLocation )) { // open the temporary tms log TInt err = file.Open( fs, KLogLocation, EFileRead|EFileShareAny); if(err == KErrInUse) { CleanupStack::PopAndDestroy(); return; } if (err == KErrNone) { CleanupClosePushL(file); TBuf8<256> line; TBuf<250> testID; TBuf<6> testResult; // get a line from the temporary tms log while (CTmsTestStep::ReadNextLineL(file,line)) { TInt blankPos = line.Find(KBlankSpace); // get the ID from the line testID.Copy(line.Left(blankPos)); //get the pass or fail result from the line testResult.Copy(line.Mid(blankPos+1,4)); // print into the standard tef log the id and the result in the correct format // so that they are correctly parsed into the TMS csv file INFO_PRINTF2(_L("START_TESTCASE %S"),&testID); INFO_PRINTF2(_L("Line = 1 Command = START_TESTCASE %S"),&testID); INFO_PRINTF2(_L("END_TESTCASE %S"),&testID); INFO_PRINTF3(_L("Line = 1 Command = END_TESTCASE %S ***TestCaseResult = %S"),&testID,&testResult); } CleanupStack::PopAndDestroy(); } // remove the temporary tms log fs.Delete(KLogLocation); } } } CleanupStack::PopAndDestroy(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // void CSymbianUnitTestResult::AddFailureL( const TDesC8& aFailureText, TInt aAllocFailureRate ) { CSymbianUnitTestFailure* failure = NULL; if ( aAllocFailureRate > 0 ) { const TInt KLength = aFailureText.Length() + KSymbianUnitTestAllocFailureRateFormat().Length() + KMax64BitUintLengthAsDescriptor; HBufC8* failureMsg = HBufC8::NewLC( KLength ); failureMsg->Des() = aFailureText; failureMsg->Des().AppendFormat( KSymbianUnitTestAllocFailureRateFormat, aAllocFailureRate ); failure = CSymbianUnitTestFailure::NewL( *iCurrentTestName, *failureMsg, KErrNotFound, KNullDesC8 ); CleanupStack::PopAndDestroy( failureMsg ); CleanupStack::PushL( failure ); } else { failure = CSymbianUnitTestFailure::NewLC( *iCurrentTestName, aFailureText, KErrNotFound, KNullDesC8 ); } TBuf8<KMaxLength> strLine; strLine.Format( KSymbianUnitTestFailed, &aFailureText ); while(strLine.Length() > 120) { TBuf8<KMaxLength> line = strLine.MidTPtr( 0, 120 ); line.Append( '-' ); SUT_LOG_FORMAT(_L8("%S"), &line ); line = strLine.Mid( 120 ); strLine = line; } SUT_LOG_FORMAT(_L8("%S"), &strLine ); //SUT_LOG_FORMAT(KSymbianUnitTestFailed, &aFailureText); iCurrentResult = EFalse; iFailures.AppendL( failure ); CleanupStack::Pop( failure ); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // void CSymbianUnitTestResult::AddAssertFailureL( const TDesC8& aFailureMessage, TInt aLineNumber, const TDesC8& aFileName ) { CSymbianUnitTestFailure* failure = CSymbianUnitTestFailure::NewLC( *iCurrentTestName, aFailureMessage, aLineNumber, aFileName ); TBuf8<KMaxLength> strLine; strLine.Format( KSymbianUnitTestErrorFormat, &aFileName, aLineNumber, &aFailureMessage ); while(strLine.Length() > 120) { TBuf8<KMaxLength> line = strLine.MidTPtr( 0, 120 ); line.Append( '-' ); SUT_LOG_FORMAT(_L8("%S"), &line ); line = strLine.Mid( 120 ); strLine = line; } SUT_LOG_FORMAT(_L8("%S"), &strLine ); iCurrentResult = EFalse; iFailures.AppendL( failure ); CleanupStack::Pop( failure ); }
// --------------------------------------------------------------------------------- // CUpnpTmServerDeviceXmlParser::StartL // Method which inputs xml formatted buffer content to the XML Parser // and invokes parsing // --------------------------------------------------------------------------------- // void CUpnpTmServerDeviceXmlParser::StartL() { OstTraceFunctionEntry0( CUPNPTMSERVERDEVICEXMLPARSER_STARTL_ENTRY ); TDriveNumber drive = RFs::GetSystemDrive(); //Find system's drive TBuf<UpnpString::KMaxFilenameLength> privatePath; TInt err = iFs.PrivatePath(privatePath); //Find the application's private path // a) If the Private Path is not found (for whatever reasons), // Create a private path in the System Drive if( err == KErrNotFound ) { User::LeaveIfError( iFs.CreatePrivatePath(drive) ); } // b) If Private Path is found but is a read-only or non-persistent drive // Create a private path in the system drive else use it else if( err == KErrNone ) { TDriveInfo driveInfo; User::LeaveIfError( iFs.Drive(driveInfo)); TUint driveAttr = driveInfo.iDriveAtt; if ( driveAttr == KDriveAttRom ) { User::LeaveIfError( iFs.CreatePrivatePath(drive) ); } } else { OstTrace1( TRACE_ERROR, CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;err=%d", err ); User::Leave(err); } privatePath.Append(KPublicDevicePath()); err = iFs.MkDirAll(privatePath); if( err && err != KErrAlreadyExists ) { OstTrace1( TRACE_ERROR, DUP1_CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;err=%d", err ); User::LeaveIfError(err); } iDeviceDir.CreateL(privatePath); RBuf8 rootDeviceBuf; CleanupClosePushL(rootDeviceBuf); rootDeviceBuf.CreateL(KBufSize); rootDeviceBuf.Append(KRootDeviceXmlLead()); // Appends the device icon list to the device xml buffer const RPointerArray<CUpnpTerminalModeIcon>& deviceList = iDeviceInfo.DeviceIconList(); TInt iconCount = deviceList.Count(); if ( iconCount > KErrNone ) { privatePath.Append(KIconDirectory()); err = iFs.MkDir(privatePath); // Creates icon directory if( err && err != KErrAlreadyExists ) { OstTrace1( TRACE_ERROR, DUP2_CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;err=%d", err ); User::LeaveIfError(err); } iIconDirectory.CreateL(privatePath); OstTrace1( TRACE_ERROR, DUP3_CUPNPTMSERVERDEVICEXMLPARSER_STARTL, "CUpnpTmServerDeviceXmlParser::StartL;iconCount=%d", iconCount ); rootDeviceBuf.Append(KStartIconList); for ( TInt i(0); i < iconCount; i++ ) { rootDeviceBuf.Append(KStartIcon); rootDeviceBuf.Append(KStartMimeType); rootDeviceBuf.Append(deviceList[i]->MimeType()); rootDeviceBuf.Append(KEndMimeType); rootDeviceBuf.Append(KStartWidth); rootDeviceBuf.AppendNum(deviceList[i]->Width()); rootDeviceBuf.Append(KEndWidth); rootDeviceBuf.Append(KStartHeight); rootDeviceBuf.AppendNum(deviceList[i]->Height()); rootDeviceBuf.Append(KEndHeight); rootDeviceBuf.Append(KStartDepth); rootDeviceBuf.AppendNum(deviceList[i]->Depth()); rootDeviceBuf.Append(KEndDepth); rootDeviceBuf.Append(KStartUrl); TBuf8<KMaxPath> iconBuf; const TDesC& fileName = deviceList[i]->IconFilename(); iconBuf.Copy(fileName); TBuf8<UpnpString::KDefaultStringLength> iconRelativeUrl(KScpdUrl()); // Extracts the actual input filepath and creates the relative url for the icon // to be provided in the device xml file iconRelativeUrl.Append(KIconPath()); // Extracts only filename and appends the same to url iconRelativeUrl.Append(iconBuf.Mid((iconBuf.LocateReverse(KDirectorySeparator))+1)); rootDeviceBuf.Append(iconRelativeUrl); delete iFileMan; iFileMan = NULL; iFileMan = CFileMan::NewL(iFs) ; // copies icon files to the private device directory User::LeaveIfError(iFileMan->Copy(fileName,iIconDirectory)); rootDeviceBuf.Append(KEndUrl); rootDeviceBuf.Append(KEndIcon); } rootDeviceBuf.Append(KEndIconList); } rootDeviceBuf.Append( iDeviceInfo.DeviceInfo()); rootDeviceBuf.Append( KRootDeviceXmlTrail() ); ParseL(*iParser, rootDeviceBuf ); CleanupStack::PopAndDestroy(&rootDeviceBuf); OstTraceFunctionExit0( CUPNPTMSERVERDEVICEXMLPARSER_STARTL_EXIT ); }
void CATSmsReadPDU::ParseAndStoreCMGRResponseL() /** * Parse the +CMGR: message from the ME. * It is of the form +CMGR: <Msg Status>,[<alpha>],<Msg Length> <New line> PDU */ { LOCAL_LOGTEXT("ParseAndStoreCMGRResponseL","Enter function"); __ASSERT_DEBUG(iClientItem,Panic(ESmsRxQueuePduReadNullParameter)); // Intiailise the attributes iClientItem->iAttr.iFlags=0; iClientItem->iAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; iClientItem->iAttr.iFlags|=RMobileSmsMessaging::KSmsDataFormat; iClientItem->iAttr.iStatus=RMobileSmsMessaging::EMtMessageStored; iClientItem->iAttr.iFlags|=RMobileSmsMessaging::KIncomingStatus; iClientItem->iAttr.iFlags|=RMobileSmsMessaging::KStorageLocation; ParseBufferLC(); CATParamListEntry* start; CATParamListEntry* msgAlpha; CATParamListEntry* msgLen; CATParamListEntry* msgPdu; { // Curly brackets used to scope 'iter' variable // // Read in tokens TDblQueIter<CATParamListEntry> iter(iRxResults); start=iter++; iter++; // To skip past the msgStatus pointer which is not used. msgAlpha=iter++; msgLen=iter++; msgPdu=iter; } // If alpha token was missing then we have to reorder our tokens if(msgPdu==NULL) { LOCAL_LOGTEXT("ParseAndStoreCMGRResponseL","<alpha> token seems to be missing"); msgPdu=msgLen; msgLen=msgAlpha; } // Ensure that we have all the tokens we need if(start==NULL || msgLen==NULL || msgPdu==NULL) { LOCAL_LOGTEXT("ParseAndStoreCMGRResponseL","Failed to read in tokens"); CleanupStack::PopAndDestroy(); // destroy ParseBufferLC object return; } // // Process tokens // Process message length token TInt msgLenVal(0); msgLenVal=CATParamListEntry::EntryValL(msgLen); // // Copy the received pdu to local storage so that we can process // and modify it. // Buffer size calculated as follows; // (max pdu size + max prefixed SCA size) * number of ASCII chars used to code an octet TBuf8<(RMobileSmsMessaging::KGsmTpduSize+12)*2> localPdu; localPdu.Copy(msgPdu->iResultPtr); // // Check if we have a prefixed SCA on our pdu. // If we do then remove it. if(localPdu.Length()>(msgLenVal*2)) { if(CATSmsUtils::ReadAndRemoveAddressFromAscii(localPdu,iClientItem->iAttr.iGsmServiceCentre,ETrue)!=KErrNone) { LOCAL_LOGTEXT("ParseAndStoreCMGRResponseL","Failed to read and remove SCA from PDU"); } else { iClientItem->iAttr.iFlags|=RMobileSmsMessaging::KGsmServiceCentre; } } // // Read originator address from PDU // We know from ETSI standards that the originator address // will start with the 3rd character (at index 2) in the pdu if(CATSmsUtils::ReadAddressFromAscii(localPdu.Mid(2),iClientItem->iAttr.iOriginator,EFalse)!=KErrNone) { LOCAL_LOGTEXT("ParseAndStoreCMGRResponseL","Failed to read originator from PDU"); } else { iClientItem->iAttr.iFlags|=RMobileSmsMessaging::KRemotePartyInfo; } // // Convert received pdu from ASCII into binary if(CATSmsUtils::ConvertAsciiToBinary(localPdu,iClientItem->iPdu)!=KErrNone) { LOCAL_LOGTEXT("ParseAndStoreCMGRResponseL","Failed to code PDU into binary"); } // // We've finsihed, do clean up CleanupStack::PopAndDestroy(); // destroy ParseBufferLC object LOCAL_LOGTEXT("ParseAndStoreCMGRResponseL","Exit function, PDU read OK"); }
/** ConstructL() Parses a .txt file and creates Arrays of fields and there values @param aFileName Name of the file to be parsed. */ EXPORT_C void CT_MsgUtilsConfigFileParserUtility::ConstructL(const TDesC& aFileName) { RFs fileServerSession; fileServerSession.Connect(); RFile file; User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead)); TInt eof = EFalse; TInt fileOffset = 0; TBuf8<KFileBufferSize> fileBuffer; while (!eof) { fileBuffer.SetLength(0); User::LeaveIfError(file.Read(fileOffset, fileBuffer, KFileBufferSize)); TInt read = fileBuffer.Length(); if (read < KFileBufferSize) { fileBuffer.Append('\n'); eof = ETrue; } TInt lineOverflow = fileBuffer.Locate('\n'); if ((lineOverflow == KErrNotFound) && (read == KFileBufferSize)) { User::Leave(KErrOverflow); } TInt eol = EFalse; while (!eol) { TInt lineFeedLocation = fileBuffer.Locate('\n'); if (lineFeedLocation == KErrNotFound) { eol = ETrue; } else { fileOffset += lineFeedLocation + 1; TInt lineLength; if ((lineFeedLocation != 0) && (fileBuffer[lineFeedLocation - 1] == '\r')) { lineLength = lineFeedLocation - 1; } else { lineLength = lineFeedLocation; } TPtrC8 line = fileBuffer.Left(lineLength); TInt commentLocation = line.Match(KComment); if (commentLocation != KErrNotFound) { TPtrC8 skipComment = line.Left(commentLocation); line.Set(skipComment); } TInt seperatorLocation = line.Locate('='); if (seperatorLocation != KErrNotFound) { if ((seperatorLocation == 0) || (seperatorLocation == line.Length() - 1)) { seperatorLocation = KErrNotFound; } } if (seperatorLocation != KErrNotFound) { TPtrC8 namePtr = line.Left(seperatorLocation); HBufC8* nameBuf8 = HBufC8::NewL(namePtr.Length()); CleanupStack::PushL(nameBuf8); TPtr8 name8 = nameBuf8->Des(); name8.Copy(namePtr); name8.Trim(); HBufC* nameBuf16 = HBufC::NewL(namePtr.Length()); TPtr name16 = nameBuf16->Des(); name16.Copy(name8); iName.Append(nameBuf16); CleanupStack::PopAndDestroy(nameBuf8); TPtrC8 contentPtr = line.Mid(seperatorLocation + 1); HBufC8* contentBuf8 = HBufC8::NewL(contentPtr.Length()); CleanupStack::PushL(contentBuf8); TPtr8 content8 = contentBuf8->Des(); content8.Copy(contentPtr); content8.Trim(); HBufC* contentBuf16 = HBufC::NewL(contentPtr.Length()); TPtr content16 = contentBuf16->Des(); content16.Copy(content8); iContent.Append(contentBuf16); iContent8.Append(contentBuf8); CleanupStack::Pop(contentBuf8); } TPtrC8 theRest = fileBuffer.Mid(lineFeedLocation + 1); fileBuffer.Copy(theRest); } } } file.Close(); fileServerSession.Close(); }
TInt CReceiveStoredSms::SendSms(TBool aQuiet, RMobileSmsMessaging& aSms) /** * SendSms test. */ { if(!aQuiet) INFO_PRINTF1(_L("Sending SMS.")); // Create message PDU and convert to binary TBuf8<400> msgData; TLex8 lex; TUint8 val; TInt i; TInt ret; msgData.Zero(); const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_before;++i) { lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2); ret = lex.Val(val,EHex); if(ret) return ret; msgData.Append(TChar(val)); } TBuf8<20> targetAddressAscii; targetAddressAscii.Zero(); RMobilePhone::TMobileAddress targetAddress; targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber; targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan; targetAddress.iTelNumber.Copy(iTelNumber); ret = CATSmsUtils::AppendAddressToAscii(targetAddressAscii,targetAddress); if(ret) return ret; const TInt count_address(targetAddressAscii.Length()/2); // Assume length is always even for(i=0;i<count_address;++i) { lex=targetAddressAscii.Mid(i*2,2); ret = lex.Val(val,EHex); if(ret) return ret; msgData.Append(TChar(val)); } const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_after;++i) { lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2); ret = lex.Val(val,EHex); if(ret) return ret; msgData.Append(TChar(val)); } // Create message attibutes RMobileSmsMessaging::TMobileSmsSendAttributesV1 msgAttr; msgAttr.iFlags=0x184; msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan; msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber); // Package up data ready for sending to etel RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr); // Send the message, try upto 3 times if phone is not ready TRequestStatus status; INFO_PRINTF1(_L("..")); TSmsPdu smsPduSent; smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA)); aSms.SendMessage(status,smsPduSent,msgAttrPkg); User::WaitForRequest(status); if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) { INFO_PRINTF1(_L("..")); aSms.SendMessage(status,smsPduSent,msgAttrPkg); User::WaitForRequest(status); if(status==KErrGsmSMSFailureInME || status==KErrGeneral || status==KErrGsmSMSUnknownError) { INFO_PRINTF1(_L("..")); aSms.SendMessage(status,smsPduSent,msgAttrPkg); User::WaitForRequest(status); } } ret = status.Int(); if(ret) return ret; // Validate message reference number has changed if(!(msgAttr.iFlags&RMobileSmsMessaging::KMessageReference)) { return(KErrCorrupt); } if(!aQuiet) { INFO_PRINTF1(_L("test(s) passed")); } return(KErrNone); }
TVerdict CSendSmsAndCancel::doTestStepL( void ) { TInt i; TRequestStatus status; INFO_PRINTF1(_L("Sending SMS and cancelling.")); // Create message PDU and convert to binary _LIT8(KMsgDataBeforeTargetAddress,"1d00"); _LIT8(KMsgDataAfterTargetAddress,"01A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A001A0"); TBuf8<400> msgData; TLex8 lex; TUint8 val; msgData.Zero(); const TInt count_before((&KMsgDataBeforeTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_before;++i) { lex=(&KMsgDataBeforeTargetAddress)->Mid(i*2,2); TESTL(KErrNone == lex.Val(val,EHex)); msgData.Append(TChar(val)); } TBuf8<20> targetAddressAscii; targetAddressAscii.Zero(); RMobilePhone::TMobileAddress targetAddress; targetAddress.iTypeOfNumber=RMobilePhone::EInternationalNumber; targetAddress.iNumberPlan=RMobilePhone::EIsdnNumberPlan; targetAddress.iTelNumber.Copy(iTelNumber); TInt ret = CATSmsUtils::AppendAddressToAscii(targetAddressAscii,targetAddress); if(ret) return(EFail); const TInt count_address(targetAddressAscii.Length()/2); // Assume length is always even for(i=0;i<count_address;++i) { lex=targetAddressAscii.Mid(i*2,2); lex.Val(val,EHex); msgData.Append(TChar(val)); } const TInt count_after((&KMsgDataAfterTargetAddress)->Length()/2); // Assume length of pdu is always even for(i=0;i<count_after;++i) { lex=(&KMsgDataAfterTargetAddress)->Mid(i*2,2); lex.Val(val,EHex); msgData.Append(TChar(val)); } // Create message attibutes RMobileSmsMessaging::TMobileSmsSendAttributesV1 msgAttr; msgAttr.iFlags=0x184; msgAttr.iDataFormat=RMobileSmsMessaging::EFormatGsmTpdu; msgAttr.iGsmServiceCentre.iTypeOfNumber=RMobilePhone::EInternationalNumber; msgAttr.iGsmServiceCentre.iNumberPlan=RMobilePhone::EIsdnNumberPlan; msgAttr.iGsmServiceCentre.iTelNumber.Copy(iSCANumber); // Package up data ready for sending to etel RMobileSmsMessaging::TMobileSmsSendAttributesV1Pckg msgAttrPkg(msgAttr); // Send the message INFO_PRINTF1(_L("..")); TSmsPdu smsPduSent; smsPduSent.Copy(KTestSendPduA,sizeof(KTestSendPduA)); iSms.SendMessage(status,smsPduSent,msgAttrPkg); // Wait for a bit User::After(KOneSecond*2); // Cancel sending, then wait for sending operation to complete iSms.CancelAsyncRequest(EMobileSmsMessagingSendMessage); //if(status==KRequestPending) User::WaitForRequest(status); ret=KErrNone; if(status!=KErrCancel && status!=KErrNone) ret=status.Int(); else INFO_PRINTF1(_L("TESTL(s) passed")); // If we don't cause a panic or leave the test has passed /* iSms.Close(); iPhone->Close(); User::After(500000L); iPhone.Open(iTelServer,GSM_NAME); iSms.Open(iPhone); */ return TestStepResult(); }