mmappfw_plat/harvester_collection_mediator_api/tsrc/HarvesterCollectionMediatorTest/src/HarvesterCollectionMediatorTestBlocks.cpp
changeset 0 a2952bb97e68
child 20 4aca42fa4eb1
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  HarvesterCollectionMediatorTestBlocks.cpp
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES] - do not remove
       
    21 #include <e32svr.h>
       
    22 #include <StifParser.h>
       
    23 #include <Stiftestinterface.h>
       
    24 #include "HarvesterCollectionMediatorTest.h"
       
    25 
       
    26 #include <mpxmedia.h>
       
    27 #include <mpxmediageneraldefs.h>//to get KMPXMediaIdGeneral\EMPXSong\TMPXGeneralCategory\KMPXMediaGeneralCategory
       
    28 #include <mpxmediaaudiodefs.h>//to get KMPXMediaIdAudio
       
    29 #include <mpxmediamusicdefs.h>//to get KMPXMediaIdMusic 
       
    30 #include <mpxmediadrmdefs.h>//to get KMPXMediaIdDrm 
       
    31 #include "mpxcollectionpath.h"
       
    32 #include <mpxmediamusicdefs.h>
       
    33 #include <mpxmediageneraldefs.h>
       
    34 #include <mpxcollectionplugin.hrh>
       
    35 
       
    36 //#include <mpxcollectionutilityimpl.h>
       
    37 //#include <mpxcollectionmediator.h>
       
    38 #include <mpxcollectionutility.h>
       
    39 #include "HarvesterCollectionMediatorTest.h"
       
    40 //class CMPXCollectionMediator;
       
    41 
       
    42 class CMPXMedia;
       
    43 class MMPXCollection;
       
    44 
       
    45 _LIT( KTestFileMimeType, "audio/aac" );
       
    46 
       
    47 class SonOfMMPXCollection:public MMPXCollection
       
    48 	{
       
    49 	virtual void OpenL(TMPXOpenMode /*aMode=EMPXOpenDefault*/)
       
    50 		{
       
    51 		//iLog->Log(_L("OpenL with a mode is called"));
       
    52 		};
       
    53     virtual void OpenL(TInt/* aIndex*/,TMPXOpenMode /*aMode=EMPXOpenDefault*/){
       
    54     //iLog->Log(_L("OpenL with 2 paras is called");
       
    55     }; 
       
    56     virtual void OpenL(const CMPXCollectionPath& /*aPath*/,
       
    57                        TMPXOpenMode /*aMode=EMPXOpenDefault*/){
       
    58                        //iLog->Log(_L("OpenL with a path is called");
       
    59                        };
       
    60     virtual void OpenL(TInt /*aIndex*/,
       
    61                        const TArray<TMPXAttribute>&/* aAttrs*/,
       
    62                        TMPXOpenMode /*aMode=EMPXOpenDefault*/){
       
    63                        //iLog->Log(_L("OpenL with 3 paras is called"));
       
    64                        };
       
    65     virtual void OpenL(const CMPXCollectionPath& /*aPath*/,
       
    66                        const TArray<TMPXAttribute>& /*aAttrs*/,
       
    67                        TMPXOpenMode/* aMode=EMPXOpenDefault*/){
       
    68                        //iLog->Log(_L("OpenL with 3 paras2 is called"));
       
    69                        };  
       
    70     virtual void OpenL(const TArray<TUid>& /*aUids*/,
       
    71                        TMPXOpenMode/* aMode=EMPXOpenDefault*/){
       
    72                        //iLog->Log(_L("OpenL with a mode is called"));
       
    73                        };  
       
    74     virtual void OpenL(const TUid& /*aUid*/,
       
    75                        TMPXOpenMode /*aMode=EMPXOpenDefault*/){};  
       
    76     virtual void SetFilterL(CMPXFilter* /*aFilter*/){};
       
    77     virtual CMPXFilter* FilterL(){return NULL;};  
       
    78     virtual TUid UidL() const{return TUid::Null();};  
       
    79     virtual CMPXCollectionPath* PathL(){return NULL;};  
       
    80     virtual void BackL(){};  
       
    81     virtual TBool IsRemote(const CMPXCollectionPath& /*aPath*/){return NULL;};  
       
    82     virtual void CancelRequest(){};
       
    83     virtual void AddL(const CMPXMedia& /*aNewMedia*/){}; 
       
    84     virtual void RemoveL(const CMPXCollectionPath& /*aPath*/,
       
    85                          MMPXCollectionRemoveObserver* /*aObs = NULL*/ ){};
       
    86     virtual void RemoveL(const CMPXMedia& /*aMedia*/){}; 
       
    87     virtual void SetSyncL(const CMPXMedia&/* aMedia*/){};  
       
    88     virtual void SetL(const CMPXMedia& /*aMedia*/){}; 
       
    89     virtual void FindAllL(const CMPXSearchCriteria& /*aCriteria*/,
       
    90                           const TArray<TMPXAttribute>&/* aAttrs*/,
       
    91                           MMPXCollectionFindObserver& /*aObs*/){};   
       
    92     virtual CMPXMedia* FindAllL(const CMPXSearchCriteria&/* aCriteria*/,
       
    93                                 const TArray<TMPXAttribute>& /*aAttrs*/){return NULL;};  
       
    94     virtual void MediaL(const CMPXCollectionPath&/* aPath*/,
       
    95                         const TArray<TMPXAttribute>& /*aAttrs*/,
       
    96                         CMPXAttributeSpecs* /*aSpecs=NULL*/,
       
    97                         CMPXFilter* /*aFilter=NULL*/){};
       
    98     virtual void NotifyL(TMPXCollectionBroadCastMsg /*aMsg*/, TInt /*aData*/){};
       
    99     virtual void CommandL(TMPXCollectionCommand /*aCmd*/, TInt /*aData = 0*/){};
       
   100     virtual void CommandL(CMPXCommand&/* aCmd*/){};
       
   101     virtual void GetSupportedTypesL(RPointerArray<CMPXCollectionType>& /*aArray*/){};
       
   102     virtual void GetSupportedCapabilitiesL(TCollectionCapability& /*aCapability*/){};
       
   103     virtual TUid CollectionIDL(TUid& /*aCollection*/){return TUid::Null();}
       
   104     virtual void AddSubscriptionL(const CMPXSubscription& /*aSubscription*/){};
       
   105     virtual void RemoveSubscriptionL(const CMPXSubscription& /*aSubscription*/){};
       
   106     virtual void ClearSubscriptionsL(){};
       
   107 	};
       
   108 
       
   109 
       
   110 
       
   111 
       
   112 // ============================ MEMBER FUNCTIONS ===============================
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CHarvesterCollectionMediatorTest::Delete
       
   116 // Delete here all resources allocated and opened from test methods. 
       
   117 // Called from destructor. 
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CHarvesterCollectionMediatorTest::Delete() 
       
   121     {
       
   122     
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CHarvesterCollectionMediatorTest::RunMethodL
       
   127 // Run specified method. Contains also table of test mothods and their names.
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 TInt CHarvesterCollectionMediatorTest::RunMethodL( 
       
   131     CStifItemParser& aItem ) 
       
   132     {
       
   133 
       
   134     static TStifFunctionInfo const KFunctions[] =
       
   135         {  
       
   136         // Copy this line for every implemented function.
       
   137         // First string is the function name used in TestScripter script file.
       
   138         // Second is the actual implementation member function. 
       
   139         ENTRY( "Example", CHarvesterCollectionMediatorTest::ExampleL ),
       
   140         ENTRY( "CMPXCollectionMediatorNewL", CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewL ),
       
   141         ENTRY( "CMPXCollectionMediatorNewLC", CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLC ),       
       
   142         ENTRY( "CMPXCollectionMediatorNewLWithMPXCollection", CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLWithMPXCollection ),
       
   143         ENTRY( "CMPXCollectionMediatorDestruction", CHarvesterCollectionMediatorTest::CMPXCollectionMediatorDestruction ),
       
   144         ENTRY( "CMPXCollectionMediatorAddItemLMedia", CHarvesterCollectionMediatorTest::CMPXCollectionMediatorAddItemLMedia ),
       
   145         ENTRY( "CMPXCollectionAddItemLCMPXMediaArray", CHarvesterCollectionMediatorTest::CMPXCollectionAddItemLCMPXMediaArray ),
       
   146         ENTRY( "CMPXCollectionSetItemLByCMPXMedia", CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMedia ),
       
   147         ENTRY( "CMPXCollectionSetItemLByCMPXMediaArray", CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMediaArray ),        
       
   148         ENTRY( "CMPXCollectionSetItemL", CHarvesterCollectionMediatorTest::CMPXCollectionSetItemL ),
       
   149         ENTRY( "CMPXCollectionCheckItemL", CHarvesterCollectionMediatorTest::CMPXCollectionCheckItemL ),
       
   150         ENTRY( "CMPXCollectionMoveItemLwith3paras", CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith3paras ),
       
   151         ENTRY( "CMPXCollectionMoveItemLwith4paras", CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith4paras ),
       
   152         ENTRY( "CMPXCollectionMediatorWithRealCollection", CHarvesterCollectionMediatorTest::CMPXCollectionMediatorWithRealCollection ), 
       
   153         //ADD NEW ENTRY HERE
       
   154         // [test cases entries] - Do not remove
       
   155 
       
   156         };
       
   157 
       
   158     const TInt count = sizeof( KFunctions ) / 
       
   159                         sizeof( TStifFunctionInfo );
       
   160 
       
   161     return RunInternalL( KFunctions, count, aItem );
       
   162 
       
   163     }
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CHarvesterCollectionMediatorTest::ExampleL
       
   167 // Example test method function.
       
   168 // (other items were commented in a header).
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 TInt CHarvesterCollectionMediatorTest::ExampleL( CStifItemParser& aItem )
       
   172     {
       
   173 
       
   174     // Print to UI
       
   175     _LIT( KHarvesterCollectionMediatorTest, "HarvesterCollectionMediatorTest" );
       
   176     _LIT( KExample, "In Example" );
       
   177     TestModuleIf().Printf( 0, KHarvesterCollectionMediatorTest, KExample );
       
   178     // Print to log file
       
   179     iLog->Log( KExample );
       
   180 
       
   181     TInt i = 0;
       
   182     TPtrC string;
       
   183     _LIT( KParam, "Param[%i]: %S" );
       
   184     while ( aItem.GetNextString ( string ) == KErrNone )
       
   185         {
       
   186         TestModuleIf().Printf( i, KHarvesterCollectionMediatorTest, 
       
   187                                 KParam, i, &string );
       
   188         i++;
       
   189         }
       
   190 
       
   191     return KErrNone;
       
   192 
       
   193     }
       
   194 
       
   195 // -----------------------------------------------------------------------------
       
   196 // CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewL
       
   197 // Example test method function.
       
   198 // (other items were commented in a header).
       
   199 // -----------------------------------------------------------------------------
       
   200 //--------debug pass
       
   201 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewL( CStifItemParser&/* aItem*/ )
       
   202 	{	
       
   203     iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewL testing CMPXCollectionMediator::NewL() begin") );
       
   204     TInt err = KErrNone;
       
   205     TRAP( err,iMediator = CMPXCollectionMediator::NewL() )
       
   206     if( err != KErrNone )
       
   207    	   {
       
   208    	   iLog->Log( _L("CMPXCollectionMediatorNewL returns a error %d"),err );
       
   209    	   }
       
   210     else 
       
   211 	   {
       
   212        iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewL testing CMPXCollectionMediator::NewL() End") );
       
   213        }
       
   214     return err;
       
   215  	}
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CHarvesterCollectionMediatorTest::CMPXCollectionMediatorDestruction
       
   219 // Example test method function.
       
   220 // (other items were commented in a header).
       
   221 // -----------------------------------------------------------------------------
       
   222 //----debug   pass
       
   223 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMediatorDestruction( CStifItemParser&/* aItem*/ )
       
   224 	{
       
   225 	 TInt err = KErrNone;
       
   226      delete iMediator;
       
   227      iMediator = NULL;
       
   228 	 iLog->Log(_L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorDestruction testing ~CMPXCollectionMediator end err=%d"), err);
       
   229 	 return err;
       
   230  	}
       
   231 
       
   232 
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLWithMPXCollection
       
   236 // Example test method function.
       
   237 // (other items were commented in a header).
       
   238 // -----------------------------------------------------------------------------
       
   239 //-----debug pass
       
   240 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLWithMPXCollection( CStifItemParser&/* aItem*/ )
       
   241 	{
       
   242 	
       
   243     iLog->Log(_L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLWithMPXCollection testing CMPXCollectionMediator::NewL() begin"));
       
   244     TInt err=KErrNone;
       
   245     
       
   246     iCollectionUtility = MMPXCollectionUtility::NewL( );
       
   247     TRAP( err,iMediator = CMPXCollectionMediator::NewL( iCollectionUtility->Collection() ) );
       
   248     if( err != KErrNone )
       
   249    	   {
       
   250    	   iLog->Log( _L("CMPXCollectionMediatorNewLWithMPXCollection returns a error %d"),err );
       
   251    	   }
       
   252     else 
       
   253 	   {
       
   254        iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLWithMPXCollection testing CMPXCollectionMediator::NewL() End") );
       
   255        }    
       
   256     iCollectionUtility->Close();
       
   257     return err;
       
   258  	}
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLC
       
   262 // Example test method function.
       
   263 // (other items were commented in a header).
       
   264 // -----------------------------------------------------------------------------
       
   265 //-----debug pass---->crash  17,10,2008
       
   266 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLC( CStifItemParser&/* aItem*/ )
       
   267 	{
       
   268 	iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLC testing CMPXCollectionMediator::NewLC() begin") );
       
   269     TInt err = KErrNone;
       
   270     iCollectionUtility = MMPXCollectionUtility::NewL( );
       
   271     iMediator = CMPXCollectionMediator::NewLC( iCollectionUtility->Collection() );
       
   272     CleanupStack::Pop( iMediator );
       
   273     iCollectionUtility->Close();
       
   274     iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorNewLC testing CMPXCollectionMediator::NewLC() End") );
       
   275     return err;
       
   276  	}
       
   277 
       
   278 
       
   279 // -----------------------------------------------------------------------------
       
   280 // CHarvesterCollectionMediatorTest::CMPXCollectionMediatorAddItemLMedia
       
   281 // Example test method function.
       
   282 // (other items were commented in a header).
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMediatorAddItemLMedia( CStifItemParser&/* aItem*/ )
       
   286 	{
       
   287 	
       
   288     iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorAddItemLMedia testing CMPXCollectionMediator::AddItemL() begin") );
       
   289     TInt err=KErrNone;
       
   290     RArray<TInt> contentIDs;
       
   291     contentIDs.AppendL( KMPXMediaIdGeneral );
       
   292     contentIDs.AppendL( KMPXMediaIdAudio );
       
   293     contentIDs.AppendL( KMPXMediaIdMusic ); 
       
   294     contentIDs.AppendL( KMPXMediaIdDrm ); 
       
   295     CMPXMedia* media;
       
   296     TRAP(err,media=CMPXMedia::NewL(contentIDs.Array()));
       
   297     CleanupStack::PushL(media);
       
   298     media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, 
       
   299                                                       EMPXSong );
       
   300     media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaMusicGenre, 
       
   301                                                           EMPXSong );
       
   302     media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCollectionId, 
       
   303                                                           EMPXSong );
       
   304     media->ValueText(KMPXMediaGeneralCategory);
       
   305     media->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, 
       
   306                                                   EMPXItem );
       
   307     TRAP(err,media->SetTextValueL( KMPXMediaMusicAlbumTrack, KNullDesC ));
       
   308     TRAP(err,media->SetTextValueL( KMPXMediaGeneralMimeType, KTestFileMimeType ));
       
   309     //iMediator->AddItemL(media); 
       
   310     TRAP( err,iMediator->AddItemL( media ) );
       
   311     if( err != KErrNone )
       
   312    	   {
       
   313    	   iLog->Log( _L("CMPXCollectionMediatorAddItemLMedia returns a error %d"),err );
       
   314    	   }
       
   315     else 
       
   316 	   {
       
   317        iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorAddItemLMedia testing CMPXCollectionMediator::AddItemL() End") );
       
   318        }    
       
   319     CleanupStack::PopAndDestroy( media );
       
   320     return err;
       
   321  	}
       
   322 // -----------------------------------------------------------------------------
       
   323 // CHarvesterCollectionMediatorTest::CMPXCollectionAddItemLCMPXMediaArray
       
   324 // Example test method function.
       
   325 // (other items were commented in a header).
       
   326 // -----------------------------------------------------------------------------
       
   327 //-----debug pass
       
   328 TInt CHarvesterCollectionMediatorTest::CMPXCollectionAddItemLCMPXMediaArray( CStifItemParser&/* aItem*/ )
       
   329 	{
       
   330 	iLog->Log(_L("CMPXCollectionAddItemLCMPXMediaArray"));
       
   331 	TInt err = KErrNone;    
       
   332     CMPXMediaArray* mediaAry = CMPXMediaArray::NewL();
       
   333     CleanupStack::PushL( mediaAry );
       
   334     
       
   335     // One music and one podcast media
       
   336     CMPXMedia* m1 = CMPXMedia::NewL();
       
   337     CleanupStack::PushL( m1 );
       
   338     m1->SetTextValueL(KMPXMediaGeneralUri,KTestItemPath2);
       
   339     m1->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXSong );
       
   340     m1->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);
       
   341     m1->SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, TUid::Uid(0x101FFC3A) );
       
   342     
       
   343     CMPXMedia* m2 = CMPXMedia::NewL();
       
   344     CleanupStack::PushL( m2 );
       
   345     m2->SetTextValueL(KMPXMediaGeneralUri,KTestItemPath3);
       
   346     m2->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXSong );
       
   347     m2->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);
       
   348     m2->SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, TUid::Uid(0x101FFC3A) );
       
   349     m2->SetTextValueL(KMPXMediaMusicGenre, _L("podcast"));
       
   350     
       
   351     mediaAry->AppendL(*m1); // copy
       
   352     mediaAry->AppendL(*m2); // copy
       
   353     
       
   354     iLog->Log(_L("CMPXCollectionAddItemLCMPXMediaArray -- adding via mediator"));
       
   355     iMediator->AddItemL(*mediaAry);
       
   356     
       
   357     mediaAry->Reset();
       
   358     m1->SetTextValueL(KMPXMediaGeneralTitle, _L("abcdefg") );
       
   359     m2->SetTextValueL(KMPXMediaGeneralTitle, _L("abcdefg") );
       
   360     
       
   361     mediaAry->AppendL(*m1); // copy
       
   362     mediaAry->AppendL(*m2); // copy
       
   363     iLog->Log(_L("CMPXCollectionAddItemLCMPXMediaArray -- updating via mediator"));
       
   364     iMediator->SetItemL(*mediaAry);
       
   365     
       
   366     CleanupStack::PopAndDestroy(2); // m1, m2
       
   367     CleanupStack::PopAndDestroy( mediaAry );
       
   368 	
       
   369     if( err != KErrNone )
       
   370     	{
       
   371     	iLog->Log( _L("CMPXCollectionAddItemLCMPXMediaArray returns a error %d"),err );
       
   372     	}
       
   373     else
       
   374     	{
       
   375     	 iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionAddItemLCMPXMediaArray testing CMPXCollectionMediator::AddItemL() End") );
       
   376     	}
       
   377     return err;
       
   378  	}
       
   379 // -----------------------------------------------------------------------------
       
   380 // CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMedia
       
   381 // Example test method function.
       
   382 // (other items were commented in a header).
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 TInt CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMedia( CStifItemParser&/* aItem*/ )
       
   386 	{	
       
   387     iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMedia testing CMPXCollectionMediator::SetItemL( CMPXMedia*& aMediaProp) begin") );
       
   388     TInt err = KErrNone;   
       
   389     CMPXMedia* media = CMPXMedia::NewL();
       
   390     CleanupStack::PushL( media );
       
   391     
       
   392     iLog->Log(_L("CMPXCollectionSetItemLByCMPXMedia -- adding item"));
       
   393     // Add an item
       
   394     media->SetTextValueL(KMPXMediaGeneralUri,KTestItemPath);
       
   395     media->SetTextValueL(KMPXMediaMusicArtist,_L("MyArtist"));
       
   396     media->SetTextValueL(KMPXMediaMusicAlbum,_L("AnAlbum"));
       
   397     media->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXSong );
       
   398     media->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);
       
   399     media->SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, TUid::Uid(0x101FFC3A) );
       
   400     iMediator->AddItemL(media);
       
   401     
       
   402     // General update
       
   403     iLog->Log(_L("CMPXCollectionSetItemLByCMPXMedia -- updating item"));
       
   404     media->SetTextValueL(KMPXMediaGeneralTitle,_L("SomeTitle"));
       
   405     iMediator->SetItemL(media);
       
   406     
       
   407     // Move to podcast, tests FetchAndMoveItemSyncL() in mediator
       
   408     iLog->Log(_L("CMPXCollectionSetItemLByCMPXMedia -- moving item"));
       
   409     media->SetTextValueL(KMPXMediaMusicGenre, _L("podcast"));
       
   410     iMediator->SetItemL(media);
       
   411     
       
   412     CleanupStack::PopAndDestroy(media);
       
   413     
       
   414     if( err != KErrNone )
       
   415     	{
       
   416     	iLog->Log( _L("CMPXCollectionSetItemLByCMPXMedia returns a error %d"),err );
       
   417     	}
       
   418     else
       
   419     	{
       
   420     	 iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMedia testing CMPXCollectionMediator::SetItemL( CMPXMedia*& aMediaProp) End") );
       
   421     	}    
       
   422     return err;
       
   423  	}
       
   424 // -----------------------------------------------------------------------------
       
   425 // CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMediaArray
       
   426 // Example test method function.
       
   427 // (other items were commented in a header).
       
   428 // -----------------------------------------------------------------------------
       
   429 //-----debug pass--->fail 17,10,2008
       
   430 TInt CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMediaArray( CStifItemParser&/* aItem*/ )
       
   431 	{
       
   432     iLog->Log(_L("CMPXCollectionSetItemL"));
       
   433 	TInt err = KErrNone;    
       
   434     CMPXMediaArray* mediaAry = CMPXMediaArray::NewL();
       
   435     CleanupStack::PushL( mediaAry );
       
   436     
       
   437     // One music and one podcast media
       
   438     CMPXMedia* m1 = CMPXMedia::NewL();
       
   439     CleanupStack::PushL( m1 );
       
   440     m1->SetTextValueL(KMPXMediaGeneralUri,KTestItemPath2);
       
   441     m1->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXSong );
       
   442     m1->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);
       
   443     m1->SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, TUid::Uid(0x101FFC3A) );
       
   444     
       
   445     CMPXMedia* m2 = CMPXMedia::NewL();
       
   446     CleanupStack::PushL( m2 );
       
   447     m2->SetTextValueL(KMPXMediaGeneralUri,KTestItemPath3);
       
   448     m2->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXSong );
       
   449     m2->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);
       
   450     m2->SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, TUid::Uid(0x101FFC3A) );
       
   451     m2->SetTextValueL(KMPXMediaMusicGenre, _L("podcast"));
       
   452     
       
   453     mediaAry->AppendL(*m1); // copy
       
   454     mediaAry->AppendL(*m2); // copy
       
   455     
       
   456     iLog->Log(_L("CMPXCollectionSetItemL -- adding via mediator"));
       
   457     iMediator->AddItemL(*mediaAry);
       
   458     
       
   459     mediaAry->Reset();
       
   460     m1->SetTextValueL(KMPXMediaGeneralTitle, _L("abcdefg") );
       
   461     m2->SetTextValueL(KMPXMediaGeneralTitle, _L("abcdefg") );
       
   462     
       
   463     mediaAry->AppendL(*m1); // copy
       
   464     mediaAry->AppendL(*m2); // copy
       
   465     iLog->Log(_L("CMPXCollectionSetItemL -- updating via mediator"));
       
   466     iMediator->SetItemL(*mediaAry);
       
   467     
       
   468     CleanupStack::PopAndDestroy(2); // m1, m2
       
   469     CleanupStack::PopAndDestroy( mediaAry );
       
   470     if( err != KErrNone )
       
   471     	{
       
   472     	iLog->Log( _L("CMPXCollectionSetItemLByCMPXMediaArray returns a error %d"),err );
       
   473     	}
       
   474     else
       
   475     	{
       
   476     	iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionSetItemLByCMPXMediaArray testing CMPXCollectionMediator::SetItemL( CMPXMediaArray& aMPArray ) End") );
       
   477     	}
       
   478     return err;
       
   479  	}
       
   480 // -----------------------------------------------------------------------------
       
   481 // CHarvesterCollectionMediatorTest::CMPXCollectionSetItemL
       
   482 // Example test method function.
       
   483 // (other items were commented in a header).
       
   484 // -----------------------------------------------------------------------------
       
   485 //-----debug pass
       
   486 TInt CHarvesterCollectionMediatorTest::CMPXCollectionSetItemL( CStifItemParser&/* aItem*/ )
       
   487 	{
       
   488 	iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionSetItemL testing CMPXCollectionMediator::SetItemL(TArray<CMPXMedia*>& aArray,CMPXCollectionPath& aPath,RArray<TInt>& aIndices ) begin") );
       
   489     TInt err = KErrNone;
       
   490     /*RArray<CMPXMedia*> iArray = RArray<CMPXMedia*>::RArray();
       
   491     CMPXMedia* media = CMPXMedia::NewL();
       
   492 //    CleanupStack::PushL(media);
       
   493     iArray.Append( media );
       
   494 //    CleanupStack::PopAndDestroy(media);
       
   495     TArray<CMPXMedia*> iTarray = iArray.Array();
       
   496     
       
   497     const TMPXItemId KMPXPathItem1 = 44441;
       
   498     RArray<TMPXItemId> itemIdArray;
       
   499 
       
   500     // Start from scratch
       
   501     if ( iCollectionPath )
       
   502         {
       
   503         iCollectionPath->Reset();
       
   504         delete iCollectionPath;
       
   505         }
       
   506     // build collection path
       
   507     TRAP( err , iCollectionPath = CMPXCollectionPath::NewL());
       
   508     TMPXItemId item(33331);
       
   509     TRAP( err , iCollectionPath->AppendL(item));
       
   510     itemIdArray.Append(KMPXPathItem1);
       
   511     TRAP( err , iCollectionPath->AppendL(itemIdArray.Array()));
       
   512     
       
   513     itemIdArray.Close();
       
   514       
       
   515             
       
   516     CMPXCollectionPath* iPath;
       
   517     TRAP( err , iPath = CMPXCollectionPath::NewL(*iCollectionPath));
       
   518 
       
   519     RArray<TInt> iIndices = RArray<TInt>::RArray();
       
   520     TInt index = 0;
       
   521     iIndices.Append( index );    
       
   522     iMediator->SetItemL( iTarray,*iPath,iIndices );
       
   523 //    CleanupStack::PopAndDestroy(iPath);
       
   524     iArray.Close();   
       
   525   
       
   526 	delete media;
       
   527 	media = NULL;
       
   528     delete iPath;
       
   529 	iPath = NULL;   */
       
   530     if(err != KErrNone )
       
   531     	{
       
   532     	iLog->Log( _L("CMPXCollectionSetItemL returns a error %d"),err );
       
   533     	}
       
   534     else
       
   535     	{
       
   536     	iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionSetItemL testing CMPXCollectionMediator::SetItemL(TArray<CMPXMedia*>& aArray,CMPXCollectionPath& aPath,RArray<TInt>& aIndices ) End") );
       
   537     	}
       
   538     return err;
       
   539  	}
       
   540 // -----------------------------------------------------------------------------
       
   541 // CHarvesterCollectionMediatorTest::CMPXCollectionCheckItemL
       
   542 // Example test method function.
       
   543 // (other items were commented in a header).
       
   544 // -----------------------------------------------------------------------------
       
   545 //
       
   546 TInt CHarvesterCollectionMediatorTest::CMPXCollectionCheckItemL( CStifItemParser&/* aItem*/ )
       
   547 	{
       
   548 	iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionCheckItemL testing CMPXCollectionMediator::CheckItemL( CMPXMedia& aMedia ) begin") );
       
   549 	RArray<TInt> contentIDs;
       
   550 	TInt err = KErrNone;
       
   551 	contentIDs.AppendL( KMPXMediaIdGeneral );
       
   552     contentIDs.AppendL( KMPXMediaIdAudio );
       
   553     contentIDs.AppendL( KMPXMediaIdMusic ); 
       
   554     contentIDs.AppendL( KMPXMediaIdDrm ); 
       
   555     CMPXMedia* media = CMPXMedia::NewL( contentIDs.Array() );
       
   556     CleanupStack::PushL( media );
       
   557     media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, 
       
   558                                                       EMPXSong );
       
   559     TInt iIndex = media->Index( KMPXMediaGeneralCategory );
       
   560     media->ValueText( KMPXMediaGeneralCategory );
       
   561     media->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, 
       
   562                                                   EMPXItem );
       
   563     media->SetTextValueL( KMPXMediaMusicAlbumTrack, KNullDesC );
       
   564     media->SetTextValueL( KMPXMediaGeneralMimeType, KTestFileMimeType );  
       
   565     iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionCheckItemL testing CMPXCollectionMediator::CheckItemL( CMPXMedia& aMedia ) begin") );
       
   566    
       
   567     //iMediator->CheckItemL(*media);
       
   568     TRAP( err,iMediator->CheckItemL( *media ) );
       
   569     CleanupStack::PopAndDestroy( media );
       
   570     if( err != KErrNone )
       
   571     	{
       
   572     	iLog->Log( _L("CMPXCollectionCheckItemL returns a error %d"),err );
       
   573     	}
       
   574     else{
       
   575     	iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionCheckItemL testing CMPXCollectionMediator::SetItemLCheckItemL( CMPXMedia& aMedia ) End") );
       
   576     	}
       
   577     return err;
       
   578  	}
       
   579 // -----------------------------------------------------------------------------
       
   580 // CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith3paras
       
   581 // Example test method function.
       
   582 // (other items were commented in a header).
       
   583 // -----------------------------------------------------------------------------
       
   584 //
       
   585 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith3paras( CStifItemParser&/* aItem*/ )
       
   586 	{
       
   587 	iLog->Log( _L("Testing CMPXCollectionMediator::MoveItemL( CMPXMedia*& aMedia, TUid aOldCollectionId,TUid aNewCollectionId ) begin") );		
       
   588 	TInt err = KErrNone;
       
   589 	CMPXMedia* m1 = CMPXMedia::NewL();
       
   590     CleanupStack::PushL( m1 );
       
   591     m1->SetTextValueL(KMPXMediaGeneralUri, KTestItemPath);
       
   592     m1->SetTObjectValueL(KMPXMediaGeneralCategory, EMPXSong );
       
   593     m1->SetTObjectValueL(KMPXMediaGeneralType, EMPXItem);
       
   594     m1->SetTObjectValueL<TUid>(KMPXMediaGeneralCollectionId, TUid::Uid(0x101FFC3C) );
       
   595     iLog->Log(_L("CMPXCollectionMoveItemLwith3paras -- adding dummy"));
       
   596     iMediator->AddItemL(m1);
       
   597 
       
   598     // Next move it synchronously via mediator to the podcasting plugin
       
   599     iLog->Log(_L("CMPXCollectionMoveItemLwith3paras -- moving item"));
       
   600     iMediator->MoveItemL(m1, TUid::Uid(0x101FFC3C), TUid::Uid(0x101FFC3A));
       
   601     CleanupStack::PopAndDestroy(m1);
       
   602 
       
   603     if( err != KErrNone )
       
   604     	{
       
   605     	iLog->Log( _L("CMPXCollectionMoveItemLwith3paras returns a error %d"),err );
       
   606     	}
       
   607     else
       
   608     	{
       
   609     	iLog->Log( _L("Testing CMPXCollectionMediator::MoveItemL( CMPXMedia*& aMedia,TUid aOldCollectionId,TUid aNewCollectionId) End") );
       
   610     	}
       
   611     return err;
       
   612  	}
       
   613 // -----------------------------------------------------------------------------
       
   614 // CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith4paras
       
   615 // Example test method function.
       
   616 // (other items were commented in a header).
       
   617 // -----------------------------------------------------------------------------
       
   618 //-----debug pass
       
   619 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith4paras( CStifItemParser&/* aItem*/ )
       
   620 	{
       
   621 	iLog->Log( _L("Testing CMPXCollectionMediator::MoveItemL( CMPXMedia*& aMedia, TUid aOldCollectionId,TUid aNewCollectionId,MMPXMoveItemObserver* aObs ) begin") );		
       
   622 		
       
   623 	RArray<TInt> contentIDs;
       
   624 	TInt err = KErrNone;
       
   625     contentIDs.AppendL( KMPXMediaIdGeneral );
       
   626     contentIDs.AppendL( KMPXMediaIdAudio );
       
   627     contentIDs.AppendL( KMPXMediaIdMusic ); 
       
   628     contentIDs.AppendL( KMPXMediaIdDrm ); 
       
   629     CMPXMedia* media;
       
   630     TRAP(err,media = CMPXMedia::NewL( contentIDs.Array() ));
       
   631     CleanupStack::PushL( media );
       
   632     media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, 
       
   633                                                       EMPXSong );
       
   634     TInt iIndex = media->Index( KMPXMediaGeneralCategory );
       
   635     media->ValueText( KMPXMediaGeneralCategory );
       
   636     media->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, 
       
   637                                                   EMPXItem );
       
   638     TRAP(err,media->SetTextValueL( KMPXMediaMusicAlbumTrack, KNullDesC ));
       
   639     TRAP(err,media->SetTextValueL( KMPXMediaGeneralMimeType, KTestFileMimeType ));  
       
   640     iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith4paras testing CMPXCollectionMediator::MoveItemL( CMPXMedia*& aMedia,TUid aOldCollectionId,TUid aNewCollectionId,MMPXMoveItemObserver* aObs) begin") );
       
   641     TUid iOldCollectionId = {0};
       
   642     TUid iNewCollectionId = {1};
       
   643     //iMediator->MoveItemL(media,iOldCollectionId,iNewCollectionId,this);
       
   644     TRAP( err,iMediator->MoveItemL( media,iOldCollectionId,iNewCollectionId,this ) );
       
   645     CleanupStack::PopAndDestroy( media );
       
   646     if( err != KErrNone )
       
   647     	{
       
   648     	iLog->Log( _L("CMPXCollectionMoveItemLwith4paras returns a error %d"),err );
       
   649     	}
       
   650     else
       
   651     	{
       
   652     	iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMoveItemLwith4paras testing CMPXCollectionMediator::MoveItemL( CMPXMedia*& aMedia,TUid aOldCollectionId,TUid aNewCollectionId,MMPXMoveItemObserver* aObs) End") );
       
   653     	}
       
   654     return err;
       
   655  	}
       
   656 
       
   657 
       
   658 
       
   659 // -----------------------------------------------------------------------------
       
   660 // CHarvesterCollectionMediatorTest::CMPXCollectionMediatorWithRealCollection
       
   661 // Example test method function.
       
   662 // (other items were commented in a header).
       
   663 // -----------------------------------------------------------------------------
       
   664 //-----debug pass
       
   665 TInt CHarvesterCollectionMediatorTest::CMPXCollectionMediatorWithRealCollection( CStifItemParser&/* aItem*/ )
       
   666 	{
       
   667 	
       
   668     iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorWithRealCollection testing CMPXCollectionMediator::NewL() begin") );
       
   669     TInt err = KErrNone;
       
   670     SonOfMMPXCollection* son= new SonOfMMPXCollection();
       
   671     TRAP( err,iMediator = CMPXCollectionMediator::NewL( *son ) );
       
   672     if( err != KErrNone )
       
   673    	   {
       
   674    	   iLog->Log( _L("CMPXCollectionMediatorWithRealCollection returns a error %d"),err );
       
   675    	   }
       
   676     else 
       
   677 	   {
       
   678        iLog->Log( _L("CHarvesterCollectionMediatorTest::CMPXCollectionMediatorWithRealCollection testing CMPXCollectionMediator::NewL() End") );
       
   679        }    
       
   680     //iUtility->Close();
       
   681     return err;
       
   682  	}
       
   683 
       
   684 // -----------------------------------------------------------------------------
       
   685 // CHarvesterCollectionMediatorTest::?member_function
       
   686 // ?implementation_description
       
   687 // (other items were commented in a header).
       
   688 // -----------------------------------------------------------------------------
       
   689 //
       
   690 
       
   691 /*TInt CHarvesterCollectionMediatorTest::?member_function(
       
   692    CItemParser& aItem )
       
   693    {
       
   694 
       
   695    ?code
       
   696 
       
   697    }*/
       
   698 
       
   699 
       
   700 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   701 // None
       
   702 
       
   703 //  [End of File] - Do not remove