mmappfw_plat/collection_helper_api/tsrc/CollectionHelperTestClass/src/CollectionHelperTestClassBlocks.cpp
changeset 0 a2952bb97e68
child 17 780c925249c1
child 25 d881023c13eb
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:   CCollectionHelperTestClass block implementaion for STIF Test Framework TestScripter.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32svr.h>
       
    21 #include <StifParser.h>
       
    22 #include <Stiftestinterface.h>
       
    23 #include "CollectionHelperTestClass.h"
       
    24 #include <mpxmessagegeneraldefs.h> // KMPXMessageGeneralEvent, KMPXMessageGeneralType
       
    25 #include <mpxmediageneraldefs.h>
       
    26 #include <mpxmediaaudiodefs.h>
       
    27 #include <mpxmediamusicdefs.h>
       
    28 #include <mpxmediadrmdefs.h>
       
    29 #include <mpxmediaarray.h>
       
    30 #include <mpxmediacontainerdefs.h>
       
    31 #include <mpxattribute.h>
       
    32 #include "debug.h"
       
    33 
       
    34 // EXTERNAL DATA STRUCTURES
       
    35 //extern  ?external_data;
       
    36 
       
    37 // EXTERNAL FUNCTION PROTOTYPES  
       
    38 //extern ?external_function( ?arg_type,?arg_type );
       
    39 
       
    40 // CONSTANTS
       
    41 //const ?type ?constant_var = ?constant;
       
    42 
       
    43 // MACROS
       
    44 //#define ?macro ?macro_def
       
    45 
       
    46 // LOCAL CONSTANTS AND MACROS
       
    47 //const ?type ?constant_var = ?constant;
       
    48 //#define ?macro_name ?macro_def
       
    49 
       
    50 // MODULE DATA STRUCTURES
       
    51 //enum ?declaration
       
    52 //typedef ?declaration
       
    53 
       
    54 // LOCAL FUNCTION PROTOTYPES
       
    55 //?type ?function_name( ?arg_type, ?arg_type );
       
    56 
       
    57 // FORWARD DECLARATIONS
       
    58 //class ?FORWARD_CLASSNAME;
       
    59 
       
    60 // ============================= LOCAL FUNCTIONS ===============================
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // ?function_name ?description.
       
    64 // ?description
       
    65 // Returns: ?value_1: ?description
       
    66 //          ?value_n: ?description_line1
       
    67 //                    ?description_line2
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 /*
       
    71 ?type ?function_name(
       
    72     ?arg_type arg,  // ?description
       
    73     ?arg_type arg)  // ?description
       
    74     {
       
    75 
       
    76     ?code  // ?comment
       
    77 
       
    78     // ?comment
       
    79     ?code
       
    80     }
       
    81 */
       
    82 
       
    83 // ============================ MEMBER FUNCTIONS ===============================
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CCollectionHelperTestClass::Delete
       
    87 // Delete here all resources allocated and opened from test methods. 
       
    88 // Called from destructor. 
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 void CCollectionHelperTestClass::Delete() 
       
    92     {
       
    93     FTRACE(FPrint(_L("CTunerUtilityTestClass::Delete")));
       
    94     
       
    95     iExpectedEvents.Close();
       
    96     iOcurredEvents.Close();
       
    97     
       
    98     iLog->Log(_L("Deleting test class..."));
       
    99 	iLog->Log(_L(""));
       
   100 	iLog->Log(_L(""));
       
   101     
       
   102     if(iUIHelper)
       
   103    		{
       
   104         //delete iUIHelper;
       
   105         iUIHelper = NULL;
       
   106  	  	}
       
   107     if(iHelper)
       
   108    		{
       
   109         //delete iHelper;
       
   110         iHelper = NULL;
       
   111    		}
       
   112     if(iCachedHelper)
       
   113    		{
       
   114         //delete iCachedHelper;
       
   115         iCachedHelper = NULL;
       
   116    		}
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CCollectionHelperTestClass::RunMethodL
       
   121 // Run specified method. Contains also table of test mothods and their names.
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 TInt CCollectionHelperTestClass::RunMethodL( 
       
   125     CStifItemParser& aItem ) 
       
   126     {
       
   127 
       
   128     static TStifFunctionInfo const KFunctions[] =
       
   129         {        
       
   130         // Copy this line for every implemented function.
       
   131         // First string is the function name used in TestScripter script file.
       
   132         // Second is the actual implementation member function. 
       
   133         ENTRY( "OpenCollectionUtility", CCollectionHelperTestClass::OpenCollectionUtilityL ),
       
   134         ENTRY( "NewUiHelper", CCollectionHelperTestClass::NewUiHelperL ),
       
   135         ENTRY( "NewHelper", CCollectionHelperTestClass::NewHelperL ),
       
   136         ENTRY( "NewCachedHelper", CCollectionHelperTestClass::NewCachedHelperL ),
       
   137         ENTRY( "CloseUiHelper", CCollectionHelperTestClass::CloseUiHelperL ),
       
   138         ENTRY( "CloseHelper", CCollectionHelperTestClass::CloseHelperL ),
       
   139         ENTRY( "CloseCachedHelper", CCollectionHelperTestClass::CloseCachedHelperL ),        
       
   140         };
       
   141 
       
   142     const TInt count = sizeof( KFunctions ) / 
       
   143                         sizeof( TStifFunctionInfo );
       
   144 
       
   145     return RunInternalL( KFunctions, count, aItem );
       
   146     }
       
   147 
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CCollectionHelperTestClass::EventName
       
   151 // Return descriptor with the notification description
       
   152 // -----------------------------------------------------------------------------
       
   153 TPtrC CCollectionHelperTestClass::EventName( TInt aKey )
       
   154 {
       
   155 	static TText* const badKeyword = (TText*)L"BadKeyword";
       
   156 	static TText* const keywords[] =
       
   157 	{
       
   158 		(TText*)L"EHandleCollectionMessage",
       
   159 		(TText*)L"EHandleOpen",
       
   160 		(TText*)L"EHandleAddFileComplete",
       
   161 		(TText*)L"EHandleRemove",
       
   162 		(TText*)L"EHandleFindAllComplete"
       
   163 	};
       
   164 
       
   165 	if( (TUint)aKey >= (sizeof( keywords )/sizeof(TText*)) )
       
   166 	{
       
   167 		iLog->Log(_L("Keyword out of bounds"));
       
   168 		TPtrC keyword( badKeyword );
       
   169 		return keyword;
       
   170 	}
       
   171 	else
       
   172 	{
       
   173 		TPtrC keyword( keywords[aKey] );
       
   174 		return keyword;
       
   175 	}
       
   176 }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CCollectionHelperTestClass::AddExpectedEvent
       
   180 // Add an event to the expected events' list
       
   181 // -----------------------------------------------------------------------------
       
   182 void CCollectionHelperTestClass::AddExpectedEvent(TCollectionHelperExpectedEvent event, TInt ms)
       
   183 {
       
   184 	FTRACE(FPrint(_L("CCollectionHelperTestClass::AddExpectedEvent")));
       
   185 	iExpectedEvents.Append(event);
       
   186 	TPtrC eventName = EventName(event);
       
   187 	iLog->Log(_L("Adding expected event:(0x%02x)%S Total=%d"), event, &eventName, iExpectedEvents.Count() );
       
   188 
       
   189 	if ( iTimeoutController && !iTimeoutController->IsActive() )
       
   190 	{
       
   191 		if (ms > 0)
       
   192 		{
       
   193 			iTimeoutController->Start( TTimeIntervalMicroSeconds(ms * 1000) );
       
   194 		}
       
   195 		else
       
   196 		{
       
   197 			iLog->Log(_L("Timeout with default value (1s)"));
       
   198 			iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) );
       
   199 		}
       
   200 	}
       
   201 }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // CCollectionHelperTestClass::RemoveExpectedEvent
       
   205 // Remove the indicated event from the expected events' list
       
   206 // Returns: ETrue: Event found.
       
   207 //          EFalse: Event not found.
       
   208 // -----------------------------------------------------------------------------
       
   209 TBool CCollectionHelperTestClass::RemoveExpectedEvent(TCollectionHelperExpectedEvent aEvent)
       
   210 {
       
   211 	FTRACE(FPrint(_L("CCollectionHelperTestClass::RemoveExpectedEvent")));
       
   212 	TBool match = EFalse;
       
   213 	for (TUint i=0; i < iExpectedEvents.Count() ; i++)
       
   214 	{
       
   215 		if (iExpectedEvents[i] == aEvent)
       
   216 		{
       
   217 			iExpectedEvents.Remove(i);
       
   218 			match = ETrue;
       
   219 			break;
       
   220 		}
       
   221 	}
       
   222 
       
   223 	return match;
       
   224 }
       
   225 
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CCollectionHelperTestClass::RemoveAllExpectedEvents
       
   229 // Remove the indicated event from the expected events' list
       
   230 // -----------------------------------------------------------------------------
       
   231 void CCollectionHelperTestClass::RemoveAllExpectedEvents()
       
   232 {
       
   233 	FTRACE(FPrint(_L("CCollectionHelperTestClass::RemoveAllExpectedEvents")));
       
   234 	iLog->Log(_L("Removing all expected events"));
       
   235 
       
   236 	iExpectedEvents.Reset();
       
   237 	iOcurredEvents.Reset();
       
   238 }
       
   239 
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // CCollectionHelperTestClass::ProcessEvent
       
   243 // Process events.
       
   244 // -----------------------------------------------------------------------------
       
   245 void CCollectionHelperTestClass::ProcessEvent(TCollectionHelperExpectedEvent aEvent, TInt aError)
       
   246 {
       
   247 	FTRACE(FPrint(_L("CCollectionHelperTestClass::ProcessExpectedEvent")));
       
   248 	TPtrC nameEvent = EventName(aEvent);
       
   249 
       
   250 	// Check for error
       
   251 	if (aError == KErrNone)
       
   252 	{
       
   253 		// Remove the event
       
   254 		if (RemoveExpectedEvent(aEvent))
       
   255 		{
       
   256 			iLog->Log(_L("Expected Event: (0x%02x)%S has ocurred Total=%d"), aEvent, &nameEvent,iExpectedEvents.Count());
       
   257 		}
       
   258 		else
       
   259 		{
       
   260 			iLog->Log(_L("Event: (0x%02x)%S has ocurred"), aEvent, &nameEvent);
       
   261 			return;
       
   262 		}
       
   263 
       
   264 		// All expected events have ocurred
       
   265 		if (iExpectedEvents.Count() == 0 )
       
   266 		{
       
   267 			Signal();
       
   268 			iTimeoutController->Cancel();
       
   269 		}
       
   270 	}
       
   271 	else
       
   272 	{
       
   273 		iLog->Log(_L("[Error] Event: (0x%02x)%S return with error code=%d"), aEvent, &nameEvent, aError);
       
   274 		if (iExpectedEvents.Count() != 0 )
       
   275 		{
       
   276 			RemoveExpectedEvent(aEvent);
       
   277 		}
       
   278 		iTimeoutController->Cancel();
       
   279 		Signal(KErrCallbackErrorCode);
       
   280 	}
       
   281 }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // CCollectionHelperTestClass::HandleTimeout
       
   285 // Review if all the expected events have ocurred once the time is over
       
   286 // -----------------------------------------------------------------------------
       
   287 void CCollectionHelperTestClass::HandleTimeout(TInt aError)
       
   288 {
       
   289 	FTRACE(FPrint(_L("CCollectionHelperTestClass::HandleTimeout")));
       
   290 	// All expected events have ocurred
       
   291 	if (aError != KErrNone)
       
   292 	{
       
   293 		if (iExpectedEvents.Count() == 0 )
       
   294 		{
       
   295 			iLog->Log(_L("Timing out but events have ocurred"));
       
   296 			Signal();
       
   297 		}
       
   298 		else
       
   299 		{
       
   300 			RemoveAllExpectedEvents();
       
   301 			iLog->Log(_L("Timing out and events still pending"));
       
   302 			Signal(KErrEventPending);
       
   303 		}
       
   304 	}
       
   305 	else
       
   306 	{
       
   307 		iLog->Log(_L("Timing out return a error %d"), aError);
       
   308 		Signal(aError);
       
   309 	}
       
   310 }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CCollectionHelperTestClass::SetTimeout
       
   314 // Create a timer and set a timeout
       
   315 // When the timeout is reached the test case is marked as failed
       
   316 // It's used rather than the "timeout" keyword in the configuration file
       
   317 // because in this way the log continues
       
   318 // -----------------------------------------------------------------------------
       
   319 TInt CCollectionHelperTestClass::SetTimeout( CStifItemParser& aItem )
       
   320 {
       
   321 	FTRACE(FPrint(_L("CCollectionHelperTestClass::SetTimeout")));
       
   322 	TInt timeout=0;
       
   323 	TInt error = aItem.GetNextInt(timeout) ;
       
   324 	if ( iTimeoutController )
       
   325 	{
       
   326 		if ( timeout > 0 )
       
   327 		{
       
   328 			iTimeoutController->Start( TTimeIntervalMicroSeconds(timeout*1000) );
       
   329 		}
       
   330 		else
       
   331 		{
       
   332 			iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) );
       
   333 		}
       
   334 	}
       
   335 	else
       
   336 	{
       
   337 		iLog->Log(_L("Timeout Controller doesn't exist"));
       
   338 		error = KErrTimeoutController;
       
   339 	}
       
   340 	return error;
       
   341 }
       
   342 
       
   343 
       
   344 // -----------------------------------------------------------------------------
       
   345 // Uses the TestModuleBase API to allow a panic as exit reason for a test case
       
   346 // Returns: Symbian OS errors.
       
   347 // -----------------------------------------------------------------------------
       
   348 TInt CCollectionHelperTestClass::SetAllowedPanic( CStifItemParser& aItem )
       
   349 {
       
   350 	FTRACE(FPrint(_L("CCollectionHelperTestClass::SetAllowedPanic")));
       
   351 	TInt error = KErrNone;
       
   352 	TInt panicCode;
       
   353 	TPtrC panicType;
       
   354 	if (  ( KErrNone == aItem.GetNextString(panicType) ) &&
       
   355 	( KErrNone == aItem.GetNextInt(panicCode) )  )
       
   356 	{
       
   357 		iLog->Log(_L("Allowing panic: %S %d"), &panicType, panicCode);
       
   358 		iTestModuleIf.SetExitReason( CTestModuleIf::EPanic, panicCode );
       
   359 		iNormalExitReason = EFalse;
       
   360 	}
       
   361 	else
       
   362 	{
       
   363 		iLog->Log(KMsgBadTestParameters);
       
   364 		error = KErrBadTestParameter;
       
   365 	}
       
   366 	return error;
       
   367 }
       
   368 
       
   369 // -----------------------------------------------------------------------------
       
   370 // CCollectionHelperTestClass::SetExpectedEvents()
       
   371 // Returns: Symbian OS errors.
       
   372 // -----------------------------------------------------------------------------
       
   373 TInt CCollectionHelperTestClass::SetExpectedEvents( CStifItemParser& aItem )
       
   374 {
       
   375 	FTRACE(FPrint(_L("CCollectionHelperTestClass::SetExpectedEvents")));
       
   376 	TInt error = KErrNone;
       
   377 	TInt event=0;
       
   378 	while ( KErrNone == aItem.GetNextInt(event))
       
   379 	{
       
   380 		AddExpectedEvent(static_cast<TCollectionHelperExpectedEvent>(event), 0); // Default timeout value
       
   381 	}
       
   382 	return error;
       
   383 }
       
   384 // -----------------------------------------------------------------------------
       
   385 // CCollectionHelperTestClass::CreateTestMediaL()
       
   386 // Returns: no return value.
       
   387 // -----------------------------------------------------------------------------
       
   388 void CCollectionHelperTestClass::CreateTestMediaL( CMPXMedia*& aNewProperty )
       
   389     {
       
   390     RArray<TInt> contentIDs;
       
   391     contentIDs.AppendL( KMPXMediaIdGeneral );
       
   392     contentIDs.AppendL( KMPXMediaIdAudio );
       
   393     contentIDs.AppendL( KMPXMediaIdMusic );
       
   394     contentIDs.AppendL( KMPXMediaIdDrm ); 
       
   395             
       
   396     aNewProperty = NULL;
       
   397     CMPXMedia* media = CMPXMedia::NewL( contentIDs.Array() );
       
   398     CleanupStack::PushL( media );
       
   399     contentIDs.Close();
       
   400     
       
   401     // CMPXMedia default types    
       
   402     media->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, 
       
   403                                               EMPXItem );
       
   404     media->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, 
       
   405                                                   EMPXSong );
       
   406     media->SetTextValueL( KMPXMediaGeneralUri, KTestFile() );
       
   407     
       
   408     // Title, default is file name
       
   409     media->SetTextValueL( KMPXMediaGeneralTitle, KTestFile() );
       
   410     
       
   411     // Default album track
       
   412     media->SetTextValueL( KMPXMediaMusicAlbumTrack, KNullDesC );
       
   413     
       
   414     // Set the Mime Type and collection UID
       
   415     media->SetTextValueL( KMPXMediaGeneralMimeType, KTestFileMimeType() );
       
   416     //media->SetTObjectValueL( KMPXMediaGeneralCollectionId, );
       
   417 
       
   418     // Set the pointers now that the object is ready
       
   419     CleanupStack::Pop( media );
       
   420     aNewProperty = media;
       
   421     }
       
   422 
       
   423 // -----------------------------------------------------------------------------
       
   424 // CCollectionHelperTestClass::ExampleL
       
   425 // Example test method function.
       
   426 // (other items were commented in a header).
       
   427 // -----------------------------------------------------------------------------
       
   428 //
       
   429 TInt CCollectionHelperTestClass::ExampleL( CStifItemParser& aItem )
       
   430     {
       
   431     // Print to UI
       
   432     _LIT( KCollectionHelperTestClass, "CollectionHelperTestClass" );
       
   433     _LIT( KExample, "In Example" );
       
   434     TestModuleIf().Printf( 0, KCollectionHelperTestClass, KExample );
       
   435     // Print to log file
       
   436     iLog->Log( KExample );
       
   437 
       
   438     TInt i = 0;
       
   439     TPtrC string;
       
   440     _LIT( KParam, "Param[%i]: %S" );
       
   441     while ( aItem.GetNextString ( string ) == KErrNone )
       
   442         {
       
   443         TestModuleIf().Printf( i, KCollectionHelperTestClass, 
       
   444                                 KParam, i, &string );
       
   445         i++;
       
   446         }
       
   447 
       
   448     return KErrNone;
       
   449     }     
       
   450 // -----------------------------------------------------------------------------
       
   451 // CCollectionHelperTestClass::OpenCollectionUtilityL()
       
   452 // Returns: Symbian OS errors.
       
   453 // -----------------------------------------------------------------------------
       
   454     
       
   455 TInt CCollectionHelperTestClass::OpenCollectionUtilityL(CStifItemParser& /*aItem*/)
       
   456 	{    
       
   457 	FTRACE(FPrint(_L("CCollectionHelperTest::OpenCollectionUtilityL")));
       
   458 	iLog->Log(_L("CCollectionHelperTestClass::OpenCollectionUtilityL"));
       
   459 		
       
   460     TRAPD( result, iCollectionUtility->Collection().OpenL() );
       
   461     
       
   462 	if( KErrNone == result )
       
   463 		{		
       
   464 		AddExpectedEvent( EHandleCollectionMessage, KMediumTimeout );
       
   465 		AddExpectedEvent( EHandleOpen, KMediumTimeout );
       
   466 		}
       
   467 	
       
   468 	return result;
       
   469     }    
       
   470 	    	
       
   471 // -----------------------------------------------------------------------------
       
   472 // CCollectionHelperTestClass::NewUiHelperL()
       
   473 // Returns: Symbian OS errors.
       
   474 // -----------------------------------------------------------------------------
       
   475 	    	
       
   476 TInt CCollectionHelperTestClass::NewUiHelperL(CStifItemParser& /*aItem*/)
       
   477 	{
       
   478 	FTRACE(FPrint(_L("CCollectionHelperTest::NewUiHelperL")));
       
   479 	iLog->Log(_L("CCollectionHelperTestClass::NewUiHelperL"));
       
   480 
       
   481 	TRAPD( result, iUIHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL() ); 
       
   482 
       
   483 	return result;
       
   484     }    
       
   485 
       
   486 // -----------------------------------------------------------------------------
       
   487 // CCollectionHelperTestClass::NewHelperL()
       
   488 // Returns: Symbian OS errors.
       
   489 // -----------------------------------------------------------------------------
       
   490 		
       
   491 TInt CCollectionHelperTestClass::NewHelperL(CStifItemParser& /*aItem*/)
       
   492 	{
       
   493 	FTRACE(FPrint(_L("CCollectionHelperTest::NewHelperL")));
       
   494 	iLog->Log(_L("CCollectionHelperTestClass::NewHelperL"));
       
   495 
       
   496 	TRAPD( result, iHelper = CMPXCollectionHelperFactory::NewCollectionHelperL() ); 
       
   497 
       
   498 	return result;
       
   499 	}
       
   500 // -----------------------------------------------------------------------------
       
   501 // CCollectionHelperTestClass::NewCachedHelperL()
       
   502 // Returns: Symbian OS errors.
       
   503 // -----------------------------------------------------------------------------
       
   504 
       
   505 TInt CCollectionHelperTestClass::NewCachedHelperL(CStifItemParser& /*aItem*/)
       
   506 	{
       
   507 	FTRACE(FPrint(_L("CCollectionHelperTest::NewCachedHelperL")));
       
   508 	iLog->Log(_L("CCollectionHelperTestClass::NewCachedHelperL"));
       
   509 
       
   510 	TRAPD( result, iCachedHelper = CMPXCollectionHelperFactory::NewCollectionCachedHelperL() ); 
       
   511 
       
   512 	return result;
       
   513 	}
       
   514 // -----------------------------------------------------------------------------
       
   515 // CCollectionHelperTestClass::CloseUiHelperL()
       
   516 // Returns: Symbian OS errors.
       
   517 // -----------------------------------------------------------------------------
       
   518 
       
   519 TInt CCollectionHelperTestClass::CloseUiHelperL(CStifItemParser& /*aItem*/)
       
   520 	{
       
   521 	FTRACE(FPrint(_L("CCollectionHelperTest::CloseUiHelperL")));
       
   522 	iLog->Log(_L("CCollectionHelperTestClass::CloseUiHelperL"));
       
   523 
       
   524 	TRAPD( result, iUIHelper->Close() ); 
       
   525 
       
   526 	return result;
       
   527 	}
       
   528 // -----------------------------------------------------------------------------
       
   529 // CCollectionHelperTestClass::CloseHelperL()
       
   530 // Returns: Symbian OS errors.
       
   531 // -----------------------------------------------------------------------------
       
   532 	
       
   533 TInt CCollectionHelperTestClass::CloseHelperL(CStifItemParser& /*aItem*/)
       
   534 	{
       
   535 	FTRACE(FPrint(_L("CCollectionHelperTest::CloseHelperL")));
       
   536 	iLog->Log(_L("CCollectionHelperTestClass::CloseHelperL"));
       
   537 	
       
   538 	TRAPD( result, iHelper->Close() ); 
       
   539 
       
   540 	return result;
       
   541 	}
       
   542 // -----------------------------------------------------------------------------
       
   543 // CCollectionHelperTestClass::CloseCachedHelperL()
       
   544 // Returns: Symbian OS errors.
       
   545 // -----------------------------------------------------------------------------
       
   546 	
       
   547 TInt CCollectionHelperTestClass::CloseCachedHelperL(CStifItemParser& /*aItem*/)
       
   548 	{
       
   549 	FTRACE(FPrint(_L("CCollectionHelperTest::CloseCachedHelperL")));
       
   550 	iLog->Log(_L("CCollectionHelperTestClass::CloseCachedHelperL"));
       
   551 
       
   552 	TRAPD( result, iCachedHelper->Close() ); 
       
   553 
       
   554 	return result;
       
   555 	}
       
   556 
       
   557 // ---------------------------------------------------------------------------
       
   558 // Handle collection message
       
   559 // ---------------------------------------------------------------------------
       
   560 //
       
   561 void CCollectionHelperTestClass::HandleCollectionMessageL(const CMPXMessage& aMsg)
       
   562     {
       
   563 	FTRACE(FPrint(_L("CCollectionHelperTestClass::HandleCollectionMessageL")));
       
   564 	iLog->Log(_L("CCollectionHelperTestClass::HandleCollectionMessageL"));
       
   565 	
       
   566 	if( aMsg.IsSupported(KMPXMessageGeneralEvent) &&
       
   567         aMsg.IsSupported(KMPXMessageGeneralType) )         
       
   568         {
       
   569         TMPXCollectionMessage::TEvent event = 
       
   570         *aMsg.Value<TMPXCollectionMessage::TEvent>( KMPXMessageGeneralEvent );
       
   571         TInt type = *aMsg.Value<TInt>( KMPXMessageGeneralType );
       
   572         TInt data = *aMsg.Value<TInt>( KMPXMessageGeneralData );
       
   573         
       
   574         TMPXCollectionMessage message(event, type, data);
       
   575 	    if(message.Event() == TMPXCollectionMessage::EPathChanged && 
       
   576 	       message.Type() == EMcPathChangedByOpen)
       
   577         	{
       
   578         	iCollectionUtility->Collection().OpenL();
       
   579         	
       
   580         	this->ProcessEvent(EHandleCollectionMessage, KErrNone);
       
   581         	}	
       
   582         }
       
   583     }
       
   584 
       
   585 // ---------------------------------------------------------------------------
       
   586 //  Handles the collection entries being opened. Typically called
       
   587 //  when client has Open()'d a folder
       
   588 // ---------------------------------------------------------------------------
       
   589 //
       
   590 void CCollectionHelperTestClass::HandleOpenL(const CMPXMedia& /*aEntries*/,
       
   591                                   TInt /*aIndex*/,TBool /*aComplete*/,TInt aError)
       
   592     {
       
   593 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleOpenL")));
       
   594 	iLog->Log(_L("CCollectionHelperTestClass::HandleOpenL"));
       
   595 	
       
   596 	this->ProcessEvent(EHandleOpen, aError);
       
   597     }
       
   598                      
       
   599 // ---------------------------------------------------------------------------
       
   600 // Handles the item being opened. Typically called
       
   601 // when client has Open()'d an item. Client typically responds by
       
   602 // 'playing' the item via the playlist
       
   603 // ---------------------------------------------------------------------------
       
   604 void CCollectionHelperTestClass::HandleOpenL(const CMPXCollectionPlaylist& /*aPlaylist*/,TInt /*aError*/)
       
   605     {
       
   606 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleOpenL")));
       
   607 	iLog->Log(_L("CCollectionHelperTestClass::HandleOpenL"));
       
   608     }
       
   609 
       
   610 // ---------------------------------------------------------------------------
       
   611 // Handle completion of a asynchronous command
       
   612 // ---------------------------------------------------------------------------
       
   613 void CCollectionHelperTestClass::HandleCommandComplete(CMPXCommand* /*aCommandResult*/, TInt /*aError*/)
       
   614     {
       
   615 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleCommandComplete")));
       
   616 	iLog->Log(_L("CCollectionHelperTestClass::HandleCommandComplete"));
       
   617 	
       
   618 	Signal();
       
   619 	iTimeoutController->Cancel();
       
   620     }
       
   621     
       
   622 // ---------------------------------------------------------------------------
       
   623 //  Handle extended media properties
       
   624 // ---------------------------------------------------------------------------
       
   625 //
       
   626 void CCollectionHelperTestClass::HandleCollectionMediaL(const CMPXMedia& /*aMedia*/, 
       
   627                                              TInt /*aError*/)
       
   628     {
       
   629 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleCollectionMediaL")));
       
   630 	iLog->Log(_L("CCollectionHelperTestClass::HandleCollectionMediaL"));
       
   631 	
       
   632 	Signal();
       
   633 	iTimeoutController->Cancel();
       
   634     }
       
   635 
       
   636 // ---------------------------------------------------------------------------
       
   637 //  Handles removing a collection path
       
   638 // ---------------------------------------------------------------------------
       
   639 //
       
   640 void CCollectionHelperTestClass::HandleRemoveL(MDesCArray& /*aUriArray*/, TInt aError)
       
   641     {
       
   642 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleRemoveL")));
       
   643 	iLog->Log(_L("CCollectionHelperTestClass::HandleRemoveL"));
       
   644 	
       
   645 	this->ProcessEvent(EHandleRemove, aError);
       
   646     }
       
   647 
       
   648 // ---------------------------------------------------------------------------
       
   649 //  Handle callback for "find" operation
       
   650 // ---------------------------------------------------------------------------
       
   651 //
       
   652 void CCollectionHelperTestClass::HandleFindAllL(const CMPXMedia& /*aResults*/, TBool aComplete,
       
   653                                      TInt aError)
       
   654     {
       
   655 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleFindAllL")));
       
   656 	iLog->Log(_L("CCollectionHelperTestClass::HandleFindAllL"));
       
   657 	
       
   658 	if(aComplete)
       
   659 		{
       
   660 		this->ProcessEvent(EHandleFindAllComplete, aError);
       
   661 		}
       
   662 		else 
       
   663 		{
       
   664 		this->ProcessEvent(EHandleFindAllComplete, KErrGeneral );
       
   665 		}	
       
   666     }
       
   667    
       
   668 // ---------------------------------------------------------------------------
       
   669 //  Handle callback for "AddFileComplete" operation
       
   670 // ---------------------------------------------------------------------------
       
   671 //
       
   672 void CCollectionHelperTestClass::HandleAddFileCompleteL( TInt aErr )
       
   673 	{
       
   674 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleAddFileCompleteL")));
       
   675 	iLog->Log(_L("CCollectionHelperTestClass::HandleAddFileCompleteL"));
       
   676 	
       
   677 	this->ProcessEvent(EHandleAddFileComplete, aErr);
       
   678 	}
       
   679 // ---------------------------------------------------------------------------
       
   680 //  Handle callback for "OperationComplete" operation
       
   681 // ---------------------------------------------------------------------------
       
   682 //
       
   683 void CCollectionHelperTestClass::HandleOperationCompleteL( 
       
   684 		TCHelperOperation /*aOperation*/, TInt /*aErr*/, void* /*aArgument*/ )
       
   685     {
       
   686 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleOperationCompleteL")));
       
   687 	iLog->Log(_L("CCollectionHelperTestClass::HandleOperationCompleteL"));
       
   688 	
       
   689 	Signal();
       
   690 	iTimeoutController->Cancel();
       
   691 	}      
       
   692 // ---------------------------------------------------------------------------
       
   693 //  Handle callback for "EmbeddedOpen" operation
       
   694 // ---------------------------------------------------------------------------
       
   695 //	                                 
       
   696 void CCollectionHelperTestClass::HandleEmbeddedOpenL( 
       
   697 		TInt /*aErr*/, TMPXGeneralCategory /*aCategory*/ )
       
   698     {
       
   699 	FTRACE(FPrint(_L("CCollectionHelperTest::HandleEmbeddedOpenL")));
       
   700 	iLog->Log(_L("CCollectionHelperTestClass::HandleEmbeddedOpenL"));
       
   701 	
       
   702 	Signal();
       
   703 	iTimeoutController->Cancel();
       
   704 	}
       
   705 //add new function
       
   706