// ----------------------------------------------------------------------------- // CCLFDefaultOperation::SortItemsL // ----------------------------------------------------------------------------- // void CCLFDefaultOperation::SortItemsL( RPointerArray<MCLFItem>& aItemArray ) { if( iSortingStyle ) { RPointerArray<MCLFItem> array; CleanupClosePushL( array ); RPointerArray<MCLFItem> array1; CleanupClosePushL( array1 ); RPointerArray<MCLFItem>* undefinedItemArray = &array; RPointerArray<MCLFItem>* newUndefinedItemArray = &array1; SortItemsBySortingStyleL( aItemArray, *iSortingStyle, *undefinedItemArray ); TInt lastAddedItemCount( aItemArray.Count() ); TInt nextItemIndex( lastAddedItemCount ); TCLFUndefinedItemPosition position( iSortingStyle->UndefinedItemPosition() ); const TInt secondarySorterCount( iSortingStyleArray.Count() ); for( TInt i = 0 ; i < secondarySorterCount ; ++i ) { MCLFSortingStyle& sortingStyle = *iSortingStyleArray[i]; newUndefinedItemArray->Reset(); // sort undefined items SortItemsBySortingStyleL( *undefinedItemArray, sortingStyle, *newUndefinedItemArray ); // append sorted items to aItemArray AppendItemsToArrayL( undefinedItemArray->Array(), aItemArray, position, nextItemIndex, lastAddedItemCount ); position = sortingStyle.UndefinedItemPosition(); // change pointers RPointerArray<MCLFItem>* tmp = undefinedItemArray; undefinedItemArray = newUndefinedItemArray; newUndefinedItemArray = tmp; } // copy rest undefined items to correct position AppendItemsToArrayL( undefinedItemArray->Array(), aItemArray, position, nextItemIndex, lastAddedItemCount ); // close undefined arrays CleanupStack::PopAndDestroy( 2, &array ); } // else no sorting }
void CCmdTestMultipleWait::doTestNewLWithBadDataL() { RPointerArray<MSsmCommand> emptyDeferredList; TArray<MSsmCommand*> testDeferredList = emptyDeferredList.Array(); TInt err = KErrNone; // If empty deferred list is passed then command should return KErrNone TInt expectedErr = KErrNone; TInt32 timeout = 10000; INFO_PRINTF1(_L("Test:doTestNewLWithBadDataL - Command construction with in-valid data")); INFO_PRINTF1(_L("doTestNewLWithBadDataL:01 Test: NewL(RReadStream& aReadStream, TArray<MSsmCommand*>& aDeferredCommands)")); TRAP(err, iTestCmd = CreateCmdFromStreamL(testDeferredList, timeout)); INFO_PRINTF3(_L("Test completed with err : %d. expected err : %d"), err, expectedErr); TEST(err == expectedErr); Reset(); INFO_PRINTF1(_L("doTestNewLWithBadDataL:02 Test: NewL(TInt32 aTimeout)")); }
// ----------------------------------------------------------------------------- // SortItemsBySortingStyleL // sort aItemArray with aSortingStyle // add undefined items to aUndefinedItemArray // ----------------------------------------------------------------------------- // void SortItemsBySortingStyleL( RPointerArray<MCLFItem>& aItemArray, MCLFSortingStyle& aSortingStyle, RPointerArray<MCLFItem>& aUndefinedItemArray ) { RArray<TCLFFieldId> sortingFields; CleanupClosePushL( sortingFields ); aSortingStyle.GetFieldsL( sortingFields ); const TInt sortingFieldsCount( sortingFields.Count() ); if( sortingFieldsCount ) // sort only if there are sorting fields { TCLFItemDataType sortingDataType( aSortingStyle.SortingDataType() ); RArray<TCLFSortingItem> sortingArray; CleanupClosePushL( sortingArray ); MakeSortingItemsL( sortingArray, aUndefinedItemArray, aItemArray.Array(), sortingFields.Array(), sortingDataType ); SortSortingItemsL( sortingArray, sortingDataType ); aItemArray.Reset(); if( aSortingStyle.Ordering() == ECLFOrderingAscending ) { AppendSortingItemsToArrayL( sortingArray.Array(), aItemArray ); } else { AppendSortingItemsToArrayReverseL( sortingArray.Array(), aItemArray ); } CleanupStack::PopAndDestroy( &sortingArray ); // sortingArray.Close } CleanupStack::PopAndDestroy( &sortingFields ); // sortingFields.Close }