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
    {
    	ON_CALL(*env->mpCommandReceive, getListMainSources(_)).WillByDefault(Return(E_OK));
    	ON_CALL(*env->mpCommandReceive, getListMainSinks(_)).WillByDefault(Return(E_OK));
    	ON_CALL(*env->mpCommandReceive, getListMainSourceSoundProperties(_,_)).WillByDefault(Return(E_OK));

    	EXPECT_CALL(*env->mpCommandReceive,confirmCommandReady(10,_));
    	plugin.setCommandReady(10);
    	socketHandler.start_listenting();

    	EXPECT_CALL(*env->mpCommandReceive,confirmCommandRundown(10,_));
    	plugin.setCommandRundown(10);
    	plugin.tearDownInterface(env->mpCommandReceive);
    }

//Cleanup
    env->mpPlugin = NULL;
    env->mpCommandReceive = NULL;
    env->mSocketHandlerClient = NULL;

    return (NULL);
}
Esempio n. 2
0
TEST_F(CAmRoutingReceiverAsync,setDomainState)
{
    am_domainID_t domainID = 1;
    am_DomainState_e state = DS_INDEPENDENT_RUNDOWN;

    EXPECT_CALL(pReceiveInterface,hookDomainStateChange(_,DS_INDEPENDENT_RUNDOWN)).Times(1);

    ASSERT_EQ(E_OK, pRouter->setDomainState(domainID,state));
    pSocketHandler.start_listenting();
}
Esempio n. 3
0
TEST_F(CAmRoutingReceiverAsync,disconnectNonExisting)
{

    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_DISCONNECT;

    am_connectionID_t connectionID = 4;

    EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
    EXPECT_CALL(pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0);
    ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncDisconnect(handle,connectionID));
    pSocketHandler.start_listenting();
}
Esempio n. 4
0
TEST_F(CAmRoutingReceiverAsync,connectWrongSource)
{
    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_CONNECT;

    am_connectionID_t connectionID = 4;
    am_sourceID_t sourceID = 25;
    am_sinkID_t sinkID = 1;
    am_ConnectionFormat_e format = CF_GENIVI_ANALOG;

    EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0);
    ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
    pSocketHandler.start_listenting();
}
Esempio n. 5
0
TEST_F(CAmRoutingReceiverAsync,setSourceState)
{

    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_SETSOURCESTATE;

    am_sourceID_t sourceID = 1;
    am_SourceState_e state = SS_OFF;

    EXPECT_CALL(pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1);

    ASSERT_EQ(E_OK, pRouter->asyncSetSourceState(handle,sourceID,state));
    pSocketHandler.start_listenting();
}
Esempio n. 6
0
void CAmEnvironment::SetUp()
{
    logInfo("RoutingSendInterface Test started ");

    std::vector<int> domainIDs;
    domainIDs.push_back(0);
    domainIDs.push_back(1);

    EXPECT_CALL(pReceiveInterface,getSocketHandler(_)).WillOnce(DoAll(SetArgReferee<0>(&pSocketHandler), Return(E_OK)));
    EXPECT_CALL(pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleDomainRegister));
    EXPECT_CALL(pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSourceRegister));
    EXPECT_CALL(pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSinkRegister));
    EXPECT_CALL(pReceiveInterface,confirmRoutingReady(_)).Times(1);

    IAmRoutingSend* (*createFunc)();
    void* tempLibHandle = NULL;
    std::string libname("../plugins/routing/libPluginRoutingInterfaceAsync.so");
    createFunc = getCreateFunction<IAmRoutingSend*()>(libname, tempLibHandle);

    if (!createFunc)
    {
        logError("RoutingSendInterface Test Entry point of RoutingPlugin not found");
        exit(1);
    }

    pRouter = createFunc();

    if (!pRouter)
    {
        logError("RoutingSendInterface Test RoutingPlugin initialization failed. Entry Function not callable");
        exit(1);
    }

    pRouter->startupInterface(&pReceiveInterface);
    pRouter->setRoutingReady(10);

    timespec t;
    t.tv_nsec = 500000000;
    t.tv_sec = 1;

    sh_timerHandle_t handle;

    //lets use a timeout so the test will finish
    pSocketHandler.addTimer(t, &ptimerCallback, handle, (void*) NULL);
    pSocketHandler.start_listenting();

}
Esempio n. 7
0
TEST_F(CAmRoutingReceiverAsync,setSinkSoundProperty)
{

    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_SETSINKSOUNDPROPERTY;

    am_sinkID_t sinkID = 1;
    am_SoundProperty_s property;
    property.type = SP_EXAMPLE_MID;
    property.value = 24;

    EXPECT_CALL(pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1);

    ASSERT_EQ(E_OK, pRouter->asyncSetSinkSoundProperty(handle,sinkID,property));
    pSocketHandler.start_listenting();
}
Esempio n. 8
0
TEST_F(CAmRoutingReceiverAsync,connectAbort)
{

    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_CONNECT;

    am_connectionID_t connectionID = 4;
    am_sourceID_t sourceID = 2;
    am_sinkID_t sinkID = 1;
    am_ConnectionFormat_e format = CF_GENIVI_ANALOG;

    EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1);
    ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
    sleep(0.5);
    ASSERT_EQ(E_OK, pRouter->asyncAbort(handle));
    pSocketHandler.start_listenting();
}
Esempio n. 9
0
TEST_F(CAmRoutingReceiverAsync,setSinkVolume)
{

    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_SETSINKVOLUME;

    am_sinkID_t sinkID = 1;
    am_volume_t volume = 9;
    am_RampType_e ramp = RAMP_GENIVI_DIRECT;
    am_time_t myTime = 25;

    EXPECT_CALL(pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(AtLeast(2));
    EXPECT_CALL(pReceiveInterface,ackSetSinkVolumeChange(_,volume,E_OK)).Times(1);

    ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime));
    pSocketHandler.start_listenting();
}
Esempio n. 10
0
TEST_F(CAmRoutingReceiverAsync,setSinkVolumeAbort)
{

    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_SETSINKVOLUME;

    am_sinkID_t sinkID = 2;
    am_volume_t volume = 25;
    am_RampType_e ramp = RAMP_GENIVI_DIRECT;
    am_time_t myTime = 25;

    EXPECT_CALL(pReceiveInterface, ackSinkVolumeTick(_,sinkID,_));
    EXPECT_CALL(pReceiveInterface,ackSetSinkVolumeChange(_,AllOf(Ne(volume),Ne(0)),E_ABORTED)).Times(1);

    ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime));
    sleep(0.5);
    ASSERT_EQ(E_OK, pRouter->asyncAbort(handle));
    pSocketHandler.start_listenting();
}
void* run_client(void*)
{
	CAmSocketHandler socketHandler;
	CAmTestCAPIWrapper wrapper(&socketHandler);
	env->mSocketHandlerClient = &socketHandler;
	std::shared_ptr<CommonAPI::Factory> factory = wrapper.factory();
	env->mProxy = factory->buildProxy<org::genivi::am::CommandControlProxy>(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);
}
Esempio n. 12
0
TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads)
{

    am_Handle_s handle;
    handle.handle = 1;
    handle.handleType = H_CONNECT;

    am_connectionID_t connectionID = 1;
    am_sourceID_t sourceID = 2;
    am_sinkID_t sinkID = 1;
    am_ConnectionFormat_e format = CF_GENIVI_ANALOG;

    EXPECT_CALL(pReceiveInterface,ackConnect(_,_,E_OK)).Times(10);
    for (int i = 0; i < 10; i++)
    {
        handle.handle++;
        connectionID++;
        ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
    }
    ASSERT_EQ(E_NOT_POSSIBLE, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format));
    pSocketHandler.start_listenting();
}
void* run_the_loop(void* wrapper)
{
    CAmSocketHandler* wrap = (CAmSocketHandler*) wrapper;
    wrap->start_listenting();
    return (NULL);
}
Esempio n. 14
0
void mainProgram()
{
    //Instantiate all classes. Keep in same order !
    CAmSocketHandler iSocketHandler;

#ifdef WITH_CAPI_WRAPPER
    //We instantiate a singleton with the current socket handler, which loads the common-api runtime.
    CAmCommonAPIWrapper *pCAPIWrapper = CAmCommonAPIWrapper::instantiateOnce(&iSocketHandler);
    CAmCommonAPIWrapper iDBusWrapper = *pCAPIWrapper;
#ifdef WITH_NSM
    CAmNodeStateCommunicatorCAPI iNodeStateCommunicator(&iDBusWrapper);
#endif /*WITH_NSM*/
#endif /*WITH_CAPI_WRAPPER */

#ifdef WITH_DBUS_WRAPPER
    CAmDbusWrapper iDBusWrapper(&iSocketHandler,dbusWrapperType);
#ifdef WITH_NSM
    CAmNodeStateCommunicatorDBus iNodeStateCommunicator(&iDBusWrapper);
#endif /*WITH_NSM*/
#endif /*WITH_DBUS_WRAPPER */

#ifdef WITH_SYSTEMD_WATCHDOG
    CAmWatchdog iWatchdog(&iSocketHandler);
#endif /*WITH_SYSTEMD_WATCHDOG*/

#ifdef WITH_DATABASE_STORAGE
    CAmDatabaseHandlerSQLite iDatabaseHandler(databasePath);
#else
    CAmDatabaseHandlerMap iDatabaseHandler;
#endif /*WITH_DATABASE_STORAGE*/
    IAmDatabaseHandler *pDatabaseHandler = dynamic_cast<IAmDatabaseHandler*>( &iDatabaseHandler );

    CAmRoutingSender iRoutingSender(listRoutingPluginDirs, iSocketHandler);
    CAmCommandSender iCommandSender(listCommandPluginDirs);
    CAmControlSender iControlSender(controllerPlugin,&iSocketHandler);
    CAmRouter iRouter(pDatabaseHandler, &iControlSender);

#ifdef WITH_DBUS_WRAPPER
    CAmCommandReceiver iCommandReceiver(pDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper);
    CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper);
#else /*WITH_DBUS_WRAPPER*/
	    CAmCommandReceiver iCommandReceiver(pDatabaseHandler,&iControlSender,&iSocketHandler);
	    CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
#endif /*WITH_DBUS_WRAPPER*/

#ifdef WITH_NSM
	CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator);
	iNodeStateCommunicator.registerControlSender(&iControlSender);
#else /*WITH_NSM*/
	CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
#endif /*WITH_NSM*/

#ifdef WITH_TELNET
    CAmTelnetServer iTelnetServer(&iSocketHandler, &iCommandSender, &iCommandReceiver, &iRoutingSender, &iRoutingReceiver, &iControlSender, &iControlReceiver, pDatabaseHandler, &iRouter, telnetport, maxConnections);
    CAmDatabaseObserver iObserver(&iCommandSender, &iRoutingSender, &iSocketHandler, &iTelnetServer);
#else /*WITH_TELNET*/
    CAmDatabaseObserver iObserver(&iCommandSender,&iRoutingSender, &iSocketHandler);
#endif

    iDatabaseHandler.registerObserver(&iObserver);

    //startup all the Plugins and Interfaces
    iControlSender.startupController(&iControlReceiver);
    iCommandSender.startupInterfaces(&iCommandReceiver);
    iRoutingSender.startupInterfaces(&iRoutingReceiver);

    //when the routingInterface is done, all plugins are loaded:
    iControlSender.setControllerReady();

#ifdef WITH_SYSTEMD_WATCHDOG
    iWatchdog.startWatchdog();
#endif /*WITH_SYSTEMD_WATCHDOG*/

    //start the mainloop here....
    iSocketHandler.start_listenting();
}