mmaudio_pub/audio_effects_presets_api/tsrc/EffectPresetsTest/src/EffectPresetTestBase.cpp
changeset 0 b8ed18f6c07b
child 5 b220a9341636
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 /*
       
     2 * Copyright (c) 2008 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:  EffectsPresets
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "EffectPresetsTest.h"
       
    22 #include "EffectPresetTestCore.h"
       
    23 
       
    24 // EXTERNAL DATA STRUCTURES
       
    25 //extern  ?external_data;
       
    26 
       
    27 // EXTERNAL FUNCTION PROTOTYPES
       
    28 //extern ?external_function( ?arg_type,?arg_type );
       
    29 
       
    30 // CONSTANTS
       
    31 //const ?type ?constant_var = ?constant;
       
    32 const TInt CEffectPresetsTest::KTestCaseEffectPreset=1201;
       
    33 const TInt CEffectPresetsTest::MAX_TESTCASE_ID=1201;
       
    34 
       
    35 
       
    36 // ============================= LOCAL FUNCTIONS ===============================
       
    37 
       
    38 TInt CEffectPresetsTest::RunTestCaseFunctionL(TInt id, CStifSectionParser *section, TTestResult &aResult)
       
    39 	{
       
    40 	TInt retValue=KErrConfigInvalid;
       
    41 	aResult.iResult=KErrNotExecuted;
       
    42 
       
    43 	switch (id)
       
    44 	{
       
    45 		case KTestCaseEffectPreset:
       
    46 		    retValue = TestCaseAudioEffectPresetL(section, aResult);
       
    47 		    break;
       
    48 
       
    49 		default:
       
    50 			aResult.iResultDes.Copy(KConfigInvalid());
       
    51 			aResult.iResult = KErrNotExecuted;
       
    52 	}
       
    53 
       
    54 	return retValue;
       
    55 	}
       
    56 
       
    57 TInt CEffectPresetsTest::TestCaseAudioEffectPresetL(CStifSectionParser *aSection, TTestResult & aResult)
       
    58 	{
       
    59 	TInt err = KErrNone;
       
    60 
       
    61 	if (CreateEffectUtilityL(aSection, aResult))
       
    62 		return KErrExecuted;
       
    63 
       
    64 	if (AssignEffectObjectL(aSection, aResult))
       
    65 	{
       
    66 		deleteObject();
       
    67 		return KErrExecuted;
       
    68 	}
       
    69 
       
    70 	CStifItemParser *item = aSection->GetNextItemLineL(_L(""));
       
    71 	while (item)
       
    72 	{
       
    73 		CleanupStack::PushL(item);
       
    74 		err = iTestAudioEffectPreset->ProcessTag(item, aResult);
       
    75 		CleanupStack::PopAndDestroy(item);
       
    76 
       
    77 		if (err)
       
    78 		{
       
    79 			item = NULL;
       
    80 		}
       
    81 		else
       
    82 		{
       
    83 			item = aSection->GetNextItemLineL(_L(""));
       
    84 		}
       
    85 	}
       
    86 
       
    87 	deleteObject();
       
    88 	return KErrExecuted;
       
    89 	}
       
    90 
       
    91 
       
    92 TInt CEffectPresetsTest::CreateEffectUtilityL(CStifSectionParser *aSection, TTestResult & aResult)
       
    93 	{
       
    94 	TInt err = KErrNone;
       
    95 
       
    96 	// read in audio effect
       
    97 	TPtrC audioEffectPtr;
       
    98 	if ( aSection->GetLine(KTagAudioEffectUtility, audioEffectPtr, ENoTag) )
       
    99 	{
       
   100 		iLogger->Log(_L("Missing tag AudioEffect"));
       
   101 		aResult.iResultDes.Copy(KConfigInvalid());
       
   102 		aResult.iResult = KErrNotExecuted ;
       
   103 		return KErrArgument;
       
   104 	}
       
   105 
       
   106 	iLogger->Log(_L("Audio Effect [%S]"), &audioEffectPtr);
       
   107 
       
   108 	err = SetUtility(audioEffectPtr);
       
   109 	if (err)
       
   110 	{
       
   111 		iLogger->Log(_L("Unable to create Audio Effect."));
       
   112 		aResult.iResultDes.Copy(KTestCaseResultFail());
       
   113 		aResult.iResult = err ;
       
   114 		return KErrArgument;
       
   115 	}
       
   116 
       
   117 	iLogger->Log(_L("Create Audio Effect Successful."));
       
   118 	aResult.iResultDes.Copy(KTestCaseResultSuccess());
       
   119 	aResult.iResult = err ;
       
   120 	return err;
       
   121 	}
       
   122 
       
   123 TInt CEffectPresetsTest::SetUtility(TPtrC aAudioEffectUtilityName)
       
   124 	{
       
   125 	TInt err = KErrNone;
       
   126 
       
   127 	if (!aAudioEffectUtilityName.Compare(KEqualizerUtility))
       
   128 	{
       
   129 		TRAP(err, iTestAudioEffectPreset = CTestAudioEqualizerUtility::NewL(iLogger));
       
   130 		iObject = EEqualizer;
       
   131 		return err;
       
   132 	}
       
   133 
       
   134 	if (!aAudioEffectUtilityName.Compare(KEnvironmentalReverbUtility))
       
   135 	{
       
   136 		TRAP(err, iTestAudioEffectPreset = CTestEnvironmentalReverbUtility::NewL(iLogger));
       
   137         iObject = EEnvironmentalReverb;
       
   138 		return err;
       
   139 	}
       
   140 
       
   141 	if (!aAudioEffectUtilityName.Compare(KStereoWideningUtility))
       
   142 	{
       
   143 		TRAP(err, iTestAudioEffectPreset = CTestStereoWideningUtility::NewL(iLogger));
       
   144         iObject = EStereoWidening;
       
   145 		return err;
       
   146 	}
       
   147 
       
   148 	return KErrArgument;
       
   149 	}
       
   150 
       
   151 
       
   152 TInt CEffectPresetsTest::AssignEffectObjectL(CStifSectionParser *aSection, TTestResult & aResult)
       
   153 	{
       
   154 	TInt err = KErrNone;
       
   155 
       
   156 	// read in audio effect
       
   157 	TPtrC assignEffectPtr;
       
   158 	if ( aSection->GetLine(KTagEffectObject, assignEffectPtr, ENoTag) )
       
   159 	{
       
   160 		iLogger->Log(_L("Missing tag AssignEffect"));
       
   161 		aResult.iResultDes.Copy(KConfigInvalid());
       
   162 		aResult.iResult = KErrNotExecuted ;
       
   163 		return KErrArgument;
       
   164 	}
       
   165 
       
   166 	iLogger->Log(_L("Assign Effect to [%S]"), &assignEffectPtr);
       
   167 
       
   168 	err = AssignObject(assignEffectPtr);
       
   169 	if (err)
       
   170 	{
       
   171 		iLogger->Log(_L("Unable to assign Audio Effect."));
       
   172 		aResult.iResultDes.Copy(KTestCaseResultFail());
       
   173 		aResult.iResult = err ;
       
   174 		return KErrArgument;
       
   175 	}
       
   176 
       
   177 
       
   178 	iLogger->Log(_L("Assign Audio Effect Successful."));
       
   179 	aResult.iResultDes.Copy(KTestCaseResultSuccess());
       
   180 	aResult.iResult = err ;
       
   181 	return err;
       
   182 	}
       
   183 
       
   184 
       
   185 TInt CEffectPresetsTest::AssignObject(TPtrC aAssignEffectObjectName)
       
   186 	{
       
   187 	TInt err = KErrNone;
       
   188 
       
   189 	if (!aAssignEffectObjectName.Compare(KPlayer))
       
   190 	{
       
   191 		err = iTestAudioEffectPreset->AssignObject(iAudioPlayer);
       
   192 		return err;
       
   193 	}
       
   194 
       
   195 	if (!aAssignEffectObjectName.Compare(KRecorder))
       
   196 	{
       
   197 		err = iTestAudioEffectPreset->AssignObject(iAudioRecorder);
       
   198 		return err;
       
   199 	}
       
   200 
       
   201 	if (!aAssignEffectObjectName.Compare(KConverter))
       
   202 	{
       
   203 		err = iTestAudioEffectPreset->AssignObject(iAudioConverter);
       
   204 		return err;
       
   205 	}
       
   206 
       
   207 	if (!aAssignEffectObjectName.Compare(KTone))
       
   208 	{
       
   209 		err = iTestAudioEffectPreset->AssignObject(iAudioTone);
       
   210 		return err;
       
   211 	}
       
   212 
       
   213 	if (!aAssignEffectObjectName.Compare(KDevSound))
       
   214 	{
       
   215 		err = iTestAudioEffectPreset->AssignObject(iDevSound);
       
   216 		return err;
       
   217 	}
       
   218 
       
   219 	if (!aAssignEffectObjectName.Compare(KCustomCommand))
       
   220 	{
       
   221 		iCustomCommandUtility = CCustomCommandUtility::NewL(*iAudioPlayer);
       
   222 		err = iTestAudioEffectPreset->AssignObject(iCustomCommandUtility);
       
   223 		return err;
       
   224 	}
       
   225 
       
   226 	if (!aAssignEffectObjectName.Compare(KCustomInterface))
       
   227 	{
       
   228 		iCustomCommandUtility = CCustomCommandUtility::NewL(*iAudioPlayer);
       
   229 		iCustomInterfaceUtility = CCustomInterfaceUtility::NewL(*iCustomCommandUtility);
       
   230 	    err = iTestAudioEffectPreset->AssignObject(iCustomInterfaceUtility);
       
   231 		return err;
       
   232 	}
       
   233 
       
   234 	if (!aAssignEffectObjectName.Compare(KInputStream))
       
   235 	{
       
   236 		err = iTestAudioEffectPreset->AssignObject(iAudioInputStream);
       
   237 		return err;
       
   238 	}
       
   239 
       
   240 	if (!aAssignEffectObjectName.Compare(KOutputStream))
       
   241 	{
       
   242 		err = iTestAudioEffectPreset->AssignObject(iAudioOutputStream);
       
   243 		return err;
       
   244 	}
       
   245 
       
   246 	if (!aAssignEffectObjectName.Compare(KMidiClient))
       
   247 		{
       
   248 		err = iTestAudioEffectPreset->AssignObject(iMidiClientUtility);
       
   249 		return err;
       
   250 		}
       
   251 
       
   252 	if (!aAssignEffectObjectName.Compare(KDrmPlayer))
       
   253 		{
       
   254 		err = iTestAudioEffectPreset->AssignObject(iDrmPlayerUtility);
       
   255 		return err;
       
   256 		}
       
   257 
       
   258 	if (!aAssignEffectObjectName.Compare(KVideoPlayer))
       
   259 		{
       
   260 		err = iTestAudioEffectPreset->AssignObject(iVideoPlayerUtility);
       
   261 		return err;
       
   262 		}
       
   263 	return KErrArgument;
       
   264 	}
       
   265 
       
   266 
       
   267 void CEffectPresetsTest::deleteObject()
       
   268 	{
       
   269 	if (iTestAudioEffectPreset != NULL)
       
   270 	{
       
   271 	    switch(iObject)
       
   272     	{
       
   273 			case EEqualizer:
       
   274         		delete (CTestAudioEqualizerUtility*)iTestAudioEffectPreset;
       
   275 				break;
       
   276 			case EEnvironmentalReverb:
       
   277     	    	delete (CTestEnvironmentalReverbUtility*)iTestAudioEffectPreset;
       
   278 				break;
       
   279 			case EStereoWidening:
       
   280     	    	delete (CTestStereoWideningUtility*)iTestAudioEffectPreset;
       
   281 				break;
       
   282     	}
       
   283 	}
       
   284 
       
   285 	iTestAudioEffectPreset = NULL;
       
   286 	iObject = EENone;
       
   287 	}
       
   288 
       
   289 
       
   290 // ========== Callback Functions ==========
       
   291 //
       
   292 void CEffectPresetsTest::MapcInitComplete(TInt aStatus, const TTimeIntervalMicroSeconds& aDuration)
       
   293 	{
       
   294 	iLogger->Log(_L("MapcInit: %d"), aStatus);
       
   295 	TInt d = I64INT(aDuration.Int64());
       
   296 	RDebug::Print(_L("CEffectPresetsTest::MapcInitComplete :-> Status[%d] Duration[%d]"), aStatus, d);
       
   297 
       
   298 	if (aStatus != KErrNone)
       
   299 		{
       
   300 		iLogger->Log(_L("Cannot open "));
       
   301 		iLogger->Log(KAMRTestFile);
       
   302 		iLogger->Log(_L("\nPress any key to exit ..."));
       
   303 		}
       
   304 	else
       
   305 		{
       
   306 			iLogger->Log(_L("Ready!"));
       
   307 		}
       
   308 
       
   309 	CActiveScheduler::Stop();
       
   310 	}
       
   311 
       
   312 
       
   313 void CEffectPresetsTest::MapcPlayComplete(TInt aErr)
       
   314 	{
       
   315 	iLogger->Log(_L("MapcPlay: %d"), aErr);
       
   316 	RDebug::Print(_L("CEffectPresetsTest::MapcPlayComplete :-> Error[%d]"), aErr);
       
   317 	}
       
   318 
       
   319 
       
   320 void CEffectPresetsTest::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
       
   321 	{
       
   322 	RDebug::Print(_L("aPreviousState[%d], aCurrentState[%d], aErrorCode[%d]"), aPreviousState, aCurrentState, aErrorCode);
       
   323 	iLogger->Log(_L("Mosco: %d"), aErrorCode);
       
   324 	CActiveScheduler::Stop();
       
   325 	}
       
   326 
       
   327 
       
   328 void CEffectPresetsTest::MatoPrepareComplete(TInt aError)
       
   329 	{
       
   330 	RDebug::Print(_L("aError[%d]"), aError);
       
   331 	iLogger->Log(_L("MatoPrepareComplete: %d"), aError);
       
   332 	}
       
   333 
       
   334 
       
   335 void CEffectPresetsTest::MatoPlayComplete(TInt aError)
       
   336 	{
       
   337 	RDebug::Print(_L("aError[%d]"), aError);
       
   338 	iLogger->Log(_L("MatoPlayComplete: %d"), aError);
       
   339 	}
       
   340 
       
   341 
       
   342 void CEffectPresetsTest::MaiscOpenComplete(TInt aError)
       
   343 	{
       
   344 	RDebug::Print(_L("aError[%d]"), aError);
       
   345 	iLogger->Log(_L("MaiscOpenComplete: %d"), aError);
       
   346 	}
       
   347 
       
   348 
       
   349 void CEffectPresetsTest::MaiscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
       
   350 	{
       
   351 	RDebug::Print(_L("aError[%d]"), aError);
       
   352 	iLogger->Log(_L("MaiscBufferCopied: %d"), aError);
       
   353 	}
       
   354 
       
   355 
       
   356 void CEffectPresetsTest::MaiscRecordComplete(TInt aError)
       
   357 	{
       
   358 	RDebug::Print(_L("aError[%d]"), aError);
       
   359 	iLogger->Log(_L("MaiscRecordComplete: %d"), aError);
       
   360 	}
       
   361 
       
   362 
       
   363 void CEffectPresetsTest::MaoscOpenComplete(TInt aError)
       
   364 	{
       
   365 	RDebug::Print(_L("aError[%d]"), aError);
       
   366 	iLogger->Log(_L("MaoscOpenComplete: %d\n"), aError);
       
   367 	}
       
   368 
       
   369 
       
   370 void CEffectPresetsTest::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
       
   371 	{
       
   372 	RDebug::Print(_L("aError[%d]"), aError);
       
   373 	iLogger->Log(_L("MaoscBufferCopied: %d"), aError);
       
   374 	}
       
   375 
       
   376 
       
   377 void CEffectPresetsTest::MaoscPlayComplete(TInt aError)
       
   378 	{
       
   379 	RDebug::Print(_L("aError[%d]"), aError);
       
   380 	iLogger->Log(_L("MaoscPlayComplete: %d"), aError);
       
   381 	}
       
   382 
       
   383 void CEffectPresetsTest::MmcuoStateChanged(TMidiState /*aOldState*/,TMidiState aNewState,const TTimeIntervalMicroSeconds& /*aTime*/,TInt aError)
       
   384 	{
       
   385 	RDebug::Print(_L("MmcuoStateChanged->MidiState %d"), aNewState);
       
   386 	iLogger->Log(_L("MmcuoStateChanged: %d\n"), aError);
       
   387 	}
       
   388 
       
   389 void CEffectPresetsTest::MmcuoTempoChanged(TInt aMicroBeatsPerMinute)
       
   390 	{
       
   391 	RDebug::Print(_L("MmcuoTempoChanged->MicroBeatsPerMinute %d"), aMicroBeatsPerMinute);
       
   392 	iLogger->Log(_L("MmcuoTempoChanged->MicroBeatsPerMinute %d\n"), aMicroBeatsPerMinute);
       
   393 	}
       
   394 
       
   395 
       
   396 void CEffectPresetsTest::MmcuoVolumeChanged(TInt /*aChannel*/,TReal32 aVolumeInDecibels)
       
   397 	{
       
   398 	RDebug::Print(_L("MmcuoVolumeChanged->Volume %f"), aVolumeInDecibels);
       
   399 	iLogger->Log(_L("MmcuoVolumeChanged->Volume %f\n"), aVolumeInDecibels);
       
   400 	}
       
   401 
       
   402 
       
   403 void CEffectPresetsTest::MmcuoMuteChanged(TInt /*aChannel*/,TBool aMuted)
       
   404 	{
       
   405 	RDebug::Print(_L("MmcuoMuteChanged->Muted %d"), aMuted);
       
   406 	iLogger->Log(_L("MmcuoMuteChanged->Muted %d\n"), aMuted);
       
   407 	}
       
   408 
       
   409 void CEffectPresetsTest::MmcuoSyncUpdate(const TTimeIntervalMicroSeconds& /*aMicroSeconds*/,TInt64 aMicroBeats)
       
   410 	{
       
   411 	RDebug::Print(_L("MmcuoSyncUpdate->MicroBeats %d"), aMicroBeats);
       
   412 	iLogger->Log(_L("MmcuoSyncUpdate->MicroBeats %d\n"), aMicroBeats);
       
   413 	}
       
   414 
       
   415 void CEffectPresetsTest::MmcuoMetaDataEntryFound(const TInt aMetaDataEntryId,const TTimeIntervalMicroSeconds& /*aPosition*/)
       
   416 	{
       
   417 	RDebug::Print(_L("MmcuoMetaDataEntryFound->EntryId %d"), aMetaDataEntryId);
       
   418 	iLogger->Log(_L("MmcuoMetaDataEntryFound->EntryId %d\n"), aMetaDataEntryId);
       
   419 	}
       
   420 
       
   421 void CEffectPresetsTest::MmcuoMipMessageReceived(const RArray<TMipMessageEntry>& /*aMessage*/)
       
   422 	{
       
   423 	RDebug::Print(_L("MmcuoMipMessageReceived"));
       
   424 	iLogger->Log(_L("MmcuoMipMessageReceived\n"));
       
   425 	}
       
   426 
       
   427 void CEffectPresetsTest::MmcuoPolyphonyChanged(TInt aNewPolyphony)
       
   428 	{
       
   429 	RDebug::Print(_L("MmcuoPolyphonyChanged: %d"), aNewPolyphony);
       
   430 	iLogger->Log(_L("MmcuoPolyphonyChanged: %d\n"), aNewPolyphony);
       
   431 	}
       
   432 
       
   433 void CEffectPresetsTest::MmcuoInstrumentChanged(TInt /*aChannel*/,TInt /*aBankId*/,TInt aInstrumentId)
       
   434 	{
       
   435 	RDebug::Print(_L("MmcuoInstrumentChanged->InstrumentId %d"), aInstrumentId);
       
   436 	iLogger->Log(_L("MmcuoInstrumentChanged->InstrumentId %d\n"), aInstrumentId);
       
   437 	}
       
   438 
       
   439 void CEffectPresetsTest::MdapcInitComplete(TInt aStatus, const TTimeIntervalMicroSeconds& aDuration)
       
   440 	{
       
   441 	iLogger->Log(_L("MdapcInit: %d"), aStatus);
       
   442 	TInt d = I64INT(aDuration.Int64());
       
   443 	RDebug::Print(_L("CEffectPresetsTest::MdapcInitComplete :-> Status[%d] Duration[%d]"), aStatus, d);
       
   444 	if (aStatus != KErrNone)
       
   445 		{
       
   446 		iLogger->Log(_L("Cannot open "));
       
   447 		iLogger->Log(KAMRTestFile);
       
   448 		iLogger->Log(_L("\nPress any key to exit ..."));
       
   449 		}
       
   450 	else
       
   451 		{
       
   452 		iLogger->Log(_L("Ready!"));
       
   453 		}
       
   454 
       
   455 	CActiveScheduler::Stop();
       
   456 	}
       
   457 
       
   458 void CEffectPresetsTest::MdapcPlayComplete(TInt aErr)
       
   459 	{
       
   460 		iLogger->Log(_L("MdapcPlay: %d"), aErr);
       
   461 		RDebug::Print(_L("CEffectPresetsTest::MdapcPlayComplete :-> Error[%d]"), aErr);
       
   462 	}
       
   463 
       
   464 
       
   465 void CEffectPresetsTest::MvpuoOpenComplete(TInt aError)
       
   466 	{
       
   467 
       
   468 	iLogger->Log(_L("MvpuoOpenComplete: %d"), aError);
       
   469 	RDebug::Print(_L("CEffectPresetsTest::MvpuoOpenComplete :-> Error[%d]"), aError);
       
   470 
       
   471 	if (aError != KErrNone)
       
   472 		{
       
   473 		iLogger->Log(_L("Cannot open "));
       
   474 		iLogger->Log(K3gpTestFile);
       
   475 		iLogger->Log(_L("\nPress any key to exit ..."));
       
   476 		}
       
   477 	else
       
   478 		{
       
   479 			iLogger->Log(_L("Ready!"));
       
   480 		}
       
   481 
       
   482 	CActiveScheduler::Stop();
       
   483 	}
       
   484 
       
   485 void CEffectPresetsTest::MvpuoPrepareComplete(TInt aError)
       
   486 	{
       
   487 	iLogger->Log(_L("MvpuoPrepareComplete: %d"), aError);
       
   488 	RDebug::Print(_L("CEffectPresetsTest::MvpuoPrepareComplete :-> Error[%d]"), aError);
       
   489 	}
       
   490 
       
   491 void CEffectPresetsTest::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt aError)
       
   492 	{
       
   493 	iLogger->Log(_L("MvpuoFrameReady: %d"), aError);
       
   494 	RDebug::Print(_L("CEffectPresetsTest::MvpuoFrameReady :-> Error[%d]"), aError);
       
   495 	}
       
   496 
       
   497 void CEffectPresetsTest::MvpuoPlayComplete(TInt aError)
       
   498 	{
       
   499 	iLogger->Log(_L("MvpuoPrepareComplete: %d"), aError);
       
   500 	RDebug::Print(_L("CEffectPresetsTest::MvpuoPrepareComplete :-> Error[%d]"), aError);
       
   501 	}
       
   502 
       
   503 void CEffectPresetsTest::MvpuoEvent(const TMMFEvent& aEvent)
       
   504 	{
       
   505 	iLogger->Log(_L("MvpuoPrepareComplete: %x"), aEvent);
       
   506 	RDebug::Print(_L("CEffectPresetsTest::MvpuoPrepareComplete :-> Error[%x]"), aEvent);
       
   507 	}