diff -r 000000000000 -r bde4ae8d615e os/mm/mmlibs/mmfw/tsrc/mmfunittest/GEF/Plugin/TestGlobalEffectPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/GEF/Plugin/TestGlobalEffectPlugin.cpp Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,213 @@ +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include "TestGlobalEffectPlugin.h" + +#include +#include +#include "../src/TestGlobalEffect.hrh" + +const TUid KUidTestGlbCustomCall = {KUidTestGlbCustomCallDefine}; +const TInt KPresetsCount = 3; + +// +// CTestEffect +// + +CTestEffect::CTestEffect() + { + } + +CTestEffect::~CTestEffect() + { + delete iSettingsDes; + delete iPresetList; + REComSession::DestroyedImplementation(iDestructorKey); + } + +MMmfGlobalAudioImpl* CTestEffect::NewL() + { + return new (ELeave) CTestEffect; + } + +void CTestEffect::Release() + { + // this is effectively delete + delete this; + } + +TUint CTestEffect::Capability(TBool aCurrentOnly) + { + // not totally clear what to do for testing purposes, so just return 0 or -1 depending on param + return aCurrentOnly ? 0xffff : 0; + } + +void CTestEffect::RequestNotificationL(TUid aEventUid) + { + // for test, just remember the pass event uid and use in test GenCallbackL() call + iNotifyUid = aEventUid; + } + +void CTestEffect::GenCallbackL() + { + iObserver->GAEEventNotificationL(iParent, iNotifyUid, KNullDesC8); + } + +TBool CTestEffect::IsEnabled() const + { + return iEnabled; + } + +void CTestEffect::SetEnabledL(TBool aBool) + { + iEnabled = aBool; + } + +TBool CTestEffect::IsActive() const + { + return iIsActive; + } + +void CTestEffect::SetActive(TBool aValue) + { + iIsActive = aValue; + } + +TUid CTestEffect::SettingsByUidL() const + { + if (iValueState!=ESetByUid) + { + User::Leave(KErrNotSupported); + } + return iSettingsUid; + } + +void CTestEffect::SetSettingsByUidL(TUid aPresetUid) + { + iSettingsUid = aPresetUid; + iValueState = ESetByUid; + } + +HBufC8* CTestEffect::SettingsByDesL() const + { + // for test, if we've not set via Des then return default value - except for SetByValue + _LIT8(KDefaultDes, "1234"); + if (iValueState==ESetByDes) + { + return iSettingsDes->AllocL(); + } + else if (iValueState!=ESetByValue) + { + return KDefaultDes().AllocL(); + } + else + { + User::Leave(KErrNotSupported); + return NULL; + } + } + +void CTestEffect::SetSettingsByDesL(const TDesC8& aParam) + { + delete iSettingsDes; + iSettingsDes = NULL; + iSettingsDes = aParam.Alloc(); + iValueState = ESetByDes; + } + +MMmfGlobalAudioPresetList* CTestEffect::KnownPresetsL() + { + delete iPresetList; + iPresetList = NULL; + iPresetList = CPresetList::NewL(); + + // produce list of num in numeric and readable form, upto count + for (TInt index=0; index name; + name.Num(index); + TUid tempUid={index}; + iPresetList->AppendL(tempUid, name); + } + return iPresetList; + } + +void CTestEffect::ExtractValuesL(TDes8& aPackageBuf) + { + if (iValueState!=ESetByValue) + { + User::LeaveIfError(KErrNotSupported); + } + TPckgC packageBuf(iSettingsValue); + aPackageBuf = packageBuf; + } + +void CTestEffect::SetByValuesL(const TDesC8& aPackageBuf) + { + TPckg packageBuf(iSettingsValue); + packageBuf.Copy(aPackageBuf); + iValueState = ESetByValue; + } + +TInt CTestEffect::CreateCustomInterface(TUid aInterfaceUid) + { + if (aInterfaceUid==KUidTestGlbCustomCall) + { + // we derive from this anyway, so just return KErrNone to say supported + return KErrNone; + } + return KErrNotSupported; + } + + +TAny* CTestEffect::CustomInterface(TUid aInterfaceUid) + { + if (aInterfaceUid==KUidTestGlbCustomCall) + { + MTestEffectCustomIf* castedThis = this; + return castedThis; + } + return NULL; + } + +void CTestEffect::PassDestructorKey(TUid aDestructorKey) + { + iDestructorKey = aDestructorKey; + } + +void CTestEffect::CompleteConstructL(CMmfGlobalAudioEffect* aParent, MMmfGlobalAudioEffectObserver* aObserver) + { + iParent = aParent; + iObserver = aObserver; + } + + + + +// __________________________________________________________________________ +// Exported proxy for instantiation method resolution +// Define the interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(KUidTestGlblPluginImpDefine, CTestEffect::NewL), + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } +