summaryrefslogtreecommitdiff
path: root/src/components/hmi_message_handler/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/hmi_message_handler/test')
-rw-r--r--src/components/hmi_message_handler/test/CMakeLists.txt57
-rw-r--r--src/components/hmi_message_handler/test/Readme.txt11
-rw-r--r--src/components/hmi_message_handler/test/dbus_message_adapter_test.cc67
-rw-r--r--src/components/hmi_message_handler/test/include/hmi_message_handler/mock_dbus_message_controller.h68
-rw-r--r--src/components/hmi_message_handler/test/include/hmi_message_handler/mock_subscriber.h62
-rw-r--r--src/components/hmi_message_handler/test/include/mock_subscriber.h62
-rw-r--r--src/components/hmi_message_handler/test/main.cc41
-rw-r--r--src/components/hmi_message_handler/test/mock_subscriber.cc81
-rw-r--r--src/components/hmi_message_handler/test/mqueue_adapter_test.cc94
9 files changed, 543 insertions, 0 deletions
diff --git a/src/components/hmi_message_handler/test/CMakeLists.txt b/src/components/hmi_message_handler/test/CMakeLists.txt
new file mode 100644
index 0000000000..a8597b51bd
--- /dev/null
+++ b/src/components/hmi_message_handler/test/CMakeLists.txt
@@ -0,0 +1,57 @@
+# 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.
+
+if(BUILD_TESTS)
+
+include_directories (
+ ${GMOCK_INCLUDE_DIRECTORY}
+ ${COMPONENTS_DIR}/hmi_message_handler/include
+)
+
+set(LIBRARIES
+ gmock
+ ApplicationManager
+ HMIMessageHandler
+)
+
+set(SOURCES
+ ${COMPONENTS_DIR}/hmi_message_handler/test/main.cc
+ ${COMPONENTS_DIR}/hmi_message_handler/test/mqueue_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
+ )
+endif()
+create_test("hmi_message_handler_test" "${SOURCES}" "${LIBRARIES}")
+
+endif() \ No newline at end of file
diff --git a/src/components/hmi_message_handler/test/Readme.txt b/src/components/hmi_message_handler/test/Readme.txt
new file mode 100644
index 0000000000..4dcd565d90
--- /dev/null
+++ b/src/components/hmi_message_handler/test/Readme.txt
@@ -0,0 +1,11 @@
+28.11.2014 Andriy Byzhynar
+
+1) Tests for mqueue_adapter failed as mqueue transport still not used.
+2) Tests are not actual at the moment until PASA moves to use mqueue transport.
+3) To activate tests - just uncomment following lines in CMakeLists.txt of hmi_message_handler :
+
+ - #if(BUILD_TESTS)
+ - # add_subdirectory(test)
+ - #endif()
+
+ They are located at the end of file.
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
new file mode 100644
index 0000000000..6699f788dd
--- /dev/null
+++ b/src/components/hmi_message_handler/test/dbus_message_adapter_test.cc
@@ -0,0 +1,67 @@
+/**
+* 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/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
new file mode 100644
index 0000000000..7512f2ab19
--- /dev/null
+++ b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_dbus_message_controller.h
@@ -0,0 +1,68 @@
+/*
+* 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.
+*/
+
+#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_
+
+#include <pthread.h>
+#include "hmi_message_handler/dbus_message_controller.h"
+
+class MockDBusMessageController :
+ public ::hmi_message_handler::DBusMessageController {
+ public:
+ MOCK_METHOD1(Recv, void(std::string&));
+
+ MockDBusMessageController(const std::string& serviceName,
+ const std::string& path)
+ : DBusMessageController(serviceName, path),
+ 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 ::hmi_message_handler::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;
+ }
+};
+
+
+#endif // TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_MOCK_DBUS_MESSAGE_CONTROLLER_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
new file mode 100644
index 0000000000..62ccafb19a
--- /dev/null
+++ b/src/components/hmi_message_handler/test/include/hmi_message_handler/mock_subscriber.h
@@ -0,0 +1,62 @@
+/*
+* 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.
+*/
+
+#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_
+
+#include <string>
+
+struct DBusConnection;
+
+namespace test {
+namespace components {
+namespace hmi_message_handler {
+
+class MockSubscriber {
+ public:
+ MockSubscriber(const std::string nameService, const std::string path);
+ virtual ~MockSubscriber();
+ virtual void Receive();
+ bool Start();
+ void Send(const std::string& message);
+
+ private:
+ std::string nameService_;
+ std::string path_;
+ DBusConnection* conn_;
+};
+
+} // namespace hmi_message_handler
+} // namespace components
+} // namespace test
+
+#endif // TEST_COMPONENTS_HMI_MESSAGE_HANDLER_INCLUDE_HMI_MESSAGE_HANDLER_DBUS_SUBSCRIBER_H_
diff --git a/src/components/hmi_message_handler/test/include/mock_subscriber.h b/src/components/hmi_message_handler/test/include/mock_subscriber.h
new file mode 100644
index 0000000000..27e7cad1be
--- /dev/null
+++ b/src/components/hmi_message_handler/test/include/mock_subscriber.h
@@ -0,0 +1,62 @@
+/*
+* 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.
+*/
+
+#ifndef SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_MOCK_SUBSCRIBER_H_
+#define SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_MOCK_SUBSCRIBER_H_
+
+#include <string>
+
+struct DBusConnection;
+
+namespace test {
+namespace components {
+namespace hmi_message_handler {
+
+class MockSubscriber {
+ public:
+ MockSubscriber(const std::string &nameService, const std::string & path);
+ virtual ~MockSubscriber();
+ virtual void Receive();
+ bool Start();
+ void Send(const std::string& message);
+
+ private:
+ std::string nameService_;
+ std::string path_;
+ DBusConnection* conn_;
+};
+
+} // namespace hmi_message_handler
+} // namespace components
+} // namespace test
+
+#endif // SRC_COMPONENTS_HMI_MESSAGE_HANDLER_TEST_INCLUDE_MOCK_SUBSCRIBER_H_
diff --git a/src/components/hmi_message_handler/test/main.cc b/src/components/hmi_message_handler/test/main.cc
new file mode 100644
index 0000000000..3a4e919d02
--- /dev/null
+++ b/src/components/hmi_message_handler/test/main.cc
@@ -0,0 +1,41 @@
+/*
+ * 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 "gmock/gmock.h"
+
+int main(int argc, char** argv) {
+ testing::InitGoogleMock(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+
+
+
+
diff --git a/src/components/hmi_message_handler/test/mock_subscriber.cc b/src/components/hmi_message_handler/test/mock_subscriber.cc
new file mode 100644
index 0000000000..3f1235bea9
--- /dev/null
+++ b/src/components/hmi_message_handler/test/mock_subscriber.cc
@@ -0,0 +1,81 @@
+/**
+* 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 <dbus/dbus.h>
+#include "include/mock_subscriber.h"
+
+
+namespace test {
+namespace components {
+namespace hmi_message_handler {
+
+MockSubscriber::MockSubscriber(
+ const std::string & nameService, const std::string & path)
+ : nameService_(nameService),
+ path_(path),
+ conn_(NULL) {
+}
+
+MockSubscriber::~MockSubscriber() {
+}
+
+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)) {
+ dbus_error_free(&err);
+ return false;
+ }
+
+
+ std::string rule = "type='signal',interface='" + nameService_ + "'";
+ dbus_bus_add_match(conn_, rule.c_str(), &err);
+ dbus_connection_flush(conn_);
+ if (dbus_error_is_set(&err)) {
+ dbus_error_free(&err);
+ return false;
+ }
+ return true;
+}
+
+void MockSubscriber::Send(const std::string& message) {
+ // int a = message.length();
+}
+
+} // namespace hmi_message_handler
+} // 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
new file mode 100644
index 0000000000..87fb3a3539
--- /dev/null
+++ b/src/components/hmi_message_handler/test/mqueue_adapter_test.cc
@@ -0,0 +1,94 @@
+/*
+ * 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;
+//}