summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/test
diff options
context:
space:
mode:
authorchristian mueller <christian.ei.mueller@bmw.de>2012-01-24 17:04:42 +0100
committerchristian mueller <christian.ei.mueller@bmw.de>2012-01-24 17:04:42 +0100
commit4fe50302a695c625d5161b538da771b2c36bd33e (patch)
tree79d9fb949d626b19ac0d933a637b4881af31114e /AudioManagerDaemon/test
parent80213f17291e5b58c733de09f06439d71640d2e2 (diff)
downloadaudiomanager-4fe50302a695c625d5161b538da771b2c36bd33e.tar.gz
* formatting all the source code with eclipse source code style
* added used xml to the project
Diffstat (limited to 'AudioManagerDaemon/test')
-rw-r--r--AudioManagerDaemon/test/CommandInterfaceBackdoor.h60
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.cpp636
-rw-r--r--AudioManagerDaemon/test/CommonFunctions.h141
-rw-r--r--AudioManagerDaemon/test/ControlInterfaceBackdoor.h58
-rw-r--r--AudioManagerDaemon/test/RoutingInterfaceBackdoor.h60
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp857
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h91
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.cpp2920
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.h85
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp584
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h83
-rw-r--r--AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp377
-rw-r--r--AudioManagerDaemon/test/sockethandler/sockethandlerTest.h72
13 files changed, 3002 insertions, 3022 deletions
diff --git a/AudioManagerDaemon/test/CommandInterfaceBackdoor.h b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
index ab57a62..5d06fb1 100644
--- a/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
+++ b/AudioManagerDaemon/test/CommandInterfaceBackdoor.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommandInterfaceBackdoor.h
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommandInterfaceBackdoor.h
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef COMMANDINTERFACEBACKDOOR_H_
#define COMMANDINTERFACEBACKDOOR_H_
@@ -29,16 +29,18 @@
#include <command/CommandSendInterface.h>
#include "CommandSender.h"
-namespace am {
+namespace am
+{
class CommandSender;
-class CommandInterfaceBackdoor {
+class CommandInterfaceBackdoor
+{
public:
- CommandInterfaceBackdoor();
- virtual ~CommandInterfaceBackdoor();
- bool unloadPlugins(CommandSender *CommandSender);
- bool injectInterface(CommandSender* CommandSender, CommandSendInterface* CommandSendInterface);
+ CommandInterfaceBackdoor();
+ virtual ~CommandInterfaceBackdoor();
+ bool unloadPlugins(CommandSender *CommandSender);
+ bool injectInterface(CommandSender* CommandSender, CommandSendInterface* CommandSendInterface);
};
}
diff --git a/AudioManagerDaemon/test/CommonFunctions.cpp b/AudioManagerDaemon/test/CommonFunctions.cpp
index b62169e..2a5c8cf 100644
--- a/AudioManagerDaemon/test/CommonFunctions.cpp
+++ b/AudioManagerDaemon/test/CommonFunctions.cpp
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommonFunctions.cpp
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommonFunctions.cpp
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#include "CommonFunctions.h"
#include "CommandInterfaceBackdoor.h"
@@ -32,359 +32,305 @@
using namespace am;
-CommandInterfaceBackdoor::CommandInterfaceBackdoor() {
+CommandInterfaceBackdoor::CommandInterfaceBackdoor()
+{
}
-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::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
+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()
+{
}
-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::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
+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()
+{
+}
-ControlInterfaceBackdoor::~ControlInterfaceBackdoor() {}
+ControlInterfaceBackdoor::~ControlInterfaceBackdoor()
+{
+}
bool ControlInterfaceBackdoor::replaceController(ControlSender *controlSender, ControlSendInterface *newController)
{
- controlSender->mController=newController;
- return true;
+ 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);
- }
+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;
+}
+bool CommonFunctions::compareRoute(am_Route_s a, am_Route_s b)
+{
+ bool retVal = true;
+ std::vector<am_RoutingElement_s>::iterator itA = a.route.begin(), itB = b.route.begin();
+ retVal &= a.sourceID == b.sourceID;
+ retVal &= a.sinkID == b.sinkID;
+ for (; itA != a.route.end(); ++itA)
+ {
+ retVal &= itA->sinkID == itB->sinkID;
+ retVal &= itA->sourceID == itB->sourceID;
+ retVal &= itA->connectionFormat == itB->connectionFormat;
+ retVal &= itA->domainID == itB->domainID;
+ itB++;
+ }
+ return retVal;
+}
+
+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
index af6d43b..7bc7e04 100644
--- a/AudioManagerDaemon/test/CommonFunctions.h
+++ b/AudioManagerDaemon/test/CommonFunctions.h
@@ -1,91 +1,92 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file CommonFunctions.h
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file CommonFunctions.h
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef COMMONHEADERS_H_
#define COMMONHEADERS_H_
#include "audiomanagertypes.h"
-namespace am {
+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);
+ 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);
+ bool compareRoute(am_Route_s a, am_Route_s b);
+ 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 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 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 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);
- }
- };
+ 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
index b07f3ad..135bc48 100644
--- a/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
+++ b/AudioManagerDaemon/test/ControlInterfaceBackdoor.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file ControlInterfaceBackdoor.h
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file ControlInterfaceBackdoor.h
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef CONTROLINTERFACEBACKDOOR_H_
#define CONTROLINTERFACEBACKDOOR_H_
@@ -29,15 +29,17 @@
#include "control/ControlSendInterface.h"
#include "ControlSender.h"
-namespace am {
+namespace am
+{
class ControlSender;
-class ControlInterfaceBackdoor {
+class ControlInterfaceBackdoor
+{
public:
- ControlInterfaceBackdoor();
- virtual ~ControlInterfaceBackdoor();
- bool replaceController(ControlSender *controlSender, ControlSendInterface *newController);
+ ControlInterfaceBackdoor();
+ virtual ~ControlInterfaceBackdoor();
+ bool replaceController(ControlSender *controlSender, ControlSendInterface *newController);
};
}
diff --git a/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
index b7e7624..ff7ffdb 100644
--- a/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
+++ b/AudioManagerDaemon/test/RoutingInterfaceBackdoor.h
@@ -1,43 +1,45 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file RoutingInterfaceBackdoor.h
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file RoutingInterfaceBackdoor.h
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef ROUTINGINTERFACEBACKDOOR_H_
#define ROUTINGINTERFACEBACKDOOR_H_
#include "RoutingSender.h"
-namespace am {
+namespace am
+{
class RoutingSender;
-class RoutingInterfaceBackdoor {
+class RoutingInterfaceBackdoor
+{
public:
- RoutingInterfaceBackdoor();
- virtual ~RoutingInterfaceBackdoor();
- bool unloadPlugins(RoutingSender *RoutingSender);
- bool injectInterface(RoutingSender *RoutingSender, RoutingSendInterface *newInterface, const std::string& busname);
+ RoutingInterfaceBackdoor();
+ virtual ~RoutingInterfaceBackdoor();
+ bool unloadPlugins(RoutingSender *RoutingSender);
+ bool injectInterface(RoutingSender *RoutingSender, RoutingSendInterface *newInterface, const std::string& busname);
};
}
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
index 2efcc64..5d3a4f1 100644
--- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file controlInterfaceTest.cpp
-*
-* \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.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file controlInterfaceTest.cpp
+ *
+ * \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.
+ *
+ */
#include "controlInterfaceTest.h"
#include <algorithm>
@@ -33,26 +33,26 @@ using namespace testing;
DLT_DECLARE_CONTEXT(DLT_CONTEXT)
-controlInterfaceTest::controlInterfaceTest()
- :pDBusWrapper((DBusWrapper*)1), //to get rid of assert
- plistCommandPluginDirs(),
- plistRoutingPluginDirs(),
- pDatabaseHandler(std::string(":memory:")),
- pRoutingSender(plistRoutingPluginDirs),
- pCommandSender(plistCommandPluginDirs),
- pMockControlInterface(),
- pMockRoutingInterface(),
- pControlSender(std::string("")),
- pRoutingInterfaceBackdoor(),
- pCommandInterfaceBackdoor(),
- pControlInterfaceBackdoor(),
- pDatabaseObserver(&pCommandSender,&pRoutingSender),
- pControlReceiver(&pDatabaseHandler,&pRoutingSender,&pCommandSender),
- pRoutingReceiver(&pDatabaseHandler,&pRoutingSender,&pControlSender,pDBusWrapper)
+controlInterfaceTest::controlInterfaceTest() :
+ pDBusWrapper((DBusWrapper*) 1), //
+ plistCommandPluginDirs(), //
+ plistRoutingPluginDirs(), //
+ pDatabaseHandler(std::string(":memory:")), //
+ pRoutingSender(plistRoutingPluginDirs), //
+ pCommandSender(plistCommandPluginDirs), //
+ pMockControlInterface(), //
+ pMockRoutingInterface(), //
+ pControlSender(std::string("")), //
+ pRoutingInterfaceBackdoor(), //
+ pCommandInterfaceBackdoor(), //
+ pControlInterfaceBackdoor(), //
+ pDatabaseObserver(&pCommandSender, &pRoutingSender), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, pDBusWrapper)
{
- pDatabaseHandler.registerObserver(&pDatabaseObserver);
- pControlInterfaceBackdoor.replaceController(&pControlSender,&pMockControlInterface);
- pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender,&pMockRoutingInterface,"mock");
+ pDatabaseHandler.registerObserver(&pDatabaseObserver);
+ pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
+ pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockRoutingInterface, "mock");
}
@@ -62,473 +62,472 @@ controlInterfaceTest::~controlInterfaceTest()
void controlInterfaceTest::SetUp()
{
- DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
- DLT_REGISTER_CONTEXT(DLT_CONTEXT,"Main","Main Context");
- DLT_LOG(DLT_CONTEXT,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+ DLT_REGISTER_APP("Rtest", "RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
+ DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
}
void controlInterfaceTest::TearDown()
{
- DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
+ DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
}
TEST_F(controlInterfaceTest,registerDomain)
{
- am_Domain_s domain;
- am_domainID_t domainID;
- pCF.createDomain(domain);
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ pCF.createDomain(domain);
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterDomain(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerDomain(domain,domainID));
- ASSERT_EQ(domainID,2);
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterDomain(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerDomain(domain,domainID));
+ ASSERT_EQ(domainID, 2);
}
TEST_F(controlInterfaceTest,deregisterDomain)
{
- am_domainID_t domainID=34;
+ am_domainID_t domainID = 34;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterDomain(34)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterDomain(domainID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterDomain(34)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterDomain(domainID));
}
TEST_F(controlInterfaceTest,registerSink)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
-
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterSink(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerSink(sink,sinkID));
- ASSERT_EQ(sinkID,2);
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterSink(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerSink(sink,sinkID));
+ ASSERT_EQ(sinkID, 2);
}
TEST_F(controlInterfaceTest,deregisterSink)
{
- am_sinkID_t sinkID=12;
+ am_sinkID_t sinkID = 12;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSink(12)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterSink(sinkID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSink(12)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterSink(sinkID));
}
TEST_F(controlInterfaceTest,registerSource)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
-
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterSource(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerSource(source,sourceID));
- ASSERT_EQ(sourceID,2);
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterSource(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerSource(source,sourceID));
+ ASSERT_EQ(sourceID, 2);
}
TEST_F(controlInterfaceTest,deregisterSource)
{
- am_sourceID_t sourceID=12;
+ am_sourceID_t sourceID = 12;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSource(12)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterSource(sourceID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterSource(12)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterSource(sourceID));
}
TEST_F(controlInterfaceTest,registerGateway)
{
- am_Gateway_s gateway;
- am_gatewayID_t gatewayID;
- pCF.createGateway(gateway);
-
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemRegisterGateway(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2),Return(E_OK)));
- ASSERT_EQ(E_OK,pRoutingReceiver.registerGateway(gateway,gatewayID));
- ASSERT_EQ(gatewayID,2);
+ am_Gateway_s gateway;
+ am_gatewayID_t gatewayID;
+ pCF.createGateway(gateway);
+
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemRegisterGateway(_,_)).WillRepeatedly(DoAll(SetArgReferee<1>(2), Return(E_OK)));
+ ASSERT_EQ(E_OK, pRoutingReceiver.registerGateway(gateway,gatewayID));
+ ASSERT_EQ(gatewayID, 2);
}
TEST_F(controlInterfaceTest,deregisterGateway)
{
- am_gatewayID_t gatewayID=12;
+ am_gatewayID_t gatewayID = 12;
- //When we run this test, we expect the call on the control interface
- EXPECT_CALL(pMockControlInterface,hookSystemDeregisterGateway(12)).WillRepeatedly(Return(E_OK));
- ASSERT_EQ(E_OK,pRoutingReceiver.deregisterGateway(gatewayID));
+ //When we run this test, we expect the call on the control interface
+ EXPECT_CALL(pMockControlInterface,hookSystemDeregisterGateway(12)).WillRepeatedly(Return(E_OK));
+ ASSERT_EQ(E_OK, pRoutingReceiver.deregisterGateway(gatewayID));
}
-
TEST_F(controlInterfaceTest,ackConnect)
{
- am_connectionID_t connectionID;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Connection_s> connectionList;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //when asyncConnect is called, we expect a call on the routingInterface
- EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
-
- //The handle should have the correct type
- ASSERT_EQ(handle.handleType,H_CONNECT);
- ASSERT_EQ(handle.handle,1);
- ASSERT_EQ(connectionID,1);
-
- //The list of handles shall have the handle inside
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,handle.handleType);
-
- //we check the list of connections - but it must be empty because the ack did not arrive yet
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(connectionList.empty());
-
- //finally we answer via the RoutingInterface and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
- pRoutingReceiver.ackConnect(handle,connectionID,E_OK);
-
- //the list of handles must be empty now
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //but the connection must be in the connectionlist
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(!connectionList.empty());
-
- //no we try the same, but do expect a no_change answer directly and no call because connection already exists
- ASSERT_EQ(E_ALREADY_EXISTS,pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
+ am_connectionID_t connectionID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //when asyncConnect is called, we expect a call on the routingInterface
+ EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
+
+ //The handle should have the correct type
+ ASSERT_EQ(handle.handleType, H_CONNECT);
+ ASSERT_EQ(handle.handle, 1);
+ ASSERT_EQ(connectionID, 1);
+
+ //The list of handles shall have the handle inside
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, handle.handleType);
+
+ //we check the list of connections - but it must be empty because the ack did not arrive yet
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(connectionList.empty());
+
+ //finally we answer via the RoutingInterface and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
+ pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
+
+ //the list of handles must be empty now
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //but the connection must be in the connectionlist
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(!connectionList.empty());
+
+ //no we try the same, but do expect a no_change answer directly and no call because connection already exists
+ ASSERT_EQ(E_ALREADY_EXISTS, pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
}
TEST_F(controlInterfaceTest,ackDisconnect)
{
- am_connectionID_t connectionID;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Connection_s> connectionList;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //now we first need to connect, we expect a call on the routing interface
- EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
-
- //answer with an ack to insert the connection in the database
- EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
- pRoutingReceiver.ackConnect(handle,connectionID,E_OK);
-
- //now we can start to disconnect and expect a call on the routing interface
- EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.disconnect(handle,1));
-
- //during the disconnection, the connection is still in the list!
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(!connectionList.empty());
-
- //then we fire the ack and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckDisconnect(_,E_OK)).Times(1);
- pRoutingReceiver.ackDisconnect(handle,connectionID,E_OK);
-
- //make sure the handle is gone
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //make sure the connection is gone
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(connectionList.empty());
-
- //Now let's try to disconnect what is not existing...
- ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.disconnect(handle,2));
+ am_connectionID_t connectionID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //now we first need to connect, we expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncConnect(_,1,2,2,CF_STEREO)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.connect(handle,connectionID,CF_STEREO,2,2));
+
+ //answer with an ack to insert the connection in the database
+ EXPECT_CALL(pMockControlInterface,cbAckConnect(_,E_OK)).Times(1);
+ pRoutingReceiver.ackConnect(handle, connectionID, E_OK);
+
+ //now we can start to disconnect and expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncDisconnect(_,1)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.disconnect(handle,1));
+
+ //during the disconnection, the connection is still in the list!
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(!connectionList.empty());
+
+ //then we fire the ack and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckDisconnect(_,E_OK)).Times(1);
+ pRoutingReceiver.ackDisconnect(handle, connectionID, E_OK);
+
+ //make sure the handle is gone
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //make sure the connection is gone
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(connectionList.empty());
+
+ //Now let's try to disconnect what is not existing...
+ ASSERT_EQ(E_NON_EXISTENT, pControlReceiver.disconnect(handle,2));
}
TEST_F(controlInterfaceTest,setSourceState)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- am_SourceState_e state;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //we set the sourcestate and expect a call on the routingInterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSourceState(_,2,SS_PAUSED)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
-
- //we want our handle in the list and let the type be the right one
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSOURCESTATE);
-
- //the state must be unchanged because did not get the ack
- ASSERT_EQ(E_OK,pDatabaseHandler.getSoureState(source.sourceID,state));
- ASSERT_EQ(state,SS_ON);
-
- //now we sent out the ack and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSourceState(_,E_OK)).Times(1);
- pRoutingReceiver.ackSetSourceState(handle,E_OK);
-
- //finally we need the sourcestate to be changed
- ASSERT_EQ(E_OK,pDatabaseHandler.getSoureState(source.sourceID,state));
- ASSERT_EQ(state,SS_PAUSED);
-
- //make sure the handle is gone
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //we try again but expect a no change error
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ am_SourceState_e state;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //we set the sourcestate and expect a call on the routingInterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSourceState(_,2,SS_PAUSED)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
+
+ //we want our handle in the list and let the type be the right one
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSOURCESTATE);
+
+ //the state must be unchanged because did not get the ack
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSoureState(source.sourceID,state));
+ ASSERT_EQ(state, SS_ON);
+
+ //now we sent out the ack and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSourceState(_,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSourceState(handle, E_OK);
+
+ //finally we need the sourcestate to be changed
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSoureState(source.sourceID,state));
+ ASSERT_EQ(state, SS_PAUSED);
+
+ //make sure the handle is gone
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //we try again but expect a no change error
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceState(handle,source.sourceID,SS_PAUSED));
}
TEST_F(controlInterfaceTest,SetSinkVolumeChange)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_volume_t volume;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- sink.volume=10;
-
- //setup environment, we need a domain and a sink
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //set the volume and expect a call on the routing interface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSinkVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSINKVOLUME);
-
- //now we read out the volume, but we expect no change because the ack did not arrive yet
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkVolume(sinkID,volume));
- ASSERT_EQ(sink.volume,volume);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSinkVolumeChange(_,11,E_OK)).Times(1);
- pRoutingReceiver.ackSetSinkVolumeChange(handle,11,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkVolume(sinkID,volume));
- ASSERT_EQ(11,volume);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_volume_t volume;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ sink.volume = 10;
+
+ //setup environment, we need a domain and a sink
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //set the volume and expect a call on the routing interface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSinkVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSINKVOLUME);
+
+ //now we read out the volume, but we expect no change because the ack did not arrive yet
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkVolume(sinkID,volume));
+ ASSERT_EQ(sink.volume, volume);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSinkVolumeChange(_,11,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSinkVolumeChange(handle, 11, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkVolume(sinkID,volume));
+ ASSERT_EQ(11, volume);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkVolume(handle,sinkID,11,RAMP_DIRECT,23));
}
TEST_F(controlInterfaceTest,ackSetSourceVolumeChange)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_volume_t volume;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
- source.volume=12;
-
- //prepare the scene
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //change the sinkVolume, expect a call on the routingInterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSourceVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSOURCEVOLUME);
-
- //now we read out the volume, but we expect no change because the ack did not arrive yet
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceVolume(sourceID,volume));
- ASSERT_EQ(source.volume,volume);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSourceVolumeChange(_,11,E_OK)).Times(1);
- pRoutingReceiver.ackSetSourceVolumeChange(handle,11,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceVolume(sourceID,volume));
- ASSERT_EQ(11,volume);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_volume_t volume;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+ source.volume = 12;
+
+ //prepare the scene
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //change the sinkVolume, expect a call on the routingInterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSourceVolume(_,2,11,RAMP_DIRECT,23)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSOURCEVOLUME);
+
+ //now we read out the volume, but we expect no change because the ack did not arrive yet
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceVolume(sourceID,volume));
+ ASSERT_EQ(source.volume, volume);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSourceVolumeChange(_,11,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSourceVolumeChange(handle, 11, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceVolume(sourceID,volume));
+ ASSERT_EQ(11, volume);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceVolume(handle,source.sourceID,11,RAMP_DIRECT,23));
}
TEST_F(controlInterfaceTest,ackSetSinkSoundProperty)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- am_SoundProperty_s soundProperty;
- uint16_t oldvalue;
- pCF.createSink(sink);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- sink.sinkID=2;
- sink.domainID=1;
- soundProperty.type=SP_BASS;
- soundProperty.value=244;
-
- //setup environment, we need a domain and a sink
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //change the soundproperty, expect a call on the routinginterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,_,2)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSINKSOUNDPROPERTY);
-
- //read out this property. There is no change, because the ack did not arrive yet.
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkSoundPropertyValue(2,SP_BASS,oldvalue));
- ASSERT_EQ(sink.listSoundProperties[0].value,oldvalue);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK)).Times(1);
- pRoutingReceiver.ackSetSinkSoundProperty(handle,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkSoundPropertyValue(sinkID,SP_BASS,oldvalue));
- ASSERT_EQ(soundProperty.value,oldvalue);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ uint16_t oldvalue;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+ soundProperty.type = SP_BASS;
+ soundProperty.value = 244;
+
+ //setup environment, we need a domain and a sink
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //change the soundproperty, expect a call on the routinginterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,_,2)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSINKSOUNDPROPERTY);
+
+ //read out this property. There is no change, because the ack did not arrive yet.
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(2,SP_BASS,oldvalue));
+ ASSERT_EQ(sink.listSoundProperties[0].value, oldvalue);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSinkSoundProperty(handle, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(sinkID,SP_BASS,oldvalue));
+ ASSERT_EQ(soundProperty.value, oldvalue);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
}
TEST_F(controlInterfaceTest,ackSetSourceSoundProperty)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Handle_s> handlesList;
- am_Handle_s handle;
- am_SoundProperty_s soundProperty;
- uint16_t oldvalue;
- pCF.createSource(source);
- pCF.createDomain(domain);
- domain.name="mock";
- domain.busname="mock";
- source.sourceID=2;
- source.domainID=1;
- soundProperty.type=SP_BASS;
- soundProperty.value=244;
-
- //prepare the scene
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //we trigger the change and wait for a call on the routinginterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,_,2)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
-
- //check the list of handles. The handle must be in there and have the right type
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_EQ(handlesList[0].handle,handle.handle);
- ASSERT_EQ(handlesList[0].handleType,H_SETSOURCESOUNDPROPERTY);
-
- //read out this property. There is no change, because the ack did not arrive yet.
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceSoundPropertyValue(2,SP_BASS,oldvalue));
- ASSERT_EQ(source.listSoundProperties[0].value,oldvalue);
-
- //lets send the answer and expect a call on the controlInterface
- EXPECT_CALL(pMockControlInterface,cbAckSetSourceSoundProperty(_,E_OK)).Times(1);
- pRoutingReceiver.ackSetSourceSoundProperty(handle,E_OK);
-
- //finally, the new value must be in the database
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceSoundPropertyValue(sourceID,SP_BASS,oldvalue));
- ASSERT_EQ(soundProperty.value,oldvalue);
-
- //and the handle must be destroyed
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(handlesList));
- ASSERT_TRUE(handlesList.empty());
-
- //Now we try again, but the value is unchanged
- ASSERT_EQ(E_NO_CHANGE,pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Handle_s> handlesList;
+ am_Handle_s handle;
+ am_SoundProperty_s soundProperty;
+ uint16_t oldvalue;
+ pCF.createSource(source);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ source.sourceID = 2;
+ source.domainID = 1;
+ soundProperty.type = SP_BASS;
+ soundProperty.value = 244;
+
+ //prepare the scene
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //we trigger the change and wait for a call on the routinginterface
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,_,2)).WillOnce(Return(E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
+
+ //check the list of handles. The handle must be in there and have the right type
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_EQ(handlesList[0].handle, handle.handle);
+ ASSERT_EQ(handlesList[0].handleType, H_SETSOURCESOUNDPROPERTY);
+
+ //read out this property. There is no change, because the ack did not arrive yet.
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(2,SP_BASS,oldvalue));
+ ASSERT_EQ(source.listSoundProperties[0].value, oldvalue);
+
+ //lets send the answer and expect a call on the controlInterface
+ EXPECT_CALL(pMockControlInterface,cbAckSetSourceSoundProperty(_,E_OK)).Times(1);
+ pRoutingReceiver.ackSetSourceSoundProperty(handle, E_OK);
+
+ //finally, the new value must be in the database
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(sourceID,SP_BASS,oldvalue));
+ ASSERT_EQ(soundProperty.value, oldvalue);
+
+ //and the handle must be destroyed
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(handlesList));
+ ASSERT_TRUE(handlesList.empty());
+
+ //Now we try again, but the value is unchanged
+ ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
}
TEST_F(controlInterfaceTest,crossFading)
{
- //todo: implement crossfading test
+ //todo: implement crossfading test
}
int main(int argc, char **argv)
{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
index 5b1bd99..1bc3ce8 100644
--- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
@@ -1,26 +1,26 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file controlInterfaceTest.h
-*
-* \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.
-*
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file controlInterfaceTest.h
+ *
+ * \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.
+ *
+ */
#ifndef ROUTINGINTERFACETEST_H_
#define ROUTINGINTERFACETEST_H_
@@ -41,31 +41,32 @@
#include "../ControlInterfaceBackdoor.h"
#include "../CommonFunctions.h"
+namespace am
+{
-namespace am {
-
-class controlInterfaceTest : public ::testing::Test{
+class controlInterfaceTest: public ::testing::Test
+{
public:
- controlInterfaceTest();
- ~controlInterfaceTest();
- DBusWrapper* pDBusWrapper;
- std::vector<std::string> plistCommandPluginDirs;
- std::vector<std::string> plistRoutingPluginDirs;
- DatabaseHandler pDatabaseHandler;
- RoutingSender pRoutingSender;
- CommandSender pCommandSender;
- MockControlSendInterface pMockControlInterface;
- MockRoutingSendInterface pMockRoutingInterface;
- ControlSender pControlSender;
- RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
- CommandInterfaceBackdoor pCommandInterfaceBackdoor;
- ControlInterfaceBackdoor pControlInterfaceBackdoor;
- DatabaseObserver pDatabaseObserver;
- ControlReceiver pControlReceiver;
- RoutingReceiver pRoutingReceiver;
- CommonFunctions pCF;
- void SetUp();
- void TearDown();
+ controlInterfaceTest();
+ ~controlInterfaceTest();
+ DBusWrapper* pDBusWrapper;
+ std::vector<std::string> plistCommandPluginDirs;
+ std::vector<std::string> plistRoutingPluginDirs;
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockControlSendInterface pMockControlInterface;
+ MockRoutingSendInterface pMockRoutingInterface;
+ ControlSender pControlSender;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlInterfaceBackdoor pControlInterfaceBackdoor;
+ DatabaseObserver pDatabaseObserver;
+ ControlReceiver pControlReceiver;
+ RoutingReceiver pRoutingReceiver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
};
}
diff --git a/AudioManagerDaemon/test/database/databaseTest.cpp b/AudioManagerDaemon/test/database/databaseTest.cpp
index 1a0075c..5d53610 100644
--- a/AudioManagerDaemon/test/database/databaseTest.cpp
+++ b/AudioManagerDaemon/test/database/databaseTest.cpp
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file databasetest.cpp
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file databasetest.cpp
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#include "databaseTest.h"
#include "MockInterfaces.h"
@@ -40,1493 +40,1546 @@ DLT_DECLARE_CONTEXT(DLT_CONTEXT)
//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 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);
-databaseTest::databaseTest()
- :plistRoutingPluginDirs(),
- plistCommandPluginDirs(),
- pDatabaseHandler(std::string(":memory:")),
- pRoutingSender(plistRoutingPluginDirs),
- pCommandSender(plistCommandPluginDirs),
- pMockInterface(),
- pRoutingInterfaceBackdoor(),
- pCommandInterfaceBackdoor(),
- pControlReceiver(&pDatabaseHandler,&pRoutingSender,&pCommandSender),
- pObserver(&pCommandSender,&pRoutingSender)
-{
- pDatabaseHandler.registerObserver(&pObserver);
- pCommandInterfaceBackdoor.injectInterface(&pCommandSender,&pMockInterface);
-}
+routingTest::routingTest() :
+ plistRoutingPluginDirs(), //
+ plistCommandPluginDirs(), //
+ pDatabaseHandler(std::string(":memory:")), //
+ pRoutingSender(plistRoutingPluginDirs), //
+ pCommandSender(plistCommandPluginDirs), //
+ pMockInterface(), //
+ pRoutingInterfaceBackdoor(),//
+ pCommandInterfaceBackdoor(), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pObserver(&pCommandSender, &pRoutingSender)
+{
+ pDatabaseHandler.registerObserver(&pObserver);
+ pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
+}
-databaseTest::~databaseTest()
+routingTest::~routingTest()
{
}
-void databaseTest::createMainConnectionSetup()
+void routingTest::createMainConnectionSetup()
{
- //fill the connection database
- am_Connection_s connection;
- am_Source_s source;
- am_Sink_s sink;
- std::vector<am_Connection_s> connectionList;
+ //fill the connection database
+ am_Connection_s connection;
+ am_Source_s source;
+ am_Sink_s sink;
+ std::vector<am_Connection_s> connectionList;
- //we create 9 sources and sinks:
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
+ //we create 9 sources and sinks:
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
- for (uint16_t i=1;i<10;i++)
- {
- am_sinkID_t forgetSink;
- am_sourceID_t forgetSource;
- am_connectionID_t forgetConnection;
+ for (uint16_t i = 1; i < 10; i++)
+ {
+ am_sinkID_t forgetSink;
+ am_sourceID_t forgetSource;
+ am_connectionID_t forgetConnection;
- pCF.createConnection(connection);
- connection.sinkID=i;
- connection.sourceID=i;
- connectionList.push_back(connection);
+ pCF.createConnection(connection);
+ connection.sinkID = i;
+ connection.sourceID = i;
+ connectionList.push_back(connection);
- 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;
+ 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));
- }
+ 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;
- pCF.connectionList2RoutingList(routingList,connectionList);
+ //fill the route
+ std::vector<am_RoutingElement_s> routingList;
+ pCF.connectionList2RoutingList(routingList, connectionList);
- //create the Route
- am_Route_s route;
- route.route=routingList;
- route.sinkID=1;
- route.sourceID=1;
+ //create the Route
+ am_Route_s route;
+ route.route = routingList;
+ route.sinkID = 1;
+ route.sourceID = 1;
- //create a mainConnection
- am_MainConnection_s mainConnection;
- am_mainConnectionID_t mainConnectionID;
- std::vector<am_MainConnection_s> mainConnectionList;
- pCF.createMainConnection(mainConnection,route);
+ //create a mainConnection
+ am_MainConnection_s mainConnection;
+ am_mainConnectionID_t mainConnectionID;
+ std::vector<am_MainConnection_s> mainConnectionList;
+ pCF.createMainConnection(mainConnection, route);
- //enter mainconnection in database
- EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
- EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))<< "ERROR: database error";
- ASSERT_NE(0,mainConnectionID)<< "ERROR: connectionID zero";
+ //enter mainconnection in database
+ EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
+ EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID))
+ << "ERROR: database error";
+ ASSERT_NE(0,mainConnectionID)
+ << "ERROR: connectionID zero";
- //read out the mainconnections and check if they are equal to the data written.
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(mainConnectionList));
- bool equal=true;
- std::vector<am_MainConnection_s>::iterator listIterator=mainConnectionList.begin();
- for(;listIterator<mainConnectionList.end();++listIterator)
- {
- if(listIterator->connectionID==mainConnectionID) {
- equal= equal && (listIterator->connectionState == mainConnection.connectionState)
- && (listIterator->route.sinkID == mainConnection.route.sinkID)
- && (listIterator->route.sourceID == mainConnection.route.sourceID)
- && (listIterator->delay == mainConnection.delay)
- && (std::equal(listIterator->route.route.begin(),listIterator->route.route.end(),routingList.begin(),equalRoutingElement));
- }
- }
- ASSERT_EQ(true,equal);
+ //read out the mainconnections and check if they are equal to the data written.
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(mainConnectionList));
+ bool equal = true;
+ std::vector<am_MainConnection_s>::iterator listIterator = mainConnectionList.begin();
+ for (; listIterator < mainConnectionList.end(); ++listIterator)
+ {
+ if (listIterator->connectionID == mainConnectionID)
+ {
+ equal = equal && (listIterator->connectionState == mainConnection.connectionState) && (listIterator->route.sinkID == mainConnection.route.sinkID) && (listIterator->route.sourceID == mainConnection.route.sourceID) && (listIterator->delay == mainConnection.delay) && (std::equal(listIterator->route.route.begin(), listIterator->route.route.end(), routingList.begin(), equalRoutingElement));
+ }
+ }
+ ASSERT_EQ(true, equal);
}
-void databaseTest::SetUp()
-{
- DLT_REGISTER_APP("Dtest","AudioManagerDeamon");
- DLT_REGISTER_CONTEXT(DLT_CONTEXT,"Main","Main Context");
- DLT_LOG(DLT_CONTEXT,DLT_LOG_INFO, DLT_STRING("Database Test started "));
+void routingTest::SetUp()
+{
+ DLT_REGISTER_APP("Dtest", "AudioManagerDeamon");
+ DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
+ DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("Database Test started "));
}
-void databaseTest::TearDown()
+void routingTest::TearDown()
{
- DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
+ DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
}
-TEST_F(databaseTest,crossfaders)
+TEST_F(routingTest,crossfaders)
{
- //todo:implement crossfader tests
+ //todo:implement crossfader tests
}
-TEST_F(databaseTest,sourceState)
+TEST_F(routingTest,sourceState)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- std::vector<am_Source_s> listSources;
- pCF.createSource(source);
- source.sourceState=SS_OFF;
-
- //prepare the test
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- //change the source state
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceState(sourceID,SS_ON));
-
- //read out the changed values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(listSources[0].sourceState,SS_ON);
-}
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ std::vector<am_Source_s> listSources;
+ pCF.createSource(source);
+ source.sourceState = SS_OFF;
+
+ //prepare the test
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ //change the source state
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceState(sourceID,SS_ON));
+
+ //read out the changed values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(listSources[0].sourceState, SS_ON);
+}
-TEST_F(databaseTest,sinkVolumeChange)
+TEST_F(routingTest,sinkVolumeChange)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- std::vector<am_Sink_s> listSinks;
- pCF.createSink(sink);
- sink.volume=23;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+ sink.volume = 23;
+
+ //prepare the test
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- //prepare the test
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //change the volume and check the read out
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkVolume(sinkID,34));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(listSinks[0].volume,34);
+ //change the volume and check the read out
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkVolume(sinkID,34));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(listSinks[0].volume, 34);
}
-TEST_F(databaseTest,sourceVolumeChange)
+TEST_F(routingTest,sourceVolumeChange)
{
- am_Source_s source;
- am_sourceID_t sourceID;
- std::vector<am_Source_s> listSources;
- pCF.createSource(source);
- source.volume=23;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ std::vector<am_Source_s> listSources;
+ pCF.createSource(source);
+ source.volume = 23;
- //prepare test
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
+ //prepare test
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- //change the volume and check the read out
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceVolume(sourceID,34));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(listSources[0].volume,34);
+ //change the volume and check the read out
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceVolume(sourceID,34));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(listSources[0].volume, 34);
}
-TEST_F(databaseTest, peekSource)
+TEST_F(routingTest, peekSource)
{
- std::vector<am_Source_s> listSources;
- am_sourceID_t sourceID, source2ID, source3ID;
- am_Source_s source;
- pCF.createSource(source);
-
- //peek a source that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
-
- //make sure it is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_TRUE(listSources.empty());
- ASSERT_EQ(sourceID,100);
-
- //now enter the source with the same name and make sure it does not get a new ID
- source.name="newsource";
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- 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);
-
- //now we peek again. This time, the source exists
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(source.name,source3ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_TRUE(listSources.size()==1);
- ASSERT_EQ(source3ID,source2ID);
-}
-
-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);
-
- //peek a source that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
-
- //peek a second source that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
-
- //make sure they are is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_TRUE(listSources.empty());
- ASSERT_EQ(sourceID,100);
- source.name="newsource";
-
- //now enter the source with the same name than the first peek and make sure it does not get a new ID
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- 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, peekSink)
-{
- std::vector<am_Sink_s> listSinks;
- am_sinkID_t sinkID,sink2ID, sink3ID;
- am_Sink_s sink;
- pCF.createSink(sink);
-
- //peek a sink that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
-
- //make sure it is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_TRUE(listSinks.empty());
- ASSERT_EQ(sinkID,100);
- sink.name="newsink";
-
- //now enter the source with the same name and make sure it does not get a new ID
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- 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);
-
- //now we peek again, this time, the sink exists
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(sink.name,sink3ID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_TRUE(listSinks.size()==1);
- ASSERT_EQ(sink3ID,sink2ID);
-}
-
-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);
-
- //peek a sink that does not exits
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
-
- //peek again
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
- ASSERT_EQ(E_OK,pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
-
- //make sure they are is not in the list
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_TRUE(listSinks.empty());
- ASSERT_EQ(sinkID,100);
- sink.name="newsink";
-
- //now enter the sink with the same name than the first peek and make sure it does not get a new ID
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- 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,changeConnectionTimingInformationCheckMainConnection)
-{
- am_Connection_s connection;
- std::vector<am_Connection_s> connectionList;
- std::vector<am_MainConnectionType_s> mainList;
- pCF.createConnection(connection);
-
- //prepare the test, it is one mainconnection, so we expect one callback
- createMainConnectionSetup();
- EXPECT_CALL(pMockInterface,cbTimingInformationChanged(1,216)).Times(1);
-
- //first get all visible mainconnections and make sure, the delay is set to -1 for the first entry
- ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
- ASSERT_EQ(mainList[0].delay,-1);
-
- //no go through all connections and set the delay time to 24 for each connection
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- std::vector<am_Connection_s>::iterator iteratorConnectionList=connectionList.begin();
- for(;iteratorConnectionList<connectionList.end();++iteratorConnectionList)
- {
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
- }
-
- //we read the result again and expect that the value is now different from -1
- ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(mainList));
- ASSERT_EQ(mainList[0].delay,216);
-}
-
-TEST_F(databaseTest,changeConnectionTimingInformation)
-{
- am_Connection_s connection;
- am_connectionID_t connectionID;
- std::vector<am_Connection_s> connectionList;
- pCF.createConnection(connection);
-
- //enter a connection
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionFinal(connectionID));
-
- //change the timing and check it
- ASSERT_EQ(E_OK,pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListConnections(connectionList));
- ASSERT_TRUE(connectionList[0].delay==24);
-}
-
-TEST_F(databaseTest,getSinkClassOfSink)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass, returnClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=4;
- sinkClass.listClassProperties=classPropertyList;
- pCF.createSink(sink);
- sink.sinkClassID=4;
-
- //prepare test
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //enter a new sinkclass, read out again and check
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,4);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
- ASSERT_EQ(sinkClassList[0].name,returnClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,returnClass.sinkClassID);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest,getSourceClassOfSource)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass, sinkSourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- am_Source_s source;
- am_sourceID_t sourceID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=1;
- sourceClass.listClassProperties=classPropertyList;
- pCF.createSource(source);
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,1);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
- ASSERT_EQ(sourceClassList[0].name,sinkSourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,sinkSourceClass.sourceClassID);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest,removeSourceClass)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=3;
- sourceClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,3);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceClassDB(3));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_TRUE(sourceClassList.empty());
-}
-
-TEST_F(databaseTest,updateSourceClass)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList,changedPropertyList;
- am_SourceClass_s sourceClass, changedClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=0;
- sourceClass.listClassProperties=classPropertyList;
- changedClass=sourceClass;
- changedClass.listClassProperties[1].value=6;
- changedPropertyList=changedClass.listClassProperties;
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- changedClass.sourceClassID=sourceClassID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,100);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceClassInfoDB(changedClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,100);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSourceClass)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=0;
- sourceClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,100);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSourceClassStatic)
-{
- std::vector<am_SourceClass_s> sourceClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SourceClass_s sourceClass;
- am_ClassProperty_s classProperty;
- am_sourceClass_t sourceClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sourceClass.name="test";
- sourceClass.sourceClassID=3;
- sourceClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceClasses(sourceClassList));
- ASSERT_EQ(sourceClassList[0].name,sourceClass.name);
- ASSERT_EQ(sourceClassList[0].sourceClassID,3);
- ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest,removeSinkClass)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=0;
- sinkClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkClassDB(sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_TRUE(sinkClassList.empty());
-}
-
-TEST_F(databaseTest,updateSinkClass)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
- am_SinkClass_s sinkClass, changedClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=0;
- sinkClass.listClassProperties=classPropertyList;
- changedClass=sinkClass;
- changedClass.listClassProperties[1].value=6;
- changedPropertyList=changedClass.listClassProperties;
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- changedClass.sinkClassID=sinkClassID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkClassInfoDB(changedClass));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSinkClass)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=0;
- sinkClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,100);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-TEST_F(databaseTest,enterSinkClassStatic)
-{
- std::vector<am_SinkClass_s> sinkClassList;
- std::vector<am_ClassProperty_s> classPropertyList;
- am_SinkClass_s sinkClass;
- am_ClassProperty_s classProperty;
- am_sinkClass_t sinkClassID;
- classProperty.classProperty=CP_SINK_TYPE;
- classProperty.value=1;
- classPropertyList.push_back(classProperty);
- classProperty.classProperty=CP_SOURCE_TYPE;
- classProperty.value=4;
- classPropertyList.push_back(classProperty);
- sinkClass.name="test";
- sinkClass.sinkClassID=4;
- sinkClass.listClassProperties=classPropertyList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkClasses(sinkClassList));
- ASSERT_EQ(sinkClassList[0].name,sinkClass.name);
- ASSERT_EQ(sinkClassList[0].sinkClassID,4);
- ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
-}
-
-
-TEST_F(databaseTest, changeSystemProperty)
-{
- std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
- am_SystemProperty_s systemProperty;
-
- systemProperty.type=SYP_TEST;
- systemProperty.value=33;
- listSystemProperties.push_back(systemProperty);
- EXPECT_CALL(pMockInterface,cbSystemPropertyChanged(_)).Times(1); //todo: check the exact value here
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
- systemProperty.value=444;
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSystemPropertyDB(systemProperty));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
- ASSERT_EQ(listReturn[0].type,systemProperty.type);
- ASSERT_EQ(listReturn[0].value,systemProperty.value);
-}
-
-TEST_F(databaseTest, systemProperties)
-{
- std::vector<am_SystemProperty_s> listSystemProperties,listReturn;
- am_SystemProperty_s systemProperty;
-
- systemProperty.type=SYP_TEST;
- systemProperty.value=33;
- listSystemProperties.push_back(systemProperty);
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSystemProperties(listSystemProperties));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSystemProperties(listReturn));
- ASSERT_EQ(listReturn[0].type,systemProperty.type);
- ASSERT_EQ(listReturn[0].value,systemProperty.value);
-}
-
-
-TEST_F(databaseTest,enterSourcesCorrect)
-{
- //fill the connection database
- am_Source_s staticSource,firstDynamicSource,secondDynamicSource;
- am_sourceID_t staticSourceID,firstDynamicSourceID,secondDynamicSourceID;
- std::vector<am_Source_s> sourceList;
-
- pCF.createSource(staticSource);
- staticSource.sourceID=4;
- staticSource.name="Static";
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
- ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
-
- 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";
-
- 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";
-
- //now read back and check the returns agains the given values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))<< "ERROR: database error";
- bool equal=true;
-
- std::vector<am_Source_s>::iterator listIterator=sourceList.begin();
- for(;listIterator<sourceList.end();++listIterator)
- {
- if(listIterator->sourceID==staticSourceID)
- {
- equal = equal && pCF.compareSource(listIterator,staticSource);
- }
-
- if(listIterator->sourceID==firstDynamicSourceID)
- {
- equal = equal && pCF.compareSource(listIterator,firstDynamicSource);
- }
-
- if(listIterator->sourceID==secondDynamicSourceID)
- {
- equal = equal && pCF.compareSource(listIterator,secondDynamicSource);
- }
-
- }
- ASSERT_EQ(true,equal);
-}
-
-
-TEST_F(databaseTest, changeSourceMainSoundProperty)
-{
- std::vector<am_Source_s> listSources;
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
- am_MainSoundProperty_s property;
- property.type=MSP_NAVIGATION_OFFSET;
- property.value=33;
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
- EXPECT_CALL(pMockInterface,cbMainSourceSoundPropertyChanged(sourceID,_)).Times(1); //todo: check in detail
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- std::vector<am_MainSoundProperty_s>::iterator listIterator=listSources[0].listMainSoundProperties.begin();
- for(;listIterator<listSources[0].listMainSoundProperties.end();++listIterator)
- {
- if(listIterator->type==property.type)
- {
- ASSERT_EQ(listIterator->value,property.value);
- }
- }
-}
-
-TEST_F(databaseTest, changeSinkMuteState)
-{
- std::vector<am_Sink_s> listSinks;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- am_MuteState_e muteState=MS_MUTED;
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- EXPECT_CALL(pMockInterface,cbSinkMuteStateChanged(sinkID,muteState)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(muteState,listSinks[0].muteState);
-}
-
-TEST_F(databaseTest, changeSinkMainSoundProperty)
-{
- std::vector<am_Sink_s> listSinks;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- am_MainSoundProperty_s property;
- property.type=MSP_NAVIGATION_OFFSET;
- property.value=33;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- EXPECT_CALL(pMockInterface,cbMainSinkSoundPropertyChanged(sinkID,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- std::vector<am_MainSoundProperty_s>::iterator listIterator=listSinks[0].listMainSoundProperties.begin();
- for(;listIterator<listSinks[0].listMainSoundProperties.end();++listIterator)
- {
- if(listIterator->type==property.type)
- {
- ASSERT_EQ(listIterator->value,property.value);
- }
- }
-}
-
-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;
- 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));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(listDomains));
- ASSERT_EQ(newState,listDomains[0].state);
-}
-
-
-TEST_F(databaseTest, changeMainConnectionState)
-{
- std::vector<am_MainConnection_s> listMainConnections;
- createMainConnectionSetup();
- EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(listMainConnections));
- ASSERT_EQ(CS_DISCONNECTING,listMainConnections[0].connectionState);
-}
-
-TEST_F(databaseTest, changeSinkAvailability)
-{
- std::vector<am_Sink_s> listSinks;
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- am_Availability_s availability;
- availability.availability=A_UNKNOWN;
- availability.availabilityReason=AR_TEMPERATURE;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(availability.availability,listSinks[0].available.availability);
- ASSERT_EQ(availability.availabilityReason,listSinks[0].available.availabilityReason);
-}
-
-TEST_F(databaseTest, changeSourceAvailability)
-{
- std::vector<am_Source_s> listSources;
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
- am_Availability_s availability;
- availability.availability=A_UNKNOWN;
- availability.availabilityReason=AR_TEMPERATURE;
- source.visible=true;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources));
- ASSERT_EQ(availability.availability,listSources[0].available.availability);
- ASSERT_EQ(availability.availabilityReason,listSources[0].available.availabilityReason);
-}
-
-
-TEST_F(databaseTest,changeMainConnectionRoute)
-{
- std::vector<am_MainConnection_s> originalList;
- std::vector<am_MainConnection_s> newList;
- createMainConnectionSetup();
- //fill the connection database
- am_Connection_s connection;
- am_Source_s source;
- am_Sink_s sink;
- std::vector<am_Connection_s> connectionList;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
- for (uint16_t i=1;i<10;i++)
- {
- am_sinkID_t forgetSink;
- am_sourceID_t forgetSource;
- am_connectionID_t forgetConnection;
-
- pCF.createConnection(connection);
- connection.sinkID=i+20;
- connection.sourceID=i+20;
- connection.delay=-1;
- connectionList.push_back(connection);
-
- 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";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))<< "ERROR: database error";
-
- }
-
- //fill the route
- std::vector<am_RoutingElement_s> routingList;
- pCF.connectionList2RoutingList(routingList,connectionList);
-
- //create the Route
- am_Route_s route;
- route.route=routingList;
- route.sinkID=2;
- route.sourceID=2;
-
- ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionRouteDB(1,route));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
- ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
-}
-
-TEST_F(databaseTest,changeMainSinkVolume)
-{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_mainVolume_t newVol=20;
- std::vector<am_Sink_s> listSinks;
- pCF.createSink(sink);
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
-
- EXPECT_CALL(pMockInterface,cbVolumeChanged(sinkID,newVol)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(listSinks[0].mainVolume,newVol);
-}
-
-TEST_F(databaseTest,getMainSourceSoundProperties)
-{
- am_Source_s source;
- am_sourceID_t sourceID;
- pCF.createSource(source);
- std::vector<am_MainSoundProperty_s> mainSoundProperties=source.listMainSoundProperties;
- std::vector<am_MainSoundProperty_s> listMainSoundProperties;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
- ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
-}
-
-TEST_F(databaseTest,getMainSinkSoundProperties)
- {
- am_Sink_s sink;
- am_sinkID_t sinkID;
- pCF.createSink(sink);
- std::vector<am_MainSoundProperty_s> mainSoundProperties=sink.listMainSoundProperties;
- std::vector<am_MainSoundProperty_s> listMainSoundProperties;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
- ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
- }
-
-TEST_F(databaseTest,getMainSources)
-{
- am_Source_s source, source1,source2;
- am_sourceID_t sourceID;
- 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;
- std::vector<am_Source_s> listSources;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
- source.sourceID=sourceID;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source1,sourceID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID));
- source2.sourceID=sourceID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSources(listMainSources));
- listSources.push_back(source);
- listSources.push_back(source2);
- std::vector<am_SourceType_s>::iterator listIterator=listMainSources.begin();
- for(;listIterator<listMainSources.end();++listIterator)
- {
- equal = equal && pCF.compareSinkMainSource(listIterator,listSources);
- }
- ASSERT_TRUE(equal);
-}
-
-TEST_F(databaseTest,getMainSinks)
-{
- am_Sink_s sink, sink1,sink2;
- am_sinkID_t sinkID;
- 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;
- std::vector<am_Sink_s> listSinks;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
- sink.sinkID=sinkID;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink1,sinkID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID));
- sink2.sinkID=sinkID;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListMainSinks(listMainSinks));
- listSinks.push_back(sink);
- listSinks.push_back(sink2);
- std::vector<am_SinkType_s>::iterator listIterator=listMainSinks.begin();
- for(;listIterator<listMainSinks.end();++listIterator)
- {
- equal = equal && pCF.compareSinkMainSink(listIterator,listSinks);
- }
- ASSERT_TRUE(equal);
-}
-
-TEST_F(databaseTest,getVisibleMainConnections)
-{
- createMainConnectionSetup();
- am_MainConnection_s mainConnection;
- am_Route_s route;
- pCF.createMainConnection(mainConnection,route);
- std::vector<am_MainConnectionType_s> visibleMainConnection;
- ASSERT_EQ(E_OK,pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
- ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
- ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
- ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
- ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
- ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
-}
-
-TEST_F(databaseTest,getListSourcesOfDomain)
-{
- am_Source_s source, source2;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_sourceID_t sourceID;
- std::vector<am_sourceID_t> sourceList,sourceCheckList;
- 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);
-
-
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))<< "ERROR: database error";
- ASSERT_TRUE(sourceList.empty());
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
-}
-
-TEST_F(databaseTest,getListSinksOfDomain)
-{
- am_Sink_s sink, sink2;
- am_Domain_s domain;
- am_domainID_t domainID;
- am_sinkID_t sinkID;
- std::vector<am_sinkID_t> sinkList,sinkCheckList;
- 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);
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))<< "ERROR: database error";
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))<< "ERROR: database error";
- ASSERT_TRUE(sinkList.empty());
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
-}
-
-TEST_F(databaseTest,getListGatewaysOfDomain)
-{
- am_Gateway_s gateway, gateway2;
- am_gatewayID_t gatewayID;
- am_domainID_t domainID;
- am_Domain_s domain;
- std::vector<am_gatewayID_t> gatewayList,gatewayCheckList;
- 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";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))<< "ERROR: database error";
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))<< "ERROR: database error";
- ASSERT_TRUE(gatewayList.empty());
- ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))<< "ERROR: database error";
- ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
-}
-
-TEST_F(databaseTest,removeDomain)
-{
- am_Domain_s domain;
- am_domainID_t domainID;
- std::vector<am_Domain_s> listDomains;
- 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";
- ASSERT_TRUE(listDomains.empty());
-}
-
-TEST_F(databaseTest,removeGateway)
-{
- am_Gateway_s gateway;
- am_gatewayID_t gatewayID;
- std::vector<am_Gateway_s> listGateways;
- 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";
- ASSERT_TRUE(listGateways.empty());
-}
-
-TEST_F(databaseTest,removeSink)
-{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- std::vector<am_Sink_s> listSinks;
- pCF.createSink(sink);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
- 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";
- ASSERT_TRUE(listSinks.empty());
-}
+ std::vector<am_Source_s> listSources;
+ am_sourceID_t sourceID, source2ID, source3ID;
+ am_Source_s source;
+ pCF.createSource(source);
-TEST_F(databaseTest,removeSource)
-{
- //fill the connection database
- am_Source_s source;
- am_sourceID_t sourceID;
- std::vector<am_Source_s> listSources;
- pCF.createSource(source);
+ //peek a source that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))<< "ERROR: database error";
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))<< "ERROR: database error";
- ASSERT_TRUE(listSources.empty());
-}
+ //make sure it is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID, 100);
-TEST_F(databaseTest, removeMainConnection)
-{
- createMainConnectionSetup();
- EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
- EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))<< "ERROR: database error";
-}
+ //now enter the source with the same name and make sure it does not get a new ID
+ source.name = "newsource";
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ 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,removeNonexistentMainConnectionFail)
-{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))<< "ERROR: database error";
+ //now we peek again. This time, the source exists
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(source.name,source3ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.size()==1);
+ ASSERT_EQ(source3ID, source2ID);
}
-TEST_F(databaseTest,removeNonexistentSource)
+TEST_F(routingTest, peekSourceDouble)
{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))<< "ERROR: database error";
-}
+ 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);
-TEST_F(databaseTest,removeNonexistentSink)
-{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))<< "ERROR: database error";
-}
+ //peek a source that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
+
+ //peek a second source that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource2"),source2ID));
+
+ //make sure they are is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_TRUE(listSources.empty());
+ ASSERT_EQ(sourceID, 100);
+ source.name = "newsource";
-TEST_F(databaseTest,removeNonexistentGateway)
-{
- ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))<< "ERROR: database error";
+ //now enter the source with the same name than the first peek and make sure it does not get a new ID
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ 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(routingTest, peekSink)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_sinkID_t sinkID, sink2ID, sink3ID;
+ am_Sink_s sink;
+ pCF.createSink(sink);
+
+ //peek a sink that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+
+ //make sure it is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID, 100);
+ sink.name = "newsink";
+
+ //now enter the source with the same name and make sure it does not get a new ID
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ 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);
+
+ //now we peek again, this time, the sink exists
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(sink.name,sink3ID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.size()==1);
+ ASSERT_EQ(sink3ID, sink2ID);
+}
+
+TEST_F(routingTest, 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);
+
+ //peek a sink that does not exits
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
+
+ //peek again
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(0);
+ ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("nextsink"),sink2ID));
+
+ //make sure they are is not in the list
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_TRUE(listSinks.empty());
+ ASSERT_EQ(sinkID, 100);
+ sink.name = "newsink";
+
+ //now enter the sink with the same name than the first peek and make sure it does not get a new ID
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ 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(routingTest,changeConnectionTimingInformationCheckMainConnection)
+{
+ am_Connection_s connection;
+ std::vector<am_Connection_s> connectionList;
+ std::vector<am_MainConnectionType_s> mainList;
+ pCF.createConnection(connection);
+
+ //prepare the test, it is one mainconnection, so we expect one callback
+ createMainConnectionSetup();
+ EXPECT_CALL(pMockInterface,cbTimingInformationChanged(1,216)).Times(1);
+
+ //first get all visible mainconnections and make sure, the delay is set to -1 for the first entry
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
+ ASSERT_EQ(mainList[0].delay, -1);
+
+ //no go through all connections and set the delay time to 24 for each connection
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ std::vector<am_Connection_s>::iterator iteratorConnectionList = connectionList.begin();
+ for (; iteratorConnectionList < connectionList.end(); ++iteratorConnectionList)
+ {
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->sinkID,24));
+ }
+
+ //we read the result again and expect that the value is now different from -1
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(mainList));
+ ASSERT_EQ(mainList[0].delay, 216);
+}
+
+TEST_F(routingTest,changeConnectionTimingInformation)
+{
+ am_Connection_s connection;
+ am_connectionID_t connectionID;
+ std::vector<am_Connection_s> connectionList;
+ pCF.createConnection(connection);
+
+ //enter a connection
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
+
+ //change the timing and check it
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(connectionID,24));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListConnections(connectionList));
+ ASSERT_TRUE(connectionList[0].delay==24);
+}
+
+TEST_F(routingTest,getSinkClassOfSink)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass, returnClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 4;
+ sinkClass.listClassProperties = classPropertyList;
+ pCF.createSink(sink);
+ sink.sinkClassID = 4;
+
+ //prepare test
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //enter a new sinkclass, read out again and check
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkClassInfoDB(sinkID,returnClass));
+ ASSERT_EQ(sinkClassList[0].name, returnClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, returnClass.sinkClassID);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),returnClass.listClassProperties.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,getSourceClassOfSource)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass, sinkSourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 1;
+ sourceClass.listClassProperties = classPropertyList;
+ pCF.createSource(source);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 1);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceClassInfoDB(sourceID,sinkSourceClass));
+ ASSERT_EQ(sourceClassList[0].name, sinkSourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, sinkSourceClass.sourceClassID);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),sinkSourceClass.listClassProperties.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,removeSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 3;
+ sourceClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.removeSourceClassDB(3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_TRUE(sourceClassList.empty());
+}
+
+TEST_F(routingTest,updateSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
+ am_SourceClass_s sourceClass, changedClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 0;
+ sourceClass.listClassProperties = classPropertyList;
+ changedClass = sourceClass;
+ changedClass.listClassProperties[1].value = 6;
+ changedPropertyList = changedClass.listClassProperties;
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ changedClass.sourceClassID = sourceClassID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceClassInfoDB(changedClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSourceClass)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 0;
+ sourceClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 100);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSourceClassStatic)
+{
+ std::vector<am_SourceClass_s> sourceClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SourceClass_s sourceClass;
+ am_ClassProperty_s classProperty;
+ am_sourceClass_t sourceClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sourceClass.name = "test";
+ sourceClass.sourceClassID = 3;
+ sourceClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourceClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
+ ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
+ ASSERT_EQ(sourceClassList[0].sourceClassID, 3);
+ ASSERT_TRUE(std::equal(sourceClassList[0].listClassProperties.begin(),sourceClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,removeSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 0;
+ sinkClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.removeSinkClassDB(sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_TRUE(sinkClassList.empty());
+}
+
+TEST_F(routingTest,updateSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList, changedPropertyList;
+ am_SinkClass_s sinkClass, changedClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 0;
+ sinkClass.listClassProperties = classPropertyList;
+ changedClass = sinkClass;
+ changedClass.listClassProperties[1].value = 6;
+ changedPropertyList = changedClass.listClassProperties;
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ changedClass.sinkClassID = sinkClassID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkClassInfoDB(changedClass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),changedPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSinkClass)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 0;
+ sinkClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 100);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest,enterSinkClassStatic)
+{
+ std::vector<am_SinkClass_s> sinkClassList;
+ std::vector<am_ClassProperty_s> classPropertyList;
+ am_SinkClass_s sinkClass;
+ am_ClassProperty_s classProperty;
+ am_sinkClass_t sinkClassID;
+ classProperty.classProperty = CP_SINK_TYPE;
+ classProperty.value = 1;
+ classPropertyList.push_back(classProperty);
+ classProperty.classProperty = CP_SOURCE_TYPE;
+ classProperty.value = 4;
+ classPropertyList.push_back(classProperty);
+ sinkClass.name = "test";
+ sinkClass.sinkClassID = 4;
+ sinkClass.listClassProperties = classPropertyList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinkClassesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
+ ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
+ ASSERT_EQ(sinkClassList[0].sinkClassID, 4);
+ ASSERT_TRUE(std::equal(sinkClassList[0].listClassProperties.begin(),sinkClassList[0].listClassProperties.end(),classPropertyList.begin(),equalClassProperties));
+}
+
+TEST_F(routingTest, changeSystemProperty)
+{
+ std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
+ am_SystemProperty_s systemProperty;
+
+ systemProperty.type = SYP_TEST;
+ systemProperty.value = 33;
+ listSystemProperties.push_back(systemProperty);
+ EXPECT_CALL(pMockInterface,cbSystemPropertyChanged(_)).Times(1); //todo: check the exact value here
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
+ systemProperty.value = 444;
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSystemPropertyDB(systemProperty));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
+ ASSERT_EQ(listReturn[0].type, systemProperty.type);
+ ASSERT_EQ(listReturn[0].value, systemProperty.value);
+}
+
+TEST_F(routingTest, systemProperties)
+{
+ std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
+ am_SystemProperty_s systemProperty;
+
+ systemProperty.type = SYP_TEST;
+ systemProperty.value = 33;
+ listSystemProperties.push_back(systemProperty);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSystemProperties(listReturn));
+ ASSERT_EQ(listReturn[0].type, systemProperty.type);
+ ASSERT_EQ(listReturn[0].value, systemProperty.value);
+}
+
+TEST_F(routingTest,enterSourcesCorrect)
+{
+ //fill the connection database
+ am_Source_s staticSource, firstDynamicSource, secondDynamicSource;
+ am_sourceID_t staticSourceID, firstDynamicSourceID, secondDynamicSourceID;
+ std::vector<am_Source_s> sourceList;
+
+ pCF.createSource(staticSource);
+ staticSource.sourceID = 4;
+ staticSource.name = "Static";
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSource.sourceID,staticSourceID)
+ << "ERROR: ID not the one given in staticSource";
+
+ 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";
+
+ 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";
+
+ //now read back and check the returns agains the given values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(sourceList))
+ << "ERROR: database error";
+ bool equal = true;
+
+ std::vector<am_Source_s>::iterator listIterator = sourceList.begin();
+ for (; listIterator < sourceList.end(); ++listIterator)
+ {
+ if (listIterator->sourceID == staticSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator, staticSource);
+ }
+
+ if (listIterator->sourceID == firstDynamicSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator, firstDynamicSource);
+ }
+
+ if (listIterator->sourceID == secondDynamicSourceID)
+ {
+ equal = equal && pCF.compareSource(listIterator, secondDynamicSource);
+ }
+
+ }
+ ASSERT_EQ(true, equal);
+}
+
+TEST_F(routingTest, changeSourceMainSoundProperty)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_MainSoundProperty_s property;
+ property.type = MSP_NAVIGATION_OFFSET;
+ property.value = 33;
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ EXPECT_CALL(pMockInterface,cbMainSourceSoundPropertyChanged(sourceID,_)).Times(1); //todo: check in detail
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ std::vector<am_MainSoundProperty_s>::iterator listIterator = listSources[0].listMainSoundProperties.begin();
+ for (; listIterator < listSources[0].listMainSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ {
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+ }
+}
+
+TEST_F(routingTest, changeSinkMuteState)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_MuteState_e muteState = MS_MUTED;
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ EXPECT_CALL(pMockInterface,cbSinkMuteStateChanged(sinkID,muteState)).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(muteState, listSinks[0].muteState);
+}
+
+TEST_F(routingTest, changeSinkMainSoundProperty)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_MainSoundProperty_s property;
+ property.type = MSP_NAVIGATION_OFFSET;
+ property.value = 33;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ EXPECT_CALL(pMockInterface,cbMainSinkSoundPropertyChanged(sinkID,_)).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ std::vector<am_MainSoundProperty_s>::iterator listIterator = listSinks[0].listMainSoundProperties.begin();
+ for (; listIterator < listSinks[0].listMainSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ {
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+ }
+}
+
+TEST_F(routingTest, 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(routingTest, 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(routingTest, changeDomainState)
+{
+ std::vector<am_Domain_s> listDomains;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ 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));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
+ ASSERT_EQ(newState, listDomains[0].state);
+}
+
+TEST_F(routingTest, changeMainConnectionState)
+{
+ std::vector<am_MainConnection_s> listMainConnections;
+ createMainConnectionSetup();
+ EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING))
+ << "ERROR: database error";ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(listMainConnections));
+ ASSERT_EQ(CS_DISCONNECTING, listMainConnections[0].connectionState);
+}
+
+TEST_F(routingTest, changeSinkAvailability)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_Availability_s availability;
+ availability.availability = A_UNKNOWN;
+ availability.availabilityReason = AR_TEMPERATURE;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(availability.availability, listSinks[0].available.availability);
+ ASSERT_EQ(availability.availabilityReason, listSinks[0].available.availabilityReason);
+}
+
+TEST_F(routingTest, changeSourceAvailability)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_Availability_s availability;
+ availability.availability = A_UNKNOWN;
+ availability.availabilityReason = AR_TEMPERATURE;
+ source.visible = true;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+ ASSERT_EQ(availability.availability, listSources[0].available.availability);
+ ASSERT_EQ(availability.availabilityReason, listSources[0].available.availabilityReason);
+}
+
+TEST_F(routingTest,changeMainConnectionRoute)
+{
+ std::vector<am_MainConnection_s> originalList;
+ std::vector<am_MainConnection_s> newList;
+ createMainConnectionSetup();
+ //fill the connection database
+ am_Connection_s connection;
+ am_Source_s source;
+ am_Sink_s sink;
+ std::vector<am_Connection_s> connectionList;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(9);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(9);
+ for (uint16_t i = 1; i < 10; i++)
+ {
+ am_sinkID_t forgetSink;
+ am_sourceID_t forgetSource;
+ am_connectionID_t forgetConnection;
+
+ pCF.createConnection(connection);
+ connection.sinkID = i + 20;
+ connection.sourceID = i + 20;
+ connection.delay = -1;
+ connectionList.push_back(connection);
+
+ 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";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,forgetConnection))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(originalList))
+ << "ERROR: database error";
+
+ }
+
+ //fill the route
+ std::vector<am_RoutingElement_s> routingList;
+ pCF.connectionList2RoutingList(routingList, connectionList);
+
+ //create the Route
+ am_Route_s route;
+ route.route = routingList;
+ route.sinkID = 2;
+ route.sourceID = 2;
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainConnectionRouteDB(1,route));
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListMainConnections(newList))
+ << "ERROR: database error";ASSERT_TRUE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),routingList.begin(),equalRoutingElement));
+ ASSERT_FALSE(std::equal(newList[0].route.route.begin(),newList[0].route.route.end(),originalList[0].route.route.begin(),equalRoutingElement));
+}
+
+TEST_F(routingTest,changeMainSinkVolume)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ am_mainVolume_t newVol = 20;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ EXPECT_CALL(pMockInterface,cbVolumeChanged(sinkID,newVol)).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(listSinks[0].mainVolume, newVol);
+}
+
+TEST_F(routingTest,getMainSourceSoundProperties)
+{
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ std::vector<am_MainSoundProperty_s> mainSoundProperties = source.listMainSoundProperties;
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
+ ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
+}
+
+TEST_F(routingTest,getMainSinkSoundProperties)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ std::vector<am_MainSoundProperty_s> mainSoundProperties = sink.listMainSoundProperties;
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
+ ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
+}
+
+TEST_F(routingTest,getMainSources)
+{
+ am_Source_s source, source1, source2;
+ am_sourceID_t sourceID;
+ 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;
+ std::vector<am_Source_s> listSources;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ source.sourceID = sourceID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source1,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source2,sourceID));
+ source2.sourceID = sourceID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSources(listMainSources));
+ listSources.push_back(source);
+ listSources.push_back(source2);
+ std::vector<am_SourceType_s>::iterator listIterator = listMainSources.begin();
+ for (; listIterator < listMainSources.end(); ++listIterator)
+ {
+ equal = equal && pCF.compareSinkMainSource(listIterator, listSources);
+ }
+ ASSERT_TRUE(equal);
+}
+
+TEST_F(routingTest,getMainSinks)
+{
+ am_Sink_s sink, sink1, sink2;
+ am_sinkID_t sinkID;
+ 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;
+ std::vector<am_Sink_s> listSinks;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ sink.sinkID = sinkID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink1,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink2,sinkID));
+ sink2.sinkID = sinkID;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinks(listMainSinks));
+ listSinks.push_back(sink);
+ listSinks.push_back(sink2);
+ std::vector<am_SinkType_s>::iterator listIterator = listMainSinks.begin();
+ for (; listIterator < listMainSinks.end(); ++listIterator)
+ {
+ equal = equal && pCF.compareSinkMainSink(listIterator, listSinks);
+ }
+ ASSERT_TRUE(equal);
+}
+
+TEST_F(routingTest,getVisibleMainConnections)
+{
+ createMainConnectionSetup();
+ am_MainConnection_s mainConnection;
+ am_Route_s route;
+ pCF.createMainConnection(mainConnection, route);
+ std::vector<am_MainConnectionType_s> visibleMainConnection;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(visibleMainConnection));
+ ASSERT_TRUE(1==visibleMainConnection[0].mainConnectionID);
+ ASSERT_TRUE(mainConnection.connectionState==visibleMainConnection[0].connectionState);
+ ASSERT_TRUE(mainConnection.delay==visibleMainConnection[0].delay);
+ ASSERT_TRUE(1==visibleMainConnection[0].sinkID);
+ ASSERT_TRUE(1==visibleMainConnection[0].sourceID);
+}
+
+TEST_F(routingTest,getListSourcesOfDomain)
+{
+ am_Source_s source, source2;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_sourceID_t sourceID;
+ std::vector<am_sourceID_t> sourceList, sourceCheckList;
+ 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);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source2,sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSourcesOfDomain(2,sourceList))
+ << "ERROR: database error";ASSERT_TRUE(sourceList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSourcesOfDomain(1,sourceList))
+ << "ERROR: database error";
+ ASSERT_TRUE(std::equal(sourceList.begin(),sourceList.end(),sourceCheckList.begin()) && !sourceList.empty());
+}
+
+TEST_F(routingTest,getListSinksOfDomain)
+{
+ am_Sink_s sink, sink2;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ am_sinkID_t sinkID;
+ std::vector<am_sinkID_t> sinkList, sinkCheckList;
+ 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);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink2,sinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListSinksOfDomain(2,sinkList))
+ << "ERROR: database error";ASSERT_TRUE(sinkList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinksOfDomain(1,sinkList))
+ << "ERROR: database error";
+ ASSERT_TRUE(std::equal(sinkList.begin(),sinkList.end(),sinkCheckList.begin()) && !sinkList.empty());
+}
+
+TEST_F(routingTest,getListGatewaysOfDomain)
+{
+ am_Gateway_s gateway, gateway2;
+ am_gatewayID_t gatewayID;
+ am_domainID_t domainID;
+ am_Domain_s domain;
+ std::vector<am_gatewayID_t> gatewayList, gatewayCheckList;
+ 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";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.getListGatewaysOfDomain(2,gatewayList))
+ << "ERROR: database error";ASSERT_TRUE(gatewayList.empty());
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListGatewaysOfDomain(1,gatewayList))
+ << "ERROR: database error";
+ ASSERT_TRUE(std::equal(gatewayList.begin(),gatewayList.end(),gatewayCheckList.begin()) && !gatewayList.empty());
+}
+
+TEST_F(routingTest,removeDomain)
+{
+ am_Domain_s domain;
+ am_domainID_t domainID;
+ std::vector<am_Domain_s> listDomains;
+ 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";
+ ASSERT_TRUE(listDomains.empty());
+}
+
+TEST_F(routingTest,removeGateway)
+{
+ am_Gateway_s gateway;
+ am_gatewayID_t gatewayID;
+ std::vector<am_Gateway_s> listGateways;
+ 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";
+ ASSERT_TRUE(listGateways.empty());
+}
+
+TEST_F(routingTest,removeSink)
+{
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ std::vector<am_Sink_s> listSinks;
+ pCF.createSink(sink);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
+ 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";
+ ASSERT_TRUE(listSinks.empty());
+}
+
+TEST_F(routingTest,removeSource)
+{
+ //fill the connection database
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ std::vector<am_Source_s> listSources;
+ pCF.createSource(source);
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSources(listSources))
+ << "ERROR: database error";
+ ASSERT_TRUE(listSources.empty());
+}
+
+TEST_F(routingTest, removeMainConnection)
+{
+ createMainConnectionSetup();
+ EXPECT_CALL(pMockInterface,cbNumberOfMainConnectionsChanged()).Times(1);
+ EXPECT_CALL(pMockInterface,cbMainConnectionStateChanged(_,_)).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(1))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,removeNonexistentMainConnectionFail)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeMainConnectionDB(34))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,removeNonexistentSource)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSourceDB(3))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,removeNonexistentSink)
+{
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeSinkDB(2))
+ << "ERROR: database error";
}
-TEST_F(databaseTest,registerGatewayCorrect)
+TEST_F(routingTest,removeNonexistentGateway)
{
- //initialize gateway
- std::vector<am_Gateway_s> returnList;
- am_Gateway_s gateway, gateway1, gateway2;
- am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
-
- 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";
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
- ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
-
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
- ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
-
- //now check if we read out the correct values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
- bool equal=true;
- std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
-
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->gatewayID==gatewayID)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway);
- }
-
- if(listIterator->gatewayID==gatewayID1)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway1);
- }
-
- if(listIterator->gatewayID==gatewayID2)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway2);
- }
- }
-
- ASSERT_EQ(true,equal);
+ ASSERT_EQ(E_NON_EXISTENT,pDatabaseHandler.removeGatewayDB(12))
+ << "ERROR: database error";
}
-TEST_F(databaseTest,getGatewayInfo)
+TEST_F(routingTest,registerGatewayCorrect)
{
- //initialize gateway
- std::vector<am_Gateway_s> returnList;
- am_Gateway_s gateway, gateway1, gateway2;
- am_gatewayID_t gatewayID=0,gatewayID1=0,gatewayID2=0;
-
- pCF.createGateway(gateway);
- pCF.createGateway(gateway1);
- gateway1.gatewayID=20;
- pCF.createGateway(gateway2);
+ //initialize gateway
+ std::vector<am_Gateway_s> returnList;
+ am_Gateway_s gateway, gateway1, gateway2;
+ am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))<< "ERROR: database error";
- ASSERT_EQ(100,gatewayID)<< "ERROR: domainID zero";
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID = 20;
+ pCF.createGateway(gateway2);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))<< "ERROR: database error";
- ASSERT_EQ(gateway1.gatewayID,gatewayID1)<< "ERROR: domainID zero";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(100,gatewayID)
+ << "ERROR: domainID zero";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))<< "ERROR: database error";
- ASSERT_EQ(101,gatewayID2)<< "ERROR: domainID zero";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
+ << "ERROR: database error";
+ ASSERT_EQ(gateway1.gatewayID,gatewayID1)
+ << "ERROR: domainID zero";
- //now check if we read out the correct values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListGateways(returnList));
- bool equal=true;
- std::vector<am_Gateway_s>::iterator listIterator=returnList.begin();
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
+ << "ERROR: database error";
+ ASSERT_EQ(101,gatewayID2)
+ << "ERROR: domainID zero";
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->gatewayID==gatewayID)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway);
- }
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
+ bool equal = true;
+ std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
- if(listIterator->gatewayID==gatewayID1)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway1);
- }
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->gatewayID == gatewayID)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway);
+ }
- if(listIterator->gatewayID==gatewayID2)
- {
- equal= equal && pCF.compareGateway(listIterator,gateway2);
- }
- }
+ if (listIterator->gatewayID == gatewayID1)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway1);
+ }
- ASSERT_EQ(true,equal);
-
- am_Gateway_s gatewayInfo;
- ASSERT_EQ(E_OK,pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
- ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
+ if (listIterator->gatewayID == gatewayID2)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway2);
+ }
+ }
+ ASSERT_EQ(true, equal);
}
-TEST_F(databaseTest,enterSinkThatAlreadyExistFail)
+TEST_F(routingTest,getGatewayInfo)
{
- //fill the connection database
- am_Sink_s staticSink,SecondSink;
- am_sinkID_t staticSinkID,SecondSinkID;
+ //initialize gateway
+ std::vector<am_Gateway_s> returnList;
+ am_Gateway_s gateway, gateway1, gateway2;
+ am_gatewayID_t gatewayID = 0, gatewayID1 = 0, gatewayID2 = 0;
- pCF.createSink(staticSink);
- staticSink.sinkID=43;
- staticSink.name="Static";
+ pCF.createGateway(gateway);
+ pCF.createGateway(gateway1);
+ gateway1.gatewayID = 20;
+ pCF.createGateway(gateway2);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
- ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
+ << "ERROR: database error";
+ ASSERT_EQ(100,gatewayID)
+ << "ERROR: domainID zero";
- pCF.createSink(SecondSink);
- SecondSink.sinkID=43;
- SecondSink.name="SecondSink";
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1))
+ << "ERROR: database error";
+ ASSERT_EQ(gateway1.gatewayID,gatewayID1)
+ << "ERROR: domainID zero";
- ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))<< "ERROR: database error";
-}
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2))
+ << "ERROR: database error";
+ ASSERT_EQ(101,gatewayID2)
+ << "ERROR: domainID zero";
-TEST_F(databaseTest,enterSourcesThatAlreadyExistFail)
-{
- //fill the connection database
- am_Source_s staticSource,SecondSource;
- am_sourceID_t staticSourceID,SecondSourceID;
- pCF.createSource(staticSource);
- staticSource.sourceID=4;
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListGateways(returnList));
+ bool equal = true;
+ std::vector<am_Gateway_s>::iterator listIterator = returnList.begin();
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))<< "ERROR: database error";
- ASSERT_EQ(staticSource.sourceID,staticSourceID)<< "ERROR: ID not the one given in staticSource";
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->gatewayID == gatewayID)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway);
+ }
- pCF.createSource(SecondSource);
- SecondSource.sourceID=4;
+ if (listIterator->gatewayID == gatewayID1)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway1);
+ }
+
+ if (listIterator->gatewayID == gatewayID2)
+ {
+ equal = equal && pCF.compareGateway(listIterator, gateway2);
+ }
+ }
+
+ ASSERT_EQ(true, equal);
+
+ am_Gateway_s gatewayInfo;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getGatewayInfoDB(20,gatewayInfo));
+ ASSERT_TRUE(pCF.compareGateway1(gateway1,gatewayInfo));
+
+}
+
+TEST_F(routingTest,enterSinkThatAlreadyExistFail)
+{
+ //fill the connection database
+ am_Sink_s staticSink, SecondSink;
+ am_sinkID_t staticSinkID, SecondSinkID;
- ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))<< "ERROR: database error";
-}
+ pCF.createSink(staticSink);
+ staticSink.sinkID = 43;
+ staticSink.name = "Static";
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSink.sinkID,staticSinkID)
+ << "ERROR: ID not the one given in staticSink";
-TEST_F(databaseTest,registerDomainCorrect)
-{
- //initialize domain
- std::vector<am_Domain_s> returnList;
- am_Domain_s domain;
- am_domainID_t domainID=0;
- pCF.createDomain(domain);
+ pCF.createSink(SecondSink);
+ SecondSink.sinkID = 43;
+ SecondSink.name = "SecondSink";
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))<< "ERROR: database error";
- ASSERT_NE(0,domainID)<< "ERROR: domainID zero";
+ ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSinkDB(SecondSink,SecondSinkID))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,enterSourcesThatAlreadyExistFail)
+{
+ //fill the connection database
+ am_Source_s staticSource, SecondSource;
+ am_sourceID_t staticSourceID, SecondSourceID;
+ pCF.createSource(staticSource);
+ staticSource.sourceID = 4;
- //now check if we read out the correct values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListDomains(returnList));
- bool equal=true;
- std::vector<am_Domain_s>::iterator listIterator=returnList.begin();
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->domainID==domainID) {
- equal= equal && (listIterator->name.compare(domain.name)==0)
- && (listIterator->busname.compare(domain.busname)==0)
- && (listIterator->complete == domain.complete)
- && (listIterator->early == domain.early)
- && (listIterator->state == domain.state);
- }
- }
- ASSERT_EQ(true,equal);
-}
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(1);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSource.sourceID,staticSourceID)
+ << "ERROR: ID not the one given in staticSource";
-TEST_F(databaseTest,registerConnectionCorrect)
-{
- am_Connection_s connection;
- am_connectionID_t connectionID;
- std::vector<am_Connection_s> returnList;
- pCF.createConnection(connection);
+ pCF.createSource(SecondSource);
+ SecondSource.sourceID = 4;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))<< "ERROR: database error";;
- ASSERT_NE(0,connectionID)<< "ERROR: connectionID zero";
+ ASSERT_EQ(E_ALREADY_EXISTS,pDatabaseHandler.enterSourceDB(SecondSource,SecondSourceID))
+ << "ERROR: database error";
+}
+
+TEST_F(routingTest,registerDomainCorrect)
+{
+ //initialize domain
+ std::vector<am_Domain_s> returnList;
+ am_Domain_s domain;
+ am_domainID_t domainID = 0;
+ pCF.createDomain(domain);
+
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
+ << "ERROR: database error";
+ ASSERT_NE(0,domainID)
+ << "ERROR: domainID zero";
+
+ //now check if we read out the correct values
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(returnList));
+ bool equal = true;
+ std::vector<am_Domain_s>::iterator listIterator = returnList.begin();
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->domainID == domainID)
+ {
+ equal = equal && (listIterator->name.compare(domain.name) == 0) && (listIterator->busname.compare(domain.busname) == 0) && (listIterator->complete == domain.complete) && (listIterator->early == domain.early) && (listIterator->state == domain.state);
+ }
+ }
+ ASSERT_EQ(true, equal);
+}
+
+TEST_F(routingTest,registerConnectionCorrect)
+{
+ am_Connection_s connection;
+ am_connectionID_t connectionID;
+ std::vector<am_Connection_s> returnList;
+ pCF.createConnection(connection);
- //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();
- for(;listIterator<returnList.end();++listIterator)
- {
- if(listIterator->connectionID==connectionID) {
- equal= (listIterator->sourceID == connection.sourceID)
- && (listIterator->sinkID == connection.sinkID)
- && (listIterator->delay == connection.delay)
- && (listIterator->connectionFormat = connection.connectionFormat);
- }
- }
- ASSERT_EQ(true,equal);
-}
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))
+ << "ERROR: database error";;
+ ASSERT_NE(0,connectionID)
+ << "ERROR: connectionID zero";
-TEST_F(databaseTest,enterMainConnectionCorrect)
-{
- createMainConnectionSetup();
+ //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();
+ for (; listIterator < returnList.end(); ++listIterator)
+ {
+ if (listIterator->connectionID == connectionID)
+ {
+ equal = (listIterator->sourceID == connection.sourceID) && (listIterator->sinkID == connection.sinkID) && (listIterator->delay == connection.delay) && (listIterator->connectionFormat = connection.connectionFormat);
+ }
+ }
+ ASSERT_EQ(true, equal);
}
-TEST_F(databaseTest,enterSinksCorrect)
-{
- //fill the connection database
- am_Sink_s staticSink,firstDynamicSink,secondDynamicSink;
- am_sinkID_t staticSinkID,firstDynamicSinkID,secondDynamicSinkID;
- std::vector<am_Sink_s> sinkList;
-
- pCF.createSink(staticSink);
- staticSink.sinkID=4;
-
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))<< "ERROR: database error";
- ASSERT_EQ(staticSink.sinkID,staticSinkID)<< "ERROR: ID not the one given in staticSink";
-
- 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";
-
- 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";
-
- //now read back and check the returns agains the given values
- ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))<< "ERROR: database error";
- bool equal=true;
-
- std::vector<am_Sink_s>::iterator listIterator=sinkList.begin();
- for(;listIterator<sinkList.end();++listIterator)
- {
- if(listIterator->sinkID==staticSinkID)
- {
- equal = equal && pCF.compareSink(listIterator,staticSink);
- }
-
- if(listIterator->sinkID==firstDynamicSinkID)
- {
- equal = equal && pCF.compareSink(listIterator,firstDynamicSink);
- }
-
- if(listIterator->sinkID==secondDynamicSinkID)
- {
- equal = equal && pCF.compareSink(listIterator,secondDynamicSink);
- }
- }
- ASSERT_EQ(true,equal);
+TEST_F(routingTest,enterMainConnectionCorrect)
+{
+ createMainConnectionSetup();
+}
+
+TEST_F(routingTest,enterSinksCorrect)
+{
+ //fill the connection database
+ am_Sink_s staticSink, firstDynamicSink, secondDynamicSink;
+ am_sinkID_t staticSinkID, firstDynamicSinkID, secondDynamicSinkID;
+ std::vector<am_Sink_s> sinkList;
+
+ pCF.createSink(staticSink);
+ staticSink.sinkID = 4;
+
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
+ ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
+ << "ERROR: database error";
+ ASSERT_EQ(staticSink.sinkID,staticSinkID)
+ << "ERROR: ID not the one given in staticSink";
+
+ 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";
+
+ 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";
+
+ //now read back and check the returns agains the given values
+ ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(sinkList))
+ << "ERROR: database error";
+ bool equal = true;
+
+ std::vector<am_Sink_s>::iterator listIterator = sinkList.begin();
+ for (; listIterator < sinkList.end(); ++listIterator)
+ {
+ if (listIterator->sinkID == staticSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator, staticSink);
+ }
+
+ if (listIterator->sinkID == firstDynamicSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator, firstDynamicSink);
+ }
+
+ if (listIterator->sinkID == secondDynamicSinkID)
+ {
+ equal = equal && pCF.compareSink(listIterator, secondDynamicSink);
+ }
+ }
+ ASSERT_EQ(true, equal);
}
//Commented out - gives always a warning..
@@ -1539,18 +1592,9 @@ TEST_F(databaseTest,enterSinksCorrect)
// ASSERT_DEATH(pDatabaseHandler.enterDomainDB(domain,domainID),"Assertion `domainData.domainID==0'");
//}
-
int main(int argc, char **argv)
{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/test/database/databaseTest.h b/AudioManagerDaemon/test/database/databaseTest.h
index 4098dc0..0d46b68 100644
--- a/AudioManagerDaemon/test/database/databaseTest.h
+++ b/AudioManagerDaemon/test/database/databaseTest.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file databasetest.h
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file databasetest.h
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef DATABASETEST_H_
#define DATABASETEST_H_
@@ -45,28 +45,29 @@
#include "../CommandInterfaceBackdoor.h"
#include "../CommonFunctions.h"
-namespace am {
+namespace am
+{
-
-class databaseTest : public ::testing::Test {
+class routingTest: public ::testing::Test
+{
public:
- databaseTest();
- ~databaseTest();
- std::vector<std::string> plistRoutingPluginDirs;
- std::vector<std::string> plistCommandPluginDirs;
- DatabaseHandler pDatabaseHandler;
- RoutingSender pRoutingSender;
- CommandSender pCommandSender;
- MockCommandSendInterface pMockInterface;
- RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
- CommandInterfaceBackdoor pCommandInterfaceBackdoor;
- ControlReceiver pControlReceiver;
- DatabaseObserver pObserver;
- CommonFunctions pCF;
- void SetUp();
- void TearDown();
+ routingTest();
+ ~routingTest();
+ std::vector<std::string> plistRoutingPluginDirs;
+ std::vector<std::string> plistCommandPluginDirs;
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockCommandSendInterface pMockInterface;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlReceiver pControlReceiver;
+ DatabaseObserver pObserver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
- void createMainConnectionSetup();
+ void createMainConnectionSetup();
};
}
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
index 8a66d57..6ebd99d 100644
--- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file routingInterfaces.cpp
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file routingInterfaces.cpp
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#include "routingInterfaceTest.h"
@@ -30,22 +30,22 @@ using namespace testing;
DLT_DECLARE_CONTEXT(DLT_CONTEXT);
-routingInterfaceTest::routingInterfaceTest()
- :plistRoutingPluginDirs(),
- plistCommandPluginDirs(),
- pDatabaseHandler(std::string(":memory:")),
- pRoutingSender(plistRoutingPluginDirs),
- pCommandSender(plistCommandPluginDirs),
- pMockInterface(),
- pRoutingInterfaceBackdoor(),
- pCommandInterfaceBackdoor(),
- pControlReceiver(&pDatabaseHandler,&pRoutingSender,&pCommandSender),
- pObserver(&pCommandSender,&pRoutingSender)
+routingInterfaceTest::routingInterfaceTest() :
+ plistRoutingPluginDirs(), //
+ plistCommandPluginDirs(), //
+ pDatabaseHandler(std::string(":memory:")), //
+ pRoutingSender(plistRoutingPluginDirs), //
+ pCommandSender(plistCommandPluginDirs), //
+ pMockInterface(), //
+ pRoutingInterfaceBackdoor(), //
+ pCommandInterfaceBackdoor(), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pObserver(&pCommandSender, &pRoutingSender)
{
- pDatabaseHandler.registerObserver(&pObserver);
- pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
- pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender,&pMockInterface,"mock");
- pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
+ pDatabaseHandler.registerObserver(&pObserver);
+ pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
+ pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockInterface, "mock");
+ pCommandInterfaceBackdoor.unloadPlugins(&pCommandSender);
}
routingInterfaceTest::~routingInterfaceTest()
@@ -54,389 +54,387 @@ routingInterfaceTest::~routingInterfaceTest()
void routingInterfaceTest::SetUp()
{
- DLT_REGISTER_APP("Rtest","RoutingInterfacetest");
- DLT_REGISTER_CONTEXT(DLT_CONTEXT,"Main","Main Context");
- DLT_LOG(DLT_CONTEXT,DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
+ DLT_REGISTER_APP("Rtest", "RoutingInterfacetest");
+ DLT_REGISTER_CONTEXT(DLT_CONTEXT, "Main", "Main Context");
+ DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("RoutingSendInterface Test started "));
}
void routingInterfaceTest::TearDown()
{
- DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
+ DLT_UNREGISTER_CONTEXT(DLT_CONTEXT);
}
TEST_F(routingInterfaceTest,abort)
{
- am_Sink_s sink;
- am_sinkID_t sinkID;
- am_Domain_s domain;
- am_domainID_t domainID;
+ 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;
-
- //prepare the stage
- ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
-
- //start a connect, expect a call on the routingInterface
+ std::vector<am_Handle_s> listHandles;
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = 1;
+
+ //prepare the stage
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ //start a connect, expect a call on the routingInterface
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, pControlReceiver.connect(handle,connectionID,CF_ANALOG,1,2));
//check the correctness of the handle
- ASSERT_NE(handle.handle,0);
- ASSERT_EQ(handle.handleType,H_CONNECT);
+ ASSERT_NE(handle.handle, 0);
+ ASSERT_EQ(handle.handleType, H_CONNECT);
//the handle must be inside the handlelist
- ASSERT_EQ(E_OK,pControlReceiver.getListHandles(listHandles));
+ ASSERT_EQ(E_OK, pControlReceiver.getListHandles(listHandles));
ASSERT_TRUE(listHandles[0].handle==handle.handle);
ASSERT_TRUE(listHandles[0].handleType==handle.handleType);
//send an abort expect a call on the routing interface
EXPECT_CALL(pMockInterface,asyncAbort(_)).WillOnce(Return(E_OK));
- ASSERT_EQ(E_OK,pControlReceiver.abortAction(handle));
+ ASSERT_EQ(E_OK, pControlReceiver.abortAction(handle));
//the reaction on the abort is specific for every function
//now we try to abort a handle that does not exist
- handle.handle=24;
- ASSERT_EQ(E_NON_EXISTENT,pControlReceiver.abortAction(handle));
+ handle.handle = 24;
+ ASSERT_EQ(E_NON_EXISTENT, 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));
+ 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));
+ 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);
+ 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_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));
+ 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));
+ 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);
+ 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_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));
+ 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_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_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));
+ 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_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_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));
+ 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_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_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));
+ 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_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_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));
+ 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_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_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));
+ 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_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_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));
+ 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_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_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));
+ 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));
+ 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_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));
+ 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));
+ 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();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
index acd1264..4da9643 100644
--- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
@@ -1,27 +1,27 @@
/**
-* Copyright (C) 2011, BMW AG
-*
-* GeniviAudioMananger AudioManagerDaemon
-*
-* \file routingInterfaces.h
-*
-* \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.
-*
-* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
-*/
+ * Copyright (C) 2011, BMW AG
+ *
+ * GeniviAudioMananger AudioManagerDaemon
+ *
+ * \file routingInterfaces.h
+ *
+ * \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.
+ *
+ * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+ */
#ifndef ROUTINGINTERFACETEST_H_
#define ROUTINGINTERFACETEST_H_
@@ -42,26 +42,27 @@
#include "../CommandInterfaceBackdoor.h"
#include "../CommonFunctions.h"
+namespace am
+{
-namespace am {
-
-class routingInterfaceTest : public ::testing::Test{
+class routingInterfaceTest: public ::testing::Test
+{
public:
- routingInterfaceTest();
- ~routingInterfaceTest();
- std::vector<std::string> plistRoutingPluginDirs;
- std::vector<std::string> plistCommandPluginDirs;
- DatabaseHandler pDatabaseHandler;
- RoutingSender pRoutingSender;
- CommandSender pCommandSender;
- MockRoutingSendInterface pMockInterface;
- RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
- CommandInterfaceBackdoor pCommandInterfaceBackdoor;
- ControlReceiver pControlReceiver;
- DatabaseObserver pObserver;
- CommonFunctions pCF;
- void SetUp();
- void TearDown();
+ routingInterfaceTest();
+ ~routingInterfaceTest();
+ std::vector<std::string> plistRoutingPluginDirs;
+ std::vector<std::string> plistCommandPluginDirs;
+ DatabaseHandler pDatabaseHandler;
+ RoutingSender pRoutingSender;
+ CommandSender pCommandSender;
+ MockRoutingSendInterface pMockInterface;
+ RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
+ CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlReceiver pControlReceiver;
+ DatabaseObserver pObserver;
+ CommonFunctions pCF;
+ void SetUp();
+ void TearDown();
};
}
diff --git a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
index cf551aa..5c23789 100644
--- a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
+++ b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
@@ -23,7 +23,7 @@ using namespace am;
DLT_DECLARE_CONTEXT(AudioManager)
-static volatile sig_atomic_t gDispatch = 1; //this global is used to stop the mainloop
+static volatile sig_atomic_t gDispatch = 1; //this global is used to stop the mainloop
sockethandlerTest::sockethandlerTest()
{
@@ -33,89 +33,83 @@ sockethandlerTest::~sockethandlerTest()
{
}
-am::timerCallBack::timerCallBack(SocketHandler *myHandler)
- :pTimer1Callback(this, &timerCallBack::timer1Callback),
- pTimer2Callback(this, &timerCallBack::timer2Callback),
- pTimer3Callback(this, &timerCallBack::timer3Callback),
- pTimer4Callback(this, &timerCallBack::timer4Callback),
- mSocketHandler(myHandler)
+timerCallBack::timerCallBack(SocketHandler *myHandler) :
+ pTimer1Callback(this, &timerCallBack::timer1Callback), //
+ pTimer2Callback(this, &timerCallBack::timer2Callback), //
+ pTimer3Callback(this, &timerCallBack::timer3Callback), //
+ pTimer4Callback(this, &timerCallBack::timer4Callback), //
+ mSocketHandler(myHandler)
{
}
-
-
am::timerCallBack::~timerCallBack()
{
}
-
-
void am::timerCallBack::timer1Callback(sh_timerHandle_t handle, void* userData)
{
- std::cout<<"callback1 called"<<std::endl;
- timespec timeout;
- timeout.tv_nsec=0;
- timeout.tv_sec=1;
- shTimerCallBack *buf=&pTimer1Callback;
- sh_timerHandle_t handle_;
- mSocketHandler->addTimer(timeout,buf,handle_,NULL);
+ std::cout << "callback1 called" << std::endl;
+ timespec timeout;
+ timeout.tv_nsec = 0;
+ timeout.tv_sec = 1;
+ shTimerCallBack *buf = &pTimer1Callback;
+ sh_timerHandle_t handle_;
+ mSocketHandler->addTimer(timeout, buf, handle_, NULL);
}
-
-
void am::timerCallBack::timer2Callback(sh_timerHandle_t handle, void* userData)
{
- std::cout<<"callback2 called"<<std::endl;
- timespec timeout;
- timeout.tv_nsec=0;
- timeout.tv_sec=1;
- shTimerCallBack *buf=&pTimer2Callback;
- sh_timerHandle_t handle_;
- mSocketHandler->addTimer(timeout,buf,handle_,NULL);
+ std::cout << "callback2 called" << std::endl;
+ timespec timeout;
+ timeout.tv_nsec = 0;
+ timeout.tv_sec = 1;
+ shTimerCallBack *buf = &pTimer2Callback;
+ sh_timerHandle_t handle_;
+ mSocketHandler->addTimer(timeout, buf, handle_, NULL);
}
void am::timerCallBack::timer3Callback(sh_timerHandle_t, void* userData)
{
- std::cout<<"callback3 called"<<std::endl;
+ std::cout << "callback3 called" << std::endl;
}
void am::timerCallBack::timer4Callback(sh_timerHandle_t, void* userData)
{
- std::cout<<"callback4 called"<<std::endl;
- mSocketHandler->stop_listening();
+ std::cout << "callback4 called" << std::endl;
+ mSocketHandler->stop_listening();
}
void* playWithSocketServer(void* data)
{
- SocketHandler myHandler;
- SamplePlugin::sockType_e type=SamplePlugin::INET;
- SamplePlugin myplugin(&myHandler,type);
- myHandler.start_listenting();
+ SocketHandler myHandler;
+ SamplePlugin::sockType_e type = SamplePlugin::INET;
+ SamplePlugin myplugin(&myHandler, type);
+ myHandler.start_listenting();
}
void* playWithUnixSocketServer(void* data)
{
- SocketHandler myHandler;
- SamplePlugin::sockType_e type=SamplePlugin::UNIX;
- SamplePlugin myplugin(&myHandler,type);
- myHandler.start_listenting();
+ SocketHandler myHandler;
+ SamplePlugin::sockType_e type = SamplePlugin::UNIX;
+ SamplePlugin myplugin(&myHandler, type);
+ myHandler.start_listenting();
}
TEST(sockethandlerTest,playWithUNIXSockets)
{
- pthread_t serverThread;
- char buffer[3000];
- struct sockaddr_un servAddr;
- int socket_;
+ pthread_t serverThread;
+ char buffer[3000];
+ struct sockaddr_un servAddr;
+ int socket_;
- //creates a thread that handles the serverpart
- pthread_create(&serverThread,NULL,playWithUnixSocketServer,NULL);
+ //creates a thread that handles the serverpart
+ pthread_create(&serverThread, NULL, playWithUnixSocketServer, NULL);
- sleep(1); //we need that here because the port needs to be opened
+ sleep(1); //we need that here because the port needs to be opened
if ((socket_ = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
- std::cout<<"socket problem"<<std::endl;
+ std::cout << "socket problem" << std::endl;
}
@@ -124,90 +118,90 @@ TEST(sockethandlerTest,playWithUNIXSockets)
servAddr.sun_family = AF_UNIX;
if (connect(socket_, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0)
{
- std::cout<<"ERROR: connect() failed\n"<<std::endl;
+ std::cout << "ERROR: connect() failed\n" << std::endl;
}
- for (int i=0;i<=1000;i++)
- {
- std::string string("Got It?");
- send(socket_,string.c_str(),string.size(),0);
- }
- std::string string("finish!");
- send(socket_,string.c_str(),string.size(),0);
+ for (int i = 0; i <= 1000; i++)
+ {
+ std::string string("Got It?");
+ send(socket_, string.c_str(), string.size(), 0);
+ }
+ std::string string("finish!");
+ send(socket_, string.c_str(), string.size(), 0);
- pthread_join(serverThread,NULL);
+ pthread_join(serverThread, NULL);
}
TEST(sockethandlerTest,playWithSockets)
{
- pthread_t serverThread;
- char buffer[3000];
- struct sockaddr_in servAddr;
- unsigned short servPort = 6060;
- struct hostent *host;
- int socket_;
+ pthread_t serverThread;
+ char buffer[3000];
+ struct sockaddr_in servAddr;
+ unsigned short servPort = 6060;
+ struct hostent *host;
+ int socket_;
- //creates a thread that handles the serverpart
- pthread_create(&serverThread,NULL,playWithSocketServer,NULL);
+ //creates a thread that handles the serverpart
+ pthread_create(&serverThread, NULL, playWithSocketServer, NULL);
- sleep(1); //we need that here because the port needs to be opened
+ sleep(1); //we need that here because the port needs to be opened
if ((socket_ = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
{
- std::cout<<"socket problem"<<std::endl;
+ std::cout << "socket problem" << std::endl;
}
if ((host = (struct hostent*) gethostbyname("localhost")) == 0)
{
- std::cout<<"ERROR: gethostbyname() failed\n"<<std::endl;
+ std::cout << "ERROR: gethostbyname() failed\n" << std::endl;
}
memset(&servAddr, 0, sizeof(servAddr));
- servAddr.sin_family = AF_INET;
- servAddr.sin_addr.s_addr = inet_addr(inet_ntoa(*( struct in_addr*)( host -> h_addr_list[0])));
- servAddr.sin_port = htons(servPort);
+ servAddr.sin_family = AF_INET;
+ servAddr.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr*) (host->h_addr_list[0])));
+ servAddr.sin_port = htons(servPort);
if (connect(socket_, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0)
{
- std::cout<<"ERROR: connect() failed\n"<<std::endl;
+ std::cout << "ERROR: connect() failed\n" << std::endl;
}
- for (int i=0;i<=1000;i++)
- {
- std::string string("Got It?");
- send(socket_,string.c_str(),string.size(),0);
- }
- std::string string("finish!");
- send(socket_,string.c_str(),string.size(),0);
+ for (int i = 0; i <= 1000; i++)
+ {
+ std::string string("Got It?");
+ send(socket_, string.c_str(), string.size(), 0);
+ }
+ std::string string("finish!");
+ send(socket_, string.c_str(), string.size(), 0);
- pthread_join(serverThread,NULL);
+ pthread_join(serverThread, NULL);
}
TEST(sockethandlerTest,playWithTimers)
{
- gDispatchDone=0;
- SocketHandler myHandler;
- timerCallBack testCallback(&myHandler);
- timespec timeoutTime, timeout2, timeout3, timeout4;
- timeoutTime.tv_sec=3;
- timeoutTime.tv_nsec=0;
- timeout2.tv_nsec=0;
- timeout2.tv_sec=1;
- timeout3.tv_nsec=000000000;
- timeout3.tv_sec=2;
- timeout4.tv_nsec=0;
- timeout4.tv_sec=13;
- shTimerCallBack* buf=&testCallback.pTimer1Callback;
- shTimerCallBack* buf2=&testCallback.pTimer2Callback;
- shTimerCallBack* buf3=&testCallback.pTimer3Callback;
- shTimerCallBack* buf4=&testCallback.pTimer4Callback;
- sh_timerHandle_t handle;
- myHandler.addTimer(timeoutTime,buf,handle,NULL);
- myHandler.addTimer(timeout2,buf2,handle,NULL);
- myHandler.addTimer(timeout3,buf3,handle,NULL);
- myHandler.addTimer(timeout4,buf4,handle,NULL);
- myHandler.start_listenting();
+ gDispatchDone = 0;
+ SocketHandler myHandler;
+ timerCallBack testCallback(&myHandler);
+ timespec timeoutTime, timeout2, timeout3, timeout4;
+ timeoutTime.tv_sec = 3;
+ timeoutTime.tv_nsec = 0;
+ timeout2.tv_nsec = 0;
+ timeout2.tv_sec = 1;
+ timeout3.tv_nsec = 000000000;
+ timeout3.tv_sec = 2;
+ timeout4.tv_nsec = 0;
+ timeout4.tv_sec = 13;
+ shTimerCallBack* buf = &testCallback.pTimer1Callback;
+ shTimerCallBack* buf2 = &testCallback.pTimer2Callback;
+ shTimerCallBack* buf3 = &testCallback.pTimer3Callback;
+ shTimerCallBack* buf4 = &testCallback.pTimer4Callback;
+ sh_timerHandle_t handle;
+ myHandler.addTimer(timeoutTime, buf, handle, NULL);
+ myHandler.addTimer(timeout2, buf2, handle, NULL);
+ myHandler.addTimer(timeout3, buf3, handle, NULL);
+ myHandler.addTimer(timeout4, buf4, handle, NULL);
+ myHandler.start_listenting();
}
@@ -221,131 +215,118 @@ void sockethandlerTest::TearDown()
int main(int argc, char **argv)
{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
-am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socketType)
- :connectFiredCB(this,&SamplePlugin::connectSocket),
- receiveFiredCB(this,&SamplePlugin::receiveData),
- sampleDispatchCB(this,&SamplePlugin::dispatchData),
- sampleCheckCB(this,&SamplePlugin::check),
- mSocketHandler(mySocketHandler),
- mConnecthandle(),
- mReceiveHandle(),
- msgList()
+am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socketType) :
+ connectFiredCB(this, &SamplePlugin::connectSocket), //
+ receiveFiredCB(this, &SamplePlugin::receiveData), //
+ sampleDispatchCB(this, &SamplePlugin::dispatchData), //
+ sampleCheckCB(this, &SamplePlugin::check), //
+ mSocketHandler(mySocketHandler), //
+ mConnecthandle(), //
+ mReceiveHandle(), //
+ msgList()
{
- int ret;
- int yes = 1;
-
- int socketHandle;
- struct sockaddr_in servAddr;
- struct sockaddr_un unixAddr;
- unsigned int servPort = 6060;
-
- switch (socketType)
- {
- case UNIX:
- socketHandle = socket(AF_UNIX, SOCK_STREAM, 0);
- unixAddr.sun_family = AF_UNIX;
- strcpy(unixAddr.sun_path,SOCK_PATH);
- unlink(unixAddr.sun_path);
- bind(socketHandle, (struct sockaddr *)&unixAddr, strlen(unixAddr.sun_path) + sizeof(unixAddr.sun_family));
- break;
- case INET:
- socketHandle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- setsockopt(socketHandle, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
- memset(&servAddr, 0, sizeof(servAddr));
- servAddr.sin_family = AF_INET;
- servAddr.sin_addr.s_addr = INADDR_ANY;
- servAddr.sin_port = htons(servPort);
- bind(socketHandle, (struct sockaddr *) &servAddr, sizeof(servAddr));
- break;
- default:
- break;
- }
+ int ret;
+ int yes = 1;
+
+ int socketHandle;
+ struct sockaddr_in servAddr;
+ struct sockaddr_un unixAddr;
+ unsigned int servPort = 6060;
+
+ switch (socketType)
+ {
+ case UNIX:
+ socketHandle = socket(AF_UNIX, SOCK_STREAM, 0);
+ unixAddr.sun_family = AF_UNIX;
+ strcpy(unixAddr.sun_path, SOCK_PATH);
+ unlink(unixAddr.sun_path);
+ bind(socketHandle, (struct sockaddr *) &unixAddr, strlen(unixAddr.sun_path) + sizeof(unixAddr.sun_family));
+ break;
+ case INET:
+ socketHandle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ setsockopt(socketHandle, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int));
+ memset(&servAddr, 0, sizeof(servAddr));
+ servAddr.sin_family = AF_INET;
+ servAddr.sin_addr.s_addr = INADDR_ANY;
+ servAddr.sin_port = htons(servPort);
+ bind(socketHandle, (struct sockaddr *) &servAddr, sizeof(servAddr));
+ break;
+ default:
+ break;
+ }
if (listen(socketHandle, 3) < 0)
{
- std::cout<<"listen ok"<<std::endl;
+ std::cout << "listen ok" << std::endl;
} /* if */
- int a=1;
- ioctl (socketHandle, FIONBIO, (char *) &a);
- setsockopt (socketHandle, SOL_SOCKET, SO_KEEPALIVE, (char *) &a, sizeof (a));
+ int a = 1;
+ ioctl(socketHandle, FIONBIO, (char *) &a);
+ setsockopt(socketHandle, SOL_SOCKET, SO_KEEPALIVE, (char *) &a, sizeof(a));
- short events=0;
- events |= POLLIN;
- mySocketHandler->addFDPoll(socketHandle,events,NULL,&connectFiredCB,NULL,NULL,NULL,mConnecthandle);
- std::cout<<"setup server - listening"<<std::endl;
+ short events = 0;
+ events |= POLLIN;
+ mySocketHandler->addFDPoll(socketHandle, events, NULL, &connectFiredCB, NULL, NULL, NULL, mConnecthandle);
+ std::cout << "setup server - listening" << std::endl;
}
-
-
void am::SamplePlugin::connectSocket(const pollfd pollfd1, const sh_pollHandle_t handle, void *userData)
{
- //first, accept the connection, create a new filedescriptor
- std::cout<<"Got a connection request !"<<std::endl;
- struct sockaddr answer;
- socklen_t len=sizeof(answer);
- int receiveFD = accept(pollfd1.fd, (struct sockaddr*)&answer, &len);
+ //first, accept the connection, create a new filedescriptor
+ std::cout << "Got a connection request !" << std::endl;
+ struct sockaddr answer;
+ socklen_t len = sizeof(answer);
+ int receiveFD = accept(pollfd1.fd, (struct sockaddr*) &answer, &len);
- //set the correct event:
- short event = 0;
- event |=POLLIN;
+ //set the correct event:
+ short event = 0;
+ event |= POLLIN;
- //aded the filedescriptor to the sockethandler and register the callbacks for receiving the data
- mSocketHandler->addFDPoll(receiveFD,event,NULL,&receiveFiredCB,&sampleCheckCB,&sampleDispatchCB,NULL,mReceiveHandle);
+ //aded the filedescriptor to the sockethandler and register the callbacks for receiving the data
+ mSocketHandler->addFDPoll(receiveFD, event, NULL, &receiveFiredCB, &sampleCheckCB, &sampleDispatchCB, NULL, mReceiveHandle);
}
-
-
void am::SamplePlugin::receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
- //initialize buffer
- char buffer[10];
- //read until buffer is full or no more data is there
- int read=recv(pollfd.fd,buffer,7,NULL);
- if (read>1)
- {
- //read the message and store it in a queue
- std::string msg=std::string(buffer,read);
- msgList.push(msg);
- std::cout<<"Got a message !"<<std::endl;
- }
+ //initialize buffer
+ char buffer[10];
+ //read until buffer is full or no more data is there
+ int read = recv(pollfd.fd, buffer, 7, NULL);
+ if (read > 1)
+ {
+ //read the message and store it in a queue
+ std::string msg = std::string(buffer, read);
+ msgList.push(msg);
+ std::cout << "Got a message !" << std::endl;
+ }
}
-
-
bool am::SamplePlugin::dispatchData(const sh_pollHandle_t handle, void *userData)
{
- //read data from the queue
- std::cout<<"Data:"<<msgList.front()<<std::endl;
-
- //if the message was our finish message, we quit the poll loop
- if (msgList.front().compare("finish!")==0)
- {
- mSocketHandler->stop_listening();
- }
- //remove the message from the queue and return false if there is no more message to read.
- msgList.pop();
- if (msgList.size()!=0) return true;
- return false;
+ //read data from the queue
+ std::cout << "Data:" << msgList.front() << std::endl;
+
+ //if the message was our finish message, we quit the poll loop
+ if (msgList.front().compare("finish!") == 0)
+ {
+ mSocketHandler->stop_listening();
+ }
+ //remove the message from the queue and return false if there is no more message to read.
+ msgList.pop();
+ if (msgList.size() != 0) return true;
+ return false;
}
bool am::SamplePlugin::check(const sh_pollHandle_t handle, void *userData)
{
- //checks if there is data to dispatch
- std::cout<<"check!:"<<std::endl;
- if (msgList.size()!=0) return true;
- return false;
+ //checks if there is data to dispatch
+ std::cout << "check!:" << std::endl;
+ if (msgList.size() != 0) return true;
+ return false;
}
-
-
-
-
-
-
-
diff --git a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h
index 18eff7e..faf604b 100644
--- a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h
+++ b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.h
@@ -12,56 +12,58 @@
#include <queue>
#include "SocketHandler.h"
-namespace am {
+namespace am
+{
class SamplePlugin
{
public:
- enum sockType_e
- {
- UNIX,
- INET
- };
- SamplePlugin(SocketHandler *mySocketHandler,sockType_e socketType);
- virtual ~SamplePlugin() {};
- void connectSocket(const pollfd pollfd,const sh_pollHandle_t handle, void* userData);
- void receiveData(const pollfd pollfd,const sh_pollHandle_t handle, void* userData);
- bool dispatchData(const sh_pollHandle_t handle, void* userData);
- bool check(const sh_pollHandle_t handle, void* userData);
- shPollFired_T<SamplePlugin> connectFiredCB;
- shPollFired_T<SamplePlugin> receiveFiredCB;
- shPollDispatch_T<SamplePlugin> sampleDispatchCB;
- shPollCheck_T<SamplePlugin> sampleCheckCB;
+ enum sockType_e
+ {
+ UNIX, INET
+ };
+ SamplePlugin(SocketHandler *mySocketHandler, sockType_e socketType);
+ virtual ~SamplePlugin()
+ {
+ }
+ ;
+ void connectSocket(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ void receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ bool dispatchData(const sh_pollHandle_t handle, void* userData);
+ bool check(const sh_pollHandle_t handle, void* userData);
+ shPollFired_T<SamplePlugin> connectFiredCB;
+ shPollFired_T<SamplePlugin> receiveFiredCB;
+ shPollDispatch_T<SamplePlugin> sampleDispatchCB;
+ shPollCheck_T<SamplePlugin> sampleCheckCB;
private:
- SocketHandler *mSocketHandler;
- sh_pollHandle_t mConnecthandle,mReceiveHandle;
- std::queue<std::string> msgList;
+ SocketHandler *mSocketHandler;
+ sh_pollHandle_t mConnecthandle, mReceiveHandle;
+ std::queue<std::string> msgList;
};
-
class timerCallBack
{
public:
- timerCallBack(SocketHandler *SocketHandler);
- virtual ~timerCallBack();
- void timer1Callback(sh_timerHandle_t handle,void * userData);
- void timer2Callback(sh_timerHandle_t handle,void * userData);
- void timer3Callback(sh_timerHandle_t handle,void * userData);
- void timer4Callback(sh_timerHandle_t handle,void * userData);
- shTimerCallBack_T<timerCallBack> pTimer1Callback;
- shTimerCallBack_T<timerCallBack> pTimer2Callback;
- shTimerCallBack_T<timerCallBack> pTimer3Callback;
- shTimerCallBack_T<timerCallBack> pTimer4Callback;
- SocketHandler *mSocketHandler;
+ timerCallBack(SocketHandler *SocketHandler);
+ virtual ~timerCallBack();
+ void timer1Callback(sh_timerHandle_t handle, void * userData);
+ void timer2Callback(sh_timerHandle_t handle, void * userData);
+ void timer3Callback(sh_timerHandle_t handle, void * userData);
+ void timer4Callback(sh_timerHandle_t handle, void * userData);
+ shTimerCallBack_T<timerCallBack> pTimer1Callback;
+ shTimerCallBack_T<timerCallBack> pTimer2Callback;
+ shTimerCallBack_T<timerCallBack> pTimer3Callback;
+ shTimerCallBack_T<timerCallBack> pTimer4Callback;
+ SocketHandler *mSocketHandler;
};
class sockethandlerTest: public ::testing::Test
{
public:
- sockethandlerTest();
- virtual ~sockethandlerTest();
- void SetUp();
- void TearDown();
+ sockethandlerTest();
+ virtual ~sockethandlerTest();
+ void SetUp();
+ void TearDown();
};
} /* namespace am */