summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/test
diff options
context:
space:
mode:
authorChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
committerChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
commit205595e3d3e6a1d55be3c462ef02c9f828a77feb (patch)
tree9c1202619c7b9a66ed874ca1a0c81530ae06e426 /AudioManagerDaemon/test
parentd85e69bbf6d8ec6e087c7af579686923c76079cd (diff)
downloadaudiomanager-205595e3d3e6a1d55be3c462ef02c9f828a77feb.tar.gz
some updates, new tests
Diffstat (limited to 'AudioManagerDaemon/test')
-rw-r--r--AudioManagerDaemon/test/CMakeLists.txt50
-rw-r--r--AudioManagerDaemon/test/CommandInterfaceBackdoor.h27
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.cpp368
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.h74
-rw-r--r--AudioManagerDaemon/test/ControlInterfaceBackdoor.h25
-rw-r--r--AudioManagerDaemon/test/RoutingInterfaceBackdoor.h27
-rw-r--r--AudioManagerDaemon/test/controlInterface/CMakeLists.txt79
-rw-r--r--AudioManagerDaemon/test/controlInterface/MockControlInterface.h103
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp82
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h53
-rw-r--r--AudioManagerDaemon/test/database/CMakeLists.txt73
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.cpp (renamed from AudioManagerDaemon/test/databasetest.cpp)727
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.h37
-rw-r--r--AudioManagerDaemon/test/databasetest.h109
-rw-r--r--AudioManagerDaemon/test/routingInterface/CMakeLists.txt77
-rw-r--r--AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h52
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp415
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h49
18 files changed, 1853 insertions, 574 deletions
diff --git a/AudioManagerDaemon/test/CMakeLists.txt b/AudioManagerDaemon/test/CMakeLists.txt
index 1431ee5..3bcc777 100644
--- a/AudioManagerDaemon/test/CMakeLists.txt
+++ b/AudioManagerDaemon/test/CMakeLists.txt
@@ -11,51 +11,7 @@
cmake_minimum_required(VERSION 2.6)
-PROJECT(AudioManagerDeamon)
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xlinker -export-dynamic")
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
-set(CMAKE_CXX_FLAGS "-g -pipe -g -Wall -W -D_REENTRANT")
-
-##todo only when dbus needed!
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
-
-set(STD_INCLUDE_DIRS "/usr/include")
-set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../dbusInterfaces)
-set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../includes)
-set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../dbusIncludes)
-set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../include)
-set(EXECUTABLE_OUTPUT_PATH ../../../test/)
-
-file(MAKE_DIRECTORY ${DOC_OUTPUT_PATH})
-
-FIND_PACKAGE(PkgConfig)
-pkg_check_modules(SQLITE REQUIRED sqlite3)
-pkg_check_modules(DLT REQUIRED automotive-dlt)
-
-file(GLOB DATABASE_SRCS_CXX "../src/DatabaseHandler.cpp")
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}
- ${STD_INCLUDE_DIRS}
- ${CMAKE_CURRENT_BINARY_DIR}
- ${DLT_INCLUDE_DIRS}
- ${DBUS_INCLUDE_DIR}
- ${AUDIO_INCLUDES_FOLDER}
- ${INCLUDES_FOLDER}
- ${DBUS_ARCH_INCLUDE_DIR}
- ${DBUS_INCLUDES_FOLDER}
-)
-
-ADD_EXECUTABLE(databasetest databasetest.cpp ${DATABASE_SRCS_CXX})
-
-TARGET_LINK_LIBRARIES(databasetest
- ${SQLITE_LIBRARIES}
- ${DLT_LIBRARIES}
- ${DBUS_LIBRARY}
- ${CMAKE_THREAD_LIBS_INIT}
- gtest
-)
-
-
+add_subdirectory (database)
+add_subdirectory (routingInterface)
+add_subdirectory (controlInterface)
diff --git a/AudioManagerDaemon/test/CommandInterfaceBackdoor.h b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
new file mode 100644
index 0000000..10bb135
--- /dev/null
+++ b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
@@ -0,0 +1,27 @@
+/*
+ * CommandInterfaceBackdoor.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef COMMANDINTERFACEBACKDOOR_H_
+#define COMMANDINTERFACEBACKDOOR_H_
+
+#include "CommandSender.h"
+
+using namespace am;
+
+class CommandSender;
+
+class CommandInterfaceBackdoor {
+public:
+ CommandInterfaceBackdoor();
+ virtual ~CommandInterfaceBackdoor();
+ bool unloadPlugins(CommandSender *CommandSender);
+ bool injectInterface(CommandSender* CommandSender, CommandSendInterface* CommandSendInterface);
+};
+
+//definitions are in CommonFunctions.cpp!
+
+#endif /* COMMANDINTERFACEBACKDOOR_H_ */
diff --git a/AudioManagerDaemon/test/CommonFunctions.cpp b/AudioManagerDaemon/test/CommonFunctions.cpp
new file mode 100644
index 0000000..734bbbc
--- /dev/null
+++ b/AudioManagerDaemon/test/CommonFunctions.cpp
@@ -0,0 +1,368 @@
+/*
+ * CommonFunctions.cpp
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#include "CommonFunctions.h"
+#include "CommandInterfaceBackdoor.h"
+#include "RoutingInterfaceBackdoor.h"
+#include "ControlInterfaceBackdoor.h"
+
+CommandInterfaceBackdoor::CommandInterfaceBackdoor() {
+}
+CommandInterfaceBackdoor::~CommandInterfaceBackdoor() {
+}
+
+bool CommandInterfaceBackdoor::unloadPlugins(CommandSender *CommandSender) {
+ assert(CommandSender != NULL);
+ CommandSender->unloadLibraries();
+ CommandSender->mListInterfaces.clear();
+ if (CommandSender->mListInterfaces.empty())
+ return true;
+ return false;
+}
+
+bool CommandInterfaceBackdoor::injectInterface(CommandSender *CommandSender,
+ CommandSendInterface *CommandSendInterface) {
+ assert(CommandSender != NULL);
+ assert(CommandSendInterface != NULL);
+ CommandSender->mListInterfaces.push_back(CommandSendInterface);
+ return true; //todo: check if it worked
+}
+
+RoutingInterfaceBackdoor::RoutingInterfaceBackdoor() {
+}
+RoutingInterfaceBackdoor::~RoutingInterfaceBackdoor() {
+}
+
+bool RoutingInterfaceBackdoor::unloadPlugins(RoutingSender *RoutingSender) {
+ assert(RoutingSender != NULL);
+ RoutingSender->unloadLibraries();
+ RoutingSender->mListInterfaces.clear();
+ if (RoutingSender->mListInterfaces.empty())
+ return true;
+ return false;
+}
+
+bool RoutingInterfaceBackdoor::injectInterface(RoutingSender *RoutingSender,
+ RoutingSendInterface *newInterface, const std::string& busname) {
+ assert(RoutingSender != NULL);
+ assert(newInterface != NULL);
+
+ RoutingSender::InterfaceNamePairs newInterfacePair;
+ newInterfacePair.routingInterface = newInterface;
+ newInterfacePair.busName = busname;
+ RoutingSender->mListInterfaces.push_back(newInterfacePair);
+ return true; //todo: check if it worked
+}
+
+ControlInterfaceBackdoor::ControlInterfaceBackdoor() {}
+
+ControlInterfaceBackdoor::~ControlInterfaceBackdoor() {}
+
+bool ControlInterfaceBackdoor::replaceController(ControlSender *controlSender, ControlSendInterface *newController)
+{
+ controlSender->mController=newController;
+ return true;
+}
+
+
+int GetRandomNumber(int nLow, int nHigh) {
+ return (rand() % (nHigh - nLow + 1)) + nLow;
+}
+
+bool equalSoundProperty(const am_SoundProperty_s a,
+ const am_SoundProperty_s b) {
+ return (a.type == b.type && a.value == b.value);
+}
+
+bool equalMainSoundProperty(const am_MainSoundProperty_s a,
+ const am_MainSoundProperty_s b) {
+ return (a.type == b.type && a.value == b.value);
+}
+
+bool equalRoutingElement(const am_RoutingElement_s a,
+ const am_RoutingElement_s b) {
+ return (a.connectionFormat == b.connectionFormat && a.domainID == b.domainID
+ && a.sinkID == b.sinkID && a.sourceID == b.sourceID);
+}
+
+bool equalClassProperties(const am_ClassProperty_s a,
+ const am_ClassProperty_s b) {
+ return (a.classProperty == b.classProperty && a.value == b.value);
+}
+
+std::string int2string(int i) {
+ std::stringstream out;
+ out << i;
+ return out.str();
+}
+
+bool CommonFunctions::compareSource(
+ std::vector<am_Source_s>::iterator listIterator,
+ const am_Source_s& sourceData) {
+ return (listIterator->available.availability
+ == sourceData.available.availability)
+ && (listIterator->available.availabilityReason
+ == sourceData.available.availabilityReason)
+ && (listIterator->sourceClassID == sourceData.sourceClassID)
+ && (listIterator->domainID == sourceData.domainID)
+ && (listIterator->interruptState == sourceData.interruptState)
+ && (listIterator->visible == sourceData.visible)
+ && (listIterator->name.compare(sourceData.name) == 0)
+ && (listIterator->volume == sourceData.volume)
+ && std::equal(listIterator->listConnectionFormats.begin(),
+ listIterator->listConnectionFormats.end(),
+ sourceData.listConnectionFormats.begin())
+ && std::equal(listIterator->listMainSoundProperties.begin(),
+ listIterator->listMainSoundProperties.end(),
+ sourceData.listMainSoundProperties.begin(),
+ equalMainSoundProperty)
+ && std::equal(listIterator->listSoundProperties.begin(),
+ listIterator->listSoundProperties.end(),
+ sourceData.listSoundProperties.begin(), equalSoundProperty);
+}
+
+bool CommonFunctions::compareSink(std::vector<am_Sink_s>::iterator listIterator,
+ const am_Sink_s& sinkData) {
+ return (listIterator->available.availability
+ == sinkData.available.availability)
+ && (listIterator->available.availabilityReason
+ == sinkData.available.availabilityReason)
+ && (listIterator->sinkClassID == sinkData.sinkClassID)
+ && (listIterator->domainID == sinkData.domainID)
+ && (listIterator->mainVolume == sinkData.mainVolume)
+ && (listIterator->muteState == sinkData.muteState)
+ && (listIterator->visible == sinkData.visible)
+ && (listIterator->name.compare(sinkData.name) == 0)
+ && (listIterator->volume == sinkData.volume)
+ && std::equal(listIterator->listConnectionFormats.begin(),
+ listIterator->listConnectionFormats.end(),
+ sinkData.listConnectionFormats.begin())
+ && std::equal(listIterator->listMainSoundProperties.begin(),
+ listIterator->listMainSoundProperties.end(),
+ sinkData.listMainSoundProperties.begin(),
+ equalMainSoundProperty)
+ && std::equal(listIterator->listSoundProperties.begin(),
+ listIterator->listSoundProperties.end(),
+ sinkData.listSoundProperties.begin(), equalSoundProperty);
+}
+
+bool CommonFunctions::compareGateway(
+ std::vector<am_Gateway_s>::iterator listIterator,
+ const am_Gateway_s& gatewayData) {
+ return (listIterator->name.compare(gatewayData.name) == 0)
+ && (listIterator->sinkID == gatewayData.sinkID)
+ && (listIterator->sourceID == gatewayData.sourceID)
+ && (listIterator->controlDomainID == gatewayData.controlDomainID)
+ && (listIterator->domainSinkID == gatewayData.domainSinkID)
+ && (listIterator->domainSourceID == gatewayData.domainSourceID)
+ && std::equal(listIterator->convertionMatrix.begin(),
+ listIterator->convertionMatrix.end(),
+ gatewayData.convertionMatrix.begin())
+ && std::equal(listIterator->listSourceFormats.begin(),
+ listIterator->listSourceFormats.end(),
+ gatewayData.listSourceFormats.begin())
+ && std::equal(listIterator->listSinkFormats.begin(),
+ listIterator->listSinkFormats.end(),
+ gatewayData.listSinkFormats.begin());
+}
+
+bool CommonFunctions::compareGateway1(const am_Gateway_s gateway1,
+ const am_Gateway_s gatewayData) {
+ return (gateway1.name.compare(gatewayData.name) == 0)
+ && (gateway1.sinkID == gatewayData.sinkID)
+ && (gateway1.sourceID == gatewayData.sourceID)
+ && (gateway1.controlDomainID == gatewayData.controlDomainID)
+ && (gateway1.domainSinkID == gatewayData.domainSinkID)
+ && (gateway1.domainSourceID == gatewayData.domainSourceID)
+ && std::equal(gateway1.convertionMatrix.begin(),
+ gateway1.convertionMatrix.end(),
+ gatewayData.convertionMatrix.begin())
+ && std::equal(gateway1.listSourceFormats.begin(),
+ gateway1.listSourceFormats.end(),
+ gatewayData.listSourceFormats.begin())
+ && std::equal(gateway1.listSinkFormats.begin(),
+ gateway1.listSinkFormats.end(),
+ gatewayData.listSinkFormats.begin());
+}
+
+bool CommonFunctions::compareSinkMainSink(
+ std::vector<am_SinkType_s>::iterator listIterator,
+ const std::vector<am_Sink_s>& sinkList) {
+ std::vector<am_Sink_s>::const_iterator sinkListIterator = sinkList.begin();
+ for (; sinkListIterator < sinkList.end(); ++sinkListIterator) {
+ if (listIterator->sinkID == sinkListIterator->sinkID) {
+ return (listIterator->name.compare(sinkListIterator->name) == 0)
+ && (listIterator->availability.availability
+ == sinkListIterator->available.availability)
+ && (listIterator->availability.availabilityReason
+ == sinkListIterator->available.availabilityReason)
+ && (listIterator->muteState == sinkListIterator->muteState)
+ && (listIterator->volume == sinkListIterator->mainVolume)
+ && (listIterator->sinkClassID
+ == sinkListIterator->sinkClassID);
+ }
+ }
+ return false;
+}
+
+bool CommonFunctions::compareSinkMainSource(
+ std::vector<am_SourceType_s>::iterator listIterator,
+ const std::vector<am_Source_s>& sourceList) {
+ std::vector<am_Source_s>::const_iterator sinkListIterator =
+ sourceList.begin();
+ for (; sinkListIterator < sourceList.end(); ++sinkListIterator) {
+ if (listIterator->sourceID == sinkListIterator->sourceID) {
+ return (listIterator->name.compare(sinkListIterator->name) == 0)
+ && (listIterator->availability.availability
+ == sinkListIterator->available.availability)
+ && (listIterator->availability.availabilityReason
+ == sinkListIterator->available.availabilityReason)
+ && (listIterator->sourceClassID
+ == sinkListIterator->sourceClassID);
+ }
+ }
+ return false;
+}
+
+std::vector<am_ConnectionFormat_e> CommonFunctions::getStandardConnectionFormatList() {
+ std::vector < am_ConnectionFormat_e > list;
+ list.push_back(CF_ANALOG);
+ list.push_back(CF_STEREO);
+ return list;
+}
+
+std::vector<am_SoundProperty_s> CommonFunctions::getStandardSoundPropertyList() {
+ std::vector < am_SoundProperty_s > soundPropertyList;
+ am_SoundProperty_s soundProperty;
+ soundProperty.type = SP_BASS;
+ soundProperty.value = 23;
+ soundPropertyList.push_back(soundProperty);
+ soundProperty.type = SP_MID;
+ soundProperty.value = 2;
+ soundPropertyList.push_back(soundProperty);
+ return soundPropertyList;
+}
+
+std::vector<am_MainSoundProperty_s> CommonFunctions::getStandardMainSoundPropertyList() {
+ std::vector < am_MainSoundProperty_s > mainSoundPropertyList;
+ am_MainSoundProperty_s mainSoundProperty;
+ mainSoundProperty.type = MSP_NAVIGATION_OFFSET;
+ mainSoundProperty.value = 23;
+ mainSoundPropertyList.push_back(mainSoundProperty);
+ mainSoundProperty.type = MSP_TEST;
+ mainSoundProperty.value = 3;
+ mainSoundPropertyList.push_back(mainSoundProperty);
+ return mainSoundPropertyList;
+}
+
+void CommonFunctions::createSink(am_Sink_s& sink) const {
+ sink.name = "AnySink";
+ sink.domainID = 4;
+ sink.available.availability = A_AVAILABLE;
+ sink.available.availabilityReason = AR_NEWMEDIA;
+ sink.sinkClassID = 1;
+ sink.listConnectionFormats = getStandardConnectionFormatList();
+ sink.listSoundProperties = getStandardSoundPropertyList();
+ sink.listMainSoundProperties = getStandardMainSoundPropertyList();
+ sink.mainVolume = 12;
+ sink.muteState = MS_UNMUTED;
+ sink.visible = true;
+ sink.volume = 23;
+ sink.sinkID = 0;
+}
+
+void CommonFunctions::createSource(am_Source_s& source) const {
+ source.name = "AnySource";
+ source.domainID = 4;
+ source.available.availability = A_AVAILABLE;
+ source.available.availabilityReason = AR_NEWMEDIA;
+ source.sourceClassID = 1;
+ source.listConnectionFormats = getStandardConnectionFormatList();
+ source.listSoundProperties = getStandardSoundPropertyList();
+ source.listMainSoundProperties = getStandardMainSoundPropertyList();
+ source.interruptState = IS_OFF;
+ source.visible = true;
+ source.volume = 23;
+ source.sourceID = 0;
+ source.sourceState = SS_ON;
+}
+
+void CommonFunctions::createDomain(am_Domain_s & domain) const {
+
+ domain.domainID = 0;
+ domain.name = "AnyDomain";
+ domain.nodename = "AnyNode";
+ domain.busname = "AnyBusname";
+ domain.complete = true;
+ domain.early = true;
+ domain.state = DS_CONTROLLED;
+}
+
+void CommonFunctions::createGateway(am_Gateway_s & gateway) {
+ gateway.name = "AnyGateway";
+ gateway.sinkID = 1;
+ gateway.sourceID = 2;
+ gateway.controlDomainID = 1;
+ gateway.domainSinkID = 3;
+ gateway.domainSourceID = 4;
+ gateway.convertionMatrix = getStandardConvertionMatrix();
+ gateway.listSourceFormats = getStandardConnectionFormatList();
+ gateway.listSinkFormats = getStandardConnectionFormatList();
+ gateway.gatewayID = 0;
+
+}
+
+void CommonFunctions::createConnection(am_Connection_s & connection) const {
+ connection.connectionID = 0;
+ connection.sinkID = 1;
+ connection.sourceID = 2;
+ connection.delay = -1;
+ connection.connectionFormat = CF_ANALOG;
+}
+
+void CommonFunctions::createMainConnection(am_MainConnection_s & mainConnection,
+ am_Route_s route) const {
+ mainConnection.connectionID = 0;
+ mainConnection.connectionState = CS_CONNECTED;
+ mainConnection.route = route;
+ mainConnection.delay = -1;
+}
+
+std::vector<bool> CommonFunctions::getStandardConvertionMatrix() {
+ std::vector<bool> convMatrix;
+ convMatrix.push_back(true);
+ convMatrix.push_back(false);
+ convMatrix.push_back(true);
+ convMatrix.push_back(false);
+ convMatrix.push_back(true);
+ convMatrix.push_back(true);
+ return convMatrix;
+}
+
+void CommonFunctions::connectionList2RoutingList(
+ std::vector<am_RoutingElement_s> & routingList,
+ const std::vector<am_Connection_s>& connectionList) {
+ am_RoutingElement_s routingElement;
+ std::vector<am_Connection_s>::const_iterator cIterator =
+ connectionList.begin();
+ for (; cIterator < connectionList.end(); ++cIterator) {
+ routingElement.sinkID = cIterator->sinkID;
+ routingElement.sourceID = cIterator->sourceID;
+ routingElement.connectionFormat = cIterator->connectionFormat;
+ routingElement.domainID = 4; //todo: make this test read out the real value
+ routingList.push_back(routingElement);
+ }
+}
+
+
+
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/test/CommonFunctions.h b/AudioManagerDaemon/test/CommonFunctions.h
new file mode 100644
index 0000000..b7c3a40
--- /dev/null
+++ b/AudioManagerDaemon/test/CommonFunctions.h
@@ -0,0 +1,74 @@
+/*
+ * CommonHeaders.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef COMMONHEADERS_H_
+#define COMMONHEADERS_H_
+
+#include <gtest/gtest.h>
+#include "DatabaseHandler.h"
+
+using namespace am;
+
+class CommonFunctions
+{
+public:
+
+ static std::vector<am_ConnectionFormat_e> getStandardConnectionFormatList();
+ static std::vector<am_SoundProperty_s> getStandardSoundPropertyList();
+ static std::vector<am_MainSoundProperty_s> getStandardMainSoundPropertyList();
+ static std::vector<bool> getStandardConvertionMatrix();
+ bool compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData);
+ bool compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData);
+ bool compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData);
+ bool compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData);
+ bool compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList);
+ bool compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList);
+ void createSink(am_Sink_s& sink) const;
+ void createSource(am_Source_s& source) const ;
+ void createDomain(am_Domain_s& domain) const;
+ void createGateway(am_Gateway_s& gateway);
+ void createConnection(am_Connection_s& connection) const ;
+ void createMainConnection(am_MainConnection_s& mainConnection, am_Route_s route) const;
+ void connectionList2RoutingList(std::vector<am_RoutingElement_s>& routingList, const std::vector<am_Connection_s>& connectionList);
+
+ struct sortBySinkID
+ {
+ bool operator()(const am_RoutingElement_s & a, const am_RoutingElement_s & b) const
+ {
+ return (a.sinkID < b.sinkID);
+ }
+ };
+
+ struct sortByConnectionFormat
+ {
+ bool operator()(const am_ConnectionFormat_e & a, const am_ConnectionFormat_e & b) const
+ {
+ return (a < b);
+ }
+ };
+
+ struct sortByMainSoundProperty
+ {
+ bool operator()(const am_MainSoundProperty_s & a, const am_MainSoundProperty_s & b) const
+ {
+ return (a.type > b.type);
+ }
+ };
+
+ struct sortBySoundProperty
+ {
+ bool operator()(const am_SoundProperty_s & a, const am_SoundProperty_s & b) const
+ {
+ return (a.type < b.type);
+ }
+ };
+};
+
+
+
+
+#endif /* COMMONHEADERS_H_ */
diff --git a/AudioManagerDaemon/test/ControlInterfaceBackdoor.h b/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
new file mode 100644
index 0000000..b6a5337
--- /dev/null
+++ b/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
@@ -0,0 +1,25 @@
+/*
+ * ControlInterfaceBackdoor.h
+ *
+ * Created on: Dec 11, 2011
+ * Author: christian
+ */
+
+#ifndef CONTROLINTERFACEBACKDOOR_H_
+#define CONTROLINTERFACEBACKDOOR_H_
+
+#include "control/ControlSendInterface.h"
+#include "ControlSender.h"
+
+class ControlSender;
+
+using namespace am;
+
+class ControlInterfaceBackdoor {
+public:
+ ControlInterfaceBackdoor();
+ virtual ~ControlInterfaceBackdoor();
+ bool replaceController(ControlSender *controlSender, ControlSendInterface *newController);
+};
+
+#endif /* CONTROLINTERFACEBACKDOOR_H_ */
diff --git a/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
new file mode 100644
index 0000000..bd4a5ca
--- /dev/null
+++ b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
@@ -0,0 +1,27 @@
+/*
+ * RoutingInterfaceBackdoor.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef ROUTINGINTERFACEBACKDOOR_H_
+#define ROUTINGINTERFACEBACKDOOR_H_
+
+#include "RoutingSender.h"
+
+using namespace am;
+
+class RoutingSender;
+
+class RoutingInterfaceBackdoor {
+public:
+ RoutingInterfaceBackdoor();
+ virtual ~RoutingInterfaceBackdoor();
+ bool unloadPlugins(RoutingSender *RoutingSender);
+ bool injectInterface(RoutingSender *RoutingSender, RoutingSendInterface *newInterface, const std::string& busname);
+};
+
+//definitions are in CommonFunctions.cpp!
+
+#endif /* ROUTINGINTERFACEBACKDOOR_H_ */
diff --git a/AudioManagerDaemon/test/controlInterface/CMakeLists.txt b/AudioManagerDaemon/test/controlInterface/CMakeLists.txt
new file mode 100644
index 0000000..bd09acd
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/CMakeLists.txt
@@ -0,0 +1,79 @@
+#
+# Copyright (C) 2011, BMW AG
+#
+# GeniviAudioMananger ControlInterfaceTest
+#
+# \file CMakeLists.txt
+#
+# \date 20-Oct-2011 3:42:04 PM
+# \author Christian Mueller (christian.ei.mueller@bmw.de)
+#
+# \section License
+# GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+# Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+#
+# This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+# You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+# Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+# Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+# As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+# Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(controlInterfacetest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../../dbusInterfaces)
+set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../includes)
+set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../../dbusIncludes)
+set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../include)
+set(EXECUTABLE_OUTPUT_PATH ../../../../test/)
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+pkg_check_modules(DLT REQUIRED automotive-dlt)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDES_FOLDER}
+ ${DBUS_ARCH_INCLUDE_DIR}
+ ${DBUS_INCLUDES_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${STD_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIR}
+ ${INCLUDES_FOLDER}
+)
+
+file(GLOB CONTROL_INTERFACE_SRCS_CXX
+ "../../src/DatabaseHandler.cpp"
+ "../../src/Observer.cpp"
+ "../../src/RoutingSender.cpp"
+ "../../src/RoutingReceiver.cpp"
+ "../../src/CommandSender.cpp"
+ "../../src/ControlReceiver.cpp"
+ "../../src/ControlSender.cpp"
+ "../CommonFunctions.cpp"
+ "*.cpp"
+)
+
+ADD_EXECUTABLE(controlInterfaceTest ${CONTROL_INTERFACE_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES(controlInterfaceTest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ gtest
+ gmock
+)
+
+
+
diff --git a/AudioManagerDaemon/test/controlInterface/MockControlInterface.h b/AudioManagerDaemon/test/controlInterface/MockControlInterface.h
new file mode 100644
index 0000000..28d26af
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/MockControlInterface.h
@@ -0,0 +1,103 @@
+/*
+ * MockRoutingInterface.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef MOCKROUTINGINTERFACE_H_
+#define MOCKROUTINGINTERFACE_H_
+
+#include <control/ControlSendInterface.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+namespace am {
+
+class MockControlSendInterface : public ControlSendInterface {
+ public:
+ MOCK_METHOD1(startupController,
+ am_Error_e(ControlReceiveInterface* controlreceiveinterface));
+ MOCK_METHOD0(stopController,
+ am_Error_e());
+ MOCK_METHOD0(hookAllPluginsLoaded,
+ void());
+ MOCK_METHOD3(hookUserConnectionRequest,
+ am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID));
+ MOCK_METHOD1(hookUserDisconnectionRequest,
+ am_Error_e(const am_mainConnectionID_t connectionID));
+ MOCK_METHOD2(hookUserSetMainSinkSoundProperty,
+ am_Error_e(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty));
+ MOCK_METHOD2(hookUserSetMainSourceSoundProperty,
+ am_Error_e(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty));
+ MOCK_METHOD1(hookUserSetSystemProperty,
+ am_Error_e(const am_SystemProperty_s& property));
+ MOCK_METHOD2(hookUserVolumeChange,
+ am_Error_e(const am_sinkID_t SinkID, const am_mainVolume_t newVolume));
+ MOCK_METHOD2(hookUserVolumeStep,
+ am_Error_e(const am_sinkID_t SinkID, const int16_t increment));
+ MOCK_METHOD2(hookUserSetSinkMuteState,
+ am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState));
+ MOCK_METHOD2(hookSystemRegisterDomain,
+ am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID));
+ MOCK_METHOD1(hookSystemDeregisterDomain,
+ am_Error_e(const am_domainID_t domainID));
+ MOCK_METHOD1(hookSystemDomainRegistrationComplete,
+ void(const am_domainID_t domainID));
+ MOCK_METHOD2(hookSystemRegisterSink,
+ am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID));
+ MOCK_METHOD1(hookSystemDeregisterSink,
+ am_Error_e(const am_sinkID_t sinkID));
+ MOCK_METHOD2(hookSystemRegisterSource,
+ am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID));
+ MOCK_METHOD1(hookSystemDeregisterSource,
+ am_Error_e(const am_sourceID_t sourceID));
+ MOCK_METHOD2(hookSystemRegisterGateway,
+ am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID));
+ MOCK_METHOD1(hookSystemDeregisterGateway,
+ am_Error_e(const am_gatewayID_t gatewayID));
+ MOCK_METHOD2(hookSystemRegisterCrossfader,
+ am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID));
+ MOCK_METHOD1(hookSystemDeregisterCrossfader,
+ am_Error_e(const am_crossfaderID_t crossfaderID));
+ MOCK_METHOD3(hookSystemSinkVolumeTick,
+ void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume));
+ MOCK_METHOD3(hookSystemSourceVolumeTick,
+ void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume));
+ MOCK_METHOD2(hookSystemInterruptStateChange,
+ void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState));
+ MOCK_METHOD2(hookSystemSinkAvailablityStateChange,
+ void(const am_sinkID_t sinkID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookSystemSourceAvailablityStateChange,
+ void(const am_sourceID_t sourceID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookSystemDomainStateChange,
+ void(const am_domainID_t domainID, const am_DomainState_e state));
+ MOCK_METHOD1(hookSystemReceiveEarlyData,
+ void(const std::vector<am_EarlyData_s>& data));
+ MOCK_METHOD1(hookSystemSpeedChange,
+ void(const am_speed_t speed));
+ MOCK_METHOD2(hookSystemTimingInformationChanged,
+ void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time));
+ MOCK_METHOD2(cbAckConnect,
+ void(const am_Handle_s handle, const am_Error_e errorID));
+ MOCK_METHOD2(cbAckDisconnect,
+ void(const am_Handle_s handle, const am_Error_e errorID));
+ MOCK_METHOD3(cbAckCrossFade,
+ void(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error));
+ MOCK_METHOD3(cbAckSetSinkVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
+ MOCK_METHOD3(cbAckSetSourceVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error));
+ MOCK_METHOD2(cbAckSetSourceState,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(cbAckSetSourceSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(cbAckSetSinkSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+};
+
+} // namespace am
+
+
+
+#endif /* MOCKROUTINGINTERFACE_H_ */
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
new file mode 100644
index 0000000..1a8c48b
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
@@ -0,0 +1,82 @@
+/*
+ * routingInterfaceTest.cpp
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#include "controlInterfaceTest.h"
+
+using namespace am;
+
+using ::testing::Field;
+using ::testing::Property;
+using ::testing::Matcher;
+using ::testing::Pointee;
+using ::testing::AllOf;
+using ::testing::SafeMatcherCast;
+using ::testing::MatcherCast;
+using ::testing::DefaultValue;
+using ::testing::Eq;
+using ::testing::An;
+using ::testing::ElementsAreArray;
+using ::testing::ElementsAre;
+using ::testing::NotNull;
+using ::testing::Assign;
+using ::testing::SetArgReferee;
+using ::testing::DoAll;
+
+controlInterfaceTest::controlInterfaceTest()
+ :pDatabaseHandler(),
+ pRoutingSender(),
+ pCommandSender(),
+ pMockInterface(),
+ pControlSender(),
+ pRoutingInterfaceBackdoor(),
+ pCommandInterfaceBackdoor(),
+ pControlInterfaceBackdoor(),
+ pObserver(&pCommandSender,&pRoutingSender),
+ pControlReceiver(&pDatabaseHandler,&pRoutingSender),
+ pRoutingReceiver(&pDatabaseHandler,&pRoutingSender,&pControlSender)
+{
+ pDatabaseHandler.registerObserver(&pObserver);
+ pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
+ pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
+ pControlInterfaceBackdoor.replaceController(&pControlSender,&pMockInterface);
+
+}
+
+controlInterfaceTest::~controlInterfaceTest()
+{
+}
+
+void controlInterfaceTest::SetUp()
+{
+ DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+
+}
+
+void controlInterfaceTest::TearDown()
+{
+ DLT_UNREGISTER_CONTEXT(AudioManager);
+}
+
+TEST_F(controlInterfaceTest,registerDomain)
+{
+
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createDomain(domain);
+ EXPECT_CALL(pMockInterface,hookSystemRegisterDomain(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
+ ASSERT_EQ(E_OK,pRoutingReceiver.registerDomain(domain,domainID));
+}
+
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
new file mode 100644
index 0000000..2b73af6
--- /dev/null
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
@@ -0,0 +1,53 @@
+/*
+ * routingInterfaceTest.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef ROUTINGINTERFACETEST_H_
+#define ROUTINGINTERFACETEST_H_
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <dlt/dlt.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "MockControlInterface.h"
+#include "DatabaseHandler.h"
+#include "ControlReceiver.h"
+#include "ControlSender.h"
+#include "Observer.h"
+#include "RoutingReceiver.h"
+#include "../RoutingInterfaceBackdoor.h"
+#include "../CommandInterfaceBackdoor.h"
+#include "../CommonFunctions.h"
+
+DLT_DECLARE_CONTEXT(AudioManager)
+
+using namespace testing;
+using namespace am;
+
+class controlInterfaceTest : public Test{
+public:
+ controlInterfaceTest();
+ virtual ~controlInterfaceTest();
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockControlSendInterface pMockInterface;
+ ControlSender pControlSender;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlInterfaceBackdoor pControlInterfaceBackdoor;
+ Observer pObserver;
+ ControlReceiver pControlReceiver;
+ RoutingReceiver pRoutingReceiver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
+};
+
+#endif /* ROUTINGINTERFACETEST_H_ */
diff --git a/AudioManagerDaemon/test/database/CMakeLists.txt b/AudioManagerDaemon/test/database/CMakeLists.txt
new file mode 100644
index 0000000..33e6f87
--- /dev/null
+++ b/AudioManagerDaemon/test/database/CMakeLists.txt
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2011, BMW AG
+#
+# GeniviAudioMananger DatbaseTest
+#
+# \file CMakeLists.txt
+#
+# \date 20-Oct-2011 3:42:04 PM
+# \author Christian Mueller (christian.ei.mueller@bmw.de)
+#
+# \section License
+# GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+# Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+#
+# This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+# You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+# Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+# Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+# As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+# Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(datbaseTest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../../dbusInterfaces)
+set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../includes)
+set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../../dbusIncludes)
+set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../include)
+set(EXECUTABLE_OUTPUT_PATH ../../../../test/)
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+pkg_check_modules(DLT REQUIRED automotive-dlt)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDES_FOLDER}
+ ${DBUS_ARCH_INCLUDE_DIR}
+ ${DBUS_INCLUDES_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${STD_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIR}
+ ${INCLUDES_FOLDER}
+)
+
+file(GLOB DATABASE_SRCS_CXX
+ "../../src/DatabaseHandler.cpp"
+ "../../src/Observer.cpp"
+ "../../src/CommandSender.cpp"
+ "../../src/RoutingSender.cpp"
+ "../CommonFunctions.cpp"
+ "*.cpp"
+ )
+
+ADD_EXECUTABLE( databasetest ${DATABASE_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES( databasetest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ gtest
+ gmock
+) \ No newline at end of file
diff --git a/AudioManagerDaemon/test/databasetest.cpp b/AudioManagerDaemon/test/database/databaseTest.cpp
index 29f8e98..75fb389 100644
--- a/AudioManagerDaemon/test/databasetest.cpp
+++ b/AudioManagerDaemon/test/database/databaseTest.cpp
@@ -23,341 +23,17 @@
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
*/
-#include "databasetest.h"
+#include "databaseTest.h"
+#include "Observer.h"
-int GetRandomNumber(int nLow, int nHigh)
-{
- return (rand() % (nHigh - nLow + 1)) + nLow;
-}
-
-bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b)
-{
- return (a.type==b.type && a.value == b.value);
-}
-
-bool equalMainSoundProperty (const am_MainSoundProperty_s a, const am_MainSoundProperty_s b)
-{
- return (a.type==b.type && a.value == b.value);
-}
-
-bool equalRoutingElement (const am_RoutingElement_s a,const am_RoutingElement_s b)
-{
- return (a.connectionFormat==b.connectionFormat && a.domainID==b.domainID && a.sinkID==b.sinkID && a.sourceID==b.sourceID);
-}
-
-bool equalClassProperties (const am_ClassProperty_s a,const am_ClassProperty_s b)
-{
- return (a.classProperty==b.classProperty && a.value==b.value);
-}
+using namespace am;
-void databaseTest::SetUp()
-{
- DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
- DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
- DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Database Test started "));
-}
-
-void databaseTest::TearDown()
-{
- DLT_UNREGISTER_CONTEXT(AudioManager);
-}
-
-bool databaseTest::compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData)
-{
- return (listIterator->available.availability == sourceData.available.availability)
- && (listIterator->available.availabilityReason == sourceData.available.availabilityReason)
- && (listIterator->sourceClassID == sourceData.sourceClassID)
- && (listIterator->domainID == sourceData.domainID)
- && (listIterator->interruptState == sourceData.interruptState)
- && (listIterator->visible == sourceData.visible)
- && (listIterator->name.compare(sourceData.name)==0)
- && (listIterator->volume == sourceData.volume)
- && std::equal(listIterator->listConnectionFormats.begin(),listIterator->listConnectionFormats.end(),sourceData.listConnectionFormats.begin())
- && std::equal(listIterator->listMainSoundProperties.begin(),listIterator->listMainSoundProperties.end(),sourceData.listMainSoundProperties.begin(),equalMainSoundProperty)
- && std::equal(listIterator->listSoundProperties.begin(),listIterator->listSoundProperties.end(),sourceData.listSoundProperties.begin(),equalSoundProperty);
-}
-
-bool databaseTest::compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData)
-{
- return (listIterator->available.availability == sinkData.available.availability)
- && (listIterator->available.availabilityReason == sinkData.available.availabilityReason)
- && (listIterator->sinkClassID == sinkData.sinkClassID)
- && (listIterator->domainID == sinkData.domainID)
- && (listIterator->mainVolume == sinkData.mainVolume)
- && (listIterator->muteState == sinkData.muteState)
- && (listIterator->visible == sinkData.visible)
- && (listIterator->name.compare(sinkData.name)==0)
- && (listIterator->volume == sinkData.volume)
- && std::equal(listIterator->listConnectionFormats.begin(),listIterator->listConnectionFormats.end(),sinkData.listConnectionFormats.begin())
- && std::equal(listIterator->listMainSoundProperties.begin(),listIterator->listMainSoundProperties.end(),sinkData.listMainSoundProperties.begin(),equalMainSoundProperty)
- && std::equal(listIterator->listSoundProperties.begin(),listIterator->listSoundProperties.end(),sinkData.listSoundProperties.begin(),equalSoundProperty);
-}
-
-bool databaseTest::compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData)
-{
- return (listIterator->name.compare(gatewayData.name)==0)
- && (listIterator->sinkID == gatewayData.sinkID)
- && (listIterator->sourceID == gatewayData.sourceID)
- && (listIterator->controlDomainID == gatewayData.controlDomainID)
- && (listIterator->domainSinkID == gatewayData.domainSinkID)
- && (listIterator->domainSourceID == gatewayData.domainSourceID)
- && std::equal(listIterator->convertionMatrix.begin(),listIterator->convertionMatrix.end(),gatewayData.convertionMatrix.begin())
- && std::equal(listIterator->listSourceFormats.begin(),listIterator->listSourceFormats.end(),gatewayData.listSourceFormats.begin())
- && std::equal(listIterator->listSinkFormats.begin(),listIterator->listSinkFormats.end(),gatewayData.listSinkFormats.begin());
-}
-
-bool databaseTest::compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData)
-{
- return (gateway1.name.compare(gatewayData.name)==0)
- && (gateway1.sinkID == gatewayData.sinkID)
- && (gateway1.sourceID == gatewayData.sourceID)
- && (gateway1.controlDomainID == gatewayData.controlDomainID)
- && (gateway1.domainSinkID == gatewayData.domainSinkID)
- && (gateway1.domainSourceID == gatewayData.domainSourceID)
- && std::equal(gateway1.convertionMatrix.begin(),gateway1.convertionMatrix.end(),gatewayData.convertionMatrix.begin())
- && std::equal(gateway1.listSourceFormats.begin(),gateway1.listSourceFormats.end(),gatewayData.listSourceFormats.begin())
- && std::equal(gateway1.listSinkFormats.begin(),gateway1.listSinkFormats.end(),gatewayData.listSinkFormats.begin());
-}
-
-bool databaseTest::compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList)
-{
- std::vector<am_Sink_s>::const_iterator sinkListIterator=sinkList.begin();
- for(;sinkListIterator<sinkList.end();++sinkListIterator)
- {
- if (listIterator->sinkID==sinkListIterator->sinkID)
- {
- return (listIterator->name.compare(sinkListIterator->name)==0)
- && (listIterator->availability.availability==sinkListIterator->available.availability)
- && (listIterator->availability.availabilityReason==sinkListIterator->available.availabilityReason)
- && (listIterator->muteState==sinkListIterator->muteState)
- && (listIterator->volume==sinkListIterator->mainVolume)
- && (listIterator->sinkClassID==sinkListIterator->sinkClassID);
- }
- }
- return false;
-}
-
-bool databaseTest::compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList)
-{
- std::vector<am_Source_s>::const_iterator sinkListIterator=sourceList.begin();
- for(;sinkListIterator<sourceList.end();++sinkListIterator)
- {
- if (listIterator->sourceID==sinkListIterator->sourceID)
- {
- return (listIterator->name.compare(sinkListIterator->name)==0)
- && (listIterator->availability.availability==sinkListIterator->available.availability)
- && (listIterator->availability.availabilityReason==sinkListIterator->available.availabilityReason)
- && (listIterator->sourceClassID==sinkListIterator->sourceClassID);
- }
- }
- return false;
-}
-
-std::vector<am_ConnectionFormat_e> databaseTest::getStandardConnectionFormatList()
-{
- std::vector<am_ConnectionFormat_e> list;
- list.push_back(CF_ANALOG);
- list.push_back(CF_STEREO);
- return list;
-}
-
-std::string databaseTest::int2string(int i)
-{
- std::stringstream out;
- out << i;
- return out.str();
-}
-
-std::vector<am_SoundProperty_s> databaseTest::getStandardSoundPropertyList()
-{
- std::vector<am_SoundProperty_s> soundPropertyList;
- am_SoundProperty_s soundProperty;
- soundProperty.type=SP_BASS;
- soundProperty.value=23;
- soundPropertyList.push_back(soundProperty);
- soundProperty.type=SP_MID;
- soundProperty.value=2;
- soundPropertyList.push_back(soundProperty);
- return soundPropertyList;
-}
-
-std::vector<am_MainSoundProperty_s> databaseTest::getStandardMainSoundPropertyList()
-{
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList;
- am_MainSoundProperty_s mainSoundProperty;
- mainSoundProperty.type=MSP_NAVIGATION_OFFSET;
- mainSoundProperty.value=23;
- mainSoundPropertyList.push_back(mainSoundProperty);
- mainSoundProperty.type=MSP_TEST;
- mainSoundProperty.value=3;
- mainSoundPropertyList.push_back(mainSoundProperty);
- return mainSoundPropertyList;
-}
-
-void databaseTest::createSink(
- am_Sink_s& sink,
- am_sinkID_t sinkID=0,
- std::string name="AnySink",
- am_domainID_t domainID=4,
- am_Availablility_e availability=A_AVAILABLE,
- am_AvailabilityReason_e availabilityReason=AR_NEWMEDIA,
- am_sinkClass_t sinkClassID=1,
- std::vector<am_ConnectionFormat_e> connectionFormatList=getStandardConnectionFormatList(),
- std::vector<am_SoundProperty_s> soundPropertyList=getStandardSoundPropertyList(),
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList=getStandardMainSoundPropertyList(),
- am_mainVolume_t mainVolume=12,
- am_MuteState_e muteState=MS_UNMUTED,
- bool visible=true,
- am_volume_t volume=23)
-{
- sink.name=name;
- sink.domainID=domainID;
- sink.available.availability=availability;
- sink.available.availabilityReason=availabilityReason;
- sink.sinkClassID=sinkClassID;
- sink.listConnectionFormats=connectionFormatList;
- sink.listSoundProperties=soundPropertyList;
- sink.listMainSoundProperties=mainSoundPropertyList;
- sink.mainVolume=mainVolume;
- sink.muteState=muteState;
- sink.visible=visible;
- sink.volume=volume;
- sink.sinkID=sinkID;
-}
-
-void databaseTest::createSource(
- am_Source_s& source,
- am_sourceID_t sourceID=0,
- std::string name="AnySource",
- am_domainID_t domainID=4,
- am_Availablility_e availability=A_AVAILABLE,
- am_AvailabilityReason_e availabilityReason=AR_NEWMEDIA,
- am_sourceClass_t sourceClassID=1,
- std::vector<am_ConnectionFormat_e> connectionFormatList=getStandardConnectionFormatList(),
- std::vector<am_SoundProperty_s> soundPropertyList=getStandardSoundPropertyList(),
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList=getStandardMainSoundPropertyList(),
- am_InterruptState_e interruptState=IS_OFF,
- bool visible=true,
- am_volume_t volume=23,
- am_SourceState_e sourceState=SS_ON)
-{
- source.name=name;
- source.domainID=domainID;
- source.available.availability=availability;
- source.available.availabilityReason=availabilityReason;
- source.sourceClassID=sourceClassID;
- source.listConnectionFormats=connectionFormatList;
- source.listSoundProperties=soundPropertyList;
- source.listMainSoundProperties=mainSoundPropertyList;
- source.interruptState=interruptState;
- source.visible=visible;
- source.volume=volume;
- source.sourceID=sourceID;
- source.sourceState=sourceState;
-}
-
-void databaseTest::createDomain(
- am_Domain_s & domain,
- am_domainID_t domainID=0,
- std::string name = "AnyDomain",
- std::string nodename = "AnyNode",
- std::string busname = "AnyBusname",
- bool complete= true,
- bool early= true,
- am_DomainState_e state=DS_CONTROLLED)
-{
-
- domain.domainID=domainID;
- domain.name=name;
- domain.nodename=nodename;
- domain.busname=busname;
- domain.complete=complete;
- domain.early=early;
- domain.state=state;
-}
-
-
-void databaseTest::createGateway(
- am_Gateway_s & gateway,
- am_gatewayID_t gatewayID=0,
- std::string name="AnyGateway",
- am_sinkID_t sinkID=1,
- am_sourceID_t sourceID=2,
- am_domainID_t controlDomainID=1,
- am_domainID_t domainSinkID=3,
- am_domainID_t domainSourceID=4,
- std::vector<bool> convertionMatrix=getStandardConvertionMatrix(),
- std::vector<am_ConnectionFormat_e> listSourceFormats=getStandardConnectionFormatList(),
- std::vector<am_ConnectionFormat_e> listSinkFormats=getStandardConnectionFormatList())
-{
- gateway.name=name;
- gateway.sinkID= sinkID;
- gateway.sourceID= sourceID;
- gateway.controlDomainID= controlDomainID;
- gateway.domainSinkID= domainSinkID;
- gateway.domainSourceID= domainSourceID;
- gateway.convertionMatrix= convertionMatrix;
- gateway.listSourceFormats=listSourceFormats;
- gateway.listSinkFormats=listSinkFormats;
- gateway.gatewayID=gatewayID;
-
-}
-
-void databaseTest::createConnection(
- am_Connection_s & connection,
- am_connectionID_t connectionID=0,
- am_sinkID_t sinkID=1,
- am_sourceID_t sourceID=2,
- am_timeSync_t delay=-1,
- am_ConnectionFormat_e connectionFormat=CF_ANALOG)
-{
- connection.connectionID=connectionID;
- connection.sinkID=sinkID;
- connection.sourceID=sourceID;
- connection.delay=delay;
- connection.connectionFormat=connectionFormat;
-}
-
-void databaseTest::createMainConnection(
- am_MainConnection_s & mainConnection,
- am_Route_s route,
- am_timeSync_t delay=-1,
- am_mainConnectionID_t connectionID=0,
- am_ConnectionState_e state=CS_CONNECTED)
-{
- mainConnection.connectionID=connectionID;
- mainConnection.connectionState=state;
- mainConnection.route=route;
- mainConnection.delay=delay;
-}
-
-
-std::vector<bool> databaseTest::getStandardConvertionMatrix()
-{
- std::vector<bool> convMatrix;
- convMatrix.push_back(true);
- convMatrix.push_back(false);
- convMatrix.push_back(true);
- convMatrix.push_back(false);
- convMatrix.push_back(true);
- convMatrix.push_back(true);
- return convMatrix;
-}
-
-
-void databaseTest::connectionList2RoutingList(std::vector<am_RoutingElement_s> & routingList, const std::vector<am_Connection_s>& connectionList)
-{
- am_RoutingElement_s routingElement;
- std::vector<am_Connection_s>::const_iterator cIterator=connectionList.begin();
- for(;cIterator<connectionList.end();++cIterator)
- {
- routingElement.sinkID=cIterator->sinkID;
- routingElement.sourceID=cIterator->sourceID;
- routingElement.connectionFormat=cIterator->connectionFormat;
- routingElement.domainID=4; //todo: make this test read out the real value
- routingList.push_back(routingElement);
- }
-}
+//extern int GetRandomNumber(int nLow, int nHigh);
+//extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b);
+extern bool equalMainSoundProperty (const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
+extern bool equalRoutingElement (const am_RoutingElement_s a,const am_RoutingElement_s b);
+extern bool equalClassProperties (const am_ClassProperty_s a,const am_ClassProperty_s b);
+extern std::string int2string(int i);
void databaseTest::createMainConnectionSetup()
{
@@ -373,20 +49,29 @@ void databaseTest::createMainConnectionSetup()
am_sourceID_t forgetSource;
am_connectionID_t forgetConnection;
- createConnection(connection,0,i,i);
+ pCF.createConnection(connection);
+ connection.sinkID=i;
+ connection.sourceID=i;
connectionList.push_back(connection);
- createSink(sink,i,"sink" + int2string(i),4);
- createSource(source,i,"source" + int2string(i),4);
+ pCF.createSink(sink);
+ sink.sinkID=i;
+ sink.name="sink" + int2string(i);
+ sink.domainID=4;
+ pCF.createSource(source);
+ source.sourceID=i;
+ source.name="source" + int2string(i);
+ source.domainID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(forgetConnection));
}
//fill the route
std::vector<am_RoutingElement_s> routingList;
- connectionList2RoutingList(routingList,connectionList);
+ pCF.connectionList2RoutingList(routingList,connectionList);
//create the Route
am_Route_s route;
@@ -398,7 +83,7 @@ void databaseTest::createMainConnectionSetup()
am_MainConnection_s mainConnection;
am_mainConnectionID_t mainConnectionID;
std::vector<am_MainConnection_s> mainConnectionList;
- createMainConnection(mainConnection,route);
+ pCF.createMainConnection(mainConnection,route);
//enter mainconnection in database
ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))<< "ERROR: database error";
@@ -421,13 +106,131 @@ void databaseTest::createMainConnectionSetup()
ASSERT_EQ(true,equal);
}
+void databaseTest::SetUp()
+{
+ DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Database Test started "));
+ Observer *observer=NULL;
+ pDatabaseHandler.registerObserver(observer);
+}
+
+void databaseTest::TearDown()
+{
+ DLT_UNREGISTER_CONTEXT(AudioManager);
+}
+
+TEST_F(databaseTest, peekSource)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID,100);
+ source.name="newsource";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID,source2ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
+}
+
+TEST_F(databaseTest, peekSourceDouble)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_sourceID_t source3ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID,100);
+ source.name="newsource";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,source3ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(sourceID,source3ID);
+ ASSERT_TRUE(listSources[0].sourceID==sourceID);
+}
+
+TEST_F(databaseTest, peekSourceExists)
+{
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID;
+ am_sourceID_t source2ID;
+ am_Source_s source;
+ pCF.createSource(source);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(source.name,source2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.size()==1);
+ ASSERT_EQ(sourceID,source2ID);
+}
+
+TEST_F(databaseTest, peekSink)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID,100);
+ sink.name="newsink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID,sink2ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+}
+
+TEST_F(databaseTest, peekSinkDouble)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_sinkID_t sink3ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID,100);
+ sink.name="newsink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sink3ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(sinkID,sink3ID);
+ ASSERT_TRUE(listSinks[0].sinkID==sinkID);
+}
+
+TEST_F(databaseTest, peekSinkExists)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID;
+ am_sinkID_t sink2ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(sink.name,sink2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.size()==1);
+ ASSERT_EQ(sinkID,sink2ID);
+}
+
+
TEST_F(databaseTest,changeConnectionTimingInformationCheckMainConnection)
{
am_Connection_s connection;
- am_connectionID_t connectionID;
std::vector<am_Connection_s> connectionList;
std::vector<am_MainConnectionType_s> mainList;
- createConnection(connection);
+ pCF.createConnection(connection);
createMainConnectionSetup();
ASSERT_EQ(-E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
ASSERT_EQ(mainList[0].delay,-1);
@@ -446,10 +249,11 @@ TEST_F(databaseTest,changeConnectionTimingInformation)
am_Connection_s connection;
am_connectionID_t connectionID;
std::vector<am_Connection_s> connectionList;
- createConnection(connection);
+ pCF.createConnection(connection);
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID));
ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
ASSERT_TRUE(connectionList[0].delay==24);
}
@@ -472,7 +276,7 @@ TEST_F(databaseTest,getSinkClassOfSink)
sinkClass.name="test";
sinkClass.sinkClassID=4;
sinkClass.listClassProperties=classPropertyList;
- createSink(sink);
+ pCF.createSink(sink);
sink.sinkClassID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
@@ -506,7 +310,7 @@ TEST_F(databaseTest,getSourceClassOfSource)
sourceClass.name="test";
sourceClass.sourceClassID=1;
sourceClass.listClassProperties=classPropertyList;
- createSource(source);
+ pCF.createSource(source);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
@@ -776,17 +580,21 @@ TEST_F(databaseTest,enterSourcesCorrect)
am_sourceID_t staticSourceID,firstDynamicSourceID,secondDynamicSourceID;
std::vector<am_Source_s> sourceList;
- createSource(staticSource,4,"Static");
+ pCF.createSource(staticSource);
+ staticSource.sourceID=4;
+ staticSource.name="Static";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
- createSource(firstDynamicSource,0,"firstDynamicSource");
+ pCF.createSource(firstDynamicSource);
+ firstDynamicSource.name="firstDynamicSource";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(firstDynamicSource,firstDynamicSourceID))<< "ERROR: database error";
ASSERT_EQ(firstDynamicSourceID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
- createSource(secondDynamicSource,0,"secondDynamicSource");
+ pCF.createSource(secondDynamicSource);
+ secondDynamicSource.name="secondDynamicSource";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(secondDynamicSource,secondDynamicSourceID))<< "ERROR: database error";
ASSERT_NEAR(secondDynamicSourceID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
@@ -800,17 +608,17 @@ TEST_F(databaseTest,enterSourcesCorrect)
{
if(listIterator->sourceID==staticSourceID)
{
- equal = equal && compareSource(listIterator,staticSource);
+ equal = equal && pCF.compareSource(listIterator,staticSource);
}
if(listIterator->sourceID==firstDynamicSourceID)
{
- equal = equal && compareSource(listIterator,firstDynamicSource);
+ equal = equal && pCF.compareSource(listIterator,firstDynamicSource);
}
if(listIterator->sourceID==secondDynamicSourceID)
{
- equal = equal && compareSource(listIterator,secondDynamicSource);
+ equal = equal && pCF.compareSource(listIterator,secondDynamicSource);
}
}
@@ -823,7 +631,7 @@ TEST_F(databaseTest, changeSourceMainSoundProperty)
std::vector<am_Source_s> listSources;
am_Source_s source;
am_sourceID_t sourceID;
- createSource(source);
+ pCF.createSource(source);
am_MainSoundProperty_s property;
property.type=MSP_NAVIGATION_OFFSET;
property.value=33;
@@ -845,7 +653,7 @@ TEST_F(databaseTest, changeSinkMuteState)
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
am_MuteState_e muteState=MS_MUTED;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
@@ -858,7 +666,7 @@ TEST_F(databaseTest, changeSinkMainSoundProperty)
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
am_MainSoundProperty_s property;
property.type=MSP_NAVIGATION_OFFSET;
property.value=33;
@@ -875,12 +683,45 @@ TEST_F(databaseTest, changeSinkMainSoundProperty)
}
}
+TEST_F(databaseTest, peekDomain)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.empty());
+ ASSERT_EQ(domainID,1);
+ domain.name="newdomain";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domain2ID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_EQ(domainID,domain2ID);
+ ASSERT_TRUE(listDomains[0].domainID==domainID);
+}
+
+TEST_F(databaseTest, peekDomainFirstEntered)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_domainID_t domain2ID;
+ pCF.createDomain(domain);
+ domain.name="newdomain";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
+ ASSERT_EQ(domainID,domain2ID);
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_TRUE(listDomains.size()==1);
+}
+
TEST_F(databaseTest, changeDomainState)
{
std::vector<am_Domain_s> listDomains;
am_Domain_s domain;
am_domainID_t domainID;
- createDomain(domain);
+ pCF.createDomain(domain);
am_DomainState_e newState=DS_INDEPENDENT_STARTUP;
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.changDomainStateDB(newState,domainID));
@@ -903,7 +744,7 @@ TEST_F(databaseTest, changeSinkAvailability)
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
am_Availability_s availability;
availability.availability=A_UNKNOWN;
availability.availabilityReason=AR_TEMPERATURE;
@@ -919,7 +760,7 @@ TEST_F(databaseTest, changeSourceAvailability)
std::vector<am_Source_s> listSources;
am_Source_s source;
am_sourceID_t sourceID;
- createSource(source);
+ pCF.createSource(source);
am_Availability_s availability;
availability.availability=A_UNKNOWN;
availability.availabilityReason=AR_TEMPERATURE;
@@ -948,11 +789,20 @@ TEST_F(databaseTest,changeMainConnectionRoute)
am_sourceID_t forgetSource;
am_connectionID_t forgetConnection;
- createConnection(connection,0,i+20,i+20,-1,CF_ANALOG);
+ pCF.createConnection(connection);
+ connection.sinkID=i+20;
+ connection.sourceID=i+20;
+ connection.delay=-1;
connectionList.push_back(connection);
- createSink(sink,i+20,"sink" + int2string(i+20),4);
- createSource(source,i+20,"source" + int2string(i+30),4);
+ pCF.createSink(sink);
+ sink.sinkID=i+20;
+ sink.name="sink" + int2string(i+20);
+ sink.domainID=4;
+ pCF.createSource(source);
+ source.sourceID=i+20;
+ source.name="source" + int2string(i+30);
+ source.domainID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,forgetSink))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,forgetSource))<< "ERROR: database error";
@@ -963,7 +813,7 @@ TEST_F(databaseTest,changeMainConnectionRoute)
//fill the route
std::vector<am_RoutingElement_s> routingList;
- connectionList2RoutingList(routingList,connectionList);
+ pCF.connectionList2RoutingList(routingList,connectionList);
//create the Route
am_Route_s route;
@@ -983,7 +833,7 @@ TEST_F(databaseTest,changeMainSinkVolume)
am_sinkID_t sinkID;
am_mainVolume_t newVol=20;
std::vector<am_Sink_s> listSinks;
- createSink(sink);
+ pCF.createSink(sink);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
@@ -994,7 +844,7 @@ TEST_F(databaseTest,getMainSourceSoundProperties)
{
am_Source_s source;
am_sourceID_t sourceID;
- createSource(source);
+ pCF.createSource(source);
std::vector<am_MainSoundProperty_s> mainSoundProperties=source.listMainSoundProperties;
std::vector<am_MainSoundProperty_s> listMainSoundProperties;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
@@ -1006,7 +856,7 @@ TEST_F(databaseTest,getMainSinkSoundProperties)
{
am_Sink_s sink;
am_sinkID_t sinkID;
- createSink(sink);
+ pCF.createSink(sink);
std::vector<am_MainSoundProperty_s> mainSoundProperties=sink.listMainSoundProperties;
std::vector<am_MainSoundProperty_s> listMainSoundProperties;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
@@ -1018,9 +868,11 @@ TEST_F(databaseTest,getMainSources)
{
am_Source_s source, source1,source2;
am_sourceID_t sourceID;
- createSource(source);
- createSource(source1);
- createSource(source2);
+ pCF.createSource(source);
+ pCF.createSource(source1);
+ pCF.createSource(source2);
+ source1.name="source1";
+ source2.name="source2";
bool equal=true;
source1.visible=false;
std::vector<am_SourceType_s> listMainSources;
@@ -1036,7 +888,7 @@ TEST_F(databaseTest,getMainSources)
std::vector<am_SourceType_s>::iterator listIterator=listMainSources.begin();
for(;listIterator<listMainSources.end();++listIterator)
{
- equal = equal && compareSinkMainSource(listIterator,listSources);
+ equal = equal && pCF.compareSinkMainSource(listIterator,listSources);
}
ASSERT_TRUE(equal);
}
@@ -1045,9 +897,11 @@ TEST_F(databaseTest,getMainSinks)
{
am_Sink_s sink, sink1,sink2;
am_sinkID_t sinkID;
- createSink(sink);
- createSink(sink1);
- createSink(sink2);
+ pCF.createSink(sink);
+ pCF.createSink(sink1);
+ pCF.createSink(sink2);
+ sink1.name="sink1";
+ sink2.name="sink2";
bool equal=true;
sink1.visible=false;
std::vector<am_SinkType_s> listMainSinks;
@@ -1063,7 +917,7 @@ TEST_F(databaseTest,getMainSinks)
std::vector<am_SinkType_s>::iterator listIterator=listMainSinks.begin();
for(;listIterator<listMainSinks.end();++listIterator)
{
- equal = equal && compareSinkMainSink(listIterator,listSinks);
+ equal = equal && pCF.compareSinkMainSink(listIterator,listSinks);
}
ASSERT_TRUE(equal);
}
@@ -1073,7 +927,7 @@ TEST_F(databaseTest,getVisibleMainConnections)
createMainConnectionSetup();
am_MainConnection_s mainConnection;
am_Route_s route;
- createMainConnection(mainConnection,route);
+ pCF.createMainConnection(mainConnection,route);
std::vector<am_MainConnectionType_s> visibleMainConnection;
ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
@@ -1090,9 +944,15 @@ TEST_F(databaseTest,getListSourcesOfDomain)
am_domainID_t domainID;
am_sourceID_t sourceID;
std::vector<am_sourceID_t> sourceList,sourceCheckList;
- createSource(source,1,"testSink",1);
- createSource(source2,0,"testSink",5);
- createDomain(domain);
+ pCF.createSource(source);
+ source.sourceID=1;
+ source.name="testSource";
+ source.domainID=1;
+ pCF.createSource(source2);
+ source2.sourceID=0;
+ source2.name="testSource2";
+ source2.domainID=5;
+ pCF.createDomain(domain);
sourceCheckList.push_back(1);//sink.sinkID);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
@@ -1110,9 +970,13 @@ TEST_F(databaseTest,getListSinksOfDomain)
am_domainID_t domainID;
am_sinkID_t sinkID;
std::vector<am_sinkID_t> sinkList,sinkCheckList;
- createSink(sink,1,"testSink",1);
- createSink(sink2,0,"testSink",5);
- createDomain(domain);
+ pCF.createSink(sink);
+ sink.sinkID=1;
+ sink.domainID=1;
+ pCF.createSink(sink2);
+ sink2.domainID=5;
+ sink2.name="sink2";
+ pCF.createDomain(domain);
sinkCheckList.push_back(1);//sink.sinkID);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
@@ -1130,9 +994,23 @@ TEST_F(databaseTest,getListGatewaysOfDomain)
am_domainID_t domainID;
am_Domain_s domain;
std::vector<am_gatewayID_t> gatewayList,gatewayCheckList;
- createGateway(gateway,1,"testGateway",1,1,1);
- createGateway(gateway2,0,"testGateway2",1,1,4);
- createDomain(domain);
+ pCF.createGateway(gateway);
+ gateway.gatewayID=1;
+ gateway.name="testGateway";
+ gateway.controlDomainID=1;
+ gateway.sourceID=1;
+ gateway.sinkID=1;
+ gateway.domainSinkID=1;
+ gateway.domainSourceID=1;
+ pCF.createGateway(gateway2);
+ gateway2.gatewayID=2;
+ gateway2.name="testGateway2";
+ gateway2.controlDomainID=4;
+ gateway2.sourceID=1;
+ gateway2.sinkID=1;
+ gateway2.domainSinkID=1;
+ gateway2.domainSourceID=1;
+ pCF.createDomain(domain);
gatewayCheckList.push_back(gateway.gatewayID);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
@@ -1148,7 +1026,7 @@ TEST_F(databaseTest,removeDomain)
am_Domain_s domain;
am_domainID_t domainID;
std::vector<am_Domain_s> listDomains;
- createDomain(domain);
+ pCF.createDomain(domain);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains))<< "ERROR: database error";
@@ -1160,7 +1038,7 @@ TEST_F(databaseTest,removeGateway)
am_Gateway_s gateway;
am_gatewayID_t gatewayID;
std::vector<am_Gateway_s> listGateways;
- createGateway(gateway);
+ pCF.createGateway(gateway);
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(listGateways))<< "ERROR: database error";
@@ -1172,7 +1050,7 @@ TEST_F(databaseTest,removeSink)
am_Sink_s sink;
am_sinkID_t sinkID;
std::vector<am_Sink_s> listSinks;
- createSink(sink);
+ pCF.createSink(sink);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks))<< "ERROR: database error";
@@ -1185,7 +1063,7 @@ TEST_F(databaseTest,removeSource)
am_Source_s source;
am_sourceID_t sourceID;
std::vector<am_Source_s> listSources;
- createSource(source);
+ pCF.createSource(source);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))<< "ERROR: database error";
@@ -1226,9 +1104,10 @@ TEST_F(databaseTest,registerGatewayCorrect)
am_Gateway_s gateway, gateway1, gateway2;
am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
- createGateway(gateway,0,"Gateway1");
- createGateway(gateway1,20,"Gateway2");
- createGateway(gateway2,0,"Gateway3");
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID=20;
+ pCF.createGateway(gateway2);
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
@@ -1248,17 +1127,17 @@ TEST_F(databaseTest,registerGatewayCorrect)
{
if(listIterator->gatewayID==gatewayID)
{
- equal= equal && compareGateway(listIterator,gateway);
+ equal= equal && pCF.compareGateway(listIterator,gateway);
}
if(listIterator->gatewayID==gatewayID1)
{
- equal= equal && compareGateway(listIterator,gateway1);
+ equal= equal && pCF.compareGateway(listIterator,gateway1);
}
if(listIterator->gatewayID==gatewayID2)
{
- equal= equal && compareGateway(listIterator,gateway2);
+ equal= equal && pCF.compareGateway(listIterator,gateway2);
}
}
@@ -1272,9 +1151,10 @@ TEST_F(databaseTest,getGatewayInfo)
am_Gateway_s gateway, gateway1, gateway2;
am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
- createGateway(gateway,0,"Gateway1");
- createGateway(gateway1,20,"Gateway2");
- createGateway(gateway2,0,"Gateway3");
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID=20;
+ pCF.createGateway(gateway2);
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
@@ -1294,17 +1174,17 @@ TEST_F(databaseTest,getGatewayInfo)
{
if(listIterator->gatewayID==gatewayID)
{
- equal= equal && compareGateway(listIterator,gateway);
+ equal= equal && pCF.compareGateway(listIterator,gateway);
}
if(listIterator->gatewayID==gatewayID1)
{
- equal= equal && compareGateway(listIterator,gateway1);
+ equal= equal && pCF.compareGateway(listIterator,gateway1);
}
if(listIterator->gatewayID==gatewayID2)
{
- equal= equal && compareGateway(listIterator,gateway2);
+ equal= equal && pCF.compareGateway(listIterator,gateway2);
}
}
@@ -1312,7 +1192,7 @@ TEST_F(databaseTest,getGatewayInfo)
am_Gateway_s gatewayInfo;
ASSERT_EQ(E_OK,pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
- ASSERT_TRUE(compareGateway1(gateway1,gatewayInfo));
+ ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
}
@@ -1322,12 +1202,16 @@ TEST_F(databaseTest,enterSinkThatAlreadyExistFail)
am_Sink_s staticSink,SecondSink;
am_sinkID_t staticSinkID,SecondSinkID;
- createSink(staticSink,43,"Static");
+ pCF.createSink(staticSink);
+ staticSink.sinkID=43;
+ staticSink.name="Static";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
- createSink(SecondSink,43,"secondStatic");
+ pCF.createSink(SecondSink);
+ SecondSink.sinkID=43;
+ SecondSink.name="SecondSink";
ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))<< "ERROR: database error";
}
@@ -1337,12 +1221,14 @@ TEST_F(databaseTest,enterSourcesThatAlreadyExistFail)
//fill the connection database
am_Source_s staticSource,SecondSource;
am_sourceID_t staticSourceID,SecondSourceID;
- createSource(staticSource,4,"FirstSource");
+ pCF.createSource(staticSource);
+ staticSource.sourceID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
- createSource(SecondSource,4,"SecondSource");
+ pCF.createSource(SecondSource);
+ SecondSource.sourceID=4;
ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))<< "ERROR: database error";
}
@@ -1353,7 +1239,7 @@ TEST_F(databaseTest,registerDomainCorrect)
std::vector<am_Domain_s> returnList;
am_Domain_s domain;
am_domainID_t domainID=0;
- createDomain(domain);
+ pCF.createDomain(domain);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
ASSERT_NE(0,domainID)<< "ERROR: domainID zero";
@@ -1375,25 +1261,18 @@ TEST_F(databaseTest,registerDomainCorrect)
ASSERT_EQ(true,equal);
}
-TEST_F(databaseTest,registerDomainFailonID0)
-{
- am_Domain_s domain;
- am_domainID_t domainID=5;
- createDomain(domain,1);
- ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
-}
-
TEST_F(databaseTest,registerConnectionCorrect)
{
am_Connection_s connection;
am_connectionID_t connectionID;
std::vector<am_Connection_s> returnList;
- createConnection(connection);
+ pCF.createConnection(connection);
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))<< "ERROR: database error";;
ASSERT_NE(0,connectionID)<< "ERROR: connectionID zero";
//now check if we read out the correct values
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(returnList));
bool equal=false;
std::vector<am_Connection_s>::iterator listIterator=returnList.begin();
@@ -1421,17 +1300,19 @@ TEST_F(databaseTest,enterSinksCorrect)
am_sinkID_t staticSinkID,firstDynamicSinkID,secondDynamicSinkID;
std::vector<am_Sink_s> sinkList;
- createSink(staticSink,4,"Static");
+ pCF.createSink(staticSink);
+ staticSink.sinkID=4;
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
- createSink(firstDynamicSink,0,"firstDynamicSink");
-
+ pCF.createSink(firstDynamicSink);
+ firstDynamicSink.name="firstdynamic";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(firstDynamicSink,firstDynamicSinkID))<< "ERROR: database error";
ASSERT_EQ(firstDynamicSinkID,DYNAMIC_ID_BOUNDARY)<< "ERROR: ID not the one given in firstDynamicSink";
- createSink(secondDynamicSink,0,"secondDynamicSink");
+ pCF.createSink(secondDynamicSink);
+ secondDynamicSink.name="seconddynamic";
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(secondDynamicSink,secondDynamicSinkID))<< "ERROR: database error";
ASSERT_NEAR(secondDynamicSinkID,DYNAMIC_ID_BOUNDARY,10)<< "ERROR: ID not the one given in secondDynamicSink";
@@ -1445,22 +1326,32 @@ TEST_F(databaseTest,enterSinksCorrect)
{
if(listIterator->sinkID==staticSinkID)
{
- equal = equal && compareSink(listIterator,staticSink);
+ equal = equal && pCF.compareSink(listIterator,staticSink);
}
if(listIterator->sinkID==firstDynamicSinkID)
{
- equal = equal && compareSink(listIterator,firstDynamicSink);
+ equal = equal && pCF.compareSink(listIterator,firstDynamicSink);
}
if(listIterator->sinkID==secondDynamicSinkID)
{
- equal = equal && compareSink(listIterator,secondDynamicSink);
+ equal = equal && pCF.compareSink(listIterator,secondDynamicSink);
}
}
ASSERT_EQ(true,equal);
}
+//Commented out - gives always a warning..
+//TEST_F(databaseTest,registerDomainFailonID0)
+//{
+// am_Domain_s domain;
+// am_domainID_t domainID=5;
+// pCF.createDomain(domain);
+// domain.domainID=1;
+// ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
+//}
+
int main(int argc, char **argv)
{
diff --git a/AudioManagerDaemon/test/database/databaseTest.h b/AudioManagerDaemon/test/database/databaseTest.h
new file mode 100644
index 0000000..3255b71
--- /dev/null
+++ b/AudioManagerDaemon/test/database/databaseTest.h
@@ -0,0 +1,37 @@
+/*
+ * databasetest.h
+ *
+ * Created on: Dec 6, 2011
+ * Author: christian
+ */
+
+#ifndef DATABASETEST_H_
+#define DATABASETEST_H_
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <dlt/dlt.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "DatabaseHandler.h"
+#include "../CommonFunctions.h"
+
+DLT_DECLARE_CONTEXT(AudioManager)
+
+using namespace testing;
+
+class databaseTest : public Test {
+public:
+
+ DatabaseHandler pDatabaseHandler;
+ CommonFunctions pCF;
+
+ void SetUp();
+ void TearDown();
+
+ void createMainConnectionSetup();
+};
+
+#endif /* DATABASETEST_H_ */
diff --git a/AudioManagerDaemon/test/databasetest.h b/AudioManagerDaemon/test/databasetest.h
deleted file mode 100644
index a969fc9..0000000
--- a/AudioManagerDaemon/test/databasetest.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * databasetest.h
- *
- * Created on: Dec 6, 2011
- * Author: christian
- */
-
-#ifndef DATABASETEST_H_
-#define DATABASETEST_H_
-
-
-#include <gtest/gtest.h>
-#include <dlt/dlt.h>
-#include <algorithm>
-#include <string>
-#include <vector>
-#include <set>
-#include "DatabaseHandler.h"
-
-DLT_DECLARE_CONTEXT(AudioManager);
-
-using namespace testing;
-
-class databaseTest : public Test {
-public:
-
- DatabaseHandler pDatabaseHandler;
- void SetUp();
- void TearDown();
-
- static std::vector<am_ConnectionFormat_e> getStandardConnectionFormatList();
- static std::vector<am_SoundProperty_s> getStandardSoundPropertyList();
- static std::vector<am_MainSoundProperty_s> getStandardMainSoundPropertyList();
- static std::vector<bool> getStandardConvertionMatrix();
- bool compareSource(std::vector<am_Source_s>::iterator listIterator, const am_Source_s& sourceData);
- bool compareSink(std::vector<am_Sink_s>::iterator listIterator, const am_Sink_s& sinkData);
- bool compareGateway(std::vector<am_Gateway_s>::iterator listIterator, const am_Gateway_s& gatewayData);
- bool compareGateway1(const am_Gateway_s gateway1, const am_Gateway_s gatewayData);
- bool compareSinkMainSink(std::vector<am_SinkType_s>::iterator listIterator, const std::vector<am_Sink_s>& sinkList);
- bool compareSinkMainSource(std::vector<am_SourceType_s>::iterator listIterator, const std::vector<am_Source_s>& sourceList);
- std::string int2string(int i);
-
- void createSink(am_Sink_s& sink,am_sinkID_t sinkID,std::string name,am_domainID_t domainID, am_Availablility_e availability,
- am_AvailabilityReason_e availabilityReason, am_sinkClass_t sinkClassID,
- std::vector<am_ConnectionFormat_e> connectionFormatList,
- std::vector<am_SoundProperty_s> soundPropertyList,
- std::vector<am_MainSoundProperty_s> mainSoundPropertyList,
- am_mainVolume_t mainVolume, am_MuteState_e muteState,
- bool visible, am_volume_t volume);
-
- void createSource(am_Source_s& source, am_sourceID_t sourceID, std::string name, am_domainID_t domainID,
- am_Availablility_e availability, am_AvailabilityReason_e availabilityReason, am_sourceClass_t sourceClassID,
- std::vector<am_ConnectionFormat_e> listConnectionFormats,
- std::vector<am_SoundProperty_s> listSoundProperties,
- std::vector<am_MainSoundProperty_s> listMainSoundProperties,
- am_InterruptState_e interruptState, bool visible, am_volume_t volume, am_SourceState_e sourceState);
-
- void createDomain(am_Domain_s& domain, am_domainID_t domainID, std::string name, std::string nodename,
- std::string busname, bool complete, bool early, am_DomainState_e state);
-
- void createGateway(am_Gateway_s& gateway, am_gatewayID_t gatewayID, std::string name, am_sinkID_t sinkID, am_sourceID_t sourceID, am_domainID_t controlDomainID,
- am_domainID_t domainSinkID, am_domainID_t domainSourceID,std::vector<bool> convertionMatrix,
- std::vector<am_ConnectionFormat_e> listSourceFormats,std::vector<am_ConnectionFormat_e> listSinkFormats);
-
- void createConnection(am_Connection_s& connection, am_connectionID_t connectionID, am_sinkID_t sinkID,
- am_sourceID_t sourceID, am_timeSync_t delay, am_ConnectionFormat_e connectionFormat);
-
- void createMainConnection(am_MainConnection_s& mainConnection, am_Route_s route, am_timeSync_t delay,
- am_mainConnectionID_t connectionID, am_ConnectionState_e state);
-
-
- void connectionList2RoutingList(std::vector<am_RoutingElement_s>& routingList, const std::vector<am_Connection_s>& connectionList);
-
- void createMainConnectionSetup();
-
- struct sortBySinkID
- {
- bool operator()(const am_RoutingElement_s & a, const am_RoutingElement_s & b) const
- {
- return (a.sinkID < b.sinkID);
- }
- };
-
- struct sortByConnectionFormat
- {
- bool operator()(const am_ConnectionFormat_e & a, const am_ConnectionFormat_e & b) const
- {
- return (a < b);
- }
- };
-
- struct sortByMainSoundProperty
- {
- bool operator()(const am_MainSoundProperty_s & a, const am_MainSoundProperty_s & b) const
- {
- return (a.type > b.type);
- }
- };
-
- struct sortBySoundProperty
- {
- bool operator()(const am_SoundProperty_s & a, const am_SoundProperty_s & b) const
- {
- return (a.type < b.type);
- }
- };
-};
-
-#endif /* DATABASETEST_H_ */
diff --git a/AudioManagerDaemon/test/routingInterface/CMakeLists.txt b/AudioManagerDaemon/test/routingInterface/CMakeLists.txt
new file mode 100644
index 0000000..b3db54a
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/CMakeLists.txt
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2011, BMW AG
+#
+# GeniviAudioMananger RoutingInterfaceTest
+#
+# \file CMakeLists.txt
+#
+# \date 20-Oct-2011 3:42:04 PM
+# \author Christian Mueller (christian.ei.mueller@bmw.de)
+#
+# \section License
+# GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+# Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+#
+# This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+# You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+# Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+# Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+# As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+# Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(routingInterfaceTest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic")
+#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../../../dbusInterfaces)
+set(AUDIO_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../includes)
+set(DBUS_INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../../../dbusIncludes)
+set(INCLUDES_FOLDER ${CMAKE_SOURCE_DIR}/../../include)
+set(EXECUTABLE_OUTPUT_PATH ../../../../test/)
+
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+pkg_check_modules(DLT REQUIRED automotive-dlt)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDES_FOLDER}
+ ${DBUS_ARCH_INCLUDE_DIR}
+ ${DBUS_INCLUDES_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${STD_INCLUDE_DIRS}
+ ${DLT_INCLUDE_DIRS}
+ ${DBUS_INCLUDE_DIR}
+ ${INCLUDES_FOLDER}
+)
+
+file(GLOB ROUTING_INTERFACE_SRCS_CXX
+ "../../src/ControlReceiver.cpp"
+ "../../src/DatabaseHandler.cpp"
+ "../../src/Observer.cpp"
+ "../../src/CommandSender.cpp"
+ "../../src/RoutingSender.cpp"
+ "../CommonFunctions.cpp"
+ "*.cpp"
+)
+
+ADD_EXECUTABLE(routinginterfacetest ${ROUTING_INTERFACE_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES(routinginterfacetest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ gtest
+ gmock
+)
+
+
+
diff --git a/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h
new file mode 100644
index 0000000..bd25156
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h
@@ -0,0 +1,52 @@
+/*
+ * MockRoutingInterface.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef MOCKROUTINGINTERFACE_H_
+#define MOCKROUTINGINTERFACE_H_
+
+#include <routing/RoutingSendInterface.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+namespace am {
+
+class MockRoutingSendInterface : public RoutingSendInterface {
+ public:
+ MOCK_METHOD1(startupRoutingInterface,
+ void(RoutingReceiveInterface* routingreceiveinterface));
+ MOCK_METHOD0(routingInterfacesReady,
+ void());
+ MOCK_METHOD0(routingInterfacesRundown,
+ void());
+ MOCK_METHOD1(asyncAbort,
+ am_Error_e(const am_Handle_s handle));
+ MOCK_METHOD5(asyncConnect,
+ am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat));
+ MOCK_METHOD2(asyncDisconnect,
+ am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID));
+ MOCK_METHOD5(asyncSetSinkVolume,
+ am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time));
+ MOCK_METHOD5(asyncSetSourceVolume,
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time));
+ MOCK_METHOD3(asyncSetSourceState,
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state));
+ MOCK_METHOD3(asyncSetSinkSoundProperty,
+ am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID));
+ MOCK_METHOD3(asyncSetSourceSoundProperty,
+ am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID));
+ MOCK_METHOD5(asyncCrossFade,
+ am_Error_e(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time));
+ MOCK_METHOD2(setDomainState,
+ am_Error_e(const am_domainID_t domainID, const am_DomainState_e domainState));
+ MOCK_CONST_METHOD1(returnBusName,
+ am_Error_e(std::string& BusName));
+ };
+
+} // namespace am
+
+
+#endif /* MOCKROUTINGINTERFACE_H_ */
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
new file mode 100644
index 0000000..bc3e583
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
@@ -0,0 +1,415 @@
+/*
+ * routingInterfaceTest.cpp
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#include "routingInterfaceTest.h"
+
+using ::testing::Field;
+using ::testing::Property;
+using ::testing::Matcher;
+using ::testing::Pointee;
+using ::testing::AllOf;
+using ::testing::SafeMatcherCast;
+using ::testing::MatcherCast;
+using ::testing::DefaultValue;
+using ::testing::Eq;
+using ::testing::An;
+using ::testing::ElementsAreArray;
+using ::testing::ElementsAre;
+using ::testing::NotNull;
+
+routingInterfaceTest::routingInterfaceTest()
+ :pDatabaseHandler(),
+ pRoutingSender(),
+ pCommandSender(),
+ pMockInterface(),
+ pRoutingInterfaceBackdoor(),
+ pCommandInterfaceBackdoor(),
+ pControlReceiver(&pDatabaseHandler,&pRoutingSender),
+ pObserver(&pCommandSender,&pRoutingSender)
+{
+ pDatabaseHandler.registerObserver(&pObserver);
+ pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
+ pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender,&pMockInterface,"mock");
+ pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
+}
+
+routingInterfaceTest::~routingInterfaceTest()
+{
+}
+
+void routingInterfaceTest::SetUp()
+{
+ DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+
+}
+
+void routingInterfaceTest::TearDown()
+{
+ DLT_UNREGISTER_CONTEXT(AudioManager);
+}
+
+TEST_F(routingInterfaceTest,abort)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_CONNECT);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+ EXPECT_CALL(pMockInterface,asyncAbort(_)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.abortAction(handle));
+}
+
+TEST_F(routingInterfaceTest,abortNonExistent)
+{
+ EXPECT_CALL(pMockInterface,asyncAbort(_)).Times(0);
+ am_Handle_s handle;
+ ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.abortAction(handle));
+}
+
+TEST_F(routingInterfaceTest,alreadyConnected)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(E_ALREADY_EXISTS,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_CONNECT);
+}
+
+TEST_F(routingInterfaceTest,setSinkSoundPropertyNoChange)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ soundProperty.type=SP_TREBLE;
+ soundProperty.value=23;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ sink.listSoundProperties.push_back(soundProperty);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+}
+
+TEST_F(routingInterfaceTest,setSourceState)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ handle.handle=0;
+ am_SourceState_e state=SS_PAUSED;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSourceState(handle,sourceID,state));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSOURCESTATE);
+}
+
+TEST_F(routingInterfaceTest,setSourceSoundProperty)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.sourceID=2;
+ source.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceSoundProperty(_,_,sourceID)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSourceSoundProperty(handle,sourceID,soundProperty));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSOURCESOUNDPROPERTY);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,setSinkSoundProperty)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSINKSOUNDPROPERTY);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,setSourceVolumeNoChange)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.sourceID=2;
+ source.domainID=1;
+ source.volume=volume;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceVolume(_,2,volume,rampType,rampTime)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles.empty());
+}
+
+TEST_F(routingInterfaceTest,setSourceVolume)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.sourceID=2;
+ source.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceVolume(_,2,volume,rampType,rampTime)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSourceVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSOURCEVOLUME);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,setSinkVolumeNoChange)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ sink.volume=volume;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkVolume(_,2,volume,rampType,rampTime)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles.empty());
+}
+
+TEST_F(routingInterfaceTest,setSinkVolume)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_volume_t volume=34;
+ am_RampType_e rampType=RAMP_DIRECT;
+ am_time_t rampTime=300;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncSetSinkVolume(_,2,volume,rampType,rampTime)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.setSinkVolume(handle,2,volume,rampType,rampTime));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_SETSINKVOLUME);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,connect)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_CONNECT);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[0].handle==handle.handle);
+ ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,disconnect)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ am_connectionID_t connectionID;
+ std::vector<am_Handle_s>listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ sink.sinkID=2;
+ sink.domainID=1;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
+ EXPECT_CALL(pMockInterface,asyncConnect(_,_,1,sinkID,CF_ANALOG)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
+ EXPECT_CALL(pMockInterface,asyncDisconnect(_,connectionID)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK,pControlReceiver.disconnect(handle,connectionID));
+ ASSERT_NE(handle.handle,0);
+ ASSERT_EQ(handle.handleType,H_DISCONNECT);
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles[1].handle==handle.handle);
+ ASSERT_TRUE(listHandles[1].handleType==handle.handleType);
+}
+
+TEST_F(routingInterfaceTest,nothingTodisconnect)
+{
+ am_Handle_s handle;
+ am_connectionID_t connectionID=4;
+ std::vector<am_Handle_s>listHandles;
+ ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.disconnect(handle,connectionID));
+ ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_TRUE(listHandles.empty());
+}
+
+
+TEST_F(routingInterfaceTest,setSourceStateNoChange)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_Handle_s handle;
+ handle.handle=0;
+ am_SourceState_e state=SS_PAUSED;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name="mock";
+ domain.busname="mock";
+ source.domainID=1;
+ source.sourceState=state;
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,asyncSetSourceState(_,sourceID,state)).Times(0);
+ ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceState(handle,sourceID,state));
+}
+
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
new file mode 100644
index 0000000..f46ea5f
--- /dev/null
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
@@ -0,0 +1,49 @@
+/*
+ * routingInterfaceTest.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef ROUTINGINTERFACETEST_H_
+#define ROUTINGINTERFACETEST_H_
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <dlt/dlt.h>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "MockRoutingInterface.h"
+#include "DatabaseHandler.h"
+#include "ControlReceiver.h"
+#include "ControlSender.h"
+#include "Observer.h"
+#include "../RoutingInterfaceBackdoor.h"
+#include "../CommandInterfaceBackdoor.h"
+#include "../CommonFunctions.h"
+
+DLT_DECLARE_CONTEXT(AudioManager)
+
+using namespace testing;
+using namespace am;
+
+class routingInterfaceTest : public Test{
+public:
+ routingInterfaceTest();
+ virtual ~routingInterfaceTest();
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockRoutingSendInterface pMockInterface;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlReceiver pControlReceiver;
+ Observer pObserver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
+};
+
+#endif /* ROUTINGINTERFACETEST_H_ */