app/tsrc/unittest_mpglobalpopuphandler/stub/src/mpenginefactory.cpp
changeset 48 af3740e3753f
child 55 f3930dda3342
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/tsrc/unittest_mpglobalpopuphandler/stub/src/mpenginefactory.cpp	Wed Aug 18 09:46:20 2010 +0300
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 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: MpEngineFactory stub for testing MpNowPlayingWidget
+*
+*/
+
+
+#include "mpenginefactory.h"
+
+
+/*!
+ *  Stub function
+ */
+MpEngineFactory::MpEngineFactory()
+    : mSharedEngine( 0 )
+{
+}
+
+/*!
+ *  Stub function
+ */
+MpEngineFactory::~MpEngineFactory()
+{
+}
+
+/*!
+ *  Stub function
+ */
+MpEngineFactory * MpEngineFactory::instance()
+{
+    static MpEngineFactory instance;
+    return &instance;
+}
+
+/*!
+ *  Stub function
+ */
+MpEngine *MpEngineFactory::sharedEngine()
+{
+    if ( !instance()->mSharedEngine ) {
+        instance()->mSharedEngine = new MpEngine();
+    }
+    return instance()->mSharedEngine;
+}
+
+/*!
+ Returns an instance to an isolated engine with \a mode.
+ */
+MpEngine *MpEngineFactory::createIsolatedEngine( MpEngine::EngineMode mode )
+{
+    instance()->mEngines.append( new MpEngine() );
+    instance()->mEngines.last()->initialize( TUid::Uid( MpCommon::KMusicPlayerUid + instance()->mEngines.count() ), mode );
+    return instance()->mEngines.last();
+}
+
+/*!
+ Closes all engines created on this process.
+ */
+void MpEngineFactory::close()
+{
+    if ( instance()->mSharedEngine ) {
+        delete instance()->mSharedEngine;
+        instance()->mSharedEngine = 0;
+        
+    }
+    MpEngine *ptr;
+    foreach ( ptr, instance()->mEngines ) {
+        delete ptr;
+        ptr = 0;
+    }
+}
+
+/*!
+ Returns an instance to an engine with \a hostUid, and \a mode, if the shared engine is 
+ already created parameters are ignored.
+ */
+MpEngine *MpEngineFactory::createSharedEngine( TUid hostUid , MpEngine::EngineMode mode )
+{
+    if ( !instance()->mSharedEngine ) {
+        instance()->mSharedEngine = new MpEngine();
+        instance()->mSharedEngine->initialize( hostUid, mode );
+    }
+    return instance()->mSharedEngine;
+}
+