// From MTest: void CTestCase::ExecuteL (TTestResult& aResult) { TInt error = ExecuteImplL(); aResult.iResult = error; // add the possible failure or error to the result if (error == KErrCppUnitAssertionFailed) { CAssertFailure* assertFailure = AssertFailureFromTlsL (); CleanupStack::PushL(assertFailure); TBuf16 <0x80> convertBuf; TBuf16 <256> temporaryBuf; convertBuf.Copy(assertFailure->What()); temporaryBuf.Append(convertBuf); temporaryBuf.AppendFormat(_L(" at Line %i of "), assertFailure->LineNumber()); convertBuf.Copy(assertFailure->FileName()); if (convertBuf.Length() + temporaryBuf.Length() >= 0x80) { TBuf <0x80> printBuf; printBuf = convertBuf.Right(0x80 - temporaryBuf.Length() - 1 -3 ); convertBuf = _L("..."); convertBuf.Append(printBuf); } temporaryBuf.Append(convertBuf); aResult.iResultDes = temporaryBuf; CleanupStack::PopAndDestroy(assertFailure); } }
void CAknEcsNote::SetEmergencyNumber( const TDesC& aMatchedNumber ) { TRect screen(iAvkonAppUi->ApplicationRect()); TAknLayoutRect mainPane; mainPane.LayoutRect(screen, AKN_LAYOUT_WINDOW_main_pane(screen, 0, 1, 1)); TAknLayoutRect popupNoteWindow; AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() ); TInt variety( 0 ); if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) { variety = 5; } else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) { variety = 8; } else { variety = 2; } popupNoteWindow.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::popup_note_window( variety )); TAknLayoutText textRect; textRect.LayoutText(popupNoteWindow.Rect(), AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(4)); // Size of a temporary buffer that contains new lines, spaces and // emergency number for a note. TBuf16<KAknEcsMaxMatchingLength+80> number; number.Append('\n'); number.Append('\n'); TInt spaceCharWidthInPixels = textRect.Font()->CharWidthInPixels(' '); if (spaceCharWidthInPixels < 1) { // Avoid divide by zero situation even the space char would have zero length. spaceCharWidthInPixels = 1; } TInt length = (textRect.TextRect().Width() - textRect.Font()->TextWidthInPixels(aMatchedNumber)) / spaceCharWidthInPixels; const TInt matchedNumberLength = aMatchedNumber.Length(); const TInt numberLength = number.Length(); const TInt numberMaxLength = number.MaxLength(); if ( numberLength + length + matchedNumberLength > numberMaxLength) { // To make sure that buffer overflow does not happen. length = numberMaxLength - numberLength - matchedNumberLength; } for (int i = 0; i < length ; i++) { number.Append(' '); } number.Append(aMatchedNumber); TRAP_IGNORE(SetTextL(number)); }
void CMobilePhone::RunL(void) { TBuf16<128> string; if(iStatus==KErrNone) { string.Append(_L("Success.")); } else { string.Append(_L("Error (")); string.AppendNum(iStatus.Int()); string.Append(_L(").")); } ShowResult(string); }
void CT_ISO2022JP1_2::TestSplittingConvertingFromUnicodeToIso2022Jp( CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, const TDesC8& aExpectedFirstPartOfIso2022Jp, const TDesC8& aExpectedSecondPartOfIso2022Jp, const TDesC16& aOriginalUnicode) { INFO_PRINTF1(_L(" TestTruncatedConversionFromUnicodeToIso2022Jp ")); test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit); test(aMaximumLengthUpperLimit<=KBufferLength); TUint8 iso2022JpBuffer[KBufferLength]; for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i) { TPtr8 generatedFirstPartOfIso2022Jp(iso2022JpBuffer, i); test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfIso2022Jp, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit); test(generatedFirstPartOfIso2022Jp==aExpectedFirstPartOfIso2022Jp); TBuf8<KBufferLength> generatedSecondPartOfIso2022Jp; test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfIso2022Jp, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0); test(generatedSecondPartOfIso2022Jp==aExpectedSecondPartOfIso2022Jp); TInt state=CCnvCharacterSetConverter::KStateDefault; TBuf16<KBufferLength> generatedUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfIso2022Jp, state)==0); TBuf16<KBufferLength> generatedSecondPartOfUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfIso2022Jp, state)==0); generatedUnicode.Append(generatedSecondPartOfUnicode); test(generatedUnicode==aOriginalUnicode); } }
/** @SYMTestCaseID SYSLIB-CHARCONV-CT-0536 @SYMTestCaseDesc Splitting and converting from Unicode to EucJpPacked test @SYMTestPriority Medium @SYMTestActions Tests for conversion after splitting, from Unicode to EucJpPacked and back to Unicode @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ void CT_EUCJP_PACKED_2::TestSplittingConvertingFromUnicodeToEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, TInt aMaximumLengthLowerLimit, TInt aMaximumLengthUpperLimit, TInt aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit, TInt aExpectedLengthOfFirstPartOfEucJpPacked, const TDesC8& aExpectedEucJpPacked, const TDesC16& aOriginalUnicode) { INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0536 ")); test(aMaximumLengthLowerLimit<=aMaximumLengthUpperLimit); test(aMaximumLengthUpperLimit<=KBufferLength); TUint8 eucJpPackedBuffer[KBufferLength]; for (TInt i=aMaximumLengthLowerLimit; i<=aMaximumLengthUpperLimit; ++i) { TPtr8 generatedFirstPartOfEucJpPacked(eucJpPackedBuffer, i); test(aCharacterSetConverter.ConvertFromUnicode(generatedFirstPartOfEucJpPacked, aOriginalUnicode)==aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit); test(generatedFirstPartOfEucJpPacked==aExpectedEucJpPacked.Left(aExpectedLengthOfFirstPartOfEucJpPacked)); TBuf8<KBufferLength> generatedSecondPartOfEucJpPacked; test(aCharacterSetConverter.ConvertFromUnicode(generatedSecondPartOfEucJpPacked, aOriginalUnicode.Right(aExpectedNumberOfUnicodeCharactersNotConvertedAtSplit))==0); test(generatedSecondPartOfEucJpPacked==aExpectedEucJpPacked.Mid(aExpectedLengthOfFirstPartOfEucJpPacked)); TInt state=CCnvCharacterSetConverter::KStateDefault; TBuf16<KBufferLength> generatedUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedUnicode, generatedFirstPartOfEucJpPacked, state)==0); test(state==CCnvCharacterSetConverter::KStateDefault); TBuf16<KBufferLength> generatedSecondPartOfUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedSecondPartOfUnicode, generatedSecondPartOfEucJpPacked, state)==0); test(state==CCnvCharacterSetConverter::KStateDefault); generatedUnicode.Append(generatedSecondPartOfUnicode); test(generatedUnicode==aOriginalUnicode); } }
TBool CTe_LbsIniFileReader::SetNextPoint() { iIndex++; TBuf16<128> findText; findText.Zero(); findText.Append(_L("[")); findText.AppendNum(iIndex); findText.Append(_L("]")); iPoint = iPtr.Find(findText); if (iPoint == KErrNotFound) { return(EFalse); } return(ETrue); }
/** Tests the creation of a directory with 2 threads accessing different directories (the current and one with 300 files) @param aSelector Configuration in case of manual execution */ LOCAL_C TInt TestMakeMultDif(TAny* aSelector) { TInt i = 100; TBuf16<50> directory; TBuf16<50> dirtemp; TInt testStep; Validate(aSelector); CreateDirWithNFiles(300,3); directory = gSessionPath; dirtemp.Format(KDirMultipleName2, 3, 300); directory.Append(dirtemp); gDelEntryDir2 = directory; test.Printf(_L("#~TS_Title_%d,%d: MkDir with mult clients accessing dif dirs, RFs::MkDir\n"), gTestHarness, gTestCase); i = 100; testStep = 1; while(i <= KMaxFiles) { if(i == 100 || i == 1000 || i == 5000 || i == 10000) { directory = gSessionPath; dirtemp.Format(KDirMultipleName2, 2, i); directory.Append(dirtemp); gDelEntryDir = directory; DoTest2(DeleteEntryAccess); MakeDir(i, testStep++); DoTestKill(); } i += 100; } gTestCase++; return(KErrNone); }
/** Delete content of directory @param aDir Target directory @return Error returned if any, otherwise KErrNone */ TInt DeleteAll(TDes16& aDir) { TBuf16<100> dir; CFileMan* fMan=CFileMan::NewL(TheFs); TInt r=0; dir = aDir; dir.Append(_L("F*.*")); r = fMan->Delete(dir); delete fMan; return r; }
/** @SYMTestCaseID SYSLIB-CHARCONV-CT-0537 @SYMTestCaseDesc Tests for truncated conversion from EucJpPacked to Unicode @SYMTestPriority Medium @SYMTestActions Tests for truncated conversion from EucJpPacked to Unicode and back to EucJpPacked @SYMTestExpectedResults Test must not fail @SYMREQ REQ0000 */ void CT_EUCJP_PACKED_2::TestTruncatedConversionToUnicodeFromEucJpPacked(CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalEucJpPacked) { INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-CHARCONV-CT-0537 ")); for (TInt i=aOriginalEucJpPacked.Length(); i>=3; --i) // 3 is the length of GBK's longest multi-byte characters { TInt state=CCnvCharacterSetConverter::KStateDefault; TBuf16<KBufferLength> generatedUnicode; const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalEucJpPacked.Left(i), state); test(returnValue>=0); TBuf16<KBufferLength> generatedsecondPartOfUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalEucJpPacked.Mid(i-returnValue), state)==0); generatedUnicode.Append(generatedsecondPartOfUnicode); test(generatedUnicode==aExpectedUnicode); } }
void CDebugLogPrint::WriteToLog8L(const TDesC8 &aDes, const TDesC8 &aDes2) { TBuf16<256> buf; TInt pos=aDes.LocateReverse(' '); if (pos<0) pos=0; buf.Copy(aDes.Mid(pos)); buf.Append(' '); TInt bufLen=buf.Length(); TPtr16 ptr(&buf[bufLen],buf.MaxLength()-bufLen); ptr.Copy(aDes2); buf.SetLength(bufLen+aDes2.Length()); _LIT(KDebugFormatString, "%S"); RDebug::Print(KDebugFormatString, &buf); }
void CT_ISO2022JP1_2::TestTruncatedConversionToUnicodeFromIso2022Jp( CCnvCharacterSetConverter& aCharacterSetConverter, const TDesC16& aExpectedUnicode, const TDesC8& aOriginalIso2022Jp) { INFO_PRINTF1(_L(" TestTruncatedConversionToUnicodeFromIso2022Jp ")); for (TInt i=aOriginalIso2022Jp.Length(); i>=3; --i) // 3 is the length of ISO-2022-JP's longest escape sequence { TInt state=CCnvCharacterSetConverter::KStateDefault; TBuf16<KBufferLength> generatedUnicode; const TInt returnValue=aCharacterSetConverter.ConvertToUnicode(generatedUnicode, aOriginalIso2022Jp.Left(i), state); test(returnValue>=0); TBuf16<KBufferLength> generatedsecondPartOfUnicode; test(aCharacterSetConverter.ConvertToUnicode(generatedsecondPartOfUnicode, aOriginalIso2022Jp.Mid(i-returnValue), state)==0); generatedUnicode.Append(generatedsecondPartOfUnicode); test(generatedUnicode==aExpectedUnicode); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- // void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) { switch ( aCommand ) { case EAknSoftkeyExit: case EEikCmdExit: Exit(); break; case ECmdSwitchOutput: { HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); TBool last = ETrue; bufferPtr.Append(_L("Output switched to ")); iFileOutputOn = !iFileOutputOn; if (iFileOutputOn) bufferPtr.Append(_L("file.")); else bufferPtr.Append(_L("screen.")); ShowL( *buffer, last ); CleanupStack::PopAndDestroy( buffer ); } break; case ECmdStatus: { ClearL(); // layout HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); TBool last = ETrue; // Orientation bufferPtr.Append(_L("Orientation: ")); bufferPtr.AppendNum((TInt)iAvkonAppUi->Orientation()); ShowL( *buffer, last ); bufferPtr.Zero(); // Output bufferPtr.Append(_L("Output: ")); if (iFileOutputOn) bufferPtr.Append(_L("File")); else bufferPtr.Append(_L("Screen")); ShowL( *buffer, last ); bufferPtr.Zero(); CAknLayoutConfig::TScreenMode localAppScreenMode = CAknSgcClient::ScreenMode(); TInt hashValue = localAppScreenMode.ScreenStyleHash(); TPixelsTwipsAndRotation pixels = CAknSgcClient::PixelsAndRotation(); TSize pixelSize = pixels.iPixelSize; bufferPtr.Append(_L("LayoutName: ")); if ( (pixelSize.iWidth == 320 || pixelSize.iWidth == 240 )&& (pixelSize.iHeight == 320 || pixelSize.iHeight == 240 )) { if (hashValue==0x996F7AA7) bufferPtr.Append(_L("QVGA2")); else bufferPtr.Append(_L("QVGA1")); } else if ((pixelSize.iWidth == 640 || pixelSize.iWidth == 360 )&& (pixelSize.iHeight == 360 || pixelSize.iHeight == 640 )) { bufferPtr.Append(_L("nHD")); } else if ((pixelSize.iWidth == 640 || pixelSize.iWidth == 480 )&& (pixelSize.iHeight == 480 || pixelSize.iHeight == 640 )) { bufferPtr.Append(_L("VGA")); } else if ((pixelSize.iWidth == 352 || pixelSize.iWidth == 800 )&& (pixelSize.iHeight == 800 || pixelSize.iHeight == 352 )) { bufferPtr.Append(_L("E90")); } else if ((pixelSize.iWidth == 320 || pixelSize.iWidth == 480 || pixelSize.iWidth == 240 || pixelSize.iWidth == 640 )&& (pixelSize.iHeight == 320 || pixelSize.iHeight == 480 || pixelSize.iHeight == 240 || pixelSize.iHeight == 640)) { bufferPtr.Append(_L("HVGA")); } else if ((pixelSize.iWidth == 480 || pixelSize.iWidth == 854 || pixelSize.iWidth == 848 || pixelSize.iWidth == 800 )&& (pixelSize.iHeight == 800 || pixelSize.iHeight == 480 || pixelSize.iHeight == 848 || pixelSize.iHeight == 854)) { bufferPtr.Append(_L("WVGA")); } else { bufferPtr.Append(_L("Unknown")); } ShowL( *buffer, last ); bufferPtr.Zero(); CleanupStack::PopAndDestroy( buffer ); } break; case ECmdSwitchOrientation: { ClearL(); HBufC* buffer = HBufC::NewLC( 100 ); TPtr bufferPtr = buffer->Des(); TBool last = ETrue; #ifndef __SERIES60_31__ if (!iAvkonAppUi->OrientationCanBeChanged()) { bufferPtr.Append(_L("Orientation cannot be changed.")); ShowL( *buffer, last ); bufferPtr.Zero(); CleanupStack::PopAndDestroy( buffer ); break; } #endif //__SERIES60_31__ if ( iAvkonAppUi->Orientation() == CAknAppUiBase::EAppUiOrientationPortrait) { iAvkonAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape); } else if (iAvkonAppUi->Orientation() == CAknAppUiBase::EAppUiOrientationLandscape) { iAvkonAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationPortrait); } else { // unspecified iAvkonAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape); } bufferPtr.Append(_L("Orientation changed.")); ShowL( *buffer, last ); bufferPtr.Zero(); CleanupStack::PopAndDestroy( buffer ); break; } case ECmdStartCalculations: { ClearL(); // Get known values TInt index = 0; TBool last = EFalse; if (iFileOutputOn) { TRect screenRect; AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, screenRect ); // Add screen dimensions TInt height = screenRect.Height(); TInt width = screenRect.Width(); TBuf16<32> tgt; // HEIGHT tgt.Append(_L("height: \t")); tgt.AppendNum(height, EDecimal); // put max height into text file ShowL( tgt, last ); tgt.Zero(); // WIDTH tgt.Append(_L("width: \t")); tgt.AppendNum(width, EDecimal); // put max width into text file ShowL( tgt, last ); tgt.Zero(); // VERSION TPixelMetricsVersion version = PixelMetrics::Version(); tgt.Append(_L("major_version: \t")); tgt.AppendNum(version.majorVersion, EDecimal); // put major version into text file ShowL( tgt, last ); tgt.Zero(); tgt.Append(_L("minor_version: \t")); tgt.AppendNum(version.minorVersion, EDecimal); // put minor version into text file ShowL( tgt, last ); tgt.Zero(); } TInt myValue = KErrNotFound; for (;;) { if (index==QStyle::PM_Custom_MessageBoxHeight) { last = ETrue; } myValue = PixelMetrics::PixelMetricValue(static_cast<QStyle::PixelMetric>(index)); ShowSingleValueL( index, myValue, last ); if (last) break; // if last before custom values, "jump" to custom base if (index==QStyle::PM_SubMenuOverlap) index = QStyle::PM_CustomBase; index++; } } break; case ECmdCreateHeaderFile: CreateHeaderFileL(); break; default: break; } }
/** Find last.txt with TFindFile and with two threads accessing the 2 directories @param aN Number of files in the directory @param aWild Wildcard string to be used in the search @param aStep Test step */ LOCAL_C void FindFileWild3(TInt aN, const TDesC& aWild, TInt aStep) { TBuf16<100> dir1; TBuf16<100> dir2; TBuf16<100> dir3; TBuf16<100> dir4; TBuf16<100> temp; TBuf16<100> temp2; TInt r = 0; TFindFile find(TheFs); TTime startTime; TTime endTime; TTimeIntervalMicroSeconds timeTaken(0); TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; CDir* dir; if(aN <= gFilesLimit) { dir1 = gSessionPath; dir2 = gSessionPath; dir3 = gSessionPath; dir4.Format(KDirMultipleName2, 1, aN); dir1.Append(dir4); temp=gSessionPath; dir4.Format(KDirMultipleName, 3, 300); temp.Append(dir4); gFindDir = dir1; gFindDir2 = temp; temp2 = gFindDir; temp2.Append(KCommonFile); gFindEntryDir = temp2; temp2 = gFindDir2; temp2.Append(KCommonFile); gFindEntryDir2 = temp2; if(gTypes >= 1) { DoTest2(FindEntryAccess); dir4.Format(KDirMultipleName, 1, aN); startTime.HomeTime(); r = find.FindWildByPath(aWild, &dir1, dir); FailIfError(r); endTime.HomeTime(); DoTestKill(); delete dir; timeTaken = endTime.MicroSecondsFrom(startTime); timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit); } if(gTypes >= 2) { dir4.Format(KDirMultipleName2, 2, aN); dir2.Append(dir4); temp = dir2; temp.Append(KCommonFile); gFindDir = dir2; gFindEntryDir = temp; DoTest2(FindEntryAccess); startTime.HomeTime(); r = find.FindWildByPath(aWild, &dir2, dir); FailIfError(r); endTime.HomeTime(); DoTestKill(); delete dir; timeTaken = endTime.MicroSecondsFrom(startTime); timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit); } if(gTypes >= 3) { dir4.Format(KDirMultipleName2, 3, aN); dir3.Append(dir4); temp = dir3; temp.Append(KCommonFile); gFindDir = dir3; gFindEntryDir = temp; DoTest2(FindEntryAccess); startTime.HomeTime(); r = find.FindWildByPath(aWild, &dir3, dir); FailIfError(r); endTime.HomeTime(); DoTestKill(); delete dir; timeTaken = endTime.MicroSecondsFrom(startTime); timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit); } } PrintResult(aStep, 1, aN); PrintResultTime(aStep, 2, timeTaken1); PrintResultTime(aStep, 3, timeTaken2); PrintResultTime(aStep, 4, timeTaken3); }
// ----------------------------------------------------------------------------- // CSatNotifyCloseChannel::TerminalResponseL // Called by ETel server, passes terminal response to DOS // ----------------------------------------------------------------------------- // TInt CSatNotifyCloseChannel::TerminalResponseL ( TDes8* aRsp ) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_TERMINALRESPONSEL_1, "CSAT: CSatNotifyCloseChannel::TerminalResponseL"); TInt ret( KErrNone ); TBuf16<1> additionalInfo; RSat::TCloseChannelRspV2Pckg* aRspPckg = reinterpret_cast<RSat::TCloseChannelRspV2Pckg*>( aRsp ); RSat::TCloseChannelRspV2& rspV2 = ( *aRspPckg ) (); TUint8 pCmdNumber( rspV2.PCmdNumber() ); // Check that general result value is valid if ( ( RSat::KSuccess != rspV2.iGeneralResult ) && ( RSat::KPartialComprehension != rspV2.iGeneralResult ) && ( RSat::KMissingInformation != rspV2.iGeneralResult ) && ( RSat::KSuccessRequestedIconNotDisplayed != rspV2.iGeneralResult ) && ( RSat::KPSessionTerminatedByUser != rspV2.iGeneralResult ) && ( RSat::KMeUnableToProcessCmd != rspV2.iGeneralResult ) && ( RSat::KCmdBeyondMeCapabilities != rspV2.iGeneralResult ) && ( RSat::KCmdTypeNotUnderstood != rspV2.iGeneralResult ) && ( RSat::KCmdDataNotUnderstood != rspV2.iGeneralResult ) && ( RSat::KCmdNumberNotKnown != rspV2.iGeneralResult ) && ( RSat::KErrorRequiredValuesMissing != rspV2.iGeneralResult ) && ( RSat::KBearerIndepProtocolError != rspV2.iGeneralResult ) && ( RSat::KFramesError != rspV2.iGeneralResult )) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_TERMINALRESPONSEL_2, "CSAT: CSatNotifyCloseChannel::TerminalResponseL Invalid General Result"); // Invalid general result ret = KErrCorrupt; } if ( RSat::KMeProblem == rspV2.iInfoType ) { if ( rspV2.iAdditionalInfo.Length() ) { additionalInfo.Append( rspV2.iAdditionalInfo[0] ); } else { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_TERMINALRESPONSEL_3, "CSAT: CSatNotifyCloseChannel::TerminalResponseL Invalid Additional Info"); ret = KErrCorrupt; } } else if (RSat::KNoAdditionalInfo == rspV2.iInfoType ) { // do nothing } else { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_TERMINALRESPONSEL_4, "CSAT: CSatNotifyCloseChannel::TerminalResponseL Invalid Additional Info type"); ret = KErrCorrupt; } TInt response = CreateTerminalRespL( pCmdNumber, static_cast<TUint8>( rspV2.iGeneralResult ), additionalInfo ); if ( KErrNone == ret ) ret = response; return ret; }
// ----------------------------------------------------------------------------- // CSatNotifyCloseChannel::CompleteNotifyL // This method completes an outstanding asynchronous // NotifyCloseChannel request. // ----------------------------------------------------------------------------- // TInt CSatNotifyCloseChannel::CompleteNotifyL ( CSatDataPackage* aDataPackage, TInt aErrorCode ) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_COMPLETENOTIFYL_1, "CSAT: CSatNotifyCloseChannel::CompleteNotifyL"); TInt ret( KErrNone ); // Unpack parameters TPtrC8* data; aDataPackage->UnPackData( &data ); // Reset req handle. Returns the deleted req handle TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> ResetTsyReqHandle( CSatTsy::ESatNotifyCloseChannelPCmdReqType ); // Get ber tlv CBerTlv berTlv; berTlv.SetData( *data ); // Get command details tlv CTlv commandDetails; berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag ); // Store command details tlv iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( commandDetails.Data() ); TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) ); // In case the request was ongoing, continue.. if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) { // Complete right away if error has occured, otherwise continue.. if ( KErrNone == aErrorCode ) { // Fill the Close Channel structure RSat::TCloseChannelV2& closeChannelV2 = ( *iCloseChannelRspV2Pckg )(); // Store transaction ID closeChannelV2.SetPCmdNumber( pCmdNumber ); // Store Channel Id CTlv deviceIds; TInt returnValue( berTlv.TlvByTagValue( &deviceIds, KTlvDeviceIdentityTag ) ); if ( KErrNone == returnValue ) { closeChannelV2.iDestination = (RSat::TDeviceId) deviceIds. GetShortInfo( ETLV_DestinationDeviceIdentity ); // Alpha Id (Optional) CTlv alphaIdentifier; returnValue = berTlv.TlvByTagValue( &alphaIdentifier, KTlvAlphaIdentifierTag ) ; closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNotPresent; if ( KErrNotFound != returnValue ) { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_COMPLETENOTIFYL_2, "CSAT: CSatNotifyCloseChannel::CompleteNotifyL Alpha ID present"); TUint16 alphaIdLength = alphaIdentifier.GetLength(); if ( alphaIdLength ) { // Get the alpha id TPtrC8 sourceString; sourceString.Set( alphaIdentifier.GetData( ETLV_AlphaIdentifier ) ); // convert and set the alpha id TSatUtility::SetAlphaId( sourceString , closeChannelV2.iAlphaId.iAlphaId ); } // Set Alpha ID status if ( closeChannelV2.iAlphaId.iAlphaId.Length() ) { closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdProvided; } else { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_COMPLETENOTIFYL_3, "CSAT: CSatNotifyCloseChannel::CompleteNotifyL Alpha ID is NULL"); closeChannelV2.iAlphaId.iStatus = RSat::EAlphaIdNull; } } // Icon Id (Optional) TSatUtility::FillIconStructure( berTlv, closeChannelV2.iIconId ); } // if ( KErrNone == returnValue ) else { // Required values missing OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_COMPLETENOTIFYL_4, "CSAT: CSatNotifyCloseChannel::CompleteNotifyL, required values missing (Device Identities)"); ret = KErrCorrupt; CreateTerminalRespL( pCmdNumber, RSat::KErrorRequiredValuesMissing, KNullDesC16 ); } } // if ( KErrNone == aErrorCode ) else { ret = aErrorCode; } // Complete request iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret ); } else { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSATNOTIFYCLOSECHANNEL_COMPLETENOTIFYL_5, "CSAT: CSatNotifyCloseChannel::CompleteNotifyL Request not ongoing"); // Request not on, returning response immediately TBuf16<1> additionalInfo; additionalInfo.Append ( RSat::KNoSpecificMeProblem ); CreateTerminalRespL( pCmdNumber,RSat::KMeUnableToProcessCmd, additionalInfo ); ret = KErrCorrupt; } return ret; }
/** Main tests function */ void CallTestsL() { TBuf16<45> dir; TInt r = 0; #if defined(_DEBUG) || defined(_DEBUG_RELEASE) test.Printf(_L("Disabling Lock Fail simulation ...\n")); // turn OFF lock failure mode (if cache is enabled) TBool simulatelockFailureMode = EFalse; r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); test_Value(r, r == KErrNone || r == KErrNotSupported); #endif // FileNames/File generation test.Start(_L("Preparing the environment\n")); FileNameGen(gSmallFile, 8, gNextFile++); FileNameGen(gBigFile, 8, gNextFile++); dir = gSessionPath; dir.Append(gSmallFile); gSmallFile = dir; dir = gSessionPath; dir.Append(gBigFile); gBigFile = dir; TRAPD(res,gBuf = HBufC8::NewL(KBigBlockSize)); TEST(res == KErrNone && gBuf != NULL); gBufWritePtr.Set(gBuf->Des()); FillBuffer(gBufWritePtr, KBigBlockSize, 'B'); TRAPD(res2, gBufSec = HBufC8::NewL(KBlockSize)); TEST(res2 == KErrNone && gBufSec != NULL); gBufReadPtr.Set(gBufSec->Des()); test.Next(_L("Benchmarking\n")); TimeTakenToWriteBigFile(0); TimeTakenToWriteBigFileAsync(0); test.Printf(_L("second try, second timings account for the last comparison\n")); TimeTakenToWriteBigFile(0); TimeTakenToWriteBigFileAsync(0); TimeTakenToWriteBigBlock(); test.Next(_L("Big file sync written, small file read from the media at the same time\n")); TestReadingWhileWriting(); test.Next(_L("Big file written, small file written at the same time\n")); TestWritingWhileWriting(); test.Next(_L("Big file written async, deletion in the meantime\n")); TestDeletionWhileWriting(); test.Next(_L("Two big files written at the same time\n")); TestTwoBigOnes(); test.Next(_L("Big file being written, start reading\n")); TestReadingWhileWritingSameFile(); test.Next(_L("Client dying unexpectedly\n")); TestClientDies(); test.Next(_L("Ensure write order is preserved\n")); TestWriteOrder(); // Format the drive to make sure no blocks are left to be erased in LFFS if (!Is_Win32(TheFs, gDrive)) Format(gDrive); r = TheFs.MkDirAll(gSessionPath); TimeTakenToWriteBigFile(1); TimeTakenToWriteBigFileAsync(1); // Make sure that the difference between the first time and the last time the files are written doesn't // differ more than 3% test.Printf(_L("Abs(gTotalTimeSync[0]-gTotalTimeSync[1]) :%d\n"), Abs(gTotalTimeSync[0]-gTotalTimeSync[1])); test.Printf(_L("Abs(gTotalTimeAsync[0]-gTotalTimeAsync[1]) :%d\n"), Abs(gTotalTimeAsync[0]-gTotalTimeAsync[1])); test.Printf(_L("gTotalTimeSync[0] :%d\n"), gTotalTimeSync[0]); test.Printf(_L("gTotalTimeAsync[0] :%d\n"), gTotalTimeAsync[0]); #if !defined(__WINS__) test((Abs(gTotalTimeSync[0]-gTotalTimeSync[1])/gTotalTimeSync[0]) < 0.03); test((Abs(gTotalTimeAsync[0]-gTotalTimeAsync[1])/gTotalTimeAsync[0]) < 0.03); #endif r = DeleteAll(gSessionPath); TESTERROR(r); delete gBuf; delete gBufSec; #if defined(_DEBUG) || defined(_DEBUG_RELEASE) // turn lock failure mode back ON (if cache is enabled) simulatelockFailureMode = ETrue; r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); test_Value(r, r == KErrNone || r == KErrNotSupported); #endif test.End(); }
// this function was copied from t_sdpartition.cpp TInt FindMmcLocalDriveNumber(TChar aDriveChar, TInt& aLocalDriveNum, TInt aDriveNum) { TInt r = fs.CharToDrive(aDriveChar, aDriveNum); test(r==KErrNone); TDriveInfo driveInfo; r = fs.Drive(driveInfo, aDriveNum); test(r==KErrNone); TVolumeInfo vi; r = fs.Volume(vi, aDriveNum); test(r==KErrNone); TMediaSerialNumber serialNum; r = fs.GetMediaSerialNumber(serialNum, aDriveNum); test(r==KErrNone); test.Printf(_L("Drive %C size %ld\n"), (char) aDriveChar, vi.iSize); TInt len = serialNum.Length(); test.Printf(_L("Serial number (len %d) :"), len); TInt n; for (n=0; n<len; n+=16) { TBuf16<16*3 +1> buf; for (TInt m=n; m<n+16; m++) { TBuf16<3> hexBuf; hexBuf.Format(_L("%02X "),serialNum[m]); buf.Append(hexBuf); } buf.Append(_L("\n")); test.Printf(buf); } TBusLocalDrive drv; TBool chg(EFalse); aLocalDriveNum = -1; TInt serialNumbersMatched = 0; for (n=0; n<KMaxLocalDrives; n++) { r = drv.Connect(n, chg); //for user area //RDebug::Print(_L("TBusLocalDrive::Connect(%d) %d"), n, r); if(r != KErrNone) { test.Printf(_L("drive %d: TBusLocalDrive::Connect() failed %d\n"), n, r); continue; } TLocalDriveCapsV5Buf capsBuf; TLocalDriveCapsV5& caps = capsBuf(); r = drv.Caps(capsBuf); if(r != KErrNone) { test.Printf(_L("drive %d: TBusLocalDrive::Caps() failed %d\n"), n, r); continue; } //RDebug::Print(_L("areaSize %ld cardCapacity %ld"), caps.iSize, caps.iFormatInfo.iCapacity); TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength); if (serialNum.Compare(localSerialNum) == 0) { serialNumbersMatched++; TBool sizeMatch = (vi.iSize < caps.iSize); test.Printf(_L("drive %d: Serial number match, size match: %S\n"), n, sizeMatch?&KYes:&KNo); if (sizeMatch) { aLocalDriveNum = n; drv.Disconnect(); break; } } drv.Disconnect(); } return aLocalDriveNum == -1?KErrNotFound:KErrNone; }
EXPORT_C void CIpuTestHarness::GetAnEntry(const TDesC& ourPrompt, TDes& currentstring) // // Get an input string from the user, displaying a supplied prompt and default string value { // If we're scripting, try reading from script first TInt readScriptErr = KErrNotFound; if (iScriptRunning) { readScriptErr = ReadLineFromScript(currentstring); } if (!readScriptErr) return; // Either not scripting, or hit end of script - continue with user input TBuf16<KMaxUserEntrySize> ourLine; TBuf<KMaxUserEntrySize> tempstring; //tempstring is a unicode descriptor //create a temporary buffer where the //unicode strings are stored in order to //be displayed ourLine.Zero (); tempstring.Copy(currentstring); //Copy current string to Unicode buffer TKeyCode key = EKeyNull; //current string buffer is 8 bits wide. //Unicode string bufffer (tempstring) is 16 bits wide. for (;;) { if (ourLine.Length () == 0) { iTest.Console()->SetPos (0, iTest.Console()->WhereY ()); iTest.Console()->Printf (_L ("%S"), &ourPrompt); if (tempstring.Length () != 0) //get tempstring's number of items iTest.Console()->Printf (_L (" = %S"), &tempstring); //if not zero print them to iTest.Console() iTest.Console()->Printf (_L (" : ")); iTest.Console()->ClearToEndOfLine (); } key = iTest.Getch(); if (key == EKeyBackspace) { if (ourLine.Length() !=0) { ourLine.SetLength(ourLine.Length()-1); iTest.Console()->Printf (_L ("%c"), key); iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY()); iTest.Console()->ClearToEndOfLine(); } // end if (ourLine.Length() !=0) } // end if (key == KeyBackSpace) if (key == EKeyDelete) { ourLine.Zero(); iTest.Console()->SetPos (0, iTest.Console()->WhereY ()); iTest.Console()->ClearToEndOfLine (); tempstring.Copy(ourLine); break; } if (key == EKeyEnter) break; if (key < 32) { continue; } ourLine.Append (key); iTest.Console()->Printf (_L ("%c"), key); iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY()); iTest.Console()->ClearToEndOfLine(); if (ourLine.Length () == ourLine.MaxLength ()) break; } // end of for statement if ((key == EKeyEnter) && (ourLine.Length () == 0)) tempstring.Copy (currentstring); //copy contents of 8 bit "ourLine" descriptor iTest.Console()->SetPos (0, iTest.Console()->WhereY ()); iTest.Console()->ClearToEndOfLine (); iTest.Console()->Printf (_L ("%S"), &ourPrompt); if ((key == EKeyEnter) && (ourLine.Length() !=0)) tempstring.Copy(ourLine); if (tempstring.Length () != 0) //if temstring length is not zero { iTest.Console()->Printf (_L (" = %S\n"), &tempstring); //print the contents to iTest.Console() LogIt(_L ("%S = %S\n"), &ourPrompt, &tempstring); } else //iTest.Console()->Printf (_L (" is empty")); iTest.Console()->Printf (_L ("\n")); currentstring.Copy(tempstring); //copy 16 bit tempstring descriptor back }