summaryrefslogtreecommitdiff
path: root/src/components/hmi_message_handler
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/hmi_message_handler')
-rw-r--r--src/components/hmi_message_handler/CMakeLists.txt38
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/dbus_message_adapter.h2
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter.h60
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler.h63
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h8
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_observer.h53
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_sender.h47
-rw-r--r--src/components/hmi_message_handler/mock_hmi_message_handler.h (renamed from src/components/hmi_message_handler/include/hmi_message_handler/mqueue_adapter.h)53
-rw-r--r--src/components/hmi_message_handler/src/dbus_message_adapter.cc4
-rw-r--r--src/components/hmi_message_handler/src/hmi_message_handler_impl.cc2
-rw-r--r--src/components/hmi_message_handler/src/mqueue_adapter.cc143
-rw-r--r--src/components/hmi_message_handler/test/CMakeLists.txt35
-rw-r--r--src/components/hmi_message_handler/test/dbus_message_adapter_test.cc68
-rw-r--r--src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc73
-rw-r--r--src/components/hmi_message_handler/test/include/hmi_message_handler/mock_dbus_message_controller.h14
-rw-r--r--src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_observer.h57
-rw-r--r--src/components/hmi_message_handler/test/include/hmi_message_handler/mock_subscriber.h10
-rw-r--r--src/components/hmi_message_handler/test/mock_subscriber.cc13
-rw-r--r--src/components/hmi_message_handler/test/mqueue_adapter_test.cc94
19 files changed, 163 insertions, 674 deletions
diff --git a/src/components/hmi_message_handler/CMakeLists.txt b/src/components/hmi_message_handler/CMakeLists.txt
index aa10729458..c1dfca5e67 100644
--- a/src/components/hmi_message_handler/CMakeLists.txt
+++ b/src/components/hmi_message_handler/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014, Ford Motor Company
+# Copyright (c) 2016, Ford Motor Company
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,8 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake)
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
include_directories (
include/
@@ -46,30 +48,36 @@ include_directories (
${LOG4CXX_INCLUDE_DIRECTORY}
)
-IF (HMIADAPTER STREQUAL "dbus")
- set (DBUS_SOURCE ./src/dbus_message_adapter.cc)
- set (DBUS_ADAPTER DBus)
-ENDIF ()
+set(PATHS
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+)
+
+if (HMIADAPTER STREQUAL "dbus")
+ set(EXCLUDE_PATHS)
+ set(DBUS_ADAPTER DBus)
+else()
+ set(EXCLUDE_PATHS dbus_message_adapter.cc)
+ set(DBUS_ADAPTER)
+endif ()
-set (SOURCES
- ${COMPONENTS_DIR}/hmi_message_handler/src/hmi_message_handler_impl.cc
- ${COMPONENTS_DIR}/hmi_message_handler/src/messagebroker_adapter.cc
- ${COMPONENTS_DIR}/hmi_message_handler/src/hmi_message_adapter_impl.cc
- ${COMPONENTS_DIR}/hmi_message_handler/src/mqueue_adapter.cc
- ${DBUS_SOURCE}
+list(APPEND EXCLUDE_PATHS
+ mqueue_adapter.cc
)
+collect_sources(SOURCES "${PATHS}" "${EXCLUDE_PATHS}")
+
set(LIBRARIES
- Utils
- ${DBUS_ADAPTER}
- ${RTLIB}
+ Utils
+ ${DBUS_ADAPTER}
+ ${RTLIB}
)
add_library("HMIMessageHandler" ${SOURCES})
target_link_libraries("HMIMessageHandler" ${LIBRARIES})
if(ENABLE_LOG)
- target_link_libraries("HMIMessageHandler" log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
+ target_link_libraries("HMIMessageHandler" log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
endif()
# Tests temporary are inactivated. For details please check
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/dbus_message_adapter.h b/src/components/hmi_message_handler/include/hmi_message_handler/dbus_message_adapter.h
index 4dc74f71e8..beb7a9ad1d 100644
--- a/src/components/hmi_message_handler/include/hmi_message_handler/dbus_message_adapter.h
+++ b/src/components/hmi_message_handler/include/hmi_message_handler/dbus_message_adapter.h
@@ -40,8 +40,6 @@
namespace hmi_message_handler {
-namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
-
/**
* \brief adapter for DBus
*/
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter.h
deleted file mode 100644
index d2a3a5b907..0000000000
--- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_adapter.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2015, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_ADAPTER_H_
-#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_ADAPTER_H_
-
-#include "hmi_message_handler/hmi_message_sender.h"
-
-namespace hmi_message_handler {
-/**
- * \class HMIMessageAdapter
- * \brief Interface class describing methods neccessary for exchanging message
- * between ApplicationManager and HMI. Adapter for concrete transport connection
- * SDL with HMI has to implement this interface.
- */
-class HMIMessageAdapter : public HMIMessageSender {
- protected:
- /**
- * \brief Interface for subscriptions.
- * Each class implementing interface should use it according to
- * standarts of transport for which it is to be an adapter.
- * For example, Adapter for MessageBroker will use it to subscribe to
- * notifications
- * from HMI.
- */
- virtual void SubscribeTo() = 0;
-};
-
-} // namespace hmi_message_handler
-
-#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_ADAPTER_H_
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler.h
deleted file mode 100644
index 217075e89f..0000000000
--- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2016, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_HANDLER_H_
-#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_HANDLER_H_
-
-#include "hmi_message_handler/hmi_message_sender.h"
-#include "hmi_message_handler/hmi_message_observer.h"
-#include "hmi_message_handler/hmi_message_handler_settings.h"
-
-namespace hmi_message_handler {
-
-class HMIMessageAdapter;
-/**
- * \class HMIMessageHandler
- * \brief Abstract class for handling different HMI adapters;
- * establishing interface for message exchange between SDL core and HMI.
- */
-class HMIMessageHandler : public HMIMessageObserver, public HMIMessageSender {
- public:
- virtual ~HMIMessageHandler() {}
- virtual void AddHMIMessageAdapter(HMIMessageAdapter* adapter) = 0;
- virtual void RemoveHMIMessageAdapter(HMIMessageAdapter* adapter) = 0;
-
- /**
- * \brief Hmi message handler settings getter
- * \return pointer to hmi message handler settings class
- */
- virtual const HMIMessageHandlerSettings& get_settings() const = 0;
-};
-
-} // namespace hmi_message_handler
-
-#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_HANDLER_H_
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h
index 3b829b0f27..8b238b4aa8 100644
--- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h
+++ b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_handler_impl.h
@@ -106,6 +106,14 @@ class HMIMessageHandlerImpl : public HMIMessageHandler,
HMIMessageObserver* observer() const {
return observer_;
}
+
+ impl::ToHmiQueue* messages_to_hmi() {
+ return &messages_to_hmi_;
+ }
+
+ impl::FromHmiQueue* messages_from_hmi() {
+ return &messages_from_hmi_;
+ }
#endif // BUILD_TESTS
private:
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_observer.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_observer.h
deleted file mode 100644
index f2f84b13e7..0000000000
--- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_observer.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2013, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_OBSERVER_H_
-#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_OBSERVER_H_
-
-#include "utils/shared_ptr.h"
-
-namespace application_manager {
-class Message;
-}
-
-namespace hmi_message_handler {
-
-class HMIMessageObserver {
- public:
- virtual void OnMessageReceived(
- utils::SharedPtr<application_manager::Message> message) = 0;
- virtual void OnErrorSending(
- utils::SharedPtr<application_manager::Message> message) = 0;
-};
-}
-
-#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_OBSERVER_H_
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_sender.h b/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_sender.h
deleted file mode 100644
index f00b493aa1..0000000000
--- a/src/components/hmi_message_handler/include/hmi_message_handler/hmi_message_sender.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2013, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_SENDER_H_
-#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_SENDER_H_
-
-#include "application_manager/message.h"
-
-namespace hmi_message_handler {
-typedef utils::SharedPtr<application_manager::Message> MessageSharedPointer;
-
-class HMIMessageSender {
- public:
- virtual void SendMessageToHMI(MessageSharedPointer message) = 0;
-};
-}
-
-#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_HMI_MESSAGE_SENDER_H_
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/mqueue_adapter.h b/src/components/hmi_message_handler/mock_hmi_message_handler.h
index 69634ea00e..d9060088ff 100644
--- a/src/components/hmi_message_handler/include/hmi_message_handler/mqueue_adapter.h
+++ b/src/components/hmi_message_handler/mock_hmi_message_handler.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -30,37 +30,32 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_MQUEUE_ADAPTER_H_
-#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_MQUEUE_ADAPTER_H_
+#ifndef SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_HANDLER_H_
+#define SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_HANDLER_H_
-#include <memory>
-#include <mqueue.h>
-#include "utils/threads/thread.h"
-#include "hmi_message_handler/hmi_message_adapter_impl.h"
+#include "gmock/gmock.h"
+#include "hmi_message_handler/hmi_message_handler.h"
-namespace hmi_message_handler {
+namespace test {
+namespace components {
+namespace hmi_message_handler_test {
-class ReceiverThreadDelegate;
+using hmi_message_handler::HMIMessageAdapter;
+using hmi_message_handler::HMIMessageHandlerSettings;
+using hmi_message_handler::MessageSharedPointer;
-/**
- * \brief HMI message adapter for mqueue
- */
-class MqueueAdapter : public HMIMessageAdapterImpl {
+class MockHMIMessageHandler : public ::hmi_message_handler::HMIMessageHandler {
public:
- MqueueAdapter(HMIMessageHandler* hmi_message_handler);
- virtual ~MqueueAdapter();
-
- protected:
- virtual void SendMessageToHMI(MessageSharedPointer message);
- virtual void SubscribeTo();
-
- private:
- mqd_t sdl_to_hmi_mqueue_;
- mqd_t hmi_to_sdl_mqueue_;
-
- ReceiverThreadDelegate* receiver_thread_delegate_;
- threads::Thread* receiver_thread_;
+ MOCK_METHOD1(AddHMIMessageAdapter, void(HMIMessageAdapter* adapter));
+ MOCK_METHOD1(RemoveHMIMessageAdapter, void(HMIMessageAdapter* adapter));
+ MOCK_CONST_METHOD0(get_settings, const HMIMessageHandlerSettings&());
+ MOCK_METHOD1(OnMessageReceived,
+ void(utils::SharedPtr<application_manager::Message> message));
+ MOCK_METHOD1(OnErrorSending,
+ void(utils::SharedPtr<application_manager::Message> message));
+ MOCK_METHOD1(SendMessageToHMI, void(MessageSharedPointer message));
};
-
-} // namespace hmi_message_handler
-#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_MQUEUE_ADAPTER_H_
+} // namespace hmi_message_handler_test
+} // namespace components
+} // namespace test
+#endif // SRC_COMPONENTS_INCLUDE_TEST_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_HANDLER_H_ \ No newline at end of file
diff --git a/src/components/hmi_message_handler/src/dbus_message_adapter.cc b/src/components/hmi_message_handler/src/dbus_message_adapter.cc
index 6a5bda5bfb..00f5ad6be8 100644
--- a/src/components/hmi_message_handler/src/dbus_message_adapter.cc
+++ b/src/components/hmi_message_handler/src/dbus_message_adapter.cc
@@ -34,8 +34,8 @@
#include <sstream>
#include "utils/logger.h"
#include "formatters/CSmartFactory.h"
+#include "smart_objects/smart_object.h"
-namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
namespace sos = NsSmartDeviceLink::NsJSONHandler::strings;
namespace hmi_message_handler {
@@ -126,8 +126,6 @@ void DBusMessageAdapter::SubscribeTo() {
DBusMessageController::SubscribeTo("BasicCommunication", "OnSystemRequest");
DBusMessageController::SubscribeTo("BasicCommunication",
"OnSystemInfoChanged");
- DBusMessageController::SubscribeTo("BasicCommunication", "OnPhoneCall");
- DBusMessageController::SubscribeTo("BasicCommunication", "OnEmergencyEvent");
DBusMessageController::SubscribeTo("TTS", "Started");
DBusMessageController::SubscribeTo("TTS", "Stopped");
DBusMessageController::SubscribeTo("TTS", "OnLanguageChange");
diff --git a/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc b/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc
index 4e0d8e45ba..1c774b9efe 100644
--- a/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc
+++ b/src/components/hmi_message_handler/src/hmi_message_handler_impl.cc
@@ -68,7 +68,7 @@ void HMIMessageHandlerImpl::OnMessageReceived(MessageSharedPointer message) {
}
void HMIMessageHandlerImpl::SendMessageToHMI(MessageSharedPointer message) {
- LOG4CXX_INFO(logger_, "HMIMessageHandlerImpl::~sendMessageToHMI()");
+ LOG4CXX_INFO(logger_, "SendMessageToHMI");
messages_to_hmi_.PostMessage(impl::MessageToHmi(message));
}
diff --git a/src/components/hmi_message_handler/src/mqueue_adapter.cc b/src/components/hmi_message_handler/src/mqueue_adapter.cc
deleted file mode 100644
index 4cfebbe9e8..0000000000
--- a/src/components/hmi_message_handler/src/mqueue_adapter.cc
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2014, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "hmi_message_handler/mqueue_adapter.h"
-#include "hmi_message_handler/hmi_message_handler.h"
-#include "utils/logger.h"
-
-namespace hmi_message_handler {
-
-const uint32_t kMqueueSize = 100;
-const uint32_t kMqueueMessageSize = 65536;
-const char* kSdlToHmiQueue = "/sdl_to_hmi";
-const char* kHmiToSdlQueue = "/hmi_to_sdl";
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "HMIMessageHandler")
-
-class ReceiverThreadDelegate : public threads::ThreadDelegate {
- public:
- ReceiverThreadDelegate(mqd_t mqueue_descriptor,
- HMIMessageHandler* hmi_message_handler)
- : mqueue_descriptor_(mqueue_descriptor)
- , hmi_message_handler_(hmi_message_handler) {}
-
- private:
- virtual void threadMain() {
- while (true) {
- static char buffer[kMqueueMessageSize];
- const ssize_t size =
- mq_receive(mqueue_descriptor_, buffer, kMqueueMessageSize, NULL);
- if (-1 == size) {
- LOG4CXX_ERROR(logger_, "Message queue receive failed, error " << errno);
- continue;
- }
- const std::string message_string(buffer, buffer + size);
- LOG4CXX_DEBUG(logger_, "Message: " << message_string);
- MessageSharedPointer message(new application_manager::Message(
- protocol_handler::MessagePriority::kDefault));
- message->set_json_message(message_string);
- message->set_protocol_version(application_manager::ProtocolVersion::kHMI);
- hmi_message_handler_->OnMessageReceived(message);
- }
- }
-
- const mqd_t mqueue_descriptor_;
- HMIMessageHandler* hmi_message_handler_;
-};
-
-MqueueAdapter::MqueueAdapter(HMIMessageHandler* hmi_message_handler)
- : HMIMessageAdapterImpl(hmi_message_handler)
- , sdl_to_hmi_mqueue_(-1)
- , hmi_to_sdl_mqueue_(-1)
- , receiver_thread_(NULL) {
- mq_attr mq_attributes;
- mq_attributes.mq_maxmsg = kMqueueSize;
- mq_attributes.mq_msgsize = kMqueueMessageSize;
- sdl_to_hmi_mqueue_ =
- mq_open(kSdlToHmiQueue, O_CREAT | O_RDWR, S_IRWXU, &mq_attributes);
- if (-1 == sdl_to_hmi_mqueue_) {
- LOG4CXX_ERROR(logger_,
- "Could not open message queue " << kSdlToHmiQueue
- << ", error " << errno);
- return;
- }
- hmi_to_sdl_mqueue_ =
- mq_open(kHmiToSdlQueue, O_CREAT | O_RDWR, S_IRWXU, &mq_attributes);
- if (-1 == hmi_to_sdl_mqueue_) {
- LOG4CXX_ERROR(logger_,
- "Could not open message queue " << kHmiToSdlQueue
- << ", error " << errno);
- return;
- }
- receiver_thread_delegate_ =
- new ReceiverThreadDelegate(hmi_to_sdl_mqueue_, hmi_message_handler);
- receiver_thread_ =
- threads::CreateThread("MqueueAdapter", receiver_thread_delegate_);
- receiver_thread_->start();
-}
-
-MqueueAdapter::~MqueueAdapter() {
- receiver_thread_->join();
- delete receiver_thread_delegate_;
- threads::DeleteThread(receiver_thread_);
- if (-1 != hmi_to_sdl_mqueue_)
- mq_close(hmi_to_sdl_mqueue_);
- if (-1 != sdl_to_hmi_mqueue_)
- mq_close(sdl_to_hmi_mqueue_);
- mq_unlink(kHmiToSdlQueue);
- mq_unlink(kSdlToHmiQueue);
-}
-
-void MqueueAdapter::SendMessageToHMI(const MessageSharedPointer message) {
- LOG4CXX_AUTO_TRACE(logger_);
-
- if (-1 == sdl_to_hmi_mqueue_) {
- LOG4CXX_ERROR(logger_, "Message queue is not opened");
- return;
- }
- const std::string& json = message->json_message();
- if (json.size() > kMqueueMessageSize) {
- LOG4CXX_ERROR(logger_, "Message size " << json.size() << " is too big");
- return;
- }
- const int rc = mq_send(sdl_to_hmi_mqueue_, json.c_str(), json.size(), 0);
- if (0 != rc) {
- LOG4CXX_ERROR(logger_, "Could not send message, error " << errno);
- return;
- }
-}
-
-void MqueueAdapter::SubscribeTo() {
- // empty implementation of pure virtual method, actually it's not called
-}
-
-} // namespace hmi_message_handler
diff --git a/src/components/hmi_message_handler/test/CMakeLists.txt b/src/components/hmi_message_handler/test/CMakeLists.txt
index 98e9fd5653..0d7ccd9ee1 100644
--- a/src/components/hmi_message_handler/test/CMakeLists.txt
+++ b/src/components/hmi_message_handler/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (c) 2014, Ford Motor Company
+# Copyright (c) 2016, Ford Motor Company
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,8 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-if(BUILD_TESTS)
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/platform.cmake)
+include(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake)
include_directories (
${GMOCK_INCLUDE_DIRECTORY}
@@ -36,27 +37,31 @@ include_directories (
${COMPONENTS_DIR}/hmi_message_handler/test/include
)
+if (HMIADAPTER STREQUAL "messagebroker")
+ set (BROKER_LIBRARIES
+ message_broker_client
+ message_broker_server
+ )
+endif()
+
+set(EXCLUDE_PATHS)
+
set(LIBRARIES
gmock
ApplicationManager
HMIMessageHandler
jsoncpp
- MessageBrokerClient
- MessageBrokerServer
+ ${BROKER_LIBRARIES}
ConfigProfile
)
-set(SOURCES
-${COMPONENTS_DIR}/hmi_message_handler/test/hmi_message_handler_impl_test.cc
-${COMPONENTS_DIR}/hmi_message_handler/test/hmi_message_adapter_test.cc
-)
-
-if(${QT_HMI})
- list (APPEND SOURCES
- ${COMPONENTS_DIR}/hmi_message_handler/test/mock_subscriber.cc
- ${COMPONENTS_DIR}/hmi_message_handler/test/dbus_message_adapter_test.cc
+if(NOT HMI_DBUS_API})
+ list (APPEND EXCLUDE_PATHS
+ mock_subscriber.cc
+ dbus_message_adapter_test.cc
)
endif()
-create_test("hmi_message_handler_test" "${SOURCES}" "${LIBRARIES}")
-endif()
+collect_sources(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}" "${EXCLUDE_PATHS}")
+
+create_test(hmi_message_handler_test "${SOURCES}" "${LIBRARIES}")
diff --git a/src/components/hmi_message_handler/test/dbus_message_adapter_test.cc b/src/components/hmi_message_handler/test/dbus_message_adapter_test.cc
deleted file mode 100644
index ac9a36aa16..0000000000
--- a/src/components/hmi_message_handler/test/dbus_message_adapter_test.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
-* Copyright (c) 2014, Ford Motor Company
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* Redistributions of source code must retain the above copyright notice, this
-* list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following
-* disclaimer in the documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of the Ford Motor Company nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <pthread.h>
-#include "hmi_message_handler/dbus_message_adapter.h"
-#include "dbus/dbus_message_controller.h"
-
-namespace Json {
-class Value;
-}
-
-class MockDBusMessageController : public ::dbus::DBusMessageController {
- public:
- MockDBusMessageController(const std::string& serviceName,
- const std::string& path,
- const std::string& hmiserviceName,
- const std::string& hmipath)
- : DBusMessageController(serviceName, path, hmiserviceName, hmipath)
- , thread_() {}
-
- virtual void processResponse(std::string method, Json::Value& root) {}
- virtual void processRequest(Json::Value& root) {}
- virtual void processNotification(Json::Value& root) {}
-
- bool Init() {
- return ::dbus::DBusMessageController::Init() &&
- pthread_create(&thread_, 0, &Run, this) == 0;
- }
-
- private:
- pthread_t thread_;
- static void* Run(void* data) {
- if (NULL != data) {
- static_cast<MockDBusMessageController*>(data)
- ->MethodForReceiverThread(nullptr);
- }
- return 0;
- }
-};
diff --git a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
index 06cca74ba9..09f20ed75d 100644
--- a/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
+++ b/src/components/hmi_message_handler/test/hmi_message_handler_impl_test.cc
@@ -36,13 +36,16 @@
#include "hmi_message_handler/messagebroker_adapter.h"
#include "hmi_message_handler/mock_hmi_message_observer.h"
#include "hmi_message_handler/mock_hmi_message_handler_settings.h"
-#include "utils/make_shared.h"
+#include "hmi_message_handler/mock_hmi_message_adapter_impl.h"
+#include "utils/test_async_waiter.h"
namespace test {
namespace components {
namespace hmi_message_handler_test {
using ::testing::ReturnRef;
+using ::testing::_;
+
class HMIMessageHandlerImplTest : public ::testing::Test {
public:
HMIMessageHandlerImplTest()
@@ -53,7 +56,7 @@ class HMIMessageHandlerImplTest : public ::testing::Test {
protected:
hmi_message_handler::MessageBrokerAdapter* mb_adapter_;
hmi_message_handler::HMIMessageHandlerImpl* hmi_handler_;
- hmi_message_handler::MockHMIMessageObserver* mock_hmi_message_observer_;
+ MockHMIMessageObserver* mock_hmi_message_observer_;
testing::NiceMock<MockHMIMessageHandlerSettings>
mock_hmi_message_handler_settings;
const uint64_t stack_size = 1000u;
@@ -63,10 +66,12 @@ class HMIMessageHandlerImplTest : public ::testing::Test {
.WillByDefault(ReturnRef(stack_size));
hmi_handler_ = new hmi_message_handler::HMIMessageHandlerImpl(
mock_hmi_message_handler_settings);
+ ASSERT_TRUE(NULL != hmi_handler_);
mb_adapter_ = new hmi_message_handler::MessageBrokerAdapter(
hmi_handler_, "localhost", 22);
- mock_hmi_message_observer_ =
- new hmi_message_handler::MockHMIMessageObserver();
+ ASSERT_TRUE(NULL != mb_adapter_);
+ mock_hmi_message_observer_ = new MockHMIMessageObserver();
+ ASSERT_TRUE(NULL != mock_hmi_message_observer_);
hmi_handler_->set_message_observer(mock_hmi_message_observer_);
EXPECT_TRUE(NULL != hmi_handler_->observer());
}
@@ -77,6 +82,13 @@ class HMIMessageHandlerImplTest : public ::testing::Test {
delete hmi_handler_;
delete mb_adapter_;
}
+
+ hmi_message_handler::MessageSharedPointer CreateMessage() {
+ // The ServiceType doesn't really matter
+ return new application_manager::Message(
+ protocol_handler::MessagePriority::FromServiceType(
+ protocol_handler::ServiceType::kInvalidServiceType));
+ }
};
TEST_F(HMIMessageHandlerImplTest,
@@ -91,16 +103,23 @@ TEST_F(HMIMessageHandlerImplTest,
TEST_F(HMIMessageHandlerImplTest,
OnErrorSending_NotEmptyMessage_ExpectOnErrorSendingProceeded) {
// Arrange
- utils::SharedPtr<application_manager::Message> message(
- utils::MakeShared<application_manager::Message>(
- protocol_handler::MessagePriority::FromServiceType(
- protocol_handler::ServiceType::kControl)));
+ utils::SharedPtr<application_manager::Message> message = CreateMessage();
EXPECT_CALL(*mock_hmi_message_observer_, OnErrorSending(message));
// Act
hmi_handler_->OnErrorSending(message);
}
+TEST_F(HMIMessageHandlerImplTest, OnErrorSending_InvalidObserver_Cancelled) {
+ // Arrange
+ utils::SharedPtr<application_manager::Message> message = CreateMessage();
+
+ hmi_handler_->set_message_observer(NULL);
+ EXPECT_CALL(*mock_hmi_message_observer_, OnErrorSending(_)).Times(0);
+ // Act
+ hmi_handler_->OnErrorSending(message);
+}
+
TEST_F(HMIMessageHandlerImplTest,
AddHMIMessageAdapter_AddExistedAdapter_ExpectAdded) {
// Check before action
@@ -131,6 +150,44 @@ TEST_F(HMIMessageHandlerImplTest, RemoveHMIMessageAdapter_ExpectRemoved) {
EXPECT_TRUE(hmi_handler_->message_adapters().empty());
}
+// TODO(atimchenko) SDLOPEN-44 Wrong message to observer
+TEST_F(HMIMessageHandlerImplTest,
+ DISABLED_OnMessageReceived_ValidObserver_Success) {
+ hmi_message_handler::MessageSharedPointer message = CreateMessage();
+ EXPECT_CALL(*mock_hmi_message_observer_, OnMessageReceived(message));
+
+ hmi_handler_->OnMessageReceived(message);
+ // Wait for the message to be processed
+ hmi_handler_->messages_from_hmi()->WaitDumpQueue();
+}
+
+TEST_F(HMIMessageHandlerImplTest, OnMessageReceived_InvalidObserver_Cancelled) {
+ hmi_message_handler::MessageSharedPointer message = CreateMessage();
+ EXPECT_CALL(*mock_hmi_message_observer_, OnMessageReceived(_)).Times(0);
+ // Make the observer invalid
+ hmi_handler_->set_message_observer(NULL);
+ hmi_handler_->OnMessageReceived(message);
+ hmi_handler_->messages_from_hmi()->WaitDumpQueue();
+}
+
+TEST_F(HMIMessageHandlerImplTest, SendMessageToHMI_Success) {
+ hmi_message_handler::MessageSharedPointer message = CreateMessage();
+
+ TestAsyncWaiter waiter;
+
+ MockHMIMessageAdapterImpl message_adapter(hmi_handler_);
+ EXPECT_CALL(message_adapter, SendMessageToHMI(message))
+ .WillOnce(NotifyTestAsyncWaiter(&waiter));
+
+ hmi_handler_->AddHMIMessageAdapter(&message_adapter);
+ hmi_handler_->SendMessageToHMI(message);
+
+ // Wait for the message to be processed
+ hmi_handler_->messages_to_hmi()->WaitDumpQueue();
+
+ EXPECT_TRUE(waiter.WaitFor(1, 100));
+}
+
} // namespace hmi_message_handler_test
} // namespace components
} // namespace test
diff --git a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_dbus_message_controller.h b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_dbus_message_controller.h
index eb449f7121..86ebf100bb 100644
--- a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_dbus_message_controller.h
+++ b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_dbus_message_controller.h
@@ -30,12 +30,16 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_DBUS_MESSAGE_CONTROLLER_H_
-#define TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_DBUS_MESSAGE_CONTROLLER_H_
+#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_DBUS_MESSAGE_CONTROLLER_H_
+#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_DBUS_MESSAGE_CONTROLLER_H_
#include <pthread.h>
#include "hmi_message_handler/dbus_message_controller.h"
+namespace test {
+namespace components {
+namespace hmi_message_handler_test {
+
class MockDBusMessageController
: public ::hmi_message_handler::DBusMessageController {
public:
@@ -65,4 +69,8 @@ class MockDBusMessageController
}
};
-#endif // TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_DBUS_MESSAGE_CONTROLLER_H_
+} // namespace hmi_message_handler_test
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_DBUS_MESSAGE_CONTROLLER_H_
diff --git a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_observer.h b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_observer.h
deleted file mode 100644
index 09a8935ae7..0000000000
--- a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_hmi_message_observer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-* Copyright (c) 2015, Ford Motor Company
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* Redistributions of source code must retain the above copyright notice, this
-* list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright notice,
-* this list of conditions and the following
-* disclaimer in the documentation and/or other materials provided with the
-* distribution.
-*
-* Neither the name of the Ford Motor Company nor the names of its contributors
-* may be used to endorse or promote products derived from this software
-* without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-* POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_OBSERVER_H_
-#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_OBSERVER_H_
-
-#include "gmock/gmock.h"
-#include "utils/shared_ptr.h"
-#include "utils/singleton.h"
-#include "hmi_message_handler/hmi_message_observer.h"
-#include "application_manager/message.h"
-
-namespace hmi_message_handler {
-
-using ::hmi_message_handler::HMIMessageObserver;
-
-class MockHMIMessageObserver : public HMIMessageObserver,
- public utils::Singleton<MockHMIMessageObserver> {
- public:
- MOCK_METHOD1(OnMessageReceived,
- void(utils::SharedPtr<application_manager::Message> message));
- MOCK_METHOD1(OnErrorSending,
- void(utils::SharedPtr<application_manager::Message> message));
- virtual ~MockHMIMessageObserver() {}
-};
-} // namespace hmi_message_handler
-
-#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_HMI_MESSAGE_OBSERVER_H_
diff --git a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_subscriber.h b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_subscriber.h
index 62ccafb19a..9e9074e70c 100644
--- a/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_subscriber.h
+++ b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_subscriber.h
@@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_DBUS_SUBSCRIBER_H_
-#define TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_DBUS_SUBSCRIBER_H_
+#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_SUBSCRIBER_H_
+#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_SUBSCRIBER_H_
#include <string>
@@ -39,7 +39,7 @@ struct DBusConnection;
namespace test {
namespace components {
-namespace hmi_message_handler {
+namespace hmi_message_handler_test {
class MockSubscriber {
public:
@@ -55,8 +55,8 @@ class MockSubscriber {
DBusConnection* conn_;
};
-} // namespace hmi_message_handler
+} // namespace hmi_message_handler_test
} // namespace components
} // namespace test
-#endif // TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_DBUS_SUBSCRIBER_H_
+#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_SUBSCRIBER_H_
diff --git a/src/components/hmi_message_handler/test/mock_subscriber.cc b/src/components/hmi_message_handler/test/mock_subscriber.cc
index c52d47b008..0fc9110a1d 100644
--- a/src/components/hmi_message_handler/test/mock_subscriber.cc
+++ b/src/components/hmi_message_handler/test/mock_subscriber.cc
@@ -30,12 +30,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <dbus/dbus.h>
-#include "include/mock_subscriber.h"
+#include "dbus/dbus.h"
+#include "hmi_message_handler/mock_subscriber.h"
namespace test {
namespace components {
-namespace hmi_message_handler {
+namespace hmi_message_handler_test {
MockSubscriber::MockSubscriber(const std::string& nameService,
const std::string& path)
@@ -47,7 +47,6 @@ void MockSubscriber::Receive() {}
bool MockSubscriber::Start() {
DBusError err;
- // int ret;
dbus_error_init(&err);
conn_ = dbus_bus_get(DBUS_BUS_SESSION, &err);
if (dbus_error_is_set(&err)) {
@@ -65,10 +64,8 @@ bool MockSubscriber::Start() {
return true;
}
-void MockSubscriber::Send(const std::string& message) {
- // int a = message.length();
-}
+void MockSubscriber::Send(const std::string& message) {}
-} // namespace hmi_message_handler
+} // namespace hmi_message_handler_test
} // namespace components
} // namespace test
diff --git a/src/components/hmi_message_handler/test/mqueue_adapter_test.cc b/src/components/hmi_message_handler/test/mqueue_adapter_test.cc
deleted file mode 100644
index e5c5d2a396..0000000000
--- a/src/components/hmi_message_handler/test/mqueue_adapter_test.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2014, Ford Motor Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the Ford Motor Company nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "hmi_message_handler/hmi_message_handler.h"
-#include "hmi_message_handler/mqueue_adapter.h"
-
-using hmi_message_handler::MessageSharedPointer;
-using hmi_message_handler::HMIMessageHandler;
-using hmi_message_handler::HMIMessageAdapter;
-using hmi_message_handler::MqueueAdapter;
-using application_manager::Message;
-
-class MockHandler : public HMIMessageHandler {
- public:
- MOCK_METHOD1(OnMessageReceived, void(MessageSharedPointer message));
- MOCK_METHOD1(AddHMIMessageAdapter, void(HMIMessageAdapter* adapter));
- MOCK_METHOD1(RemoveHMIMessageAdapter, void(HMIMessageAdapter* adapter));
- MOCK_METHOD1(OnErrorSending, void(MessageSharedPointer message));
- MOCK_METHOD1(SendMessageToHMI, void(MessageSharedPointer message));
-};
-
-// TODO{ALeshin}: APPLINK-10846
-// TEST(MqueueAdapter, Send) {
-// MockHandler handler;
-// HMIMessageAdapter* adapter = new MqueueAdapter(&handler);
-
-// MessageSharedPointer message(
-// new Message(protocol_handler::MessagePriority::kDefault));
-// message->set_json_message("{}");
-// adapter->SendMessageToHMI(message);
-
-// mqd_t mqd = mq_open("/sdl_to_hmi", O_RDONLY);
-// ASSERT_NE(-1, mqd);
-// static char buf[65536];
-// ssize_t sz = mq_receive(mqd, buf, 65536, NULL);
-// ASSERT_EQ(2, sz);
-// EXPECT_STREQ("{}", buf);
-
-// delete adapter;
-//}
-
-// TODO{ALeshin}: APPLINK-10846
-// TEST(MqueueAdapter, Receive) {
-// MockHandler handler;
-// HMIMessageAdapter* adapter = new MqueueAdapter(&handler);
-
-// using ::testing::Property;
-// using ::testing::Pointee;
-// EXPECT_CALL(
-// handler,
-// OnMessageReceived(Property(
-// &MessageSharedPointer::get,
-// Pointee(Property(&Message::json_message, std::string("()"))))));
-
-// mqd_t mqd = mq_open("/hmi_to_sdl", O_WRONLY);
-// ASSERT_NE(-1, mqd);
-// const char buf[] = "()";
-// int rc = mq_send(mqd, buf, sizeof(buf) - 1, 0);
-// ASSERT_EQ(0, rc);
-
-// delete adapter;
-//}