summaryrefslogtreecommitdiff
path: root/PluginCommandInterfaceCAPI/test
diff options
context:
space:
mode:
authorAleksandar Donchev <aleksander.donchev@partner.bmw.de>2013-09-02 11:57:28 +0200
committerChristian Linke <Christian.Linke@bmw.de>2013-09-03 17:26:04 +0200
commita2edae5cee4254b933f42399edc0e092abd4f5cf (patch)
treeead58f525b947deed4b8c76ab9c89c80b5056227 /PluginCommandInterfaceCAPI/test
parent7aee1baeea1777318932cc49a8eac18f194233cd (diff)
downloadaudiomanager-a2edae5cee4254b933f42399edc0e092abd4f5cf.tar.gz
*PluginCommandInterfaceCAPI, PluginRoutingInterfaceCAPI, NodeStateCommunicatorCAPI with unit tests first version.
Choosing between DBUS and Common-API via cmake. CommonAPI - legacy support for DBus properties (Set 1) Signed-off-by: Christian Linke <christian.linke@bmw.de> (cherry picked from commit ea96ef59e29466667c90b506426e2a5a9cdb82d2)
Diffstat (limited to 'PluginCommandInterfaceCAPI/test')
-rw-r--r--PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp1101
-rw-r--r--PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.h77
-rw-r--r--PluginCommandInterfaceCAPI/test/CAmTestCAPIWrapper.cpp31
-rw-r--r--PluginCommandInterfaceCAPI/test/CAmTestCAPIWrapper.h32
-rw-r--r--PluginCommandInterfaceCAPI/test/CMakeLists.txt105
-rw-r--r--PluginCommandInterfaceCAPI/test/MockIAmCommandReceive.h86
-rw-r--r--PluginCommandInterfaceCAPI/test/MockNotificationsClient.h110
7 files changed, 1542 insertions, 0 deletions
diff --git a/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp b/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp
new file mode 100644
index 0000000..6f64150
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp
@@ -0,0 +1,1101 @@
+/**
+ * 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 "CAmCommandSenderCAPITest.h"
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <algorithm>
+#include <string>
+#include <vector>
+#include <set>
+#include "TAmPluginTemplate.h"
+#include "MockIAmCommandReceive.h"
+#include "shared/CAmDltWrapper.h"
+#include "../include/CAmCommandSenderCAPI.h"
+#include "MockNotificationsClient.h"
+#include <CommonAPI/CommonAPI.h>
+#include <sys/time.h>
+
+
+
+using namespace am;
+using namespace testing;
+using namespace org::genivi::audiomanager;
+using namespace CommonAPI;
+
+static CAmTestsEnvironment* env;
+
+pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t condPxy = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t mutexPxy = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t condSer = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t mutexSer = PTHREAD_MUTEX_INITIALIZER;
+
+void* run_client(void*)
+{
+ CAmSocketHandler socketHandler;
+ CAmTestCAPIWrapper wrapper(&socketHandler);
+ env->mSocketHandlerClient = &socketHandler;
+ std::shared_ptr<CommonAPI::Factory> factory = wrapper.factory();
+ env->mProxy = factory->buildProxy<CommandInterfaceProxy>(CAmCommandSenderCAPI::COMMAND_SENDER_SERVICE);
+ env->mProxy->getProxyStatusEvent().subscribe(std::bind(&CAmTestsEnvironment::onServiceStatusEvent,env,std::placeholders::_1));
+
+ 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);
+}
+
+void* run_service(void*)
+{
+ CAmSocketHandler socketHandler;
+ CAmTestCAPIWrapper wrapper(&socketHandler);
+ CAmCommandSenderCAPI plugin(&wrapper);
+ env->mpPlugin = &plugin;
+ env->mSocketHandlerService = &socketHandler;
+ MockIAmCommandReceive mock;
+ env->mpCommandReceive = &mock;
+ if(plugin.startupInterface(env->mpCommandReceive)!=E_OK)
+ {
+ logError("CommandSendInterface can't start!");
+ }
+ else
+ {
+ plugin.setCommandReady(10);
+ socketHandler.start_listenting();
+
+ plugin.setCommandRundown(10);
+ plugin.tearDownInterface(env->mpCommandReceive);
+ }
+
+//Cleanup
+ env->mpPlugin = NULL;
+ env->mpCommandReceive = NULL;
+ env->mSocketHandlerClient = NULL;
+
+ return (NULL);
+}
+
+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;
+}
+
+CAmTestsEnvironment::CAmTestsEnvironment() :
+ mListenerThread(0),
+ mServicePThread(0),
+ mClientPThread(0),
+ mSocketHandlerService(NULL),
+ mSocketHandlerClient(NULL),
+ mIsProxyInitilized(false),
+ mIsServiceAvailable(false),
+ mpCommandReceive(NULL),
+ mpPlugin(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()
+{
+// mWrapperClient.factory().reset();
+
+ mSocketHandlerClient->exit_mainloop();
+ pthread_join(mClientPThread, NULL);
+ 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);
+}
+
+int main(int argc, char **argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::AddGlobalTestEnvironment(new CAmTestsEnvironment);
+ return RUN_ALL_TESTS();
+}
+
+CAmCommandSenderCAPITest::CAmCommandSenderCAPITest()
+{
+
+}
+
+CAmCommandSenderCAPITest::~CAmCommandSenderCAPITest()
+{
+
+}
+
+void CAmCommandSenderCAPITest::SetUp()
+{
+ ::testing::GTEST_FLAG(throw_on_failure) = false;
+}
+
+void CAmCommandSenderCAPITest::TearDown()
+{
+ ::testing::GTEST_FLAG(throw_on_failure) = true;
+}
+
+TEST_F(CAmCommandSenderCAPITest, ClientStartupTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnClientConnect){
+arg2=101;
+}
+
+TEST_F(CAmCommandSenderCAPITest, ConnectTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_sourceID_t sourceID = 500;
+ CommandInterface::am_sinkID_t sinkID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+ CommandInterface::am_mainConnectionID_t mainConnectionID = 0;
+
+ EXPECT_CALL(*env->mpCommandReceive, connect(_, _, _)).WillOnce(DoAll(returnClientConnect(), Return(E_OK)));
+ env->mProxy->Connect(sourceID, sinkID, callStatus,result, mainConnectionID);
+ ASSERT_EQ(mainConnectionID, 101);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ EXPECT_CALL(*env->mpCommandReceive, disconnect(mainConnectionID)).WillOnce(Return(am_Error_e::E_OK));
+ env->mProxy->Disconnect(mainConnectionID, callStatus, result);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, SetVolumeTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_mainVolume_t volume = 100;
+ CommandInterface::am_sinkID_t sinkID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, setVolume(sinkID,volume)).WillOnce(Return(E_OK));
+ env->mProxy->SetVolume(sinkID, volume, callStatus, result);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, VolumeStepTest)
+{
+
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_mainVolume_t volume = 100;
+ CommandInterface::am_sinkID_t sinkID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, volumeStep(sinkID,volume)).WillOnce(Return(E_OK));
+ env->mProxy->VolumeStep(sinkID, volume, callStatus, result);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, SetSinkMuteStateTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_MuteState_e value = CommandInterface::am_MuteState_e::MS_UNKNOWN;
+ CommandInterface::am_sinkID_t sinkID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, setSinkMuteState(sinkID, am_MuteState_e::MS_UNKNOWN)).WillOnce(Return(E_OK));
+ env->mProxy->SetSinkMuteState(sinkID, value, callStatus, result);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, SetMainSinkSoundPropertyTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_sinkID_t sinkID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, setMainSinkSoundProperty(AllOf(
+ Field(&am_MainSoundProperty_s::value, 3),
+ Field(&am_MainSoundProperty_s::type, MSP_UNKNOWN)), sinkID)).WillOnce(Return(E_OK));
+ CommandInterface::am_MainSoundProperty_s value(CommandInterface::am_MainSoundPropertyType_e::MSP_UNKNOWN, (const int16_t)3);
+ env->mProxy->SetMainSinkSoundProperty(sinkID, value, callStatus, result);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, SetMainSourceSoundPropertyTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_sourceID_t sID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, setMainSourceSoundProperty(AllOf(
+ Field(&am_MainSoundProperty_s::value, 3),
+ Field(&am_MainSoundProperty_s::type, MSP_UNKNOWN)), sID)).WillOnce(Return(E_OK));
+ CommandInterface::am_MainSoundProperty_s value(CommandInterface::am_MainSoundPropertyType_e::MSP_UNKNOWN, (const int16_t)3);
+ env->mProxy->SetMainSourceSoundProperty(sID, value, callStatus, result);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, SetSystemPropertyTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, setSystemProperty(Field(&am_SystemProperty_s::value, 2))).WillOnce(Return(E_OK));
+
+ CommandInterface::am_SystemProperty_s value(CommandInterface::am_SystemPropertyType_e::SYP_UNKNOWN, (const int16_t)2);
+ env->mProxy->SetSystemProperty(value, callStatus, result);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListConnections){
+ std::vector<am_MainConnectionType_s> list;
+ am_MainConnectionType_s listItem;
+ listItem.mainConnectionID=15;
+ listItem.sinkID=4;
+ listItem.sourceID=3;
+ listItem.connectionState=CS_UNKNOWN;
+ listItem.delay=34;
+ list.push_back(listItem);
+ arg0=list;
+}
+
+TEST_F(CAmCommandSenderCAPITest, GetListMainConnectionsTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListMainConnections(_)).WillOnce(DoAll(returnListConnections(), Return(E_OK)));
+ CommandInterface::am_MainConnectionType_l listConnections;
+ env->mProxy->GetListMainConnections(callStatus, result, listConnections);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(1, listConnections.size());
+ ASSERT_EQ(15, listConnections.at(0).mainConnectionID);
+ ASSERT_EQ(4, listConnections.at(0).sinkID);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListSinks){
+ std::vector<am_SinkType_s> list;
+ am_SinkType_s listItem;
+ listItem.availability.availability=A_UNAVAILABLE;
+ listItem.availability.availabilityReason=AR_GENIVI_NOMEDIA;
+ listItem.muteState=MS_UNMUTED;
+ listItem.name="mySink";
+ listItem.sinkClassID=34;
+ listItem.sinkID=24;
+ listItem.volume=124;
+ list.push_back(listItem);
+ arg0=list;
+}
+
+TEST_F(CAmCommandSenderCAPITest, GetListMainSinksTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListMainSinks(_)).WillOnce(DoAll(returnListSinks(), Return(E_OK)));
+ CommandInterface::am_SinkType_l listMainSinks;
+ env->mProxy->GetListMainSinks(callStatus, result, listMainSinks);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(1, listMainSinks.size());
+ ASSERT_EQ(34, listMainSinks.at(0).sinkClassID);
+ ASSERT_EQ(24, listMainSinks.at(0).sinkID);
+ ASSERT_EQ(CommandInterface::am_Availablility_e::A_UNAVAILABLE, listMainSinks.at(0).availability.availability);
+ ASSERT_EQ(CommandInterface::am_AvailabilityReason_e::AR_GENIVI_NOMEDIA, listMainSinks.at(0).availability.availabilityReason);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListSources){
+ std::vector<am_SourceType_s> list;
+ am_SourceType_s listItem;
+ listItem.availability.availability=A_MAX;
+ listItem.availability.availabilityReason=AR_GENIVI_SAMEMEDIA;
+ listItem.name="MySource";
+ listItem.sourceClassID=12;
+ listItem.sourceID=224;
+ list.push_back(listItem);
+ listItem.name="NextSource";
+ listItem.sourceID=22;
+ list.push_back(listItem);
+ arg0=list;
+}
+TEST_F(CAmCommandSenderCAPITest, GetListMainSourcesTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListMainSources(_)).WillOnce(DoAll(returnListSources(), Return(E_OK)));
+ CommandInterface::am_SourceType_l list;
+ env->mProxy->GetListMainSources(callStatus, result, list);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(2, list.size());
+ ASSERT_EQ(12, list.at(0).sourceClassID);
+ ASSERT_EQ(224, list.at(0).sourceID);
+ ASSERT_EQ(CommandInterface::am_Availablility_e::A_MAX, list.at(0).availability.availability);
+ ASSERT_EQ(CommandInterface::am_AvailabilityReason_e::AR_GENIVI_SAMEMEDIA, list.at(0).availability.availabilityReason);
+ ASSERT_EQ(22, list.at(1).sourceID);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListMainSinkSoundProperties){
+ std::vector<am_MainSoundProperty_s> list;
+ am_MainSoundProperty_s listItem;
+ listItem.type=MSP_MAX;
+ listItem.value=223;
+ list.push_back(listItem);
+ listItem.type=MSP_MAX;
+ listItem.value=2;
+ list.push_back(listItem);
+ arg1=list;
+}
+
+TEST_F(CAmCommandSenderCAPITest, GetListMainSinkSoundPropertiesTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_sinkID_t sID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListMainSinkSoundProperties(sID,_)).WillOnce(DoAll(returnListMainSinkSoundProperties(), Return(E_OK)));
+ CommandInterface::am_MainSoundProperty_l list;
+ env->mProxy->GetListMainSinkSoundProperties(sID, callStatus, result, list);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(2, list.size());
+ ASSERT_EQ(223, list.at(0).value);
+ ASSERT_EQ(CommandInterface::am_MainSoundPropertyType_e::MSP_MAX, list.at(0).type);
+ ASSERT_EQ(2, list.at(1).value);
+ ASSERT_EQ(CommandInterface::am_MainSoundPropertyType_e::MSP_MAX, list.at(1).type);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListMainSourceSoundProperties){
+ std::vector<am_MainSoundProperty_s> list;
+ am_MainSoundProperty_s listItem;
+ listItem.type=MSP_EXAMPLE_MID;
+ listItem.value=223;
+ list.push_back(listItem);
+ listItem.type=MSP_MAX;
+ listItem.value=2;
+ list.push_back(listItem);
+ arg1=list;
+}
+
+TEST_F(CAmCommandSenderCAPITest, GetListMainSourceSoundPropertiesTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommandInterface::am_sourceID_t sID = 400;
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListMainSourceSoundProperties(sID,_)).WillOnce(DoAll(returnListMainSourceSoundProperties(), Return(E_OK)));
+ CommandInterface::am_MainSoundProperty_l list;
+ env->mProxy->GetListMainSourceSoundProperties(sID, callStatus, result, list);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(2, list.size());
+ ASSERT_EQ(223, list.at(0).value);
+ ASSERT_EQ(CommandInterface::am_MainSoundPropertyType_e::MSP_EXAMPLE_MID, list.at(0).type);
+ ASSERT_EQ(2, list.at(1).value);
+ ASSERT_EQ(CommandInterface::am_MainSoundPropertyType_e::MSP_MAX, list.at(1).type);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListSourceClasses){
+ std::vector<am_SourceClass_s> list;
+ am_SourceClass_s listItem;
+ am_ClassProperty_s property;
+ property.classProperty=CP_MAX;
+ property.value=12;
+ listItem.name="FirstCLass";
+ listItem.sourceClassID=23;
+ listItem.listClassProperties.push_back(property);
+ list.push_back(listItem);
+ listItem.name="SecondCLass";
+ listItem.sourceClassID=2;
+ listItem.listClassProperties.push_back(property);
+ list.push_back(listItem);
+ arg0=list;
+}
+
+TEST_F(CAmCommandSenderCAPITest, GetListSourceClassesTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListSourceClasses(_)).WillOnce(DoAll(returnListSourceClasses(), Return(E_OK)));
+ CommandInterface::am_SourceClass_l list;
+ env->mProxy->GetListSourceClasses(callStatus, result, list);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(2, list.size());
+
+ ASSERT_EQ(23, list.at(0).sourceClassID);
+ ASSERT_EQ(1, list.at(0).listClassProperties.size());
+ ASSERT_EQ(CommandInterface::am_ClassProperty_e::CP_MAX, list.at(0).listClassProperties.at(0).classProperty);
+
+ ASSERT_EQ(2, list.at(1).sourceClassID);
+ ASSERT_EQ(2, list.at(1).listClassProperties.size());
+ ASSERT_EQ(CommandInterface::am_ClassProperty_e::CP_MAX, list.at(1).listClassProperties.at(0).classProperty);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListSinkClasses){
+ std::vector<am_SinkClass_s> list;
+ am_SinkClass_s listItem;
+ am_ClassProperty_s property;
+ property.classProperty=CP_MAX;
+ property.value=122;
+ listItem.name="FirstCLass";
+ listItem.sinkClassID=23;
+ listItem.listClassProperties.push_back(property);
+ list.push_back(listItem);
+ listItem.name="SecondCLass";
+ listItem.sinkClassID=2;
+ listItem.listClassProperties.push_back(property);
+ list.push_back(listItem);
+ arg0=list;
+}
+
+TEST_F(CAmCommandSenderCAPITest, GetListSinkClassesTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListSinkClasses(_)).WillOnce(DoAll(returnListSinkClasses(), Return(E_OK)));
+ CommandInterface::am_SinkClass_l list;
+ env->mProxy->GetListSinkClasses(callStatus, result, list);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(2, list.size());
+
+ ASSERT_EQ(0, list.at(0).name.compare("FirstCLass"));
+ ASSERT_EQ(23, list.at(0).sinkClassID);
+ ASSERT_EQ(1, list.at(0).listClassProperties.size());
+ ASSERT_EQ(CommandInterface::am_ClassProperty_e::CP_MAX, list.at(0).listClassProperties.at(0).classProperty);
+
+ ASSERT_EQ(0, list.at(1).name.compare("SecondCLass"));
+ ASSERT_EQ(2, list.at(1).sinkClassID);
+ ASSERT_EQ(2, list.at(1).listClassProperties.size());
+ ASSERT_EQ(CommandInterface::am_ClassProperty_e::CP_MAX, list.at(1).listClassProperties.at(0).classProperty);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+ACTION(returnListSystemProperties){
+ std::vector<am_SystemProperty_s> list;
+ am_SystemProperty_s listItem;
+ listItem.type=SYP_MAX;
+ listItem.value=-2245;
+ list.push_back(listItem);
+ arg0=list;
+}
+
+TEST_F(CAmCommandSenderCAPITest, GetListSystemPropertiesTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ CommonAPI::CallStatus callStatus = CommonAPI::CallStatus::NOT_AVAILABLE;
+ CommandInterface::am_Error_e result = CommandInterface::am_Error_e::E_OK;
+
+ EXPECT_CALL(*env->mpCommandReceive, getListSystemProperties(_)).WillOnce(DoAll(returnListSystemProperties(), Return(E_OK)));
+ CommandInterface::am_SystemProperty_l list;
+ env->mProxy->GetListSystemProperties(callStatus, result, list);
+ ASSERT_EQ(result, CommandInterface::am_Error_e::E_OK);
+ ASSERT_EQ(1, list.size());
+
+ ASSERT_EQ(-2245, list.at(0).value);
+ ASSERT_EQ(CommandInterface::am_SystemPropertyType_e::SYP_MAX, list.at(0).type);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+
+/**
+ * Signal tests
+ */
+
+#define SIMPLE_THREADS_SYNC_MICROSEC() usleep(50000)
+
+TEST_F(CAmCommandSenderCAPITest, onNumberOfMainConnectionsChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getNumberOfMainConnectionsChangedEvent().subscribe(std::bind(&MockNotificationsClient::onNumberOfMainConnectionsChangedEvent, std::ref(mock)));
+ EXPECT_CALL(mock, onNumberOfMainConnectionsChangedEvent());
+ am_MainConnectionType_s mainConnection;
+ env->mpPlugin->cbNewMainConnection(mainConnection);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getNumberOfMainConnectionsChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onNumberOfSourceClassesChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getNumberOfSourceClassesChangedEvent().subscribe(
+ std::bind(&MockNotificationsClient::onNumberOfSourceClassesChangedEvent, std::ref(mock)));
+ EXPECT_CALL(mock, onNumberOfSourceClassesChangedEvent());
+ env->mpPlugin->cbNumberOfSourceClassesChanged();
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getNumberOfMainConnectionsChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onMainConnectionStateChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getMainConnectionStateChangedEvent().subscribe(std::bind(&MockNotificationsClient::onMainConnectionStateChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+ EXPECT_CALL(mock, onMainConnectionStateChangedEvent(101, CommandInterface::am_ConnectionState_e::CS_SUSPENDED));
+ env->mpPlugin->cbMainConnectionStateChanged(101, CS_SUSPENDED);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getMainConnectionStateChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSourceAddedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSourceAddedEvent().subscribe(std::bind(&MockNotificationsClient::onSourceAddedEvent, std::ref(mock),
+ std::placeholders::_1));
+ CommandInterface::am_SourceType_s destination;
+ destination.sourceID = 100;
+ destination.name = "Name";
+ destination.availability.availability = CommandInterface::am_Availablility_e::A_MAX;
+ destination.availability.availabilityReason = CommandInterface::am_AvailabilityReason_e::AR_MAX;
+ destination.sourceClassID = 200;
+
+ am_SourceType_s origin;
+ origin.sourceID = 100;
+ origin.name = "Name";
+ origin.availability.availability = A_MAX;
+ origin.availability.availabilityReason = AR_MAX;
+ origin.sourceClassID = 200;
+ EXPECT_CALL(mock, onSourceAddedEvent(destination));
+ env->mpPlugin->cbNewSource(origin);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSourceAddedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSourceRemovedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSourceRemovedEvent().subscribe(std::bind(&MockNotificationsClient::onSourceRemovedEvent, std::ref(mock),
+ std::placeholders::_1));
+ am_sourceID_t source = 101;
+ EXPECT_CALL(mock, onSourceRemovedEvent(source));
+ env->mpPlugin->cbRemovedSource(source);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSourceRemovedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onMainSourceSoundPropertyChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getMainSourceSoundPropertyChangedEvent().subscribe(std::bind(&MockNotificationsClient::onMainSourceSoundPropertyChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+
+ am_MainSoundProperty_s soundProperty;
+ soundProperty.value = 10;
+ soundProperty.type = am_MainSoundPropertyType_e::MSP_MAX;
+
+ CommandInterface::am_MainSoundProperty_s destination(CommandInterface::am_MainSoundPropertyType_e::MSP_MAX, 10);
+
+ EXPECT_CALL(mock, onMainSourceSoundPropertyChangedEvent(101, destination));
+ env->mpPlugin->cbMainSourceSoundPropertyChanged(101, soundProperty);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getMainSourceSoundPropertyChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSourceAvailabilityChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSourceAvailabilityChangedEvent().subscribe(std::bind(&MockNotificationsClient::onSourceAvailabilityChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+
+ am_Availability_s availability;
+ availability.availability = A_MAX;
+ availability.availabilityReason = AR_MAX;
+
+ CommandInterface::am_Availability_s destination(CommandInterface::am_Availablility_e::A_MAX, CommandInterface::am_AvailabilityReason_e::AR_MAX);
+
+ EXPECT_CALL(mock, onSourceAvailabilityChangedEvent(101, destination));
+ env->mpPlugin->cbSourceAvailabilityChanged(101, availability);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSourceAvailabilityChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onNumberOfSinkClassesChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getNumberOfSinkClassesChangedEvent().subscribe(std::bind(&MockNotificationsClient::onNumberOfSinkClassesChangedEvent, std::ref(mock)));
+ EXPECT_CALL(mock, onNumberOfSinkClassesChangedEvent());
+ env->mpPlugin->cbNumberOfSinkClassesChanged();
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getNumberOfSinkClassesChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSinkAddedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSinkAddedEvent().subscribe(std::bind(&MockNotificationsClient::onSinkAddedEvent, std::ref(mock),
+ std::placeholders::_1));
+ CommandInterface::am_SinkType_s destination;
+ destination.sinkID = 100;
+ destination.name = "Name";
+ destination.availability.availability = CommandInterface::am_Availablility_e::A_MAX;
+ destination.availability.availabilityReason = CommandInterface::am_AvailabilityReason_e::AR_MAX;
+ destination.muteState = CommandInterface::am_MuteState_e::MS_MAX;
+ destination.volume = 1;
+ destination.sinkClassID = 100;
+
+ am_SinkType_s origin;
+ origin.sinkID = 100;
+ origin.name = "Name";
+ origin.availability.availability = A_MAX;
+ origin.availability.availabilityReason = AR_MAX;
+ origin.muteState = am_MuteState_e::MS_MAX;
+ origin.volume = 1;
+ origin.sinkClassID = 100;
+
+ EXPECT_CALL(mock, onSinkAddedEvent(destination));
+ env->mpPlugin->cbNewSink(origin);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSinkAddedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSinkRemovedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSinkRemovedEvent().subscribe(std::bind(&MockNotificationsClient::onSinkRemovedEvent, std::ref(mock),
+ std::placeholders::_1));
+ EXPECT_CALL(mock, onSinkRemovedEvent(101));
+ env->mpPlugin->cbRemovedSink(101);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSinkRemovedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onMainSinkSoundPropertyChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getMainSinkSoundPropertyChangedEvent().subscribe(std::bind(&MockNotificationsClient::onMainSinkSoundPropertyChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+
+ am_MainSoundProperty_s soundProperty;
+ soundProperty.value = 10;
+ soundProperty.type = am_MainSoundPropertyType_e::MSP_MAX;
+
+ CommandInterface::am_MainSoundProperty_s destination(CommandInterface::am_MainSoundPropertyType_e::MSP_MAX, 10);
+
+ EXPECT_CALL(mock, onMainSinkSoundPropertyChangedEvent(101, destination));
+ env->mpPlugin->cbMainSinkSoundPropertyChanged(101, soundProperty);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getMainSinkSoundPropertyChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSinkAvailabilityChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSinkAvailabilityChangedEvent().subscribe(std::bind(&MockNotificationsClient::onSinkAvailabilityChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+
+ am_Availability_s availability;
+ availability.availability = A_MAX;
+ availability.availabilityReason = AR_MAX;
+
+ CommandInterface::am_Availability_s destination(CommandInterface::am_Availablility_e::A_MAX, CommandInterface::am_AvailabilityReason_e::AR_MAX);
+
+ EXPECT_CALL(mock, onSinkAvailabilityChangedEvent(101, destination));
+ env->mpPlugin->cbSinkAvailabilityChanged(101, availability);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSinkAvailabilityChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onVolumeChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getVolumeChangedEvent().subscribe(std::bind(&MockNotificationsClient::onVolumeChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+ EXPECT_CALL(mock, onVolumeChangedEvent(101, 4));
+ env->mpPlugin->cbVolumeChanged(101, 4);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getVolumeChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSinkMuteStateChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSinkMuteStateChangedEvent().subscribe(std::bind(&MockNotificationsClient::onSinkMuteStateChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+ EXPECT_CALL(mock, onSinkMuteStateChangedEvent(101, CommandInterface::am_MuteState_e::MS_MAX));
+ env->mpPlugin->cbSinkMuteStateChanged(101, am_MuteState_e::MS_MAX);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSinkMuteStateChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSystemPropertyChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSystemPropertyChangedEvent().subscribe(std::bind(&MockNotificationsClient::onSystemPropertyChangedEvent, std::ref(mock),
+ std::placeholders::_1));
+
+ CommandInterface::am_SystemProperty_s value(CommandInterface::am_SystemPropertyType_e::SYP_UNKNOWN, (const int16_t)2);
+ am_SystemProperty_s systemProperty;
+ systemProperty.value = 2;
+ systemProperty.type = am_SystemPropertyType_e::SYP_UNKNOWN;
+
+ EXPECT_CALL(mock, onSystemPropertyChangedEvent(value));
+ env->mpPlugin->cbSystemPropertyChanged(systemProperty);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSystemPropertyChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onTimingInformationChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getTimingInformationChangedEvent().subscribe(std::bind(&MockNotificationsClient::onTimingInformationChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+
+ EXPECT_CALL(mock, onTimingInformationChangedEvent(1, 2));
+ env->mpPlugin->cbTimingInformationChanged(1, 2);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getTimingInformationChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSinkUpdatedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSinkUpdatedEvent().subscribe(std::bind(&MockNotificationsClient::onSinkUpdatedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+ am_MainSoundProperty_s prop;
+ prop.value = 1;
+ prop.type = am_MainSoundPropertyType_e::MSP_MAX;
+ listMainSoundProperties.push_back(prop);
+ EXPECT_CALL(mock, onSinkUpdatedEvent(1, 2, _));
+ env->mpPlugin->cbSinkUpdated(1, 2, listMainSoundProperties);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSinkUpdatedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSourceUpdatedTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSourceUpdatedEvent().subscribe(std::bind(&MockNotificationsClient::onSourceUpdatedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+ std::vector<am_MainSoundProperty_s> listMainSoundProperties;
+ am_MainSoundProperty_s prop;
+ prop.value = 1;
+ prop.type = am_MainSoundPropertyType_e::MSP_MAX;
+ listMainSoundProperties.push_back(prop);
+ EXPECT_CALL(mock, onSourceUpdatedEvent(1, 2, _));
+ env->mpPlugin->cbSourceUpdated(1, 2, listMainSoundProperties);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSourceUpdatedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onSinkNotificationEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSinkNotificationEvent().subscribe(std::bind(&MockNotificationsClient::onSinkNotificationEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+ am_NotificationPayload_s orig;
+ orig.type = am_NotificationType_e::NT_MAX;
+ orig.value = 1;
+ CommandInterface::am_NotificationPayload_s dest;
+ dest.type = org::genivi::audiomanager::am::am_NotificationType_e::NT_MAX;
+ dest.value = 1;
+
+ EXPECT_CALL(mock, onSinkNotificationEvent(1, dest));
+ env->mpPlugin->cbSinkNotification(1, orig);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSinkNotificationEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+
+TEST_F(CAmCommandSenderCAPITest, onSourceNotificationEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getSourceNotificationEvent().subscribe(std::bind(&MockNotificationsClient::onSourceNotificationEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+ am_NotificationPayload_s orig;
+ orig.type = am_NotificationType_e::NT_MAX;
+ orig.value = 1;
+ CommandInterface::am_NotificationPayload_s dest;
+ dest.type = org::genivi::audiomanager::am::am_NotificationType_e::NT_MAX;
+ dest.value = 1;
+
+ EXPECT_CALL(mock, onSourceNotificationEvent(1, dest));
+ env->mpPlugin->cbSourceNotification(1, orig);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getSourceNotificationEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onMainSinkNotificationConfigurationChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getMainSinkNotificationConfigurationChangedEvent().subscribe(std::bind(&MockNotificationsClient::onMainSinkNotificationConfigurationChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+ am_NotificationConfiguration_s orig;
+ orig.type = am_NotificationType_e::NT_MAX;
+ orig.parameter = 1;
+ orig.status = am_NotificationStatus_e::NS_MAX;
+ org::genivi::audiomanager::am::am_NotificationConfiguration_s dest;
+ dest.type = org::genivi::audiomanager::am::am_NotificationType_e::NT_MAX;
+ dest.parameter = 1;
+ dest.status = org::genivi::audiomanager::am::am_NotificationStatus_e::NS_MAX;
+
+ EXPECT_CALL(mock, onMainSinkNotificationConfigurationChangedEvent(1, dest));
+ env->mpPlugin->cbMainSinkNotificationConfigurationChanged(1, orig);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getMainSinkNotificationConfigurationChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
+TEST_F(CAmCommandSenderCAPITest, onMainSourceNotificationConfigurationChangedEventTest)
+{
+ ASSERT_TRUE(env->mIsServiceAvailable);
+ if(env->mIsServiceAvailable)
+ {
+ MockNotificationsClient mock;
+ auto subscription = env->mProxy->getMainSourceNotificationConfigurationChangedEvent().subscribe(std::bind(&MockNotificationsClient::onMainSourceNotificationConfigurationChangedEvent, std::ref(mock),
+ std::placeholders::_1, std::placeholders::_2));
+ am_NotificationConfiguration_s orig;
+ orig.type = am_NotificationType_e::NT_MAX;
+ orig.parameter = 1;
+ orig.status = am_NotificationStatus_e::NS_MAX;
+ org::genivi::audiomanager::am::am_NotificationConfiguration_s dest;
+ dest.type = org::genivi::audiomanager::am::am_NotificationType_e::NT_MAX;
+ dest.parameter = 1;
+ dest.status = org::genivi::audiomanager::am::am_NotificationStatus_e::NS_MAX;
+
+ EXPECT_CALL(mock, onMainSourceNotificationConfigurationChangedEvent(1, dest));
+ env->mpPlugin->cbMainSourceNotificationConfigurationChanged(1, orig);
+ SIMPLE_THREADS_SYNC_MICROSEC();
+ env->mProxy->getMainSourceNotificationConfigurationChangedEvent().unsubscribe(subscription);
+ }
+ EXPECT_TRUE(Mock::VerifyAndClearExpectations(env->mpCommandReceive));
+}
+
diff --git a/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.h b/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.h
new file mode 100644
index 0000000..21aafe8
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.h
@@ -0,0 +1,77 @@
+/**
+ * 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 COMMANDPLUGININTERFACETEST_H_
+#define COMMANDPLUGININTERFACETEST_H_
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "shared/CAmSocketHandler.h"
+#include "CAmTestCAPIWrapper.h"
+#include "../include/CAmCommandSenderCAPI.h"
+#include "MockIAmCommandReceive.h"
+#include <../src-gen/org/genivi/audiomanager/CommandInterfaceProxy.h>
+
+#define UNIT_TEST 1
+
+using namespace testing;
+using namespace CommonAPI;
+namespace am {
+
+class CAmCommandSenderDbusBackdoor;
+class IAmCommandSend;
+
+class CAmTestsEnvironment : public ::testing::Environment
+{
+ pthread_t mListenerThread;
+ pthread_t mServicePThread;
+ pthread_t mClientPThread;
+
+public:
+ CAmSocketHandler *mSocketHandlerService;
+ CAmSocketHandler *mSocketHandlerClient;
+ bool mIsProxyInitilized;
+ bool mIsServiceAvailable;
+ MockIAmCommandReceive *mpCommandReceive;
+ CAmCommandSenderCAPI *mpPlugin;
+
+ std::shared_ptr<CommandInterfaceProxy<> > mProxy;
+
+ CAmTestsEnvironment();
+ ~CAmTestsEnvironment();
+ void SetUp();
+ // Override this to define how to tear down the environment.
+ void TearDown();
+ void onServiceStatusEvent(const CommonAPI::AvailabilityStatus& serviceStatus);
+};
+
+
+class CAmCommandSenderCAPITest :public ::testing::Test
+{
+
+public:
+ CAmCommandSenderCAPITest();
+ ~CAmCommandSenderCAPITest();
+
+ void SetUp();
+ void TearDown();
+
+};
+
+}
+
+#endif /* COMMANDPLUGININTERFACETEST_H_ */
diff --git a/PluginCommandInterfaceCAPI/test/CAmTestCAPIWrapper.cpp b/PluginCommandInterfaceCAPI/test/CAmTestCAPIWrapper.cpp
new file mode 100644
index 0000000..6134d62
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/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/PluginCommandInterfaceCAPI/test/CAmTestCAPIWrapper.h b/PluginCommandInterfaceCAPI/test/CAmTestCAPIWrapper.h
new file mode 100644
index 0000000..90499f9
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/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/PluginCommandInterfaceCAPI/test/CMakeLists.txt b/PluginCommandInterfaceCAPI/test/CMakeLists.txt
new file mode 100644
index 0000000..acfc1cf
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/test/CMakeLists.txt
@@ -0,0 +1,105 @@
+# 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(CAmCommandSenderCAPITests)
+
+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"
+ "CAmCommandSenderCAPITest.cpp"
+ "CAmTestCAPIWrapper.cpp"
+ "CAmCommandSenderCommon.cpp"
+)
+
+file(GLOB_RECURSE CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX
+ "../src-gen/*.cpp"
+)
+
+ADD_EXECUTABLE(AmCommandSenderCAPITest ${CAPI_PLUGIN_INTERFACE_SRCS_CXX} ${CAPI_PLUGIN_INTERFACE_GEN_SRCS_CXX})
+
+TARGET_LINK_LIBRARIES(AmCommandSenderCAPITest
+ ${DLT_LIBRARIES}
+ ${DBUS_LIBRARY}
+ ${CMAKE_DL_LIBS}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${PYTHON_LIBRARY}
+ ${PC_GSTREAMER_LIBRARIES}
+ ${PC_COMMON_LIBRARIES}
+ ${PC_COMMON_DBUS_LIBRARIES}
+ gtest
+ gmock
+)
+
+CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/PluginCommandInterfaceCAPI/fidl/PluginCommandInterfaceCAPI_dbus.conf ${EXECUTABLE_OUTPUT_PATH}/AmCommandSenderCAPITest_dbus.conf)
+
+INSTALL(TARGETS AmCommandSenderCAPITest
+ 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/PluginCommandInterfaceCAPI/test/MockIAmCommandReceive.h b/PluginCommandInterfaceCAPI/test/MockIAmCommandReceive.h
new file mode 100644
index 0000000..23524e1
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/test/MockIAmCommandReceive.h
@@ -0,0 +1,86 @@
+/**
+ * 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 MOCKCOMMANDRECEIVENTERFACE_H_
+#define MOCKCOMMANDRECEIVENTERFACE_H_
+
+#include "command/IAmCommandReceive.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+namespace am {
+
+class MockIAmCommandReceive : public IAmCommandReceive {
+ public:
+ MOCK_CONST_METHOD1(getInterfaceVersion,
+ void(std::string& version));
+ MOCK_METHOD3(connect,
+ am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID));
+ MOCK_METHOD1(disconnect,
+ am_Error_e(const am_mainConnectionID_t mainConnectionID));
+ MOCK_METHOD2(setVolume,
+ am_Error_e(const am_sinkID_t sinkID, const am_mainVolume_t volume));
+ MOCK_METHOD2(volumeStep,
+ am_Error_e(const am_sinkID_t sinkID, const int16_t volumeStep));
+ MOCK_METHOD2(setSinkMuteState,
+ am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState));
+ MOCK_METHOD2(setMainSinkSoundProperty,
+ am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID));
+ MOCK_METHOD2(setMainSourceSoundProperty,
+ am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID));
+ MOCK_METHOD1(setSystemProperty,
+ am_Error_e(const am_SystemProperty_s& property));
+ MOCK_CONST_METHOD1(getListMainConnections,
+ am_Error_e(std::vector<am_MainConnectionType_s>& listConnections));
+ MOCK_CONST_METHOD1(getListMainSinks,
+ am_Error_e(std::vector<am_SinkType_s>& listMainSinks));
+ MOCK_CONST_METHOD1(getListMainSources,
+ am_Error_e(std::vector<am_SourceType_s>& listMainSources));
+ MOCK_CONST_METHOD2(getListMainSinkSoundProperties,
+ am_Error_e(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties));
+ MOCK_CONST_METHOD2(getListMainSourceSoundProperties,
+ am_Error_e(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties));
+ MOCK_CONST_METHOD1(getListSourceClasses,
+ am_Error_e(std::vector<am_SourceClass_s>& listSourceClasses));
+ MOCK_CONST_METHOD1(getListSinkClasses,
+ am_Error_e(std::vector<am_SinkClass_s>& listSinkClasses));
+ MOCK_CONST_METHOD1(getListSystemProperties,
+ am_Error_e(std::vector<am_SystemProperty_s>& listSystemProperties));
+ MOCK_CONST_METHOD2(getTimingInformation,
+ am_Error_e(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay));
+ MOCK_CONST_METHOD1(getDBusConnectionWrapper,
+ am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper));
+ MOCK_CONST_METHOD1(getSocketHandler,
+ am_Error_e(CAmSocketHandler*& socketHandler));
+ MOCK_METHOD2(confirmCommandReady,
+ void(const uint16_t handle, const am_Error_e error));
+ MOCK_METHOD2(confirmCommandRundown,
+ void(const uint16_t handle, const am_Error_e error));
+ MOCK_CONST_METHOD2(getListMainSinkNotificationConfigurations,
+ am_Error_e(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations));
+ MOCK_CONST_METHOD2(getListMainSourceNotificationConfigurations,
+ am_Error_e(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations));
+ MOCK_METHOD2(setMainSinkNotificationConfiguration,
+ am_Error_e(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration));
+ MOCK_METHOD2(setMainSourceNotificationConfiguration,
+ am_Error_e(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration));
+
+
+};
+
+} // namespace am
+#endif /* MOCKCOMMANDRECEIVENTERFACE_H_ */
diff --git a/PluginCommandInterfaceCAPI/test/MockNotificationsClient.h b/PluginCommandInterfaceCAPI/test/MockNotificationsClient.h
new file mode 100644
index 0000000..8ab2e5e
--- /dev/null
+++ b/PluginCommandInterfaceCAPI/test/MockNotificationsClient.h
@@ -0,0 +1,110 @@
+/**
+ * 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 MOCKNOTIFICATIONSCLIENT_H_
+#define MOCKNOTIFICATIONSCLIENT_H_
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include <org/genivi/audiomanager/CommandInterfaceStubDefault.h>
+
+
+namespace am {
+using namespace testing;
+using namespace CommonAPI;
+using namespace org::genivi::audiomanager;
+
+class IAmNotificationsClient
+{
+public:
+ IAmNotificationsClient()
+ {}
+
+ virtual ~IAmNotificationsClient()
+ {}
+ virtual void onNumberOfMainConnectionsChangedEvent() = 0;
+ virtual void onNumberOfSourceClassesChangedEvent() = 0;
+ virtual void onMainConnectionStateChangedEvent(CommandInterface::am_mainConnectionID_t, CommandInterface::am_ConnectionState_e) = 0;
+ virtual void onSourceAddedEvent(const CommandInterface::am_SourceType_s &) = 0;
+ virtual void onSourceRemovedEvent(CommandInterface::am_sourceID_t) = 0;
+ virtual void onMainSourceSoundPropertyChangedEvent(CommandInterface::am_sourceID_t, const CommandInterface::am_MainSoundProperty_s & ) = 0;
+ virtual void onSourceAvailabilityChangedEvent(CommandInterface::am_sourceID_t, const CommandInterface::am_Availability_s &) = 0;
+ virtual void onNumberOfSinkClassesChangedEvent() = 0;
+ virtual void onSinkAddedEvent(const CommandInterface::am_SinkType_s &) = 0;
+ virtual void onSinkRemovedEvent(CommandInterface::am_sinkID_t) = 0;
+ virtual void onMainSinkSoundPropertyChangedEvent(CommandInterface::am_sinkID_t, const CommandInterface::am_MainSoundProperty_s &) = 0;
+ virtual void onSinkAvailabilityChangedEvent(CommandInterface::am_sinkID_t, const CommandInterface::am_Availability_s &) = 0;
+ virtual void onVolumeChangedEvent(CommandInterface::am_sinkID_t, CommandInterface::am_mainVolume_t) = 0;
+ virtual void onSinkMuteStateChangedEvent(CommandInterface::am_sinkID_t, CommandInterface::am_MuteState_e) = 0;
+ virtual void onSystemPropertyChangedEvent(const CommandInterface::am_SystemProperty_s &) = 0;
+ virtual void onTimingInformationChangedEvent(CommandInterface::am_mainConnectionID_t, CommandInterface::am_timeSync_t) = 0;
+ virtual void onSinkUpdatedEvent(CommandInterface::am_sinkID_t, CommandInterface::am_sinkClass_t, const CommandInterface::am_MainSoundProperty_l &) = 0;
+ virtual void onSourceUpdatedEvent(CommandInterface::am_sourceID_t, CommandInterface::am_sourceClass_t, const CommandInterface::am_MainSoundProperty_l &) = 0;
+ virtual void onSinkNotificationEvent(CommandInterface::am_sinkID_t, const CommandInterface::am_NotificationPayload_s & ) = 0;
+ virtual void onSourceNotificationEvent(CommandInterface::am_sourceID_t, const CommandInterface::am_NotificationPayload_s &) = 0;
+ virtual void onMainSinkNotificationConfigurationChangedEvent(CommandInterface::am_sinkID_t, const org::genivi::audiomanager::am::am_NotificationConfiguration_s &) = 0;
+ virtual void onMainSourceNotificationConfigurationChangedEvent(CommandInterface::am_sourceID_t, const org::genivi::audiomanager::am::am_NotificationConfiguration_s &) = 0;
+};
+
+class MockNotificationsClient : public IAmNotificationsClient {
+ public:
+ MOCK_METHOD0(onNumberOfMainConnectionsChangedEvent,
+ void());
+ MOCK_METHOD0(onNumberOfSourceClassesChangedEvent, void());
+ MOCK_METHOD2(onMainConnectionStateChangedEvent,
+ void(CommandInterface::am_mainConnectionID_t mcID, CommandInterface::am_ConnectionState_e cs));
+ MOCK_METHOD1(onSourceAddedEvent, void(const CommandInterface::am_SourceType_s & st));
+ MOCK_METHOD1(onSourceRemovedEvent, void(CommandInterface::am_sourceID_t sid));
+ MOCK_METHOD2(onMainSourceSoundPropertyChangedEvent,
+ void(CommandInterface::am_sourceID_t sid, const CommandInterface::am_MainSoundProperty_s & msp) );
+ MOCK_METHOD2(onSourceAvailabilityChangedEvent,
+ void(CommandInterface::am_sourceID_t st, const CommandInterface::am_Availability_s & a) );
+ MOCK_METHOD0(onNumberOfSinkClassesChangedEvent,
+ void());
+ MOCK_METHOD1(onSinkAddedEvent,
+ void(const CommandInterface::am_SinkType_s & st));
+ MOCK_METHOD1(onSinkRemovedEvent,
+ void(CommandInterface::am_sinkID_t sid));
+ MOCK_METHOD2(onMainSinkSoundPropertyChangedEvent,
+ void(CommandInterface::am_sinkID_t sid, const CommandInterface::am_MainSoundProperty_s & msp) );
+ MOCK_METHOD2(onSinkAvailabilityChangedEvent,
+ void(CommandInterface::am_sinkID_t sid, const CommandInterface::am_Availability_s & a) );
+ MOCK_METHOD2(onVolumeChangedEvent,
+ void(CommandInterface::am_sinkID_t sid, CommandInterface::am_mainVolume_t mv) );
+ MOCK_METHOD2(onSinkMuteStateChangedEvent,
+ void(CommandInterface::am_sinkID_t sid, CommandInterface::am_MuteState_e ms) );
+ MOCK_METHOD1(onSystemPropertyChangedEvent,
+ void(const CommandInterface::am_SystemProperty_s & sp));
+ MOCK_METHOD2(onTimingInformationChangedEvent,
+ void(CommandInterface::am_mainConnectionID_t cid, CommandInterface::am_timeSync_t ts) );
+ MOCK_METHOD3(onSinkUpdatedEvent,
+ void(CommandInterface::am_sinkID_t sid, CommandInterface::am_sinkClass_t sc, const CommandInterface::am_MainSoundProperty_l & msp) );
+ MOCK_METHOD3(onSourceUpdatedEvent,
+ void(CommandInterface::am_sourceID_t sid, CommandInterface::am_sourceClass_t sc, const CommandInterface::am_MainSoundProperty_l & msp) );
+ MOCK_METHOD2(onSinkNotificationEvent,
+ void(CommandInterface::am_sinkID_t sid, const CommandInterface::am_NotificationPayload_s & np));
+ MOCK_METHOD2(onSourceNotificationEvent,
+ void(CommandInterface::am_sourceID_t sid, const CommandInterface::am_NotificationPayload_s & np) );
+ MOCK_METHOD2(onMainSinkNotificationConfigurationChangedEvent,
+ void(CommandInterface::am_sinkID_t sid, const org::genivi::audiomanager::am::am_NotificationConfiguration_s & nc) );
+ MOCK_METHOD2(onMainSourceNotificationConfigurationChangedEvent,
+ void(CommandInterface::am_sourceID_t sid, const org::genivi::audiomanager::am::am_NotificationConfiguration_s & nc));
+};
+
+} // namespace am
+#endif /* MOCKCOMMANDRECEIVENTERFACE_H_ */