os/mm/mmlibs/mmfw/tsrc/mmfunittest/GEF/Plugin/TestGlobalEffectPlugin.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/GEF/Plugin/TestGlobalEffectPlugin.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,213 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "TestGlobalEffectPlugin.h"
    1.20 +
    1.21 +#include <ecom/ecom.h>
    1.22 +#include <ecom/implementationproxy.h>
    1.23 +#include "../src/TestGlobalEffect.hrh"
    1.24 +
    1.25 +const TUid KUidTestGlbCustomCall = {KUidTestGlbCustomCallDefine};
    1.26 +const TInt KPresetsCount = 3;
    1.27 +
    1.28 +//
    1.29 +// CTestEffect
    1.30 +//
    1.31 +
    1.32 +CTestEffect::CTestEffect()
    1.33 +	{
    1.34 +	}
    1.35 +	
    1.36 +CTestEffect::~CTestEffect()
    1.37 +	{
    1.38 +	delete iSettingsDes;
    1.39 +	delete iPresetList;
    1.40 +	REComSession::DestroyedImplementation(iDestructorKey);
    1.41 +	}
    1.42 +	
    1.43 +MMmfGlobalAudioImpl* CTestEffect::NewL()
    1.44 +	{
    1.45 +	return new (ELeave) CTestEffect;
    1.46 +	}
    1.47 +
    1.48 +void CTestEffect::Release()
    1.49 +	{
    1.50 +	// this is effectively delete
    1.51 +	delete this;
    1.52 +	}
    1.53 +	
    1.54 +TUint CTestEffect::Capability(TBool aCurrentOnly)
    1.55 +	{
    1.56 +	// not totally clear what to do for testing purposes, so just return 0 or -1 depending on param
    1.57 +	return aCurrentOnly ? 0xffff : 0;
    1.58 +	}
    1.59 +	
    1.60 +void CTestEffect::RequestNotificationL(TUid aEventUid)
    1.61 +	{
    1.62 +	// for test, just remember the pass event uid and use in test GenCallbackL() call
    1.63 +	iNotifyUid = aEventUid;
    1.64 +	}
    1.65 +	
    1.66 +void CTestEffect::GenCallbackL()
    1.67 +	{
    1.68 +	iObserver->GAEEventNotificationL(iParent, iNotifyUid, KNullDesC8);
    1.69 +	}
    1.70 +	
    1.71 +TBool CTestEffect::IsEnabled() const
    1.72 +	{
    1.73 +	return iEnabled;
    1.74 +	}
    1.75 +	
    1.76 +void CTestEffect::SetEnabledL(TBool aBool)
    1.77 +	{
    1.78 +	iEnabled = aBool;
    1.79 +	}
    1.80 +	
    1.81 +TBool CTestEffect::IsActive() const
    1.82 +	{
    1.83 +	return iIsActive;
    1.84 +	}
    1.85 +	
    1.86 +void CTestEffect::SetActive(TBool aValue)
    1.87 +	{
    1.88 +	iIsActive = aValue;
    1.89 +	}
    1.90 +	
    1.91 +TUid CTestEffect::SettingsByUidL() const
    1.92 +	{
    1.93 +	if (iValueState!=ESetByUid)
    1.94 +		{
    1.95 +		User::Leave(KErrNotSupported);
    1.96 +		}
    1.97 +	return iSettingsUid;
    1.98 +	}
    1.99 +	
   1.100 +void CTestEffect::SetSettingsByUidL(TUid aPresetUid)
   1.101 +	{
   1.102 +	iSettingsUid = aPresetUid;
   1.103 +	iValueState = ESetByUid;
   1.104 +	}
   1.105 +	
   1.106 +HBufC8* CTestEffect::SettingsByDesL() const
   1.107 +	{
   1.108 +	// for test, if we've not set via Des then return default value - except for SetByValue
   1.109 +	_LIT8(KDefaultDes, "1234");
   1.110 +	if (iValueState==ESetByDes)
   1.111 +		{
   1.112 +		return iSettingsDes->AllocL();
   1.113 +		}
   1.114 +	else if (iValueState!=ESetByValue)
   1.115 +		{
   1.116 +		return KDefaultDes().AllocL();
   1.117 +		}
   1.118 +	else
   1.119 +		{
   1.120 +		User::Leave(KErrNotSupported);
   1.121 +		return NULL;
   1.122 +		}
   1.123 +	}
   1.124 +	
   1.125 +void CTestEffect::SetSettingsByDesL(const TDesC8& aParam)
   1.126 +	{
   1.127 +	delete iSettingsDes;
   1.128 +	iSettingsDes = NULL;
   1.129 +	iSettingsDes = aParam.Alloc();
   1.130 +	iValueState = ESetByDes;
   1.131 +	}
   1.132 +	
   1.133 +MMmfGlobalAudioPresetList* CTestEffect::KnownPresetsL()
   1.134 +	{
   1.135 +	delete iPresetList;
   1.136 +	iPresetList = NULL;
   1.137 +	iPresetList = CPresetList::NewL();
   1.138 +	
   1.139 +	// produce list of num in numeric and readable form, upto count
   1.140 +	for (TInt index=0; index<KPresetsCount; index++)
   1.141 +		{
   1.142 +		TBuf<10> name;
   1.143 +		name.Num(index);
   1.144 +		TUid tempUid={index};
   1.145 +		iPresetList->AppendL(tempUid, name);
   1.146 +		}
   1.147 +	return iPresetList;
   1.148 +	}
   1.149 +	
   1.150 +void CTestEffect::ExtractValuesL(TDes8& aPackageBuf)
   1.151 +	{
   1.152 +	if (iValueState!=ESetByValue)
   1.153 +		{
   1.154 +		User::LeaveIfError(KErrNotSupported);
   1.155 +		}
   1.156 +	TPckgC<TInt> packageBuf(iSettingsValue);
   1.157 +	aPackageBuf = packageBuf;
   1.158 +	}
   1.159 +	
   1.160 +void CTestEffect::SetByValuesL(const TDesC8& aPackageBuf)
   1.161 +	{
   1.162 +	TPckg<TInt> packageBuf(iSettingsValue);
   1.163 +	packageBuf.Copy(aPackageBuf);
   1.164 +	iValueState = ESetByValue;
   1.165 +	}
   1.166 +	
   1.167 +TInt CTestEffect::CreateCustomInterface(TUid aInterfaceUid)
   1.168 +	{
   1.169 +	if (aInterfaceUid==KUidTestGlbCustomCall)
   1.170 +		{
   1.171 +		// we derive from this anyway, so just return KErrNone to say supported
   1.172 +		return KErrNone;
   1.173 +		}
   1.174 +	return KErrNotSupported;
   1.175 +	}
   1.176 +
   1.177 +
   1.178 +TAny* CTestEffect::CustomInterface(TUid aInterfaceUid)
   1.179 +	{
   1.180 +	if (aInterfaceUid==KUidTestGlbCustomCall)
   1.181 +		{
   1.182 +		MTestEffectCustomIf* castedThis = this;
   1.183 +		return castedThis;
   1.184 +		}
   1.185 +	return NULL;
   1.186 +	}
   1.187 +		
   1.188 +void CTestEffect::PassDestructorKey(TUid aDestructorKey)
   1.189 +	{
   1.190 +	iDestructorKey = aDestructorKey;
   1.191 +	}
   1.192 +	
   1.193 +void CTestEffect::CompleteConstructL(CMmfGlobalAudioEffect* aParent, MMmfGlobalAudioEffectObserver* aObserver)
   1.194 +	{
   1.195 +	iParent = aParent;
   1.196 +	iObserver = aObserver;
   1.197 +	}
   1.198 +
   1.199 +
   1.200 +
   1.201 +
   1.202 +// __________________________________________________________________________
   1.203 +// Exported proxy for instantiation method resolution
   1.204 +// Define the interface UIDs
   1.205 +const TImplementationProxy ImplementationTable[] = 
   1.206 +	{
   1.207 +		IMPLEMENTATION_PROXY_ENTRY(KUidTestGlblPluginImpDefine,	CTestEffect::NewL),
   1.208 +	};
   1.209 +
   1.210 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   1.211 +	{
   1.212 +	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   1.213 +
   1.214 +	return ImplementationTable;
   1.215 +	}
   1.216 +