mds_pub/content_listing_framework_api/tsrc/src/ContentListingFrameworkTestBlocks.cpp
branchRCL_3
changeset 8 50de4d668bb6
child 10 ab88d4a85041
equal deleted inserted replaced
7:3cebc1a84278 8:50de4d668bb6
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of CLF API test 
       
    15 *
       
    16 */
       
    17 
       
    18 // [INCLUDE FILES] - do not remove
       
    19 #include <e32svr.h>
       
    20 #include <s32mem.h>
       
    21 #include <ecom.h>
       
    22 #include <StifParser.h>
       
    23 #include <StifTestEventInterface.h>
       
    24 #include <Stiftestinterface.h>
       
    25 #include "ContentListingFrameworkTest.h"
       
    26 
       
    27 // the header for the tested class
       
    28 #include <ContentListingFactory.h>
       
    29 #include <MCLFChangedItemObserver.h>
       
    30 #include <MCLFContentListingEngine.h>
       
    31 #include <MCLFCustomGrouper.h>
       
    32 #include <MCLFCustomSorter.h>
       
    33 #include <MCLFItem.h>
       
    34 #include <MCLFItemListModel.h>
       
    35 #include <MCLFModifiableItem.h>
       
    36 #include <MCLFOperationObserver.h>
       
    37 #include <MCLFPostFilter.h>
       
    38 #include <MCLFSortingStyle.h>
       
    39 #include <ContentListingFrameworkTest.rsg>
       
    40 #include <collate.h>
       
    41 #include <pathInfo.h>
       
    42 #include <MCLFProcessObserver.h>
       
    43 #include <CLFContentListingExtended.hrh>
       
    44 
       
    45 // CONSTANTS
       
    46 #ifdef __WINSCW__
       
    47 _LIT( KTestResourceFile, "z:\\resource\\ContentListingFrameworkTest.rsc" );
       
    48 #else
       
    49 _LIT( KTestResourceFile, "c:\\resource\\ContentListingFrameworkTest.rsc" );
       
    50 #endif
       
    51 _LIT( KTestFileNameBase, "CLFTestFiles\\TestFile" );
       
    52 _LIT( KTestFileExt, ".txt" );
       
    53 
       
    54 const TCLFFieldId KMultibleSortingTestField1 = 0x80000001;
       
    55 const TCLFFieldId KMultibleSortingTestField2 = 0x80000002;
       
    56 const TCLFFieldId KMultibleSortingTestField3 = 0x80000003;
       
    57 const TCLFFieldId KMultibleSortingTestField4 = 0x80000004;
       
    58 const TCLFFieldId KMultibleSortingTestField5 = 0x80000005;
       
    59 const TCLFFieldId KMultibleSortingTestField6 = 0x80000006;
       
    60 
       
    61 const TInt KCLFUpdateFoldersSemanticId = 0x1000;
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // class CMGXAsyncCallback
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 class CCLFAsyncCallback : public CBase
       
    68     {
       
    69     public:
       
    70         ~CCLFAsyncCallback()
       
    71             {
       
    72             if ( iActiveWait.IsStarted() )
       
    73                 {
       
    74                 iActiveWait.AsyncStop();
       
    75                 }
       
    76             }
       
    77     public:
       
    78         static void AfterL( TTimeIntervalMicroSeconds32 aInterval )
       
    79             {
       
    80             CCLFAsyncCallback* self = new( ELeave ) CCLFAsyncCallback();
       
    81             CleanupStack::PushL( self );
       
    82             CPeriodic* periodic = CPeriodic::NewL( CActive::EPriorityIdle );
       
    83             CleanupStack::PushL( periodic );
       
    84             TCallBack callBack( CallBackL, self );
       
    85             TTimeIntervalMicroSeconds32 interval( 1000000 );
       
    86             periodic->Start( aInterval, aInterval, callBack );
       
    87             self->iActiveWait.Start();
       
    88             periodic->Cancel();
       
    89             CleanupStack::PopAndDestroy( 2 ); // periodic, self
       
    90             }
       
    91 
       
    92         static TInt CallBackL( TAny* aObject )
       
    93             {
       
    94             CCLFAsyncCallback* self = reinterpret_cast< CCLFAsyncCallback* >( aObject );
       
    95             if ( self->iActiveWait.IsStarted() )
       
    96                 {
       
    97                 self->iActiveWait.AsyncStop();
       
    98                 }
       
    99             return EFalse;
       
   100             }
       
   101             
       
   102     private:
       
   103         CActiveSchedulerWait iActiveWait;
       
   104     };
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // class TTestOperationObserver
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 class TTestOperationObserver : public MCLFOperationObserver
       
   111     {
       
   112     public:
       
   113         TTestOperationObserver()
       
   114             // set invalid values
       
   115             : iOperationEvent( TCLFOperationEvent( -1 ) ), iError( 1 ), iWait( NULL )
       
   116             {}
       
   117         void HandleOperationEventL( TCLFOperationEvent aOperationEvent,
       
   118                                     TInt aError )
       
   119             {
       
   120             iError = aError;
       
   121             iOperationEvent = aOperationEvent;
       
   122             if( iWait &&
       
   123                 iWait->IsStarted() )
       
   124                 {
       
   125                 iWait->AsyncStop();
       
   126                 }
       
   127             }
       
   128         TCLFOperationEvent iOperationEvent;
       
   129         TInt iError;
       
   130         CActiveSchedulerWait* iWait;
       
   131 
       
   132     };
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // class TTestCustomSorter
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 class TTestCustomSorter : public MCLFCustomSorter
       
   139     {
       
   140     public:
       
   141         TTestCustomSorter() : iSortItems( EFalse )
       
   142             {
       
   143             }
       
   144         void SortItemsL( RPointerArray<MCLFItem>& /*aItemArray*/ )
       
   145             {
       
   146             //aItemArray;
       
   147             iSortItems = ETrue;
       
   148             }
       
   149         TBool iSortItems;
       
   150 
       
   151     };
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // class TTestCustomGrouper
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 class TTestCustomGrouper : public MCLFCustomGrouper
       
   158     {
       
   159     public:
       
   160         TTestCustomGrouper() : iGroupCount( 2 ), iCopyItems( EFalse ), iModifiableItems( NULL )
       
   161             {
       
   162             }
       
   163         void GroupItemsL( const TArray<MCLFItem*>& /*aSourceList*/,
       
   164                           RPointerArray<MCLFItem>& aGroupedList )
       
   165             {
       
   166             //aSourceList;
       
   167             if( iCopyItems )
       
   168                 {
       
   169                 TInt count( iModifiableItems->Count() );
       
   170                 for( TInt i = 0 ; i < count ; ++i )
       
   171                     {
       
   172                     aGroupedList.AppendL( (*iModifiableItems)[i] );
       
   173                     }
       
   174                 }
       
   175             else if( iModifiableItems )
       
   176                 {
       
   177                 iModifiableItems->ResetAndDestroy();
       
   178                 for( TInt i = 0 ; i < iGroupCount ; ++i )
       
   179                     {
       
   180                     MCLFModifiableItem* item = ContentListingFactory::NewModifiableItemLC();
       
   181                     iModifiableItems->AppendL( item );
       
   182                     CleanupStack::Pop(); // item
       
   183                     aGroupedList.AppendL( item );
       
   184                     }
       
   185                 }
       
   186             }
       
   187         TInt iGroupCount;
       
   188         TBool iCopyItems;
       
   189         RPointerArray<MCLFModifiableItem>* iModifiableItems;
       
   190     };
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // class TTestPostFilter
       
   194 // ---------------------------------------------------------------------------
       
   195 //
       
   196 class TTestPostFilter : public MCLFPostFilter
       
   197     {
       
   198     public:
       
   199         TTestPostFilter() : iShouldFilterCount( 5 ), iAllFilter( EFalse ), iFilteredCount( 0 )
       
   200             {
       
   201             }
       
   202 
       
   203         void FilterItemsL( const TArray<MCLFItem*>& aItemList,
       
   204                            RPointerArray<MCLFItem>& aFilteredItemList )
       
   205             {
       
   206             iFilteredCount = 0;
       
   207             if( iAllFilter )
       
   208                 {
       
   209                 iFilteredCount = aItemList.Count();
       
   210                 return;
       
   211                 }
       
   212             for( TInt i = 0 ; i < aItemList.Count() ; ++i )
       
   213                 {
       
   214                 if( i < iShouldFilterCount  )
       
   215                     {
       
   216                     iFilteredCount++;
       
   217                     }
       
   218                 else
       
   219                     {
       
   220                     aFilteredItemList.AppendL( aItemList[i] );
       
   221                     }
       
   222                 }
       
   223             }
       
   224         TInt iShouldFilterCount;
       
   225         TBool iAllFilter;
       
   226         TInt iFilteredCount;
       
   227 
       
   228     };
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // class TTestChangedItemObserver
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 class TTestChangedItemObserver : public MCLFChangedItemObserver
       
   235     {
       
   236     public:
       
   237         TTestChangedItemObserver()
       
   238             : iHandleItemChange( EFalse ),
       
   239               iLastError( KErrNone ),
       
   240               iChangedArray( NULL ),
       
   241               iWait( NULL )      
       
   242             {
       
   243             }
       
   244         void HandleItemChangeL( const TArray<TCLFItemId>& aItemIDArray )
       
   245             {
       
   246             iHandleItemChange = ETrue;
       
   247             if( iChangedArray )
       
   248                 {
       
   249                 iChangedArray->Reset();
       
   250                 for( TInt i = 0 ; i < aItemIDArray.Count() ; ++i )
       
   251                     {
       
   252                     iChangedArray->AppendL( aItemIDArray[i] );
       
   253                     }
       
   254                 }
       
   255             if( iWait && iWait->IsStarted() )
       
   256                 {
       
   257                 iWait->AsyncStop();
       
   258                 }
       
   259 
       
   260             }
       
   261         void HandleError( TInt aError )
       
   262             {
       
   263             iLastError = aError;
       
   264             if( iWait && iWait->IsStarted() )
       
   265                 {
       
   266                 iWait->AsyncStop();
       
   267                 }
       
   268             }
       
   269         TInt iHandleItemChange;
       
   270         TInt iLastError;
       
   271         RArray<TCLFItemId>* iChangedArray;
       
   272         CActiveSchedulerWait* iWait;
       
   273     };
       
   274 
       
   275 // ---------------------------------------------------------------------------
       
   276 // class TTestCLFProcessObserver
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 class TTestCLFProcessObserver : public MCLFProcessObserver
       
   280     {
       
   281     public:
       
   282         TTestCLFProcessObserver()
       
   283             : iStartEvent( EFalse ), iEndEvent( EFalse )
       
   284             {}
       
   285         void HandleCLFProcessEventL( TCLFProcessEvent aProcessEvent )
       
   286             {
       
   287             switch ( aProcessEvent )
       
   288                 {
       
   289                 case ECLFUpdateStart:
       
   290                     {
       
   291                     iStartEvent = ETrue;
       
   292                     break;
       
   293                     }
       
   294                 case ECLFUpdateStop:
       
   295                     {
       
   296                     iEndEvent = ETrue;
       
   297                     break;
       
   298                     }
       
   299                 default:
       
   300                     {
       
   301                     User::Panic( _L("CLF module test"), 1 );
       
   302                     }
       
   303                 }
       
   304             }
       
   305         void Reset()
       
   306             {
       
   307             iStartEvent = EFalse;
       
   308             iEndEvent = EFalse;
       
   309             }
       
   310         TBool iStartEvent;
       
   311         TBool iEndEvent;
       
   312     };
       
   313 
       
   314 void SerializeL( const MDesCArray& aDataArray, CBufBase& aBuffer )
       
   315     {
       
   316     const TInt count( aDataArray.MdcaCount() );
       
   317     RBufWriteStream writeStream( aBuffer );
       
   318     CleanupClosePushL( writeStream );
       
   319     writeStream.WriteInt32L( count );
       
   320     for( TInt i = 0 ; i < count ; ++i )
       
   321         {
       
   322         const TDesC& des = aDataArray.MdcaPoint( i );
       
   323         TInt length( des.Length() );
       
   324         writeStream.WriteInt32L( length );
       
   325         writeStream.WriteL( des, length );
       
   326         }
       
   327     CleanupStack::PopAndDestroy( &writeStream );
       
   328     }
       
   329 
       
   330 // ============================ MEMBER FUNCTIONS ===============================
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 // CContentListingFrameworkTest::Delete
       
   334 // Delete here all resources allocated and opened from test methods. 
       
   335 // Called from destructor. 
       
   336 // -----------------------------------------------------------------------------
       
   337 //
       
   338 void CContentListingFrameworkTest::Delete() 
       
   339     {
       
   340     }
       
   341 
       
   342 // -----------------------------------------------------------------------------
       
   343 // CCollectionManagerTest::RunMethodL
       
   344 // Run specified method. Contains also table of test mothods and their names.
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 TInt CContentListingFrameworkTest::RunMethodL( 
       
   348     CStifItemParser& aItem ) 
       
   349     {
       
   350 
       
   351     static TStifFunctionInfo const KFunctions[] =
       
   352         {  
       
   353         // Copy this line for every implemented function.
       
   354         // First string is the function name used in TestScripter script file.
       
   355         // Second is the actual implementation member function. 
       
   356 
       
   357         // engine		
       
   358         ENTRY( "BaseSetup", CContentListingFrameworkTest::BaseSetupL ),
       
   359         ENTRY( "SortingStyleResourceSetup", CContentListingFrameworkTest::SortingStyleResourceSetupL ),
       
   360         ENTRY( "CreateModelSetup", CContentListingFrameworkTest::CreateModelSetupL ),
       
   361         ENTRY( "CreateModelFromResourceSetup", CContentListingFrameworkTest::CreateModelFromResourceSetupL ),
       
   362         ENTRY( "ListModelSetup", CContentListingFrameworkTest::ListModelSetupL ),
       
   363         ENTRY( "ListModelSetupFromResource", CContentListingFrameworkTest::ListModelSetupFromResourceL ),
       
   364         ENTRY( "ListModelAllFileItemsSetup", CContentListingFrameworkTest::ListModelAllFileItemsSetupL ),
       
   365         ENTRY( "EngineTestSetup", CContentListingFrameworkTest::EngineTestSetupL ),
       
   366         ENTRY( "SortingStyleTestSetup", CContentListingFrameworkTest::SortingStyleTestSetupL ),
       
   367         ENTRY( "SortingStyleResourceTestSetup", CContentListingFrameworkTest::SortingStyleResourceTestSetupL ),
       
   368         ENTRY( "ModifiableItemTestSetup", CContentListingFrameworkTest::ModifiableItemTestSetupL ),
       
   369         ENTRY( "ItemTestSetup", CContentListingFrameworkTest::ItemTestSetupL ),
       
   370         ENTRY( "MultibleSortingSetup", CContentListingFrameworkTest::MultibleSortingSetupL ),
       
   371         ENTRY( "MultibleSortingResourceSetup", CContentListingFrameworkTest::MultibleSortingResourceSetupL ),
       
   372         ENTRY( "Teardown", CContentListingFrameworkTest::Teardown ),
       
   373         ENTRY( "CreateEngineTest", CContentListingFrameworkTest::CreateEngineTestL ),
       
   374         ENTRY( "CreateModifiableItemTest", CContentListingFrameworkTest::CreateModifiableItemTestL ),
       
   375         ENTRY( "CreateSortignStyleTest", CContentListingFrameworkTest::CreateSortignStyleTestL ),
       
   376         ENTRY( "CreateSortignStyleFromResourceTest", CContentListingFrameworkTest::CreateSortignStyleFromResourceTestL ),
       
   377         ENTRY( "CreateListModelTest", CContentListingFrameworkTest::CreateListModelTestL ),
       
   378         ENTRY( "CreateListModelFromResourceTest", CContentListingFrameworkTest::CreateListModelFromResourceTestL ),
       
   379         ENTRY( "UpdateItemsTest", CContentListingFrameworkTest::UpdateItemsTestL ),
       
   380         ENTRY( "UpdateItemsWithIdTest", CContentListingFrameworkTest::UpdateItemsWithIdTestL ),
       
   381         ENTRY( "UpdateItemsWithOpaqueDataFolderTest", CContentListingFrameworkTest::UpdateItemsWithOpaqueDataFolderTestL ),
       
   382         ENTRY( "SortingStyleResourceTest", CContentListingFrameworkTest::SortingStyleResourceTestL ),
       
   383         ENTRY( "SortingStyleOrderingTest", CContentListingFrameworkTest::SortingStyleOrderingTestL ),
       
   384         ENTRY( "SortingStyleDataTypeTest", CContentListingFrameworkTest::SortingStyleDataTypeTestL ),
       
   385         ENTRY( "SortingStyleUndefinedItemPositionTest", CContentListingFrameworkTest::SortingStyleUndefinedItemPositionTestL ),
       
   386         ENTRY( "SortingStyleFieldTest", CContentListingFrameworkTest::SortingStyleFieldTestL ),
       
   387         ENTRY( "RefreshTest", CContentListingFrameworkTest::RefreshTestL ),
       
   388         ENTRY( "SetSortingStyleTest", CContentListingFrameworkTest::SetSortingStyleTestL ),
       
   389         ENTRY( "SetCustomSorterTest", CContentListingFrameworkTest::SetCustomSorterTestL ),
       
   390         ENTRY( "GroupingTest", CContentListingFrameworkTest::GroupingTestL ),
       
   391         ENTRY( "SetPostFilterTest", CContentListingFrameworkTest::SetPostFilterTestL ),
       
   392         ENTRY( "SetWantedMimeTypesTest", CContentListingFrameworkTest::SetWantedMimeTypesTestL ),
       
   393         ENTRY( "SetWantedMediaTypesTest", CContentListingFrameworkTest::SetWantedMediaTypesTestL ),
       
   394         ENTRY( "SetWantedMediaAndMimeTypesTest", CContentListingFrameworkTest::SetWantedMediaAndMimeTypesTestL ),
       
   395         ENTRY( "MultibleSortingTest", CContentListingFrameworkTest::MultibleSortingTestL ),
       
   396         ENTRY( "ModelItemsChangedTest", CContentListingFrameworkTest::ModelItemsChangedTestL ),
       
   397         ENTRY( "ItemFieldTest", CContentListingFrameworkTest::ItemFieldTestL ),
       
   398         ENTRY( "MIFieldTest", CContentListingFrameworkTest::MIFieldTestL ),
       
   399         };
       
   400     
       
   401     const TInt count = sizeof( KFunctions ) / 
       
   402                         sizeof( TStifFunctionInfo );
       
   403 
       
   404     return RunInternalL( KFunctions, count, aItem );
       
   405 
       
   406     }
       
   407 
       
   408 /**
       
   409  * Assistance methods
       
   410  */
       
   411 
       
   412 // ---------------------------------------------------------------------------
       
   413 // CContentListingFrameworkTest::ResourceL
       
   414 // ---------------------------------------------------------------------------
       
   415 //
       
   416 void CContentListingFrameworkTest::ResourceL( TInt aResourceId )
       
   417     {
       
   418     delete iDataBuffer;
       
   419     iDataBuffer = NULL;
       
   420     iDataBuffer = iResourceFile.AllocReadL( aResourceId );
       
   421     iResourceReader.SetBuffer( iDataBuffer );
       
   422     }
       
   423 
       
   424 // ---------------------------------------------------------------------------
       
   425 // CContentListingFrameworkTest::SortingStyleResourceL
       
   426 // ---------------------------------------------------------------------------
       
   427 //
       
   428 void CContentListingFrameworkTest::SortingStyleResourceL()
       
   429     {
       
   430     ResourceL( R_SORTING_STYLE );
       
   431     }
       
   432 
       
   433 // ---------------------------------------------------------------------------
       
   434 // CContentListingFrameworkTest::ListModelResourceL
       
   435 // ---------------------------------------------------------------------------
       
   436 //
       
   437 void CContentListingFrameworkTest::ListModelResourceL()
       
   438     {
       
   439     ResourceL( R_LIST_MODEL );
       
   440     }
       
   441 
       
   442 // ---------------------------------------------------------------------------
       
   443 // CContentListingFrameworkTest::CreateNewFileL
       
   444 // ---------------------------------------------------------------------------
       
   445 //
       
   446 void CContentListingFrameworkTest::CreateNewFileL( TInt aNumber, TDes& aFileName )
       
   447     {
       
   448     aFileName.Copy( PathInfo::PhoneMemoryRootPath() );
       
   449     aFileName.Append( KTestFileNameBase );
       
   450     TBuf<125> buf;
       
   451     buf.Num( aNumber );
       
   452     aFileName.Append( buf );
       
   453     aFileName.Append( KTestFileExt );
       
   454 
       
   455     RFile file;
       
   456     BaflUtils::EnsurePathExistsL( iFs, aFileName );
       
   457     TInt error( file.Replace( iFs, aFileName, EFileShareAny | EFileWrite ) );
       
   458     if( error == KErrNone )
       
   459         {
       
   460         error = file.Write( _L8("Test data") );
       
   461         }
       
   462     file.Close();
       
   463     User::LeaveIfError( error );
       
   464     }
       
   465 
       
   466 // ---------------------------------------------------------------------------
       
   467 // CContentListingFrameworkTest::FindTestFileIdL
       
   468 // ---------------------------------------------------------------------------
       
   469 //
       
   470 TCLFItemId CContentListingFrameworkTest::FindTestFileIdL( TInt aNumber )
       
   471     {
       
   472     TCLFItemId id( 0 );
       
   473     MCLFItemListModel* model = iEngine->CreateListModelLC( *iTestObserver );
       
   474     iMimeTypeArray->AppendL( _L("*") );
       
   475     
       
   476     iTestObserver->iWait = &iWait;
       
   477     model->SetWantedMimeTypesL( *iMimeTypeArray );
       
   478     model->RefreshL();
       
   479     iWait.Start();
       
   480 
       
   481     TFileName testFileName( PathInfo::PhoneMemoryRootPath() );
       
   482     testFileName.Append( KTestFileNameBase );
       
   483     TBuf<125> buf;
       
   484     buf.Num( aNumber );
       
   485     testFileName.Append( buf );
       
   486     testFileName.Append( KTestFileExt );
       
   487     for( TInt i = 0 ; i < model->ItemCount() ; ++i )
       
   488         {
       
   489         const MCLFItem& item = model->Item( i );
       
   490         TPtrC fileName;
       
   491         if( item.GetField( ECLFFieldIdFileNameAndPath, fileName ) != KErrNone )
       
   492             {
       
   493             continue;
       
   494             }
       
   495         if( fileName.CompareF( testFileName ) == 0 )
       
   496             {
       
   497             id = item.ItemId();
       
   498             break;
       
   499             }
       
   500         }
       
   501     CleanupStack::PopAndDestroy(); // model
       
   502     return id;
       
   503     }
       
   504 
       
   505 // ---------------------------------------------------------------------------
       
   506 // CContentListingFrameworkTest::CheckFileNameShortingL
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 TBool CContentListingFrameworkTest::CheckFileNameShortingL()
       
   510     {
       
   511     TCollationMethod m = *Mem::CollationMethodByIndex( 0 );
       
   512     m.iFlags |= TCollationMethod::EIgnoreNone | TCollationMethod::EFoldCase;
       
   513 
       
   514     for( TInt i = 0 ; i < iListModel->ItemCount() -1 ; ++i )
       
   515         {
       
   516         const MCLFItem& item = iListModel->Item( i );
       
   517         const MCLFItem& item1 = iListModel->Item( i + 1 );
       
   518         TPtrC name;
       
   519         TPtrC name1;
       
   520 
       
   521         if( item.GetField( ECLFFieldIdFileName, name ) != KErrNone ||
       
   522             item1.GetField( ECLFFieldIdFileName, name1 ) != KErrNone )
       
   523             {
       
   524             return EFalse;
       
   525             }
       
   526         if( name.CompareC( name1, 3, &m ) > 0 )
       
   527             {
       
   528             return EFalse;
       
   529             }
       
   530         }
       
   531     return ETrue;
       
   532     }
       
   533 
       
   534 // ---------------------------------------------------------------------------
       
   535 // CContentListingFrameworkTest::CheckFileSizeShortingL
       
   536 // ---------------------------------------------------------------------------
       
   537 //
       
   538 TBool CContentListingFrameworkTest::CheckFileSizeShortingL()
       
   539     {
       
   540     for( TInt i = 0 ; i < iListModel->ItemCount() -1 ; ++i )
       
   541         {
       
   542         const MCLFItem& item = iListModel->Item( i );
       
   543         const MCLFItem& item1 = iListModel->Item( i + 1 );
       
   544         TInt32 size;
       
   545         TInt32 size1;
       
   546         if( item.GetField( ECLFFieldIdFileSize, size ) != KErrNone ||
       
   547             item1.GetField( ECLFFieldIdFileSize, size1 ) != KErrNone )
       
   548             {
       
   549             return EFalse;
       
   550             }
       
   551         if( size < size1 )
       
   552             {
       
   553             return EFalse;
       
   554             }
       
   555         }
       
   556     return ETrue;
       
   557     }
       
   558 
       
   559 // ---------------------------------------------------------------------------
       
   560 // CContentListingFrameworkTest::CheckMultibleSortingShortingL
       
   561 // ---------------------------------------------------------------------------
       
   562 //
       
   563 TBool CContentListingFrameworkTest::CheckMultibleSortingShortingL()
       
   564     {
       
   565     const MCLFItem* item = &( iListModel->Item( 0 ) );
       
   566     TInt32 data( 0 );
       
   567     if( item->GetField( KMultibleSortingTestField2, data ) != KErrNone ||
       
   568         data != 5 )
       
   569         {
       
   570         return EFalse;
       
   571         }
       
   572     item = &( iListModel->Item( 1 ) );
       
   573     if( item->GetField( KMultibleSortingTestField2, data ) != KErrNone ||
       
   574         data != 4 )
       
   575         {
       
   576         return EFalse;
       
   577         }
       
   578     item = &( iListModel->Item( 2 ) );
       
   579     if( item->GetField( KMultibleSortingTestField2, data ) != KErrNone ||
       
   580         data != 3 )
       
   581         {
       
   582         return EFalse;
       
   583         }
       
   584     item = &( iListModel->Item( 3 ) );
       
   585     if( item->GetField( KMultibleSortingTestField3, data ) != KErrNone ||
       
   586         data != 6 )
       
   587         {
       
   588         return EFalse;
       
   589         }
       
   590     item = &( iListModel->Item( 4 ) );
       
   591     if( item->GetField( KMultibleSortingTestField3, data ) != KErrNone ||
       
   592         data != 7 )
       
   593         {
       
   594         return EFalse;
       
   595         }
       
   596     item = &( iListModel->Item( 5 ) );
       
   597     if( item->GetField( KMultibleSortingTestField3, data ) != KErrNone ||
       
   598         data != 8 )
       
   599         {
       
   600         return EFalse;
       
   601         }
       
   602     item = &( iListModel->Item( 6 ) );
       
   603     if( item->GetField( KMultibleSortingTestField4, data ) != KErrNone ||
       
   604         data != 9 )
       
   605         {
       
   606         return EFalse;
       
   607         }
       
   608     item = &( iListModel->Item( 7 ) );
       
   609     if( item->GetField( KMultibleSortingTestField4, data ) != KErrNone ||
       
   610         data != 10 )
       
   611         {
       
   612         return EFalse;
       
   613         }
       
   614     item = &( iListModel->Item( 8 ) );
       
   615     if( item->GetField( KMultibleSortingTestField4, data ) != KErrNone ||
       
   616         data != 11 )
       
   617         {
       
   618         return EFalse;
       
   619         }
       
   620 // unsorted start
       
   621     item = &( iListModel->Item( 9 ) );
       
   622     if( item->GetField( KMultibleSortingTestField6, data ) != KErrNone ||
       
   623         ( data < 15 || data > 17 ) )
       
   624         {
       
   625         return EFalse;
       
   626         }
       
   627     item = &( iListModel->Item( 10 ) );
       
   628     if( item->GetField( KMultibleSortingTestField6, data ) != KErrNone ||
       
   629         ( data < 15 || data > 17 ) )
       
   630         {
       
   631         return EFalse;
       
   632         }
       
   633     item = &( iListModel->Item( 11 ) );
       
   634     if( item->GetField( KMultibleSortingTestField6, data ) != KErrNone ||
       
   635         ( data < 15 || data > 17 ) )
       
   636         {
       
   637         return EFalse;
       
   638         }
       
   639 // unsorted end
       
   640     item = &( iListModel->Item( 12 ) );
       
   641     if( item->GetField( KMultibleSortingTestField5, data ) != KErrNone ||
       
   642         data != 12 )
       
   643         {
       
   644         return EFalse;
       
   645         }
       
   646     item = &( iListModel->Item( 13 ) );
       
   647     if( item->GetField( KMultibleSortingTestField5, data ) != KErrNone ||
       
   648         data != 13 )
       
   649         {
       
   650         return EFalse;
       
   651         }
       
   652     item = &( iListModel->Item( 14 ) );
       
   653     if( item->GetField( KMultibleSortingTestField5, data ) != KErrNone ||
       
   654         data != 14 )
       
   655         {
       
   656         return EFalse;
       
   657         }
       
   658     item = &( iListModel->Item( 15 ) );
       
   659     if( item->GetField( KMultibleSortingTestField1, data ) != KErrNone ||
       
   660         data != 0 )
       
   661         {
       
   662         return EFalse;
       
   663         }
       
   664     item = &( iListModel->Item( 16 ) );
       
   665     if( item->GetField( KMultibleSortingTestField1, data ) != KErrNone ||
       
   666         data != 1 )
       
   667         {
       
   668         return EFalse;
       
   669         }
       
   670     item = &( iListModel->Item( 17 ) );
       
   671     if( item->GetField( KMultibleSortingTestField1, data ) != KErrNone ||
       
   672         data != 2 )
       
   673         {
       
   674         return EFalse;
       
   675         }
       
   676 
       
   677     return ETrue;
       
   678     }
       
   679 
       
   680 // ---------------------------------------------------------------------------
       
   681 // CContentListingFrameworkTest::CheckMultibleSortingShorting2L
       
   682 // ---------------------------------------------------------------------------
       
   683 //
       
   684 TBool CContentListingFrameworkTest::CheckMultibleSortingShorting2L()
       
   685     {
       
   686 // check sorted
       
   687     const MCLFItem* item = &( iListModel->Item( 0 ) );
       
   688     TInt32 data( 0 );
       
   689     if( item->GetField( KMultibleSortingTestField5, data ) != KErrNone ||
       
   690         data != 12 )
       
   691         {
       
   692         return EFalse;
       
   693         }
       
   694     item = &( iListModel->Item( 1 ) );
       
   695     if( item->GetField( KMultibleSortingTestField5, data ) != KErrNone ||
       
   696         data != 13 )
       
   697         {
       
   698         return EFalse;
       
   699         }
       
   700     item = &( iListModel->Item( 2 ) );
       
   701     if( item->GetField( KMultibleSortingTestField5, data ) != KErrNone ||
       
   702         data != 14 )
       
   703         {
       
   704         return EFalse;
       
   705         }
       
   706     item = &( iListModel->Item( 3 ) );
       
   707     if( item->GetField( KMultibleSortingTestField6, data ) != KErrNone ||
       
   708         data != 15 )
       
   709         {
       
   710         return EFalse;
       
   711         }
       
   712     item = &( iListModel->Item( 4 ) );
       
   713     if( item->GetField( KMultibleSortingTestField6, data ) != KErrNone ||
       
   714         data != 16 )
       
   715         {
       
   716         return EFalse;
       
   717         }
       
   718     item = &( iListModel->Item( 5 ) );
       
   719     if( item->GetField( KMultibleSortingTestField6, data ) != KErrNone ||
       
   720         data != 17 )
       
   721         {
       
   722         return EFalse;
       
   723         }
       
   724 // check unsorted
       
   725     for( TInt i = 6 ; i < 18 ; ++i )
       
   726         {
       
   727         item = &( iListModel->Item( i ) );
       
   728         if( item->GetField( KMultibleSortingTestField1, data ) != KErrNone )
       
   729             {
       
   730             if( item->GetField( KMultibleSortingTestField2, data ) != KErrNone )
       
   731                 {
       
   732                 if( item->GetField( KMultibleSortingTestField3, data ) != KErrNone )
       
   733                     {
       
   734                     if( item->GetField( KMultibleSortingTestField4, data ) != KErrNone )
       
   735                         {
       
   736                         return EFalse;
       
   737                         }
       
   738                     }
       
   739                 }
       
   740             }
       
   741         if( data < 0 || data > 11 )
       
   742             {
       
   743             return EFalse;
       
   744             }
       
   745         }
       
   746 
       
   747     return ETrue;
       
   748     }
       
   749 
       
   750 // ---------------------------------------------------------------------------
       
   751 // CContentListingFrameworkTest::CheckFileDateShortingL
       
   752 // ---------------------------------------------------------------------------
       
   753 //
       
   754 TBool CContentListingFrameworkTest::CheckFileDateShortingL()
       
   755     {
       
   756     for( TInt i = 0 ; i < iListModel->ItemCount() -1 ; ++i )
       
   757         {
       
   758         const MCLFItem& item = iListModel->Item( i );
       
   759         const MCLFItem& item1 = iListModel->Item( i + 1 );
       
   760         TTime date;
       
   761         TTime date1;
       
   762         if( item.GetField( ECLFFieldIdFileDate, date ) != KErrNone ||
       
   763             item1.GetField( ECLFFieldIdFileDate, date1 ) != KErrNone )
       
   764             {
       
   765             return EFalse;
       
   766             }
       
   767         if( date > date1 )
       
   768             {
       
   769             return EFalse;
       
   770             }
       
   771         }
       
   772     return ETrue;
       
   773     }
       
   774 
       
   775 // ---------------------------------------------------------------------------
       
   776 // CContentListingFrameworkTest::CheckFileTypesL
       
   777 // ---------------------------------------------------------------------------
       
   778 //
       
   779 TBool CContentListingFrameworkTest::CheckFileTypesL( const MDesCArray& aMimeTypeArray,
       
   780                                             const TArray<TInt>& aMediaTypes )
       
   781     {
       
   782     for( TInt i = 0 ; i < iListModel->ItemCount() ; ++i )
       
   783         {
       
   784         TPtrC mimeType;
       
   785         TInt32 mediaType;
       
   786         TInt error = iListModel->Item( i ).GetField( ECLFFieldIdMimeType, mimeType );
       
   787         if( iListModel->Item( i ).GetField( ECLFFieldIdMediaType, mediaType ) != KErrNone )
       
   788             {
       
   789             return EFalse;
       
   790             }
       
   791         TBool mimeTypeVal( EFalse );
       
   792         TBool mediaTypeVal( EFalse );
       
   793         if( error == KErrNone )
       
   794             {
       
   795             mimeTypeVal = CheckMimeTypesL( aMimeTypeArray, mimeType );
       
   796             }
       
   797         mediaTypeVal = CheckMediaTypesL( aMediaTypes, TCLFMediaType( mediaType ) );
       
   798         if( !( mimeTypeVal || mediaTypeVal ) )
       
   799             {
       
   800             return EFalse;
       
   801             }
       
   802         }
       
   803     return ETrue;
       
   804     }
       
   805 
       
   806 // ---------------------------------------------------------------------------
       
   807 // CContentListingFrameworkTest::CheckMimeTypesL
       
   808 // ---------------------------------------------------------------------------
       
   809 //
       
   810 TBool CContentListingFrameworkTest::CheckMimeTypesL( const MDesCArray& aMimeTypeArray,
       
   811                                             const TDesC& aMimeType )
       
   812     {
       
   813     for( TInt j = 0 ; j < aMimeTypeArray.MdcaCount() ; ++j )
       
   814         {
       
   815         if( aMimeTypeArray.MdcaPoint( j ).Match( aMimeType ) == KErrNotFound )
       
   816             {
       
   817             return ETrue;
       
   818             }
       
   819         }
       
   820     return EFalse;
       
   821     }
       
   822 
       
   823 // ---------------------------------------------------------------------------
       
   824 // CContentListingFrameworkTest::CheckMediaTypesL
       
   825 // ---------------------------------------------------------------------------
       
   826 //
       
   827 TBool CContentListingFrameworkTest::CheckMediaTypesL( const TArray<TInt>& aMediaTypes,
       
   828                                              TCLFMediaType aMediaType )
       
   829     {
       
   830     for( TInt j = 0 ; j < aMediaTypes.Count() ; ++j )
       
   831         {
       
   832         if( aMediaTypes[j] == aMediaType )
       
   833             {
       
   834             return ETrue;
       
   835             }
       
   836         }
       
   837     return EFalse;
       
   838     }
       
   839 
       
   840 // ---------------------------------------------------------------------------
       
   841 // CContentListingFrameworkTest::MakeOpaqueDataL
       
   842 // ---------------------------------------------------------------------------
       
   843 //
       
   844 HBufC8* CContentListingFrameworkTest::MakeOpaqueDataL( const MDesCArray& aFiles )
       
   845     {
       
   846     CDesCArray* folderArray = new ( ELeave ) CDesCArraySeg( 8 );
       
   847     CleanupStack::PushL( folderArray );
       
   848     TInt count( aFiles.MdcaCount() );
       
   849     for( TInt i = 0 ; i < count ; ++i )
       
   850         {
       
   851         TPtrC folderPath( TParsePtrC(
       
   852                             aFiles.MdcaPoint( i ) ).DriveAndPath() );
       
   853         TInt tmp( 0 );
       
   854         if( folderArray->Find( folderPath, tmp, ECmpFolded ) != 0 )
       
   855             {
       
   856             folderArray->AppendL( folderPath );
       
   857             }
       
   858         }
       
   859 
       
   860     CBufBase* dynBuffer = CBufFlat::NewL( 64 );
       
   861     CleanupStack::PushL( dynBuffer );
       
   862     SerializeL( *folderArray, *dynBuffer );
       
   863     HBufC8* ret = dynBuffer->Ptr( 0 ).AllocL();
       
   864     CleanupStack::PopAndDestroy( 2, folderArray );
       
   865     return ret;
       
   866     }
       
   867 
       
   868 // ---------------------------------------------------------------------------
       
   869 // CContentListingFrameworkTest::MakeMultibleSortingItemsL
       
   870 // ---------------------------------------------------------------------------
       
   871 //
       
   872 void CContentListingFrameworkTest::MakeMultibleSortingItemsL(
       
   873                         RPointerArray<MCLFModifiableItem>& aItemArray )
       
   874     {
       
   875     for( TInt i = 0 ; i < 18 ; ++i )
       
   876         {
       
   877         MCLFModifiableItem* item = ContentListingFactory::NewModifiableItemLC();
       
   878         aItemArray.AppendL( item );
       
   879         CleanupStack::Pop(); //item
       
   880 
       
   881         if( i < 3 )
       
   882             {
       
   883             item->AddFieldL( KMultibleSortingTestField1, i );
       
   884             }
       
   885         else if( i < 6 )
       
   886             {
       
   887             item->AddFieldL( KMultibleSortingTestField2, i );
       
   888             }
       
   889         else if( i < 9 )
       
   890             {
       
   891             item->AddFieldL( KMultibleSortingTestField3, i );
       
   892             }
       
   893         else if( i < 12 )
       
   894             {
       
   895             item->AddFieldL( KMultibleSortingTestField4, i );
       
   896             }
       
   897         else if( i < 15 )
       
   898             {
       
   899             item->AddFieldL( KMultibleSortingTestField5, i );
       
   900             }
       
   901         else
       
   902             {
       
   903             item->AddFieldL( KMultibleSortingTestField6, i );
       
   904             }
       
   905         }
       
   906     }
       
   907 
       
   908 // ---------------------------------------------------------------------------
       
   909 // CContentListingFrameworkTest::FindItem
       
   910 // ---------------------------------------------------------------------------
       
   911 //
       
   912 const MCLFItem* CContentListingFrameworkTest::FindItem( MCLFItemListModel& aModel, TCLFItemId aItemId )
       
   913     {
       
   914     for( TInt i = 0 ; i < aModel.ItemCount() ; ++i )
       
   915         {
       
   916         const MCLFItem& item = aModel.Item( i );
       
   917         if( item.ItemId() == aItemId )
       
   918             {
       
   919             return &item;
       
   920             }
       
   921         }
       
   922     return NULL;
       
   923     }
       
   924 
       
   925 /**
       
   926  * Setup
       
   927  */
       
   928 
       
   929 // ---------------------------------------------------------------------------
       
   930 // CContentListingFrameworkTest::BaseSetupL
       
   931 // ---------------------------------------------------------------------------
       
   932 // 
       
   933 TInt CContentListingFrameworkTest::BaseSetupL( CStifItemParser& /* aItem */ )
       
   934     {
       
   935     iFs.Close();
       
   936     iResourceFile.Close();
       
   937     
       
   938     User::LeaveIfError( iFs.Connect() );
       
   939     TFileName fileName( KTestResourceFile );
       
   940     BaflUtils::NearestLanguageFile( iFs, fileName );
       
   941     iResourceFile.OpenL( iFs, KTestResourceFile );
       
   942     iResourceFile.ConfirmSignatureL( 0 );
       
   943 
       
   944     return KErrNone;
       
   945     }
       
   946 
       
   947 // ---------------------------------------------------------------------------
       
   948 // CContentListingFrameworkTest::SortingStyleResourceSetupL
       
   949 // ---------------------------------------------------------------------------
       
   950 // 
       
   951 TInt CContentListingFrameworkTest::SortingStyleResourceSetupL( CStifItemParser& aItem )
       
   952     {
       
   953     BaseSetupL( aItem );
       
   954     SortingStyleResourceL();
       
   955 
       
   956     return KErrNone;
       
   957     }
       
   958 
       
   959 // ---------------------------------------------------------------------------
       
   960 // CContentListingFrameworkTest::CreateModelSetupL
       
   961 // ---------------------------------------------------------------------------
       
   962 // 
       
   963 TInt CContentListingFrameworkTest::CreateModelSetupL( CStifItemParser& /* aItem */ )
       
   964     {
       
   965     iEngine = ContentListingFactory::NewContentListingEngineLC();
       
   966     CleanupStack::Pop(); //engine
       
   967     iTestObserver  = new (ELeave) TTestOperationObserver;
       
   968     return KErrNone;
       
   969     }
       
   970 
       
   971 // ---------------------------------------------------------------------------
       
   972 // CContentListingFrameworkTest::CreateModelFromResourceSetupL
       
   973 // ---------------------------------------------------------------------------
       
   974 // 
       
   975 TInt CContentListingFrameworkTest::CreateModelFromResourceSetupL( CStifItemParser& aItem )
       
   976     {
       
   977     BaseSetupL( aItem );
       
   978     CreateModelSetupL( aItem );
       
   979     ListModelResourceL();
       
   980 
       
   981     return KErrNone;
       
   982     }
       
   983 
       
   984 // ---------------------------------------------------------------------------
       
   985 // CContentListingFrameworkTest::ListModelSetupL
       
   986 // ---------------------------------------------------------------------------
       
   987 // 
       
   988 TInt CContentListingFrameworkTest::ListModelSetupL( CStifItemParser& aItem )
       
   989     {
       
   990     BaseSetupL( aItem );
       
   991     CreateModelSetupL( aItem );
       
   992     iListModel = iEngine->CreateListModelLC( *iTestObserver );
       
   993     CleanupStack::Pop(); //listModel
       
   994 
       
   995     iSortingStyle = ContentListingFactory::NewSortingStyleLC();
       
   996     CleanupStack::Pop(); // sortingStyle
       
   997     iSortingStyle1 = ContentListingFactory::NewSortingStyleLC();
       
   998     CleanupStack::Pop(); // sortingStyle
       
   999     iSortingStyle2 = ContentListingFactory::NewSortingStyleLC();
       
  1000     CleanupStack::Pop(); // sortingStyle
       
  1001     iSortingStyle3 = ContentListingFactory::NewSortingStyleLC();
       
  1002     CleanupStack::Pop(); // sortingStyle
       
  1003 
       
  1004     iTestSorter = new (ELeave) TTestCustomSorter;
       
  1005     iTestSorter1 = new (ELeave) TTestCustomSorter;
       
  1006     iTestGrouper = new (ELeave) TTestCustomGrouper;
       
  1007     iTestGrouper1 = new (ELeave) TTestCustomGrouper;
       
  1008     iTestFilter = new (ELeave) TTestPostFilter;
       
  1009     iTestFilter1 = new (ELeave) TTestPostFilter;
       
  1010     iMimeTypeArray = new (ELeave) CDesCArrayFlat( 8 );
       
  1011     iMimeTypeArray1 = new (ELeave) CDesCArrayFlat( 8 );
       
  1012     
       
  1013     return KErrNone;
       
  1014     }
       
  1015 
       
  1016 // ---------------------------------------------------------------------------
       
  1017 // CContentListingFrameworkTest::MultibleSortingSetupL
       
  1018 // ---------------------------------------------------------------------------
       
  1019 // 
       
  1020 TInt CContentListingFrameworkTest::MultibleSortingSetupL( CStifItemParser& aItem )
       
  1021     {
       
  1022     ListModelSetupL( aItem );
       
  1023     MakeMultibleSortingItemsL( iModifiableItems );
       
  1024 
       
  1025 // use custom grouper to make own items
       
  1026     iTestGrouper->iModifiableItems = &iModifiableItems;
       
  1027     iTestGrouper->iCopyItems = ETrue;
       
  1028     iListModel->SetCustomGrouper( iTestGrouper );
       
  1029 
       
  1030 // set sorters
       
  1031     iSortingStyle->ResetL();
       
  1032     iSortingStyle->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  1033     iSortingStyle->AddFieldL( KMultibleSortingTestField1 );
       
  1034     iSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedFirst );
       
  1035 
       
  1036     iSortingStyle1->ResetL();
       
  1037     iSortingStyle1->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  1038     iSortingStyle1->AddFieldL( KMultibleSortingTestField2 );
       
  1039     iSortingStyle1->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd );
       
  1040     iSortingStyle1->SetOrdering( ECLFOrderingDescending );
       
  1041 
       
  1042     iSortingStyle2->ResetL();
       
  1043     iSortingStyle2->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  1044     iSortingStyle2->AddFieldL( KMultibleSortingTestField3 );
       
  1045     iSortingStyle2->AddFieldL( KMultibleSortingTestField4 );
       
  1046     iSortingStyle2->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd );
       
  1047 
       
  1048     iSortingStyle3->ResetL();
       
  1049     iSortingStyle3->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  1050     iSortingStyle3->AddFieldL( KMultibleSortingTestField5 );
       
  1051     iSortingStyle3->SetUndefinedItemPosition( ECLFSortingStyleUndefinedFirst );
       
  1052 
       
  1053     iListModel->SetSortingStyle( iSortingStyle );
       
  1054     iListModel->AppendSecondarySortingStyleL( *iSortingStyle1 );
       
  1055     iListModel->AppendSecondarySortingStyleL( *iSortingStyle2 );
       
  1056     iListModel->AppendSecondarySortingStyleL( *iSortingStyle3 );
       
  1057 
       
  1058     return KErrNone;
       
  1059     }
       
  1060 
       
  1061 // ---------------------------------------------------------------------------
       
  1062 // CContentListingFrameworkTest::MultibleSortingResourceSetupL
       
  1063 // ---------------------------------------------------------------------------
       
  1064 // 
       
  1065 TInt CContentListingFrameworkTest::MultibleSortingResourceSetupL( CStifItemParser& aItem )
       
  1066     {
       
  1067     ListModelSetupL( aItem );
       
  1068     delete iListModel;
       
  1069     iListModel = NULL;
       
  1070     ResourceL( R_LIST_MODEL_MULTIBLE );
       
  1071     iListModel = iEngine->CreateListModelLC( *iTestObserver, iResourceReader );
       
  1072     CleanupStack::Pop(); //listModel
       
  1073 
       
  1074 // use custom grouper to make own items
       
  1075     MakeMultibleSortingItemsL( iModifiableItems );
       
  1076     iTestGrouper->iModifiableItems = &iModifiableItems;
       
  1077     iTestGrouper->iCopyItems = ETrue;
       
  1078     iListModel->SetCustomGrouper( iTestGrouper );
       
  1079 
       
  1080     return KErrNone;
       
  1081     }
       
  1082 
       
  1083 // ---------------------------------------------------------------------------
       
  1084 // CContentListingFrameworkTest::ListModelAllFileItemsSetupL
       
  1085 // ---------------------------------------------------------------------------
       
  1086 // 
       
  1087 TInt CContentListingFrameworkTest::ListModelAllFileItemsSetupL( CStifItemParser& aItem )
       
  1088     {
       
  1089     ListModelSetupL( aItem );
       
  1090     iMediaTypeArray.AppendL( ECLFMediaTypeVideo );
       
  1091     iMediaTypeArray.AppendL( ECLFMediaTypeImage );
       
  1092     iMediaTypeArray.AppendL( ECLFMediaTypeSound );
       
  1093     iMediaTypeArray.AppendL( ECLFMediaTypeMusic );
       
  1094     iMediaTypeArray.AppendL( ECLFMediaTypeStreamingURL );
       
  1095     iMediaTypeArray.AppendL( ECLFMediaTypePlaylist );
       
  1096     iListModel->SetWantedMediaTypesL( iMediaTypeArray.Array() );
       
  1097     iTestObserver->iWait = &iWait;
       
  1098     iListModel->RefreshL();
       
  1099     iWait.Start();
       
  1100     iItemCount = iListModel->ItemCount();
       
  1101     
       
  1102     return KErrNone;
       
  1103     }
       
  1104 
       
  1105 // ---------------------------------------------------------------------------
       
  1106 // CContentListingFrameworkTest::ListModelSetupFromResourceL
       
  1107 // ---------------------------------------------------------------------------
       
  1108 // 
       
  1109 TInt CContentListingFrameworkTest::ListModelSetupFromResourceL( CStifItemParser& aItem )
       
  1110     {
       
  1111     BaseSetupL( aItem );
       
  1112     CreateModelSetupL( aItem );
       
  1113     ListModelResourceL();
       
  1114     iListModel = iEngine->CreateListModelLC( *iTestObserver, iResourceReader );
       
  1115     CleanupStack::Pop(); //listModel
       
  1116 
       
  1117     return KErrNone;
       
  1118     }
       
  1119 
       
  1120 // ---------------------------------------------------------------------------
       
  1121 // CContentListingFrameworkTest::EngineTestSetupL
       
  1122 // ---------------------------------------------------------------------------
       
  1123 // 
       
  1124 TInt CContentListingFrameworkTest::EngineTestSetupL( CStifItemParser& /* aItem */ )
       
  1125     {
       
  1126     User::LeaveIfError( iFs.Connect() );
       
  1127     iTestObserver  = new (ELeave) TTestOperationObserver;
       
  1128     iMimeTypeArray = new (ELeave) CDesCArrayFlat( 8 );
       
  1129     iEngine = ContentListingFactory::NewContentListingEngineLC();
       
  1130     CleanupStack::Pop(); //engine
       
  1131     iChangedItemObserver = new (ELeave) TTestChangedItemObserver;
       
  1132     iChangedItemObserver1 = new (ELeave) TTestChangedItemObserver;
       
  1133     iTestCLFProcessObserver = new (ELeave) TTestCLFProcessObserver;
       
  1134     iTestCLFProcessObserver1 = new (ELeave) TTestCLFProcessObserver;
       
  1135 
       
  1136     return KErrNone;
       
  1137     }
       
  1138 
       
  1139 // ---------------------------------------------------------------------------
       
  1140 // CContentListingFrameworkTest::SortingStyleTestSetupL
       
  1141 // ---------------------------------------------------------------------------
       
  1142 // 
       
  1143 TInt CContentListingFrameworkTest::SortingStyleTestSetupL( CStifItemParser& /* aItem */ )
       
  1144     {
       
  1145     iSortingStyle = ContentListingFactory::NewSortingStyleLC();
       
  1146     CleanupStack::Pop(); // sortingStyle
       
  1147 
       
  1148     return KErrNone;
       
  1149     }
       
  1150 
       
  1151 // ---------------------------------------------------------------------------
       
  1152 // CContentListingFrameworkTest::SortingStyleResourceTestSetupL
       
  1153 // ---------------------------------------------------------------------------
       
  1154 // 
       
  1155 TInt CContentListingFrameworkTest::SortingStyleResourceTestSetupL( CStifItemParser& aItem )
       
  1156     {
       
  1157     SortingStyleResourceSetupL( aItem );
       
  1158     iSortingStyle1 = ContentListingFactory::NewSortingStyleLC( iResourceReader );
       
  1159     CleanupStack::Pop(); // sortingStyle
       
  1160 
       
  1161     ResourceL( R_SORTING_STYLE_EMPTY );
       
  1162     iSortingStyle = ContentListingFactory::NewSortingStyleLC( iResourceReader );
       
  1163     CleanupStack::Pop(); // sortingStyle
       
  1164 
       
  1165     ResourceL( R_SORTING_STYLE_UNDEFINEDITEM );
       
  1166     iSortingStyle2 = ContentListingFactory::NewSortingStyleLC( iResourceReader );
       
  1167     CleanupStack::Pop(); // sortingStyle
       
  1168 
       
  1169     return KErrNone;
       
  1170     }
       
  1171 
       
  1172 // ---------------------------------------------------------------------------
       
  1173 // CContentListingFrameworkTest::ModifiableItemTestSetupL
       
  1174 // ---------------------------------------------------------------------------
       
  1175 // 
       
  1176 TInt CContentListingFrameworkTest::ModifiableItemTestSetupL( CStifItemParser& /* aItem */ )
       
  1177     {
       
  1178     iModifiableItem = ContentListingFactory::NewModifiableItemLC();
       
  1179     CleanupStack::Pop(); //item
       
  1180     
       
  1181     return KErrNone;
       
  1182     }
       
  1183 
       
  1184 // ---------------------------------------------------------------------------
       
  1185 // CContentListingFrameworkTest::ItemTestSetupL
       
  1186 // ---------------------------------------------------------------------------
       
  1187 // 
       
  1188 TInt CContentListingFrameworkTest::ItemTestSetupL( CStifItemParser& aItem )
       
  1189     {
       
  1190     TInt ret = KErrNone;
       
  1191 
       
  1192     ListModelSetupL( aItem );
       
  1193     CreateNewFileL( 12, iFileName );
       
  1194     iEngine->UpdateItemsL();
       
  1195     iMimeTypeArray->Reset();
       
  1196     iMimeTypeArray->AppendL( _L("*") );
       
  1197     iListModel->SetWantedMimeTypesL( *iMimeTypeArray );
       
  1198 
       
  1199     iTestObserver->iWait = &iWait;
       
  1200     iListModel->RefreshL();
       
  1201     iWait.Start();
       
  1202 
       
  1203     for( TInt i = 0 ; i < iListModel->ItemCount() ; ++i )
       
  1204         {
       
  1205         const MCLFItem& item = iListModel->Item( i );
       
  1206         TPtrC fn;
       
  1207         item.GetField( ECLFFieldIdFileNameAndPath, fn );
       
  1208         if( iFileName.CompareF( fn ) == 0 )
       
  1209             {
       
  1210             iItem = &item;
       
  1211             }
       
  1212         }
       
  1213 
       
  1214     if (!iItem)
       
  1215         {
       
  1216         ret = KErrUnknown;
       
  1217         }
       
  1218     return ret;
       
  1219     }
       
  1220 
       
  1221 /**
       
  1222  * Teardown
       
  1223  */
       
  1224 
       
  1225 // ---------------------------------------------------------------------------
       
  1226 // CContentListingFrameworkTest::Teardown
       
  1227 // ---------------------------------------------------------------------------
       
  1228 // 
       
  1229 TInt CContentListingFrameworkTest::Teardown( CStifItemParser& /* aItem */ )
       
  1230     {
       
  1231     iResourceFile.Close();
       
  1232     iFs.Close();
       
  1233     iMediaTypeArray.Reset();
       
  1234     iMediaTypeArray.Close();
       
  1235     iMediaTypeArray1.Reset();
       
  1236     iMediaTypeArray1.Close();
       
  1237     iUpdateItemIdArray.Reset();
       
  1238     iUpdateItemIdArray.Close();
       
  1239     iChangedArray.Reset();
       
  1240     iChangedArray.Close();
       
  1241     iModifiableItems.ResetAndDestroy();
       
  1242     iModifiableItems.Close();
       
  1243     
       
  1244     delete iListModel;
       
  1245     iListModel = NULL;
       
  1246     delete iEngine;
       
  1247     iEngine = NULL;
       
  1248     delete iSortingStyle;
       
  1249     iSortingStyle = NULL;
       
  1250     delete iSortingStyle1;
       
  1251     iSortingStyle1 = NULL;
       
  1252     delete iSortingStyle2;
       
  1253     iSortingStyle2 = NULL;
       
  1254     delete iSortingStyle3;
       
  1255     iSortingStyle3 = NULL;
       
  1256     delete iDataBuffer;
       
  1257     iDataBuffer = NULL;    
       
  1258     delete iTestObserver;
       
  1259     iTestObserver = NULL;
       
  1260     delete iTestSorter;
       
  1261     iTestSorter = NULL;
       
  1262     delete iTestSorter1;
       
  1263     iTestSorter1 = NULL;
       
  1264     delete iTestGrouper;
       
  1265     iTestGrouper = NULL;
       
  1266     delete iTestGrouper1;
       
  1267     iTestGrouper1 = NULL;
       
  1268     delete iTestFilter;
       
  1269     iTestFilter = NULL;
       
  1270     delete iTestFilter1;
       
  1271     iTestFilter1 = NULL;
       
  1272     delete iMimeTypeArray;
       
  1273     iMimeTypeArray = NULL;
       
  1274     delete iMimeTypeArray1;
       
  1275     iMimeTypeArray1 = NULL;
       
  1276     delete iChangedItemObserver;
       
  1277     iChangedItemObserver = NULL;
       
  1278     delete iChangedItemObserver1;
       
  1279     iChangedItemObserver1 = NULL;
       
  1280     delete iOpaqueData;
       
  1281     iOpaqueData = NULL;
       
  1282     delete iModifiableItem;
       
  1283     iModifiableItem = NULL;
       
  1284     delete iTestCLFProcessObserver1;
       
  1285     iTestCLFProcessObserver1 = NULL;
       
  1286     delete iTestCLFProcessObserver;
       
  1287     iTestCLFProcessObserver = NULL;
       
  1288     
       
  1289     TTimeIntervalMicroSeconds32 time = 1000000;
       
  1290     TRAP_IGNORE( CCLFAsyncCallback::AfterL( time ) );
       
  1291 
       
  1292     return KErrNone;
       
  1293     }
       
  1294 
       
  1295 /**
       
  1296  * Tests, construction
       
  1297  */
       
  1298 
       
  1299 // ---------------------------------------------------------------------------
       
  1300 // CContentListingFrameworkTest::CreateEngineTestL
       
  1301 // ---------------------------------------------------------------------------
       
  1302 // 
       
  1303 TInt CContentListingFrameworkTest::CreateEngineTestL( CStifItemParser& /* aItem */ )
       
  1304     {
       
  1305     TInt ret = KErrNone;
       
  1306 
       
  1307     iEngine = ContentListingFactory::NewContentListingEngineLC();
       
  1308     if (!iEngine)
       
  1309         {
       
  1310         ret = KErrUnknown;
       
  1311         }
       
  1312     CleanupStack::PopAndDestroy(); //engine
       
  1313     iEngine = NULL;
       
  1314     iEngine = ContentListingFactory::NewContentListingEngineLC();
       
  1315     if (!iEngine)
       
  1316         {
       
  1317         ret = KErrUnknown;
       
  1318         }
       
  1319     CleanupStack::Pop(); // engine
       
  1320 
       
  1321     return ret;
       
  1322     }
       
  1323 
       
  1324 // ---------------------------------------------------------------------------
       
  1325 // CContentListingFrameworkTest::CreateModifiableItemTestL
       
  1326 // ---------------------------------------------------------------------------
       
  1327 // 
       
  1328 TInt CContentListingFrameworkTest::CreateModifiableItemTestL( CStifItemParser& /* aItem */ )
       
  1329     {
       
  1330     TInt ret = KErrNone;
       
  1331 
       
  1332     MCLFModifiableItem* item = NULL;
       
  1333     item = ContentListingFactory::NewModifiableItemLC();
       
  1334     if (!item)
       
  1335         {
       
  1336         ret = KErrUnknown;
       
  1337         }
       
  1338     CleanupStack::PopAndDestroy(); // item
       
  1339     item = NULL;
       
  1340     item = ContentListingFactory::NewModifiableItemLC();
       
  1341     if (!item)
       
  1342         {
       
  1343         ret = KErrUnknown;
       
  1344         }
       
  1345     CleanupStack::Pop(); // item
       
  1346     delete item;
       
  1347 
       
  1348     return ret;
       
  1349     }
       
  1350 
       
  1351 // ---------------------------------------------------------------------------
       
  1352 // CContentListingFrameworkTest::CreateSortignStyleTestL
       
  1353 // ---------------------------------------------------------------------------
       
  1354 // 
       
  1355 TInt CContentListingFrameworkTest::CreateSortignStyleTestL( CStifItemParser& /* aItem */ )
       
  1356     {
       
  1357     TInt ret = KErrNone;
       
  1358 
       
  1359     MCLFSortingStyle* sortingStyle = NULL;
       
  1360     sortingStyle = ContentListingFactory::NewSortingStyleLC();
       
  1361     if (!sortingStyle)
       
  1362         {
       
  1363         ret = KErrUnknown;
       
  1364         }
       
  1365     CleanupStack::PopAndDestroy(); // sortingStyle
       
  1366     sortingStyle = NULL;
       
  1367     sortingStyle = ContentListingFactory::NewSortingStyleLC();
       
  1368     if (!sortingStyle)
       
  1369         {
       
  1370         ret = KErrUnknown;
       
  1371         }
       
  1372     CleanupStack::Pop(); // sortingStyle
       
  1373     delete sortingStyle;
       
  1374 
       
  1375     return ret;
       
  1376     }
       
  1377 
       
  1378 // ---------------------------------------------------------------------------
       
  1379 // CContentListingFrameworkTest::CreateSortignStyleFromResourceTestL
       
  1380 // ---------------------------------------------------------------------------
       
  1381 // 
       
  1382 TInt CContentListingFrameworkTest::CreateSortignStyleFromResourceTestL( CStifItemParser& /* aItem */ )
       
  1383     {
       
  1384     TInt ret = KErrNone;
       
  1385 
       
  1386     MCLFSortingStyle* sortingStyle = NULL;
       
  1387     sortingStyle = ContentListingFactory::NewSortingStyleLC( iResourceReader );
       
  1388     if (!sortingStyle)
       
  1389         {
       
  1390         ret = KErrUnknown;
       
  1391         }
       
  1392     CleanupStack::PopAndDestroy(); // sortingStyle
       
  1393     sortingStyle = NULL;
       
  1394 
       
  1395     SortingStyleResourceL(); // refresh resource reader
       
  1396     sortingStyle = ContentListingFactory::NewSortingStyleLC( iResourceReader );
       
  1397     if (!sortingStyle)
       
  1398         {
       
  1399         ret = KErrUnknown;
       
  1400         }
       
  1401     CleanupStack::Pop(); // sortingStyle
       
  1402     delete sortingStyle;
       
  1403 
       
  1404     return ret;
       
  1405     }
       
  1406 
       
  1407 // ---------------------------------------------------------------------------
       
  1408 // CContentListingFrameworkTest::CreateListModelTestL
       
  1409 // ---------------------------------------------------------------------------
       
  1410 // 
       
  1411 TInt CContentListingFrameworkTest::CreateListModelTestL( CStifItemParser& /* aItem */ )
       
  1412     {
       
  1413     TInt ret = KErrNone;
       
  1414 
       
  1415     MCLFItemListModel* model = NULL;
       
  1416     model = iEngine->CreateListModelLC( *iTestObserver );
       
  1417     if (!model)
       
  1418         {
       
  1419         ret = KErrUnknown;
       
  1420         }
       
  1421     CleanupStack::PopAndDestroy();  //listModel
       
  1422     model = NULL;
       
  1423 
       
  1424     model = iEngine->CreateListModelLC( *iTestObserver );
       
  1425     if (!model)
       
  1426         {
       
  1427         ret = KErrUnknown;
       
  1428         }
       
  1429     CleanupStack::Pop(); // listModel
       
  1430     delete model;
       
  1431 
       
  1432     return ret;
       
  1433     }
       
  1434 
       
  1435 // ---------------------------------------------------------------------------
       
  1436 // CContentListingFrameworkTest::CreateListModelFromResourceTestL
       
  1437 // ---------------------------------------------------------------------------
       
  1438 // 
       
  1439 TInt CContentListingFrameworkTest::CreateListModelFromResourceTestL( CStifItemParser& /* aItem */ )
       
  1440     {
       
  1441     TInt ret = KErrNone;
       
  1442 
       
  1443     MCLFItemListModel* model = NULL;
       
  1444     model = iEngine->CreateListModelLC( *iTestObserver, iResourceReader );
       
  1445     if (!model)
       
  1446         {
       
  1447         ret = KErrUnknown;
       
  1448         }
       
  1449     CleanupStack::PopAndDestroy(); //listModel
       
  1450     model = NULL;
       
  1451 
       
  1452     ListModelResourceL();
       
  1453     model = iEngine->CreateListModelLC( *iTestObserver, iResourceReader );
       
  1454     if (!model)
       
  1455         {
       
  1456         ret = KErrUnknown;
       
  1457         }
       
  1458     CleanupStack::Pop(); // listModel
       
  1459     delete model;
       
  1460 
       
  1461     ResourceL( R_LIST_MODEL_INCORRECT_VERSION );
       
  1462     TRAPD(error, iEngine->CreateListModelLC( *iTestObserver, iResourceReader ));
       
  1463     if (error != KErrNotSupported)
       
  1464         {
       
  1465         ret = KErrUnknown;
       
  1466         CleanupStack::Pop(); // listModel
       
  1467         }
       
  1468 
       
  1469     return ret;
       
  1470     }
       
  1471 
       
  1472 /**
       
  1473  * Tests, engine
       
  1474  */
       
  1475 
       
  1476 // ---------------------------------------------------------------------------
       
  1477 // CContentListingFrameworkTest::UpdateItemsTestL
       
  1478 // ---------------------------------------------------------------------------
       
  1479 // 
       
  1480 TInt CContentListingFrameworkTest::UpdateItemsTestL( CStifItemParser& /* aItem */ )
       
  1481     {
       
  1482     TInt ret = KErrNone;
       
  1483 
       
  1484     // MDS will do the updating automatically in the background,
       
  1485     // thus only checking that the methods return correctly
       
  1486     iChangedItemObserver->iWait = &iWait;
       
  1487     iChangedItemObserver->iChangedArray = &iChangedArray;
       
  1488     iEngine->AddChangedItemObserverL( *iChangedItemObserver );
       
  1489     iEngine->AddCLFProcessObserverL( *iTestCLFProcessObserver );
       
  1490     iEngine->AddCLFProcessObserverL( *iTestCLFProcessObserver1 );
       
  1491 
       
  1492     CreateNewFileL( 0, iFileName );
       
  1493     CreateNewFileL( 1, iFileName );
       
  1494     CreateNewFileL( 2, iFileName );
       
  1495     CreateNewFileL( 3, iFileName );
       
  1496     CreateNewFileL( 4, iFileName );
       
  1497     CreateNewFileL( 5, iFileName );
       
  1498 
       
  1499 // update server
       
  1500 // to aTInt incorrect test result
       
  1501     CreateNewFileL( 0, iFileName );
       
  1502     iEngine->UpdateItemsL();
       
  1503 
       
  1504     ret = iChangedItemObserver->iLastError;
       
  1505 
       
  1506     iChangedArray.Reset();
       
  1507     iEngine->RemoveCLFProcessObserver( *iTestCLFProcessObserver1 );
       
  1508     iChangedItemObserver->iHandleItemChange = EFalse;
       
  1509     iChangedItemObserver1->iHandleItemChange = EFalse;
       
  1510     iTestCLFProcessObserver->Reset();
       
  1511     iTestCLFProcessObserver1->Reset();
       
  1512     iEngine->UpdateItemsL();
       
  1513 
       
  1514     return ret;
       
  1515     }
       
  1516 
       
  1517 // ---------------------------------------------------------------------------
       
  1518 // CContentListingFrameworkTest::UpdateItemsWithIdTestL
       
  1519 // ---------------------------------------------------------------------------
       
  1520 // 
       
  1521 TInt CContentListingFrameworkTest::UpdateItemsWithIdTestL( CStifItemParser& /* aItem */ )
       
  1522     {
       
  1523     TInt ret = KErrNone;
       
  1524 
       
  1525     // MDS will do the updating automatically in the background,
       
  1526     // thus only checking that the methods return correctly
       
  1527     iChangedItemObserver->iWait = &iWait;
       
  1528     iChangedItemObserver->iChangedArray = &iChangedArray;
       
  1529     iEngine->AddChangedItemObserverL( *iChangedItemObserver );
       
  1530     iEngine->AddChangedItemObserverL( *iChangedItemObserver1 );
       
  1531     iEngine->AddCLFProcessObserverL( *iTestCLFProcessObserver );
       
  1532 
       
  1533     CreateNewFileL( 6, iFileName );
       
  1534     CreateNewFileL( 7, iFileName );
       
  1535     CreateNewFileL( 8, iFileName );
       
  1536 
       
  1537 // update server
       
  1538 // to aTInt incorrect test result
       
  1539     CreateNewFileL( 6, iFileName );
       
  1540     iEngine->UpdateItemsL();
       
  1541     
       
  1542     if (iChangedItemObserver->iLastError != KErrNone)
       
  1543         {
       
  1544         ret = KErrUnknown;
       
  1545         }
       
  1546 
       
  1547 // start testing
       
  1548 // update by id
       
  1549     TUint id1 = FindTestFileIdL( 7 );
       
  1550     TUint id0 = FindTestFileIdL( 6 );
       
  1551     TUint id2 = FindTestFileIdL( 8 );
       
  1552     iUpdateItemIdArray.AppendL( id1 );
       
  1553     iChangedItemObserver->iHandleItemChange = EFalse;
       
  1554     iChangedItemObserver1->iHandleItemChange = EFalse;
       
  1555     iTestCLFProcessObserver->Reset();
       
  1556     iTestCLFProcessObserver1->Reset();
       
  1557     CreateNewFileL( 6, iFileName );
       
  1558     CreateNewFileL( 7, iFileName );
       
  1559     iEngine->UpdateItemsL( iUpdateItemIdArray.Array() );
       
  1560     
       
  1561     if (iChangedItemObserver->iLastError != KErrNone)
       
  1562         {
       
  1563         ret = KErrUnknown;
       
  1564         }
       
  1565 
       
  1566     iEngine->RemoveChangedItemObserver( *iChangedItemObserver1 );
       
  1567     iEngine->AddCLFProcessObserverL( *iTestCLFProcessObserver1 );
       
  1568 
       
  1569     iChangedItemObserver->iHandleItemChange = EFalse;
       
  1570     iChangedItemObserver1->iHandleItemChange = EFalse;
       
  1571     iTestCLFProcessObserver->Reset();
       
  1572     iTestCLFProcessObserver1->Reset();
       
  1573     iUpdateItemIdArray.AppendL( id0 );
       
  1574     iUpdateItemIdArray.AppendL( id2 );
       
  1575     
       
  1576 // update server
       
  1577 // to aTInt incorrect test result
       
  1578     iEngine->UpdateItemsL();
       
  1579     
       
  1580     if (iChangedItemObserver->iLastError != KErrNone)
       
  1581         {
       
  1582         ret = KErrUnknown;
       
  1583         }
       
  1584     
       
  1585     CreateNewFileL( 6, iFileName );
       
  1586     CreateNewFileL( 7, iFileName );
       
  1587     CreateNewFileL( 8, iFileName );
       
  1588     iChangedArray.Reset();
       
  1589     
       
  1590     iEngine->UpdateItemsL( iUpdateItemIdArray.Array() );
       
  1591 
       
  1592     return ret;
       
  1593     }
       
  1594 
       
  1595 // ---------------------------------------------------------------------------
       
  1596 // CContentListingFrameworkTest::UpdateItemsWithOpaqueDataFolderTestL
       
  1597 // ---------------------------------------------------------------------------
       
  1598 // 
       
  1599 TInt CContentListingFrameworkTest::UpdateItemsWithOpaqueDataFolderTestL( CStifItemParser& /* aItem */ )
       
  1600     {
       
  1601     TInt ret = KErrNone;
       
  1602 
       
  1603     // start testing
       
  1604     // update by opaque data
       
  1605     // folders data
       
  1606     iSemanticId = KCLFUpdateFoldersSemanticId;
       
  1607     delete iOpaqueData;
       
  1608     iOpaqueData = NULL;
       
  1609 
       
  1610     CDesCArray* fileArray = new (ELeave) CDesCArraySeg( 8 );
       
  1611     iOpaqueData = MakeOpaqueDataL( *fileArray );
       
  1612     // Calls internally same MDS method as when updating all data
       
  1613     // thus only interested if this call leaves
       
  1614     iEngine->UpdateItemsL( iSemanticId, *iOpaqueData );
       
  1615 
       
  1616     return ret;
       
  1617     }
       
  1618 
       
  1619 /**
       
  1620  * Tests, list model
       
  1621  */
       
  1622 
       
  1623 // ---------------------------------------------------------------------------
       
  1624 // CContentListingFrameworkTest::RefreshTestL
       
  1625 // ---------------------------------------------------------------------------
       
  1626 //  
       
  1627 TInt CContentListingFrameworkTest::RefreshTestL( CStifItemParser& /* aItem */ )
       
  1628     {
       
  1629     TInt ret = KErrNone;
       
  1630 
       
  1631     iMimeTypeArray->Reset();
       
  1632     iMimeTypeArray->AppendL( _L("*") );
       
  1633     iListModel->SetWantedMimeTypesL( *iMimeTypeArray );
       
  1634 
       
  1635     iTestObserver->iWait = &iWait;
       
  1636     iTestObserver->iError = 100;
       
  1637     iListModel->RefreshL();
       
  1638     iWait.Start();
       
  1639 
       
  1640     if (iTestObserver->iOperationEvent != ECLFRefreshComplete)
       
  1641         {
       
  1642         ret = KErrUnknown;
       
  1643         }
       
  1644     if (iTestObserver->iError != KErrNone)
       
  1645         {
       
  1646         ret = KErrUnknown;
       
  1647         }
       
  1648     if (iListModel->ItemCount() != 0)
       
  1649         {
       
  1650         ret = KErrUnknown;
       
  1651         }
       
  1652 
       
  1653 // cancel refresh
       
  1654     iListModel->RefreshL();
       
  1655     iListModel->CancelRefresh();
       
  1656 
       
  1657     return ret;
       
  1658     }
       
  1659 
       
  1660 // ---------------------------------------------------------------------------
       
  1661 // CContentListingFrameworkTest::SetSortingStyleTestL
       
  1662 // ---------------------------------------------------------------------------
       
  1663 // 
       
  1664 TInt CContentListingFrameworkTest::SetSortingStyleTestL( CStifItemParser& /* aItem */ )
       
  1665     {
       
  1666     TInt ret = KErrNone;
       
  1667 
       
  1668     iListModel->SetSortingStyle( NULL );
       
  1669     iListModel->RefreshL( ECLFRefreshAll );
       
  1670     if (CheckFileNameShortingL())
       
  1671         {
       
  1672         ret = KErrUnknown;
       
  1673         }
       
  1674 
       
  1675 // file name sorting
       
  1676     iSortingStyle->ResetL();
       
  1677     iSortingStyle->SetSortingDataType( ECLFItemDataTypeDesC );
       
  1678     iSortingStyle->AddFieldL( ECLFFieldIdFileName );
       
  1679     iListModel->SetSortingStyle( iSortingStyle );
       
  1680     iListModel->RefreshL( ECLFRefreshAll );
       
  1681     if (!CheckFileNameShortingL())
       
  1682         {
       
  1683         ret = KErrUnknown;
       
  1684         }
       
  1685 
       
  1686 // file size sorting
       
  1687     iSortingStyle1->ResetL();
       
  1688     iSortingStyle1->SetOrdering( ECLFOrderingDescending );
       
  1689     iSortingStyle1->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  1690     iSortingStyle1->AddFieldL( ECLFFieldIdFileSize );
       
  1691     iListModel->SetSortingStyle( iSortingStyle1 );
       
  1692     iListModel->RefreshL( ECLFRefreshAll );
       
  1693     if (CheckFileNameShortingL())
       
  1694         {
       
  1695         ret = KErrUnknown;
       
  1696         }
       
  1697 
       
  1698     iListModel->SetSortingStyle( NULL );
       
  1699     iListModel->RefreshL( ECLFRefreshAll );
       
  1700     if (CheckFileNameShortingL() || CheckFileSizeShortingL() || CheckFileDateShortingL())
       
  1701         {
       
  1702         ret = KErrUnknown;
       
  1703         }
       
  1704 
       
  1705 // time sorting
       
  1706     iSortingStyle->ResetL();
       
  1707     iSortingStyle->SetSortingDataType( ECLFItemDataTypeTTime );
       
  1708     iSortingStyle->AddFieldL( ECLFFieldIdFileDate );
       
  1709     iListModel->SetSortingStyle( iSortingStyle );
       
  1710     iListModel->RefreshL( ECLFRefreshAll );
       
  1711     if (!CheckFileDateShortingL())
       
  1712         {
       
  1713         ret = KErrUnknown;
       
  1714         }
       
  1715 
       
  1716 // parameter test (time)
       
  1717     iListModel->SetSortingStyle( NULL );
       
  1718     iListModel->RefreshL( ECLFRefreshAll );
       
  1719     if (CheckFileNameShortingL() || CheckFileSizeShortingL() || CheckFileDateShortingL())
       
  1720         {
       
  1721         ret = KErrUnknown;
       
  1722         }
       
  1723 
       
  1724     iListModel->SetSortingStyle( iSortingStyle );
       
  1725     iListModel->RefreshL( ECLFRefreshPostFilter );
       
  1726     if (CheckFileNameShortingL() || CheckFileSizeShortingL() || CheckFileDateShortingL())
       
  1727         {
       
  1728         ret = KErrUnknown;
       
  1729         }
       
  1730 
       
  1731     iListModel->RefreshL( ECLFRefreshGrouping );
       
  1732     if (CheckFileNameShortingL() || CheckFileSizeShortingL() || CheckFileDateShortingL())
       
  1733         {
       
  1734         ret = KErrUnknown;
       
  1735         }
       
  1736 
       
  1737     iListModel->RefreshL( ECLFRefreshSorting );
       
  1738     if (CheckFileNameShortingL() || CheckFileSizeShortingL() || !CheckFileDateShortingL())
       
  1739         {
       
  1740         ret = KErrUnknown;
       
  1741         }
       
  1742 
       
  1743 // custom sorter (overwrite sorting style)
       
  1744     iTestSorter->iSortItems = EFalse;
       
  1745     iListModel->SetCustomSorter( iTestSorter );
       
  1746     iListModel->RefreshL( ECLFRefreshAll );
       
  1747     if (!(iTestSorter->iSortItems))
       
  1748         {
       
  1749         ret = KErrUnknown;
       
  1750         }
       
  1751     if (CheckFileNameShortingL() || CheckFileSizeShortingL() || CheckFileDateShortingL())
       
  1752         {
       
  1753         ret = KErrUnknown;
       
  1754         }
       
  1755 
       
  1756     return ret;
       
  1757     }
       
  1758 
       
  1759 // ---------------------------------------------------------------------------
       
  1760 // CContentListingFrameworkTest::SetCustomSorterTestL
       
  1761 // ---------------------------------------------------------------------------
       
  1762 //
       
  1763 TInt CContentListingFrameworkTest::SetCustomSorterTestL( CStifItemParser& /* aItem */ )
       
  1764     {
       
  1765     TInt ret = KErrNone;
       
  1766 
       
  1767     iTestSorter->iSortItems = EFalse;
       
  1768     iTestSorter1->iSortItems = EFalse;
       
  1769 
       
  1770     iListModel->SetCustomSorter( NULL );
       
  1771     iListModel->RefreshL( ECLFRefreshAll );
       
  1772     if ((iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1773         {
       
  1774         ret = KErrUnknown;
       
  1775         }
       
  1776 
       
  1777     iTestSorter->iSortItems = EFalse;
       
  1778     iTestSorter1->iSortItems = EFalse;
       
  1779 
       
  1780     iListModel->SetCustomSorter( iTestSorter );
       
  1781     iListModel->RefreshL( ECLFRefreshAll );
       
  1782     if (!(iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1783         {
       
  1784         ret = KErrUnknown;
       
  1785         }
       
  1786 
       
  1787     iTestSorter->iSortItems = EFalse;
       
  1788     iTestSorter1->iSortItems = EFalse;
       
  1789 
       
  1790     iListModel->SetCustomSorter( iTestSorter1 );
       
  1791     iListModel->RefreshL( ECLFRefreshAll );
       
  1792     if ((iTestSorter->iSortItems) || !(iTestSorter1->iSortItems))
       
  1793         {
       
  1794         ret = KErrUnknown;
       
  1795         }
       
  1796 
       
  1797     iTestSorter->iSortItems = EFalse;
       
  1798     iTestSorter1->iSortItems = EFalse;
       
  1799 
       
  1800     iListModel->SetCustomSorter( NULL );
       
  1801     iListModel->RefreshL( ECLFRefreshAll );
       
  1802     if ((iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1803         {
       
  1804        ret = KErrUnknown;
       
  1805         }
       
  1806 
       
  1807     iTestSorter->iSortItems = EFalse;
       
  1808     iTestSorter1->iSortItems = EFalse;
       
  1809 
       
  1810     iListModel->SetCustomSorter( iTestSorter );
       
  1811     iListModel->RefreshL( ECLFRefreshAll );
       
  1812     if (!(iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1813         {
       
  1814         ret = KErrUnknown;
       
  1815         }
       
  1816 
       
  1817     iTestSorter->iSortItems = EFalse;
       
  1818     iTestSorter1->iSortItems = EFalse;
       
  1819 
       
  1820     iListModel->SetCustomSorter( iTestSorter1 );
       
  1821     iListModel->RefreshL( ECLFRefreshAll );
       
  1822     if ((iTestSorter->iSortItems) || !(iTestSorter1->iSortItems))
       
  1823         {
       
  1824         ret = KErrUnknown;
       
  1825         }
       
  1826 
       
  1827 // parameter test
       
  1828     iTestSorter->iSortItems = EFalse;
       
  1829     iTestSorter1->iSortItems = EFalse;
       
  1830 
       
  1831     iListModel->SetCustomSorter( NULL );
       
  1832     iListModel->RefreshL( ECLFRefreshAll );
       
  1833     if ((iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1834         {
       
  1835         ret = KErrUnknown;
       
  1836         }
       
  1837 
       
  1838 
       
  1839     iTestSorter->iSortItems = EFalse;
       
  1840     iTestSorter1->iSortItems = EFalse;
       
  1841 
       
  1842     iListModel->SetCustomSorter( iTestSorter );
       
  1843     iListModel->RefreshL( ECLFRefreshPostFilter );
       
  1844     if ((iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1845         {
       
  1846         ret = KErrUnknown;
       
  1847         }
       
  1848 
       
  1849     iListModel->RefreshL( ECLFRefreshGrouping );
       
  1850     if ((iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1851         {
       
  1852         ret = KErrUnknown;
       
  1853         }
       
  1854 
       
  1855     iListModel->RefreshL( ECLFRefreshSorting );
       
  1856     if (!(iTestSorter->iSortItems) || (iTestSorter1->iSortItems))
       
  1857         {
       
  1858         ret = KErrUnknown;
       
  1859         }
       
  1860 
       
  1861     return ret;
       
  1862     }
       
  1863 
       
  1864 // ---------------------------------------------------------------------------
       
  1865 // CContentListingFrameworkTest::GroupingTestL
       
  1866 // ---------------------------------------------------------------------------
       
  1867 //
       
  1868 TInt CContentListingFrameworkTest::GroupingTestL( CStifItemParser& /* aItem */ )
       
  1869     {
       
  1870     TInt ret = KErrNone;
       
  1871 
       
  1872     iTestGrouper->iModifiableItems = &iModifiableItems;
       
  1873     iTestGrouper1->iModifiableItems = &iModifiableItems;
       
  1874 
       
  1875 // No grouping
       
  1876     iListModel->SetCustomGrouper( NULL );
       
  1877     iListModel->RefreshL( ECLFRefreshAll );
       
  1878     if (iListModel->ItemCount() != iItemCount)
       
  1879         {
       
  1880         ret = KErrUnknown;
       
  1881         }
       
  1882 
       
  1883 // couple groups
       
  1884     iListModel->SetCustomGrouper( iTestGrouper );
       
  1885     iListModel->RefreshL( ECLFRefreshAll );
       
  1886     if (iListModel->ItemCount() != iModifiableItems.Count())
       
  1887         {
       
  1888         ret = KErrUnknown;
       
  1889         }
       
  1890 
       
  1891 // 0 groups
       
  1892     iTestGrouper1->iGroupCount = 0;
       
  1893     iListModel->SetCustomGrouper( iTestGrouper1 );
       
  1894     iListModel->RefreshL( ECLFRefreshAll );
       
  1895     if (iListModel->ItemCount() != iModifiableItems.Count())
       
  1896         {
       
  1897         ret = KErrUnknown;
       
  1898         }
       
  1899 
       
  1900 // No grouping
       
  1901     iListModel->SetCustomGrouper( NULL );
       
  1902     iListModel->RefreshL( ECLFRefreshAll );
       
  1903     if (iListModel->ItemCount() != iItemCount)
       
  1904         {
       
  1905         ret = KErrUnknown;
       
  1906         }
       
  1907 // Music album grouping
       
  1908     iListModel->SetGroupingStyle( ECLFMusicAlbumGrouping );
       
  1909     iListModel->RefreshL( ECLFRefreshAll );
       
  1910     if (iListModel->ItemCount() == iItemCount)
       
  1911         {
       
  1912         ret = KErrUnknown;
       
  1913         }
       
  1914 // No grouping
       
  1915     iListModel->SetGroupingStyle( ECLFNoGrouping );
       
  1916     iListModel->RefreshL( ECLFRefreshAll );
       
  1917     if (iListModel->ItemCount() != iItemCount)
       
  1918         {
       
  1919         ret = KErrUnknown;
       
  1920         }
       
  1921 
       
  1922 // test parameters
       
  1923     iTestGrouper->iGroupCount = 1000;
       
  1924     iListModel->SetCustomGrouper( iTestGrouper );
       
  1925     iListModel->RefreshL( ECLFRefreshPostFilter );
       
  1926     if (iListModel->ItemCount() != iItemCount)
       
  1927         {
       
  1928         ret = KErrUnknown;
       
  1929         }
       
  1930     iListModel->RefreshL( ECLFRefreshSorting );
       
  1931     if (iListModel->ItemCount() != iItemCount)
       
  1932         {
       
  1933         ret = KErrUnknown;
       
  1934         }
       
  1935     iListModel->RefreshL( ECLFRefreshGrouping );
       
  1936     if (iListModel->ItemCount() != iModifiableItems.Count())
       
  1937         {
       
  1938         ret = KErrUnknown;
       
  1939         }
       
  1940 
       
  1941     return ret;
       
  1942     }
       
  1943 
       
  1944 // ---------------------------------------------------------------------------
       
  1945 // CContentListingFrameworkTest::SetPostFilterTestL
       
  1946 // ---------------------------------------------------------------------------
       
  1947 //
       
  1948 TInt CContentListingFrameworkTest::SetPostFilterTestL( CStifItemParser& /* aItem */ )
       
  1949     {
       
  1950     TInt ret = KErrNone;
       
  1951 
       
  1952 // no filter
       
  1953     iListModel->SetPostFilter( NULL );
       
  1954     iListModel->RefreshL( ECLFRefreshAll );
       
  1955     if (iListModel->ItemCount() != iItemCount)
       
  1956         {
       
  1957         ret = KErrUnknown;
       
  1958         }
       
  1959 
       
  1960 // filter couple items
       
  1961     iListModel->SetPostFilter( iTestFilter );
       
  1962     iListModel->RefreshL( ECLFRefreshAll );
       
  1963     if ( ( iListModel->ItemCount() + iTestFilter1->iFilteredCount ) == iItemCount )
       
  1964         {
       
  1965         ret = KErrUnknown;
       
  1966         }
       
  1967 
       
  1968 // filter all items
       
  1969     iListModel->SetPostFilter( iTestFilter1 );
       
  1970     iTestFilter1->iAllFilter = ETrue;
       
  1971     iListModel->RefreshL( ECLFRefreshAll );
       
  1972     if ( ( iListModel->ItemCount() + iTestFilter1->iFilteredCount ) != iItemCount )
       
  1973         {
       
  1974         ret = KErrUnknown;
       
  1975         }
       
  1976 
       
  1977 // no filter
       
  1978     iListModel->SetPostFilter( NULL );
       
  1979     iListModel->RefreshL( ECLFRefreshAll );
       
  1980     if (iListModel->ItemCount() != iItemCount)
       
  1981         {
       
  1982         ret = KErrUnknown;
       
  1983         }
       
  1984 
       
  1985 // filter one item
       
  1986     iListModel->SetPostFilter( iTestFilter );
       
  1987     iTestFilter->iShouldFilterCount = 1;
       
  1988     iListModel->RefreshL( ECLFRefreshAll );
       
  1989     if ( ( iListModel->ItemCount() + iTestFilter1->iFilteredCount ) == iItemCount )
       
  1990         {
       
  1991         ret = KErrUnknown;
       
  1992         }
       
  1993 
       
  1994 // filter couple items
       
  1995     iListModel->SetPostFilter( iTestFilter1 );
       
  1996     iTestFilter1->iAllFilter = EFalse;
       
  1997     iListModel->RefreshL( ECLFRefreshAll );
       
  1998     if ( ( iListModel->ItemCount() + iTestFilter1->iFilteredCount ) != iItemCount )
       
  1999         {
       
  2000         ret = KErrUnknown;
       
  2001         }
       
  2002 
       
  2003 // test parameters
       
  2004     iListModel->SetPostFilter( NULL );
       
  2005     iListModel->RefreshL( ECLFRefreshAll );
       
  2006     if (iListModel->ItemCount() != iItemCount)
       
  2007         {
       
  2008         ret = KErrUnknown;
       
  2009         }
       
  2010     iListModel->SetPostFilter( iTestFilter1 );
       
  2011     iTestFilter1->iAllFilter = ETrue;
       
  2012     iListModel->RefreshL( ECLFRefreshSorting );
       
  2013     if (iListModel->ItemCount() != iItemCount)
       
  2014         {
       
  2015        ret = KErrUnknown;
       
  2016         }
       
  2017     iListModel->RefreshL( ECLFRefreshGrouping );
       
  2018     if (iListModel->ItemCount() != iItemCount)
       
  2019         {
       
  2020         ret = KErrUnknown;
       
  2021         }
       
  2022     iListModel->RefreshL( ECLFRefreshPostFilter );
       
  2023     if ( ( iListModel->ItemCount() + iTestFilter1->iFilteredCount ) != iItemCount )
       
  2024         {
       
  2025         ret = KErrUnknown;
       
  2026         }
       
  2027 
       
  2028     return ret;
       
  2029     }
       
  2030 
       
  2031 // ---------------------------------------------------------------------------
       
  2032 // CContentListingFrameworkTest::SetWantedMimeTypesTestL
       
  2033 // ---------------------------------------------------------------------------
       
  2034 //
       
  2035 TInt CContentListingFrameworkTest::SetWantedMimeTypesTestL( CStifItemParser& /* aItem */ )
       
  2036     {
       
  2037     TInt ret = KErrNone;
       
  2038 
       
  2039     iTestObserver->iWait = &iWait;
       
  2040 
       
  2041 // list not defined (mimetype)
       
  2042     iListModel->RefreshL();
       
  2043     iWait.Start();
       
  2044     if (iListModel->ItemCount() != 0)
       
  2045         {
       
  2046         ret = KErrUnknown;
       
  2047         }
       
  2048 
       
  2049 // couple mime types
       
  2050     iMimeTypeArray->Reset();
       
  2051     iMimeTypeArray->AppendL( _L( "audio/mpeg" ) );
       
  2052     iMimeTypeArray->AppendL( _L( "audio/aac" ) );
       
  2053     iMimeTypeArray->AppendL( _L( "audio/mp3" ) );
       
  2054     iMimeTypeArray->AppendL( _L( "audio/x-mp3" ) );
       
  2055     iMimeTypeArray->AppendL( _L( "audio/mp4" ) );
       
  2056     iMimeTypeArray->AppendL( _L( "audio/3gpp" ) );
       
  2057     iMimeTypeArray->AppendL( _L( "audio/m4a" ) );
       
  2058     iMimeTypeArray->AppendL( _L( "audio/3gpp2" ) );
       
  2059     iMimeTypeArray->AppendL( _L( "audio/mpeg4") );
       
  2060     iListModel->SetWantedMimeTypesL( *iMimeTypeArray );
       
  2061     iListModel->RefreshL();
       
  2062     iWait.Start();
       
  2063     if ( !CheckFileTypesL( *iMimeTypeArray, iMediaTypeArray.Array() ) )
       
  2064         {
       
  2065         ret = KErrUnknown;
       
  2066         }
       
  2067 
       
  2068 // unsupported mimetype
       
  2069     iMimeTypeArray1->Reset();
       
  2070     iMimeTypeArray1->AppendL( _L("__not_supported__")  );
       
  2071     iListModel->SetWantedMimeTypesL( *iMimeTypeArray1 );
       
  2072     iListModel->RefreshL();
       
  2073     iWait.Start();
       
  2074     if (iListModel->ItemCount() != 0)
       
  2075         {
       
  2076         ret = KErrUnknown;
       
  2077         }
       
  2078 
       
  2079 // empty mimetype list
       
  2080     iMimeTypeArray1->Reset();
       
  2081     iListModel->SetWantedMimeTypesL( *iMimeTypeArray1 );
       
  2082     iListModel->RefreshL();
       
  2083     iWait.Start();
       
  2084     if (iListModel->ItemCount() != 0)
       
  2085         {
       
  2086         ret = KErrUnknown;
       
  2087         }
       
  2088 
       
  2089 // from resource (mimetype)
       
  2090     iMimeTypeArray->Reset();
       
  2091     iMimeTypeArray->AppendL( _L("image/*")  );
       
  2092     iMimeTypeArray->AppendL( _L("audio/*")  );
       
  2093 
       
  2094     ResourceL( R_MIME_TYPE_ARRAY );
       
  2095     iListModel->SetWantedMimeTypesL( iResourceReader );
       
  2096     iListModel->RefreshL();
       
  2097     iWait.Start();
       
  2098     if ( !CheckFileTypesL( *iMimeTypeArray, iMediaTypeArray.Array() ) )
       
  2099         {
       
  2100         ret = KErrUnknown;
       
  2101         }
       
  2102 
       
  2103     ResourceL( R_MIME_TYPE_ARRAY_EMPTY );
       
  2104     iListModel->SetWantedMimeTypesL( iResourceReader );
       
  2105     iListModel->RefreshL();
       
  2106     iWait.Start();
       
  2107     if (iListModel->ItemCount() != 0)
       
  2108         {
       
  2109         ret = KErrUnknown;
       
  2110         }
       
  2111 
       
  2112 // incorrect resource version
       
  2113     ResourceL( R_MIME_TYPE_ARRAY_INCORRECT_VERSION );
       
  2114     TRAPD(error, iListModel->SetWantedMimeTypesL( iResourceReader ));
       
  2115     if (error != KErrNotSupported)
       
  2116         {
       
  2117         ret = KErrUnknown;
       
  2118         }
       
  2119 
       
  2120     return ret;
       
  2121     }
       
  2122 
       
  2123 // ---------------------------------------------------------------------------
       
  2124 // CContentListingFrameworkTest::SetWantedMediaTypesTestL
       
  2125 // ---------------------------------------------------------------------------
       
  2126 //
       
  2127 TInt CContentListingFrameworkTest::SetWantedMediaTypesTestL( CStifItemParser& /* aItem */ )
       
  2128     {
       
  2129     TInt ret = KErrNone;
       
  2130 
       
  2131     iTestObserver->iWait = &iWait;
       
  2132 
       
  2133 // list not defined (mediatype)
       
  2134     iListModel->RefreshL();
       
  2135     iWait.Start();
       
  2136     if (iListModel->ItemCount() != 0)
       
  2137         {
       
  2138         ret = KErrUnknown;
       
  2139         }
       
  2140 
       
  2141 // couple media types
       
  2142     iMediaTypeArray.AppendL( ECLFMediaTypeVideo );
       
  2143     iMediaTypeArray.AppendL( ECLFMediaTypeImage );
       
  2144     iMediaTypeArray.AppendL( ECLFMediaTypeSound );
       
  2145     iMediaTypeArray.AppendL( ECLFMediaTypeMusic );
       
  2146     iMediaTypeArray.AppendL( ECLFMediaTypeStreamingURL );
       
  2147     iMediaTypeArray.AppendL( ECLFMediaTypePlaylist );
       
  2148     iMediaTypeArray.AppendL( TCLFMediaType( ECLFMediaTypeCollection ) );
       
  2149 
       
  2150     iListModel->SetWantedMediaTypesL( iMediaTypeArray.Array() );
       
  2151     iListModel->RefreshL();
       
  2152     iWait.Start();
       
  2153     if ( !CheckFileTypesL( *iMimeTypeArray, iMediaTypeArray.Array() ) )
       
  2154         {
       
  2155         ret = KErrUnknown;
       
  2156         }
       
  2157 
       
  2158 // empty media type list list
       
  2159     iListModel->SetWantedMediaTypesL( iMediaTypeArray1.Array() );
       
  2160     iListModel->RefreshL();
       
  2161     iWait.Start();
       
  2162     if (iListModel->ItemCount() != 0)
       
  2163         {
       
  2164         ret = KErrUnknown;
       
  2165         }
       
  2166 
       
  2167 // media type list from resource
       
  2168     iMediaTypeArray.Reset();
       
  2169     iMediaTypeArray.AppendL( ECLFMediaTypeImage );
       
  2170     iMediaTypeArray.AppendL( TCLFMediaType( ECLFMediaTypeCollection ) );
       
  2171     ResourceL( R_MEDIA_TYPE_ARRAY );
       
  2172     iListModel->SetWantedMediaTypesL( iResourceReader );
       
  2173     iListModel->RefreshL();
       
  2174     iWait.Start();
       
  2175     if ( !CheckFileTypesL( *iMimeTypeArray, iMediaTypeArray.Array() ) )
       
  2176         {
       
  2177         ret = KErrUnknown;
       
  2178         }
       
  2179 
       
  2180 // empty media type list from resource
       
  2181     ResourceL( R_MEDIA_TYPE_ARRAY_EMPTY );
       
  2182     iListModel->SetWantedMediaTypesL( iResourceReader );
       
  2183     iListModel->RefreshL();
       
  2184     iWait.Start();
       
  2185     if (iListModel->ItemCount() != 0)
       
  2186         {
       
  2187         ret = KErrUnknown;
       
  2188         }
       
  2189 
       
  2190     return ret;
       
  2191     }
       
  2192 
       
  2193 // ---------------------------------------------------------------------------
       
  2194 // CContentListingFrameworkTest::SetWantedMediaAndMimeTypesTestL
       
  2195 // ---------------------------------------------------------------------------
       
  2196 //
       
  2197 TInt CContentListingFrameworkTest::SetWantedMediaAndMimeTypesTestL( CStifItemParser& /* aItem */ )
       
  2198     {
       
  2199     TInt ret = KErrNone;
       
  2200 
       
  2201     iTestObserver->iWait = &iWait;
       
  2202 
       
  2203     iListModel->RefreshL();
       
  2204     iWait.Start();
       
  2205     if (iListModel->ItemCount() != 0)
       
  2206         {
       
  2207         ret = KErrUnknown;
       
  2208         }
       
  2209 
       
  2210 // couple types
       
  2211     iMimeTypeArray->AppendL( _L( "audio/mpeg" ) );
       
  2212     iMimeTypeArray->AppendL( _L( "audio/aac" ) );
       
  2213     iMimeTypeArray->AppendL( _L( "audio/mp3" ) );
       
  2214     iMimeTypeArray->AppendL( _L( "audio/x-mp3" ) );
       
  2215     iMimeTypeArray->AppendL( _L( "audio/mp4" ) );
       
  2216     iMimeTypeArray->AppendL( _L( "audio/3gpp" ) );
       
  2217     iMimeTypeArray->AppendL( _L( "audio/m4a" ) );
       
  2218     iMimeTypeArray->AppendL( _L( "audio/3gpp2" ) );
       
  2219     iMimeTypeArray->AppendL( _L( "audio/mpeg4") );
       
  2220     iListModel->SetWantedMimeTypesL( *iMimeTypeArray );
       
  2221 
       
  2222     iMediaTypeArray.AppendL( ECLFMediaTypeVideo );
       
  2223     iListModel->SetWantedMediaTypesL( iMediaTypeArray.Array() );
       
  2224     iListModel->RefreshL();
       
  2225     iWait.Start();
       
  2226     if ( !CheckFileTypesL( *iMimeTypeArray, iMediaTypeArray.Array() ) )
       
  2227         {
       
  2228         ret = KErrUnknown;
       
  2229         }
       
  2230 
       
  2231 // refresh again
       
  2232     iListModel->RefreshL();
       
  2233     iWait.Start();
       
  2234     if ( !CheckFileTypesL( *iMimeTypeArray, iMediaTypeArray.Array() ) )
       
  2235         {
       
  2236         ret = KErrUnknown;
       
  2237         }
       
  2238 
       
  2239 // empty lists
       
  2240     iMediaTypeArray.Reset();
       
  2241     iMimeTypeArray->Reset();
       
  2242     iListModel->SetWantedMediaTypesL( iMediaTypeArray.Array() );
       
  2243     iListModel->SetWantedMimeTypesL( *iMimeTypeArray );
       
  2244     iListModel->RefreshL();
       
  2245     iWait.Start();
       
  2246     if (iListModel->ItemCount() != 0)
       
  2247         {
       
  2248         ret = KErrUnknown;
       
  2249         }
       
  2250 
       
  2251     return ret;
       
  2252     }
       
  2253 
       
  2254 // ---------------------------------------------------------------------------
       
  2255 // CContentListingFrameworkTest::MultibleSortingTestL
       
  2256 // ---------------------------------------------------------------------------
       
  2257 //
       
  2258 TInt CContentListingFrameworkTest::MultibleSortingTestL( CStifItemParser& /* aItem */ )
       
  2259     {
       
  2260     TInt ret = KErrNone;
       
  2261 
       
  2262     iListModel->RefreshL( ECLFRefreshAll );
       
  2263     if ( !CheckMultibleSortingShortingL() )
       
  2264         {
       
  2265         ret = KErrUnknown;
       
  2266         }
       
  2267 
       
  2268 // resort
       
  2269 
       
  2270     iSortingStyle->ResetL();
       
  2271     iSortingStyle->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  2272     iSortingStyle->AddFieldL( KMultibleSortingTestField6 );
       
  2273     iSortingStyle->AddFieldL( KMultibleSortingTestField5 );
       
  2274     iSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd );
       
  2275     iListModel->SetSortingStyle( iSortingStyle );
       
  2276     iListModel->RefreshL( ECLFRefreshAll );
       
  2277     if ( CheckMultibleSortingShortingL() )
       
  2278         {
       
  2279         ret = KErrUnknown;
       
  2280         }
       
  2281 
       
  2282     return ret;
       
  2283     }
       
  2284 
       
  2285 /*
       
  2286 * Test model item(s) obsolate functionality
       
  2287 */
       
  2288 
       
  2289 // ---------------------------------------------------------------------------
       
  2290 // ModelItemsChangedTestL
       
  2291 // ---------------------------------------------------------------------------
       
  2292 //
       
  2293 TInt CContentListingFrameworkTest::ModelItemsChangedTestL( CStifItemParser& /* aItem */ )
       
  2294     {
       
  2295     TInt ret = KErrNone;
       
  2296 
       
  2297     const TInt newFileNumber( 13 );
       
  2298 
       
  2299 // create test files
       
  2300     CreateNewFileL( 9, iFileName );
       
  2301     CreateNewFileL( 10, iFileName );
       
  2302     CreateNewFileL( 11, iFileName );
       
  2303     CreateNewFileL( newFileNumber, iFileName );
       
  2304     User::LeaveIfError( iFs.Delete( iFileName ) );
       
  2305 
       
  2306 // update server
       
  2307 // to aTInt incorrect test result
       
  2308     CreateNewFileL( 0, iFileName );
       
  2309     iEngine->UpdateItemsL();
       
  2310 
       
  2311 // create list model with all files
       
  2312     iMimeTypeArray->Reset();
       
  2313     iMimeTypeArray->AppendL( _L("*") );
       
  2314     iListModel->SetWantedMimeTypesL( *iMimeTypeArray );
       
  2315 
       
  2316     iTestObserver->iWait = &iWait;
       
  2317     iTestObserver->iError = 100;
       
  2318     iListModel->RefreshL();
       
  2319     iWait.Start();  // wait until model is refreshed
       
  2320 
       
  2321     if ( iTestObserver->iOperationEvent != ECLFRefreshComplete
       
  2322          || iTestObserver->iError != KErrNone
       
  2323          || iListModel->ItemCount() != 0 )
       
  2324         {
       
  2325         ret = KErrUnknown;
       
  2326         }
       
  2327 
       
  2328     const TInt listModelItemCount( iListModel->ItemCount() );
       
  2329     const TCLFItemId testId( FindTestFileIdL( 0 ) );
       
  2330 
       
  2331 // test with modified item
       
  2332     CreateNewFileL( 0, iFileName );
       
  2333     iEngine->UpdateItemsL();
       
  2334     iWait.Start(); // wait until model outdated event is received
       
  2335 
       
  2336     if ( iTestObserver->iOperationEvent != ECLFModelOutdated
       
  2337          || iTestObserver->iError != KErrNone
       
  2338          || iListModel->ItemCount() != listModelItemCount
       
  2339          || FindItem( *iListModel, testId ) == NULL )
       
  2340         {
       
  2341         ret = KErrUnknown;
       
  2342         }
       
  2343 
       
  2344     iTestObserver->iError = 100;
       
  2345     iListModel->RefreshL();
       
  2346     iWait.Start();  // wait until model is refreshed
       
  2347     if ( iTestObserver->iOperationEvent != ECLFRefreshComplete
       
  2348          || iTestObserver->iError != KErrNone
       
  2349          || iListModel->ItemCount() != listModelItemCount
       
  2350          || FindItem( *iListModel, testId ) == NULL )
       
  2351         {
       
  2352         ret = KErrUnknown;
       
  2353         }
       
  2354 
       
  2355 // test with new item
       
  2356     CreateNewFileL( newFileNumber, iFileName );
       
  2357     iEngine->UpdateItemsL();
       
  2358     iWait.Start(); // wait until model outdated event is received
       
  2359 
       
  2360     if ( iTestObserver->iOperationEvent != ECLFModelOutdated
       
  2361          || iTestObserver->iError != KErrNone
       
  2362          || iListModel->ItemCount() != listModelItemCount )
       
  2363         {
       
  2364         ret = KErrUnknown;
       
  2365         }
       
  2366 
       
  2367     iTestObserver->iError = 100;
       
  2368     iListModel->RefreshL();
       
  2369     iWait.Start();  // wait until model is refreshed
       
  2370     if ( iTestObserver->iOperationEvent != ECLFRefreshComplete
       
  2371          || iTestObserver->iError != KErrNone
       
  2372          || iListModel->ItemCount() != listModelItemCount + 1 )
       
  2373         {
       
  2374         ret = KErrUnknown;
       
  2375         }
       
  2376 
       
  2377 // delete file
       
  2378     User::LeaveIfError( iFs.Delete( iFileName ) );
       
  2379     iEngine->UpdateItemsL();
       
  2380     iWait.Start(); // wait until model outdated event is received
       
  2381 
       
  2382     if ( iTestObserver->iOperationEvent != ECLFModelOutdated
       
  2383          || iTestObserver->iError != KErrNone
       
  2384          || iListModel->ItemCount() != listModelItemCount + 1 )
       
  2385         {
       
  2386         ret = KErrUnknown;
       
  2387         }
       
  2388 
       
  2389     iTestObserver->iError = 100;
       
  2390     iListModel->RefreshL();
       
  2391     iWait.Start();  // wait until model is refreshed
       
  2392     if ( iTestObserver->iOperationEvent != ECLFRefreshComplete
       
  2393          || iTestObserver->iError != KErrNone
       
  2394          || iListModel->ItemCount() != listModelItemCount )
       
  2395         {
       
  2396         ret = KErrUnknown;
       
  2397         }
       
  2398 
       
  2399     return ret;
       
  2400     }
       
  2401 
       
  2402 /**
       
  2403  * Tests, Modifiable item
       
  2404  */
       
  2405 
       
  2406 // ---------------------------------------------------------------------------
       
  2407 // CContentListingFrameworkTest::MIFieldTestL
       
  2408 // ---------------------------------------------------------------------------
       
  2409 // 
       
  2410 TInt CContentListingFrameworkTest::MIFieldTestL( CStifItemParser& /* aItem */ )
       
  2411     {
       
  2412     TInt ret = KErrNone;
       
  2413 
       
  2414     const TUint KTestField1 = 1;
       
  2415     const TUint KTestField2 = 112312312;
       
  2416     const TUint KTestField3 = 13333;
       
  2417     const TUint KTestFieldIncorrect = 2;
       
  2418 
       
  2419     TTime time( 100 );
       
  2420     TInt32 integer( 12 );
       
  2421     TBuf<30> data( _L("data") );
       
  2422     iModifiableItem->AddFieldL( KTestField1, time );
       
  2423     iModifiableItem->AddFieldL( KTestField2, integer );
       
  2424     iModifiableItem->AddFieldL( KTestField3, data );
       
  2425 
       
  2426 // data type test
       
  2427     if ( iModifiableItem->DataType( KTestField1 ) != ECLFItemDataTypeTTime
       
  2428          || iModifiableItem->DataType( KTestField2 ) != ECLFItemDataTypeTInt32
       
  2429          || iModifiableItem->DataType( KTestField3 ) != ECLFItemDataTypeDesC
       
  2430          || iModifiableItem->DataType( KTestFieldIncorrect ) != ECLFItemDataTypeNull
       
  2431          || iModifiableItem->DataType( ECLFFieldIdNull ) != ECLFItemDataTypeNull )
       
  2432         {
       
  2433         ret = KErrUnknown;
       
  2434         }
       
  2435 
       
  2436 // get field
       
  2437     TTime time1( 0 );
       
  2438     TInt32 integer1( 0 );
       
  2439     TPtrC ptr;
       
  2440     if ( iModifiableItem->GetField( KTestField1, time1 ) != KErrNone
       
  2441          || time != time1 )
       
  2442         {
       
  2443         ret = KErrUnknown;
       
  2444         }
       
  2445     if ( iModifiableItem->GetField( KTestField2, integer1 ) != KErrNone
       
  2446          || integer != integer1 )
       
  2447         {
       
  2448         ret = KErrUnknown;
       
  2449         }
       
  2450     if ( iModifiableItem->GetField( KTestField3, ptr ) != KErrNone
       
  2451          || data != ptr )
       
  2452         {
       
  2453         ret = KErrUnknown;
       
  2454         }
       
  2455 
       
  2456 // incorrect field id
       
  2457     if ( iModifiableItem->GetField( KTestFieldIncorrect, ptr ) != KErrNotFound
       
  2458          || iModifiableItem->GetField( KTestFieldIncorrect, integer1 ) != KErrNotFound
       
  2459          || iModifiableItem->GetField( KTestFieldIncorrect, time1 ) != KErrNotFound )
       
  2460         {
       
  2461         ret = KErrUnknown;
       
  2462         }
       
  2463 
       
  2464 // incorrect field type
       
  2465     if ( iModifiableItem->GetField( KTestField1, ptr ) != KErrNotFound
       
  2466          || iModifiableItem->GetField( KTestField3, integer1 ) != KErrNotFound
       
  2467          || iModifiableItem->GetField( KTestField2, time1 ) != KErrNotFound )
       
  2468         {
       
  2469         ret = KErrUnknown;
       
  2470         }
       
  2471 
       
  2472     if ( iModifiableItem->ItemId() == 0 )
       
  2473         {
       
  2474         ret = KErrUnknown;
       
  2475         }
       
  2476 
       
  2477     return ret;
       
  2478     }
       
  2479 
       
  2480 /**
       
  2481  * Tests, item
       
  2482  */
       
  2483 
       
  2484 // ---------------------------------------------------------------------------
       
  2485 // CContentListingFrameworkTest::ItemFieldTestL
       
  2486 // ---------------------------------------------------------------------------
       
  2487 // 
       
  2488 TInt CContentListingFrameworkTest::ItemFieldTestL( CStifItemParser& /* aItem */ )
       
  2489     {
       
  2490     TInt ret = KErrNone;
       
  2491 
       
  2492 // data type test
       
  2493     if ( iItem->DataType( ECLFFieldIdFileDate ) != ECLFItemDataTypeTTime
       
  2494          || iItem->DataType( ECLFFieldIdFileSize ) != ECLFItemDataTypeTInt32
       
  2495          || iItem->DataType( ECLFFieldIdFileNameAndPath ) != ECLFItemDataTypeDesC
       
  2496          || iItem->DataType( ECLFFieldIdNull ) != ECLFItemDataTypeNull )
       
  2497         {
       
  2498         ret = KErrUnknown;
       
  2499         }
       
  2500 
       
  2501 // get field
       
  2502     TTime time1( 0 );
       
  2503     TInt32 integer1( 0 );
       
  2504     TPtrC ptr;
       
  2505     TEntry entry;
       
  2506     User::LeaveIfError( iFs.Entry( iFileName, entry ) );
       
  2507 
       
  2508     if ( iModifiableItem->GetField( ECLFFieldIdFileDate, time1 ) != KErrNone
       
  2509          || entry.iModified != time1 )
       
  2510         {
       
  2511         ret = KErrUnknown;
       
  2512         }
       
  2513     if ( iModifiableItem->GetField( ECLFFieldIdFileSize, integer1 ) != KErrNone
       
  2514          || entry.iSize != integer1 )
       
  2515         {
       
  2516         ret = KErrUnknown;
       
  2517         }
       
  2518     if ( iModifiableItem->GetField( ECLFFieldIdFileNameAndPath, ptr ) != KErrNone
       
  2519          || iFileName != ptr )
       
  2520         {
       
  2521         ret = KErrUnknown;
       
  2522         }
       
  2523 
       
  2524     TParsePtrC parse( iFileName );
       
  2525 
       
  2526     if ( iModifiableItem->GetField( ECLFFieldIdFileExtension, ptr ) != KErrNone
       
  2527          || parse.Ext() != ptr )
       
  2528         {
       
  2529         ret = KErrUnknown;
       
  2530         }
       
  2531     if ( iModifiableItem->GetField( ECLFFieldIdFileName, ptr ) != KErrNone
       
  2532          || parse.Name() != ptr )
       
  2533         {
       
  2534         ret = KErrUnknown;
       
  2535         }
       
  2536     if ( iModifiableItem->GetField( ECLFFieldIdPath, ptr ) != KErrNone
       
  2537          || parse.Path() != ptr )
       
  2538         {
       
  2539         ret = KErrUnknown;
       
  2540         }
       
  2541     if ( iModifiableItem->GetField( ECLFFieldIdDrive, ptr ) != KErrNone
       
  2542          || parse.Drive() != ptr )
       
  2543         {
       
  2544         ret = KErrUnknown;
       
  2545         }
       
  2546 
       
  2547 // incorrect field id
       
  2548     if ( iItem->GetField( ECLFFieldIdNull, ptr ) != KErrNotFound
       
  2549          || iItem->GetField( ECLFFieldIdNull, integer1 ) != KErrNotFound
       
  2550          || iItem->GetField( ECLFFieldIdNull, time1 ) != KErrNotFound )
       
  2551         {
       
  2552         ret = KErrUnknown;
       
  2553         }
       
  2554 
       
  2555 // incorrect field type
       
  2556     if ( iItem->GetField( ECLFFieldIdFileSize, ptr ) != KErrNotSupported
       
  2557          || iItem->GetField( ECLFFieldIdFileDate, integer1 ) != KErrNotSupported
       
  2558          || iItem->GetField( ECLFFieldIdFileNameAndPath, time1 ) != KErrNotSupported )
       
  2559         {
       
  2560         ret = KErrUnknown;
       
  2561         }
       
  2562 
       
  2563     if ( iItem->ItemId() == 0 )
       
  2564         {
       
  2565         ret = KErrUnknown;
       
  2566         }
       
  2567 
       
  2568     return ret;
       
  2569     }
       
  2570 
       
  2571 /**
       
  2572  * Tests, Sorting style
       
  2573  */
       
  2574 
       
  2575 // ---------------------------------------------------------------------------
       
  2576 // CContentListingFrameworkTest::SortingStyleResourceTestL
       
  2577 // ---------------------------------------------------------------------------
       
  2578 //  
       
  2579 TInt CContentListingFrameworkTest::SortingStyleResourceTestL( CStifItemParser& /* aItem */ )
       
  2580     {
       
  2581     TInt ret = KErrNone;
       
  2582 
       
  2583     const TInt KArray1IdCount( 4 );
       
  2584     const TInt KArray2IdCount( 1 );
       
  2585 
       
  2586 
       
  2587     RArray<TCLFItemId> itemIdArray;
       
  2588     CleanupClosePushL( itemIdArray );
       
  2589 
       
  2590     if ( iSortingStyle->Ordering() != ECLFOrderingAscending
       
  2591          || iSortingStyle1->Ordering() != ECLFOrderingDescending
       
  2592          || iSortingStyle2->Ordering() != ECLFOrderingDescending )
       
  2593         {
       
  2594         ret = KErrUnknown;
       
  2595         }
       
  2596     if ( iSortingStyle->SortingDataType() != ECLFItemDataTypeTInt32
       
  2597          || iSortingStyle1->SortingDataType() != ECLFItemDataTypeDesC
       
  2598          || iSortingStyle2->SortingDataType() != ECLFItemDataTypeDesC )
       
  2599         {
       
  2600         ret = KErrUnknown;
       
  2601         }
       
  2602 
       
  2603     iSortingStyle->GetFieldsL( itemIdArray );
       
  2604 
       
  2605     if ( itemIdArray.Count() != 0 )
       
  2606         {
       
  2607         ret = KErrUnknown;
       
  2608         }
       
  2609 
       
  2610     itemIdArray.Reset();
       
  2611     iSortingStyle1->GetFieldsL( itemIdArray );
       
  2612 
       
  2613     if ( itemIdArray.Count() != KArray1IdCount )
       
  2614         {
       
  2615         ret = KErrUnknown;
       
  2616         }
       
  2617 
       
  2618     itemIdArray.Reset();
       
  2619     iSortingStyle2->GetFieldsL( itemIdArray );
       
  2620 
       
  2621     if ( itemIdArray.Count() != KArray2IdCount )
       
  2622         {
       
  2623         ret = KErrUnknown;
       
  2624         }
       
  2625 
       
  2626     CleanupStack::PopAndDestroy( &itemIdArray ); // itemIdArray.Close
       
  2627 
       
  2628     return ret;
       
  2629     }
       
  2630 
       
  2631 // ---------------------------------------------------------------------------
       
  2632 // CContentListingFrameworkTest::SortingStyleOrderingTestL
       
  2633 // ---------------------------------------------------------------------------
       
  2634 // 
       
  2635 TInt CContentListingFrameworkTest::SortingStyleOrderingTestL( CStifItemParser& /* aItem */ )
       
  2636     {
       
  2637     TInt ret = KErrNone;
       
  2638 
       
  2639     iSortingStyle->SetOrdering( ECLFOrderingAscending );
       
  2640     if ( iSortingStyle->Ordering() != ECLFOrderingAscending )
       
  2641         {
       
  2642         ret = KErrUnknown;
       
  2643         }
       
  2644 
       
  2645     iSortingStyle->SetOrdering( ECLFOrderingDescending );
       
  2646     if ( iSortingStyle->Ordering() != ECLFOrderingDescending )
       
  2647         {
       
  2648         ret = KErrUnknown;
       
  2649         }
       
  2650 
       
  2651     iSortingStyle->SetOrdering( ECLFOrderingAscending );
       
  2652     if ( iSortingStyle->Ordering() != ECLFOrderingAscending )
       
  2653         {
       
  2654         ret = KErrUnknown;
       
  2655         }
       
  2656 
       
  2657     return ret;
       
  2658     }
       
  2659 
       
  2660 // ---------------------------------------------------------------------------
       
  2661 // CContentListingFrameworkTest::SortingStyleDataTypeTestL
       
  2662 // ---------------------------------------------------------------------------
       
  2663 // 
       
  2664 TInt CContentListingFrameworkTest::SortingStyleDataTypeTestL( CStifItemParser& /* aItem */ )
       
  2665     {
       
  2666     TInt ret = KErrNone;
       
  2667 
       
  2668     iSortingStyle->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  2669     if ( iSortingStyle->SortingDataType() != ECLFItemDataTypeTInt32 )
       
  2670         {
       
  2671         ret = KErrUnknown;
       
  2672         }
       
  2673 
       
  2674     iSortingStyle->SetSortingDataType( ECLFItemDataTypeDesC );
       
  2675     if ( iSortingStyle->SortingDataType() != ECLFItemDataTypeDesC )
       
  2676         {
       
  2677         ret = KErrUnknown;
       
  2678         }
       
  2679 
       
  2680     iSortingStyle->SetSortingDataType( ECLFItemDataTypeTTime );
       
  2681     if ( iSortingStyle->SortingDataType() != ECLFItemDataTypeTTime )
       
  2682         {
       
  2683         ret = KErrUnknown;
       
  2684         }
       
  2685 
       
  2686     iSortingStyle->SetSortingDataType( ECLFItemDataTypeNull );
       
  2687     if ( iSortingStyle->SortingDataType() != ECLFItemDataTypeNull )
       
  2688         {
       
  2689         ret = KErrUnknown;
       
  2690         }
       
  2691 
       
  2692     iSortingStyle->SetSortingDataType( ECLFItemDataTypeTInt32 );
       
  2693     if ( iSortingStyle->SortingDataType() != ECLFItemDataTypeTInt32 )
       
  2694         {
       
  2695         ret = KErrUnknown;
       
  2696         }
       
  2697 
       
  2698     return ret;
       
  2699     }
       
  2700 
       
  2701 // ---------------------------------------------------------------------------
       
  2702 // CContentListingFrameworkTest::SortingStyleUndefinedItemPositionTestL
       
  2703 // ---------------------------------------------------------------------------
       
  2704 // 
       
  2705 TInt CContentListingFrameworkTest::SortingStyleUndefinedItemPositionTestL( CStifItemParser& /* aItem */ )
       
  2706     {
       
  2707     TInt ret = KErrNone;
       
  2708 
       
  2709     iSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd );
       
  2710     if ( iSortingStyle->UndefinedItemPosition() != ECLFSortingStyleUndefinedEnd )
       
  2711         {
       
  2712         ret = KErrUnknown;
       
  2713         }
       
  2714 
       
  2715     iSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedFirst );
       
  2716     if ( iSortingStyle->UndefinedItemPosition() != ECLFSortingStyleUndefinedFirst )
       
  2717         {
       
  2718         ret = KErrUnknown;
       
  2719         }
       
  2720 
       
  2721     iSortingStyle->SetUndefinedItemPosition( ECLFSortingStyleUndefinedEnd );
       
  2722     if ( iSortingStyle->UndefinedItemPosition() != ECLFSortingStyleUndefinedEnd )
       
  2723         {
       
  2724         ret = KErrUnknown;
       
  2725         }
       
  2726 
       
  2727     return ret;
       
  2728     }
       
  2729 
       
  2730 // ---------------------------------------------------------------------------
       
  2731 // CContentListingFrameworkTest::SortingStyleFieldTestL
       
  2732 // ---------------------------------------------------------------------------
       
  2733 // 
       
  2734 TInt CContentListingFrameworkTest::SortingStyleFieldTestL( CStifItemParser& /* aItem */ )
       
  2735     {
       
  2736     TInt ret = KErrNone;
       
  2737 
       
  2738     RArray<TCLFItemId> itemIdArray;
       
  2739     CleanupClosePushL( itemIdArray );
       
  2740 
       
  2741     iSortingStyle->GetFieldsL( itemIdArray );
       
  2742     if ( itemIdArray.Count() != 0 )
       
  2743         {
       
  2744         ret = KErrUnknown;
       
  2745         }
       
  2746 
       
  2747     iSortingStyle->AddFieldL( ECLFFieldIdFileName );
       
  2748     iSortingStyle->AddFieldL( ECLFFieldIdCollectionId );
       
  2749     iSortingStyle->AddFieldL( ECLFFieldIdCollectionName );
       
  2750     iSortingStyle->AddFieldL( ECLFFieldIdArtist );
       
  2751 
       
  2752     iSortingStyle->GetFieldsL( itemIdArray );
       
  2753 
       
  2754     if ( itemIdArray.Count() != 4 )
       
  2755         {
       
  2756         ret = KErrUnknown;
       
  2757         }
       
  2758 
       
  2759     itemIdArray.Reset();
       
  2760     iSortingStyle->ResetL();
       
  2761     iSortingStyle->GetFieldsL( itemIdArray );
       
  2762     if ( itemIdArray.Count() != 0 )
       
  2763         {
       
  2764         ret = KErrUnknown;
       
  2765         }
       
  2766 
       
  2767     CleanupStack::PopAndDestroy( &itemIdArray ); // itemIdArray.Close
       
  2768 
       
  2769     return ret;
       
  2770     }
       
  2771 
       
  2772 //  [End of File] - Do not remove