sl@0: sl@0: // GlobalEffectTest.cpp sl@0: sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "GlobalEffectTest.h" sl@0: #include "TestGlobalEffect.hrh" sl@0: #include "TestEffect.h" sl@0: sl@0: #include sl@0: sl@0: sl@0: // sl@0: // RGlobalEffectPrimitiveTest sl@0: // sl@0: sl@0: RGlobalEffectPrimitiveTest* RGlobalEffectPrimitiveTest::NewL(TBool aAllocTest) sl@0: { sl@0: RGlobalEffectPrimitiveTest* self = new (ELeave) RGlobalEffectPrimitiveTest(aAllocTest); sl@0: return self; sl@0: } sl@0: sl@0: RGlobalEffectPrimitiveTest::RGlobalEffectPrimitiveTest(TBool /*aAllocTest*/) sl@0: { sl@0: iTestStepName = _L("MM-MMF-GEF-U-001"); sl@0: } sl@0: sl@0: TVerdict RGlobalEffectPrimitiveTest::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Check can actually open test GlobalEffect plugin")); sl@0: TVerdict result = EPass; sl@0: sl@0: __MM_HEAP_MARK; sl@0: sl@0: CTestGlobalEffect* plugin = NULL; sl@0: sl@0: TRAPD(error, plugin = CTestGlobalEffect::NewL(NULL)); sl@0: sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("plugin opened as expected")); sl@0: delete plugin; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error); sl@0: result = EFail; sl@0: } sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: return result; sl@0: } sl@0: sl@0: // sl@0: // RGlobalEffectStdTest sl@0: // sl@0: sl@0: RGlobalEffectStdTest* RGlobalEffectStdTest::NewL(TBool aAllocTest) sl@0: { sl@0: RGlobalEffectStdTest* self = new (ELeave) RGlobalEffectStdTest(aAllocTest); sl@0: return self; sl@0: } sl@0: sl@0: RGlobalEffectStdTest::RGlobalEffectStdTest(TBool /*aAllocTest*/) sl@0: { sl@0: iTestStepName = _L("MM-MMF-GEF-U-002"); sl@0: } sl@0: sl@0: TVerdict RGlobalEffectStdTest::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Check standard plugins cleanup return errors")); sl@0: TVerdict result = EPass; sl@0: sl@0: { sl@0: __MM_HEAP_MARK; sl@0: sl@0: CMmfGlobalEqEffect* plugin = NULL; sl@0: sl@0: TRAPD(error, plugin = CMmfGlobalEqEffect::NewL(NULL)); sl@0: sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("GlobalEq plugin opened managed to open!")); sl@0: delete plugin; sl@0: result = EFail; sl@0: } sl@0: else if (error==KErrNotSupported) sl@0: { sl@0: INFO_PRINTF1(_L("GlobalEq plugin not supported - as expected")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("GlobalEq CreateImplementationL() failed - %d"), error); sl@0: result = EFail; sl@0: } sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: } sl@0: sl@0: { sl@0: __MM_HEAP_MARK; sl@0: sl@0: CMmfGlobalMegaEffect* plugin = NULL; sl@0: sl@0: TRAPD(error, plugin = CMmfGlobalMegaEffect::NewL(NULL)); sl@0: sl@0: if (error==KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("GlobalMega plugin opened managed to open!")); sl@0: delete plugin; sl@0: result = EFail; sl@0: } sl@0: else if (error==KErrNotSupported) sl@0: { sl@0: INFO_PRINTF1(_L("GlobalMega plugin not supported - as expected")); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("GlobalMega CreateImplementationL() failed - %d"), error); sl@0: result = EFail; sl@0: } sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: // sl@0: // RGlobalEffectMainTest sl@0: // sl@0: sl@0: RGlobalEffectMainTest* RGlobalEffectMainTest::NewL(TBool aAllocTest) sl@0: { sl@0: RGlobalEffectMainTest* self = new (ELeave) RGlobalEffectMainTest(aAllocTest); sl@0: return self; sl@0: } sl@0: sl@0: RGlobalEffectMainTest::RGlobalEffectMainTest(TBool /*aAllocTest*/) sl@0: { sl@0: iTestStepName = _L("MM-MMF-GEF-U-003"); sl@0: } sl@0: sl@0: TVerdict RGlobalEffectMainTest::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Check basic API calls on TestPlugin")); sl@0: TVerdict result = EPass; sl@0: sl@0: __MM_HEAP_MARK; sl@0: sl@0: CTestGlobalEffect* plugin = NULL; sl@0: sl@0: TRAPD(error, plugin = CTestGlobalEffect::NewL(NULL)); sl@0: sl@0: if (error!=KErrNone) sl@0: { sl@0: INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error); sl@0: return EFail; sl@0: } sl@0: sl@0: CleanupStack::PushL(plugin); sl@0: sl@0: { sl@0: // check Capability sl@0: TUint value = plugin->Capability(EFalse); sl@0: if (value!=0) sl@0: { sl@0: INFO_PRINTF2(_L("Capability(EFalse): expected 0 got - %d"), value); sl@0: result = EFail; sl@0: } sl@0: value = plugin->Capability(ETrue); sl@0: if (value!=0xffff) sl@0: { sl@0: INFO_PRINTF2(_L("Capability(ETrue): expected -1 got - %d"), value); sl@0: result = EFail; sl@0: } sl@0: } sl@0: sl@0: // check settings by des, uid or value sl@0: HBufC8* tempDes = NULL; sl@0: TUid tempUid; sl@0: TInt tempInt; sl@0: TPckg tempPackage (tempInt); sl@0: { sl@0: // initially (stage 1) nothing set, so SettingsByUidL() and ExtractValuesL() sl@0: // should leave KErrNotSupported, and SettingsByDesL() should return "1234" sl@0: sl@0: TRAP(error, tempDes = plugin->SettingsByDesL()); sl@0: if (error==KErrNone) sl@0: { sl@0: CleanupStack::PushL(tempDes); sl@0: if (*tempDes!=_L8("1234")) sl@0: { sl@0: HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); sl@0: tempDes16->Des().Copy(*tempDes); sl@0: INFO_PRINTF2(_L("Stage1: SettingsByDesL() expected \"1234\" got \"%S\""), tempDes16); sl@0: result = EFail; sl@0: CleanupStack::PopAndDestroy(tempDes16); sl@0: } sl@0: CleanupStack::PopAndDestroy(tempDes); sl@0: tempDes = NULL; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Stage1: SettingsByDesL() returned %d"), error); sl@0: result = EFail; sl@0: } sl@0: sl@0: TRAP(error, tempUid = plugin->SettingsByUidL()); sl@0: if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF3(_L("Stage1: SettingsByUidL() expected KErrNotSupported got %d(0x%x)"), error, tempUid.iUid); sl@0: result = EFail; sl@0: } sl@0: sl@0: TRAP(error, plugin->ExtractValuesL(tempPackage)); sl@0: if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF3(_L("Stage1: ExtractValuesL() expected KErrNotSupported got %d(%d)"), error, tempInt); sl@0: result = EFail; sl@0: } sl@0: sl@0: } sl@0: sl@0: { sl@0: // at stage 2, we set a value by UID, so now SettingsByUid returns something sensible sl@0: TUid sampleUid = {0x1234567}; // any silly value will do sl@0: plugin->SetSettingsByUidL(sampleUid); sl@0: sl@0: TRAP(error, tempDes = plugin->SettingsByDesL()); sl@0: if (error==KErrNone) sl@0: { sl@0: CleanupStack::PushL(tempDes); sl@0: if (*tempDes!=_L8("1234")) sl@0: { sl@0: HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); sl@0: tempDes16->Des().Copy(*tempDes); sl@0: INFO_PRINTF2(_L("Stage2: SettingsByDesL() expected \"1234\" got \"%S\""), tempDes16); sl@0: result = EFail; sl@0: CleanupStack::PopAndDestroy(tempDes16); sl@0: } sl@0: CleanupStack::PopAndDestroy(tempDes); sl@0: tempDes = NULL; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Stage2: SettingsByDesL() returned %d"), error); sl@0: result = EFail; sl@0: } sl@0: sl@0: TRAP(error, tempUid = plugin->SettingsByUidL()); sl@0: if (error!=KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Stage2: SettingsByUidL() expected KErrNone got %d(0x%x)"), error, tempUid.iUid); sl@0: result = EFail; sl@0: } sl@0: else if (tempUid != sampleUid) sl@0: { sl@0: INFO_PRINTF3(_L("Stage2: SettingsByUidL() expected return of 0x%x got 0x%x"), sampleUid.iUid, tempUid.iUid); sl@0: } sl@0: sl@0: TRAP(error, plugin->ExtractValuesL(tempPackage)); sl@0: if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF3(_L("Stage2: ExtractValuesL() expected KErrNotSupported got %d(%d)"), error, tempInt); sl@0: result = EFail; sl@0: } sl@0: sl@0: } sl@0: sl@0: { sl@0: // at stage 3, we set a value by des, so again only SettingsByDesL() gives valid results sl@0: _LIT8(KSampleDes, "89a"); sl@0: plugin->SetSettingsByDesL(KSampleDes); sl@0: sl@0: TRAP(error, tempDes = plugin->SettingsByDesL()); sl@0: if (error==KErrNone) sl@0: { sl@0: CleanupStack::PushL(tempDes); sl@0: if (*tempDes!=KSampleDes) sl@0: { sl@0: HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); sl@0: tempDes16->Des().Copy(*tempDes); sl@0: INFO_PRINTF2(_L("Stage3: SettingsByDesL() expected \"89a\" got \"%S\""), tempDes16); sl@0: result = EFail; sl@0: CleanupStack::PopAndDestroy(tempDes16); sl@0: } sl@0: CleanupStack::PopAndDestroy(tempDes); sl@0: tempDes = NULL; sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Stage3: SettingsByDesL() returned %d"), error); sl@0: result = EFail; sl@0: } sl@0: sl@0: TRAP(error, tempUid = plugin->SettingsByUidL()); sl@0: if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF3(_L("Stage3: SettingsByUidL() expected KErrNotSupported got %d(0x%x)"), error, tempUid.iUid); sl@0: result = EFail; sl@0: } sl@0: sl@0: TRAP(error, plugin->ExtractValuesL(tempPackage)); sl@0: if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF3(_L("Stage3: ExtractValuesL() expected KErrNotSupported got %d(%d)"), error, tempInt); sl@0: result = EFail; sl@0: } sl@0: } sl@0: sl@0: { sl@0: // at stage 4, we set a value by package buffer, so only that way returns valid value sl@0: const TInt sampleInt = 10; sl@0: TPckgC sampleBuffer (sampleInt); sl@0: plugin->SetByValuesL(sampleBuffer); sl@0: sl@0: TRAP(error, tempDes = plugin->SettingsByDesL()); sl@0: if (error==KErrNone) sl@0: { sl@0: CleanupStack::PushL(tempDes); sl@0: HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); sl@0: tempDes16->Des().Copy(*tempDes); sl@0: INFO_PRINTF2(_L("Stage4: SettingsByDesL() expected KErrNotSupported got \"%S\""), tempDes16); sl@0: result = EFail; sl@0: CleanupStack::PopAndDestroy(2, tempDes); sl@0: tempDes = NULL; sl@0: } sl@0: else if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF2(_L("Stage4: SettingsByDesL() expected KErrNotSupported returned %d"), error); sl@0: result = EFail; sl@0: } sl@0: sl@0: TRAP(error, tempUid = plugin->SettingsByUidL()); sl@0: if (error!=KErrNotSupported) sl@0: { sl@0: INFO_PRINTF3(_L("Stage4: SettingsByUidL() expected KErrNotSupported got %d(0x%x)"), error, tempUid.iUid); sl@0: result = EFail; sl@0: } sl@0: sl@0: TRAP(error, plugin->ExtractValuesL(tempPackage)); sl@0: if (error!=KErrNone) sl@0: { sl@0: INFO_PRINTF3(_L("Stage4: ExtractValuesL() expected KErrNone got %d(%d)"), error, tempInt); sl@0: result = EFail; sl@0: } sl@0: else if (tempInt!=sampleInt) sl@0: { sl@0: INFO_PRINTF3(_L("Stage4: ExtractValuesL() expected %d got %d"), sampleInt, tempInt); sl@0: result = EFail; sl@0: } sl@0: } sl@0: sl@0: { sl@0: // Check for Enabled() and IsActive() - should be false to start. poke value and show have sl@0: // changed. Have to use custom command for SetActive() since not really the way to drive sl@0: // - this should relate to the underlying implementation sl@0: TBool enabled = plugin->IsEnabled(); sl@0: TBool active = plugin->IsActive(); sl@0: if (enabled!=EFalse || active!=EFalse) sl@0: { sl@0: INFO_PRINTF3(_L("Check1: active(%d) and enabled(%d) should have been false"), active, enabled); sl@0: result = EFail; sl@0: } sl@0: plugin->SetEnabledL(ETrue); sl@0: plugin->SetActive(ETrue); sl@0: enabled = plugin->IsEnabled(); sl@0: active = plugin->IsActive(); sl@0: if (enabled==EFalse || active==EFalse) sl@0: { sl@0: INFO_PRINTF3(_L("Check2: active(%d) and enabled(%d) should have been true"), active, enabled); sl@0: result = EFail; sl@0: } sl@0: } sl@0: sl@0: { sl@0: // check preset - for test this ties up with the test plugin sl@0: const TInt KPresetsCount = 3; sl@0: MMmfGlobalAudioPresetList* list = plugin->KnownPresetsL(); sl@0: sl@0: // reproduce what the plugin will do and check sl@0: if (list->MdcaCount()!=KPresetsCount) sl@0: { sl@0: INFO_PRINTF3(_L("Expected %d presets, got %d"), KPresetsCount, list->MdcaCount()); sl@0: result = EFail; sl@0: } sl@0: else sl@0: { sl@0: for (TInt index=0; index name; sl@0: name.Num(index); sl@0: TUid tempUid={index}; sl@0: sl@0: TUid foundUid = list->GAPUidPoint(index); sl@0: const TPtrC foundName = list->MdcaPoint(index); sl@0: sl@0: if (foundUid!=tempUid) sl@0: { sl@0: INFO_PRINTF4(_L("Index %d, expected %x found %x"), index, tempUid.iUid, foundUid.iUid); sl@0: result = EFail; sl@0: } sl@0: if (foundName != name) sl@0: { sl@0: INFO_PRINTF4(_L("Index %d, expected %S found %S"), index, &name, &foundName); sl@0: result = EFail; sl@0: } sl@0: } sl@0: sl@0: } sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(plugin); sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: return result; sl@0: } sl@0: sl@0: // sl@0: // RGlobalEffectCallbackTest sl@0: // sl@0: sl@0: const TUid KUidTestGlbNotification = {KUidTestGlbNotificationDefine}; sl@0: sl@0: sl@0: RGlobalEffectCallbackTest* RGlobalEffectCallbackTest::NewL(TBool aAllocTest) sl@0: { sl@0: RGlobalEffectCallbackTest* self = new (ELeave) RGlobalEffectCallbackTest(aAllocTest); sl@0: return self; sl@0: } sl@0: sl@0: RGlobalEffectCallbackTest::RGlobalEffectCallbackTest(TBool /*aAllocTest*/) sl@0: { sl@0: iTestStepName = _L("MM-MMF-GEF-U-004"); sl@0: } sl@0: sl@0: void RGlobalEffectCallbackTest::GAEEventNotificationL(CMmfGlobalAudioEffect* aEffect, sl@0: TUid aEventUid, sl@0: const TDesC8& aParam) sl@0: { sl@0: INFO_PRINTF1(_L("Callback")); sl@0: if (aEffect!=iEffect) sl@0: { sl@0: INFO_PRINTF3(_L("Effect is %x, expected %d"), aEffect, iEffect); sl@0: iResult = EFail; sl@0: } sl@0: if (KUidTestGlbNotification != aEventUid) sl@0: { sl@0: INFO_PRINTF3(_L("Uid is %x, expected %x"), aEventUid.iUid, KUidTestGlbNotification.iUid); sl@0: iResult = EFail; sl@0: } sl@0: if (aParam != KNullDesC8) sl@0: { sl@0: INFO_PRINTF2(_L("Param=\"%S\", expected \"\""), &aParam); sl@0: iResult = EFail; sl@0: } sl@0: iCalledBack = ETrue; sl@0: } sl@0: sl@0: sl@0: TVerdict RGlobalEffectCallbackTest::DoTestStepL() sl@0: { sl@0: INFO_PRINTF1(_L("Check notification callback")); sl@0: iResult = EPass; sl@0: sl@0: __MM_HEAP_MARK; sl@0: sl@0: iEffect = CTestGlobalEffect::NewL(this); sl@0: CleanupStack::PushL(iEffect); sl@0: sl@0: // for test, just generate test synchronously sl@0: iEffect->RequestNotificationL(KUidTestGlbNotification); sl@0: iEffect->GenCallbackL(); sl@0: sl@0: if (!iCalledBack) sl@0: { sl@0: INFO_PRINTF1(_L("Callback seemingly did not happen")); sl@0: iResult = EFail; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(iEffect); sl@0: sl@0: __MM_HEAP_MARKEND; sl@0: sl@0: return iResult; sl@0: } sl@0: