summaryrefslogtreecommitdiff
path: root/PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp')
-rw-r--r--PluginCommandInterfaceCAPI/test/CAmCommandSenderCAPITest.cpp1101
1 files changed, 1101 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));
+}
+