summaryrefslogtreecommitdiff
path: root/PluginRoutingInterfaceCAPI/test
diff options
context:
space:
mode:
Diffstat (limited to 'PluginRoutingInterfaceCAPI/test')
-rw-r--r--PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.cpp2269
-rw-r--r--PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.h104
-rw-r--r--PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.cpp225
-rw-r--r--PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.h112
-rw-r--r--PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.cpp31
-rw-r--r--PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.h32
-rw-r--r--PluginRoutingInterfaceCAPI/test/CMakeLists.txt135
-rw-r--r--PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.cpp87
-rw-r--r--PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.h53
-rw-r--r--PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h126
-rwxr-xr-xPluginRoutingInterfaceCAPI/test/RoutingSender_dbus.conf8
-rwxr-xr-xPluginRoutingInterfaceCAPI/test/cmake/AmRoutingInterfaceCAPITests_dbus.conf.in3
-rw-r--r--PluginRoutingInterfaceCAPI/test/cmake/CAmRoutingSenderService.h.in112
-rwxr-xr-xPluginRoutingInterfaceCAPI/test/cmake/RoutingSender_dbus.conf.in8
-rw-r--r--PluginRoutingInterfaceCAPI/test/cmake/config.cmake8
15 files changed, 3313 insertions, 0 deletions
diff --git a/PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.cpp b/PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.cpp
new file mode 100644
index 0000000..5f1069e
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.cpp
@@ -0,0 +1,2269 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include <sys/time.h>
+#include <CommonAPI/CommonAPI.h>
+#include <org/genivi/audiomanager/am_gen.h>
+#include "CAmRoutingInterfaceCAPITests.h"
+#include "TAmPluginTemplate.h"
+#include "shared/CAmDltWrapper.h"
+#include "../include/CAmRoutingSenderCAPI.h"
+#include "../include/CAmRoutingSenderCommon.h"
+#include "CAmRoutingSenderService.h"
+#include "IAmRoutingSenderBackdoor.h"
+
+using namespace am;
+using namespace org::genivi::audiomanager;
+using namespace CommonAPI;
+using namespace testing;
+
+static CAmTestsEnvironment* env;
+
+/**
+ * Main thread synchronization
+ */
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/**
+ * Common-API connection thread synchronization
+ */
+pthread_cond_t condPxy = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t mutexPxy = PTHREAD_MUTEX_INITIALIZER;
+
+/**
+ * Proxy initialization thread synchronization
+ */
+pthread_cond_t condSer = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t mutexSer = PTHREAD_MUTEX_INITIALIZER;
+
+
+#define TEST_ID_1 102
+#define TEST_ID_2 103
+
+/**
+ * Initialize common-api and am sinks
+ */
+void initSink(am_gen::sinkData_s & newSink, am_Sink_s & newAmSink, const am_gen::am_domainID_t & domainID, const am_gen::am_sinkID_t & sinkID = 0)
+{
+ am_gen::am_MuteState_e muteState = am_gen::am_MuteState_e::MS_UNKNOWN;
+ am_gen::am_Availability_s available(am_gen::am_Availability_e::A_MAX, am_gen::am_AvailabilityReason_e::AR_MAX);
+ am_gen::am_SoundProperty_L listSoundProperties;
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_INTERR_OVERLAYID, 100));
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_EXAMPLE_BASS, 101));
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_MAX, 102));
+ am_gen::am_ConnectionFormat_L listConnectionFormats;
+ listConnectionFormats.push_back(am_gen::am_ConnectionFormat_e::CF_MAX);
+ am_gen::am_MainSoundProperty_L listMainSoundProperties;
+ listMainSoundProperties.push_back(am_gen::am_MainSoundProperty_s(am_gen::am_MainSoundPropertyType_e::MSP_MAX, 100));
+ am_gen::am_NotificationConfiguration_L listMainNotificationConfigurations;
+ listMainNotificationConfigurations.push_back(am_gen::am_NotificationConfiguration_s(am_gen::am_NotificationType_e::NT_MAX, am_gen::am_NotificationStatus_e::NS_MAX, 100));
+ am_gen::am_NotificationConfiguration_L listNotificationConfigurations;
+ listNotificationConfigurations.push_back(am_gen::am_NotificationConfiguration_s(am_gen::am_NotificationType_e::NT_MAX, am_gen::am_NotificationStatus_e::NS_MAX, 100));
+
+ am_gen::sinkData_s sink(sinkID, "name", domainID, 104, 50, true, available, muteState, 50,
+ listSoundProperties, listConnectionFormats, listMainSoundProperties, listMainNotificationConfigurations, listNotificationConfigurations);
+ newSink = sink;
+ CAmConvertCAPI2AM(sink, newAmSink);
+}
+
+/**
+ * Initialize common-api and am sources
+ */
+void initSource(am_gen::sourceData_s & newSource, am_Source_s & newAmSource, const am_gen::am_domainID_t & domainID, const am_gen::am_sourceID_t & sourceID = 0)
+{
+ am_gen::am_SourceState_e srcState = am_gen::am_SourceState_e::SS_MAX;
+ am_gen::am_Availability_s available(am_gen::am_Availability_e::A_MAX, am_gen::am_AvailabilityReason_e::AR_MAX);
+ am_gen::am_SoundProperty_L listSoundProperties;
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_INTERR_OVERLAYID, 100));
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_EXAMPLE_BASS, 101));
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_MAX, 102));
+ am_gen::am_ConnectionFormat_L listConnectionFormats;
+ listConnectionFormats.push_back(am_gen::am_ConnectionFormat_e::CF_MAX);
+ am_gen::am_MainSoundProperty_L listMainSoundProperties;
+ listMainSoundProperties.push_back(am_gen::am_MainSoundProperty_s(am_gen::am_MainSoundPropertyType_e::MSP_MAX, 100));
+ am_gen::am_NotificationConfiguration_L listMainNotificationConfigurations;
+ listMainNotificationConfigurations.push_back(am_gen::am_NotificationConfiguration_s(am_gen::am_NotificationType_e::NT_MAX, am_gen::am_NotificationStatus_e::NS_MAX, 100));
+ am_gen::am_NotificationConfiguration_L listNotificationConfigurations;
+ listNotificationConfigurations.push_back(am_gen::am_NotificationConfiguration_s(am_gen::am_NotificationType_e::NT_MAX, am_gen::am_NotificationStatus_e::NS_MAX, 100));
+
+ am_gen::sourceData_s source(sourceID, domainID, "name", 104, srcState, 50, true, available, am_gen::am_InterruptState_e::IS_MAX,
+ listSoundProperties, listConnectionFormats, listMainSoundProperties, listMainNotificationConfigurations, listNotificationConfigurations);
+ newSource = source;
+ CAmConvertCAPI2AM(source, newAmSource);
+}
+
+/**
+ * Initialize common-api and am crossfaders
+ */
+void initCrossfader(am_gen::crossfaderData_s & newCrossfader, am_Crossfader_s & newAmCrossfader, const am_gen::am_crossfaderID_t & crossfaderID = 0)
+{
+ am_gen::crossfaderData_s crossfader(crossfaderID, "name", TEST_ID_1, TEST_ID_2, TEST_ID_1, am_gen::am_HotSink_e::HS_MAX);
+ CAmConvertCAPI2AM(crossfader, newAmCrossfader);
+ newCrossfader = crossfader;
+}
+
+/**
+ * Client thread where the proxy and the routing test domain service run
+ */
+void* run_client(void*)
+{
+ CAmSocketHandler socketHandler;
+ CAmTestCAPIWrapper wrapper(&socketHandler);
+ env->mSocketHandlerClient = &socketHandler;
+ std::shared_ptr<CommonAPI::Factory> factory = wrapper.factory();
+
+ env->mProxy = factory->buildProxy<RoutingInterfaceProxy>(CAmRoutingSenderCAPI::ROUTING_INTERFACE_SERVICE);
+ env->mProxy->getProxyStatusEvent().subscribe(std::bind(&CAmTestsEnvironment::onServiceStatusEvent,env,std::placeholders::_1));
+
+ env->mDomainService = std::make_shared<CAmRoutingSenderService>(&wrapper, env->mProxy);
+
+ if( false == wrapper.registerStub(env->mDomainService, CAmRoutingSenderService::ROUTING_SENDER_SERVICE) )
+ {
+ printf("\n Can't register service -> %s \n", CAmRoutingSenderService::ROUTING_SENDER_SERVICE);
+ logInfo("Can't register service -> ", CAmRoutingSenderService::ROUTING_SENDER_SERVICE);
+ }
+
+ pthread_mutex_lock(&mutexSer);
+ env->mIsProxyInitilized = true;
+ pthread_mutex_unlock(&mutexSer);
+ pthread_cond_signal(&condSer);
+
+ socketHandler.start_listenting();
+
+//Cleanup
+ env->mProxy.reset();
+ env->mSocketHandlerClient = NULL;
+
+ return (NULL);
+}
+
+/**
+ * Service thread for the routing plugin
+ */
+void* run_service(void*)
+{
+ CAmSocketHandler socketHandler;
+ CAmTestCAPIWrapper wrapper(&socketHandler);
+ CAmRoutingSenderCAPI plugin(&wrapper);
+ env->mpPlugin = &plugin;
+ env->mSocketHandlerService = &socketHandler;
+ MockIAmRoutingReceive mock;
+ env->mpRoutingReceive = &mock;
+ if(plugin.startupInterface(env->mpRoutingReceive)!=E_OK)
+ {
+ logError("CommandSendInterface can't start!");
+ }
+ else
+ {
+ plugin.setRoutingReady(10);
+ socketHandler.start_listenting();
+ plugin.setRoutingRundown(10);
+ plugin.tearDownInterface(env->mpRoutingReceive);
+ }
+ //Cleanup
+ env->mpRoutingReceive = NULL;
+ env->mpPlugin = NULL;
+ env->mSocketHandlerClient = NULL;
+
+ return (NULL);
+}
+
+/**
+ * Helper thread that listens for signals from another threads in order to synchronize them.
+ * This thread starts actually the unit tests.
+ */
+void* run_listener(void*)
+{
+ pthread_mutex_lock(&mutexSer);
+ while (env->mIsProxyInitilized==false)
+ {
+ std::cout << "\n\r Intialize proxy..\n\r" ;
+ pthread_cond_wait(&condSer, &mutexSer);
+ }
+ pthread_mutex_unlock(&mutexSer);
+
+ time_t start = time(0);
+ time_t now = start;
+ pthread_mutex_lock(&mutexPxy);
+ while ( env->mIsServiceAvailable==false && now-start <= 15 )
+ {
+ std::cout << " Waiting for proxy..\n\r" ;
+ struct timespec ts = { 0, 0 };
+ clock_gettime(CLOCK_REALTIME, &ts);
+ ts.tv_sec += 5;
+ pthread_cond_timedwait(&condPxy, &mutexPxy, &ts);
+ now = time(0);
+ }
+ pthread_mutex_unlock(&mutexPxy);
+
+ pthread_cond_signal(&cond);
+
+ return NULL;
+}
+
+
+CAmRoutingInterfaceCAPITests::CAmRoutingInterfaceCAPITests()
+{
+
+}
+
+CAmRoutingInterfaceCAPITests::~CAmRoutingInterfaceCAPITests()
+{
+
+}
+
+void CAmRoutingInterfaceCAPITests::SetUp()
+{
+ ::testing::GTEST_FLAG(throw_on_failure) = false;
+}
+
+void CAmRoutingInterfaceCAPITests::TearDown()
+{
+ ::testing::GTEST_FLAG(throw_on_failure) = true;
+}
+
+
+CAmRoutingSenderCAPITests::CAmRoutingSenderCAPITests()
+{
+
+}
+
+CAmRoutingSenderCAPITests::~CAmRoutingSenderCAPITests()
+{
+
+}
+
+void CAmRoutingSenderCAPITests::SetUp()
+{
+ ::testing::GTEST_FLAG(throw_on_failure) = false;
+}
+
+void CAmRoutingSenderCAPITests::TearDown()
+{
+ ::testing::GTEST_FLAG(throw_on_failure) = true;
+}
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new CAmTestsEnvironment);
+ return RUN_ALL_TESTS();
+}
+
+CAmTestsEnvironment::CAmTestsEnvironment() :
+ mIsProxyInitilized(false),
+ mIsServiceAvailable(false),
+ mIsDomainAvailable(false),
+ mListenerThread(0),
+ mServicePThread(0),
+ mClientPThread(0),
+ mSocketHandlerService(NULL),
+ mSocketHandlerClient(NULL),
+ mpRoutingReceive(NULL),
+ mpPlugin(NULL),
+ mProxy(NULL),
+ mDomainService(NULL)
+{
+ env=this;
+ CAmDltWrapper::instance()->registerApp("capiTest", "capiTest");
+ pthread_create(&mListenerThread, NULL, run_listener, NULL);
+ pthread_create(&mServicePThread, NULL, run_service, NULL);
+ pthread_create(&mClientPThread, NULL, run_client, NULL);
+}
+
+CAmTestsEnvironment::~CAmTestsEnvironment()
+{
+
+}
+
+void CAmTestsEnvironment::SetUp()
+{
+ pthread_cond_wait(&cond, &mutex);
+}
+
+void CAmTestsEnvironment::TearDown()
+{
+ if(mSocketHandlerClient)
+ mSocketHandlerClient->exit_mainloop();
+ pthread_join(mClientPThread, NULL);
+
+ if(mSocketHandlerService)
+ mSocketHandlerService->exit_mainloop();
+ pthread_join(mServicePThread, NULL);
+ sleep(1);
+}
+
+void CAmTestsEnvironment::onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus)
+{
+ std::stringstream avail;
+ avail << "(" << static_cast<int>(serviceStatus) << ")";
+
+ logInfo("Service Status changed to ", avail.str());
+ std::cout << std::endl << "Service Status changed to " << avail.str() << std::endl;
+ pthread_mutex_lock(&mutexPxy);
+ mIsServiceAvailable = (serviceStatus==CommonAPI::AvailabilityStatus::AVAILABLE);
+ pthread_mutex_unlock(&mutexPxy);
+ pthread_cond_signal(&condPxy);
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ClientStartupTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+MATCHER_P(IsHandleEqual, value, "") {
+ am_Handle_s & lh = arg;
+ return lh.handle == value.handle && lh.handleType == value.handleType;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackConnect)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_connectionID_t connectionID = TEST_ID_1;
+ am_Error_e error = E_OK;
+ am_Handle_s handle = {H_CONNECT, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackConnect(IsHandleEqual(handle), connectionID, error)).Times(1);
+ env->mProxy->ackConnect(20, connectionID, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackDisconnect)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_connectionID_t connectionID = TEST_ID_1;
+ am_Error_e error = E_OK;
+ am_Handle_s handle = {H_DISCONNECT, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackDisconnect(IsHandleEqual(handle), connectionID, error)).Times(1);
+ env->mProxy->ackDisconnect(20, connectionID, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetSinkVolumeChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSINKVOLUME, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSinkVolumeChange(IsHandleEqual(handle), volume, error)).Times(1);
+ env->mProxy->ackSetSinkVolume(20, volume, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetSourceVolumeChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSOURCEVOLUME, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceVolumeChange(IsHandleEqual(handle), volume, error)).Times(1);
+ env->mProxy->ackSetSourceVolume(20, volume, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetSourceState)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSOURCESTATE, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceState(IsHandleEqual(handle), error)).Times(1);
+ env->mProxy->ackSetSourceState(20, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetSinkSoundProperties)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSINKSOUNDPROPERTIES, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSinkSoundProperties(IsHandleEqual(handle), error)).Times(1);
+ env->mProxy->ackSetSinkSoundProperties(20, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetSinkSoundProperty)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSINKSOUNDPROPERTY, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSinkSoundProperty(IsHandleEqual(handle), error)).Times(1);
+ env->mProxy->ackSetSinkSoundProperty(20, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetSourceSoundProperties)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSOURCESOUNDPROPERTIES, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceSoundProperties(IsHandleEqual(handle), error)).Times(1);
+ env->mProxy->ackSetSourceSoundProperties(20, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetSourceSoundProperty)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSOURCESOUNDPROPERTY, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceSoundProperty(IsHandleEqual(handle), error)).Times(1);
+ env->mProxy->ackSetSourceSoundProperty(20, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackCrossFading)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_HotSink_e hotSink = HS_UNKNOWN;
+ am_Handle_s handle = {H_CROSSFADE, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackCrossFading(IsHandleEqual(handle), hotSink, error)).Times(1);
+ env->mProxy->ackCrossFading(20, static_cast<am_gen::am_HotSink_e>(hotSink), (am_gen::am_Error_e)error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSourceVolumeTick)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_sourceID_t sourceID = TEST_ID_1;
+ am_Handle_s handle = {H_SETSOURCEVOLUME, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSourceVolumeTick(IsHandleEqual(handle), sourceID, error)).Times(1);
+ env->mProxy->ackSourceVolumeTick(20, sourceID, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSinkVolumeTick)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_sinkID_t sID = TEST_ID_1;
+ am_Handle_s handle = {H_SETSINKVOLUME, 20};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSinkVolumeTick(IsHandleEqual(handle), sID, error)).Times(1);
+ env->mProxy->ackSinkVolumeTick(20, sID, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+ACTION(actionRegister){
+ arg1=TEST_ID_1;
+}
+
+ACTION(actionPeekDomain){
+ arg1=TEST_ID_1;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, peekDomain)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ std::string name("domain name");
+ am_gen::am_domainID_t domainID = 0;
+ ON_CALL(*env->mpRoutingReceive, peekDomain(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, peekDomain(name, _)).WillOnce(DoAll(actionPeekDomain(), Return(E_OK)));
+ env->mProxy->peekDomain(name, callStatus, domainID, error);
+ ASSERT_EQ( domainID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+MATCHER_P(IsDomainDataEqualTo, value, "") {
+ auto lh = arg;
+ return lh.domainID == value.domainID &&
+ lh.name == value.name &&
+ lh.nodename == value.nodename &&
+ lh.early == value.early &&
+ lh.complete == value.complete &&
+ lh.state == value.state;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, registerDomain)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ std::string name("domain name");
+ std::string busname("busname");
+ std::string nodename("nodename");
+
+ am_gen::am_Domain_s domainData(0, name, busname, nodename, false, false, am_gen::am_DomainState_e::DS_CONTROLLED);
+ am::am_Domain_s amDomainData;
+ CAmConvertCAPI2AM(domainData, amDomainData);
+ am_gen:am_domainID_t domainID = 0;
+//If the result is E_OK, then the routing service will try to establish a connection with the domain via common-api.
+//For now we won't test common-api connection with the domain therefore E_ABORTED is returned.
+ ON_CALL(*env->mpRoutingReceive, registerDomain(_, _)).WillByDefault(Return(E_ABORTED));
+ EXPECT_CALL(*env->mpRoutingReceive, registerDomain(IsDomainDataEqualTo(amDomainData), _)).WillOnce(DoAll(actionRegister(), Return(E_ABORTED)));
+
+//example: [local:org.genivi.audiomanger.testdomaininterface:org.genivi.audiomanger]
+ env->mProxy->registerDomain(domainData,
+ "org.genivi.audiomanger", //(last part)
+ "",
+ "org.genivi.audiomanger.testdomaininterface", //(middle part)
+ callStatus,
+ domainID,
+ error);
+ ASSERT_EQ( domainID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_ABORTED );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, deregisterDomain)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_domainID_t domainID = TEST_ID_1;
+
+ ON_CALL(*env->mpRoutingReceive, deregisterDomain(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterDomain(domainID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterDomain(domainID, callStatus, error);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+ACTION(actionRegisterGateway){
+ arg1=TEST_ID_1;
+}
+
+MATCHER_P(IsGatewayDataEqualTo, value, "") {
+ auto lh = arg;
+ return lh.gatewayID == value.gatewayID &&
+ lh.name == value.name &&
+ lh.sinkID == value.sinkID &&
+ lh.sourceID == value.sourceID &&
+ lh.domainSinkID == value.domainSinkID &&
+ lh.controlDomainID == value.controlDomainID &&
+ lh.listSourceFormats == value.listSourceFormats &&
+ lh.listSinkFormats == value.listSinkFormats &&
+ lh.convertionMatrix == value.convertionMatrix;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, registerGateway)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ am_gen::am_ConnectionFormat_L listSourceFormats;
+ listSourceFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+ listSourceFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_AUTO);
+ am_gen::am_ConnectionFormat_L listSinkFormats;
+ listSinkFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_AUTO);
+ listSinkFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+ am_gen::bool_L convertionMatrix;
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+
+ am_gen:am_gatewayID_t gatewayID = 0;
+ am_gen::am_Gateway_s gateway(gatewayID, "name", 103, 104, 105, 106, 107, listSourceFormats, listSinkFormats, convertionMatrix);
+ am_Gateway_s amGateway;
+ CAmConvertCAPI2AM(gateway, amGateway);
+
+ ON_CALL(*env->mpRoutingReceive, registerGateway(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, registerGateway(IsGatewayDataEqualTo(amGateway), _)).WillOnce(DoAll(actionRegisterGateway(), Return(E_OK)));
+ env->mProxy->registerGateway(gateway, callStatus, gatewayID, error);
+ ASSERT_EQ( gatewayID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, deregisterGateway)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_gatewayID_t gatewayID = TEST_ID_1;
+
+ ON_CALL(*env->mpRoutingReceive, deregisterGateway(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterGateway(gatewayID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterGateway(gatewayID, callStatus, error);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+ACTION(actionPeek){
+ arg1=TEST_ID_1;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, peekSink)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ std::string name("name");
+ am_gen::am_sinkID_t sinkID = 0;
+ ON_CALL(*env->mpRoutingReceive, peekSink(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, peekSink(name, _)).WillOnce(DoAll(actionPeek(), Return(E_OK)));
+ env->mProxy->peekSink(name, callStatus, sinkID, error);
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+
+MATCHER_P(IsSinkDataEqualTo, value, "") {
+ auto lh = arg;
+
+ bool bMainSoundProperties = lh.listMainSoundProperties.size() == value.listMainSoundProperties.size();
+ for(int i=0; i<lh.listMainSoundProperties.size(); i++)
+ {
+ bMainSoundProperties &= (lh.listMainSoundProperties.at(i).type==value.listMainSoundProperties.at(i).type &&
+ lh.listMainSoundProperties.at(i).value==value.listMainSoundProperties.at(i).value);
+ }
+
+ bool bSoundProperties = lh.listSoundProperties.size() == value.listSoundProperties.size();
+ for(int i=0; i<lh.listSoundProperties.size(); i++)
+ {
+ bSoundProperties &= (lh.listSoundProperties.at(i).type==value.listSoundProperties.at(i).type &&
+ lh.listSoundProperties.at(i).value==value.listSoundProperties.at(i).value);
+ }
+
+ bool bMainNotificationConfigurations = lh.listMainNotificationConfigurations.size() == value.listMainNotificationConfigurations.size();
+ for(int i=0; i<lh.listMainNotificationConfigurations.size(); i++)
+ {
+ bMainNotificationConfigurations &= (lh.listMainNotificationConfigurations.at(i).type==value.listMainNotificationConfigurations.at(i).type &&
+ lh.listMainNotificationConfigurations.at(i).status==value.listMainNotificationConfigurations.at(i).status &&
+ lh.listMainNotificationConfigurations.at(i).parameter==value.listMainNotificationConfigurations.at(i).parameter);
+ }
+
+ bool bNotificationConfigurations = lh.listNotificationConfigurations.size() == value.listNotificationConfigurations.size();
+ for(int i=0; i<lh.listNotificationConfigurations.size(); i++)
+ {
+ bNotificationConfigurations &= (lh.listNotificationConfigurations.at(i).type==value.listNotificationConfigurations.at(i).type &&
+ lh.listNotificationConfigurations.at(i).status==value.listNotificationConfigurations.at(i).status &&
+ lh.listNotificationConfigurations.at(i).parameter==value.listNotificationConfigurations.at(i).parameter);
+ }
+
+ return bMainSoundProperties &&
+ bSoundProperties &&
+ bNotificationConfigurations &&
+ bMainNotificationConfigurations &&
+ lh.sinkID == value.sinkID &&
+ lh.name == value.name &&
+ lh.domainID == value.domainID &&
+ lh.sinkClassID == value.sinkClassID &&
+ lh.volume == value.volume &&
+ lh.visible == value.visible &&
+ lh.available.availability == value.available.availability &&
+ lh.available.availabilityReason == value.available.availabilityReason &&
+ lh.muteState == value.muteState &&
+ lh.mainVolume == value.mainVolume &&
+ lh.listConnectionFormats == value.listConnectionFormats;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, registerSink)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ am_gen::sinkData_s sink;
+ am_Sink_s amSink;
+ am_gen:am_sinkID_t sinkID = 0;
+ initSink(sink, amSink, TEST_ID_2, sinkID);
+
+ ON_CALL(*env->mpRoutingReceive, registerSink(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, registerSink(IsSinkDataEqualTo(amSink), _)).WillOnce(DoAll(actionRegister(), Return(E_OK)));
+ env->mProxy->registerSink(sink, callStatus, sinkID, error);
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, deregisterSink)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_sinkID_t sinkID = TEST_ID_1;
+
+ ON_CALL(*env->mpRoutingReceive, deregisterSink(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterSink(sinkID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterSink(sinkID, callStatus, error);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, peekSource)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ std::string name("name");
+ am_gen::am_sourceID_t sinkID = 0;
+ ON_CALL(*env->mpRoutingReceive, peekSource(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, peekSource(name, _)).WillOnce(DoAll(actionPeek(), Return(E_OK)));
+ env->mProxy->peekSource(name, callStatus, sinkID, error);
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+ACTION(actionRegisterSource){
+ arg1=TEST_ID_1;
+}
+
+MATCHER_P(IsSourceDataEqualTo, value, "") {
+ auto lh = arg;
+
+ bool bMainSoundProperties = lh.listMainSoundProperties.size() == value.listMainSoundProperties.size();
+ for(int i=0; i<lh.listMainSoundProperties.size(); i++)
+ {
+ bMainSoundProperties &= (lh.listMainSoundProperties.at(i).type==value.listMainSoundProperties.at(i).type &&
+ lh.listMainSoundProperties.at(i).value==value.listMainSoundProperties.at(i).value);
+ }
+
+ bool bSoundProperties = lh.listSoundProperties.size() == value.listSoundProperties.size();
+ for(int i=0; i<lh.listSoundProperties.size(); i++)
+ {
+ bSoundProperties &= (lh.listSoundProperties.at(i).type==value.listSoundProperties.at(i).type &&
+ lh.listSoundProperties.at(i).value==value.listSoundProperties.at(i).value);
+ }
+
+ bool bMainNotificationConfigurations = lh.listMainNotificationConfigurations.size() == value.listMainNotificationConfigurations.size();
+ for(int i=0; i<lh.listMainNotificationConfigurations.size(); i++)
+ {
+ bMainNotificationConfigurations &= (lh.listMainNotificationConfigurations.at(i).type==value.listMainNotificationConfigurations.at(i).type &&
+ lh.listMainNotificationConfigurations.at(i).status==value.listMainNotificationConfigurations.at(i).status &&
+ lh.listMainNotificationConfigurations.at(i).parameter==value.listMainNotificationConfigurations.at(i).parameter);
+ }
+
+ bool bNotificationConfigurations = lh.listNotificationConfigurations.size() == value.listNotificationConfigurations.size();
+ for(int i=0; i<lh.listNotificationConfigurations.size(); i++)
+ {
+ bNotificationConfigurations &= (lh.listNotificationConfigurations.at(i).type==value.listNotificationConfigurations.at(i).type &&
+ lh.listNotificationConfigurations.at(i).status==value.listNotificationConfigurations.at(i).status &&
+ lh.listNotificationConfigurations.at(i).parameter==value.listNotificationConfigurations.at(i).parameter);
+ }
+ return bMainSoundProperties &&
+ bSoundProperties &&
+ bNotificationConfigurations &&
+ bMainNotificationConfigurations &&
+ lh.sourceID == value.sourceID &&
+ lh.name == value.name &&
+ lh.domainID == value.domainID &&
+ lh.sourceClassID == value.sourceClassID &&
+ lh.volume == value.volume &&
+ lh.visible == value.visible &&
+ lh.available.availability == value.available.availability &&
+ lh.available.availabilityReason == value.available.availabilityReason &&
+ lh.sourceState == value.sourceState &&
+ lh.interruptState == value.interruptState &&
+ lh.listConnectionFormats == value.listConnectionFormats;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, registerSource)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ am_gen::sourceData_s source;
+ am_Source_s amSource;
+ am_gen:am_sourceID_t sinkID = 0;
+ initSource(source, amSource, TEST_ID_2, sinkID);
+
+ ON_CALL(*env->mpRoutingReceive, registerSource(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, registerSource(IsSourceDataEqualTo(amSource), _)).WillOnce(DoAll(actionRegister(), Return(E_OK)));
+ env->mProxy->registerSource(source, callStatus, sinkID, error);
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, deregisterSource)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_sourceID_t sinkID = TEST_ID_1;
+
+ ON_CALL(*env->mpRoutingReceive, deregisterSource(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterSource(sinkID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterSource(sinkID, callStatus, error);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+ACTION(actionRegisterCrossfader){
+ arg1=TEST_ID_1;
+}
+
+MATCHER_P(IsCrossfaderDataEqualTo, value, "") {
+ auto lh = arg;
+ return lh.crossfaderID == value.crossfaderID &&
+ lh.name == value.name &&
+ lh.sinkID_A == value.sinkID_A &&
+ lh.sinkID_B == value.sinkID_B &&
+ lh.sinkID_B == value.sinkID_B &&
+ lh.sourceID == value.sourceID &&
+ lh.hotSink == value.hotSink;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, registerCrossfader)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ am_gen:am_crossfaderID_t crossfaderID = 0;
+ am_gen::crossfaderData_s crossfader;
+ am_Crossfader_s amCrossfader;
+ initCrossfader(crossfader, amCrossfader, crossfaderID);
+
+ ON_CALL(*env->mpRoutingReceive, registerCrossfader(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, registerCrossfader(IsCrossfaderDataEqualTo(amCrossfader), _)).WillOnce(DoAll(actionRegister(), Return(E_OK)));
+ env->mProxy->registerCrossfader(crossfader, callStatus, crossfaderID, error);
+ ASSERT_EQ( crossfaderID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, deregisterCrossfader)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_crossfaderID_t crossfaderID = TEST_ID_1;
+
+ ON_CALL(*env->mpRoutingReceive, deregisterCrossfader(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterCrossfader(crossfaderID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterCrossfader(crossfaderID, callStatus, error);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, peekSourceClassID)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ std::string name("name");
+ am_gen::am_sourceClass_t sinkID = 0;
+ ON_CALL(*env->mpRoutingReceive, peekSourceClassID(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, peekSourceClassID(name, _)).WillOnce(DoAll(actionPeek(), Return(E_OK)));
+ env->mProxy->peekSourceClassID(name, callStatus, sinkID, error);
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, peekSinkClassID)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ std::string name("name");
+ am_gen::am_sinkClass_t sinkID = 0;
+ ON_CALL(*env->mpRoutingReceive, peekSinkClassID(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, peekSinkClassID(name, _)).WillOnce(DoAll(actionPeek(), Return(E_OK)));
+ env->mProxy->peekSinkClassID(name, callStatus, sinkID, error);
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookInterruptStatusChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_sourceID_t sourceID = TEST_ID_1;
+ am_InterruptState_e interruptState = am_InterruptState_e::IS_MAX;
+ EXPECT_CALL(*env->mpRoutingReceive, hookInterruptStatusChange(sourceID, interruptState)).Times(1);
+ env->mProxy->hookInterruptStatusChange(sourceID, interruptState, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookDomainRegistrationComplete)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_domainID_t testID = TEST_ID_1;
+ EXPECT_CALL(*env->mpRoutingReceive, hookDomainRegistrationComplete(testID)).Times(1);
+ env->mProxy->hookDomainRegistrationComplete(testID, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+MATCHER_P(IsAvailabilityEqualTo, value, "") {
+ am_Availability_s lh = arg;
+ return lh.availability == value.availability &&
+ lh.availabilityReason == value.availabilityReason;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookSinkAvailablityStatusChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_sinkID_t testID = TEST_ID_1;
+
+ am_gen::am_Availability_s available(am_gen::am_Availability_e::A_MAX, am_gen::am_AvailabilityReason_e::AR_MAX);
+ am_Availability_s amAvailable;
+ CAmConvertCAPI2AM(available, amAvailable);
+
+ EXPECT_CALL(*env->mpRoutingReceive, hookSinkAvailablityStatusChange(testID, IsAvailabilityEqualTo(amAvailable))).Times(1);
+ env->mProxy->hookSinkAvailablityStatusChange(testID, available, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookSourceAvailablityStatusChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_sourceID_t testID = TEST_ID_1;
+
+ am_gen::am_Availability_s available(am_gen::am_Availability_e::A_MAX, am_gen::am_AvailabilityReason_e::AR_MAX);
+ am_Availability_s amAvailable;
+ CAmConvertCAPI2AM(available, amAvailable);
+
+ EXPECT_CALL(*env->mpRoutingReceive, hookSourceAvailablityStatusChange(testID, IsAvailabilityEqualTo(amAvailable))).Times(1);
+ env->mProxy->hookSourceAvailablityStatusChange(testID, available, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookDomainStateChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_domainID_t testID = TEST_ID_1;
+ am_gen::am_DomainState_e domainState = am_gen::am_DomainState_e::DS_MAX;
+ EXPECT_CALL(*env->mpRoutingReceive, hookDomainStateChange(testID, (am_DomainState_e)domainState)).Times(1);
+ env->mProxy->hookDomainStateChange(testID, domainState, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookTimingInformationChanged)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_connectionID_t testID = TEST_ID_1;
+ int16_t delay = 10;
+ am_gen::am_DomainState_e domainState = am_gen::am_DomainState_e::DS_MAX;
+ EXPECT_CALL(*env->mpRoutingReceive, hookTimingInformationChanged(testID, delay)).Times(1);
+ env->mProxy->hookTimingInformationChanged(testID, delay, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+MATCHER_P(IsSinkEarlyDataEqualTo, value, "") {
+
+ std::vector<am_EarlyData_s> lh = arg;
+ bool result = lh.size() == value.size();
+ for(int i=0; result && i<lh.size(); i++)
+ {
+ am_EarlyData_s ed_lh = lh.at(i);
+ am_EarlyData_s ed_rh = value.at(i);
+ if(ed_lh.type != ed_rh.type)
+ {
+ result = false;
+ break;
+ }
+ else
+ {
+ if(ed_lh.type==ED_SINK_VOLUME)
+ {
+ result &= ed_lh.data.volume == ed_rh.data.volume;
+ result &= ed_lh.sinksource.sink == ed_rh.sinksource.sink;
+ }
+ else if(ed_lh.type==ED_SINK_PROPERTY)
+ {
+ result &= ed_lh.data.soundProperty.type == ed_rh.data.soundProperty.type;
+ result &= ed_lh.data.soundProperty.value == ed_rh.data.soundProperty.value;
+ result &= ed_lh.sinksource.sink == ed_rh.sinksource.sink;
+ }
+ else
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+
+ return result;
+}
+
+MATCHER_P(IsSourceEarlyDataEqualTo, value, "") {
+
+ std::vector<am_EarlyData_s> lh = arg;
+ bool result = lh.size() == value.size();
+ for(int i=0; result && i<lh.size(); i++)
+ {
+ am_EarlyData_s ed_lh = lh.at(i);
+ am_EarlyData_s ed_rh = value.at(i);
+ if(ed_lh.type != ed_rh.type)
+ {
+ result = false;
+ break;
+ }
+ else
+ {
+ if(ed_lh.type==ED_SOURCE_VOLUME)
+ {
+ result &= ed_lh.data.volume == ed_rh.data.volume;
+ result &= ed_lh.sinksource.source == ed_rh.sinksource.source;
+ }
+ else if(ed_lh.type==ED_SOURCE_PROPERTY)
+ {
+ result &= ed_lh.data.soundProperty.type == ed_rh.data.soundProperty.type;
+ result &= ed_lh.data.soundProperty.value == ed_rh.data.soundProperty.value;
+ result &= ed_lh.sinksource.source == ed_rh.sinksource.source;
+ }
+ else
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+
+ return result;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, sendChangedData)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_connectionID_t testID = TEST_ID_1;
+ am_gen::am_EarlyData_l earlyData_soundproperties;
+ am_gen::am_EarlyData_l earlyData_volumes;
+
+ am_gen::am_DataType_u dt11(static_cast<am_gen::am_sinkID_t>(103));
+ am_gen::am_EarlyData_u ed11(static_cast<am_gen::am_volume_t>(50));
+ earlyData_volumes.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SINK_VOLUME,
+ dt11,
+ ed11));
+ am_gen::am_DataType_u dt12(static_cast<am_gen::am_sinkID_t>(104));
+ earlyData_volumes.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SINK_VOLUME,
+ dt12,
+ ed11));
+
+ am_gen::am_DataType_u dt13(static_cast<am_gen::am_sinkID_t>(105));
+ am_gen::am_EarlyData_u ed12(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_MAX, 50));
+ earlyData_soundproperties.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SINK_PROPERTY,
+ dt13,
+ ed12));
+ am_gen::am_DataType_u dt14(static_cast<am_gen::am_sinkID_t>(106));
+ earlyData_soundproperties.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SINK_PROPERTY,
+ dt14,
+ ed12));
+
+ std::vector<am_EarlyData_s> earlyData;
+ am_EarlyData_s amEarlyData11;
+ amEarlyData11.type = am_EarlyDataType_e::ED_SINK_VOLUME;
+ amEarlyData11.data.volume = 50;
+ amEarlyData11.sinksource.sink = 103;
+ earlyData.push_back(amEarlyData11);
+ amEarlyData11.sinksource.sink = 104;
+ earlyData.push_back(amEarlyData11);
+
+ am_EarlyData_s amEarlyData12;
+ amEarlyData12.type = am_EarlyDataType_e::ED_SINK_PROPERTY;
+ amEarlyData12.sinksource.sink = 105;
+ amEarlyData12.data.soundProperty = (am_SoundProperty_s){SP_MAX, 50};
+ earlyData.push_back(amEarlyData12);
+ amEarlyData12.sinksource.sink = 106;
+ earlyData.push_back(amEarlyData12);
+
+ EXPECT_CALL(*env->mpRoutingReceive, sendChangedData(IsSinkEarlyDataEqualTo(earlyData))).Times(1);
+
+ env->mProxy->sendChangedData(earlyData_volumes, earlyData_soundproperties, callStatus);
+
+ earlyData_soundproperties.clear();
+ earlyData_volumes.clear();
+ earlyData.clear();
+
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+
+ am_gen::am_DataType_u dt21(static_cast<am_gen::am_sourceID_t>(103));
+ am_gen::am_EarlyData_u ed21(static_cast<am_gen::am_volume_t>(50));
+ earlyData_volumes.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SOURCE_VOLUME,
+ dt21,
+ ed21));
+ am_gen::am_DataType_u dt22(static_cast<am_gen::am_sourceID_t>(104));
+ earlyData_volumes.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SOURCE_VOLUME,
+ dt22,
+ ed21));
+
+ am_gen::am_DataType_u dt23(static_cast<am_gen::am_sourceID_t>(105));
+ am_gen::am_EarlyData_u ed22(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_MAX, 50));
+ earlyData_soundproperties.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SOURCE_PROPERTY,
+ dt23,
+ ed22));
+ am_gen::am_DataType_u dt24(static_cast<am_gen::am_sourceID_t>(106));
+ earlyData_soundproperties.push_back(am_gen::am_EarlyData_s(am_gen::am_EarlyDataType_e::ED_SOURCE_PROPERTY,
+ dt24,
+ ed22));
+
+ am_EarlyData_s amEarlyData21;
+ amEarlyData21.type = am_EarlyDataType_e::ED_SOURCE_VOLUME;
+ amEarlyData21.data.volume = 50;
+ amEarlyData21.sinksource.sink = 103;
+ earlyData.push_back(amEarlyData21);
+ amEarlyData21.sinksource.sink = 104;
+ earlyData.push_back(amEarlyData21);
+
+ am_EarlyData_s amEarlyData22;
+ amEarlyData22.type = am_EarlyDataType_e::ED_SOURCE_PROPERTY;
+ amEarlyData22.sinksource.sink = 105;
+ amEarlyData22.data.soundProperty = (am_SoundProperty_s){SP_MAX, 50};
+ earlyData.push_back(amEarlyData22);
+ amEarlyData22.sinksource.sink = 106;
+ earlyData.push_back(amEarlyData22);
+
+ EXPECT_CALL(*env->mpRoutingReceive, sendChangedData(IsSourceEarlyDataEqualTo(earlyData))).Times(1);
+
+ env->mProxy->sendChangedData(earlyData_volumes, earlyData_soundproperties, callStatus);
+
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, confirmRoutingReady)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_domainID_t testID = TEST_ID_1;
+ EXPECT_CALL(*env->mpRoutingReceive, confirmRoutingReady(10, error)).Times(1);
+ env->mProxy->confirmRoutingReady(testID, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, confirmRoutingRundown)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_domainID_t testID = TEST_ID_1;
+ EXPECT_CALL(*env->mpRoutingReceive, confirmRoutingRundown(10, error)).Times(1);
+ env->mProxy->confirmRoutingRundown(testID, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, updateGateway)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_gatewayID_t testID = TEST_ID_1;
+
+ am_gen::am_ConnectionFormat_L listSourceFormats;
+ listSourceFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+ listSourceFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_AUTO);
+
+ am_gen::am_ConnectionFormat_L listSinkFormats;
+ listSinkFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_AUTO);
+ listSinkFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+
+ am_gen::bool_L convertionMatrix;
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+
+ std::vector<am_ConnectionFormat_e> am_listSourceFormats;
+ am_listSourceFormats.push_back(am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+ am_listSourceFormats.push_back(am_ConnectionFormat_e::CF_GENIVI_AUTO);
+
+ std::vector<am_ConnectionFormat_e> am_listSinkFormats;
+ am_listSinkFormats.push_back(am_ConnectionFormat_e::CF_GENIVI_AUTO);
+ am_listSinkFormats.push_back(am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+
+ std::vector<bool> am_convertionMatrix;
+ am_convertionMatrix.push_back(1);
+ am_convertionMatrix.push_back(0);
+ ON_CALL(*env->mpRoutingReceive, updateGateway(_, _, _, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, updateGateway(testID, am_listSourceFormats, am_listSinkFormats, am_convertionMatrix)).Times(1);
+
+ env->mProxy->updateGateway(testID, listSourceFormats, listSinkFormats, convertionMatrix, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+MATCHER_P(IsSoundPropertiesArrayEqualTo, value, "") {
+ auto lh = arg;
+
+ bool bSoundProperties = lh.size() == value.size();
+ for(int i=0; i<lh.size(); i++)
+ {
+ bSoundProperties &= (lh.at(i).type==value.at(i).type &&
+ lh.at(i).value==value.at(i).value);
+ }
+ return bSoundProperties;
+}
+
+void prepareArrays( am_gen::am_SoundProperty_L & listSoundProperties,
+ am_gen::am_ConnectionFormat_L & listSinkFormats,
+ am_gen::am_MainSoundProperty_L & listMainSoundProperties,
+ std::vector<am_ConnectionFormat_e> & am_listSinkFormats,
+ std::vector<am_SoundProperty_s> & am_listSoundProperties,
+ std::vector<am_MainSoundProperty_s> & am_listMainSoundProperties)
+{
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_MAX, 50));
+ listSoundProperties.push_back(am_gen::am_SoundProperty_s(am_gen::am_SoundPropertyType_e::SP_MAX, 51));
+
+ listSinkFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_AUTO);
+ listSinkFormats.push_back(am_gen::am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+
+ listMainSoundProperties.push_back(am_gen::am_MainSoundProperty_s(am_gen::am_MainSoundPropertyType_e::MSP_MAX, 50));
+ listMainSoundProperties.push_back(am_gen::am_MainSoundProperty_s(am_gen::am_MainSoundPropertyType_e::MSP_MAX, 51));
+
+ am_listSinkFormats.push_back(am_ConnectionFormat_e::CF_GENIVI_AUTO);
+ am_listSinkFormats.push_back(am_ConnectionFormat_e::CF_GENIVI_ANALOG);
+
+ am_listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_MAX, 50});
+ am_listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_MAX, 51});
+
+ am_listMainSoundProperties.push_back((am_MainSoundProperty_s){am_MainSoundPropertyType_e::MSP_MAX, 50});
+ am_listMainSoundProperties.push_back((am_MainSoundProperty_s){am_MainSoundPropertyType_e::MSP_MAX, 51});
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, updateSink)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_sinkID_t testID = TEST_ID_1;
+
+ am_gen::am_SoundProperty_L listSoundProperties;
+ am_gen::am_ConnectionFormat_L listSinkFormats;
+ am_gen::am_MainSoundProperty_L listMainSoundProperties;
+ std::vector<am_ConnectionFormat_e> am_listSinkFormats;
+ std::vector<am_SoundProperty_s> am_listSoundProperties;
+ std::vector<am_MainSoundProperty_s> am_listMainSoundProperties;
+ prepareArrays(listSoundProperties, listSinkFormats, listMainSoundProperties, am_listSinkFormats, am_listSoundProperties, am_listMainSoundProperties);
+
+ ON_CALL(*env->mpRoutingReceive, updateSink(_, _, _, _, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, updateSink(testID, TEST_ID_2, IsSoundPropertiesArrayEqualTo(am_listSoundProperties), am_listSinkFormats, IsSoundPropertiesArrayEqualTo(am_listMainSoundProperties))).Times(1);
+ env->mProxy->updateSink(testID, TEST_ID_2, listSoundProperties, listSinkFormats, listMainSoundProperties, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, updateSource)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_sourceID_t testID = TEST_ID_1;
+
+ am_gen::am_SoundProperty_L listSoundProperties;
+ am_gen::am_ConnectionFormat_L listSinkFormats;
+ am_gen::am_MainSoundProperty_L listMainSoundProperties;
+ std::vector<am_ConnectionFormat_e> am_listSinkFormats;
+ std::vector<am_SoundProperty_s> am_listSoundProperties;
+ std::vector<am_MainSoundProperty_s> am_listMainSoundProperties;
+ prepareArrays(listSoundProperties, listSinkFormats, listMainSoundProperties, am_listSinkFormats, am_listSoundProperties, am_listMainSoundProperties);
+
+ ON_CALL(*env->mpRoutingReceive, updateSource(_, _, _, _, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, updateSource(testID, TEST_ID_2, IsSoundPropertiesArrayEqualTo(am_listSoundProperties), am_listSinkFormats, IsSoundPropertiesArrayEqualTo(am_listMainSoundProperties))).Times(1);
+ env->mProxy->updateSource(testID, TEST_ID_2, listSoundProperties, listSinkFormats, listMainSoundProperties, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+
+MATCHER_P2(IsSinkVolumeArrayEqualTo, value, isSink, "") {
+
+ std::vector<am_Volumes_s> lh = arg;
+ bool bResult = lh.size() == value.size();
+ for(int i=0; i<lh.size(); i++)
+ {
+ bResult &= (((isSink && lh.at(i).volumeID.sink==value.at(i).volumeID.sink) || (!isSink && lh.at(i).volumeID.source==value.at(i).volumeID.source)) &&
+ lh.at(i).volume==value.at(i).volume &&
+ lh.at(i).ramp==value.at(i).ramp &&
+ lh.at(i).time==value.at(i).time);
+ }
+ return bResult;
+}
+
+MATCHER_P(IsHandleStructEqualTo, value, "") {
+ am_Handle_s lh = arg;
+ return lh.handle==value.handle &&
+ lh.handleType==value.handleType ;
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSetVolumes)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ uint16_t error = (uint16_t)E_OK;
+ uint16_t testID = 10;
+ am_gen::am_Volumes_l listVolumes;
+ am_gen::am_DataType_u dt(static_cast<am_gen::am_sinkID_t>(103));
+ listVolumes.push_back(am_gen::am_Volumes_s(am_gen::am_VolumeType_e::VT_MAX,
+ dt,
+ 50,
+ am_gen::am_RampType_e::RAMP_GENIVI_DIRECT,
+ 50));
+
+ std::vector<am_Volumes_s> am_listVolumes;
+ am_DataType_u dt1;
+ dt1.sink = 103;
+ am_listVolumes.push_back((am_Volumes_s){am_VolumeType_e::VT_MAX,
+ dt1,
+ 50,
+ am_RampType_e::RAMP_GENIVI_DIRECT,
+ 50});
+
+ am_Handle_s handle_s;
+ handle_s.handle = 10;
+ handle_s.handleType = H_SETVOLUMES;
+
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetVolumes(IsHandleStructEqualTo(handle_s), IsSinkVolumeArrayEqualTo(am_listVolumes, true), _)).Times(1);
+ env->mProxy->ackSetVolumes(testID, listVolumes, error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSinkNotificationConfiguration)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_OK;
+ uint16_t testID = TEST_ID_1;
+ am_Handle_s handle_s;
+ handle_s.handle = testID;
+ handle_s.handleType = H_CONNECT;
+ EXPECT_CALL(*env->mpRoutingReceive, ackSinkNotificationConfiguration(IsHandleStructEqualTo(handle_s), (am_Error_e)error)).Times(1);
+ env->mProxy->ackSinkNotificationConfiguration(testID, (uint16_t)error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, ackSourceNotificationConfiguration)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_OK;
+ uint16_t testID = TEST_ID_1;
+ am_Handle_s handle_s;
+ handle_s.handle = testID;
+ handle_s.handleType = H_CONNECT;
+ EXPECT_CALL(*env->mpRoutingReceive, ackSourceNotificationConfiguration(IsHandleStructEqualTo(handle_s), (am_Error_e)error)).Times(1);
+ env->mProxy->ackSourceNotificationConfiguration(testID, (uint16_t)error, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+MATCHER_P(IsPayloadEqualTo, value, "") {
+
+ auto lh = arg;
+ return lh.type == value.type && lh.value == value.value;
+}
+
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookSinkNotificationDataChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_sinkID_t testID = TEST_ID_1;
+ am_gen::notificationPayload_s payload(am_NotificationType_e::NT_MAX, 50);
+
+ am_NotificationPayload_s am_payload = (am_NotificationPayload_s){am_NotificationType_e::NT_MAX, 50};
+
+ EXPECT_CALL(*env->mpRoutingReceive, hookSinkNotificationDataChange(testID, IsPayloadEqualTo(am_payload))).Times(1);
+ env->mProxy->hookSinkNotificationDataChange(testID, payload, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingInterfaceCAPITests, hookSourceNotificationDataChange)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_Error_e error = E_OK;
+ am_gen::am_sourceID_t testID = TEST_ID_1;
+ am_gen::notificationPayload_s payload(am_NotificationType_e::NT_MAX, 50);
+
+ am_NotificationPayload_s am_payload = (am_NotificationPayload_s){am_NotificationType_e::NT_MAX, 50};
+
+ EXPECT_CALL(*env->mpRoutingReceive, hookSourceNotificationDataChange(testID, IsPayloadEqualTo(am_payload))).Times(1);
+ env->mProxy->hookSourceNotificationDataChange(testID, payload, callStatus);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+ACTION(actionRegister2){
+ arg1=TEST_ID_2;
+}
+
+
+/** CAmRoutingSenderCAPITests
+ * The following methods must be executed in the given order.
+ * It is important that the TestDomain_register* methods are executed first because they make domain, sink, source and crossfader registrations.
+ * The last couple of methods are TestDomain_deregister* methods which check whether the 'deregistration' functionality works properly.
+ */
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_registerDomain)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_FALSE( backdoor.containsDomainWithID( (const am_domainID_t)TEST_ID_1) );
+
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_domainID_t domainID = 0;
+ am_gen::am_Domain_s domainData;
+ domainData.name = "TestDomain";
+ domainData.busname ="TestDomain";
+ domainData.complete = true;
+ domainData.domainID = domainID;
+ domainData.early = false;
+ domainData.nodename = "Test";
+ domainData.state = am_gen::am_DomainState_e::DS_CONTROLLED;
+
+ am::am_Domain_s amDomainData;
+ CAmConvertCAPI2AM(domainData, amDomainData);
+
+ ON_CALL(*env->mpRoutingReceive, registerDomain(_, _)).WillByDefault(Return(E_OK));
+
+ EXPECT_CALL(*env->mpRoutingReceive, registerDomain(IsDomainDataEqualTo(amDomainData), _)).WillOnce(DoAll(actionRegister(), Return(E_OK)));
+ env->mProxy->registerDomain(domainData,
+ CAPI_SENDER_INSTANCE,
+ CAPI_SENDER_PATH,
+ CAPI_SENDER_INTERFACE,
+ callStatus,
+ domainID,
+ error);
+ usleep(50000);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( domainID, TEST_ID_1 );
+ ASSERT_TRUE( backdoor.containsDomainWithID(domainID) );
+
+ domainID = 0;
+ domainData.domainID = 0;
+ domainData.name = "TestDomain2";
+ domainData.busname ="TestDomain2";
+ CAmConvertCAPI2AM(domainData, amDomainData);
+ EXPECT_CALL(*env->mpRoutingReceive, registerDomain(IsDomainDataEqualTo(amDomainData), _)).WillOnce(DoAll(actionRegister2(), Return(E_OK)));
+ env->mProxy->registerDomain(domainData,
+ CAPI_SENDER_INSTANCE,
+ CAPI_SENDER_PATH,
+ CAPI_SENDER_INTERFACE,
+ callStatus,
+ domainID,
+ error);
+ usleep(50000);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( domainID, TEST_ID_2 );
+ ASSERT_TRUE( backdoor.domainsCount()==2 );
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)TEST_ID_1) );
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)TEST_ID_2) );
+ ASSERT_FALSE( backdoor.containsDomainWithID( (const am_domainID_t)10000) );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_registerSource)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ am_gen::sourceData_s source;
+ am_Source_s amSource;
+ am_gen:am_sourceID_t sinkID = 0;
+ initSource(source, amSource, domainID, sinkID);
+
+ ON_CALL(*env->mpRoutingReceive, registerSource(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, registerSource(IsSourceDataEqualTo(amSource), _)).WillOnce(DoAll(actionRegister(), Return(E_OK)));
+ env->mProxy->registerSource(source, callStatus, sinkID, error);
+ usleep(50000);
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)TEST_ID_1) );
+
+ initSource(source, amSource, domainID, sinkID);
+ EXPECT_CALL(*env->mpRoutingReceive, registerSource(IsSourceDataEqualTo(amSource), _)).WillOnce(DoAll(actionRegister2(), Return(E_OK)));
+ env->mProxy->registerSource(source, callStatus, sinkID, error);
+ usleep(50000);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( sinkID, TEST_ID_2 );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)TEST_ID_2) );
+ ASSERT_TRUE( backdoor.sourcesCount()==2 );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_registerSink)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ am_gen::sinkData_s sink;
+ am_Sink_s amSink;
+ am_gen:am_sinkID_t sinkID = 0;
+ initSink(sink, amSink, domainID, sinkID);
+
+ ON_CALL(*env->mpRoutingReceive, registerSink(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, registerSink(IsSinkDataEqualTo(amSink), _)).WillOnce(DoAll(actionRegister(), Return(E_OK)));
+ env->mProxy->registerSink(sink, callStatus, sinkID, error);
+
+ usleep(50000);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( sinkID, TEST_ID_1 );
+ ASSERT_TRUE( backdoor.containsSinkWithID( (const am_sourceID_t)TEST_ID_1) );
+
+ initSink(sink, amSink, TEST_ID_1, 0);
+ EXPECT_CALL(*env->mpRoutingReceive, registerSink(IsSinkDataEqualTo(amSink), _)).WillOnce(DoAll(actionRegister2(), Return(E_OK)));
+ env->mProxy->registerSink(sink, callStatus, sinkID, error);
+
+ usleep(50000);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( sinkID, TEST_ID_2 );
+ ASSERT_TRUE( backdoor.containsSinkWithID( (const am_sourceID_t)TEST_ID_2) );
+ ASSERT_TRUE( backdoor.sinksCount()==2 );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_setDomainState)
+{
+//todo: Decide how to test
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSourceState)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sourceID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSOURCESTATE, 20};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceState(IsHandleEqual(handle), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSourceState(handle, sID, state);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSourceVolume)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sourceID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_volume_t volume = 50;
+ am_time_t time = 10;
+ am_RampType_e ramp = am_RampType_e::RAMP_GENIVI_DIRECT;
+ am_Handle_s handle = {H_SETSOURCEVOLUME, 20};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceVolumeChange(IsHandleEqual(handle), volume, E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSourceVolume(handle, sID, volume, ramp, time);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_registerCrossfader)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ am_gen::am_crossfaderID_t crossfaderID = 0;
+ am_gen::crossfaderData_s crossfaderData;
+ am_Crossfader_s amCrossfaderData;
+ initCrossfader(crossfaderData, amCrossfaderData, crossfaderID);
+
+ ON_CALL(*env->mpRoutingReceive, registerCrossfader(_, _)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, registerCrossfader(IsCrossfaderDataEqualTo(amCrossfaderData), _)).WillOnce(DoAll(actionRegister(), Return(E_OK)));
+ env->mProxy->registerCrossfader(crossfaderData, callStatus, crossfaderID, error);
+
+ usleep(50000);
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( crossfaderID, TEST_ID_1 );
+ ASSERT_TRUE( backdoor.containsCrossfader( TEST_ID_1) );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSinkVolume)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sinkID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_volume_t volume = 50;
+ am_time_t time = 10;
+ am_RampType_e ramp = am_RampType_e::RAMP_GENIVI_DIRECT;
+ am_Handle_s handle = {H_SETSINKVOLUME, 20};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSinkVolumeChange(IsHandleEqual(handle), volume, E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSinkVolume(handle, sID, volume, ramp, time);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncConnect)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+// const am_gen::am_domainID_t domainID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( TEST_ID_1 ));
+ ASSERT_TRUE( backdoor.containsSinkWithID( TEST_ID_1 ));
+ ASSERT_TRUE( backdoor.containsSourceWithID( TEST_ID_1 ));
+
+ am_gen::am_connectionID_t connectionID = TEST_ID_1;
+ am_Handle_s handle = {H_CONNECT, 20};
+ am_ConnectionFormat_e cf = am_ConnectionFormat_e::CF_GENIVI_STEREO;
+ EXPECT_CALL(*env->mpRoutingReceive, ackConnect(IsHandleEqual(handle), connectionID, E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncConnect(handle, connectionID, TEST_ID_1, TEST_ID_1, cf);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle ) );
+ ASSERT_EQ( backdoor.connectionsCount( ) , 1 );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncDisconnect)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( TEST_ID_1 ));
+ ASSERT_TRUE( backdoor.containsConnection( TEST_ID_1 ));
+
+ am_gen::am_connectionID_t connectionID = TEST_ID_1;
+ am_Handle_s handle = {H_DISCONNECT, 20};
+ am_ConnectionFormat_e cf = am_ConnectionFormat_e::CF_GENIVI_STEREO;
+ EXPECT_CALL(*env->mpRoutingReceive, ackDisconnect(IsHandleEqual(handle), connectionID, E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncDisconnect(handle, connectionID);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle ) );
+ ASSERT_FALSE( backdoor.containsConnection( TEST_ID_1 ) );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncAbort)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sourceID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_volume_t volume = 50;
+ am_Handle_s handle = {H_SETSOURCESTATE, 200};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+
+ //we set an abort handle in order to test the return status
+ env->mDomainService->setAbortHandle(handle.handle);
+
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceState(IsHandleEqual(handle), E_ABORTED)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSourceState(handle, sID, state);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+MATCHER_P(IsListMainSoundPropertiesEqualTo, value, "") {
+ auto lh = arg;
+
+ bool bMainSoundProperties = lh.size() == value.size();
+ for(int i=0; i<lh.size(); i++)
+ {
+ bMainSoundProperties &= (lh.at(i).type==value.at(i).type &&
+ lh.at(i).value==value.at(i).value);
+ }
+ return bMainSoundProperties;
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSinkSoundProperties)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sinkID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_Handle_s handle = {H_SETSINKSOUNDPROPERTIES, 200};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+
+ std::vector<am_SoundProperty_s> listSoundProperties;
+ listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_INTERR_OVERLAYID, 100});
+ listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_MAX, 101});
+ listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_PRIORITY, 100});
+
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSinkSoundProperties(IsHandleEqual(handle), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSinkSoundProperties(handle, sID, listSoundProperties);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSinkSoundProperty)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sinkID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_Handle_s handle = {H_SETSINKSOUNDPROPERTY, 200};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSinkSoundProperty(IsHandleEqual(handle), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSinkSoundProperty(handle, sID, (am_SoundProperty_s){am_SoundPropertyType_e::SP_INTERR_OVERLAYID, 100});
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSourceSoundProperties)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sourceID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_Handle_s handle = {H_SETSOURCESOUNDPROPERTIES, 200};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+
+ std::vector<am_SoundProperty_s> listSoundProperties;
+ listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_INTERR_OVERLAYID, 100});
+ listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_MAX, 101});
+ listSoundProperties.push_back((am_SoundProperty_s){am_SoundPropertyType_e::SP_PRIORITY, 100});
+
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceSoundProperties(IsHandleEqual(handle), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSourceSoundProperties(handle, sID, listSoundProperties);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSourceSoundProperty)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_domainID_t domainID = TEST_ID_1;
+ const am_gen::am_sourceID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( (const am_domainID_t)domainID) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( (const am_sourceID_t)sID) );
+
+ am_Handle_s handle = {H_SETSOURCESOUNDPROPERTY, 200};
+ am_SourceState_e state = am_SourceState_e::SS_MAX;
+
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetSourceSoundProperty(IsHandleEqual(handle), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSourceSoundProperty(handle, sID, (am_SoundProperty_s){am_SoundPropertyType_e::SP_INTERR_OVERLAYID, 100});
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncCrossFade)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ const am_gen::am_crossfaderID_t sID = TEST_ID_1;
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( TEST_ID_1 ));
+ ASSERT_TRUE( backdoor.containsSourceWithID( TEST_ID_1 ));
+ ASSERT_TRUE( backdoor.containsCrossfader( TEST_ID_1 ));
+
+ am_Handle_s handle = {H_CROSSFADE, 200};
+ am_RampType_e state = am_RampType_e::RAMP_GENIVI_DIRECT;
+ am_HotSink_e hotSink = HS_UNKNOWN;
+ EXPECT_CALL(*env->mpRoutingReceive, ackCrossFading(IsHandleEqual(handle), hotSink, E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncCrossFade(handle, sID, hotSink, state, 50);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSinkNotificationConfiguration)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( TEST_ID_1 ));
+ ASSERT_TRUE( backdoor.containsSinkWithID( TEST_ID_1 ));
+
+ am_Handle_s handle = {H_CONNECT, 200};
+ am_NotificationConfiguration_s nc = (am_NotificationConfiguration_s){am_NotificationType_e::NT_MAX, am_NotificationStatus_e::NS_MAX};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSinkNotificationConfiguration(IsHandleStructEqualTo(handle), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSinkNotificationConfiguration(handle, TEST_ID_1, nc);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetSourceNotificationConfiguration)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( TEST_ID_1 ));
+ ASSERT_TRUE( backdoor.containsSinkWithID( TEST_ID_1 ));
+
+ am_Handle_s handle = {H_CONNECT, 200};
+ am_NotificationConfiguration_s nc = (am_NotificationConfiguration_s){am_NotificationType_e::NT_MAX, am_NotificationStatus_e::NS_MAX};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSourceNotificationConfiguration(IsHandleStructEqualTo(handle), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetSourceNotificationConfiguration(handle, TEST_ID_1, nc);
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+ }
+
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_asyncSetVolumes)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( TEST_ID_1) );
+ ASSERT_TRUE( backdoor.containsSourceWithID( TEST_ID_1) );
+
+ am_gen::am_Volumes_l listVolumes;
+ am_gen::am_DataType_u dt(static_cast<am_gen::am_sourceID_t>(TEST_ID_1));
+ listVolumes.push_back(am_gen::am_Volumes_s(am_gen::am_VolumeType_e::VT_SOURCE,
+ dt,
+ 50,
+ am_gen::am_RampType_e::RAMP_GENIVI_DIRECT,
+ 50));
+
+ std::vector<am_Volumes_s> am_listVolumes;
+ am_DataType_u dt1;
+ dt1.source = TEST_ID_2;
+ am_listVolumes.push_back((am_Volumes_s){am_VolumeType_e::VT_SOURCE,
+ dt1,
+ 50,
+ am_RampType_e::RAMP_GENIVI_DIRECT,
+ 50});
+
+ am_Handle_s handle = {H_SETVOLUMES, 200};
+ EXPECT_CALL(*env->mpRoutingReceive, ackSetVolumes(IsHandleStructEqualTo(handle), IsSinkVolumeArrayEqualTo(am_listVolumes, false), E_OK)).Times(1);
+ am_Error_e error = env->mpPlugin->asyncSetVolumes(handle, am_listVolumes);
+
+ usleep(50000);
+ ASSERT_EQ( error, E_OK );
+ ASSERT_FALSE( backdoor.containsHandle( handle.handle) );
+
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_deregisterSink)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_sinkID_t sinkID = TEST_ID_2;
+
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsSinkWithID( sinkID ));
+
+ ON_CALL(*env->mpRoutingReceive, deregisterSink(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterSink(sinkID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterSink(sinkID, callStatus, error);
+ usleep(50000);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_FALSE( backdoor.containsSinkWithID( sinkID ));
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_deregisterSource)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_sourceID_t sID = TEST_ID_2;
+
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsSourceWithID( sID ));
+
+ ON_CALL(*env->mpRoutingReceive, deregisterSource(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterSource(sID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterSource(sID, callStatus, error);
+ usleep(50000);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_FALSE( backdoor.containsSourceWithID( sID ));
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_deregisterCrossfader)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+ am_gen:am_crossfaderID_t sID = TEST_ID_1;
+
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsCrossfader( sID ));
+
+ ON_CALL(*env->mpRoutingReceive, deregisterCrossfader(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterCrossfader(sID)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterCrossfader(sID, callStatus, error);
+ usleep(50000);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_FALSE( backdoor.containsCrossfader( sID ));
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
+
+TEST_F(CAmRoutingSenderCAPITests, TestDomain_deregisterDomain)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ IAmRoutingSenderBackdoor backdoor(env->mpPlugin);
+ ASSERT_TRUE( backdoor.containsDomainWithID( TEST_ID_2 ));
+ CallStatus callStatus = CallStatus::NOT_AVAILABLE;
+ am_gen::am_Error_e error = am_gen::am_Error_e::E_UNKNOWN;
+
+ ON_CALL(*env->mpRoutingReceive, deregisterDomain(_)).WillByDefault(Return(E_OK));
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterDomain(TEST_ID_2)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterDomain(TEST_ID_2, callStatus, error);
+ usleep(50000);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_EQ( backdoor.domainsCount(), 1 );
+ ASSERT_FALSE( backdoor.containsDomainWithID( TEST_ID_2 ));
+
+ EXPECT_CALL(*env->mpRoutingReceive, deregisterDomain(TEST_ID_1)).WillOnce(Return(E_OK));
+ env->mProxy->deregisterDomain(TEST_ID_1, callStatus, error);
+ usleep(50000);
+ ASSERT_EQ( error, am_gen::am_Error_e::E_OK );
+ ASSERT_EQ( callStatus, CallStatus::SUCCESS );
+ ASSERT_FALSE( backdoor.containsDomainWithID( TEST_ID_1 ));
+ ASSERT_EQ( backdoor.domainsCount(), 0 );
+ ASSERT_EQ( backdoor.sourcesCount(), 0 );
+ ASSERT_EQ( backdoor.sinksCount(), 0 );
+ ASSERT_EQ( backdoor.crossfadersCount(), 0 );
+ ASSERT_EQ( backdoor.connectionsCount(), 0 );
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpRoutingReceive));
+}
diff --git a/PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.h b/PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.h
new file mode 100644
index 0000000..ee7cc1d
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/CAmRoutingInterfaceCAPITests.h
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+
+#ifndef ROUTINGINTERFACETEST_H_
+#define ROUTINGINTERFACETEST_H_
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "shared/CAmSocketHandler.h"
+#include "CAmTestCAPIWrapper.h"
+#include "../include/CAmRoutingSenderCAPI.h"
+#include "MockIAmRoutingReceive.h"
+#include <../src-gen/org/genivi/audiomanager/RoutingInterfaceProxy.h>
+
+#define UNIT_TEST 1
+
+using namespace testing;
+using namespace CommonAPI;
+namespace am {
+
+using namespace org::genivi::audiomanager;
+
+class CAmCommandSenderDbusBackdoor;
+class IAmCommandSend;
+class CAmRoutingSenderService;
+
+/** Global test environment which sets the routing interface service and test domain service for all tests.
+ * The tests are executed after the connection have been successful established.
+ * If the connection is not available for some reason all tests will fail.
+ */
+class CAmTestsEnvironment : public ::testing::Environment
+{
+ pthread_t mListenerThread; ///< supporting sync thread
+ pthread_t mServicePThread; ///< plugin's thread
+ pthread_t mClientPThread; ///< thread for the routing interface proxy and test domain stub
+
+public:
+ bool mIsProxyInitilized;
+ bool mIsServiceAvailable;
+ bool mIsDomainAvailable;
+ CAmSocketHandler *mSocketHandlerService;
+ CAmSocketHandler *mSocketHandlerClient;
+ MockIAmRoutingReceive *mpRoutingReceive;
+ CAmRoutingSenderCAPI *mpPlugin;
+
+ std::shared_ptr<RoutingInterfaceProxy<>> mProxy; ///< pointer to routing interface proxy
+ std::shared_ptr<CAmRoutingSenderService> mDomainService; ///< pointer to the test domain service
+
+ CAmTestsEnvironment();
+ ~CAmTestsEnvironment();
+ void SetUp();
+ // Override this to define how to tear down the environment.
+ void TearDown();
+ void onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus);
+};
+
+/**
+ * Common tests - types and calls matching
+ */
+class CAmRoutingInterfaceCAPITests :public ::testing::Test
+{
+
+public:
+ CAmRoutingInterfaceCAPITests();
+ ~CAmRoutingInterfaceCAPITests();
+
+ void SetUp();
+ void TearDown();
+
+};
+
+/**
+ * Domain tests - connection to domain, registrations, deregistrations, lookups.
+ */
+class CAmRoutingSenderCAPITests :public ::testing::Test
+{
+
+public:
+ CAmRoutingSenderCAPITests();
+ ~CAmRoutingSenderCAPITests();
+
+ void SetUp();
+ void TearDown();
+
+};
+
+}
+
+#endif /* ROUTINGINTERFACETEST_H_ */
diff --git a/PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.cpp b/PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.cpp
new file mode 100644
index 0000000..3f2c7b3
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.cpp
@@ -0,0 +1,225 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#include <stdint.h>
+#include <limits.h>
+#include "shared/CAmCommonAPIWrapper.h"
+#include "shared/CAmDltWrapper.h"
+#include "CAmRoutingSenderService.h"
+
+
+namespace am {
+
+#define CAPI_SENDER_ADDRESS "local:" CAPI_SENDER_INTERFACE ":" CAPI_SENDER_INSTANCE
+#define CAPI_ROUTING_ADDRESS "local:" CAPI_ROUTING_INTERFACE ":" CAPI_ROUTING_INSTANCE
+
+const char * CAmRoutingSenderService::ROUTING_SENDER_SERVICE = CAPI_SENDER_ADDRESS;
+const char * CAmRoutingSenderService::ROUTING_INTERFACE_SERVICE = CAPI_ROUTING_ADDRESS;
+
+CAmRoutingSenderService::CAmRoutingSenderService(CAmCommonAPIWrapper * aWrapper):
+ mDomainData(), mAbortedHandle(UINT_MAX), mIsDomainRegistred(false), mIsServiceAvailable(0), mIsReady(0), mpWrapper(aWrapper), mRoutingInterfaceProxy(NULL)
+{
+
+}
+
+CAmRoutingSenderService::CAmRoutingSenderService():
+ mDomainData(), mAbortedHandle(UINT_MAX), mIsDomainRegistred(false), mIsServiceAvailable(0), mIsReady(0), mpWrapper(NULL), mRoutingInterfaceProxy(NULL) {
+ // TODO Auto-generated constructor stub
+
+}
+
+CAmRoutingSenderService::CAmRoutingSenderService(CAmCommonAPIWrapper * aWrapper, std::shared_ptr<RoutingInterfaceProxy<> > aProxy):
+ mDomainData(), mAbortedHandle(UINT_MAX), mIsDomainRegistred(false), mIsServiceAvailable(0), mIsReady(0), mpWrapper(aWrapper), mRoutingInterfaceProxy(aProxy)
+{
+ mRoutingInterfaceProxy->getProxyStatusEvent().subscribe(std::bind(&CAmRoutingSenderService::onServiceStatusEvent,this,std::placeholders::_1));
+ mRoutingInterfaceProxy->getSetRoutingReadyEvent().subscribe(std::bind(&CAmRoutingSenderService::onRoutingReadyEvent,this));
+ mRoutingInterfaceProxy->getSetRoutingRundownEvent().subscribe(std::bind(&CAmRoutingSenderService::onRoutingReadyRundown,this));
+}
+
+CAmRoutingSenderService::~CAmRoutingSenderService() {
+ mpWrapper = NULL;
+ if(mRoutingInterfaceProxy)
+ mRoutingInterfaceProxy.reset();
+}
+
+void CAmRoutingSenderService::onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus)
+{
+ logInfo(__PRETTY_FUNCTION__);
+ std::stringstream avail;
+ avail << "(" << static_cast<int>(serviceStatus) << ")";
+ logInfo("Domain test service status changed to ", avail.str());
+ std::cout << std::endl << "Domain test service status changed to " << avail.str() << std::endl;
+ if(serviceStatus==CommonAPI::AvailabilityStatus::AVAILABLE)
+ {
+ mIsServiceAvailable = true;
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->getRoutingReadyState(callStatus, mIsReady);
+ }
+ else
+ {
+ mIsDomainRegistred = false;
+ mIsServiceAvailable = false;
+ mIsReady = false;
+ }
+}
+
+void CAmRoutingSenderService::onRoutingReadyEvent()
+{
+ logInfo(__PRETTY_FUNCTION__);
+ mIsReady = true;
+}
+
+void CAmRoutingSenderService::onRoutingReadyRundown()
+{
+ logInfo(__PRETTY_FUNCTION__);
+ mIsReady = true;
+ mIsDomainRegistred = false;
+}
+
+void CAmRoutingSenderService::setAbortHandle(uint16_t handle)
+{
+ mAbortedHandle = handle;
+}
+
+void CAmRoutingSenderService::registerDomain()
+{
+ if( mIsDomainRegistred || !mIsServiceAvailable || !mIsReady )
+ return;
+ mIsDomainRegistred = true;
+ logInfo(__PRETTY_FUNCTION__,"start registering Domain...");
+ am_gen::am_Error_e error;
+ mDomainData.name = "TestDomain";
+ mDomainData.busname ="TestDomain";
+ mDomainData.complete = true;
+ mDomainData.domainID = 0;
+ mDomainData.early = false;
+ mDomainData.nodename = "Test";
+ mDomainData.state = am_gen::am_DomainState_e::DS_CONTROLLED;
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->registerDomain(mDomainData,
+ CAPI_SENDER_INSTANCE,
+ CAPI_SENDER_PATH,
+ CAPI_SENDER_INTERFACE,
+ callStatus,
+ mDomainData.domainID,
+ error);
+ logInfo("Domain: got domainID", mDomainData.domainID);
+}
+
+uint16_t CAmRoutingSenderService::errorForHandle(const uint16_t & handle)
+{
+ uint16_t error = E_OK;
+ if(handle==mAbortedHandle && mAbortedHandle!=UINT_MAX)
+ {
+ error = (uint16_t)am_gen::am_Error_e::E_ABORTED;
+ mAbortedHandle = UINT_MAX;
+ }
+ return error;
+}
+
+void CAmRoutingSenderService::asyncSetSourceState(uint16_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SourceState_e sourceState) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetSourceState(handle, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::setDomainState(am_gen::am_domainID_t domainID, am_gen::am_DomainState_e domainState, am_gen::am_Error_e& error) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ error = am_gen::am_Error_e::E_OK;
+ mRoutingInterfaceProxy->hookDomainStateChange(domainID, domainState, callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetSourceVolume(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_volume_t volume, am_gen::am_RampType_e ramp, am_gen::am_time_t time) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetSourceVolume(handle, volume, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetSinkVolume(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_volume_t volume, am_gen::am_RampType_e ramp, am_gen::am_time_t time) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetSinkVolume(handle, volume, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncConnect(am_gen::am_handle_t handle, am_gen::am_connectionID_t connectionID, am_gen::am_sourceID_t sourceID, am_gen::am_sinkID_t sinkID, am_gen::am_ConnectionFormat_e connectionFormat) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackConnect(handle, connectionID, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncDisconnect(am_gen::am_handle_t handle, am_gen::am_connectionID_t connectionID) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackDisconnect(handle, connectionID, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncAbort(am_gen::am_handle_t handle, am_gen::am_Error_e& error) {
+ logInfo(__FUNCTION__, " called");
+ mAbortedHandle = handle;
+ error = am_gen::am_Error_e::E_OK;
+}
+
+void CAmRoutingSenderService::asyncSetSinkSoundProperties(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_SoundProperty_L listSoundProperties) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetSinkSoundProperties(handle, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetSinkSoundProperty(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_SoundProperty_s soundProperty) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetSinkSoundProperty(handle, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetSourceSoundProperties(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SoundProperty_L listSoundProperties) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetSourceSoundProperties(handle, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetSourceSoundProperty(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SoundProperty_s soundProperty) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetSourceSoundProperty(handle, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncCrossFade(am_gen::am_handle_t handle, am_gen::am_crossfaderID_t crossfaderID, am_gen::am_HotSink_e hotSink, am_gen::am_RampType_e rampType, am_gen::am_time_t time) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackCrossFading(handle, hotSink, (am_gen::am_Error_e)errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetVolumes(am_gen::am_handle_t handle, am_gen::am_Volumes_l volumes) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSetVolumes(handle, volumes, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetSinkNotificationConfiguration(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_NotificationConfiguration_s notificationConfiguration) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSinkNotificationConfiguration(handle, errorForHandle(handle), callStatus);
+}
+
+void CAmRoutingSenderService::asyncSetSourceNotificationConfiguration(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_NotificationConfiguration_s notificationConfiguration) {
+ logInfo(__FUNCTION__, " called");
+ CommonAPI::CallStatus callStatus;
+ mRoutingInterfaceProxy->ackSourceNotificationConfiguration(handle, errorForHandle(handle), callStatus);
+}
+
+} /* namespace org */
diff --git a/PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.h b/PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.h
new file mode 100644
index 0000000..36ae646
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/CAmRoutingSenderService.h
@@ -0,0 +1,112 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#ifndef CAMROUTINGSENDERSERVICE_H_
+#define CAMROUTINGSENDERSERVICE_H_
+
+#include "audiomanagertypes.h"
+#include <org/genivi/audiomanager/RoutingSenderStubDefault.h>
+#include <org/genivi/audiomanager/RoutingInterfaceProxy.h>
+
+/**
+ * GENERATED FROM CMAKE. PLEASE USE cmake/CAmRoutingSenderService.h.in IF YOU WANT TO MAKE CHANGES.
+ */
+
+namespace am {
+
+using namespace CommonAPI;
+using namespace org::genivi::audiomanager;
+
+class CAmCommonAPIWrapper;
+
+/**
+ * THE FOLLOWING DEFINES ARE POPULATED FROM THE CMAKELISTS.TXT .
+ */
+#define CAPI_SENDER_INTERFACE "org.genivi.audiomanger.routingsender"
+#define CAPI_SENDER_INSTANCE "org.genivi.routingsender"
+#define CAPI_SENDER_PATH "/org/genivi/audiomanger/routingsender"
+
+#define CAPI_ROUTING_INTERFACE "org.genivi.audiomanger.routinginterface"
+#define CAPI_ROUTING_INSTANCE "org.genivi.audiomanger"
+#define CAPI_ROUTING_PATH "/org/genivi/audiomanger/routinginterface"
+
+
+/** Test class implementing the routing sender service.
+*
+* Please see cmake/CAmRoutingSenderService.h.in
+*/
+class CAmRoutingSenderService : public RoutingSenderStubDefault {
+
+ am_gen::am_Domain_s mDomainData;
+ uint16_t mAbortedHandle;
+ bool mIsServiceAvailable;
+ bool mIsDomainRegistred;
+ bool mIsReady;
+ CAmCommonAPIWrapper *mpWrapper;
+ std::shared_ptr<RoutingInterfaceProxy<> > mRoutingInterfaceProxy;
+
+public:
+
+ CAmRoutingSenderService();
+ CAmRoutingSenderService(CAmCommonAPIWrapper * aWrapper);
+ CAmRoutingSenderService(CAmCommonAPIWrapper * aWrapper, std::shared_ptr<RoutingInterfaceProxy<> > aProxy);
+ virtual ~CAmRoutingSenderService();
+
+ void onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus);
+ void onRoutingReadyRundown();
+ void onRoutingReadyEvent();
+ void registerDomain();
+ void setAbortHandle(uint16_t handle);
+ uint16_t errorForHandle(const uint16_t & handle);
+
+ virtual void asyncSetSourceState(uint16_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SourceState_e sourceState);
+
+ virtual void setDomainState(am_gen::am_domainID_t domainID, am_gen::am_DomainState_e domainState, am_gen::am_Error_e& error);
+
+ virtual void asyncSetSourceVolume(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_volume_t volume, am_gen::am_RampType_e ramp, am_gen::am_time_t time);
+
+ virtual void asyncSetSinkVolume(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_volume_t volume, am_gen::am_RampType_e ramp, am_gen::am_time_t time);
+
+ virtual void asyncConnect(am_gen::am_handle_t handle, am_gen::am_connectionID_t connectionID, am_gen::am_sourceID_t sourceID, am_gen::am_sinkID_t sinkID, am_gen::am_ConnectionFormat_e connectionFormat);
+
+ virtual void asyncDisconnect(am_gen::am_handle_t handle, am_gen::am_connectionID_t connectionID);
+
+ virtual void asyncAbort(am_gen::am_handle_t handle, am_gen::am_Error_e& error);
+
+ virtual void asyncSetSinkSoundProperties(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_SoundProperty_L listSoundProperties);
+
+ virtual void asyncSetSinkSoundProperty(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_SoundProperty_s soundProperty);
+
+ virtual void asyncSetSourceSoundProperties(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SoundProperty_L listSoundProperties);
+
+ virtual void asyncSetSourceSoundProperty(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SoundProperty_s soundProperty);
+
+ virtual void asyncCrossFade(am_gen::am_handle_t handle, am_gen::am_crossfaderID_t crossfaderID, am_gen::am_HotSink_e hotSink, am_gen::am_RampType_e rampType, am_gen::am_time_t time);
+
+ virtual void asyncSetVolumes(am_gen::am_handle_t handle, am_gen::am_Volumes_l volumes);
+
+ virtual void asyncSetSinkNotificationConfiguration(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_NotificationConfiguration_s notificationConfiguration);
+
+ virtual void asyncSetSourceNotificationConfiguration(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_NotificationConfiguration_s notificationConfiguration);
+
+ static const char * ROUTING_SENDER_SERVICE;
+ static const char * ROUTING_INTERFACE_SERVICE;
+};
+
+
+} /* namespace am */
+#endif /* CAMROUTINGSENDERSERVICE_H_ */
diff --git a/PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.cpp b/PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.cpp
new file mode 100644
index 0000000..6134d62
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.cpp
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#include "CAmTestCAPIWrapper.h"
+
+namespace am {
+
+CAmTestCAPIWrapper::CAmTestCAPIWrapper(CAmSocketHandler* socketHandler):CAmCommonAPIWrapper(socketHandler)
+{
+
+}
+
+CAmTestCAPIWrapper::~CAmTestCAPIWrapper() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace am */
diff --git a/PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.h b/PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.h
new file mode 100644
index 0000000..90499f9
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/CAmTestCAPIWrapper.h
@@ -0,0 +1,32 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#ifndef CAMTESTCAPIWRAPPER_H_
+#define CAMTESTCAPIWRAPPER_H_
+
+#include "shared/CAmCommonAPIWrapper.h"
+
+namespace am {
+
+class CAmTestCAPIWrapper: public am::CAmCommonAPIWrapper {
+public:
+ CAmTestCAPIWrapper(CAmSocketHandler* socketHandler);
+ virtual ~CAmTestCAPIWrapper();
+};
+
+} /* namespace am */
+#endif /* CAMTESTCAPIWRAPPER_H_ */
diff --git a/PluginRoutingInterfaceCAPI/test/CMakeLists.txt b/PluginRoutingInterfaceCAPI/test/CMakeLists.txt
new file mode 100644
index 0000000..26cdecf
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/CMakeLists.txt
@@ -0,0 +1,135 @@
+# Copyright (c) 2012 GENIVI Alliance
+# Copyright (c) 2012 BMW
+#
+# author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+#
+# copyright
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# For further information see http://www.genivi.org/.
+#
+
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(CAmRoutingInterfaceCAPITests)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -g -DUNIT_TEST=1 -DDLT_CONTEXT=AudioManager")
+
+string (REPLACE "-g -Wall -Wextra" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+string (REPLACE "-pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+
+set(STD_INCLUDE_DIRS "/usr/include")
+set(EXECUTABLE_OUTPUT_PATH ${TEST_EXECUTABLE_OUTPUT_PATH})
+
+FIND_PACKAGE(Threads)
+FIND_PACKAGE(PkgConfig)
+FIND_PACKAGE(PythonLibs REQUIRED)
+pkg_check_modules(PC_COMMON REQUIRED CommonAPI)
+pkg_check_modules(PC_COMMON_DBUS REQUIRED CommonAPI-DBus)
+
+IF(WITH_DLT)
+ pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0)
+ENDIF(WITH_DLT)
+
+INCLUDE_DIRECTORIES(
+ ${STD_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${AUDIO_INCLUDE_FOLDER}
+ ${CMAKE_SOURCE_DIR}
+ ${DLT_INCLUDE_DIRS}
+ ${PC_COMMON_INCLUDE_DIRS}
+ ${PC_COMMON_DBUS_INCLUDE_DIRS}
+ ${INCLUDE_FOLDER}
+ ${PYTHON_INCLUDE_DIRS}
+ ${GOOGLE_TEST_INCLUDE_DIR}
+ ${GMOCK_INCLUDE_DIR}
+ "../../AudioManagerDaemon/include"
+ "../include"
+)
+
+link_directories(
+ ${LINK_DIRECTORIES}
+ ${PC_COMMON_LIBRARY_DIRS}
+ ${PC_COMMON_DBUS_LIBRARY_DIRS}
+)
+
+file(GLOB CAPI_PLUGIN_INTERFACE_SRCS_CXX
+ "../../AudioManagerDaemon/src/CAmCommonAPIWrapper.cpp"
+ "../../AudioManagerDaemon/src/CAmSocketHandler.cpp"
+ "../../AudioManagerDaemon/src/CAmDltWrapper.cpp"
+ "../src/*.cpp"
+ "CAmRoutingInterfaceCAPITests.cpp"
+ "CAmTestCAPIWrapper.cpp"
+ "CAmCommandSenderCommon.cpp"
+ "CAmRoutingSenderService.cpp"
+ "IAmRoutingSenderBackdoor.cpp"
+)
+
+file(GLOB_RECURSE CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX
+ "../src-gen/*.cpp"
+)
+
+set (CAPI_SENDER_INTERFACE "org.genivi.audiomanger.routingsender")
+set (CAPI_SENDER_INSTANCE "org.genivi.routingsender")
+set (CAPI_SENDER_PATH "/org/genivi/audiomanger/routingsender")
+
+set (CAPI_SENDER_INTERFACE_H "\"${CAPI_SENDER_INTERFACE}\"")
+set (CAPI_SENDER_INSTANCE_H "\"${CAPI_SENDER_INSTANCE}\"")
+set (CAPI_SENDER_PATH_H "\"${CAPI_SENDER_PATH}\"")
+
+set (CAPI_ROUTING_INTERFACE "org.genivi.audiomanger.routinginterface")
+set (CAPI_ROUTING_INSTANCE "org.genivi.audiomanger")
+set (CAPI_ROUTING_PATH "/org/genivi/audiomanger/routinginterface")
+
+set (CAPI_ROUTING_INTERFACE_H "\"${CAPI_ROUTING_INTERFACE}\"")
+set (CAPI_ROUTING_INSTANCE_H "\"${CAPI_ROUTING_INSTANCE}\"")
+set (CAPI_ROUTING_PATH_H "\"${CAPI_ROUTING_PATH}\"")
+
+
+ADD_EXECUTABLE(AmRoutingInterfaceCAPITests ${CAPI_PLUGIN_INTERFACE_SRCS_CXX} ${CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES(AmRoutingInterfaceCAPITests
+ ${DLT_LIBRARIES}
+ ${CMAKE_DL_LIBS}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${PYTHON_LIBRARY}
+ ${PC_GSTREAMER_LIBRARIES}
+ ${PC_COMMON_LIBRARIES}
+ ${PC_COMMON_DBUS_LIBRARIES}
+ gtest
+ gmock
+)
+
+add_custom_command(
+ PRE_BUILD
+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/CAmRoutingSenderService.h
+ COMMAND generateheader ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CAmRoutingSenderService.h.in ${CMAKE_CURRENT_SOURCE_DIR}/CAmRoutingSenderService.h
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CAmRoutingSenderService.h.in
+)
+
+CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RoutingSender_dbus.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/RoutingSender_dbus.conf)
+CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CAmRoutingSenderService.h.in ${CMAKE_CURRENT_SOURCE_DIR}/CAmRoutingSenderService.h)
+
+FILE(READ ${CMAKE_CURRENT_SOURCE_DIR}/RoutingSender_dbus.conf ROUTING_TESTDOMAININTERFACE_DBUS_CONF)
+CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/AmRoutingInterfaceCAPITests_dbus.conf.in ${EXECUTABLE_OUTPUT_PATH}/AmRoutingInterfaceCAPITests_dbus.conf)
+CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/AmRoutingInterfaceCAPITests_dbus.conf.in ${EXECUTABLE_OUTPUT_PATH}/AmRoutingSenderTestDomain_dbus.conf)
+
+INSTALL(TARGETS AmRoutingInterfaceCAPITests
+ DESTINATION "~/AudioManagerTest/"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+ COMPONENT tests
+)
+
+#execute_process(
+# COMMAND cp "${CMAKE_SOURCE_DIR}/PluginCommandInterfaceCAPI/fidls/PluginCommandInterfaceCAPI_dbus.conf" ${EXECUTABLE_OUTPUT_PATH})
+
+SET(ADD_DEPEND "audiomanager-bin" "sqlite3(>=3.6.22)" "dlt" "gtest" "libpthread-stubs0")
+set_property(GLOBAL APPEND PROPERTY tests_prop "${ADD_DEPEND}")
+
diff --git a/PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.cpp b/PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.cpp
new file mode 100644
index 0000000..945a5e9
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.cpp
@@ -0,0 +1,87 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#include "IAmRoutingSenderBackdoor.h"
+#include "../include/CAmRoutingSenderCAPI.h"
+
+
+namespace am {
+
+bool IAmRoutingSenderBackdoor::containsDomainWithID(const am_domainID_t & domainID)
+{
+ return NULL!=routingSender->mLookupData.getValueForKey(domainID, routingSender->mLookupData.mMapDomains);
+}
+
+bool IAmRoutingSenderBackdoor::containsSourceWithID(const am_sourceID_t & sourceID)
+{
+ return NULL!=routingSender->mLookupData.getValueForKey(sourceID, routingSender->mLookupData.mMapSources);
+}
+
+bool IAmRoutingSenderBackdoor::containsSinkWithID(const am_sinkID_t & sinkID)
+{
+ return NULL!=routingSender->mLookupData.getValueForKey(sinkID, routingSender->mLookupData.mMapSinks);
+}
+
+bool IAmRoutingSenderBackdoor::containsCrossfader(const am_crossfaderID_t & crossfaderID)
+{
+ return routingSender->mLookupData.mMapCrossfaders.find(crossfaderID)!=routingSender->mLookupData.mMapCrossfaders.end();
+}
+
+bool IAmRoutingSenderBackdoor::containsHandle(const uint16_t & handle)
+{
+ return routingSender->mLookupData.mMapHandles.find(handle)!=routingSender->mLookupData.mMapHandles.end();
+}
+
+bool IAmRoutingSenderBackdoor::containsConnection(const am_connectionID_t & connID)
+{
+ return NULL!=routingSender->mLookupData.getValueForKey(connID, routingSender->mLookupData.mMapConnections);
+}
+
+unsigned IAmRoutingSenderBackdoor::domainsCount()
+{
+ return routingSender->mLookupData.mMapDomains.size();
+}
+
+unsigned IAmRoutingSenderBackdoor::sourcesCount()
+{
+ return routingSender->mLookupData.mMapSources.size();
+}
+
+unsigned IAmRoutingSenderBackdoor::sinksCount()
+{
+ return routingSender->mLookupData.mMapSinks.size();
+}
+
+unsigned IAmRoutingSenderBackdoor::crossfadersCount()
+{
+ return routingSender->mLookupData.mMapCrossfaders.size();
+}
+
+unsigned IAmRoutingSenderBackdoor::handlesCount()
+{
+ return routingSender->mLookupData.mMapHandles.size();
+}
+
+unsigned IAmRoutingSenderBackdoor::connectionsCount()
+{
+ return routingSender->mLookupData.mMapConnections.size();
+}
+
+
+}
+
+
diff --git a/PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.h b/PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.h
new file mode 100644
index 0000000..80d0f4e
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/IAmRoutingSenderBackdoor.h
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+
+#ifndef ROUTINGSENDERINTERFACEBACKDOOR_H_
+#define ROUTINGSENDERINTERFACEBACKDOOR_H_
+
+#include "audiomanagertypes.h"
+
+namespace am
+{
+
+class CAmRoutingSenderCAPI;
+
+class IAmRoutingSenderBackdoor
+{
+ CAmRoutingSenderCAPI *routingSender;
+public:
+ IAmRoutingSenderBackdoor():routingSender(NULL){};
+ IAmRoutingSenderBackdoor(CAmRoutingSenderCAPI *aSender):routingSender(aSender){};
+ virtual ~IAmRoutingSenderBackdoor(){routingSender=NULL;};
+
+ bool containsDomainWithID(const am_domainID_t & domainID);
+ bool containsSourceWithID(const am_sourceID_t & sourceID);
+ bool containsSinkWithID(const am_sinkID_t & sinkID);
+ bool containsCrossfader(const am_crossfaderID_t & crossfaderID);
+ bool containsHandle(const uint16_t & handle);
+ bool containsConnection(const am_connectionID_t & connID);
+ unsigned domainsCount();
+ unsigned sourcesCount();
+ unsigned sinksCount();
+ unsigned crossfadersCount();
+ unsigned handlesCount();
+ unsigned connectionsCount();
+};
+
+}
+
+#endif /* ROUTINGSENDERINTERFACEBACKDOOR_H_ */
diff --git a/PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h b/PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h
new file mode 100644
index 0000000..77cded1
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h
@@ -0,0 +1,126 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#ifndef MOCKROUTINGRECEIVENTERFACE_H_
+#define MOCKROUTINGRECEIVENTERFACE_H_
+
+#include "routing/IAmRoutingReceive.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+namespace am {
+
+class MockIAmRoutingReceive : public IAmRoutingReceive {
+ public:
+ MOCK_CONST_METHOD1(getInterfaceVersion,
+ void(std::string& version));
+ MOCK_METHOD3(ackConnect,
+ void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error));
+ MOCK_METHOD3(ackDisconnect,
+ void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error));
+ MOCK_METHOD3(ackSetSinkVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
+ MOCK_METHOD3(ackSetSourceVolumeChange,
+ void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error));
+ MOCK_METHOD2(ackSetSourceState,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSinkSoundProperties,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSinkSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSourceSoundProperties,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSetSourceSoundProperty,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD3(ackCrossFading,
+ void(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error));
+ MOCK_METHOD3(ackSourceVolumeTick,
+ void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume));
+ MOCK_METHOD3(ackSinkVolumeTick,
+ void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume));
+ MOCK_METHOD2(peekDomain,
+ am_Error_e(const std::string& name, am_domainID_t& domainID));
+ MOCK_METHOD2(registerDomain,
+ am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID));
+ MOCK_METHOD1(deregisterDomain,
+ am_Error_e(const am_domainID_t domainID));
+ MOCK_METHOD2(registerGateway,
+ am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID));
+ MOCK_METHOD1(deregisterGateway,
+ am_Error_e(const am_gatewayID_t gatewayID));
+ MOCK_METHOD2(peekSink,
+ am_Error_e(const std::string& name, am_sinkID_t& sinkID));
+ MOCK_METHOD2(registerSink,
+ am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID));
+ MOCK_METHOD1(deregisterSink,
+ am_Error_e(const am_sinkID_t sinkID));
+ MOCK_METHOD2(peekSource,
+ am_Error_e(const std::string& name, am_sourceID_t& sourceID));
+ MOCK_METHOD2(registerSource,
+ am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID));
+ MOCK_METHOD1(deregisterSource,
+ am_Error_e(const am_sourceID_t sourceID));
+ MOCK_METHOD2(registerCrossfader,
+ am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID));
+ MOCK_METHOD1(deregisterCrossfader,
+ am_Error_e(const am_crossfaderID_t crossfaderID));
+ MOCK_METHOD2(peekSourceClassID,
+ am_Error_e(const std::string& name, am_sourceClass_t& sourceClassID));
+ MOCK_METHOD2(peekSinkClassID,
+ am_Error_e(const std::string& name, am_sinkClass_t& sinkClassID));
+ MOCK_METHOD2(hookInterruptStatusChange,
+ void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState));
+ MOCK_METHOD1(hookDomainRegistrationComplete,
+ void(const am_domainID_t domainID));
+ MOCK_METHOD2(hookSinkAvailablityStatusChange,
+ void(const am_sinkID_t sinkID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookSourceAvailablityStatusChange,
+ void(const am_sourceID_t sourceID, const am_Availability_s& availability));
+ MOCK_METHOD2(hookDomainStateChange,
+ void(const am_domainID_t domainID, const am_DomainState_e domainState));
+ MOCK_METHOD2(hookTimingInformationChanged,
+ void(const am_connectionID_t connectionID, const am_timeSync_t delay));
+ MOCK_METHOD1(sendChangedData,
+ void(const std::vector<am_EarlyData_s>& earlyData));
+ MOCK_CONST_METHOD1(getDBusConnectionWrapper,
+ am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper));
+ MOCK_CONST_METHOD1(getSocketHandler,
+ am_Error_e(CAmSocketHandler*& socketHandler));
+ MOCK_METHOD2(confirmRoutingReady,
+ void(const uint16_t handle, const am_Error_e error));
+ MOCK_METHOD2(confirmRoutingRundown,
+ void(const uint16_t handle, const am_Error_e error));
+ MOCK_METHOD4(updateGateway,
+ am_Error_e(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceFormats, const std::vector<am_ConnectionFormat_e>& listSinkFormats, const std::vector<bool>& convertionMatrix));
+ MOCK_METHOD5(updateSink,
+ am_Error_e(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties));
+ MOCK_METHOD5(updateSource,
+ am_Error_e(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties));
+ MOCK_METHOD3(ackSetVolumes,
+ void(const am_Handle_s handle, const std::vector<am_Volumes_s>& listvolumes, const am_Error_e error));
+ MOCK_METHOD2(ackSinkNotificationConfiguration,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(ackSourceNotificationConfiguration,
+ void(const am_Handle_s handle, const am_Error_e error));
+ MOCK_METHOD2(hookSinkNotificationDataChange,
+ void(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload));
+ MOCK_METHOD2(hookSourceNotificationDataChange,
+ void(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload));
+};
+
+} // namespace am
+#endif /* MOCKROUTINGRECEIVENTERFACE_H_ */
diff --git a/PluginRoutingInterfaceCAPI/test/RoutingSender_dbus.conf b/PluginRoutingInterfaceCAPI/test/RoutingSender_dbus.conf
new file mode 100755
index 0000000..f54fdd7
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/RoutingSender_dbus.conf
@@ -0,0 +1,8 @@
+##################################### Routing Test Domain Interface configuration ################################
+# RoutingSender_dbus.conf #
+# If you change something make sure you re-configure with 'ccmake..' which generates the *_dbus.conf file again. #
+##################################################################################################################
+[local:org.genivi.audiomanger.routingsender:org.genivi.routingsender]
+dbus_connection=org.genivi.routingsender
+dbus_object=/org/genivi/audiomanger/routingsender
+dbus_interface=org.genivi.audiomanger.routingsender
diff --git a/PluginRoutingInterfaceCAPI/test/cmake/AmRoutingInterfaceCAPITests_dbus.conf.in b/PluginRoutingInterfaceCAPI/test/cmake/AmRoutingInterfaceCAPITests_dbus.conf.in
new file mode 100755
index 0000000..95d09b2
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/cmake/AmRoutingInterfaceCAPITests_dbus.conf.in
@@ -0,0 +1,3 @@
+@ROUTING_INTERFACE_DBUS_CONF@
+
+@ROUTING_TESTDOMAININTERFACE_DBUS_CONF@ \ No newline at end of file
diff --git a/PluginRoutingInterfaceCAPI/test/cmake/CAmRoutingSenderService.h.in b/PluginRoutingInterfaceCAPI/test/cmake/CAmRoutingSenderService.h.in
new file mode 100644
index 0000000..2b23745
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/cmake/CAmRoutingSenderService.h.in
@@ -0,0 +1,112 @@
+/**
+ * Copyright (c) 2012 BMW
+ *
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \copyright
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#ifndef CAMROUTINGSENDERSERVICE_H_
+#define CAMROUTINGSENDERSERVICE_H_
+
+#include "audiomanagertypes.h"
+#include <org/genivi/audiomanager/RoutingSenderStubDefault.h>
+#include <org/genivi/audiomanager/RoutingInterfaceProxy.h>
+
+/**
+ * GENERATED FROM CMAKE. PLEASE USE cmake/CAmRoutingSenderService.h.in IF YOU WANT TO MAKE CHANGES.
+ */
+
+namespace am {
+
+using namespace CommonAPI;
+using namespace org::genivi::audiomanager;
+
+class CAmCommonAPIWrapper;
+
+/**
+ * THE FOLLOWING DEFINES ARE POPULATED FROM THE CMAKELISTS.TXT .
+ */
+#define CAPI_SENDER_INTERFACE @CAPI_SENDER_INTERFACE_H@
+#define CAPI_SENDER_INSTANCE @CAPI_SENDER_INSTANCE_H@
+#define CAPI_SENDER_PATH @CAPI_SENDER_PATH_H@
+
+#define CAPI_ROUTING_INTERFACE @CAPI_ROUTING_INTERFACE_H@
+#define CAPI_ROUTING_INSTANCE @CAPI_ROUTING_INSTANCE_H@
+#define CAPI_ROUTING_PATH @CAPI_ROUTING_PATH_H@
+
+
+/** Test class implementing the routing sender service.
+*
+* Please see cmake/CAmRoutingSenderService.h.in
+*/
+class CAmRoutingSenderService : public RoutingSenderStubDefault {
+
+ am_gen::am_Domain_s mDomainData;
+ uint16_t mAbortedHandle;
+ bool mIsServiceAvailable;
+ bool mIsDomainRegistred;
+ bool mIsReady;
+ CAmCommonAPIWrapper *mpWrapper;
+ std::shared_ptr<RoutingInterfaceProxy<> > mRoutingInterfaceProxy;
+
+public:
+
+ CAmRoutingSenderService();
+ CAmRoutingSenderService(CAmCommonAPIWrapper * aWrapper);
+ CAmRoutingSenderService(CAmCommonAPIWrapper * aWrapper, std::shared_ptr<RoutingInterfaceProxy<> > aProxy);
+ virtual ~CAmRoutingSenderService();
+
+ void onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus);
+ void onRoutingReadyRundown();
+ void onRoutingReadyEvent();
+ void registerDomain();
+ void setAbortHandle(uint16_t handle);
+ uint16_t errorForHandle(const uint16_t & handle);
+
+ virtual void asyncSetSourceState(uint16_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SourceState_e sourceState);
+
+ virtual void setDomainState(am_gen::am_domainID_t domainID, am_gen::am_DomainState_e domainState, am_gen::am_Error_e& error);
+
+ virtual void asyncSetSourceVolume(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_volume_t volume, am_gen::am_RampType_e ramp, am_gen::am_time_t time);
+
+ virtual void asyncSetSinkVolume(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_volume_t volume, am_gen::am_RampType_e ramp, am_gen::am_time_t time);
+
+ virtual void asyncConnect(am_gen::am_handle_t handle, am_gen::am_connectionID_t connectionID, am_gen::am_sourceID_t sourceID, am_gen::am_sinkID_t sinkID, am_gen::am_ConnectionFormat_e connectionFormat);
+
+ virtual void asyncDisconnect(am_gen::am_handle_t handle, am_gen::am_connectionID_t connectionID);
+
+ virtual void asyncAbort(am_gen::am_handle_t handle, am_gen::am_Error_e& error);
+
+ virtual void asyncSetSinkSoundProperties(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_SoundProperty_L listSoundProperties);
+
+ virtual void asyncSetSinkSoundProperty(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_SoundProperty_s soundProperty);
+
+ virtual void asyncSetSourceSoundProperties(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SoundProperty_L listSoundProperties);
+
+ virtual void asyncSetSourceSoundProperty(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_SoundProperty_s soundProperty);
+
+ virtual void asyncCrossFade(am_gen::am_handle_t handle, am_gen::am_crossfaderID_t crossfaderID, am_gen::am_HotSink_e hotSink, am_gen::am_RampType_e rampType, am_gen::am_time_t time);
+
+ virtual void asyncSetVolumes(am_gen::am_handle_t handle, am_gen::am_Volumes_l volumes);
+
+ virtual void asyncSetSinkNotificationConfiguration(am_gen::am_handle_t handle, am_gen::am_sinkID_t sinkID, am_gen::am_NotificationConfiguration_s notificationConfiguration);
+
+ virtual void asyncSetSourceNotificationConfiguration(am_gen::am_handle_t handle, am_gen::am_sourceID_t sourceID, am_gen::am_NotificationConfiguration_s notificationConfiguration);
+
+ static const char * ROUTING_SENDER_SERVICE;
+ static const char * ROUTING_INTERFACE_SERVICE;
+};
+
+
+} /* namespace am */
+#endif /* CAMROUTINGSENDERSERVICE_H_ */
diff --git a/PluginRoutingInterfaceCAPI/test/cmake/RoutingSender_dbus.conf.in b/PluginRoutingInterfaceCAPI/test/cmake/RoutingSender_dbus.conf.in
new file mode 100755
index 0000000..bcd29a6
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/cmake/RoutingSender_dbus.conf.in
@@ -0,0 +1,8 @@
+##################################### Routing Test Domain Interface configuration ################################
+# RoutingSender_dbus.conf #
+# If you change something make sure you re-configure with 'ccmake..' which generates the *_dbus.conf file again. #
+##################################################################################################################
+[local:@CAPI_SENDER_INTERFACE@:@CAPI_SENDER_INSTANCE@]
+dbus_connection=@CAPI_SENDER_INSTANCE@
+dbus_object=@CAPI_SENDER_PATH@
+dbus_interface=@CAPI_SENDER_INTERFACE@ \ No newline at end of file
diff --git a/PluginRoutingInterfaceCAPI/test/cmake/config.cmake b/PluginRoutingInterfaceCAPI/test/cmake/config.cmake
new file mode 100644
index 0000000..b2ef0b2
--- /dev/null
+++ b/PluginRoutingInterfaceCAPI/test/cmake/config.cmake
@@ -0,0 +1,8 @@
+#ifndef _ROUTINGDBUS_CONFIG_H
+#define _ROUTINGDBUS_CONFIG_H
+
+#cmakedefine CAPI_SENDER_INTERFACE "@CAPI_SENDER_INTERFACE@"
+#cmakedefine CAPI_SENDER_INSTANCE "@CAPI_SENDER_INSTANCE@"
+#cmakedefine CAPI_SENDER_PATH "@CAPI_SENDER_PATH@"
+
+#endif /* _ROUTINGDBUS_CONFIG_H */