summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/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 /AudioManagerDaemon/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 'AudioManagerDaemon/test')
-rw-r--r--AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt2
-rw-r--r--AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt2
-rw-r--r--AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt2
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp262
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h65
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt119
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py179
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/org.genivi.NodeStateManager.Consumer.xml (renamed from AudioManagerDaemon/test/AmNodeStateCommunicatorTest/org.genivi.NodeStateManager.Consumer.xml)0
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/send2nsm.py (renamed from AudioManagerDaemon/test/AmNodeStateCommunicatorTest/send2nsm.py)0
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.cpp (renamed from AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.cpp)7
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.h (renamed from AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.h)4
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CMakeLists.txt (renamed from AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CMakeLists.txt)12
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/nsm.py (renamed from AudioManagerDaemon/test/AmNodeStateCommunicatorTest/nsm.py)0
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml259
-rw-r--r--AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py68
-rw-r--r--AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt6
-rw-r--r--AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt6
-rw-r--r--AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt6
-rw-r--r--AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt6
-rw-r--r--AudioManagerDaemon/test/CAmCommonFunctions.cpp2
-rw-r--r--AudioManagerDaemon/test/CMakeLists.txt7
21 files changed, 988 insertions, 26 deletions
diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt
index 86f0da2..80bfa90 100644
--- a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt
@@ -62,7 +62,7 @@ file(GLOB CONTROL_INTERFACE_SRCS_CXX
IF(WITH_NSM)
SET (CONTROL_INTERFACE_SRCS_CXX
${CONTROL_INTERFACE_SRCS_CXX}
- "../../src/CAmNodeStateCommunicator.cpp")
+ "../../src/CAmNodeStateCommunicatorDBus.cpp")
ENDIF(WITH_NSM)
ADD_EXECUTABLE(AmControlInterfaceTest ${CONTROL_INTERFACE_SRCS_CXX})
diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt
index 7899588..032cdbb 100644
--- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt
@@ -63,7 +63,7 @@ file(GLOB DATABASE_SRCS_CXX
IF(WITH_NSM)
SET (DATABASE_SRCS_CXX
${DATABASE_SRCS_CXX}
- "../../src/CAmNodeStateCommunicator.cpp")
+ "../../src/CAmNodeStateCommunicatorDBus.cpp")
ENDIF(WITH_NSM)
ADD_EXECUTABLE( AmDatabaseHandlerTest ${DATABASE_SRCS_CXX})
diff --git a/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt
index 0e081ae..493de6a 100644
--- a/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt
@@ -63,7 +63,7 @@ file(GLOB DATABASE_SRCS_CXX
IF(WITH_NSM)
SET (DATABASE_SRCS_CXX
${DATABASE_SRCS_CXX}
- "../../src/CAmNodeStateCommunicator.cpp")
+ "../../src/CAmNodeStateCommunicatorDBus.cpp")
ENDIF(WITH_NSM)
ADD_EXECUTABLE( AmMapHandlerTest ${DATABASE_SRCS_CXX})
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp
new file mode 100644
index 0000000..0833dde
--- /dev/null
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.cpp
@@ -0,0 +1,262 @@
+/**
+ * Copyright (C) 2012, BMW AG
+ *
+ * This file is part of GENIVI Project AudioManager.
+ *
+ * Contributions are licensed to the GENIVI Alliance under one or more
+ * Contribution License Agreements.
+ *
+ * \copyright
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+ * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ *
+* \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \file CAmNodeStateCommunicatorTest.cpp
+ * For further information see http://www.genivi.org/.
+ *
+ */
+
+#include "CAmNodeStateCommunicatorTest.h"
+#include "shared/CAmDltWrapper.h"
+#include "shared/CAmSocketHandler.h"
+
+#include <unistd.h>
+
+using namespace testing;
+using namespace am;
+
+static CAmEnvironment* env;
+
+
+CAmNodeStateCommunicatorTest::CAmNodeStateCommunicatorTest()
+{
+ std::cout<<"Exec path : " << EXECUTABLE_OUTPUT_PATH <<std::endl;
+}
+
+CAmNodeStateCommunicatorTest::~CAmNodeStateCommunicatorTest()
+{
+ // TODO Auto-generated destructor stub
+}
+
+/**This is the thread for the nsm python fake
+ *
+ * @param
+ */
+void* nsmThread (void*)
+{
+ system("python nsm.py");
+ return (NULL);
+}
+
+/**this is the thread the mainloop runs in
+ *
+ * @param importHandler
+ */
+void* mainLoop(void* importHandler)
+{
+ CAmSocketHandler* handler=static_cast<CAmSocketHandler*>(importHandler);
+ handler->start_listenting();
+ return (NULL);
+}
+
+
+TEST_F(CAmNodeStateCommunicatorTest, nsmChangeNodeState)
+{
+ assert(true == env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface));
+ NsmNodeState_e newstate(NsmNodeState_BaseRunning) ;
+ EXPECT_CALL(pMockControlInterface,hookSystemNodeStateChanged(newstate));
+ std::ostringstream send;
+ send<<"python send2nsm.py nodeState "<<static_cast<std::int32_t>(newstate);
+ system(send.str().c_str());
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, nsmChangeApplicationMode)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ NsmApplicationMode_e appmode(NsmApplicationMode_Swl) ;
+ EXPECT_CALL(pMockControlInterface,hookSystemNodeApplicationModeChanged(appmode));
+ std::ostringstream send;
+ send<<"python send2nsm.py appMode "<<static_cast<std::int32_t>(appmode);
+ system(send.str().c_str());
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, nsmChangeSessionState)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ std::string sessionName("mySession");
+ NsmSeat_e seatID(NsmSeat_CoDriver);
+ NsmSessionState_e sessionState(NsmSessionState_Inactive) ;
+ EXPECT_CALL(pMockControlInterface,hookSystemSessionStateChanged(sessionName,seatID,sessionState));
+ std::ostringstream send;
+ send<<"python send2nsm.py sessionState "<<sessionName<<" "<<static_cast<std::int32_t>(seatID)<<" "<<static_cast<int32_t>(sessionState);
+ system(send.str().c_str());
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, getRestartReason)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ NsmRestartReason_e restartReason;
+ ASSERT_EQ(E_OK,env->nsmController.nsmGetRestartReasonProperty(restartReason));
+ ASSERT_EQ(restartReason,1);
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, getShutdownReason)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ NsmShutdownReason_e ShutdownReason;
+ ASSERT_EQ(E_OK,env->nsmController.nsmGetShutdownReasonProperty(ShutdownReason));
+ ASSERT_EQ(ShutdownReason,2);
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, getWakeUpReason)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ NsmRunningReason_e WakeUpReason;
+ ASSERT_EQ(E_OK,env->nsmController.nsmGetRunningReasonProperty(WakeUpReason));
+ ASSERT_EQ(WakeUpReason,3);
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, getNodeState)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ NsmNodeState_e nodeState;
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetNodeState(nodeState));
+ ASSERT_EQ(nodeState,1);
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, getApplicationMode)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ NsmApplicationMode_e applicationMode;
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Error,env->nsmController.nsmGetApplicationMode(applicationMode));
+ ASSERT_EQ(applicationMode,5);
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, getSessionState)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ std::string sessionName("mySession");
+ NsmSeat_e seatID(NsmSeat_Driver);
+ NsmSessionState_e sessionState;
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetSessionState(sessionName,seatID,sessionState));
+ ASSERT_EQ(sessionState,5);
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, RegisterShutdownClient)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ uint32_t shutdownmode(1), timeoutMs(100);
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, receiveLifecycleRequest)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ uint32_t shutdownmode(1);
+ uint32_t timeoutMs(100);
+ int32_t Request(1);
+ int32_t RequestID(4);
+ EXPECT_CALL(pMockControlInterface,hookSystemLifecycleRequest(_,RequestID)).WillOnce(Return(NsmErrorStatus_e::NsmErrorStatus_Ok));
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
+ std::ostringstream send;
+ send << "python send2nsm.py LifecycleRequest "<<Request<<" "<<RequestID;
+ system(send.str().c_str());
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, UnRegisterShutdownClient)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ uint32_t shutdownmode(1),timeoutMs(100);
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs));
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmUnRegisterShutdownClient(shutdownmode));
+
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, sendLifecycleRequestComplete)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ uint32_t RequestID(22);
+ NsmErrorStatus_e errorStatus(NsmErrorStatus_Internal);
+ ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmSendLifecycleRequestComplete(RequestID,errorStatus));
+}
+
+TEST_F(CAmNodeStateCommunicatorTest, getInterfaceVersion)
+{
+ env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ uint32_t version(0);
+ ASSERT_EQ(E_OK,env->nsmController.nsmGetInterfaceVersion(version));
+ ASSERT_EQ(version,static_cast<uint32_t>(23));
+}
+
+void CAmNodeStateCommunicatorTest::SetUp()
+{
+}
+
+void CAmNodeStateCommunicatorTest::TearDown()
+{
+}
+
+int main(int argc, char **argv)
+{
+ CAmDltWrapper::instance()->registerApp("nsm", "nsmtest");
+ logInfo("nsmtest Test started ");
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::Environment* const env = ::testing::AddGlobalTestEnvironment(new CAmEnvironment);
+ (void) env;
+ return RUN_ALL_TESTS();
+}
+
+CAmEnvironment::CAmEnvironment() :
+ pControlInterfaceBackdoor(),
+ pControlSender(),
+ iSocketHandler(),
+ wrapper(CAmCommonAPIWrapper::instantiateOnce(&iSocketHandler)),
+ nsmController(wrapper),
+ pNsmThread(0),
+ pMainLoopThread(0)
+{
+ env=this;
+}
+
+CAmEnvironment::~CAmEnvironment()
+{
+}
+
+void CAmEnvironment::waitUntilAvailable(unsigned short seconds = 10)
+{
+ int countTries = 0;
+ printf("\nWaiting for service");
+ while( countTries++<seconds )
+ {
+ printf(".");
+ if(nsmController.isServiceAvailable())
+ break;
+ else
+ sleep(1);
+ }
+ printf("\n");
+}
+
+void CAmEnvironment::SetUp()
+{
+ //create the nsm thread
+ pthread_create(&pNsmThread, NULL, nsmThread, NULL);
+ nsmController.registerControlSender(&pControlSender);
+ //create the mainloop thread
+ pthread_create(&pMainLoopThread, NULL, mainLoop, (void*)&iSocketHandler);
+ printf("[----------] Waiting for interface to be ready....\r\n");
+ waitUntilAvailable(10);
+}
+
+void CAmEnvironment::TearDown()
+{
+ //end the nsm per dbus
+ system("python send2nsm.py finish");
+ pthread_join(pNsmThread, NULL);
+ //end the mainloop
+ iSocketHandler.exit_mainloop();
+ pthread_join(pMainLoopThread, NULL);
+}
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h
new file mode 100644
index 0000000..c6a9a5a
--- /dev/null
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CAmNodeStateCommunicatorTest.h
@@ -0,0 +1,65 @@
+/**
+ * Copyright (C) 2012, BMW AG
+ *
+ * This file is part of GENIVI Project AudioManager.
+ *
+ * Contributions are licensed to the GENIVI Alliance under one or more
+ * Contribution License Agreements.
+ *
+ * \copyright
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+ * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ *
+* \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
+ *
+ * \file CAmNodeStateCommunicatorTest.h
+ * For further information see http://www.genivi.org/.
+ *
+ */
+
+
+#ifndef CAMNODESTATECOMMUNICATORTEST_H_
+#define CAMNODESTATECOMMUNICATORTEST_H_
+
+#include "CAmNodeStateCommunicatorCAPI.h"
+#include "CAmControlSender.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+#include "../IAmControlBackdoor.h"
+#include "../MockIAmControlSend.h"
+#include "shared/CAmCommonAPIWrapper.h"
+
+using namespace testing;
+using namespace am;
+
+class CAmEnvironment : public ::testing::Environment
+{
+public:
+ IAmControlBackdoor pControlInterfaceBackdoor;
+ CAmControlSender pControlSender;
+ CAmSocketHandler iSocketHandler;
+ CAmCommonAPIWrapper *wrapper;
+ CAmNodeStateCommunicatorCAPI nsmController;
+ pthread_t pNsmThread, pMainLoopThread;
+ CAmEnvironment();
+ ~CAmEnvironment();
+ void SetUp();
+ // Override this to define how to tear down the environment.
+ void TearDown();
+ void waitUntilAvailable(unsigned short seconds);
+};
+
+class CAmNodeStateCommunicatorTest:public ::testing::Test
+{
+public:
+ MockIAmControlSend pMockControlInterface;
+ CAmNodeStateCommunicatorTest();
+ virtual ~CAmNodeStateCommunicatorTest();
+ void SetUp();
+ void TearDown();
+};
+
+
+#endif /* CAMNODESTATECOMMUNICATORTEST_H_ */
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt
new file mode 100644
index 0000000..4817c24
--- /dev/null
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/CMakeLists.txt
@@ -0,0 +1,119 @@
+# 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(AmNodeStateCommunicatorCAPITest)
+
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
+
+set(STD_INCLUDE_DIRS "/usr/include")
+SET(COMMON_API_SRC_GEN "../../src-gen/")
+set(EXECUTABLE_OUTPUT_PATH ${TEST_EXECUTABLE_OUTPUT_PATH})
+
+FIND_PACKAGE(Threads)
+FIND_PACKAGE(PkgConfig)
+pkg_check_modules(SQLITE REQUIRED sqlite3)
+
+FIND_PACKAGE(CommonAPI REQUIRED)
+FIND_PACKAGE(CommonAPI_DBus REQUIRED)
+
+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}
+ ${INCLUDE_FOLDER}
+ ${PYTHON_INCLUDE_DIRS}
+ ${GOOGLE_TEST_INCLUDE_DIR}
+ ${GMOCK_INCLUDE_DIR}
+ "../../include"
+ ${COMMON_API_INCLUDE_DIRS}
+ ${COMMON_API_DBUS_INCLUDE_DIRS}
+ ${COMMON_API_GEN_INCLUDE_DIR}
+)
+
+
+file(GLOB NODESTATECOMMUNICATORCAPI
+ "../../src/CAmDatabaseHandler.cpp"
+ "../../src/CAmDatabaseObserver.cpp"
+ "../../src/CAmRoutingSender.cpp"
+ "../../src/CAmRoutingReceiver.cpp"
+ "../../src/CAmCommonAPIWrapper.cpp"
+ "../../src/CAmDltWrapper.cpp"
+ "../../src/CAmSocketHandler.cpp"
+ "../../src/CAmNodeStateCommunicatorCAPI.cpp"
+ "../../src/CAmControlSender.cpp"
+ "../../src/CAmCommandSender.cpp"
+ "../../src/CAmCommandReceiver.cpp"
+ "../CAmCommonFunctions.cpp"
+ "../../src/CAmRouter.cpp"
+ "*.cpp"
+ ${COMMON_API_GEN_SOURCES}
+ )
+
+CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/fidls/AudioManager_dbus.conf.in ${CMAKE_BINARY_DIR}/AmNodeStateCommunicatorCAPITest_dbus.conf)
+
+ADD_EXECUTABLE(AmNodeStateCommunicatorCAPITest ${NODESTATECOMMUNICATORCAPI} ${COMMON_API_GEN_SOURCES})
+
+TARGET_LINK_LIBRARIES(AmNodeStateCommunicatorCAPITest
+ ${SQLITE_LIBRARIES}
+ ${DLT_LIBRARIES}
+ ${CMAKE_DL_LIBS}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${PYTHON_LIBRARY}
+ ${COMMON_API_LIBRARIES}
+ ${COMMON_API_DBUS_LIBRARIES}
+ gtest
+ gmock
+)
+
+ADD_DEPENDENCIES(AmNodeStateCommunicatorCAPITest gtest gmock)
+
+INSTALL(TARGETS AmNodeStateCommunicatorCAPITest
+ DESTINATION "~/AudioManagerTest/"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+ COMPONENT tests
+)
+
+INSTALL(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml
+ ${CMAKE_CURRENT_SOURCE_DIR}/nsm.py
+ ${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py
+ DESTINATION "~/AudioManagerTest/"
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
+ COMPONENT tests
+)
+
+IF(USE_BUILD_LIBS)
+ execute_process(
+ COMMAND mkdir -p ${EXECUTABLE_OUTPUT_PATH}
+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml" ${EXECUTABLE_OUTPUT_PATH}/org.genivi.NodeStateManager.Consumer.xml
+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/nsm.py" ${EXECUTABLE_OUTPUT_PATH}/nsm.py
+ COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py" ${EXECUTABLE_OUTPUT_PATH}/send2nsm.py
+ COMMAND cp "${CMAKE_BINARY_DIR}/AmNodeStateCommunicatorCAPITest_dbus.conf" ${EXECUTABLE_OUTPUT_PATH})
+ENDIF(USE_BUILD_LIBS)
+
+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/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py
new file mode 100644
index 0000000..74dae54
--- /dev/null
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/nsm.py
@@ -0,0 +1,179 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012, BMW AG
+#
+# This file is part of GENIVI Project AudioManager.
+#
+# Contributions are licensed to the GENIVI Alliance under one or more
+# Contribution License Agreements.
+#
+# \copyright
+# This Source Code Form is subject to the terms of the
+# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#
+# \author Christian Linke, christian.linke@bmw.de BMW 2012
+#
+# For further information see http://www.genivi.org/.
+#
+
+import sys
+import traceback
+import gobject
+import math
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+loop = gobject.MainLoop()
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+class NodeStateManager(dbus.service.Object):
+ def __init__(self, loop):
+ busName = dbus.service.BusName('org.genivi.NodeStateManager', bus = dbus.SessionBus())
+ dbus.service.Object.__init__(self, busName, '/org/genivi/NodeStateManager')
+ self.properties = {'RestartReason': 1, 'ShutdownReason': 2, 'WakeUpReason' :3, 'BootMode' :4}
+ self.ABus=""
+ self.APath=""
+ self.loop=loop
+
+ @dbus.service.method(dbus_interface='org.freedesktop.DBus.Introspectable', out_signature = 's')
+ def Introspect(self):
+ f = open('org.genivi.NodeStateManager.Consumer.xml', "r")
+ text = f.read()
+ return text
+
+ @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'ii')
+ def GetNodeState(self):
+ NodeStateId=1
+ ErrorCode=1
+ print('[-----nsm-----] send out nodeState' + str(NodeStateId) + ' ErrorCode '+ str(1))
+ return NodeStateId, ErrorCode
+
+ @dbus.service.method('org.genivi.NodeStateManager.Consumer', out_signature = 'ii')
+ def GetApplicationMode(self):
+ ApplicationModeId=5
+ ErrorCode=2
+ print('[-----nsm-----] send out ApplicationMode' + str(ApplicationModeId) + ' ErrorCode '+ str(2))
+ return ApplicationModeId, ErrorCode
+
+ @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='si', out_signature = 'ii')
+ def GetSessionState(self,SessionName,seatID):
+ SessionState=0
+ ErrorCode=2
+
+ if SessionName=="mySession" and seatID==1:
+ SessionState=5
+ ErrorCode=1
+
+ print('[-----nsm-----] GetSessionState for session ' + SessionName + ' seatID '+ str(seatID) + ' returnState ' + str (SessionState))
+ return SessionState, ErrorCode
+
+ @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssuu', out_signature = 'i')
+ def RegisterShutdownClient(self,BName,ObjName,ShutdownMode,TimeoutMs):
+ print('[-----nsm-----] Busname: ' + BName)
+ print('[-----nsm-----] ObjName: ' + ObjName)
+ print('[-----nsm-----] ShutdownMode: ' + str(ShutdownMode))
+ print('[-----nsm-----] TimeoutMs: ' + str(TimeoutMs))
+ ErrorCode=1
+ if TimeoutMs!=100:
+ ErrorCode=3
+ if BName!="org.genivi.audiomanager":
+ ErrorCode=4
+ if ShutdownMode!=1:
+ ErrorCode=5
+ if ObjName!="/org/genivi/audiomanager/LifeCycleConsumer":
+ ErrorCode=6
+ self.ABus=BName
+ self.APath=ObjName
+ return ErrorCode
+
+ @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssu', out_signature = 'i')
+ def UnRegisterShutdownClient(self,BusName,ObjName,ShutdownMode):
+ print('[-----nsm-----] Busname: ' + str(BusName))
+ print('[-----nsm-----] ObjName: ' + str(ObjName))
+ print('[-----nsm-----] ShutdownMode: ' + str(ShutdownMode))
+ ErrorCode=1
+ if BusName!=self.ABus:
+ ErrorCode=2
+ if ObjName!=self.APath:
+ ErrorCode=2
+ if ShutdownMode!=1:
+ ErrorCode=2
+ return ErrorCode
+
+ @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'u')
+ def GetInterfaceVersion(self):
+ version=23
+ return version
+
+ @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ui', out_signature='i')
+ def LifecycleRequestComplete(self,RequestID,Status):
+ print('[-----nsm-----] RequestId: ' + str(RequestID))
+ print('[-----nsm-----] Status: ' + str(Status))
+ ErrorCode=1
+ if RequestID!=22:
+ ErrorCode=2
+ if Status!=4:
+ ErrorCode=2
+ return ErrorCode
+
+ @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v')
+ def Get(self, interface, prop):
+ if prop in self.properties:
+ print('[-----nsm-----] send out ' + str(self.properties[prop]) + ' for property '+ prop)
+ return self.properties[prop]
+ return 0
+
+ @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ssv')
+ def Set(self, interface, prop, value):
+ return 3
+
+ @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
+ def GetAll(self, interface):
+ return self.properties
+
+ @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i')
+ def NodeApplicationMode(self, ApplicationModeId):
+ print "[-----nsm-----] Send out application mode ID %d" % (ApplicationModeId)
+
+ @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i')
+ def NodeState(self, NodeState):
+ print "[-----nsm-----] Send out NodeState %d" % (NodeState)
+
+ @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='sii')
+ def SessionStateChanged(self, SessionStateName,SeatID,SessionState):
+ print "[-----nsm-----] Send out SessionStateChanged " + SessionStateName
+
+ @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i')
+ def sendNodeApplicationMode(self, input):
+ self.NodeApplicationMode(input)
+ return input
+
+ @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i')
+ def sendNodeState(self, input):
+ self.NodeState(input)
+ return input
+
+ @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='sii')
+ def sendSessionState(self, SessionStateName,SeatID,SessionState):
+ self.SessionStateChanged (SessionStateName,SeatID,SessionState)
+ return SeatID
+
+ @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='uu', out_signature='i')
+ def sendLifeCycleRequest(self, request, requestID):
+ bus = dbus.SessionBus()
+ remote_object = bus.get_object(self.ABus,self.APath)
+ iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.LifeCycleConsumer')
+ iface.LifecycleRequest(request,requestID)
+ return 42
+
+ @dbus.service.method('org.genivi.NodeStateManager.Control')
+ def finish(self):
+ print '[-----nsm-----] Going to exit now!'
+ self.loop.quit()
+ return 0
+
+nsm = NodeStateManager(loop)
+loop.run()
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/org.genivi.NodeStateManager.Consumer.xml b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/org.genivi.NodeStateManager.Consumer.xml
index bb40a96..bb40a96 100644
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/org.genivi.NodeStateManager.Consumer.xml
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/org.genivi.NodeStateManager.Consumer.xml
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/send2nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/send2nsm.py
index c7e8bf5..c7e8bf5 100644
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/send2nsm.py
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorCAPITest/send2nsm.py
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.cpp b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.cpp
index 11debf9..09e5f2b 100644
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.cpp
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.cpp
@@ -24,13 +24,18 @@
#include "shared/CAmSocketHandler.h"
#include "shared/CAmDbusWrapper.h"
+#include <unistd.h>
+
using namespace testing;
using namespace am;
static CAmEnvironment* env;
+
+
CAmNodeStateCommunicatorTest::CAmNodeStateCommunicatorTest()
{
+
}
CAmNodeStateCommunicatorTest::~CAmNodeStateCommunicatorTest()
@@ -63,7 +68,7 @@ void* mainLoop(void* importHandler)
TEST_F(CAmNodeStateCommunicatorTest, nsmChangeNodeState)
{
- env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface);
+ assert(true == env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface));
NsmNodeState_e newstate(NsmNodeState_BaseRunning) ;
EXPECT_CALL(pMockControlInterface,hookSystemNodeStateChanged(newstate));
std::ostringstream send;
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.h b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.h
index bd83e97..d75920b 100644
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.h
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CAmNodeStateCommunicatorTest.h
@@ -21,7 +21,7 @@
#ifndef CAMNODESTATECOMMUNICATORTEST_H_
#define CAMNODESTATECOMMUNICATORTEST_H_
-#include "CAmNodeStateCommunicator.h"
+#include "CAmNodeStateCommunicatorDBus.h"
#include "CAmControlSender.h"
#include "gtest/gtest.h"
#include "gmock/gmock.h"
@@ -38,7 +38,7 @@ public:
CAmControlSender pControlSender;
CAmSocketHandler iSocketHandler;
CAmDbusWrapper wrapper;
- CAmNodeStateCommunicator nsmController;
+ CAmNodeStateCommunicatorDBus nsmController;
pthread_t pNsmThread, pMainLoopThread;
CAmEnvironment();
~CAmEnvironment();
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CMakeLists.txt b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CMakeLists.txt
index 99b2963..4ecd421 100644
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/CMakeLists.txt
@@ -17,7 +17,7 @@
cmake_minimum_required(VERSION 2.6)
-PROJECT(AmNodeStateCommunicatorTest)
+PROJECT(AmNodeStateCommunicatorDBusTest)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1")
@@ -59,7 +59,7 @@ file(GLOB NODESTATECOMMUNICATOR
"../../src/CAmDbusWrapper.cpp"
"../../src/CAmDltWrapper.cpp"
"../../src/CAmSocketHandler.cpp"
- "../../src/CAmNodeStateCommunicator.cpp"
+ "../../src/CAmNodeStateCommunicatorDBus.cpp"
"../../src/CAmControlSender.cpp"
"../../src/CAmCommandSender.cpp"
"../../src/CAmCommandReceiver.cpp"
@@ -68,9 +68,9 @@ file(GLOB NODESTATECOMMUNICATOR
"*.cpp"
)
-ADD_EXECUTABLE(AmNodeStateCommunicatorTest ${NODESTATECOMMUNICATOR})
+ADD_EXECUTABLE(AmNodeStateCommunicatorDBusTest ${NODESTATECOMMUNICATOR})
-TARGET_LINK_LIBRARIES(AmNodeStateCommunicatorTest
+TARGET_LINK_LIBRARIES(AmNodeStateCommunicatorDBusTest
${SQLITE_LIBRARIES}
${DLT_LIBRARIES}
${DBUS_LIBRARY}
@@ -81,9 +81,9 @@ TARGET_LINK_LIBRARIES(AmNodeStateCommunicatorTest
gmock
)
-ADD_DEPENDENCIES(AmNodeStateCommunicatorTest gtest gmock)
+ADD_DEPENDENCIES(AmNodeStateCommunicatorDBusTest gtest gmock)
-INSTALL(TARGETS AmNodeStateCommunicatorTest
+INSTALL(TARGETS AmNodeStateCommunicatorDBusTest
DESTINATION "~/AudioManagerTest/"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
COMPONENT tests
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/nsm.py
index 7a02d05..7a02d05 100644
--- a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/nsm.py
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/nsm.py
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml
new file mode 100644
index 0000000..bb40a96
--- /dev/null
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/org.genivi.NodeStateManager.Consumer.xml
@@ -0,0 +1,259 @@
+<!-- Auto-Generated interface from Rhapsody: 'Repository::ssw_LifecycleSupport::NodeStateManagement::Concept::Interface::INSM_Consumer' -->
+<!-- Created at 2012-06-01 09:36:05 by uid65904 -->
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+<interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" direction="out" type="s"/>
+ </method>
+</interface>
+<interface name="org.freedesktop.DBus.Properties">
+ <method name="Get">
+ <arg name="interface" direction="in" type="s"/>
+ <arg name="propname" direction="in" type="s"/>
+ <arg name="value" direction="out" type="v"/>
+ </method>
+
+ <method name="Set">
+ <arg name="interface" direction="in" type="s"/>
+ <arg name="propname" direction="in" type="s"/>
+ <arg name="value" direction="in" type="v"/>
+ </method>
+
+ <method name="GetAll">
+ <arg name="interface" direction="in" type="s"/>
+ <arg name="props" direction="out" type="a{sv}"/>
+ </method>
+</interface>
+ <!--
+ org.genivi.NodeStateManager.Consumer:
+ @short_description: "Consumer" interface of the NodeStateManager.
+
+ This interface contains functions which are not safety critical and can be accessed by "every" client without further restrictions.
+ -->
+ <interface name="org.genivi.NodeStateManager.Consumer">
+ <!--
+ RestartReason: This property informs clients about the reason for the last restart. The values are based upon the enummeration NsmRestartReason_e. Note: The value is only set once at start-up.
+ -->
+ <property name="RestartReason" type="i" access="read"/>
+
+ <!--
+ ShutdownReason: This property informs clients about the reason for the last shutdown. The values are based upon the enummeration NsmShutdownReason_e. Note: The value is only set once at start-up.
+ -->
+ <property name="ShutdownReason" type="i" access="read"/>
+
+ <!--
+ WakeUpReason: This property informs clients about the recent reason for waking up the target. The values are based upon the enummeration NsmWakeUpReason_e. Note: The value is only set once at start-up.
+ -->
+ <property name="WakeUpReason" type="i" access="read"/>
+
+ <!--
+ BootMode: This property informs clients about the recent BootMode of the target. The values will be defined by a third party header, which has not been delivered yet. The description needs to be updated as soon as the header is available.
+ -->
+ <property name="BootMode" type="i" access="read"/>
+
+ <!--
+ NodeState:
+ @NodeState: Numeric value for the current NodeState, defined in NsmNodeState_e.
+
+ Clients can register for notifications when the NodeState is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeState as a parameter.
+ -->
+ <signal name="NodeState">
+ <arg name="NodeState" type="i"/>
+ </signal>
+
+ <!--
+ NodeApplicationMode:
+ @ApplicationModeId: Numeric value for the current ApplicationMode, defined in NsmAplicationMode_e.
+
+ Clients can register for notifications when the NodeApplicationMode is updated inside the NodeStateManager. This signal is sent to registered clients and will include the current NodeApplicationMode as a parameter.
+ -->
+ <signal name="NodeApplicationMode">
+ <arg name="ApplicationModeId" type="i"/>
+ </signal>
+
+ <!--
+ SessionStateChanged:
+ @SessionStateName: The SessionName will be based upon either the pre-defined platform SessionNames or using a newly added product defined session name.
+ @SeatID: This parameter will be based upon the enum NsmSeat_e.
+ @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
+
+ This signal is sent to registered clients when a particular session is state is changed. The client can register for notification about a specific session through the use of the SessionName, as a "match rule".
+ -->
+ <signal name="SessionStateChanged">
+ <arg name="SessionStateName" type="s"/>
+ <arg name="SeatID" type="i"/>
+ <arg name="SessionState" type="i"/>
+ </signal>
+
+ <!--
+ GetNodeState:
+ @NodeStateId: Will be based on the NsmNodeState_e.
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by other applications to get the NodeState without the need of registration to the signal.
+ -->
+ <method name="GetNodeState">
+ <arg name="NodeStateId" direction="out" type="i"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ SetSessionState:
+ @SessionName: The SessionName will be based upon either the pre-defined platform SessionNames (see NSM content page) or using a newly added product defined session name.
+ @SessionOwner: This parameter defines the name of the application that is setting the state of the session. This must be the applications systemd unit filename.
+ @SeatID: This parameter will be based upon the enum NsmSeat_e
+ @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by applications to set the state of a session.
+ -->
+ <method name="SetSessionState">
+ <arg name="SessionName" direction="in" type="s"/>
+ <arg name="SessionOwner" direction="in" type="s"/>
+ <arg name="SeatID" direction="in" type="i"/>
+ <arg name="SessionState" direction="in" type="i"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ GetSessionState:
+ @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
+ @SeatID: This parameter will be based upon the enum NsmSeat_e.
+ @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional SessionStates.
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by applications to get the state of a session.
+ -->
+ <method name="GetSessionState">
+ <arg name="SessionName" direction="in" type="s"/>
+ <arg name="SeatID" direction="in" type="i"/>
+ <arg name="SessionState" direction="out" type="i"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ GetApplicationMode:
+ @ApplicationModeId: This parameter will be based upon the NsmNodeApplicationMode_e.
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by other applications to get the application mode.
+ -->
+ <method name="GetApplicationMode">
+ <arg name="ApplicationModeId" direction="out" type="i"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ RegisterShutdownClient:
+ @BusName: Bus name of remote application.
+ @ObjName: Object name of remote object that provides the shutdown interface.
+ @ShutdownMode: Shutdown mode for which client wants to be informed (i.e normal, fast etc).
+ @TimeoutMs: Max. Timeout to wait for response from shutdown client in ms.
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by other applications to register themselves as shutdown client. Any client that registers must provide a method in their D-Bus object called "LifecycleRequest". This method will take one parameter which is the RequestType (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST). For an example of the required client interface please see the BootManager component who will be a client of the NSM.
+ -->
+ <method name="RegisterShutdownClient">
+ <arg name="BusName" direction="in" type="s"/>
+ <arg name="ObjName" direction="in" type="s"/>
+ <arg name="ShutdownMode" direction="in" type="u"/>
+ <arg name="TimeoutMs" direction="in" type="u"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ UnRegisterShutdownClient:
+ @BusName: Bus name of remote application.
+ @ObjName: Object name of remote object that provides the shutdown interface.
+ @ShutdownMode: Shutdown mode for which client wants to unregister (NSM_SHUTDOWNTYPE_NORMAL, NSM_SHUTDOWNTYPE_FAST).
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by other applications to unregister themselves as shutdown client.
+ -->
+ <method name="UnRegisterShutdownClient">
+ <arg name="BusName" direction="in" type="s"/>
+ <arg name="ObjName" direction="in" type="s"/>
+ <arg name="ShutdownMode" direction="in" type="u"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ RegisterSession:
+ @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
+ @SessionOwner: This is the name of the application that is registering the new session (this must be the applications systemd unit filename).
+ @SeatID: This parameter will be based upon the enum NsmSeatId_e
+ @SessionState: This parameter will be based upon the NsmSessionState_e but it will not be bounded by the values in that enumeration. The listed values are the default values that are mandatory for platform sessions, but product sessions may have additional session states.
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by other applications to register a new session whose state should be observed and distributed by the NSM.
+ -->
+ <method name="RegisterSession">
+ <arg name="SessionName" direction="in" type="s"/>
+ <arg name="SessionOwner" direction="in" type="s"/>
+ <arg name="SeatID" direction="in" type="i"/>
+ <arg name="SessionState" direction="in" type="i"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ UnRegisterSession:
+ @SessionName: The SessionName will be based upon either the pre-defined platform session names (see NSM content page) or using a newly added product defined SessionName.
+ @SessionOwner: This is the name of the application that originally registered the session. It will be validated that this value matches the stored value from the registration.
+ @SeatID: This parameter will be based upon the enum NsmSeat_e.
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The method is used by other applications to remove a new session from the session list hosted by NSM.
+ -->
+ <method name="UnRegisterSession">
+ <arg name="SessionName" direction="in" type="s"/>
+ <arg name="SessionOwner" direction="in" type="s"/>
+ <arg name="SeatID" direction="in" type="i"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+
+ <!--
+ GetAppHealthCount:
+ @Count: Return value passed to the caller. Number of applications that crashed or terminated accidentally.
+
+ The method returns the number of applications that crashed or terminated accidentally, within the current life cycle. It can be used to observe the system state.
+ -->
+ <method name="GetAppHealthCount">
+ <arg name="Count" direction="out" type="u"/>
+ </method>
+
+ <!--
+ GetInterfaceVersion:
+ @Version: Unsigned integer that represents the version number of the Node State Manager.
+
+ The method returns the version number of the Node State Manager. The number is organized in four bytes:
+
+ Version: VVV.RRR.PPP.BBB
+
+ <literallayout>
+ VVV => Version [1..255]
+ RRR => Release [0..255]
+ PPP => Patch [0..255]
+ BBB => Build [0..255]
+ </literallayout>
+ -->
+ <method name="GetInterfaceVersion">
+ <arg name="Version" direction="out" type="u"/>
+ </method>
+
+ <!--
+ LifecycleRequestComplete:
+ @RequestId: The request Id of the called life cycle client. The value has been passed when "LifecycleRequest" was called.
+ @Status: The result of the call to "LifecycleRequest". NsmErrorStatus_Ok: Request successfully processed. NsmErrorStatus_Error: An error occured while processing the "LifecycleRequest".
+ @ErrorCode: Return value passed to the caller, based upon NsmErrorStatus_e.
+
+ The function has to be called by a "asynchrounous" lifecycle client, when he processed the "LifecycleRequest".
+ -->
+ <method name="LifecycleRequestComplete">
+ <arg name="RequestId" direction="in" type="u"/>
+ <arg name="Status" direction="in" type="i"/>
+ <arg name="ErrorCode" direction="out" type="i"/>
+ </method>
+ </interface>
+</node>
diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py
new file mode 100644
index 0000000..c7e8bf5
--- /dev/null
+++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorDBusTest/send2nsm.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012, BMW AG
+#
+# This file is part of GENIVI Project AudioManager.
+#
+# Contributions are licensed to the GENIVI Alliance under one or more
+# Contribution License Agreements.
+#
+# \copyright
+# This Source Code Form is subject to the terms of the
+# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+# this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#
+# \author Christian Linke, christian.linke@bmw.de BMW 2012
+#
+# For further information see http://www.genivi.org/.
+#
+
+import sys
+import traceback
+import gobject
+import math
+import dbus
+import dbus.service
+
+def nodeState (nodeState):
+ bus = dbus.SessionBus()
+ remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
+ iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
+ iface.sendNodeState(int(nodeState))
+
+def appMode (appMode):
+ bus = dbus.SessionBus()
+ remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
+ iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
+ iface.sendNodeApplicationMode(int(appMode))
+
+def sessionState (SessionStateName,SeatID,SessionState):
+ bus = dbus.SessionBus()
+ remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
+ iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
+ iface.sendSessionState(SessionStateName,int(SeatID),int(SessionState))
+
+def finish():
+ bus = dbus.SessionBus()
+ remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
+ iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
+ iface.finish()
+
+def LifecycleRequest(Request,RequestID):
+ bus = dbus.SessionBus()
+ remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
+ iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
+ iface.sendLifeCycleRequest(dbus.UInt32(Request),dbus.UInt32(RequestID))
+
+command=sys.argv[1]
+if command=="nodeState":
+ nodeState(sys.argv[2])
+if command=="finish":
+ finish()
+if command=="appMode":
+ appMode(sys.argv[2])
+if command=="sessionState":
+ sessionState(sys.argv[2],sys.argv[3],sys.argv[4])
+if command=="LifecycleRequest":
+ LifecycleRequest(sys.argv[2],sys.argv[3])
diff --git a/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt
index d587f0c..2b16eda 100644
--- a/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt
@@ -60,9 +60,9 @@ file(GLOB ROUTINGMAP_SRCS_CXX
)
IF(WITH_NSM)
- SET (ROUTINGMAP_SRCS_CXX
- ${ROUTINGMAP_SRCS_CXX}
- "../../src/CAmNodeStateCommunicator.cpp")
+ SET (DATABASE_SRCS_CXX
+ ${DATABASE_SRCS_CXX}
+ "../../src/CAmNodeStateCommunicatorDBus.cpp")
ENDIF(WITH_NSM)
ADD_EXECUTABLE( AmRouterMapTest ${ROUTINGMAP_SRCS_CXX})
diff --git a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt
index 6f556ff..602767b 100644
--- a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt
@@ -61,9 +61,9 @@ file(GLOB ROUTING_SRCS_CXX
)
IF(WITH_NSM)
- SET (ROUTING_SRCS_CXX
- ${ROUTING_SRCS_CXX}
- "../../src/CAmNodeStateCommunicator.cpp")
+ SET (DATABASE_SRCS_CXX
+ ${DATABASE_SRCS_CXX}
+ "../../src/CAmNodeStateCommunicatorDBus.cpp")
ENDIF(WITH_NSM)
ADD_EXECUTABLE( AmRouterTest ${ROUTING_SRCS_CXX})
diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt
index a73cec0..122ea69 100644
--- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt
@@ -62,9 +62,9 @@ file(GLOB ROUTING_INTERFACE_SRCS_CXX
)
IF(WITH_NSM)
- SET (ROUTING_INTERFACE_SRCS_CXX
- ${ROUTING_INTERFACE_SRCS_CXX}
- "../../src/CAmNodeStateCommunicator.cpp")
+ SET (DATABASE_SRCS_CXX
+ ${DATABASE_SRCS_CXX}
+ "../../src/CAmNodeStateCommunicatorDBus.cpp")
ENDIF(WITH_NSM)
ADD_EXECUTABLE(AmRoutingInterfaceTest ${ROUTING_INTERFACE_SRCS_CXX})
diff --git a/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt
index 6c20e4e..26c83d9 100644
--- a/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt
+++ b/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt
@@ -69,9 +69,9 @@ file(GLOB TELNET_SRCS_CXX
)
IF(WITH_NSM)
- SET (TELNET_SRCS_CXX
- ${TELNET_SRCS_CXX}
- "../../src/CAmNodeStateCommunicator.cpp")
+ SET (DATABASE_SRCS_CXX
+ ${DATABASE_SRCS_CXX}
+ "../../src/CAmNodeStateCommunicatorDBus.cpp")
ENDIF(WITH_NSM)
ADD_EXECUTABLE(AmTelnetServerTest ${TELNET_SRCS_CXX})
diff --git a/AudioManagerDaemon/test/CAmCommonFunctions.cpp b/AudioManagerDaemon/test/CAmCommonFunctions.cpp
index 7ee9090..d8c2e03 100644
--- a/AudioManagerDaemon/test/CAmCommonFunctions.cpp
+++ b/AudioManagerDaemon/test/CAmCommonFunctions.cpp
@@ -92,7 +92,7 @@ IAmControlBackdoor::~IAmControlBackdoor()
bool IAmControlBackdoor::replaceController(CAmControlSender *controlSender, IAmControlSend *newController)
{
controlSender->mController = newController;
- return true;
+ return controlSender->mController == newController;
}
//int GetRandomNumber(int nLow, int nHigh) {
diff --git a/AudioManagerDaemon/test/CMakeLists.txt b/AudioManagerDaemon/test/CMakeLists.txt
index 5eda5cb..e0ae651 100644
--- a/AudioManagerDaemon/test/CMakeLists.txt
+++ b/AudioManagerDaemon/test/CMakeLists.txt
@@ -27,8 +27,13 @@ add_subdirectory (AmRouterTest)
add_subdirectory (AmRouterMapTest)
add_subdirectory (AmRoutingInterfaceTest)
add_subdirectory (AmSocketHandlerTest)
+
IF(WITH_NSM)
- add_subdirectory (AmNodeStateCommunicatorTest)
+ IF(WITH_DBUS_WRAPPER)
+ add_subdirectory (AmNodeStateCommunicatorDBusTest)
+ ELSEIF(WITH_CAPI_WRAPPER)
+ add_subdirectory (AmNodeStateCommunicatorCAPITest)
+ ENDIF()
ENDIF(WITH_NSM)
IF(WITH_TELNET)