summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerasym Oleh <oolleehh@gmail.com>2015-12-25 12:37:07 +0200
committerHerasym Oleh <oolleehh@gmail.com>2015-12-25 12:37:07 +0200
commit5a0b47bd2c503aa90eca2fd74acb77a831fe3050 (patch)
tree29a0e409f6e754dbee66a3b7f4e30eed36d5499f
parent3db17ce4390bdf66c8048095e39cb3350280e1be (diff)
downloadsmartdevicelink-5a0b47bd2c503aa90eca2fd74acb77a831fe3050.tar.gz
Delete unused folder test
Related: APPLINK-20109
-rw-r--r--test/CMakeLists.txt116
-rw-r--r--test/components/CMakeLists.txt39
-rw-r--r--test/components/application_manager/CMakeLists.txt35
-rw-r--r--test/components/application_manager/api_converter_v1_test.cpp137
-rw-r--r--test/components/application_manager/formatters_commands.cc37
-rw-r--r--test/components/application_manager/formatters_commands.h359
-rw-r--r--test/components/application_manager/generated_factory.cc37
-rw-r--r--test/components/application_manager/generated_factory.h91
-rw-r--r--test/components/connection_handler/CMakeLists.txt33
-rw-r--r--test/components/connection_handler/include/connection_handler/connection_handler_impl_test.h659
-rw-r--r--test/components/connection_handler/include/connection_handler/connection_test.h272
-rw-r--r--test/components/connection_handler/include/connection_handler/heart_beat_monitor_test.h232
-rw-r--r--test/components/connection_handler/src/connection_handler_impl_test.cc33
-rw-r--r--test/components/connection_handler/src/connection_test.cc33
-rw-r--r--test/components/connection_handler/src/heart_beat_monitor_test.cc33
-rw-r--r--test/components/dbus/CMakeLists.txt31
-rw-r--r--test/components/dbus/log4cxx.properties35
-rw-r--r--test/components/dbus/src/test_dbus_adapter.cc66
-rw-r--r--test/components/dbus/src/test_dbus_message_controller.cc124
-rw-r--r--test/components/dbus/src/test_schema.cc121
-rw-r--r--test/components/formatters/CMakeLists.txt19
-rw-r--r--test/components/formatters/src/generic_json_formatter_test.cc161
-rw-r--r--test/components/hmi_message_handler/CMakeLists.txt35
-rw-r--r--test/components/hmi_message_handler/include/hmi_message_handler/mock_dbus_message_controller.h68
-rw-r--r--test/components/hmi_message_handler/include/hmi_message_handler/mock_subscriber.h62
-rw-r--r--test/components/hmi_message_handler/log4cxx.properties35
-rw-r--r--test/components/hmi_message_handler/src/mock_subscriber.cc88
-rw-r--r--test/components/hmi_message_handler/src/test_dbus_message_adapter.cc38
-rw-r--r--test/components/hmi_message_handler/src/test_mqueue_adapter.cc92
-rw-r--r--test/components/include/protocol_handler/control_message_matcher.h138
-rw-r--r--test/components/include/protocol_handler/protocol_handler_mock.h66
-rw-r--r--test/components/include/protocol_handler/protocol_observer_mock.h57
-rw-r--r--test/components/include/protocol_handler/session_observer_mock.h104
-rw-r--r--test/components/include/security_manager/crypto_manager_mock.h67
-rw-r--r--test/components/include/security_manager/security_manager_listener_mock.h54
-rw-r--r--test/components/include/security_manager/security_manager_mock.h76
-rw-r--r--test/components/include/security_manager/ssl_context_mock.h71
-rw-r--r--test/components/include/transport_manager/transport_manager_mock.h87
-rw-r--r--test/components/json_handler/CMakeLists.txt38
-rw-r--r--test/components/json_handler/include/json_handler/formatter_json_alrpcv1_test.h991
-rw-r--r--test/components/json_handler/include/json_handler/formatter_json_alrpcv2_test.h114
-rw-r--r--test/components/json_handler/include/json_handler/formatter_json_rpcv2_test.h96
-rw-r--r--test/components/json_handler/include/json_handler/formatter_test_helper.h55
-rw-r--r--test/components/json_handler/include/json_handler/meta_formatter_test_helper.h157
-rw-r--r--test/components/json_handler/include/json_handler/smart_schema_draft_test.h307
-rw-r--r--test/components/json_handler/src/FormatterJsonSDLRPCv1Test.cpp1090
-rw-r--r--test/components/json_handler/src/FormatterJsonSDLRPCv2Test.cpp298
-rw-r--r--test/components/json_handler/src/formatter_json_alrpcv1_test.cc31
-rw-r--r--test/components/json_handler/src/formatter_json_alrpcv2_test.cc31
-rw-r--r--test/components/json_handler/src/formatter_json_rpc2_test.cc31
-rw-r--r--test/components/json_handler/src/formatter_json_rpc_test.cc855
-rw-r--r--test/components/json_handler/src/formatter_test_helper.cc94
-rw-r--r--test/components/json_handler/src/meta_formatter_test.cc502
-rw-r--r--test/components/json_handler/src/meta_formatter_test_helper.cc245
-rw-r--r--test/components/json_handler/src/smart_schema_draft_test.cc32
-rw-r--r--test/components/json_handler/src/test_json_rpc_full_scenario.cpp258
-rw-r--r--test/components/json_handler/test_JSONHandler_v4_protocol_v1_2_no_extra.xml1154
-rw-r--r--test/components/json_handler/test_JSONHandler_v4_protocol_v2_0_revP.xml3174
-rw-r--r--test/components/json_handler/test_json_rpc.xml100
-rw-r--r--test/components/media_manager/CMakeLists.txt51
-rw-r--r--test/components/media_manager/include/media_manager/media_manager_impl_test.h119
-rw-r--r--test/components/media_manager/src/media_manager_impl_test.cc34
-rw-r--r--test/components/mobile_message_handler/CMakeLists.txt28
-rw-r--r--test/components/mobile_message_handler/include/mobile_message_handler/mobile_message_handler_test.h181
-rw-r--r--test/components/mobile_message_handler/src/mobile_message_handler_test.cc36
-rw-r--r--test/components/protocol_handler/CMakeLists.txt31
-rw-r--r--test/components/protocol_handler/include/protocol_handler/incoming_data_handler_test.h359
-rw-r--r--test/components/protocol_handler/include/protocol_handler/protocol_handler_mock.h169
-rw-r--r--test/components/protocol_handler/include/protocol_handler/protocol_handler_tm_test.h759
-rw-r--r--test/components/protocol_handler/include/protocol_handler/protocol_header_validator_test.h249
-rw-r--r--test/components/protocol_handler/src/incoming_data_handler_test.cc33
-rw-r--r--test/components/protocol_handler/src/protocol_handler_tm_test.cc32
-rw-r--r--test/components/protocol_handler/src/protocol_header_validator_test.cc32
-rw-r--r--test/components/qt_hmi/CMakeLists.txt52
-rw-r--r--test/components/qt_hmi/log4cxx.properties41
-rw-r--r--test/components/qt_hmi/qt_hmi_test.cc33
-rw-r--r--test/components/qt_hmi/readme.txt12
-rw-r--r--test/components/qt_hmi/src/tst_AddCommand.qml320
-rw-r--r--test/components/qt_hmi/src/tst_AddSubMenu.qml328
-rw-r--r--test/components/qt_hmi/src/tst_DeleteCommand.qml210
-rw-r--r--test/components/qt_hmi/src/tst_ScrollableMessage.qml421
-rw-r--r--test/components/qt_hmi/src/tst_SetMediaClockTimer.qml292
-rw-r--r--test/components/qt_hmi/src/tst_Show.qml363
-rw-r--r--test/components/qt_hmi/src/tst_Slider.qml204
-rw-r--r--test/components/rpc_base/CMakeLists.txt29
-rw-r--r--test/components/rpc_base/rpc_base_dbus_test.cc689
-rw-r--r--test/components/rpc_base/rpc_base_json_test.cc378
-rw-r--r--test/components/rpc_base/rpc_base_test.cc438
-rw-r--r--test/components/security_manager/CMakeLists.txt69
-rw-r--r--test/components/security_manager/include/security_manager/crypto_manager_impl_test.h459
-rw-r--r--test/components/security_manager/include/security_manager/security_manager_mock.h261
-rw-r--r--test/components/security_manager/include/security_manager/security_manager_test.h798
-rw-r--r--test/components/security_manager/include/security_manager/security_query_matcher.h105
-rw-r--r--test/components/security_manager/include/security_manager/security_query_test.h461
-rw-r--r--test/components/security_manager/src/crypto_manager_impl_test.cc33
-rw-r--r--test/components/security_manager/src/security_manager_test.cc33
-rw-r--r--test/components/security_manager/src/security_query_matcher.cc55
-rw-r--r--test/components/security_manager/src/security_query_test.cc33
-rw-r--r--test/components/smart_objects/CMakeLists.txt40
-rw-r--r--test/components/smart_objects/SchemaItem/AlwaysFalseSchemaItemTest.cpp92
-rw-r--r--test/components/smart_objects/SchemaItem/AlwaysTrueSchemaItemTest.cpp94
-rw-r--r--test/components/smart_objects/SchemaItem/CMakeLists.txt32
-rw-r--r--test/components/smart_objects/SchemaItem/EnumSchemaItemTest.cpp277
-rw-r--r--test/components/smart_objects/SchemaItem/test_ArraySchemaItemTest.cpp347
-rw-r--r--test/components/smart_objects/SchemaItem/test_BoolSchemaItemTest.cpp198
-rw-r--r--test/components/smart_objects/SchemaItem/test_CObjectSchemaItem.cpp488
-rw-r--r--test/components/smart_objects/SchemaItem/test_NumberSchemaItemTest.cpp781
-rw-r--r--test/components/smart_objects/SchemaItem/test_StringSchemaItemTest.cpp305
-rw-r--r--test/components/smart_objects/SmartObjectConvertionTimeTest.cc32
-rw-r--r--test/components/smart_objects/SmartObjectConvertionTimeTest.h676
-rw-r--r--test/components/smart_objects/SmartObjectDraftTest.cc32
-rw-r--r--test/components/smart_objects/SmartObjectDraftTest.h368
-rw-r--r--test/components/smart_objects/SmartObjectInvalidTest.cc32
-rw-r--r--test/components/smart_objects/SmartObjectInvalidTest.h178
-rw-r--r--test/components/smart_objects/SmartObjectStressTest.cc32
-rw-r--r--test/components/smart_objects/SmartObjectStressTest.h358
-rw-r--r--test/components/smart_objects/SmartObjectUnitTest.cc32
-rw-r--r--test/components/smart_objects/SmartObjectUnitTest.h590
-rw-r--r--test/components/smart_objects/TSharedPtrTest.cc32
-rw-r--r--test/components/smart_objects/TSharedPtrTest.h209
-rw-r--r--test/components/smart_objects/map_performance_test.cc79
-rw-r--r--test/components/smart_objects/smart_object_performance_test.cc79
-rw-r--r--test/components/transport_manager/CMakeLists.txt65
-rw-r--r--test/components/transport_manager/HandleGeneratorsTest.cpp114
-rw-r--r--test/components/transport_manager/ListenersTest.cpp236
-rw-r--r--test/components/transport_manager/TcpSimulator.cpp862
-rw-r--r--test/components/transport_manager/TransportManagerTestWithCorrectDeviceAdapter.cpp406
-rw-r--r--test/components/transport_manager/TransportManagerTestWithHighDataTransferRate.cpp406
-rw-r--r--test/components/transport_manager/TransportManagerTestWithIncorrectDeviceAdapter.cpp224
-rw-r--r--test/components/transport_manager/TransportManagerTestWithMultiThreadedClient.cpp502
-rw-r--r--test/components/transport_manager/TransportManagerTestWithMultipleClients.cpp552
-rw-r--r--test/components/transport_manager/TransportManagerTestWithMultipleDeviceAdapters.cpp435
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_application.h80
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_connection.h69
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_connection_factory.h69
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_device.h82
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_device_scanner.h76
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_transport_adapter.h62
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_transport_adapter_listener.h94
-rw-r--r--test/components/transport_manager/include/transport_manager/mock_transport_manager_listener.h103
-rw-r--r--test/components/transport_manager/include/transport_manager/raw_message_matcher.h78
-rw-r--r--test/components/transport_manager/log4cplus.properties19
-rw-r--r--test/components/transport_manager/log4cplus_disabled.properties3
-rw-r--r--test/components/transport_manager/log4cxx.properties57
-rw-r--r--test/components/transport_manager/src/mock_application.cc149
-rw-r--r--test/components/transport_manager/src/mock_connection.cc87
-rw-r--r--test/components/transport_manager/src/mock_connection_factory.cc66
-rw-r--r--test/components/transport_manager/src/mock_device.cc87
-rw-r--r--test/components/transport_manager/src/mock_device_scanner.cc106
-rw-r--r--test/components/transport_manager/src/mock_transport_adapter.cc60
-rw-r--r--test/components/transport_manager/src/raw_message_matcher.cc135
-rw-r--r--test/components/transport_manager/src/test_dnssd_service_browser.cc98
-rw-r--r--test/components/transport_manager/src/test_tcp_transport_adapter.cc332
-rw-r--r--test/components/transport_manager/src/transport_manager_test.cc285
-rwxr-xr-xtest/components/transport_manager/test_DnssdServiceDiscovery.sh21
-rw-r--r--test/components/transport_manager/transport_manager_instance_test.cc447
-rw-r--r--test/components/transport_manager/transport_manager_instance_test.h397
-rw-r--r--test/gtest-example/CMakeLists.txt18
-rw-r--r--test/gtest-example/example.cpp53
-rw-r--r--test/log4cxx.properties78
-rwxr-xr-xtest/scripts/random_stream.py76
-rw-r--r--test/thirdPartyLibs/CMakeLists.txt2
-rw-r--r--test/thirdPartyLibs/jsoncpp/CMakeLists.txt11
-rw-r--r--test/thirdPartyLibs/jsoncpp/include/jsoncpp/json_reader_test.h168
-rw-r--r--test/thirdPartyLibs/jsoncpp/src/json_reader_test.cc36
-rw-r--r--test/tools/CMakeLists.txt2
-rw-r--r--test/tools/intergen/CMakeLists.txt54
-rw-r--r--test/tools/intergen/src/generated_interface_dbus_tests.cc95
-rw-r--r--test/tools/intergen/src/generated_interface_json_tests.cc593
-rw-r--r--test/tools/intergen/test_hmi_interafce.xml3669
-rw-r--r--test/tools/intergen/test_interface.xml426
-rw-r--r--test/tools/policy_table_validator/CMakeLists.txt27
-rw-r--r--test/tools/policy_table_validator/main.cpp83
173 files changed, 0 insertions, 39362 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
deleted file mode 100644
index cb0052e1a..000000000
--- a/test/CMakeLists.txt
+++ /dev/null
@@ -1,116 +0,0 @@
-find_package(Gstreamer-1.0 REQUIRED)
-find_package(Glib-2.0 REQUIRED)
-
-# --- GoogleTest example
-#add_subdirectory(./gtest-example)
-
-include_directories(
- ${CMAKE_SOURCE_DIR}/test/components/include)
-
-# --- components tests
-#add_subdirectory(./components)
-#add_subdirectory(./thirdPartyLibs)
-add_subdirectory(./tools)
-
-set (INCLUDE_DIR
- ${GMOCK_INCLUDE_DIRECTORY}
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${MESSAGE_BROKER_INCLUDE_DIRECTORY}
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ../src/appMain
- ../src/components/application_manager/include
- ../src/components/hmi_message_handler/include
- ../src/components/request_watchdog/include
- ../src/components/media_manager/include
- ../src/components/config_profile/include
- ../src/components/policy/src/policy/include
- ../src/components/policy/src/policy/usage_statistics/include
- ../src/components/protocol_handler/include
- ../src/components/transport_manager/include
- ../src/components/connection_handler/include
- ${SecurityManagerIncludeDir}
- ../src/components/formatters/include
- ../src/components/smart_objects/include
- ../src/components/formatters/include
- ../src/components/utils/include/
- ../src/components/resumption/include/
- ../test/components/mobile_message_handler/include/
- ../test/components/request_watchdog/include/
- ../test/components/media_manager/include
- ../test/components/protocol_handler/include/
- ../test/components/utils/include
- ../test/components/json_handler/include
- ../test/components/smart_objects
- ../test/components/smart_objects/SchemaItem
- ../test/components/transport_manager
- ../test/components/connection_handler/include
- ../test/components/security_manager/include
- ../test/components/
- ../test/thirdPartyLibs/jsoncpp/include
- ../test/components/application_manager
- ../test/components/application_manager/rpc/include
- ${CMAKE_BINARY_DIR}/src/components/
- ${CMAKE_BINARY_DIR}
-# /usr/lib/i386-linux-gnu/glib-2.0/include
-# /usr/lib/x86_64-linux-gnu/glib-2.0/include/
-# ${GSTREAMER_gst_INCLUDE_DIR}
-# ${GLIB_glib_2_INCLUDE_DIR}
-)
-
-set(LIBRARIES
- MediaManager
- ApplicationManager
- gtest
- gtest_main
- gmock
- gmock_main
- formatters
- HMI_API
- v4_protocol_v1_2_no_extra
- SmartObjects
- ProtocolHandler
- Utils
- ConfigProfile
- #test_JSONHandler_v4_protocol_v2_0_revP
- #test_json_handler
- #test_SmartObjectTest
- #test_FormattersCommandsTest
- #test_UtilsTest
- #test_RequestWatchdogTest
- #test_ProtocolHandlerTest
- #test_JSONCPPTest
- #test_MobileMessageHandlerTest
- connectionHandler
- MOBILE_API
- jsoncpp
- TransportManager
- HMIMessageHandler
- MessageBroker
- MessageBrokerClient
- MessageBrokerServer
- encryption
- ${RTLIB}
- # ${GSTREAMER_gstreamer_LIBRARY}
- Resumption
- Policy
- ${SecurityManagerLibrary}
-)
-if(ENABLE_SECURITY)
- LIST(APPEND LIBRARIES test_SecurityManager)
-endif()
-
-if (BUILD_USB_SUPPORT)
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- list(APPEND LIBRARIES Libusb-1.0.16)
-endif()
-endif()
-
-#add_executable("test_suit" "./test_suit.cc")
-#file(COPY ${CMAKE_SOURCE_DIR}/mycert.pem ${CMAKE_SOURCE_DIR}/mykey.pem DESTINATION ${CMAKE_BINARY_DIR}/test/)
-#file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx.properties DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-
-#include_directories(${INCLUDE_DIR})
-#target_link_libraries("test_suit" ${LIBRARIES})
-
-# vim: set ts=2 sw=2 et:
diff --git a/test/components/CMakeLists.txt b/test/components/CMakeLists.txt
deleted file mode 100644
index 5a0af2f38..000000000
--- a/test/components/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-
-# --- TransportManager
-add_subdirectory(./transport_manager)
-
-# --- JSONHandler
-add_subdirectory(./json_handler)
-
-# --- SmartObjects
-#add_subdirectory(./smart_objects)
-
-# --- AppMgr
-#add_subdirectory(./application_manager)
-
-if(ENABLE_SECURITY)
-# --- ProtocolHandler
-#add_subdirectory(./protocol_handler)
-# --- SecurityManager
-#add_subdirectory(./security_manager)
-# TODO(EZamakhov): split connection tests and security
-# --- ConnectionHandler
-#add_subdirectory(./connection_handler)
-endif()
-
-add_subdirectory(./hmi_message_handler)
-
-# --- Mobile Message Handler
-# add_subdirectory(./mobile_message_handler)
-
-# --- Audio Manager
-#add_subdirectory(./media_manager)
-
-# -- rpc_base
-#add_subdirectory(./rpc_base)
-
-# --- DBus
-if(${QT_HMI})
- add_subdirectory(./dbus)
- add_subdirectory(./qt_hmi)
-endif(${QT_HMI})
diff --git a/test/components/application_manager/CMakeLists.txt b/test/components/application_manager/CMakeLists.txt
deleted file mode 100644
index 9d5e3802b..000000000
--- a/test/components/application_manager/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-############################## Subfolders #####################################
-# --- Policies table test
-#add_subdirectory(./policies_manager)
-
-###############################################################################
-
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ../../../src/components/application_manager/include
- ../../../src/components/smart_objects/include
- ../../../src/components/formatters/include/
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${CMAKE_BINARY_DIR}/src/components/
-)
-
-set(LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- ApplicationManager
- formatters
- jsoncpp
- MOBILE_API
- HMI_API
- SmartObjects
- ProtocolLibrary
-)
-
-#create_test("test_APIVersionConverterV1Test" "./api_converter_v1_test.cpp" "${LIBRARIES}")
-create_test("test_formatters_commands" "./formatters_commands.cc" "${LIBRARIES}")
-#create_test("test_schema_factory_test" "./schema_factory_test.cc" "${LIBRARIES}")
-add_library("test_FormattersCommandsTest" "./formatters_commands.cc")
diff --git a/test/components/application_manager/api_converter_v1_test.cpp b/test/components/application_manager/api_converter_v1_test.cpp
deleted file mode 100644
index 633dde5fe..000000000
--- a/test/components/application_manager/api_converter_v1_test.cpp
+++ /dev/null
@@ -1,137 +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.
-
-#include <stdlib.h>
-#include <string>
-#include <set>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-//#include "application_manager/api_version_converter_v1.h"
-
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-#include "interfaces/MOBILE_API.h"
-#include "v4_protocol_v1_2_no_extra.h"
-#include "formatters/CSmartFactory.hpp"
-
-namespace test {
-namespace components {
-namespace application_mngr {
-namespace APIVersionConverterV1Test {
-
-class CAPIVersionConverterV1Test {
- public:
- /**
- * Class constructor
- */
- CAPIVersionConverterV1Test() {}
-
- /**
- * Class destructor
- */
- virtual ~CAPIVersionConverterV1Test() {
- destructor();
- }
-
- /**
- *
- */
- MOCK_METHOD0(destructor, void());
-
- private:
-};
-
-} // namespace ApplicationCoreTest
-} // namespace AppMgr
-} // namespace components
-} // namespace test
-
-TEST(CAPIVersionConverterV1Test, Constructor) {
- using namespace test::components::application_mngr::APIVersionConverterV1Test;
-
- CAPIVersionConverterV1Test* pVersionConverter = new CAPIVersionConverterV1Test();
-
- EXPECT_CALL(*pVersionConverter, destructor()).Times(0);
- EXPECT_CALL(*pVersionConverter, destructor()).Times(1);
- delete pVersionConverter;
-}
-
-TEST(CAPIVersionConverterV1Test, convertJSON) {
- using namespace NsSmartDeviceLink::NsJSONHandler::strings;
- using namespace NsSmartDeviceLink::NsJSONHandler::Formatters;
- using namespace NsSmartDeviceLink::NsSmartObjects;
- using namespace NsSmartDeviceLinkRPC::V1;
-
- // create CApplicationCoreTest instance
- std::string inputJsonString = "\
- {\
- \"request\": {\
- \"name\" : \"RegisterAppInterace\",\
- \"correlationID\": 0,\
- \"parameters\": {\
- \"syncMsgVersion\" : {\
- \"majorVersion\" : 2,\
- \"minorVersion\" : 10\
- },\
- \"appName\": \"some app name\",\
- \"ttsName\": [{\
- \"text\": \"ABC\",\
- \"type\": \"TEXT\"\
- }],\
- \"vrSynonyms\": [\"Synonym 1\", \"Synonym 2\"]\
- }\
- }\
- }";
-
- SmartObject obj;
- bool result;
- result = CFormatterJsonSDLRPCv1::fromString<FunctionID::eType, messageType::eType>(inputJsonString, obj);
-
- if (false == result) {
- printf("Formatter result is FALSE\n");
- } else {
- printf("Formatter result is TRUE\n");
- }
-
- printf("#### %d \n", obj[S_PARAMS][S_FUNCTION_ID].asInt());
-
- /*
- std::set<std::string> tmp2 = newobj.enumerate();
- for (std::set<std::string>::iterator it = tmp2.begin(); it != tmp2.end(); ++it) {
- printf("%s\n", (*it).c_str());
- }
- */
-}
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/application_manager/formatters_commands.cc b/test/components/application_manager/formatters_commands.cc
deleted file mode 100644
index 3e067da35..000000000
--- a/test/components/application_manager/formatters_commands.cc
+++ /dev/null
@@ -1,37 +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.
-*/
-
-#include "./formatters_commands.h"
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/application_manager/formatters_commands.h b/test/components/application_manager/formatters_commands.h
deleted file mode 100644
index c3530944e..000000000
--- a/test/components/application_manager/formatters_commands.h
+++ /dev/null
@@ -1,359 +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 TEST_COMPONENTS_APPLICATION_MANAGER_FORMATTERS_COMMANDS_H_
-#define TEST_COMPONENTS_APPLICATION_MANAGER_FORMATTERS_COMMANDS_H_
-
-#include <string>
-#include <iostream>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "application_manager/mobile_command_factory.h"
-#include "utils/shared_ptr.h"
-
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-#include "formatters/formatter_json_rpc.h"
-
-#include "interfaces/MOBILE_API.h"
-#include "interfaces/MOBILE_API_schema.h"
-#include "interfaces/HMI_API.h"
-#include "interfaces/HMI_API_schema.h"
-
-namespace test_command {
-
-}
-namespace formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
-namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
-namespace sos = NsSmartDeviceLink::NsJSONHandler::strings;
-
-TEST(add_command, general) {
- std::string incoming_string =
- "{\
- \"menuID\" : 1000,\
- \"menuName\" : \"SubmenuName\"\
-}";
-
- smart_objects::SmartObject incoming_message;
-
- formatters::CFormatterJsonSDLRPCv2::fromString<mobile_apis::FunctionID::eType, mobile_apis::messageType::eType>(
- incoming_string,
- incoming_message,
- mobile_apis::FunctionID::AddSubMenuID,
- mobile_apis::messageType::request,
- 258);
-
- mobile_apis::MOBILE_API factory;
-/* std::cout << "Attach schema: " << factory.attachSchema(incoming_message) << std::endl;
-
- std::cout << "Is message valid? " << incoming_message.isValid() << std::endl;
-
- std::cout << "Internal message parameters: " << std::endl;
- std::set<std::string> internal_params = incoming_message["params"].enumerate();
- for (std::set<std::string>::const_iterator i = internal_params.begin(); i != internal_params.end(); ++i) {
- std::cout << (*i) << " : " << incoming_message["params"][*i].asString() << std::endl;
- }
-
- std::cout << "API parameters:" << std::endl;
-
- std::set<std::string> elements = incoming_message["msg_params"].enumerate();
- for (std::set<std::string>::const_iterator i = elements.begin(); i != elements.end(); ++i) {
- std::cout << (*i) << std::endl;
- }
-
- std::string str;
- formatters::CFormatterJsonSDLRPCv2::toString(incoming_message, str);
- std::cout << str << std::endl;
-*/
-}
-
-TEST(json2_command, notification) {
- std::string incoming_string = "{\"jsonrpc\" : \"2.0\",\"method\" : \"BasicCommunication.OnDeviceListUpdated\", \"params\" : { \"deviceList\" : [ \"XT910\", \"GT-I9300\", \"HTC Explorer A310e\" ] }}";
- smart_objects::SmartObject incoming_message;
-
- formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>(
- incoming_string,
- incoming_message);
-
- hmi_apis::HMI_API factory;
-/*
- std::cout << "Attach schema: " << factory.attachSchema(incoming_message) << std::endl;
-
- std::cout << "Is message valid? " << incoming_message.isValid() << std::endl;
-
- std::cout << "Internal message parameters: " << std::endl;
- std::set<std::string> internal_params = incoming_message["params"].enumerate();
- for (std::set<std::string>::const_iterator i = internal_params.begin(); i != internal_params.end(); ++i) {
- std::cout << (*i) << " : " << incoming_message["params"][*i].asString() << std::endl;
- }
-
- std::cout << "API parameters:" << std::endl;
-
- std::set<std::string> elements = incoming_message["msg_params"].enumerate();
- for (std::set<std::string>::const_iterator i = elements.begin(); i != elements.end(); ++i) {
- std::cout << (*i) << std::endl;
- }
-
- for (int i = 0; i < incoming_message["msg_params"]["deviceList"].length(); ++i) {
- std::cout << incoming_message["msg_params"]["deviceList"][i].asString() << std::endl;
- }
-
- std::cout << "Formatted message string: " << std::endl;
-
- std::string str;
- formatters::FormatterJsonRpc::ToString(incoming_message, str);
- std::cout << str << std::endl;
-*/
-}
-
-TEST(json2_command, request_no_params) {
- std::string incoming_string = "{\"id\":5005,\"jsonrpc\":\"2.0\",\"method\":\"BasicCommunication.GeApplictionSet\"}";
-
- smart_objects::SmartObject incoming_message;
-
- formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>(
- incoming_string,
- incoming_message);
-
- hmi_apis::HMI_API factory;
-/*
- std::cout << "Attach schema: " << factory.attachSchema(incoming_message) << std::endl;
-
- std::cout << "Is message valid? " << incoming_message.isValid() << std::endl;
-
- std::cout << "Internal message parameters: " << std::endl;
- std::set<std::string> internal_params = incoming_message["params"].enumerate();
- for (std::set<std::string>::const_iterator i = internal_params.begin(); i != internal_params.end(); ++i) {
- std::cout << (*i) << " : " << incoming_message["params"][*i].asString() << std::endl;
- }
-
- std::cout << "API parameters:" << std::endl;
-
- std::set<std::string> elements = incoming_message["msg_params"].enumerate();
- for (std::set<std::string>::const_iterator i = elements.begin(); i != elements.end(); ++i) {
- std::cout << (*i) << std::endl;
- }
-
- for (int i = 0; i < incoming_message["msg_params"]["deviceList"].length(); ++i) {
- std::cout << incoming_message["msg_params"]["deviceList"][i].asString() << std::endl;
- }
-
- std::cout << "Formatted message string: " << std::endl;
-
- std::string str;
- formatters::FormatterJsonRpc::ToString(incoming_message, str);
- std::cout << str << std::endl;
-*/
-}
-
-TEST(json2_command, response_params) {
- std::string incoming_string = "{\"id\" : 19,\"jsonrpc\" : \"2.0\",\"result\" : {\"capabilities\" : [{\
- \"longPressAvailable\" : true,\
- \"name\" : \"PRESET_0\",\
- \"shortPressAvailable\" : true,\
- \"upDownAvailable\" : true\
- },\
- {\
- \"longPressAvailable\" : true,\
- \"name\" : \"PRESET_1\",\
- \"shortPressAvailable\" : true,\
- \"upDownAvailable\" : true\
- }\
- ],\
- \"presetBankCapabilities\" : \
- {\
- \"onScreenPresetsAvailable\" : true\
- },\
- \"code\" : 0,\
- \"method\" : \"Buttons.GetCapabilities\"\
- }\
- }";
-
- smart_objects::SmartObject incoming_message;
-
- formatters::FormatterJsonRpc::FromString<hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>(
- incoming_string,
- incoming_message);
-
- hmi_apis::HMI_API factory;
-/*
- std::cout << "Attach schema: " << factory.attachSchema(incoming_message) << std::endl;
-
- std::cout << "Is message valid? " << incoming_message.isValid() << std::endl;
-
- std::cout << "Internal message parameters: " << std::endl;
- std::set<std::string> internal_params = incoming_message["params"].enumerate();
- for (std::set<std::string>::const_iterator i = internal_params.begin(); i != internal_params.end(); ++i) {
- std::cout << (*i) << " : " << incoming_message["params"][*i].asString() << std::endl;
- }
-
- std::cout << "API parameters:" << std::endl;
-
- std::set<std::string> elements = incoming_message["msg_params"].enumerate();
- for (std::set<std::string>::const_iterator i = elements.begin(); i != elements.end(); ++i) {
- std::cout << (*i) << std::endl;
- std::set<std::string> sub_params = incoming_message["msg_params"][*i].enumerate();
- for (std::set<std::string>::const_iterator j = sub_params.begin();
- sub_params.end() != j;
- ++j) {
- std::cout << (*j) << " : " << incoming_message["msg_params"][*i][*j].asString() << std::endl;
- }
- }
-
- for (int i = 0; i < incoming_message["msg_params"]["deviceList"].length(); ++i) {
- std::cout << incoming_message["msg_params"]["deviceList"][i].asString() << std::endl;
- }
-
- std::cout << "Formatted message string: " << std::endl;
-
- std::string str;
- formatters::FormatterJsonRpc::ToString(incoming_message, str);
- std::cout << str << std::endl;
-*/
-}
-
-TEST(json2_command, response_error_params) {
- std::string incoming_string = "{\
- \"id\" : 35,\
- \"jsonrpc\" : \"2.0\",\
- \"error\" : \
- {\
- \"code\" : 12,\
- \"message\" : \"File with this name is not available\",\
- \"data\" : {\
- \"method\" : \"Buttons.GetCapabilities\"\
- }\
- }\
-}";
-
- smart_objects::SmartObject incoming_message;
-
- formatters::FormatterJsonRpc::
- FromString<hmi_apis::FunctionID::eType, hmi_apis::messageType::eType>(
- incoming_string,
- incoming_message);
-
- hmi_apis::HMI_API factory;
-/*
- std::cout << "Attach schema: " << factory.attachSchema(incoming_message) << std::endl;
-
- std::cout << "Is message valid? " << incoming_message.isValid() << std::endl;
-
- std::cout << "Internal message parameters: " << std::endl;
- std::set<std::string> internal_params = incoming_message["params"].enumerate();
- for (std::set<std::string>::const_iterator i = internal_params.begin(); i != internal_params.end(); ++i) {
- std::cout << (*i) << " : " << incoming_message["params"][*i].asString() << std::endl;
- }
-
- std::cout << "API parameters:" << std::endl;
-
- std::set<std::string> elements = incoming_message["msg_params"].enumerate();
- for (std::set<std::string>::const_iterator i = elements.begin(); i != elements.end(); ++i) {
- std::cout << (*i) << std::endl;
- }
-
- std::cout << "Formatted message string: " << std::endl;
-
- std::string str;
- formatters::FormatterJsonRpc::ToString(incoming_message, str);
- std::cout << str << std::endl;
-*/
-}
-
-TEST(json2_command, create_object) {
- hmi_apis::HMI_API factory;
- smart_objects::SmartObject is_vr_ready =
- factory.CreateSmartObject(hmi_apis::FunctionID::VR_IsReady,
- hmi_apis::messageType::request);
-
- ASSERT_EQ(smart_objects::SmartType_Map, is_vr_ready.getType());
- /*std::cout << "FunctionID " << is_vr_ready[sos::S_PARAMS][sos::S_FUNCTION_ID].asInt()
- << "; message type " << is_vr_ready[sos::S_PARAMS][sos::S_MESSAGE_TYPE].asInt()
- << "; protocol version " << is_vr_ready[sos::S_PARAMS][sos::S_PROTOCOL_VERSION].asInt()
- << "; protocol type " << is_vr_ready[sos::S_PARAMS][sos::S_PROTOCOL_TYPE].asInt()
- << "; correlation id " << is_vr_ready[sos::S_PARAMS][sos::S_CORRELATION_ID].asInt() << std::endl;
- */
-
- is_vr_ready[sos::S_PARAMS][sos::S_FUNCTION_ID] =
- hmi_apis::FunctionID::VR_IsReady;
- is_vr_ready[sos::S_PARAMS][sos::S_MESSAGE_TYPE] =
- hmi_apis::messageType::request;
- is_vr_ready[sos::S_PARAMS][sos::S_PROTOCOL_VERSION] = 2;
- is_vr_ready[sos::S_PARAMS][sos::S_PROTOCOL_TYPE] = 1;
- is_vr_ready[sos::S_PARAMS][sos::S_CORRELATION_ID] = 4444;
- is_vr_ready[sos::S_MSG_PARAMS] = smart_objects::SmartObject(smart_objects::SmartType_Map);
-/*
- std::cout << "FunctionID " << is_vr_ready[sos::S_PARAMS][sos::S_FUNCTION_ID].asInt()
- << "; message type " << is_vr_ready[sos::S_PARAMS][sos::S_MESSAGE_TYPE].asInt()
- << "; protocol version " << is_vr_ready[sos::S_PARAMS][sos::S_PROTOCOL_VERSION].asInt()
- << "; protocol type " << is_vr_ready[sos::S_PARAMS][sos::S_PROTOCOL_TYPE].asInt()
- << "; correlation id " << is_vr_ready[sos::S_PARAMS][sos::S_CORRELATION_ID].asInt() << std::endl;
-
- ASSERT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, is_vr_ready.validate());
-
- std::string str;
- formatters::FormatterJsonRpc::ToString(is_vr_ready, str);
- std::cout << str << std::endl;
-*/
-}
-
-TEST(json2_command, without_factory_create) {
- smart_objects::SmartObject so_to_send;
- so_to_send[sos::S_PARAMS][sos::S_FUNCTION_ID] =
- hmi_apis::FunctionID::VR_IsReady;
- so_to_send[sos::S_PARAMS][sos::S_MESSAGE_TYPE] =
- hmi_apis::messageType::request;
- so_to_send[sos::S_PARAMS][sos::S_PROTOCOL_VERSION] = 2;
- so_to_send[sos::S_PARAMS][sos::S_PROTOCOL_TYPE] = 1;
- so_to_send[sos::S_PARAMS][sos::S_CORRELATION_ID] = 4444;
- so_to_send[sos::S_MSG_PARAMS] = smart_objects::SmartObject(smart_objects::SmartType_Map);
-
- /*std::cout << "FunctionID " << so_to_send[sos::S_PARAMS][sos::S_FUNCTION_ID].asInt()
- << "; message type " << so_to_send[sos::S_PARAMS][sos::S_MESSAGE_TYPE].asInt()
- << "; protocol version " << so_to_send[sos::S_PARAMS][sos::S_PROTOCOL_VERSION].asInt()
- << "; protocol type " << so_to_send[sos::S_PARAMS][sos::S_PROTOCOL_TYPE].asInt()
- << "; correlation id " << so_to_send[sos::S_PARAMS][sos::S_CORRELATION_ID].asInt() << std::endl;
- */
-
- hmi_apis::HMI_API factory;
- factory.attachSchema(so_to_send);
- ASSERT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, so_to_send.validate());
-/*
- std::string str;
- formatters::FormatterJsonRpc::ToString(so_to_send, str);
- std::cout << str << std::endl;
-*/
-}
-
-#endif // TEST_COMPONENTS_APPLICATION_MANAGER_FORMATTERS_COMMANDS_H_
diff --git a/test/components/application_manager/generated_factory.cc b/test/components/application_manager/generated_factory.cc
deleted file mode 100644
index 77da54acb..000000000
--- a/test/components/application_manager/generated_factory.cc
+++ /dev/null
@@ -1,37 +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.
-*/
-
-#include "./generated_factory.h"
-
-int main(int argc, char** argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/application_manager/generated_factory.h b/test/components/application_manager/generated_factory.h
deleted file mode 100644
index 27ac61def..000000000
--- a/test/components/application_manager/generated_factory.h
+++ /dev/null
@@ -1,91 +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 TEST_COMPONENTS_APPLICATION_MANAGER_FORMATTERS_COMMANDS_H_
-#define TEST_COMPONENTS_APPLICATION_MANAGER_FORMATTERS_COMMANDS_H_
-
-#include <string>
-#include <iostream>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-//#include "application_manager/mobile_command_factory.h"
-#include "utils/shared_ptr.h"
-
-//#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-//#include "formatters/formatter_json_rpc.h"
-
-#include "interfaces/MOBILE_API.h"
-#include "interfaces/MOBILE_API_schema.h"
-#include "interfaces/HMI_API.h"
-#include "interfaces/HMI_API_schema.h"
-
-#include "utils/threads/thread.h"
-
-namespace test_command {
-
-class SomeClass : public threads::ThreadDelegate {
- public:
- void threadMain();
-};
-
-void SomeClass::threadMain() {
- hmi_apis::HMI_API factory;
- while (1) {
- std::cout << "1" << std::endl;
- }
-}
-
-}
-/*namespace formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
-namespace smart_objects = NsSmartDeviceLink::NsSmartObjects;
-namespace sos = NsSmartDeviceLink::NsJSONHandler::strings;
-*/
-TEST(generated_factory, create) {
- threads::Thread* thread = new threads::Thread(
- "application_manager::SomeClass",
- new test_command::SomeClass);
-
- if (!thread->start(
- threads::ThreadOptions(16384))) {
- std::cout << "Something went wrong with thread." << std::endl;
- return;
- }
-
- sleep(2);
- thread->stop();
-
-}
-
-#endif // TEST_COMPONENTS_APPLICATION_MANAGER_FORMATTERS_COMMANDS_H_
diff --git a/test/components/connection_handler/CMakeLists.txt b/test/components/connection_handler/CMakeLists.txt
deleted file mode 100644
index 9e0a8ba97..000000000
--- a/test/components/connection_handler/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ./include
- ${CMAKE_SOURCE_DIR}/src/components/connection_handler/include
- ${CMAKE_SOURCE_DIR}/src/components/protocol_handler/include
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ../../../src/components/utils/include
- ../../../src/components/config_profile/include
- ../security_manager/include
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- ProtocolHandler
- connectionHandler
- Utils
- ConfigProfile
- ProtocolLibrary
-)
-
-set (SOURCES
- ./src/connection_handler_impl_test.cc
- ./src/connection_test.cc
- ./src/heart_beat_monitor_test.cc
-)
-
-create_test("test_ConnectionHandler" "${SOURCES}" "${LIBRARIES}")
-
-add_library("test_ConnectionHandlerTest" ${SOURCES})
diff --git a/test/components/connection_handler/include/connection_handler/connection_handler_impl_test.h b/test/components/connection_handler/include/connection_handler/connection_handler_impl_test.h
deleted file mode 100644
index 15574d3b3..000000000
--- a/test/components/connection_handler/include/connection_handler/connection_handler_impl_test.h
+++ /dev/null
@@ -1,659 +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.
- */
-
-#ifndef CONNECTION_HANDLER_IMPL_TEST_H
-#define CONNECTION_HANDLER_IMPL_TEST_H
-
-#include <gtest/gtest.h>
-#include <fstream>
-#include <cstdint>
-#include "connection_handler/connection_handler_impl.h"
-#include "protocol/common.h"
-#include "config_profile/profile.h"
-// TODO(EZamakhov): move security test
-#include "security_manager/security_manager_mock.h"
-#include "security_manager/ssl_context_mock.h"
-
-namespace test {
-namespace components {
-namespace connection_handle_test {
-
-using namespace ::connection_handler;
-using ::protocol_handler::ServiceType;
-using namespace ::protocol_handler; // For service types and PROTECTION_ON/OFF
-
-class ConnectionHandlerTest: public ::testing::Test {
- protected:
- void SetUp() OVERRIDE {
- connection_handler_ = ConnectionHandlerImpl::instance();
- uid = 1u;
- connection_key = connection_handler_->KeyFromPair(0, 0u);
- }
- void TearDown() OVERRIDE {
- ConnectionHandlerImpl::destroy();
- }
- //Additional SetUp
- void AddTestDeviceConnection() {
- const transport_manager::DeviceHandle device_handle = 0;
- const transport_manager::DeviceInfo device_info(
- device_handle,
- std::string("test_address"),
- std::string("test_name"),
- std::string("BTMAC"));
- //Add Device and connection
- connection_handler_->addDeviceConnection(device_info, uid);
- connection_key = connection_handler_->KeyFromPair(uid, 0u);
- //Remove all specifis services
- SetSpecificServices("", "");
- }
- void AddTestSession() {
- start_session_id =
- connection_handler_->OnSessionStartedCallback(uid, 0,
- kRpc,
- PROTECTION_OFF, &out_hash_id);
- EXPECT_NE(0u, start_session_id);
- EXPECT_EQ(SessionHash(uid, start_session_id), out_hash_id);
- connection_key = connection_handler_->KeyFromPair(uid,
- start_session_id);
- CheckSessionExists(uid, start_session_id);
- }
- uint32_t SessionHash(const uint32_t connection,
- const uint32_t session) {
- return connection_handler_->KeyFromPair(connection, session);
- }
-
- //Additional SetUp
- void SetSpecificServices(const std::string& protect,
- const std::string& not_protect) {
- const char* config_file = "config.ini";
- std::ofstream file_config(config_file);
- ASSERT_TRUE(file_config.is_open());
- const std::string non("NON");
- file_config
- << "[Security Manager]" << std::endl
- << "; Force protected services (could be id's from 0x01 to 0xFF)"
- << std::endl
- << "ForceProtectedService = " << (protect.empty() ? non : protect) << std::endl
- << "; Force unprotected services" << std::endl
- << "ForceUnprotectedService = " << (not_protect.empty() ? non : not_protect)
- << std::endl;
- file_config.close();
- profile::Profile::instance()->config_file_name(config_file);
- }
- // Check Service Wrapper
- // If session_id is NULL - check that there is no sessions in connection
- void CheckSessionExists(const int connectionId, const int session_id) {
- //check all tree to find Session and check own protected value
- const ConnectionList& connection_list = connection_handler_->getConnectionList();
- ASSERT_FALSE(connection_list.empty());
- ConnectionList::const_iterator conn_it = connection_list.find(connectionId);
- ASSERT_NE(conn_it, connection_list.end());
- const Connection& connection = *connection_list.begin()->second;
-
- const SessionMap& session_map = connection.session_map();
- SessionMap::const_iterator sess_it = session_map.find(session_id);
- if(session_id == 0) {
- ASSERT_TRUE(session_map.empty());
- } else {
- ASSERT_FALSE(session_map.empty());
- ASSERT_NE(sess_it, session_map.end());
- const Session& session = sess_it->second;
- const ServiceList& service_list = session.service_list;
- ASSERT_FALSE(service_list.empty());
- // Check RPC and bulk services in session
- ASSERT_NE(service_list.end(),
- std::find(service_list.begin(), service_list.end(), kRpc));
- ASSERT_NE(service_list.end(),
- std::find(service_list.begin(), service_list.end(), kBulk));
- }
- }
-
- //Check Service Wrapper
- void CheckServiceExists(const int connectionId, const int session_id,
- const ::protocol_handler::ServiceType serviceId,
- const bool exists) {
- //check all tree to find Service and check own protected value
- const ConnectionList& connection_list = connection_handler_->getConnectionList();
- ASSERT_FALSE(connection_list.empty());
- ConnectionList::const_iterator conn_it = connection_list.find(connectionId);
- ASSERT_NE(conn_it, connection_list.end());
- const Connection& connection = *connection_list.begin()->second;
-
- const SessionMap& session_map = connection.session_map();
- ASSERT_FALSE(session_map.empty());
- SessionMap::const_iterator sess_it = session_map.find(session_id);
- ASSERT_NE(sess_it, session_map.end());
- const Session& session = sess_it->second;
- const ServiceList& service_list = session.service_list;
- ASSERT_FALSE(service_list.empty());
- ServiceList::const_iterator serv_it =
- std::find(service_list.begin(), service_list.end(), serviceId);
- if(exists) {
- ASSERT_NE(serv_it, service_list.end());
- } else {
- ASSERT_EQ(serv_it, service_list.end());
- }
- }
- //Check Service Wrapper
- void CheckService(const int connectionId, const int session_id,
- const ::protocol_handler::ServiceType serviceId,
- const ::security_manager::SSLContext* ssl_context,
- const bool is_protected) {
- //check all tree to find Service and check own protected value
- const ConnectionList& connection_list = connection_handler_->getConnectionList();
- ASSERT_FALSE(connection_list.empty());
- ConnectionList::const_iterator conn_it = connection_list.find(connectionId);
- ASSERT_NE(conn_it, connection_list.end());
- const Connection& connection = *connection_list.begin()->second;
-
- const SessionMap& session_map = connection.session_map();
- ASSERT_FALSE(session_map.empty());
- SessionMap::const_iterator sess_it = session_map.find(session_id);
- ASSERT_NE(sess_it, session_map.end());
- const Session& session = sess_it->second;
-
- ASSERT_EQ(session.ssl_context, ssl_context);
-
- const ServiceList& service_list = session.service_list;
- ASSERT_FALSE(service_list.empty());
- ServiceList::const_iterator serv_it =
- std::find(service_list.begin(), service_list.end(), serviceId);
- ASSERT_NE(serv_it, service_list.end());
-
- const Service& service = *serv_it;
- EXPECT_EQ(PROTECTION_OFF, service.is_protected_);
- //
- if(is_protected) {
- // Emulate success protection - check enable service flag
- const uint32_t connection_key =
- connection_handler_->KeyFromPair(connectionId, session_id);
- connection_handler_->SetProtectionFlag(connection_key, serviceId);
- }
- }
-
- ConnectionHandlerImpl* connection_handler_;
- transport_manager::ConnectionUID uid;
- uint32_t connection_key;
- uint32_t start_session_id;
- uint32_t out_hash_id;
-};
-
-TEST_F(ConnectionHandlerTest, StartSession_NoConnection) {
- //null sessionId for start new session
- const uint8_t sessionID = 0;
- //start new session with RPC service
- const uint32_t result_fail =
- connection_handler_->OnSessionStartedCallback(uid, sessionID,
- kRpc,
- PROTECTION_ON, &out_hash_id);
- //Unknown connection error is '0'
- EXPECT_EQ(0u, result_fail);
- EXPECT_EQ(protocol_handler::HASH_ID_WRONG, out_hash_id);
- ASSERT_TRUE(connection_handler_->getConnectionList().empty());
-}
-TEST_F(ConnectionHandlerTest, StartSession) {
- //Add virtual device and connection
- AddTestDeviceConnection();
- //start new session with RPC service
- AddTestSession();
-}
-
-TEST_F(ConnectionHandlerTest, StartService_withServices) {
- //Add virtual device and connection
- AddTestDeviceConnection();
- AddTestSession();
-
- //start Audio service
- const uint32_t start_audio =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_OFF, &out_hash_id);
- EXPECT_EQ(start_session_id, start_audio);
- CheckServiceExists(uid, start_session_id, kAudio, true);
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
-
- //start Audio service
- const uint32_t start_video =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kMobileNav,
- PROTECTION_OFF, &out_hash_id);
- EXPECT_EQ(start_session_id, start_video);
- CheckServiceExists(uid, start_session_id, kMobileNav, true);
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
-}
-
-TEST_F(ConnectionHandlerTest, ServiceStop_UnExistSession) {
- AddTestDeviceConnection();
-
- const uint32_t end_session_result =
- connection_handler_->OnSessionEndedCallback(uid, 0u, 0u,
- kAudio);
- EXPECT_EQ(0u, end_session_result);
- CheckSessionExists(uid, 0);
-}
-
-TEST_F(ConnectionHandlerTest, ServiceStop_UnExistService) {
- AddTestDeviceConnection();
- AddTestSession();
- const uint32_t end_session_result =
- connection_handler_->OnSessionEndedCallback(uid, start_session_id, 0u,
- kAudio);
- EXPECT_EQ(0u, end_session_result);
- CheckServiceExists(uid, start_session_id, kAudio, false);
-}
-
-TEST_F(ConnectionHandlerTest, ServiceStop) {
- AddTestDeviceConnection();
- AddTestSession();
- // Check ignoring hash_id on stop non-rpc service
- for (uint32_t some_hash_id = 0; some_hash_id < 0xFF; ++some_hash_id) {
- //start audio service
- const uint32_t start_audio =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_OFF, &out_hash_id);
- EXPECT_EQ(start_session_id, start_audio);
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
-
- const uint32_t end_session_result =
- connection_handler_->OnSessionEndedCallback(uid, start_session_id, some_hash_id,
- kAudio);
- EXPECT_EQ(connection_key, end_session_result);
- CheckServiceExists(uid, start_session_id, kAudio, false);
- }
-}
-
-TEST_F(ConnectionHandlerTest, SessionStop_CheckHash) {
- AddTestDeviceConnection();
- for (uint32_t session = 0; session < 0xFF; ++session) {
- AddTestSession();
-
- const uint32_t hash = connection_key;
- const uint32_t wrong_hash = hash + 1;
-
- const uint32_t end_audio_wrong_hash =
- connection_handler_->OnSessionEndedCallback(uid, start_session_id, wrong_hash,
- kRpc);
- EXPECT_EQ(0u, end_audio_wrong_hash);
- CheckSessionExists(uid, start_session_id);
-
- const uint32_t end_audio =
- connection_handler_->OnSessionEndedCallback(uid, start_session_id, hash,
- kRpc);
- EXPECT_EQ(connection_key, end_audio);
- CheckSessionExists(uid, 0);
- }
-}
-
-TEST_F(ConnectionHandlerTest, SessionStop_CheckSpecificHash) {
- AddTestDeviceConnection();
- for (uint32_t session = 0; session < 0xFF; ++session) {
- AddTestSession();
-
- const uint32_t wrong_hash = protocol_handler::HASH_ID_WRONG;
- const uint32_t hash = protocol_handler::HASH_ID_NOT_SUPPORTED;
-
- const uint32_t end_audio_wrong_hash =
- connection_handler_->OnSessionEndedCallback(uid, start_session_id, wrong_hash,
- kRpc);
- EXPECT_EQ(0u, end_audio_wrong_hash);
- CheckSessionExists(uid, start_session_id);
-
- const uint32_t end_audio =
- connection_handler_->OnSessionEndedCallback(uid, start_session_id, hash,
- kRpc);
- EXPECT_EQ(connection_key, end_audio);
- CheckSessionExists(uid, 0);
- }
-}
-
-TEST_F(ConnectionHandlerTest, SessionStarted_StartSession_SecureSpecific_Unprotect) {
- //Add virtual device and connection
- AddTestDeviceConnection();
-
- //Forbid start kRPC without encryption
- SetSpecificServices("0x07", "");
- //start new session with RPC service
- const uint32_t session_id_fail =
- connection_handler_->OnSessionStartedCallback(uid, 0,
- kRpc,
- PROTECTION_OFF, &out_hash_id);
- EXPECT_EQ(0u, session_id_fail);
- EXPECT_EQ(protocol_handler::HASH_ID_WRONG, out_hash_id);
-
- //Allow start kRPC without encryption
- SetSpecificServices("0x00, Non", "");
- //start new session with RPC service
- const uint32_t session_id =
- connection_handler_->OnSessionStartedCallback(uid, 0,
- kRpc,
- PROTECTION_OFF, &out_hash_id);
- EXPECT_NE(0u, session_id);
- CheckService(uid, session_id, kRpc, NULL, PROTECTION_OFF);
- EXPECT_EQ(SessionHash(uid, session_id), out_hash_id);
-}
-TEST_F(ConnectionHandlerTest, SessionStarted_StartSession_SecureSpecific_Protect) {
- //Add virtual device and connection
- AddTestDeviceConnection();
-
- //Forbid start kRPC with encryption
- SetSpecificServices("", "0x06, 0x07, 0x08, Non");
- //start new session with RPC service
- const uint32_t session_id_fail =
- connection_handler_->OnSessionStartedCallback(uid, 0,
- kRpc,
- PROTECTION_ON, NULL);
- EXPECT_EQ(0u, session_id_fail);
-
- //Allow start kRPC with encryption
- SetSpecificServices("", "0x00, 0x05, Non");
- //start new session with RPC service
- const uint32_t session_id =
- connection_handler_->OnSessionStartedCallback(uid, 0,
- kRpc,
- PROTECTION_ON, &out_hash_id);
- EXPECT_NE(0u, session_id);
- EXPECT_EQ(SessionHash(uid, session_id), out_hash_id);
-
- //Protection steal FALSE because of APPlink Protocol implementation
- CheckService(uid, session_id, kRpc, NULL, PROTECTION_OFF);
-}
-TEST_F(ConnectionHandlerTest, SessionStarted_StartService_SecureSpecific_Unprotect) {
- AddTestDeviceConnection();
- AddTestSession();
-
- //Audio is 0x0A
- ASSERT_EQ(0x0A, kAudio);
-
- //Forbid start kAudio without encryption
- SetSpecificServices("0x06, 0x0A, 0x08, Non", "");
- //start new session with Audio service
- const uint32_t session_id2 =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_OFF, NULL);
- EXPECT_EQ(0u, session_id2);
-
- //Allow start kAudio without encryption
- SetSpecificServices("0x06, 0x0B, 0x08, Non", "");
- const uint32_t session_id3 =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_OFF, &out_hash_id);
- // returned orriginal session id
- EXPECT_EQ(start_session_id, session_id3);
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
- CheckService(uid, session_id3, kRpc, NULL, PROTECTION_OFF);
-}
-TEST_F(ConnectionHandlerTest, SessionStarted_StartService_SecureSpecific_Protect) {
- AddTestDeviceConnection();
- AddTestSession();
-
- //Audio is 0x0A
- ASSERT_EQ(0x0A, kAudio);
- //Forbid start kAudio with encryption
- SetSpecificServices("", "0x06, 0x0A, 0x08, Non");
- //start new session with Audio service
- const uint32_t session_id_reject =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_ON, NULL);
- EXPECT_EQ(0u, session_id_reject);
-
- //Allow start kAudio without encryption
- SetSpecificServices("", "Non");
- const uint32_t session_id3 =
- connection_handler_->OnSessionStartedCallback( uid, start_session_id,
- kAudio,
- PROTECTION_ON, &out_hash_id);
- // returned orriginal session id
- EXPECT_EQ(start_session_id, session_id3);
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
- CheckService(uid, session_id3, kAudio, NULL, PROTECTION_ON);
-}
-TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) {
- AddTestDeviceConnection();
- AddTestSession();
-
- // Start RPC protection
- const uint32_t session_id_new =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kRpc,
- PROTECTION_ON, &out_hash_id);
- EXPECT_EQ(start_session_id, session_id_new);
- // Post protection nedd no hash
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
- CheckService(uid, start_session_id, kRpc, NULL, PROTECTION_ON);
-
- // Start Audio session without protection
- const uint32_t session_id2 =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_OFF, &out_hash_id);
- EXPECT_EQ(start_session_id, session_id2);
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
- CheckService(uid, start_session_id, kAudio, NULL, PROTECTION_OFF);
-
- // Start Audio protection
- const uint32_t session_id3 =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_ON, &out_hash_id);
- EXPECT_EQ(start_session_id, session_id3);
- EXPECT_EQ(protocol_handler::HASH_ID_NOT_SUPPORTED, out_hash_id);
- CheckService(uid, start_session_id, kAudio, NULL, PROTECTION_ON);
-}
-TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtectBulk) {
- AddTestDeviceConnection();
- AddTestSession();
-
- const uint32_t session_id_new =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kBulk,
- PROTECTION_ON, NULL);
- EXPECT_EQ(start_session_id, session_id_new);
- CheckService(uid, start_session_id, kRpc, NULL, PROTECTION_ON);
-}
-TEST_F(ConnectionHandlerTest, SetSSLContext_Null) {
- //No SSLContext on start up
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
- EXPECT_EQ(::security_manager::SecurityManager::ERROR_INTERNAL,
- connection_handler_->SetSSLContext(connection_key, NULL));
- //No SSLContext after error
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-
- AddTestDeviceConnection();
- EXPECT_EQ(::security_manager::SecurityManager::ERROR_INTERNAL,
- connection_handler_->SetSSLContext(connection_key, NULL));
- //No SSLContext after error
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-
- AddTestSession();
- EXPECT_EQ(::security_manager::SecurityManager::ERROR_SUCCESS,
- connection_handler_->SetSSLContext(connection_key, NULL));
- //NULL SSLContext after success
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-}
-TEST_F(ConnectionHandlerTest, SetSSLContext) {
- //No SSLContext on start up
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context;
- //Error on no connection
- EXPECT_EQ(connection_handler_->SetSSLContext(connection_key, &mock_ssl_context),
- ::security_manager::SecurityManager::ERROR_INTERNAL);
- //No SSLContext after error
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-
- AddTestDeviceConnection();
- //Error on no session
- EXPECT_EQ(connection_handler_->SetSSLContext(connection_key, &mock_ssl_context),
- ::security_manager::SecurityManager::ERROR_INTERNAL);
- //No SSLContext after error
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
- AddTestSession();
- //success
- EXPECT_EQ(connection_handler_->SetSSLContext(connection_key, &mock_ssl_context),
- ::security_manager::SecurityManager::ERROR_SUCCESS);
- //SSLContext set on Success
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- &mock_ssl_context);
- //Null SSLContext for unprotected services
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kRpc),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kBulk),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kAudio),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kMobileNav),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-}
-TEST_F(ConnectionHandlerTest, GetSSLContext_ByProtectedService) {
- //No SSLContext on start up
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context;
- AddTestDeviceConnection();
- AddTestSession();
- EXPECT_EQ(connection_handler_->SetSSLContext(connection_key, &mock_ssl_context),
- ::security_manager::SecurityManager::ERROR_SUCCESS);
- //kControl service mean - return for all connection
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- &mock_ssl_context);
-
- //kAudio is not exists yet
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kAudio),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
- //Open kAudio service
- const uint32_t session_id =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kAudio,
- PROTECTION_ON, NULL);
- EXPECT_EQ(session_id, start_session_id);
- CheckService(uid, session_id, kAudio, &mock_ssl_context, PROTECTION_ON);
-
- //kAudio is not exists yet
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kAudio),
- &mock_ssl_context);
-}
-TEST_F(ConnectionHandlerTest, GetSSLContext_ByDealyProtecteRPC) {
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context;
- AddTestDeviceConnection();
- AddTestSession();
- EXPECT_EQ(connection_handler_->SetSSLContext(connection_key, &mock_ssl_context),
- ::security_manager::SecurityManager::ERROR_SUCCESS);
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- &mock_ssl_context);
-
- //kRpc is not protected
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kRpc),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-
- //Protect kRpc (Bulk will be protect also)
- const uint32_t session_id =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kRpc,
- PROTECTION_ON, NULL);
- EXPECT_EQ(start_session_id, session_id);
- CheckService(uid, session_id, kRpc, &mock_ssl_context, PROTECTION_ON);
-
- //kRpc is protecte
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kRpc),
- &mock_ssl_context);
- //kBulk is protecte
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kBulk),
- &mock_ssl_context);
-}
-TEST_F(ConnectionHandlerTest, GetSSLContext_ByDealyProtecteBulk) {
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context;
- AddTestDeviceConnection();
- AddTestSession();
- EXPECT_EQ(connection_handler_->SetSSLContext(connection_key, &mock_ssl_context),
- ::security_manager::SecurityManager::ERROR_SUCCESS);
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kControl),
- &mock_ssl_context);
-
- //kRpc is not protected
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kRpc),
- reinterpret_cast<security_manager::SSLContext *>(NULL));
-
- //Protect Bulk (kRpc will be protect also)
- const uint32_t session_id =
- connection_handler_->OnSessionStartedCallback(uid, start_session_id,
- kBulk,
- PROTECTION_ON, NULL);
- EXPECT_EQ(start_session_id, session_id);
- CheckService(uid, session_id, kRpc, &mock_ssl_context, PROTECTION_ON);
-
- //kRpc is protected
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kRpc),
- &mock_ssl_context);
- //kBulk is protected
- EXPECT_EQ(connection_handler_->GetSSLContext(
- connection_key, kBulk),
- &mock_ssl_context);
-}
-} // connection_handle_test
-} // namespace components
-} // namespace test
-#endif // CONNECTION_HANDLER_IMPL_TEST_H
diff --git a/test/components/connection_handler/include/connection_handler/connection_test.h b/test/components/connection_handler/include/connection_handler/connection_test.h
deleted file mode 100644
index e21ce2112..000000000
--- a/test/components/connection_handler/include/connection_handler/connection_test.h
+++ /dev/null
@@ -1,272 +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.
- */
-
-#ifndef CONNECTION_TEST_H
-#define CONNECTION_TEST_H
-
-#include <gtest/gtest.h>
-#include <algorithm>
-#include "protocol/common.h"
-#include "connection_handler/connection.h"
-#include "connection_handler/connection_handler_impl.h"
-#include "protocol/service_type.h"
-#include "utils/shared_ptr.h"
-
-#define EXPECT_RETURN_TRUE true
-#define EXPECT_RETURN_FALSE false
-#define EXPECT_SERVICE_EXISTS true
-#define EXPECT_SERVICE_NOT_EXISTS false
-
-namespace test {
-namespace components {
-namespace connection_handle {
- using namespace ::connection_handler;
- using namespace ::protocol_handler;
-
-class ConnectionTest: public ::testing::Test {
- protected:
- void SetUp() OVERRIDE {
- connection_handler_ = ConnectionHandlerImpl::instance();
- const ConnectionHandle connectionHandle = 0;
- const DeviceHandle device_handle = 0;
- connection_.reset(new Connection(connectionHandle, device_handle,
- connection_handler_, 10000));
- }
-
- void TearDown() OVERRIDE {
- connection_.reset();
- ConnectionHandlerImpl::destroy();
- }
- void StartSession() {
- using namespace protocol_handler;
- session_id = connection_->AddNewSession();
- EXPECT_NE(session_id, 0u);
- const SessionMap sessionMap = connection_->session_map();
- EXPECT_FALSE(sessionMap.empty());
- const ServiceList serviceList = sessionMap.begin()->second.service_list;
- EXPECT_FALSE(serviceList.empty());
- const ServiceList::const_iterator it =
- std::find(serviceList.begin(), serviceList.end(), protocol_handler::kRpc);
- EXPECT_NE(it, serviceList.end());
- }
- void AddNewService(const protocol_handler::ServiceType service_type,
- const bool protection,
- const bool expect_add_new_service_call_result,
- const bool expect_exist_service) {
- const bool result = connection_->
- AddNewService(session_id, service_type, protection);
- EXPECT_EQ(result, expect_add_new_service_call_result);
-
- if (protection) {
- connection_->SetProtectionFlag(session_id, service_type);
- }
-
- const SessionMap session_map = connection_->session_map();
- EXPECT_FALSE(session_map.empty());
- const ServiceList newServiceList = session_map.begin()->second.service_list;
- EXPECT_FALSE(newServiceList.empty());
- const ServiceList::const_iterator it =
- std::find(newServiceList.begin(), newServiceList.end(), service_type);
- const bool found_result = it != newServiceList.end();
- EXPECT_EQ(expect_exist_service, found_result);
- if (found_result) {
- const Service& service = *it;
- EXPECT_EQ(service.is_protected_, protection);
- }
- }
-
- void RemoveService(const protocol_handler::ServiceType service_type,
- const bool expect_remove_service_result,
- const bool expect_exist_service) {
- const bool result = connection_->
- RemoveService(session_id, service_type);
- EXPECT_EQ(result, expect_remove_service_result);
-
- const SessionMap newSessionMap = connection_->session_map();
- EXPECT_FALSE(newSessionMap.empty());
- const ServiceList newServiceList = newSessionMap.begin()->second.service_list;
- EXPECT_FALSE(newServiceList.empty());
- const ServiceList::const_iterator it =
- std::find(newServiceList.begin(), newServiceList.end(), service_type);
- const bool found_result = it != newServiceList.end();
- EXPECT_EQ(expect_exist_service, found_result);
- }
-
- ::utils::SharedPtr<Connection> connection_;
- ConnectionHandlerImpl* connection_handler_;
- uint32_t session_id;
-};
-
-// Try to add service without session
-TEST_F(ConnectionTest, Session_AddNewServiceWithoySession) {
- EXPECT_EQ(connection_->
- AddNewService(session_id, protocol_handler::kAudio, true),
- EXPECT_RETURN_FALSE);
- EXPECT_EQ(connection_->
- AddNewService(session_id, protocol_handler::kAudio, false),
- EXPECT_RETURN_FALSE);
- EXPECT_EQ(connection_->
- AddNewService(session_id, protocol_handler::kMobileNav, true),
- EXPECT_RETURN_FALSE);
- EXPECT_EQ(connection_->
- AddNewService(session_id, protocol_handler::kMobileNav, false),
- EXPECT_RETURN_FALSE);
-}
-// Try to remove service without session
-TEST_F(ConnectionTest, Session_RemoveServiceWithoutSession) {
- EXPECT_EQ(connection_->
- RemoveService(session_id, protocol_handler::kAudio),
- EXPECT_RETURN_FALSE);
- EXPECT_EQ(connection_->
- RemoveService(session_id, protocol_handler::kMobileNav),
- EXPECT_RETURN_FALSE);
-}
-// Try to remove RPC
-TEST_F(ConnectionTest, Session_RemoveRPCBulk) {
- StartSession();
- EXPECT_EQ(connection_->
- RemoveService(session_id, protocol_handler::kRpc),
- EXPECT_RETURN_FALSE);
- EXPECT_EQ(connection_->
- RemoveService(session_id, protocol_handler::kBulk),
- EXPECT_RETURN_FALSE);
-}
-// Control Service couldnot be started anyway
-TEST_F(ConnectionTest, Session_AddControlService) {
- StartSession();
-
- AddNewService(protocol_handler::kControl, PROTECTION_OFF,
- EXPECT_RETURN_FALSE,
- EXPECT_SERVICE_NOT_EXISTS);
- AddNewService(protocol_handler::kControl, PROTECTION_ON,
- EXPECT_RETURN_FALSE,
- EXPECT_SERVICE_NOT_EXISTS);
-}
-
-// Invalid Services couldnot be started anyway
-TEST_F(ConnectionTest, Session_AddInvalidService) {
- StartSession();
-
- AddNewService(protocol_handler::kInvalidServiceType, PROTECTION_OFF,
- EXPECT_RETURN_FALSE,
- EXPECT_SERVICE_NOT_EXISTS);
- AddNewService(protocol_handler::kInvalidServiceType, PROTECTION_ON,
- EXPECT_RETURN_FALSE,
- EXPECT_SERVICE_NOT_EXISTS);
-}
-
-// RPC and Bulk Services could be only delay protected
-TEST_F(ConnectionTest, Session_AddRPCBulkServices) {
- StartSession();
-
- AddNewService(protocol_handler::kRpc, PROTECTION_OFF,
- EXPECT_RETURN_FALSE,
- EXPECT_SERVICE_EXISTS);
-
- //Bulk shall not be added and shall be PROTECTION_OFF
- AddNewService(protocol_handler::kBulk, PROTECTION_OFF,
- EXPECT_RETURN_FALSE,
- EXPECT_SERVICE_EXISTS);
-
- AddNewService(protocol_handler::kRpc, PROTECTION_ON,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
-
- //Bulk shall not be added and shall be PROTECTION_ON
- AddNewService(protocol_handler::kBulk, PROTECTION_ON,
- EXPECT_RETURN_FALSE,
- EXPECT_SERVICE_EXISTS);
-}
-TEST_F(ConnectionTest, Session_AddAllOtherService_Unprotected) {
- StartSession();
-
- AddNewService(protocol_handler::kAudio, PROTECTION_OFF,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
- AddNewService(protocol_handler::kMobileNav, PROTECTION_OFF,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
-}
-
-TEST_F(ConnectionTest, Session_AddAllOtherService_Protected) {
- StartSession();
-
- AddNewService(protocol_handler::kAudio, PROTECTION_ON,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
- AddNewService(protocol_handler::kMobileNav, PROTECTION_ON,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
-}
-
-TEST_F(ConnectionTest, Session_AddAllOtherService_DelayProtected1) {
- StartSession();
-
- AddNewService(protocol_handler::kAudio, PROTECTION_OFF,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
- AddNewService(protocol_handler::kMobileNav, PROTECTION_OFF,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
-
-
- AddNewService(protocol_handler::kAudio, PROTECTION_ON,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
- AddNewService(protocol_handler::kMobileNav, PROTECTION_ON,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
-}
-//Use other order
-TEST_F(ConnectionTest, Session_AddAllOtherService_DelayProtected2) {
- StartSession();
-
- AddNewService(protocol_handler::kAudio, PROTECTION_OFF,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
- AddNewService(protocol_handler::kAudio, PROTECTION_ON,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
-
- AddNewService(protocol_handler::kMobileNav, PROTECTION_OFF,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
- AddNewService(protocol_handler::kMobileNav, PROTECTION_ON,
- EXPECT_RETURN_TRUE,
- EXPECT_SERVICE_EXISTS);
-}
-
-} // connection_handle
-} // namespace components
-} // namespace test
-
-#endif // CONNECTION_TEST_H
diff --git a/test/components/connection_handler/include/connection_handler/heart_beat_monitor_test.h b/test/components/connection_handler/include/connection_handler/heart_beat_monitor_test.h
deleted file mode 100644
index 01a89618a..000000000
--- a/test/components/connection_handler/include/connection_handler/heart_beat_monitor_test.h
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (c) 2013-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_CONNECTION_HANDLER_INCLUDE_CONNECTION_HANDLER_HEART_BEAT_MONITOR_TEST_H_
-#define TEST_COMPONENTS_CONNECTION_HANDLER_INCLUDE_CONNECTION_HANDLER_HEART_BEAT_MONITOR_TEST_H_
-
-#include <string>
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-
-#include "connection_handler/heartbeat_monitor.h"
-#include "connection_handler/connection.h"
-#include "connection_handler/connection_handler.h"
-
-namespace test {
-namespace components {
-namespace connection_handler_test {
-using ::testing::_;
-
-class ConnectionHandlerMock : public connection_handler::ConnectionHandler {
- public:
- MOCK_METHOD1(set_connection_handler_observer,
- void(connection_handler::ConnectionHandlerObserver*));
- MOCK_METHOD1(set_transport_manager,
- void(transport_manager::TransportManager*));
- MOCK_METHOD0(StartTransportManager,
- void());
- MOCK_METHOD1(ConnectToDevice,
- void(connection_handler::DeviceHandle device_handle));
- MOCK_METHOD0(ConnectToAllDevices,
- void());
- MOCK_METHOD1(CloseRevokedConnection, void(uint32_t connection_key));
- MOCK_METHOD1(CloseConnection,
- void(connection_handler::ConnectionHandle connection_handle));
- MOCK_METHOD1(GetConnectionSessionsCount, uint32_t(uint32_t connection_key));
- MOCK_METHOD2(GetDeviceID,
- bool(const std::string& mac_address,
- connection_handler::DeviceHandle* device_handle));
- MOCK_METHOD2(CloseSession,
- void(uint32_t key, connection_handler::CloseSessionReason));
- MOCK_METHOD3(CloseSession,
- void(connection_handler::ConnectionHandle connection_handle,
- uint8_t session_id,
- connection_handler::CloseSessionReason));
- MOCK_METHOD1(StartSessionHeartBeat,
- void(uint32_t key));
- MOCK_METHOD2(SendHeartBeat,
- void(connection_handler::ConnectionHandle connection_handle,
- uint8_t session_id));
- MOCK_METHOD2(SetHeartBeatTimeout, void(uint32_t connection_key,
- int32_t timeout));
- MOCK_METHOD2(BindProtocolVersionWithSession,
- void(uint32_t connection_key,
- uint8_t protocol_version));
-};
-
-class HeartBeatMonitorTest : public testing::Test {
- protected:
- testing::NiceMock<ConnectionHandlerMock> connection_handler_mock;
- connection_handler::Connection* conn;
- static const int32_t kTimeout = 2;
- static const connection_handler::ConnectionHandle kConnectionHandle = 0xABCDEF;
-
- virtual void SetUp() {
- conn = new connection_handler::Connection(kConnectionHandle, 0,
- &connection_handler_mock,
- kTimeout);
- }
-
- virtual void TearDown() {
- delete conn;
- }
-};
-
-ACTION_P2(RemoveSession, conn, session_id){
- conn->RemoveSession(session_id);
-}
-
-TEST_F(HeartBeatMonitorTest, TimerNotStarted) {
- // Whithout StartHeartBeat nothing to be call
- EXPECT_CALL(connection_handler_mock, CloseSession(_, _)).Times(0);
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(0);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, _)).Times(0);
-
- conn->AddNewSession();
- sleep(kTimeout + 1);
-}
-
-TEST_F(HeartBeatMonitorTest, TimerNotElapsed) {
- EXPECT_CALL(connection_handler_mock, CloseSession(_, _)).Times(0);
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(0);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, _)).Times(0);
-
- const uint32_t session = conn->AddNewSession();
- conn->StartHeartBeat(session);
- sleep(kTimeout - 1);
-}
-
-TEST_F(HeartBeatMonitorTest, TimerElapsed) {
- const uint32_t session = conn->AddNewSession();
-
- EXPECT_CALL(connection_handler_mock, CloseSession(
- _,session, connection_handler::kCommon)).Times(1)
- .WillOnce(RemoveSession(conn, session));
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(1);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, session)).Times(1);
-
- conn->StartHeartBeat(session);
- sleep(2 * kTimeout + 1);
-}
-
-TEST_F(HeartBeatMonitorTest, KeptAlive) {
- EXPECT_CALL(connection_handler_mock, CloseSession(
- _, _, connection_handler::kCommon)).Times(0);
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(0);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, _)).Times(0);
-
- const uint32_t session = conn->AddNewSession();
- conn->StartHeartBeat(session);
- sleep(kTimeout - 1);
- conn->KeepAlive(session);
- sleep(kTimeout - 1);
- conn->KeepAlive(session);
- sleep(kTimeout - 1);
- conn->KeepAlive(session);
- sleep(kTimeout - 1);
-}
-
-TEST_F(HeartBeatMonitorTest, NotKeptAlive) {
- const uint32_t session = conn->AddNewSession();
-
- EXPECT_CALL(connection_handler_mock, CloseSession(
- _, session, connection_handler::kCommon)).Times(1)
- .WillOnce(RemoveSession(conn, session));
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(1);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, session)).Times(1);
-
- conn->StartHeartBeat(session);
- sleep(kTimeout - 1);
- conn->KeepAlive(session);
- sleep(kTimeout - 1);
- conn->KeepAlive(session);
- sleep(kTimeout - 1);
- conn->KeepAlive(session);
- sleep(2 * kTimeout + 1);
-}
-
-TEST_F(HeartBeatMonitorTest, TwoSessionsElapsed) {
- const uint32_t kSession1 = conn->AddNewSession();
- const uint32_t kSession2 = conn->AddNewSession();
-
- EXPECT_CALL(connection_handler_mock, CloseSession(
- _, kSession1, connection_handler::kCommon)).Times(1)
- .WillOnce(RemoveSession(conn, kSession1));
- EXPECT_CALL(connection_handler_mock, CloseSession(
- _, kSession2, connection_handler::kCommon)).Times(1)
- .WillOnce(RemoveSession(conn, kSession2));
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(1);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, kSession1)).Times(1);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, kSession2)).Times(1);
-
- conn->StartHeartBeat(kSession1);
- conn->StartHeartBeat(kSession2);
- sleep(2 * kTimeout + 1);
-}
-
-TEST_F(HeartBeatMonitorTest, IncreaseHeartBeatTimeout) {
- const uint32_t kSession = conn->AddNewSession();
-
- EXPECT_CALL(connection_handler_mock, CloseSession(
- _, _, connection_handler::kCommon)).Times(0);
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(0);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, _)).Times(0);
-
-
- const int32_t kNewTimeout = kTimeout + 1;
- conn->StartHeartBeat(kSession);
- conn->SetHeartBeatTimeout(kNewTimeout, kSession);
- // new timeout greater by old timeout so mock object shouldn't be invoked
- sleep(kTimeout);
-}
-
-TEST_F(HeartBeatMonitorTest, DecreaseHeartBeatTimeout) {
- const uint32_t kSession = conn->AddNewSession();
-
- EXPECT_CALL(connection_handler_mock, CloseSession(
- _, kSession, connection_handler::kCommon)).Times(1)
- .WillOnce(RemoveSession(conn, kSession));;
- EXPECT_CALL(connection_handler_mock, CloseConnection(_)).Times(1);
- EXPECT_CALL(connection_handler_mock, SendHeartBeat(_, kSession)).Times(1);
-
- const int32_t kNewTimeout = kTimeout - 1;
- conn->StartHeartBeat(kSession);
- conn->SetHeartBeatTimeout(kNewTimeout, kSession);
- // new timeout less by old timeout so mock object should be invoked
- sleep(kTimeout);
-}
-
-}
- // namespace connection_handler_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_CONNECTION_HANDLER_INCLUDE_CONNECTION_HANDLER_HEART_BEAT_MONITOR_TEST_H_
diff --git a/test/components/connection_handler/src/connection_handler_impl_test.cc b/test/components/connection_handler/src/connection_handler_impl_test.cc
deleted file mode 100644
index 6f6017db8..000000000
--- a/test/components/connection_handler/src/connection_handler_impl_test.cc
+++ /dev/null
@@ -1,33 +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 "connection_handler/connection_handler_impl_test.h"
diff --git a/test/components/connection_handler/src/connection_test.cc b/test/components/connection_handler/src/connection_test.cc
deleted file mode 100644
index ca68d322e..000000000
--- a/test/components/connection_handler/src/connection_test.cc
+++ /dev/null
@@ -1,33 +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 "connection_handler/connection_test.h"
diff --git a/test/components/connection_handler/src/heart_beat_monitor_test.cc b/test/components/connection_handler/src/heart_beat_monitor_test.cc
deleted file mode 100644
index a6403871c..000000000
--- a/test/components/connection_handler/src/heart_beat_monitor_test.cc
+++ /dev/null
@@ -1,33 +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.
-*/
-
-#include "connection_handler/heart_beat_monitor_test.h"
diff --git a/test/components/dbus/CMakeLists.txt b/test/components/dbus/CMakeLists.txt
deleted file mode 100644
index c521dee40..000000000
--- a/test/components/dbus/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/
- ${CMAKE_BINARY_DIR}/src/components/
- ${CMAKE_SOURCE_DIR}/src/components/dbus/include/
- ${CMAKE_SOURCE_DIR}/src/components/utils/include/
- ${CMAKE_SOURCE_DIR}/src/components/smart_objects/include/
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- DBus
- formatters
- SmartObjects
- Utils
-)
-
-set (SCHEMA_SOURCES
- ./src/test_schema.cc
-)
-
-set (DBUS_ADAPTER_SOURCES
- ./src/test_dbus_adapter.cc
-)
-
-create_test("test_DBusSchema" "${SCHEMA_SOURCES}" "${LIBRARIES}")
-create_test("test_DBusAdapter" "${DBUS_ADAPTER_SOURCES}" "${LIBRARIES}")
diff --git a/test/components/dbus/log4cxx.properties b/test/components/dbus/log4cxx.properties
deleted file mode 100644
index 6fb2f5a1c..000000000
--- a/test/components/dbus/log4cxx.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-# Log for all SmartDeviceLinkCoreSocketHub messages
-log4j.appender.SmartDeviceLinkCoreSocketHub=org.apache.log4j.net.SocketHubAppender
-log4j.appender.SmartDeviceLinkCoreSocketHub.port=4555
-log4j.appender.SmartDeviceLinkCoreSocketHub.locationInfo=true
-
-# Only ERROR and FATAL messages are logged to console
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.ImmediateFlush=true
-log4j.appender.Console.layout=org.apache.log4j.PatternLayout
-log4j.appender.Console.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %m%n
-log4j.appender.Console.Threshold=ALL
-
-# Log for all SmartDeviceLinkCore messages
-log4j.appender.SmartDeviceLinkCoreLogFile=org.apache.log4j.FileAppender
-log4j.appender.SmartDeviceLinkCoreLogFile.File=SmartDeviceLinkCore.log
-log4j.appender.SmartDeviceLinkCoreLogFile.append=false
-log4j.appender.SmartDeviceLinkCoreLogFile.DatePattern='.' yyyy-MM-dd HH-mm
-log4j.appender.SmartDeviceLinkCoreLogFile.ImmediateFlush=true
-log4j.appender.SmartDeviceLinkCoreLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.SmartDeviceLinkCoreLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for all TransportManager messages
-log4j.appender.TransportManagerLogFile=org.apache.log4j.FileAppender
-log4j.appender.TransportManagerLogFile.File=TransportManager.log
-log4j.appender.TransportManagerLogFile.append=false
-log4j.appender.TransportManagerLogFile.DatePattern='.' yyyy-MM-dd HH-mm
-log4j.appender.TransportManagerLogFile.ImmediateFlush=true
-log4j.appender.TransportManagerLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.TransportManagerLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# All SmartDeviceLinkCore logs
-log4j.rootLogger=ALL, Console, SmartDeviceLinkCoreLogFile, SmartDeviceLinkCoreSocketHub
-
-# TransportManager logs
-log4j.logger.TransportManager=ALL, TransportManagerLogFile
diff --git a/test/components/dbus/src/test_dbus_adapter.cc b/test/components/dbus/src/test_dbus_adapter.cc
deleted file mode 100644
index e603288fd..000000000
--- a/test/components/dbus/src/test_dbus_adapter.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * \file test_dbus_adapter.cc
- * \brief
- *
- * 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.
- */
-
-#include <gtest/gtest.h>
-#include "dbus/dbus_adapter.h"
-
-using ::dbus::DBusAdapter;
-
-namespace test {
-namespace components {
-namespace dbus {
-
-class DBusAdapterTest : public ::testing::Test {
- protected:
-};
-
-TEST_F(DBusAdapterTest, Initialization) {
- const std::string kSdlServiceName = "test.ford.sdl.core";
- const std::string kSdlObjectPath = "/";
- const std::string kHmiServiceName = "test.ford.sdl.hmi";
- const std::string kHmiObjectPath = "/";
- ::dbus::DBusAdapter adapter(kSdlServiceName, kSdlObjectPath,
- kHmiServiceName, kHmiObjectPath);
- EXPECT_TRUE(adapter.Init());
-}
-
-} // namespace dbus
-} // namespace components
-} // namespace test
-
-int main(int argc, char** argv) {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/dbus/src/test_dbus_message_controller.cc b/test/components/dbus/src/test_dbus_message_controller.cc
deleted file mode 100644
index 1007a07bc..000000000
--- a/test/components/dbus/src/test_dbus_message_controller.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * \file test_dbus_adapter.cc
- * \brief
- *
- * 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.
- */
-
-#include <pthread.h>
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-#include "hmi_message_handler/mock_dbus_message_controller.h"
-#include "hmi_message_handler/mock_subscriber.h"
-
-using ::testing::_;
-
-namespace test {
-namespace components {
-namespace hmi_message_handler {
-
-ACTION_P(SignalTest, test) {
- if (test->thread_id != pthread_self()) {
- pthread_mutex_lock(&test->test_mutex);
- pthread_cond_signal(&test->test_cond);
- pthread_mutex_unlock(&test->test_mutex);
- } else {
- test->one_thread = true;
- }
-}
-
-class DBusMessageControllerTest : public ::testing::Test {
- public:
- volatile bool one_thread;
- pthread_t thread_id;
- static pthread_mutex_t test_mutex;
- static pthread_cond_t test_cond;
-
- protected:
- MockDBusMessageController* controller_;
- MockSubscriber* subscriber_;
-
- static void SetUpTestCase() {
-
- }
-
- static void TearDownTestCase() {
-
- }
-
- virtual void SetUp() {
- const std::string kService = "sdl.core.test_api";
- const std::string kPath = "/dbus_test";
- controller_ = new MockDBusMessageController(kService, kPath);
- subscriber_ = new MockSubscriber(kService, kPath);
- ASSERT_TRUE(controller_->Init());
- ASSERT_TRUE(subscriber_->Start());
- }
-
- virtual void TearDown() {
- delete controller_;
- delete subscriber_;
- }
-
- bool waitCond(int seconds) {
- if (one_thread)
- return true;
- timespec elapsed;
- clock_gettime(CLOCK_REALTIME, &elapsed);
- elapsed.tv_sec += seconds;
- return pthread_cond_timedwait(&test_cond, &test_mutex, &elapsed) != ETIMEDOUT;
- }
-};
-
-pthread_mutex_t DBusMessageControllerTest::test_mutex;
-pthread_cond_t DBusMessageControllerTest::test_cond;
-
-TEST_F(DBusMessageControllerTest, Receive) {
- std::string text = "Test message for call method DBus";
- EXPECT_CALL(*controller_, Recv(text)).Times(1).WillOnce(SignalTest(this));
- subscriber_->Send(text);
- EXPECT_TRUE(waitCond(1));
-}
-
-TEST_F(DBusMessageControllerTest, DISABLED_Send) {
- const std::string kText = "Test message for signal DBus";
-// EXPECT_CALL(*subscriber_, Receive(kText)).Times(1);
- controller_->Send(kText);
-}
-
-} // namespace hmi_message_handler
-} // namespace components
-} // namespace test
-
-int main(int argc, char** argv) {
-testing::InitGoogleTest(&argc, argv);
-return RUN_ALL_TESTS();
-}
diff --git a/test/components/dbus/src/test_schema.cc b/test/components/dbus/src/test_schema.cc
deleted file mode 100644
index da5eafa45..000000000
--- a/test/components/dbus/src/test_schema.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * \file test_schema.cc
- * \brief
- *
- * 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.
- */
-
-#include <gtest/gtest.h>
-#include "dbus/schema.h"
-
-using dbus::DBusSchema;
-using dbus::MessageId;
-using dbus::MessageName;
-using dbus::MessageType;
-using dbus::ListArgs;
-using ford_message_descriptions::ParameterDescription;
-
-namespace test {
-namespace components {
-namespace dbus {
-
-class DBusSchemaTest : public ::testing::Test {
- protected:
- static void SetUpTestCase() {
- schema_ = new DBusSchema(ford_message_descriptions::message_descriptions);
- }
-
- static void TearDownTestCase() {
- delete schema_;
- }
-
- static const DBusSchema* schema_;
-};
-
-const DBusSchema* DBusSchemaTest::schema_ = 0;
-
-TEST_F(DBusSchemaTest, GetName) {
- const MessageId kId = hmi_apis::FunctionID::Buttons_GetCapabilities;
- const MessageName kExpName("Buttons", "GetCapabilities");
- MessageName name = schema_->getMessageName(kId);
- EXPECT_EQ(kExpName, name);
-
- const MessageId kIdWrong = static_cast<const MessageId>(-3);
- const MessageName kExpNameWrong("", "");
- name = schema_->getMessageName(kIdWrong);
- EXPECT_EQ(kExpNameWrong, name);
-}
-
-TEST_F(DBusSchemaTest, GetId) {
- const MessageName kName("Buttons", "GetCapabilities");
- const MessageId kExpId = hmi_apis::FunctionID::Buttons_GetCapabilities;
- MessageId id = schema_->getMessageId(kName);
- EXPECT_EQ(kExpId, id);
-
- const MessageName kNameWrong("TestInterface", "TestMessage");
- const MessageId kExpIdWrong = hmi_apis::FunctionID::INVALID_ENUM;
- id = schema_->getMessageId(kNameWrong);
- EXPECT_EQ(kExpIdWrong, id);
-}
-
-TEST_F(DBusSchemaTest, GetListArg) {
- const MessageName kName("Buttons", "GetCapabilities");
- const MessageType kType = hmi_apis::messageType::response;
- const MessageId kId = hmi_apis::FunctionID::Buttons_GetCapabilities;
- ListArgs argsName = schema_->getListArgs(kName, kType);
- const ParameterDescription** params =
- ford_message_descriptions::message_descriptions[1]->parameters;
- EXPECT_EQ(params[0], argsName[0]);
- EXPECT_EQ(params[1], argsName[1]);
-
- ListArgs argsId = schema_->getListArgs(kId, kType);
- EXPECT_EQ(params[0], argsId[0]);
- EXPECT_EQ(params[1], argsId[1]);
-
- const MessageId kIdWrong = static_cast<const MessageId>(-3);
- const MessageName kNameWrong("TestInterface", "TestMessage");
- const MessageType kTypeWrong = static_cast<const MessageType>(-3);
- const ListArgs kExpListWrong;
- argsName = schema_->getListArgs(kNameWrong, kTypeWrong);
- EXPECT_EQ(kExpListWrong, argsName);
-
- argsId = schema_->getListArgs(kIdWrong, kTypeWrong);
- EXPECT_EQ(kExpListWrong, argsId);
-}
-
-} // namespace dbus
-} // namespace components
-} // namespace test
-
-int main(int argc, char** argv) {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/formatters/CMakeLists.txt b/test/components/formatters/CMakeLists.txt
deleted file mode 100644
index 842d9913b..000000000
--- a/test/components/formatters/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ../../../src/components/smart_objects/include
- ../../../src/components/formatters/include
- ../../../src/components/utils/include
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${CMAKE_BINARY_DIR}
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- SmartObjects
- formatters
- jsoncpp
-)
-
-create_test("test_generic_json_formatter" "./src/generic_json_formatter_test.cc" "${LIBRARIES}")
diff --git a/test/components/formatters/src/generic_json_formatter_test.cc b/test/components/formatters/src/generic_json_formatter_test.cc
deleted file mode 100644
index 978349193..000000000
--- a/test/components/formatters/src/generic_json_formatter_test.cc
+++ /dev/null
@@ -1,161 +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.
-
-#include "gtest/gtest.h"
-
-#include "formatters/generic_json_formatter.h"
-
-namespace test {
-namespace components {
-namespace formatters {
-
-TEST(GenericJsonFormatter, ToString) {
- namespace smartobj = NsSmartDeviceLink::NsSmartObjects;
- namespace formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
-
- smartobj::SmartObject obj;
- std::string result;
-
- formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("null\n", result.c_str());
-
- obj = true;
- formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("true\n", result.c_str());
-
- obj = 10;
- formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("10\n", result.c_str());
-
- obj = 15.2;
- formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("15.20\n", result.c_str());
-
- obj = 'c';
- formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("\"c\"\n", result.c_str());
-
- obj[0] = 1;
- obj[1] = true;
- obj[2] = "string";
- formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("[ 1, true, \"string\" ]\n", result.c_str());
-
- obj["intField"] = 100500;
- obj["stringField"] = "s";
- obj["subobject"]["boolField"] = false;
- obj["subobject"]["arrayField"][0] = 0;
- obj["subobject"]["arrayField"][1] = 'c';
- obj["subobject"]["arrayField"][2][0] = 10.0;
- formatters::GenericJsonFormatter::ToString(obj, result);
- ASSERT_STREQ("{\n"
- " \"intField\" : 100500,\n"
- " \"stringField\" : \"s\",\n"
- " \"subobject\" : {\n"
- " \"arrayField\" : [\n"
- " 0,\n"
- " \"c\",\n"
- " [ 10.0 ]\n"
- " ],\n"
- " \"boolField\" : false\n"
- " }\n"
- "}\n", result.c_str());
-}
-
-TEST(GenericJsonFormatter, FromString) {
- namespace smartobj = NsSmartDeviceLink::NsSmartObjects;
- namespace formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
-
- smartobj::SmartObject result;
-
- ASSERT_FALSE(formatters::GenericJsonFormatter::FromString("", result));
- ASSERT_FALSE(formatters::GenericJsonFormatter::FromString("\"str", result));
- ASSERT_FALSE(formatters::GenericJsonFormatter::FromString("[10", result));
- ASSERT_FALSE(formatters::GenericJsonFormatter::FromString("{10}", result));
-
- ASSERT_TRUE(formatters::GenericJsonFormatter::FromString("null", result));
- ASSERT_EQ(smartobj::SmartType_Null, result.getType());
-
- ASSERT_TRUE(formatters::GenericJsonFormatter::FromString("true", result));
- ASSERT_EQ(smartobj::SmartType_Boolean, result.getType());
- ASSERT_EQ(true, result.asBool());
-
- ASSERT_TRUE(formatters::GenericJsonFormatter::FromString("1", result));
- ASSERT_EQ(smartobj::SmartType_Integer, result.getType());
- ASSERT_EQ(1, result.asInt());
-
- ASSERT_TRUE(formatters::GenericJsonFormatter::FromString("0.5", result));
- ASSERT_EQ(smartobj::SmartType_Double, result.getType());
- ASSERT_DOUBLE_EQ(0.5, result.asDouble());
-
- ASSERT_TRUE(formatters::GenericJsonFormatter::FromString("\"str\"", result));
- ASSERT_EQ(smartobj::SmartType_String, result.getType());
- ASSERT_STREQ("str", result.asString().c_str());
-
- ASSERT_TRUE(formatters::GenericJsonFormatter::FromString("[true, null, 10]",
- result));
- ASSERT_EQ(smartobj::SmartType_Array, result.getType());
- ASSERT_EQ(smartobj::SmartType_Boolean, result.getElement(0U).getType());
- ASSERT_EQ(true, result.getElement(0U).asBool());
- ASSERT_EQ(smartobj::SmartType_Null, result.getElement(1U).getType());
- ASSERT_EQ(smartobj::SmartType_Integer, result.getElement(2U).getType());
- ASSERT_EQ(10, result.getElement(2U).asInt());
-
- ASSERT_TRUE(
- formatters::GenericJsonFormatter::FromString("{"
- " \"intField\": 100500,"
- " \"subobject\": {"
- " \"arrayField\": [1, null],"
- " \"strField\": \"str\""
- " }"
- "}",
- result));
- ASSERT_EQ(smartobj::SmartType_Map, result.getType());
- ASSERT_EQ(smartobj::SmartType_Integer,
- result.getElement("intField").getType());
- ASSERT_EQ(100500, result.getElement("intField").asInt());
- ASSERT_EQ(smartobj::SmartType_Map, result.getElement("subobject").getType());
- ASSERT_EQ(smartobj::SmartType_Array,
- result.getElement("subobject").getElement("arrayField").getType());
- ASSERT_EQ(smartobj::SmartType_Integer,
- result.getElement("subobject").getElement("arrayField").getElement(0U).getType());
- ASSERT_EQ(1, result.getElement("subobject").getElement("arrayField").getElement(0U).asInt());
- ASSERT_EQ(smartobj::SmartType_Null,
- result.getElement("subobject").getElement("arrayField").getElement(1U).getType());
- ASSERT_EQ(smartobj::SmartType_String,
- result.getElement("subobject").getElement("strField").getType());
- ASSERT_STREQ(
- "str",
- result.getElement("subobject").getElement("strField").asString().c_str());
-}
-
-} // formatters
-} // components
-} // test
diff --git a/test/components/hmi_message_handler/CMakeLists.txt b/test/components/hmi_message_handler/CMakeLists.txt
deleted file mode 100644
index 3ec6b7a89..000000000
--- a/test/components/hmi_message_handler/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-include_directories (
- ${GMOCK_INCLUDE_DIRECTORY}
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/utils/include/
- ${CMAKE_SOURCE_DIR}/src/components/application_manager/include/
- ${CMAKE_SOURCE_DIR}/src/components/hmi_message_handler/include/
- ${CMAKE_SOURCE_DIR}/src/components/smart_objects/include/
- ${CMAKE_SOURCE_DIR}/test/components/hmi_message_handler/include/
- ${CMAKE_BINARY_DIR}/src/components/
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- Utils
- ProtocolHandler
- ApplicationManager
- SmartObjects
- jsoncpp
- HMIMessageHandler
- ${RTLIB}
- ProtocolLibrary
-)
-
-set (SOURCES
- #./src/mock_subscriber.cc
- #./src/test_dbus_message_adapter.cc
-)
-
-#create_test("test_DBusMessageAdapter" "${SOURCES}" "${LIBRARIES}")
-create_test("test_mqueue_adapter" "./src/test_mqueue_adapter.cc" "${LIBRARIES}")
-
diff --git a/test/components/hmi_message_handler/include/hmi_message_handler/mock_dbus_message_controller.h b/test/components/hmi_message_handler/include/hmi_message_handler/mock_dbus_message_controller.h
deleted file mode 100644
index 9d980364d..000000000
--- a/test/components/hmi_message_handler/include/hmi_message_handler/mock_dbus_message_controller.h
+++ /dev/null
@@ -1,68 +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 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/test/components/hmi_message_handler/include/hmi_message_handler/mock_subscriber.h b/test/components/hmi_message_handler/include/hmi_message_handler/mock_subscriber.h
deleted file mode 100644
index 7faf7ee4b..000000000
--- a/test/components/hmi_message_handler/include/hmi_message_handler/mock_subscriber.h
+++ /dev/null
@@ -1,62 +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 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/test/components/hmi_message_handler/log4cxx.properties b/test/components/hmi_message_handler/log4cxx.properties
deleted file mode 100644
index 6fb2f5a1c..000000000
--- a/test/components/hmi_message_handler/log4cxx.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-# Log for all SmartDeviceLinkCoreSocketHub messages
-log4j.appender.SmartDeviceLinkCoreSocketHub=org.apache.log4j.net.SocketHubAppender
-log4j.appender.SmartDeviceLinkCoreSocketHub.port=4555
-log4j.appender.SmartDeviceLinkCoreSocketHub.locationInfo=true
-
-# Only ERROR and FATAL messages are logged to console
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.ImmediateFlush=true
-log4j.appender.Console.layout=org.apache.log4j.PatternLayout
-log4j.appender.Console.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %m%n
-log4j.appender.Console.Threshold=ALL
-
-# Log for all SmartDeviceLinkCore messages
-log4j.appender.SmartDeviceLinkCoreLogFile=org.apache.log4j.FileAppender
-log4j.appender.SmartDeviceLinkCoreLogFile.File=SmartDeviceLinkCore.log
-log4j.appender.SmartDeviceLinkCoreLogFile.append=false
-log4j.appender.SmartDeviceLinkCoreLogFile.DatePattern='.' yyyy-MM-dd HH-mm
-log4j.appender.SmartDeviceLinkCoreLogFile.ImmediateFlush=true
-log4j.appender.SmartDeviceLinkCoreLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.SmartDeviceLinkCoreLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for all TransportManager messages
-log4j.appender.TransportManagerLogFile=org.apache.log4j.FileAppender
-log4j.appender.TransportManagerLogFile.File=TransportManager.log
-log4j.appender.TransportManagerLogFile.append=false
-log4j.appender.TransportManagerLogFile.DatePattern='.' yyyy-MM-dd HH-mm
-log4j.appender.TransportManagerLogFile.ImmediateFlush=true
-log4j.appender.TransportManagerLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.TransportManagerLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# All SmartDeviceLinkCore logs
-log4j.rootLogger=ALL, Console, SmartDeviceLinkCoreLogFile, SmartDeviceLinkCoreSocketHub
-
-# TransportManager logs
-log4j.logger.TransportManager=ALL, TransportManagerLogFile
diff --git a/test/components/hmi_message_handler/src/mock_subscriber.cc b/test/components/hmi_message_handler/src/mock_subscriber.cc
deleted file mode 100644
index 019e00718..000000000
--- a/test/components/hmi_message_handler/src/mock_subscriber.cc
+++ /dev/null
@@ -1,88 +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.
-*/
-
-#include "hmi_message_handler/mock_subscriber.h"
-
-#include <dbus/dbus.h>
-
-namespace test {
-namespace components {
-namespace hmi_message_handler {
-
-MockSubscriber::MockSubscriber(
- const std::string nameService, const std::string path)
- : nameService_(nameService),
- path_(path),
- conn_(nullptr) {
-}
-
-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;
- }
-// ret = dbus_bus_request_name(conn_, nameService_.c_str(),
-// DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
-// if (dbus_error_is_set(&err)) {
-// dbus_error_free(&err);
-// return false;
-// }
-// if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
-// 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)) {
- 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/test/components/hmi_message_handler/src/test_dbus_message_adapter.cc b/test/components/hmi_message_handler/src/test_dbus_message_adapter.cc
deleted file mode 100644
index d055092cf..000000000
--- a/test/components/hmi_message_handler/src/test_dbus_message_adapter.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * \file test_dbus_message_adapter.cc
- * \brief
- *
- * 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.
- */
-
-#include <gtest/gtest.h>
-
-
diff --git a/test/components/hmi_message_handler/src/test_mqueue_adapter.cc b/test/components/hmi_message_handler/src/test_mqueue_adapter.cc
deleted file mode 100644
index c30b3aa7b..000000000
--- a/test/components/hmi_message_handler/src/test_mqueue_adapter.cc
+++ /dev/null
@@ -1,92 +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));
- virtual void AddHMIMessageAdapter(HMIMessageAdapter* adapter) {}
- virtual void RemoveHMIMessageAdapter(HMIMessageAdapter* adapter) {}
- virtual void OnErrorSending(MessageSharedPointer message) {}
- virtual void SendMessageToHMI(MessageSharedPointer message) {}
-};
-
-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;
-}
-
-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;
-}
diff --git a/test/components/include/protocol_handler/control_message_matcher.h b/test/components/include/protocol_handler/control_message_matcher.h
deleted file mode 100644
index 60400f5b1..000000000
--- a/test/components/include/protocol_handler/control_message_matcher.h
+++ /dev/null
@@ -1,138 +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.
- */
-#ifndef TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_CONTROL_MESSAGE_MATCHER_H_
-#define TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_CONTROL_MESSAGE_MATCHER_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include <vector>
-#include "protocol/raw_message.h"
-#include "protocol_handler/protocol_packet.h"
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-/*
- * Matcher for checking RawMessage with ControlMessage
- * Check error id
- */
-MATCHER_P2(ControlMessage, ExpectedFrameData, ExpectedEncryption,
- (std::string(ExpectedEncryption ? "Protected" : "Unprotected")
- + " control message ")) {
- // Nack shall be always with flag protected off
- DCHECK(ExpectedFrameData != 0x03 /*FRAME_DATA_START_SERVICE_NACK*/ ||
- !ExpectedEncryption);
- const ::protocol_handler::RawMessagePtr message = arg;
- ::protocol_handler::ProtocolPacket packet(message->connection_key());
- const protocol_handler::RESULT_CODE result =
- packet.deserializePacket(message->data(), message->data_size());
- if (result != protocol_handler::RESULT_OK) {
- *result_listener << "Error while message deserialization.";
- return false;
- }
- if (::protocol_handler::FRAME_TYPE_CONTROL != packet.frame_type()) {
- *result_listener << "Is not control message";
- return false;
- }
- if (ExpectedFrameData != packet.frame_data()) {
- *result_listener << "Control message with data 0x"
- << std::hex << static_cast<int>(packet.frame_data())
- << ", not 0x"
- << std::hex << static_cast<int>(ExpectedFrameData);
- return false;
- }
- if (ExpectedEncryption != packet.protection_flag()) {
- *result_listener << "Control message is " <<
- (ExpectedEncryption ? "" : "not ") << "protected";
- return false;
- }
- return true;
-}
-
-
-MATCHER_P4(ControlMessage, ExpectedFrameData, ExpectedEncryption,
- ConnectionKey, VectorMatcher,
- (std::string(ExpectedEncryption ? "Protected" : "Unprotected")
- + " control message ")) {
- // Nack shall be always with flag protected off
- DCHECK(ExpectedFrameData != 0x03 /*FRAME_DATA_START_SERVICE_NACK*/ ||
- !ExpectedEncryption);
- const ::protocol_handler::RawMessagePtr message = arg;
- ::protocol_handler::ProtocolPacket packet(message->connection_key());
- const protocol_handler::RESULT_CODE result =
- packet.deserializePacket(message->data(), message->data_size());
- if (result != protocol_handler::RESULT_OK) {
- *result_listener << "Error while message deserialization.";
- return false;
- }
- if (::protocol_handler::FRAME_TYPE_CONTROL != packet.frame_type()) {
- *result_listener << "Is not control message";
- return false;
- }
- if (ExpectedFrameData != packet.frame_data()) {
- *result_listener << "Control message with data 0x"
- << std::hex << static_cast<int>(packet.frame_data())
- << ", not 0x"
- << std::hex << static_cast<int>(ExpectedFrameData);
- return false;
- }
- if (ExpectedEncryption != packet.protection_flag()) {
- *result_listener << "Control message is " <<
- (ExpectedEncryption ? "" : "not ") << "protected";
- return false;
- }
- if (ConnectionKey != message->connection_key()) {
- *result_listener << "Message for connection_id " << message->connection_key() <<
- ", expected for connection_id " << ConnectionKey;
- return false;
- }
- std::vector<uint8_t> data_vector;
- if (packet.data() && packet.data_size()) {
- data_vector.assign(packet.data(), packet.data() + packet.data_size());
- }
- ::testing::Matcher<std::vector<uint8_t> > m = VectorMatcher;
- if (!m.Matches(data_vector)) {
- *result_listener << "Message with " << data_vector.size()
- << " byte data : 0x";
- for (size_t i = 0u; i < data_vector.size(); ++i) {
- *result_listener << std::hex << static_cast<int>(data_vector[i]);
- }
- return false;
- }
- return true;
-}
-
-
-} // namespace protocol_handler_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_CONTROL_MESSAGE_MATCHER_H_
diff --git a/test/components/include/protocol_handler/protocol_handler_mock.h b/test/components/include/protocol_handler/protocol_handler_mock.h
deleted file mode 100644
index 204a56242..000000000
--- a/test/components/include/protocol_handler/protocol_handler_mock.h
+++ /dev/null
@@ -1,66 +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.
- */
-#ifndef TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include "protocol_handler/protocol_handler.h"
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-/*
- * MOCK implementation of ::protocol_handler::ProtocolObserver interface
- */
-using namespace ::protocol_handler;
-
-class ProtocolHandlerMock: public ::protocol_handler::ProtocolHandler {
- public:
- MOCK_METHOD2(SendMessageToMobileApp,
- void(const ::protocol_handler::RawMessagePtr message,
- bool final_message));
- MOCK_METHOD1(AddProtocolObserver,
- void(::protocol_handler::ProtocolObserver *observer));
- MOCK_METHOD1(RemoveProtocolObserver,
- void(::protocol_handler::ProtocolObserver *observer));
- MOCK_METHOD2(SendFramesNumber,
- void(uint32_t connection_key, int32_t number_of_frames));
- MOCK_METHOD2(SendHeartBeat,
- void(int32_t connection_id, uint8_t session_id));
- MOCK_METHOD2(SendEndSession,
- void(int32_t connection_id, uint8_t session_id));
-};
-} // namespace protocol_handler_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_MOCK_H_
diff --git a/test/components/include/protocol_handler/protocol_observer_mock.h b/test/components/include/protocol_handler/protocol_observer_mock.h
deleted file mode 100644
index 9049c9db9..000000000
--- a/test/components/include/protocol_handler/protocol_observer_mock.h
+++ /dev/null
@@ -1,57 +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.
- */
-
-#ifndef TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_OBSERVER_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_OBSERVER_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include "protocol_handler/protocol_observer.h"
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-
-/*
- * MOCK implementation of ::protocol_handler::ProtocolObserver interface
- */
-class ProtocolObserverMock: public ::protocol_handler::ProtocolObserver {
- public:
- MOCK_METHOD1(OnMessageReceived,
- void(const ::protocol_handler::RawMessagePtr));
- MOCK_METHOD1(OnMobileMessageSent,
- void(const ::protocol_handler::RawMessagePtr));
-};
-} // namespace protocol_handler_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_OBSERVER_MOCK_H_
diff --git a/test/components/include/protocol_handler/session_observer_mock.h b/test/components/include/protocol_handler/session_observer_mock.h
deleted file mode 100644
index 91d9b40b3..000000000
--- a/test/components/include/protocol_handler/session_observer_mock.h
+++ /dev/null
@@ -1,104 +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.
- */
-
-#ifndef TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_SESSION_OBSERVER_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_SESSION_OBSERVER_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include <list>
-#include "protocol_handler/session_observer.h"
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-/*
- * MOCK implementation of ::protocol_handler::SessionObserver interface
- */
-class SessionObserverMock: public ::protocol_handler::SessionObserver {
- public:
- MOCK_METHOD5(OnSessionStartedCallback,
- uint32_t(
- const transport_manager::ConnectionUID &connection_handle,
- const uint8_t session_id,
- const ::protocol_handler::ServiceType &service_type,
- const bool is_protected, uint32_t* hash_id));
- MOCK_METHOD4(OnSessionEndedCallback,
- uint32_t(
- const transport_manager::ConnectionUID &connection_handle,
- const uint8_t sessionId,
- const uint32_t &hashCode,
- const ::protocol_handler::ServiceType &service_type));
- MOCK_METHOD1(OnApplicationFloodCallBack,
- void(const uint32_t&));
- MOCK_METHOD2(KeyFromPair,
- uint32_t(
- transport_manager::ConnectionUID connection_handle,
- uint8_t sessionId));
- MOCK_METHOD3(PairFromKey,
- void(
- uint32_t key,
- transport_manager::ConnectionUID *connection_handle,
- uint8_t *sessionId));
- MOCK_METHOD4(GetDataOnSessionKey,
- int32_t(uint32_t key,
- uint32_t *app_id,
- std::list<int32_t> *sessions_list,
- uint32_t *device_id));
- MOCK_METHOD5(GetDataOnDeviceID,
- int32_t(
- uint32_t device_handle,
- std::string *device_name,
- std::list<uint32_t> *applications_list,
- std::string *mac_address,
- std::string *connection_type));
- MOCK_METHOD2(IsHeartBeatSupported,
- bool(transport_manager::ConnectionUID connection_handle,
- uint8_t session_id));
-#ifdef ENABLE_SECURITY
- MOCK_METHOD2(SetSSLContext,
- int(const uint32_t &key,
- ::security_manager::SSLContext *context));
- MOCK_METHOD2(GetSSLContext,
- ::security_manager::SSLContext * (
- const uint32_t &key,
- const ::protocol_handler::ServiceType &service_type));
- MOCK_METHOD2(SetProtectionFlag,
- void(
- const uint32_t &key,
- const ::protocol_handler::ServiceType &service_type));
-#endif // ENABLE_SECURITY
-};
-} // namespace protocol_handler_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_PROTOCOL_HANDLER_SESSION_OBSERVER_MOCK_H_
diff --git a/test/components/include/security_manager/crypto_manager_mock.h b/test/components/include/security_manager/crypto_manager_mock.h
deleted file mode 100644
index 18d7b36a4..000000000
--- a/test/components/include/security_manager/crypto_manager_mock.h
+++ /dev/null
@@ -1,67 +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.
- */
-
-#ifndef TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_CRYPTO_MANAGER_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_CRYPTO_MANAGER_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include "security_manager/crypto_manager.h"
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-/*
- * MOCK implementation of ::security_manager::CryptoManager interface
- */
-class CryptoManagerMock: public ::security_manager::CryptoManager {
- public:
- MOCK_METHOD6(Init,
- bool(::security_manager::Mode mode,
- ::security_manager::Protocol protocol,
- const std::string &cert_filename,
- const std::string &key_filename,
- const std::string &ciphers_list,
- bool verify_peer));
- MOCK_METHOD0(Finish,
- void());
- MOCK_METHOD0(CreateSSLContext,
- ::security_manager::SSLContext * ());
- MOCK_METHOD1(ReleaseSSLContext,
- void(::security_manager::SSLContext *));
- MOCK_CONST_METHOD0(LastError,
- std::string());
-};
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_CRYPTO_MANAGER_MOCK_H_
diff --git a/test/components/include/security_manager/security_manager_listener_mock.h b/test/components/include/security_manager/security_manager_listener_mock.h
deleted file mode 100644
index 047571cf6..000000000
--- a/test/components/include/security_manager/security_manager_listener_mock.h
+++ /dev/null
@@ -1,54 +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.
- */
-
-#ifndef TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_LISTENER_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_LISTENER_MOCK_H_
-
-#include <gmock/gmock.h>
-#include "security_manager/security_manager_listener.h"
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-/*
- * MOCK implementation of ::security_manager::SecurityManagerListener
- */
-class SMListenerMock: public ::security_manager::SecurityManagerListener {
- public:
- MOCK_METHOD2(OnHandshakeDone,
- bool(uint32_t connection_key,
- bool success));
-};
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_LISTENER_MOCK_H_
diff --git a/test/components/include/security_manager/security_manager_mock.h b/test/components/include/security_manager/security_manager_mock.h
deleted file mode 100644
index 1d41b05e4..000000000
--- a/test/components/include/security_manager/security_manager_mock.h
+++ /dev/null
@@ -1,76 +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.
- */
-
-#ifndef TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include "security_manager/security_manager.h"
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-/*
- * MOCK implementation of ::security_manager::SecurityManager
- */
-class SecurityManagerMock: public ::security_manager::SecurityManager {
- public:
- MOCK_METHOD1(set_session_observer,
- void(::protocol_handler::SessionObserver *));
- MOCK_METHOD1(set_protocol_handler,
- void(::protocol_handler::ProtocolHandler *));
- MOCK_METHOD1(set_crypto_manager,
- void(::security_manager::CryptoManager *));
- MOCK_METHOD4(SendInternalError,
- void(const uint32_t ,
- const uint8_t &,
- const std::string &,
- const uint32_t));
- MOCK_METHOD1(CreateSSLContext,
- ::security_manager::SSLContext * (const uint32_t &));
- MOCK_METHOD1(StartHandshake,
- void(uint32_t));
- MOCK_METHOD1(AddListener,
- void(::security_manager::SecurityManagerListener *));
- MOCK_METHOD1(RemoveListener,
- void(::security_manager::SecurityManagerListener *));
- // protocol_handler::ProtocolObserver part
- MOCK_METHOD1(OnMessageReceived,
- void(const ::protocol_handler::RawMessagePtr));
- MOCK_METHOD1(OnMobileMessageSent,
- void(const ::protocol_handler::RawMessagePtr));
-};
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_MOCK_H_
diff --git a/test/components/include/security_manager/ssl_context_mock.h b/test/components/include/security_manager/ssl_context_mock.h
deleted file mode 100644
index 291a6cdd2..000000000
--- a/test/components/include/security_manager/ssl_context_mock.h
+++ /dev/null
@@ -1,71 +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.
- */
-
-#ifndef TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SSL_CONTEXT_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SSL_CONTEXT_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include "security_manager/ssl_context.h"
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-/*
- * MOCK implementation of ::security_manager::SSLContext interface
- */
-class SSLContextMock: public ::security_manager::SSLContext {
- public:
- MOCK_CONST_METHOD0(mode, int());
- MOCK_METHOD2(StartHandshake,
- ::security_manager::SSLContext::HandshakeResult(
- const uint8_t **const, size_t *));
- MOCK_METHOD4(DoHandshakeStep,
- ::security_manager::SSLContext::HandshakeResult(
- const uint8_t *const, size_t,
- const uint8_t **const, size_t *));
- MOCK_METHOD4(Encrypt,
- bool(const uint8_t *const, size_t,
- const uint8_t **const, size_t *));
- MOCK_METHOD4(Decrypt,
- bool(const uint8_t *const, size_t,
- const uint8_t **const, size_t *));
- MOCK_CONST_METHOD1(get_max_block_size, size_t(size_t));
- MOCK_CONST_METHOD0(IsInitCompleted, bool());
- MOCK_CONST_METHOD0(IsHandshakePending, bool());
- MOCK_CONST_METHOD0(LastError,
- std::string());
-};
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_SECURITY_MANAGER_SSL_CONTEXT_MOCK_H_
diff --git a/test/components/include/transport_manager/transport_manager_mock.h b/test/components/include/transport_manager/transport_manager_mock.h
deleted file mode 100644
index eb8e9b4b5..000000000
--- a/test/components/include/transport_manager/transport_manager_mock.h
+++ /dev/null
@@ -1,87 +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.
- */
-
-#ifndef TEST_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_MOCK_H_
-#define TEST_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include "transport_manager/transport_manager.h"
-#include "transport_manager/transport_adapter/transport_adapter_event.h"
-
-namespace test {
-namespace components {
-namespace transport_manager_test {
-
-using ::transport_manager::DeviceHandle;
-using ::transport_manager::ConnectionUID;
-using ::transport_manager::transport_adapter::TransportAdapter;
-using ::transport_manager::TransportAdapterEvent;
-using ::transport_manager::TransportManagerListener;
-/*
- * MOCK implementation of ::transport_manager::TransportManager interface
- */
-class TransportManagerMock: public ::transport_manager::TransportManager {
- public:
- MOCK_METHOD0(Init,
- int());
- MOCK_METHOD0(SearchDevices,
- int());
- MOCK_METHOD1(ConnectDevice,
- int(const DeviceHandle &));
- MOCK_METHOD1(DisconnectDevice,
- int(const DeviceHandle &));
- MOCK_METHOD1(Disconnect,
- int(const ConnectionUID &));
- MOCK_METHOD1(DisconnectForce,
- int(const ConnectionUID &));
- MOCK_METHOD1(SendMessageToDevice,
- int(const ::protocol_handler::RawMessagePtr));
- MOCK_METHOD1(ReceiveEventFromDevice,
- int(const TransportAdapterEvent&));
- MOCK_METHOD1(AddTransportAdapter,
- int(TransportAdapter *));
- MOCK_METHOD1(AddEventListener,
- int(TransportManagerListener *));
- MOCK_METHOD0(Stop,
- int());
- MOCK_METHOD1(RemoveDevice,
- int(const DeviceHandle &));
- MOCK_CONST_METHOD1(Visibility,
- int(const bool &));
- MOCK_METHOD0(Reinit,
- int());
-};
-} // namespace transport_manager_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_INCLUDE_TRANSPORT_MANAGER_TRANSPORT_MANAGER_MOCK_H_
diff --git a/test/components/json_handler/CMakeLists.txt b/test/components/json_handler/CMakeLists.txt
deleted file mode 100644
index 7907cc6d9..000000000
--- a/test/components/json_handler/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Generating interface
-GenerateInterface("test_json_rpc.xml" "gen::test::components::json_rpc" "jsonrpc")
-GenerateInterface("test_JSONHandler_v4_protocol_v2_0_revP.xml" "Gen::test::components::JSONHandler2" "sdlrpcv2")
-GenerateInterface("test_JSONHandler_v4_protocol_v1_2_no_extra.xml" "Gen::test::components::JSONHandler1" "sdlrpcv1")
-
-
-include_directories (
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ${LOG4CXX_INCLUDE_DIRECTORY}
-
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ${CMAKE_SOURCE_DIR}/src/components/smart_objects/include
-
- ${CMAKE_SOURCE_DIR}/test/components/json_handler/include/
- ${CMAKE_BINARY_DIR}
-)
-
-set(LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
-
- test_json_rpc
- test_JSONHandler_v4_protocol_v2_0_revP
- test_JSONHandler_v4_protocol_v1_2_no_extra
-
- jsoncpp
- formatters
- SmartObjects
-)
-
-create_test("test_JSONHandler_JSONRPCFullScenario" "./src/test_json_rpc_full_scenario.cpp" "${LIBRARIES}")
-create_test("test_JSONHandler_FormatterJsonSDLRPCv2Test" "./src/formatter_test_helper.cc;./src/meta_formatter_test_helper.cc;./src/FormatterJsonSDLRPCv2Test.cpp" "${LIBRARIES}")
-create_test("test_JSONHandler_FormatterJsonSDLRPCv1Test" "./src/formatter_test_helper.cc;./src/FormatterJsonSDLRPCv1Test.cpp" "${LIBRARIES}")
-create_test("test_JSONHandler_FormatterJsonRPC2Test" "./src/formatter_json_rpc_test.cc;./src/formatter_test_helper.cc" "${LIBRARIES}")
-create_test("test_JSONHandler_MetaFormatter" "./src/meta_formatter_test.cc;./src/meta_formatter_test_helper.cc" "${LIBRARIES}")
diff --git a/test/components/json_handler/include/json_handler/formatter_json_alrpcv1_test.h b/test/components/json_handler/include/json_handler/formatter_json_alrpcv1_test.h
deleted file mode 100644
index 6f5b7acce..000000000
--- a/test/components/json_handler/include/json_handler/formatter_json_alrpcv1_test.h
+++ /dev/null
@@ -1,991 +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 TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_ALRPCV1_TEST_H_
-#define TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_ALRPCV1_TEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <iostream>
-#include "json/json.h"
-
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
-#include "formatters/CSmartFactory.hpp"
-
-#include "smart_objects/array_schema_item.h"
-#include "smart_objects/bool_schema_item.h"
-#include "smart_objects/object_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-#include "smart_objects/enum_schema_item.h"
-#include "smart_objects/number_schema_item.h"
-#include "smart_objects/schema_item_parameter.h"
-
-#include "formatter_test_helper.h"
-
-
-namespace test { namespace components { namespace json_handler { namespace formatters {
-
- // The code below is cut and paste from the generated code just to provide necessary environment for string <-> enum conversion.
- namespace FunctionID
- {
- /**
- * @brief Enumeration FunctionID.
- */
- enum eType
- {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief RegisterAppInterface.
- */
- RegisterAppInterface,
-
- /**
- * @brief UnregisterAppInterface.
- */
- UnregisterAppInterface,
-
- /**
- * @brief SetGlobalProperties.
- */
- SetGlobalProperties,
-
- // ...
- };
- }
-
- namespace messageType
- {
- /**
- * @brief Enumeration messageType.
- */
- enum eType
- {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief request.
- */
- request,
-
- /**
- * @brief response.
- */
- response,
-
- /**
- * @brief notification.
- */
- notification
- };
- }
- // end of cut and pasted code
-
- using namespace NsSmartDeviceLink::NsJSONHandler::strings;
- typedef NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv1 FormatterV1;
-
- TEST_F(CFormatterTestHelper, test_fromObjToALRPCv1AndBack)
- {
- Json::Value value; // just a quick workaround to avoid undefined reference to Json
- Json::Reader reader; // the same thing
-
- std::string str;
- NsSmartDeviceLink::NsSmartObjects::SmartObject srcObj;
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj;
-
- fillTestObject(srcObj);
- srcObj[S_PARAMS][S_FUNCTION_ID] = "UnregisterAppInterface"; // a hack, it shouldn't be a string in the SmartObject
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = "request"; // the same thing
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
-
- // SmartObjects --> JSON
- FormatterV1::toString(srcObj, str);
-
- //std::cout << str << std::endl;
-
- // JSON --> SmartObjects
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str, dstObj);
-
- ASSERT_EQ(FormatterV1::kSuccess, result) << "Error parsing JSON string";
-
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionID::UnregisterAppInterface; // write the proper enum values
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
-
- compareObjects(srcObj, dstObj);
- }
-
- TEST_F(CFormatterTestHelper, test_fromJsonALRPCv1)
- {
- std::string str = "\
- {\
- \"request\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"syncMsgVersion\": \"version\",\
- \"appName\": \"some app name\",\
- \"ttsName\": [{\
- \"text\": \"ABC\",\
- \"type\": \"TEXT\"\
- }],\
- \"vrSynonyms\": [\"Synonym 1\", \"Synonym 2\"]\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str, obj);
-
- ASSERT_EQ(FormatterV1::kSuccess, result) << "Error parsing JSON string";
-
- ASSERT_EQ(FunctionID::SetGlobalProperties, obj[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj[S_PARAMS][S_MESSAGE_TYPE].asInt());
- ASSERT_EQ(11, obj[S_PARAMS][S_CORRELATION_ID].asInt());
- ASSERT_EQ("version", obj[S_MSG_PARAMS]["syncMsgVersion"].asString());
- ASSERT_EQ("some app name", obj[S_MSG_PARAMS]["appName"].asString());
- ASSERT_EQ("some app name", obj[S_MSG_PARAMS]["appName"].asString());
- ASSERT_EQ(1, obj[S_PARAMS][S_PROTOCOL_VERSION].asInt());
- ASSERT_EQ("TEXT", obj[S_MSG_PARAMS]["ttsName"][0]["type"].asString());
- ASSERT_EQ("Synonym 2", obj[S_MSG_PARAMS]["vrSynonyms"][1].asString());
- }
-
- TEST_F(CFormatterTestHelper, test_ALRPCv1_ErrorParsing)
- {
- std::string str = "\
- {\
- \"request\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str, obj);
-
- ASSERT_TRUE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_TRUE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is not set";
- }
-
- TEST_F(CFormatterTestHelper, test_ALRPCv1_MessageTypeError)
- {
- std::string str1 = "\
- {\
- \"information\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_TRUE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is not set";
-
- std::string str2 = "\
- {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj2;
- result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str1, obj2);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_TRUE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is not set";
- }
-
- TEST_F(CFormatterTestHelper, test_ALRPCv1_FunctionID_Error)
- {
- std::string str1 = "\
- {\
- \"request\": {\
- \"not a name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is not set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is set";
- ASSERT_EQ(11, obj1[S_PARAMS][S_CORRELATION_ID].asInt()) << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- std::string str2 = "\
- {\
- \"request\": {\
- \"name\" : \"UnknownName\",\
- \"correlationID\": 12,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj2;
- result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str2, obj2);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is not set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is set";
- ASSERT_EQ(12, obj2[S_PARAMS][S_CORRELATION_ID].asInt()) << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj2[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj2[S_PARAMS][S_MESSAGE_TYPE].asInt());
- }
-
- TEST_F(CFormatterTestHelper, test_ALRPCv1_CorrelationID_Error)
- {
- std::string str1 = "\
- {\
- \"request\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"NotACorrelationID\": 13,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is set";
- ASSERT_FALSE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is not set";
- ASSERT_EQ(-1, obj1[S_PARAMS][S_CORRELATION_ID].asInt()) << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::SetGlobalProperties, obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
- }
-
- TEST_F(CFormatterTestHelper, test_ALRPCv1_CombinationError)
- {
- std::string str1 = "\
- {\
- \"response\": {\
- \"name\" : \"UnKnownName\",\
- \"NotACorrelationID\": 10,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is not set";
- ASSERT_EQ(-1, obj1[S_PARAMS][S_CORRELATION_ID].asInt()) << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::response, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
- }
-
- TEST_F(CFormatterTestHelper, test_ALRPCv1_NotificationCorrelationId)
- {
- std::string str1 = "\
- {\
- \"notification\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"NotACorrelationID\": 10,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is set";
- ASSERT_FALSE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is set";
- ASSERT_EQ(-1, obj1[S_PARAMS][S_CORRELATION_ID].asInt()) << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::SetGlobalProperties, obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::notification, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- std::string str2 = "\
- {\
- \"notification\": {\
- \"name\" : \"UnknownNotification\",\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj2;
- result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str2, obj2);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result) << "MessageType error code is set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result) << "FunctionID error code is not set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result) << "CorrelationID error code is set";
- ASSERT_EQ(-1, obj2[S_PARAMS][S_CORRELATION_ID].asInt()) << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj2[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::notification, obj2[S_PARAMS][S_MESSAGE_TYPE].asInt());
- }
-
- TEST_F(CFormatterTestHelper, test_SDLRPCv1_EmptyMapArrayTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject srcObj, dstObj;
- std::string str;
-
- fillTestObject(srcObj);
- srcObj[S_PARAMS][S_FUNCTION_ID] = "UnregisterAppInterface"; // a hack, it shouldn't be a string in the SmartObject
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = "request"; // the same thing
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- srcObj[S_MSG_PARAMS]["EmptyArray"] = SmartObject(SmartType_Array);
- srcObj[S_MSG_PARAMS]["EmptyMap"] = SmartObject(SmartType_Map);
- srcObj[S_MSG_PARAMS]["AnotherEmptyArray"] = srcObj[S_MSG_PARAMS]["EmptyArray"];
- srcObj[S_MSG_PARAMS]["AnotherEmptyMap"] = srcObj[S_MSG_PARAMS]["EmptyMap"];
-
- // SmartObjects --> JSON
- FormatterV1::toString(srcObj, str);
-
- //std::cout << str << std::endl;
-
- // JSON --> SmartObjects
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str, dstObj);
-
- ASSERT_EQ(FormatterV1::kSuccess, result) << "Error parsing JSON string";
-
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionID::UnregisterAppInterface; // write the proper enum values
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
-
- compareObjects(srcObj, dstObj);
- }
-
- namespace so = NsSmartDeviceLink::NsSmartObjects;
- namespace mf = NsSmartDeviceLink::NsJSONHandler::Formatters::
- meta_formatter_error_code;
-
- TEST_F(CFormatterTestHelper, test_SDLRPCv1_MetaFormatToString_Empty) {
- std::string result;
- FormatterV1::tMetaFormatterErrorCode error_code;
-
- so::SmartObject empty_object;
- so::CSmartSchema empty_schema;
-
- error_code = FormatterV1::MetaFormatToString(empty_object,
- empty_schema,
- result);
-
- std::string expected_result(
- "{\n"
- " \"\" : {\n"
- " \"name\" : \"\",\n"
- " \"parameters\" : \"\"\n"
- " }\n"
- "}\n");
-
- ASSERT_EQ(expected_result, result) <<
- "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must be not be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid empty schema";
-
- so::SmartObject object(so::SmartType_Map);
-
- object["1"] = 1;
- object["2"] = "two";
- object["3"] = false;
-
- error_code = FormatterV1::MetaFormatToString(object,
- empty_schema,
- result);
-
- ASSERT_EQ(expected_result, result) <<
- "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must be not be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid empty schema";
-
- so::SmartObject function_object(so::SmartType_Map);
-
- function_object[S_PARAMS][S_FUNCTION_ID] =
- FunctionID::UnregisterAppInterface;
- function_object[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
- function_object[S_MSG_PARAMS]["Some data"] = "Some data";
-
- error_code = FormatterV1::MetaFormatToString(function_object,
- empty_schema,
- result);
-
- ASSERT_EQ(expected_result, result) <<
- "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_FALSE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid empty schema";
-
- std::map<std::string, so::CObjectSchemaItem::SMember>
- non_function_schema_members_map;
-
- non_function_schema_members_map["StringField"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- so::TSchemaItemParameter<size_t>(),
- so::TSchemaItemParameter<size_t>(1000),
- so::TSchemaItemParameter<std::string>()),
- false);
- non_function_schema_members_map["IntField"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<int>::create(
- 1, 20, 10), true);
- non_function_schema_members_map["BoolField"] =
- so::CObjectSchemaItem::SMember(
- so::CBoolSchemaItem::create(
- so::TSchemaItemParameter<bool>()),
- true);
-
- so::CSmartSchema non_function_schema(so::CObjectSchemaItem::create(
- non_function_schema_members_map));
-
- error_code = FormatterV1::MetaFormatToString(empty_object,
- non_function_schema,
- result);
-
- ASSERT_EQ(expected_result, result) <<
- "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must not be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid empty schema";
- }
-
- TEST_F(CFormatterTestHelper, test_SDLRPCv1_MetaFormatToString_Valid) {
- std::string result;
- FormatterV1::tMetaFormatterErrorCode error_code;
-
- so::SmartObject empty_object;
-
- std::set<FunctionID::eType> function_id_items;
- function_id_items.insert(FunctionID::RegisterAppInterface);
- function_id_items.insert(FunctionID::UnregisterAppInterface);
- function_id_items.insert(FunctionID::SetGlobalProperties);
-
- std::set<messageType::eType> message_type_items;
- message_type_items.insert(messageType::request);
- message_type_items.insert(messageType::response);
- message_type_items.insert(messageType::notification);
-
- std::map<std::string, so::CObjectSchemaItem::SMember>
- test_struct_members;
-
- test_struct_members["mandatory_int_field"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<int>::create(
- 1, 20, 15), true);
-
- test_struct_members["mandatory_string_field"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- 0,
- 500,
- std::string("Mandatory text")),
- true);
-
- test_struct_members["non_mandatory_string_field"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- 0,
- 500,
- std::string("Non-mandatory text")),
- false);
-
- std::map<std::string, so::CObjectSchemaItem::SMember>
- test_non_mandatory_struct_members;
-
- test_non_mandatory_struct_members["non_mandatory_int_field"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<int>::create(
- 1, 20, 15), false);
-
- std::map<std::string, so::CObjectSchemaItem::SMember> schema_members;
-
- schema_members["mandatory_auto_default_string"] =
- so::CObjectSchemaItem::SMember(so::CStringSchemaItem::create(100),
- true);
-
- schema_members["non_mandatory_auto_default_string"] =
- so::CObjectSchemaItem::SMember(so::CStringSchemaItem::create(100),
- false);
-
- schema_members["mandatory_manual_default_string"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- 0,
- 500,
- std::string("String")),
- true);
-
- schema_members["non_mandatory_manual_default_string"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- 0,
- 500,
- std::string("String")),
- false);
-
- schema_members["mandatory_auto_default_int"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<int>::create(
- 1, 200), true);
-
- schema_members["mandatory_manual_default_int"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<int>::create(
- 1, 20, 10), true);
-
- schema_members["non_mandatory_manual_default_int"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<int>::create(
- 1, 20, 10), false);
-
- schema_members["non_mandatory_auto_default_int"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<int>::create(
- 1, 200), false);
-
- schema_members["non_mandatory_auto_default_float"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<double>::create(
- 0.0, 100.0), false);
-
- schema_members["non_mandatory_manual_default_float"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<double>::create(
- 0.0, 100.0, 33.33), false);
-
- schema_members["mandatory_auto_default_float"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<double>::create(
- 0.0, 100.0), false);
-
- schema_members["mandatory_manual_default_float"] =
- so::CObjectSchemaItem::SMember(so::TNumberSchemaItem<double>::create(
- 0.0, 100.0, 33.33), false);
-
- schema_members["non_mandatory_auto_default_bool"] =
- so::CObjectSchemaItem::SMember(so::CBoolSchemaItem::create(), false);
-
- schema_members["non_mandatory_manual_default_bool"] =
- so::CObjectSchemaItem::SMember(so::CBoolSchemaItem::create(true),
- false);
-
- schema_members["mandatory_auto_default_bool"] =
- so::CObjectSchemaItem::SMember(so::CBoolSchemaItem::create(), true);
-
- schema_members["mandatory_manual_default_bool"] =
- so::CObjectSchemaItem::SMember(so::CBoolSchemaItem::create(true),
- true);
-
- schema_members["mandatory_auto_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(
- message_type_items),
- true);
-
- schema_members["mandatory_manual_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(
- message_type_items,
- messageType::request),
- true);
-
- schema_members["non_mandatory_auto_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(
- message_type_items),
- false);
-
- schema_members["non_mandatory_manual_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(
- message_type_items,
- messageType::request),
- false);
-
- schema_members["non_mandatory_struct"] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- test_struct_members), false);
-
- schema_members["mandatory_struct"] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- test_struct_members), true);
-
- schema_members["mandatory_struct_nm"] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- test_non_mandatory_struct_members), true);
-
- schema_members["non_mandatory_struct_nm"] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- test_non_mandatory_struct_members), false);
-
- schema_members["non_mandatory_non_empty_array"] =
- so::CObjectSchemaItem::SMember(so::CArraySchemaItem::create(
- so::TNumberSchemaItem<int>::create()), false);
-
- schema_members["mandatory_empty_array"] =
- so::CObjectSchemaItem::SMember(so::CArraySchemaItem::create(
- so::TNumberSchemaItem<int>::create(0, 0, 0)), true);
-
- schema_members["mandatory_empty_map"] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- std::map<std::string, so::CObjectSchemaItem::SMember>()), true);
-
- schema_members["non_mandatory_empty_map"] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- std::map<std::string, so::CObjectSchemaItem::SMember>()), false);
-
- std::map<std::string, so::CObjectSchemaItem::SMember>
- function_params_members;
-
- function_params_members[S_FUNCTION_ID] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<FunctionID::eType>::create(function_id_items),
- true);
- function_params_members[S_MESSAGE_TYPE] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(
- message_type_items), true);
- function_params_members[S_CORRELATION_ID] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(), true);
- function_params_members[S_PROTOCOL_VERSION] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(), true);
- function_params_members[S_PROTOCOL_TYPE] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(), true);
-
- std::map<std::string, so::CObjectSchemaItem::SMember>
- functiom_root_members;
-
- functiom_root_members[S_MSG_PARAMS] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- schema_members), true);
- functiom_root_members[S_PARAMS] =
- so::CObjectSchemaItem::SMember(so::CObjectSchemaItem::create(
- function_params_members), true);
-
- so::CSmartSchema function_schema(
- so::CObjectSchemaItem::create(functiom_root_members));
-
- std::string expected_result1(
- "{\n"
- " \"-1\" : {\n"
- " \"correlationID\" : 0,\n"
- " \"name\" : \"-1\",\n"
- " \"parameters\" : {\n"
- " \"mandatory_auto_default_bool\" : false,\n"
- " \"mandatory_auto_default_enum\" : -1,\n"
- " \"mandatory_auto_default_int\" : 0,\n"
- " \"mandatory_auto_default_string\" : \"\",\n"
- " \"mandatory_empty_array\" : [],\n"
- " \"mandatory_empty_map\" : {},\n"
- " \"mandatory_manual_default_bool\" : true,\n"
- " \"mandatory_manual_default_enum\" : \"request\",\n"
- " \"mandatory_manual_default_int\" : 10,\n"
- " \"mandatory_manual_default_string\" : \"String\",\n"
- " \"mandatory_struct\" : {\n"
- " \"mandatory_int_field\" : 15,\n"
- " \"mandatory_string_field\" : \"Mandatory text\"\n"
- " },\n"
- " \"mandatory_struct_nm\" : {}\n"
- " }\n"
- " }\n"
- "}\n");
-
- error_code = FormatterV1::MetaFormatToString(empty_object,
- function_schema,
- result);
-
- ASSERT_EQ(expected_result1, result) <<
- "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must not be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid schema";
-
- so::SmartObject function_object(so::SmartType_Map);
-
- function_object[S_PARAMS][S_MESSAGE_TYPE] = messageType::response;
- function_object[S_PARAMS][S_FUNCTION_ID] =
- FunctionID::RegisterAppInterface;
- function_object[S_PARAMS][S_PROTOCOL_VERSION] = 13;
-
- std::string expected_result2(
- "{\n"
- " \"response\" : {\n"
- " \"correlationID\" : 0,\n"
- " \"name\" : \"RegisterAppInterface\",\n"
- " \"parameters\" : {\n"
- " \"mandatory_auto_default_bool\" : false,\n"
- " \"mandatory_auto_default_enum\" : -1,\n"
- " \"mandatory_auto_default_int\" : 0,\n"
- " \"mandatory_auto_default_string\" : \"\",\n"
- " \"mandatory_empty_array\" : [],\n"
- " \"mandatory_empty_map\" : {},\n"
- " \"mandatory_manual_default_bool\" : true,\n"
- " \"mandatory_manual_default_enum\" : \"request\",\n"
- " \"mandatory_manual_default_int\" : 10,\n"
- " \"mandatory_manual_default_string\" : \"String\",\n"
- " \"mandatory_struct\" : {\n"
- " \"mandatory_int_field\" : 15,\n"
- " \"mandatory_string_field\" : \"Mandatory text\"\n"
- " },\n"
- " \"mandatory_struct_nm\" : {}\n"
- " }\n"
- " }\n"
- "}\n");
-
- error_code = FormatterV1::MetaFormatToString(function_object,
- function_schema,
- result);
-
- ASSERT_EQ(expected_result2, result) <<
- "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must not be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid schema";
-
- function_object[S_MSG_PARAMS]["non_schema_int_field"] = 13;
- function_object[S_MSG_PARAMS]["non_schema_string_field"] = "xxx";
- function_object[S_PARAMS]["Noise"] = "bzzzz";
-
- error_code = FormatterV1::MetaFormatToString(function_object,
- function_schema,
- result);
-
- ASSERT_EQ(expected_result2, result) <<
- "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_FALSE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid schema";
-
- function_object[S_MSG_PARAMS]["mandatory_auto_default_int"] = 25;
- function_object[S_MSG_PARAMS]["non_mandatory_auto_default_int"] = 100;
- function_object[S_MSG_PARAMS]["non_mandatory_struct_nm"]
- ["non_mandatory_int_field"] = 3;
- function_object[S_MSG_PARAMS]["mandatory_empty_map"]["x"] = 0;
- function_object[S_MSG_PARAMS]["mandatory_empty_map"]["y"] = 0;
- function_object[S_MSG_PARAMS]["non_mandatory_non_empty_array"][0] = 1;
- function_object[S_MSG_PARAMS]["non_mandatory_non_empty_array"][1] = 2;
- function_object[S_MSG_PARAMS]["non_mandatory_non_empty_array"][2] = 3;
- function_object[S_MSG_PARAMS]["mandatory_empty_array"][0] = 0;
- function_object[S_MSG_PARAMS]["mandatory_empty_array"][1] = 1;
- function_object[S_MSG_PARAMS]["mandatory_empty_array"][2] = 2;
-
- std::string expected_result3(
- "{\n"
- " \"response\" : {\n"
- " \"correlationID\" : 0,\n"
- " \"name\" : \"RegisterAppInterface\",\n"
- " \"parameters\" : {\n"
- " \"mandatory_auto_default_bool\" : false,\n"
- " \"mandatory_auto_default_enum\" : -1,\n"
- " \"mandatory_auto_default_int\" : 25,\n"
- " \"mandatory_auto_default_string\" : \"\",\n"
- " \"mandatory_empty_array\" : [ 0, 1, 2 ],\n"
- " \"mandatory_empty_map\" : {},\n"
- " \"mandatory_manual_default_bool\" : true,\n"
- " \"mandatory_manual_default_enum\" : \"request\",\n"
- " \"mandatory_manual_default_int\" : 10,\n"
- " \"mandatory_manual_default_string\" : \"String\",\n"
- " \"mandatory_struct\" : {\n"
- " \"mandatory_int_field\" : 15,\n"
- " \"mandatory_string_field\" : \"Mandatory text\"\n"
- " },\n"
- " \"mandatory_struct_nm\" : {},\n"
- " \"non_mandatory_auto_default_int\" : 100,\n"
- " \"non_mandatory_non_empty_array\" : [ 1, 2, 3 ],\n"
- " \"non_mandatory_struct_nm\" : {\n"
- " \"non_mandatory_int_field\" : 3\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n");
-
- error_code = FormatterV1::MetaFormatToString(function_object,
- function_schema,
- result);
-
- ASSERT_EQ(expected_result3, result) <<
- "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code) <<
- "Result must not be OK in such case";
-
- ASSERT_FALSE(mf::kErrorObjectIsNotFunction & error_code) <<
- "Object must be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code) <<
- "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code) <<
- "This creation shold not fail because of valid schema";
- }
-}}}}
-
-namespace NsSmartDeviceLink { namespace NsSmartObjects {
-
- template <>
- const std::map<test::components::json_handler::formatters::FunctionID::eType, std::string> &
- NsSmartDeviceLink::NsSmartObjects::TEnumSchemaItem<test::components::json_handler::formatters::FunctionID::eType>::getEnumElementsStringRepresentation(void)
- {
- static bool isInitialized = false;
- static std::map<test::components::json_handler::formatters::FunctionID::eType, std::string> enumStringRepresentationMap;
-
- if (false == isInitialized)
- {
- enumStringRepresentationMap.insert(std::make_pair(test::components::json_handler::formatters::FunctionID::RegisterAppInterface, "RegisterAppInterface"));
- enumStringRepresentationMap.insert(std::make_pair(test::components::json_handler::formatters::FunctionID::UnregisterAppInterface, "UnregisterAppInterface"));
- enumStringRepresentationMap.insert(std::make_pair(test::components::json_handler::formatters::FunctionID::SetGlobalProperties, "SetGlobalProperties"));
-
- isInitialized = true;
- }
-
- return enumStringRepresentationMap;
- }
-
- template <>
- const std::map<test::components::json_handler::formatters::messageType::eType, std::string> &
- NsSmartDeviceLink::NsSmartObjects::TEnumSchemaItem<test::components::json_handler::formatters::messageType::eType>::getEnumElementsStringRepresentation(void)
- {
- static bool isInitialized = false;
- static std::map<test::components::json_handler::formatters::messageType::eType, std::string> enumStringRepresentationMap;
-
- if (false == isInitialized)
- {
- enumStringRepresentationMap.insert(std::make_pair(test::components::json_handler::formatters::messageType::request, "request"));
- enumStringRepresentationMap.insert(std::make_pair(test::components::json_handler::formatters::messageType::response, "response"));
- enumStringRepresentationMap.insert(std::make_pair(test::components::json_handler::formatters::messageType::notification, "notification"));
-
- isInitialized = true;
- }
-
- return enumStringRepresentationMap;
- }
-}}
-
-/*int main(int argc, char **argv)
-{
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}*/
-
-#endif // TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_ALRPCV1_TEST_H_
diff --git a/test/components/json_handler/include/json_handler/formatter_json_alrpcv2_test.h b/test/components/json_handler/include/json_handler/formatter_json_alrpcv2_test.h
deleted file mode 100644
index e9fa1a59d..000000000
--- a/test/components/json_handler/include/json_handler/formatter_json_alrpcv2_test.h
+++ /dev/null
@@ -1,114 +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 TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_ALRPCV2_TEST_H_
-#define TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_ALRPCV2_TEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <iostream>
-
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-#include "formatters/CSmartFactory.hpp"
-
-#include "json/json.h"
-
-#include "formatter_test_helper.h"
-
-namespace test { namespace components { namespace json_handler { namespace formatters {
-
- using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-
- TEST_F(CFormatterTestHelper, test_fromObjToALRPCv2AndBack)
- {
- Json::Value value; // just a quick workaround to avoid undefined reference to Json
-
- std::string str;
- NsSmartDeviceLink::NsSmartObjects::SmartObject srcObj;
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj;
-
- fillTestObject(srcObj);
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
-
- // SmartObjects --> JSON
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::toString(srcObj, str);
-
- //std::cout << str << std::endl;
-
- // JSON --> SmartObjects
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::
- fromString<std::string, std::string>(str, dstObj, "some function", "request", 12);
-
-
- compareObjects(srcObj, dstObj);
- }
-
- TEST_F(CFormatterTestHelper, test_fromJsonALRPCv2)
- {
- std::string str = "\
- {\
- \"appID\": \"APP ID\",\
- \"appName\": \"APP NAME\",\
- \"appType\": [\"SYSTEM\", \"COMMUNICATION\"],\
- \"hmiDisplayLanguageDesired\": \"RU-RU\",\
- \"isMediaApplication\": true,\
- \"languageDesired\": \"EN-US\",\
- \"ngnMediaScreenAppName\": \"SCREEN NAME\",\
- \"syncMsgVersion\": {\
- \"majorVersion\": 2,\
- \"minorVersion\": 10\
- },\
- \"ttsName\": [{\
- \"text\": \"ABC\",\
- \"type\": \"TEXT\"\
- }],\
- \"vrSynonyms\": [\"Synonym 1\", \"Synonym 2\"]\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- bool result;
-
- result = NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::
- fromString<std::string, std::string>(str, obj, "some name", "request", 12);
-
- ASSERT_TRUE(result) << "Error parsing JSON string";
-
- ASSERT_EQ("some name", obj[S_PARAMS][S_FUNCTION_ID].asString());
- ASSERT_EQ(12, obj[S_PARAMS][S_CORRELATION_ID].asInt());
- ASSERT_EQ(2, obj[S_PARAMS][S_PROTOCOL_VERSION].asInt());
- ASSERT_EQ(10, obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"].asInt());
- ASSERT_EQ("TEXT", obj[S_MSG_PARAMS]["ttsName"][0]["type"].asString());
- ASSERT_EQ("Synonym 2", obj[S_MSG_PARAMS]["vrSynonyms"][1].asString());
- }
-
-}}}}
-
-#endif // TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_ALRPCV2_TEST_H_
diff --git a/test/components/json_handler/include/json_handler/formatter_json_rpcv2_test.h b/test/components/json_handler/include/json_handler/formatter_json_rpcv2_test.h
deleted file mode 100644
index 4472282f9..000000000
--- a/test/components/json_handler/include/json_handler/formatter_json_rpcv2_test.h
+++ /dev/null
@@ -1,96 +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 TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_RPCV2_TEST_H_
-#define TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_RPCV2_TEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <iostream>
-
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-
-#include "json/json.h"
-
-
-
-namespace test { namespace components { namespace JSONHandler { namespace formatters {
-
- TEST(test_SimpleTwoWaysTest, test_JsonRPC2)
- {
- Json::Value value; // just a quick workaround to avoid undefined reference to Json
- Json::Reader reader; // the same thing
-
- std::string str;
- NsSmartDeviceLink::NsSmartObjects::SmartObject srcObj;
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj;
-
- // TODO: Implement test on valid RPC2 test data
-
- srcObj["params"]["MessageType"] = 0;
- srcObj["params"]["FunctionId"] = 0;
- srcObj["msg_params"]["appId"] = "APP ID";
- srcObj["msg_params"]["appName"] = "APP NAME";
- srcObj["msg_params"]["appType"][0] = "SYSTEM";
- srcObj["msg_params"]["appType"][1] = "COMMUNICATION";
- srcObj["msg_params"]["hmiDisplayLanguageDesired"] = "RU-RU";
- srcObj["msg_params"]["isMediaApplication"] = true;
- srcObj["msg_params"]["languageDesired"] = "EN-US";
- srcObj["msg_params"]["ngnMediaScreenAppName"] = "SCREEN NAME";
- srcObj["msg_params"]["syncMsgVersion"]["majorVersion"] = 2;
- srcObj["msg_params"]["syncMsgVersion"]["minorVersion"] = 10;
- srcObj["msg_params"]["ttsName"][0]["text"] = "ABC";
- srcObj["msg_params"]["ttsName"][0]["type"] = "TEXT";
- srcObj["msg_params"]["vrSynonyms"][0] = "Synonym1";
- srcObj["msg_params"]["vrSynonyms"][1] = "Synonym2";
- // srcObj["msg_params"]["null"] = NsSmartDeviceLink::NsSmartObjects::SmartObject();
- // srcObj["msg_params"]["double"] = -0.1234;
-
- // SmartObjects --> JSON
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::toString(srcObj, str);
-
- std::cout << str << std::endl;
-
- // JSON --> SmartObjects
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::fromString(str, dstObj, 0, 0);
-
- // Compare SmartObjects
- ASSERT_EQ("APP NAME", dstObj["msg_params"]["appName"].asString());
- ASSERT_EQ(10, dstObj["msg_params"]["syncMsgVersion"]["minorVersion"].asInt());
- ASSERT_EQ("TEXT", dstObj["msg_params"]["ttsName"][0]["type"].asString());
- ASSERT_TRUE(dstObj["msg_params"]["isMediaApplication"].asBool());
-
- ASSERT_TRUE(srcObj == dstObj); // High level comparison
- }
-
-}}}}
-
-#endif // TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_JSON_RPCV2_TEST_H_
diff --git a/test/components/json_handler/include/json_handler/formatter_test_helper.h b/test/components/json_handler/include/json_handler/formatter_test_helper.h
deleted file mode 100644
index 98fae2ecd..000000000
--- a/test/components/json_handler/include/json_handler/formatter_test_helper.h
+++ /dev/null
@@ -1,55 +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 TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_TEST_HELPER_H_
-#define TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_TEST_HELPER_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-
-namespace test { namespace components { namespace json_handler { namespace formatters {
-
-
- class CFormatterTestHelper : public ::testing::Test
- {
- public:
- static void fillTestObject(NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
-
- //bool checkTestObject(const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
-
- static void compareObjects(const NsSmartDeviceLink::NsSmartObjects::SmartObject& first,
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& second);
- };
-
-}}}}
-
-#endif // TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_FORMATTERS_FORMATTER_TEST_HELPER_H_
diff --git a/test/components/json_handler/include/json_handler/meta_formatter_test_helper.h b/test/components/json_handler/include/json_handler/meta_formatter_test_helper.h
deleted file mode 100644
index 846fae7fa..000000000
--- a/test/components/json_handler/include/json_handler/meta_formatter_test_helper.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- * @file meta_formatter_test_helper.h
- * @brief file describes class CMetaFormatterTestHelper which is designed to
- * create test environemnt to test class CMetaFormatter
- */
-// 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 __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS_METAFORMATTERTESTHELPER_H__
-#define __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS_METAFORMATTERTESTHELPER_H__
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "test/components/json_handler/test_JSONHandler_v4_protocol_v2_0_revP.h"
-#include "test/components/json_handler/test_JSONHandler_v4_protocol_v2_0_revP_schema.h"
-
-#include "smart_objects/smart_object.h"
-
-namespace generated_ns = Gen::test::components::JSONHandler2;
-
-namespace test {
-namespace components {
-namespace JSONHandler {
-namespace formatters {
-
-namespace function_id {
-/**
- * @brief Enumeration function_id.
- *
- * Enumeration linking function names with function IDs in WiPro protocol.
- * Assumes enumeration starts at value 0.
- */
-enum EType {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief RegisterAppInterface.
- */
- kRegisterAppInterfaceID,
-
- /**
- * @brief UnregisterAppInterface.
- */
- kUnregisterAppInterfaceID,
-
- /**
- * @brief SetGlobalProperties.
- */
- kSetGlobalPropertiesID,
-};
-}
-
-namespace message_type {
-/**
- * @brief Enumeration message_type.
- *
- * Enumeration linking message types with function types in WiPro protocol.
- * Assumes enumeration starts at value 0.
- */
-enum EType {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief request.
- */
- kRequest = 0,
-
- /**
- * @brief response.
- */
- kResponse = 1,
-
- /**
- * @brief notification.
- */
- kNotification = 2
-};
-}
-
-class CMetaFormatterTestHelper :public ::testing::Test {
- protected:
-
- virtual void SetUp();
-
- virtual void TearDown();
-
- void AnyObjectToJsonString(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
- std::string& result_string);
-
- // for message_type::request, function_id::RegisterAppInterfaceID
- void FillObjectIdenticalToSchema(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
-
- // for message_type::request, function_id::RegisterAppInterfaceID
- void FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
-
- void CompareObjects(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& first,
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& second);
-
- // for message_type::request, function_id::RegisterAppInterfaceID
- void FillObjectWithDefaultValues(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
-
- void FillObjectWithoutSomeMandatoryFields(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj);
-
- // members
- generated_ns::test_JSONHandler_v4_protocol_v2_0_revP factory_;
- std::set<function_id::EType> function_id_items_;
- std::set<message_type::EType> message_type_items_;
-
- static const bool kIsPrintOut = false;
-};
-
-}
-}
-}
-}
-
-#endif // __SMARTDEVICELINKCORE_JSONHANDLER_FORMATTERS_METAFORMATTERTESTHELPER_H__
diff --git a/test/components/json_handler/include/json_handler/smart_schema_draft_test.h b/test/components/json_handler/include/json_handler/smart_schema_draft_test.h
deleted file mode 100644
index 1604c8cd0..000000000
--- a/test/components/json_handler/include/json_handler/smart_schema_draft_test.h
+++ /dev/null
@@ -1,307 +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 TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_SMART_SCHEMA_DRAFT_TEST_H_
-#define TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_SMART_SCHEMA_DRAFT_TEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <string>
-#include <iostream>
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-#include "test/components/json_handler/test_JSONHandler_v4_protocol_v2_0_revP_schema.h"
-
-using namespace Gen::test::components::JSONHandler2;
-using namespace NsSmartDeviceLink::NsSmartObjects;
-using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-using namespace NsSmartDeviceLink::NsJSONHandler::Formatters;
-
-namespace test { namespace components { namespace json_handler { namespace smart_schema_draft_test {
-
- TEST(test_general, test_SmartSchemaDraftTest)
- {
- bool bResult = false;
-
- // STEP 1. Getting object from string
- std::string inputJsonString = "{\
- \"appID\" : \"APP ID\",\
- \"appName\" : \"MY AMAZING APP NAME\",\
- \"appType\" : [ \"SYSTEM\", \"COMMUNICATION\" ],\
- \"isMediaApplication\" : true,\
- \"languageDesired\" : \"DE-EU\",\
- \"hmiDisplayLanguageDesired\" : \"RU-RU\",\
- \"ngnMediaScreenAppName\" : \"SCREEN NAME\",\
- \"syncMsgVersion\" : {\
- \"majorVersion\" : 2,\
- \"minorVersion\" : 10\
- },\
- \"ttsName\" : [\
- {\
- \"text\" : \"ABC\",\
- \"type\" : \"PRE_RECORDED\"\
- }\
- ],\
- \"vrSynonyms\" : [ \"Synonym1\", \"Synonym2\" ]\
- }\
- ";
-
- SmartObject obj;
- bResult = CFormatterJsonSDLRPCv2::fromString<FunctionID::eType, messageType::eType>(inputJsonString, obj, FunctionID::RegisterAppInterfaceID, messageType::request, 1);
- ASSERT_TRUE(bResult);
-
- ASSERT_EQ(FunctionID::RegisterAppInterfaceID, obj[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- //std::cout<<"TTS:"<<static_cast<std::string>(obj["msg_params"]["ttsName"][0]["type"])<<std::endl;
- // While fromString is not fully complete yet
- //obj["params"]["msg_type"] = messageType::request;
- //obj["params"]["function_id"] = FunctionID::RegisterAppInterfaceID;
-
- //obj["msg_params"]["appId"] = "APP ID";
- //obj["msg_params"]["appName"] = "APP NAME";
- //obj["msg_params"]["appType"][0] = "SYSTEM";
- //obj["msg_params"]["appType"][1] = "COMMUNICATION";
- //obj["msg_params"]["hmiDisplayLanguageDesired"] = "RU-RU";
- //obj["msg_params"]["isMediaApplication"] = true;
- //obj["msg_params"]["languageDesired"] = "EN-US";
- //obj["msg_params"]["ngnMediaScreenAppName"] = "SCREEN NAME";
- //obj["msg_params"]["syncMsgVersion"]["majorVersion"] = 2;
- //obj["msg_params"]["syncMsgVersion"]["minorVersion"] = 10;
- //obj["msg_params"]["ttsName"][0]["text"] = "ABC";
- //obj["msg_params"]["ttsName"][0]["type"] = "TEXT";
- //obj["msg_params"]["vrSynonyms"][0] = "Synonym1";
- //obj["msg_params"]["vrSynonyms"][1] = "Synonym2";
-
- // STEP 2. Attaching schema to object
- test_JSONHandler_v4_protocol_v2_0_revP factory;
-
- bResult = factory.attachSchema(obj);
- ASSERT_TRUE(bResult);
-
- // STEP 3. Validating object
- ASSERT_TRUE(obj.isValid());
-
- // STEP 4. Working with object
- obj[S_PARAMS][S_MESSAGE_TYPE] = messageType::notification;
- obj[S_MSG_PARAMS]["appName"] = "NEW APP NAME";
-
- // STEP 5. Validating object
- ASSERT_TRUE(obj.isValid());
-
- // STEP 6. Converting object to json string
-
- std::string outputJsonString;
- bResult = CFormatterJsonSDLRPCv2::toString(obj, outputJsonString);
- ASSERT_TRUE(bResult);
-
- std::string expectedOutputJsonString = "{\
- \"appID\" : \"APP ID\",\
- \"appName\" : \"NEW APP NAME\",\
- \"appType\" : [ 9, 1 ],\
- \"isMediaApplication\" : true,\
- \"languageDesired\" : \"DE-EU\",\
- \"hmiDisplayLanguageDesired\" : \"RU-RU\",\
- \"ngnMediaScreenAppName\" : \"SCREEN NAME\",\
- \"syncMsgVersion\" : {\
- \"majorVersion\" : 2,\
- \"minorVersion\" : 10\
- },\
- \"ttsName\" : [\
- {\
- \"text\" : \"ABC\",\
- \"type\" : \"PRE_RECORDED\"\
- }\
- ],\
- \"vrSynonyms\" : [ \"Synonym1\", \"Synonym2\" ]\
- }\
- ";
-
- //ASSERT_EQ(inputJsonString, outputJsonString);
-
- //std::cout<<outputJsonString<<std::endl;
- }
-
- TEST(test_general, test_AttachSchema) {
- SmartObject object(SmartType_Map);
- test_JSONHandler_v4_protocol_v2_0_revP factory;
-
- ASSERT_FALSE(factory.AttachSchema(StructIdentifiers::INVALID_ENUM,
- object));
-
- ASSERT_TRUE(factory.AttachSchema(StructIdentifiers::TextField,
- object));
-
- // Valid TextField object
- object["name"] = TextFieldName::mainField1;
- object["characterSet"] = CharacterSet::TYPE2SET;
- object["width"] = 100;
- object["rows"] = 2;
-
- ASSERT_TRUE(object.isValid());
-
- // Invalid value range for TextField
- object["rows"] = 20;
-
- ASSERT_FALSE(object.isValid());
-
- object["rows"] = 2;
- // Add unexpected field
- object["xxx"] = 1234;
-
- ASSERT_FALSE(object.isValid());
- }
-
- TEST(test_general, test_SmartObjectCreation) {
- test_JSONHandler_v4_protocol_v2_0_revP factory;
-
- SmartObject object = factory.CreateSmartObject(
- StructIdentifiers::INVALID_ENUM);
-
- ASSERT_EQ(SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(
- FunctionID::INVALID_ENUM,
- messageType::INVALID_ENUM);
-
- ASSERT_EQ(SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(
- FunctionID::RegisterAppInterfaceID,
- messageType::INVALID_ENUM);
-
- ASSERT_EQ(SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(
- FunctionID::INVALID_ENUM,
- messageType::response);
-
- ASSERT_EQ(SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(StructIdentifiers::Image);
-
- ASSERT_EQ(SmartType_Map, object.getType());
-
- object["value"] = "xxx";
- object["imageType"] = ImageType::STATIC;
-
- ASSERT_TRUE(object.isValid());
-
- object["zzz"] = "yyy";
-
- ASSERT_FALSE(object.isValid());
-
- object = factory.CreateSmartObject(FunctionID::AddSubMenuID,
- messageType::request);
-
- object[S_PARAMS][S_FUNCTION_ID] = FunctionID::AddSubMenuID;
- object[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
- object[S_PARAMS][S_CORRELATION_ID] = 0;
- object[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- object[S_PARAMS][S_PROTOCOL_TYPE] = 111;
- object[S_MSG_PARAMS]["menuID"] = 10;
- object[S_MSG_PARAMS]["position"] = 20;
- object[S_MSG_PARAMS]["menuName"] = "MenuItem";
-
- ASSERT_TRUE(object.isValid());
-
- object[S_MSG_PARAMS]["Noise"] = "Bzzzzzz!!!";
-
- ASSERT_FALSE(object.isValid());
- }
-
- TEST(test_general, test_GetSmartSchema) {
- test_JSONHandler_v4_protocol_v2_0_revP factory;
-
- CSmartSchema schema;
- ASSERT_FALSE(factory.GetSchema(StructIdentifiers::INVALID_ENUM,
- schema));
-
- ASSERT_FALSE(factory.GetSchema(FunctionID::INVALID_ENUM,
- messageType::INVALID_ENUM,
- schema));
-
- ASSERT_FALSE(factory.GetSchema(FunctionID::RegisterAppInterfaceID,
- messageType::INVALID_ENUM,
- schema));
-
- ASSERT_FALSE(factory.GetSchema(FunctionID::INVALID_ENUM,
- messageType::response,
- schema));
-
- ASSERT_TRUE(factory.GetSchema(StructIdentifiers::SyncMsgVersion,
- schema));
-
- SmartObject object(SmartType_Map);
- object.setSchema(schema);
-
- object["majorVersion"] = 1;
- object["minorVersion"] = 2;
-
- ASSERT_TRUE(object.isValid());
-
- object["majorVersion"] = 1000;
-
- ASSERT_FALSE(object.isValid());
-
- object["majorVersion"] = 1;
- object["zzzz"] = 200;
-
- ASSERT_FALSE(object.isValid());
-
- ASSERT_TRUE(factory.GetSchema(FunctionID::UnregisterAppInterfaceID,
- messageType::request,
- schema));
-
- object = SmartObject(SmartType_Map);
- object.setSchema(schema);
-
- object[S_PARAMS][S_FUNCTION_ID] = FunctionID::UnregisterAppInterfaceID;
- object[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
- object[S_PARAMS][S_CORRELATION_ID] = 22;
- object[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- object[S_PARAMS][S_PROTOCOL_TYPE] = 1;
- object[S_MSG_PARAMS] = SmartObject(SmartType_Map);
-
- ASSERT_TRUE(object.isValid());
-
- object[S_PARAMS]["blah-blah"] = "YouShallNotPass!";
-
- ASSERT_FALSE(object.isValid());
- }
-}}}}
-
-/*int main(int argc, char **argv) {
- //PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties"));
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}*/
-
-#endif // TEST_COMPONENTS_JSON_HANDLER_INCLUDE_JSON_HANDLER_SMART_SCHEMA_DRAFT_TEST_H_
diff --git a/test/components/json_handler/src/FormatterJsonSDLRPCv1Test.cpp b/test/components/json_handler/src/FormatterJsonSDLRPCv1Test.cpp
deleted file mode 100644
index 059f3601e..000000000
--- a/test/components/json_handler/src/FormatterJsonSDLRPCv1Test.cpp
+++ /dev/null
@@ -1,1090 +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.
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <iostream>
-
-#include "json/json.h"
-
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
-#include "formatters/CSmartFactory.hpp"
-
-#include "smart_objects/bool_schema_item.h"
-#include "smart_objects/array_schema_item.h"
-#include "smart_objects/object_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-#include "smart_objects/number_schema_item.h"
-#include "smart_objects/schema_item_parameter.h"
-
-#include "json_handler/formatter_test_helper.h"
-
-namespace test {
-namespace components {
-namespace json_handler {
-namespace formatters {
-
-// The code below is cut and paste from the generated code just to provide necessary environment for string <-> enum conversion.
-namespace FunctionID {
-/**
- * @brief Enumeration FunctionID.
- */
-enum eType {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief RegisterAppInterface.
- */
- RegisterAppInterface,
-
- /**
- * @brief UnregisterAppInterface.
- */
- UnregisterAppInterface,
-
- /**
- * @brief SetGlobalProperties.
- */
- SetGlobalProperties,
-
-// ...
-};
-}
-
-namespace messageType {
-/**
- * @brief Enumeration messageType.
- */
-enum eType {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief request.
- */
- request,
-
- /**
- * @brief response.
- */
- response,
-
- /**
- * @brief notification.
- */
- notification
-};
-}
-// end of cut and pasted code
-
-using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-typedef NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv1 FormatterV1;
-
-TEST_F(CFormatterTestHelper, test_fromObjToSDLRPCv1AndBack) {
- Json::Value value; // just a quick workaround to avoid undefined reference to Json
- Json::Reader reader; // the same thing
-
- std::string str;
- NsSmartDeviceLink::NsSmartObjects::SmartObject srcObj;
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj;
-
- fillTestObject(srcObj);
- srcObj[S_PARAMS][S_FUNCTION_ID] = "UnregisterAppInterface"; // a hack, it shouldn't be a string in the SmartObject
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = "request"; // the same thing
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
-
- // SmartObjects --> JSON
- FormatterV1::toString(srcObj, str);
-
- //std::cout << str << std::endl;
-
- // JSON --> SmartObjects
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str, dstObj);
-
- ASSERT_EQ(FormatterV1::kSuccess, result) << "Error parsing JSON string";
-
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionID::UnregisterAppInterface; // write the proper enum values
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
-
- compareObjects(srcObj, dstObj);
-}
-
-TEST_F(CFormatterTestHelper, test_fromJsonSDLRPCv1) {
- std::string str =
- "\
- {\
- \"request\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"syncMsgVersion\": \"version\",\
- \"appName\": \"some app name\",\
- \"ttsName\": [{\
- \"text\": \"ABC\",\
- \"type\": \"TEXT\"\
- }],\
- \"vrSynonyms\": [\"Synonym 1\", \"Synonym 2\"]\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str, obj);
-
- ASSERT_EQ(FormatterV1::kSuccess, result) << "Error parsing JSON string";
-
- ASSERT_EQ(FunctionID::SetGlobalProperties,
- obj[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj[S_PARAMS][S_MESSAGE_TYPE].asInt());
- ASSERT_EQ(11, obj[S_PARAMS][S_CORRELATION_ID].asInt());
- ASSERT_EQ("version", obj[S_MSG_PARAMS]["syncMsgVersion"].asString());
- ASSERT_EQ("some app name", obj[S_MSG_PARAMS]["appName"].asString());
- ASSERT_EQ("some app name", obj[S_MSG_PARAMS]["appName"].asString());
- ASSERT_EQ(1, obj[S_PARAMS][S_PROTOCOL_VERSION].asInt());
- ASSERT_EQ("TEXT", obj[S_MSG_PARAMS]["ttsName"][0]["type"].asString());
- ASSERT_EQ("Synonym 2", obj[S_MSG_PARAMS]["vrSynonyms"][1].asString());
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_ErrorParsing) {
- std::string str =
- "\
- {\
- \"request\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str, obj);
-
- ASSERT_TRUE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_TRUE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is not set";
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_MessageTypeError) {
- std::string str1 =
- "\
- {\
- \"information\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_TRUE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is not set";
-
- std::string str2 =
- "\
- {\
- \"name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj2;
- result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str1,
- obj2);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_TRUE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is not set";
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_FunctionID_Error) {
- std::string str1 =
- "\
- {\
- \"request\": {\
- \"not a name\" : \"SetGlobalProperties\",\
- \"correlationID\": 11,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is not set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is set";
- ASSERT_EQ(11, obj1[S_PARAMS][S_CORRELATION_ID].asInt())
- << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- std::string str2 =
- "\
- {\
- \"request\": {\
- \"name\" : \"UnknownName\",\
- \"correlationID\": 12,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj2;
- result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str2,
- obj2);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is not set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is not set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is set";
- ASSERT_EQ(12, obj2[S_PARAMS][S_CORRELATION_ID].asInt())
- << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj2[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj2[S_PARAMS][S_MESSAGE_TYPE].asInt());
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_CorrelationID_Error) {
- std::string str1 =
- "\
- {\
- \"request\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"NotACorrelationID\": 13,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is set";
- ASSERT_FALSE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is not set";
- ASSERT_EQ(-1, obj1[S_PARAMS][S_CORRELATION_ID].asInt())
- << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::SetGlobalProperties,
- obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::request, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_CombinationError) {
- std::string str1 =
- "\
- {\
- \"response\": {\
- \"name\" : \"UnKnownName\",\
- \"NotACorrelationID\": 10,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is not set";
- ASSERT_TRUE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is not set";
- ASSERT_EQ(-1, obj1[S_PARAMS][S_CORRELATION_ID].asInt())
- << "Wrong CorrelationID";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::response, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_NotificationCorrelationId) {
- std::string str1 =
- "\
- {\
- \"notification\": {\
- \"name\" : \"SetGlobalProperties\",\
- \"NotACorrelationID\": 10,\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1;
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str1, obj1);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is set";
- ASSERT_FALSE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is set";
- ASSERT_FALSE(obj1[S_PARAMS].keyExists(S_CORRELATION_ID))
- << "CorrelationID field exists in SmartObject";
- ASSERT_EQ(FunctionID::SetGlobalProperties,
- obj1[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::notification, obj1[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- std::string str2 =
- "\
- {\
- \"notification\": {\
- \"name\" : \"UnknownNotification\",\
- \"parameters\": {\
- \"appName\": \"some app name\"\
- }\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj2;
- result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(str2,
- obj2);
-
- ASSERT_FALSE(FormatterV1::kParsingError & result) << "Wrong error code";
- ASSERT_FALSE(FormatterV1::kMessageTypeNotFound & result)
- << "MessageType error code is set";
- ASSERT_TRUE(FormatterV1::kFunctionIdNotFound & result)
- << "FunctionID error code is not set";
- ASSERT_FALSE(FormatterV1::kCorrelationIdNotFound & result)
- << "CorrelationID error code is set";
- ASSERT_FALSE(obj2[S_PARAMS].keyExists(S_CORRELATION_ID))
- << "CorrelationID field exists in SmartObject";
- ASSERT_EQ(FunctionID::INVALID_ENUM, obj2[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(messageType::notification, obj2[S_PARAMS][S_MESSAGE_TYPE].asInt());
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_EmptyMapArrayTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject srcObj, dstObj;
- std::string str;
-
- fillTestObject(srcObj);
- srcObj[S_PARAMS][S_FUNCTION_ID] = "UnregisterAppInterface"; // a hack, it shouldn't be a string in the SmartObject
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = "request"; // the same thing
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- srcObj[S_MSG_PARAMS]["EmptyArray"] = SmartObject(SmartType_Array);
- srcObj[S_MSG_PARAMS]["EmptyMap"] = SmartObject(SmartType_Map);
- srcObj[S_MSG_PARAMS]["AnotherEmptyArray"] =
- srcObj[S_MSG_PARAMS]["EmptyArray"];
- srcObj[S_MSG_PARAMS]["AnotherEmptyMap"] = srcObj[S_MSG_PARAMS]["EmptyMap"];
-
- // SmartObjects --> JSON
- FormatterV1::toString(srcObj, str);
-
- std::cout << str << std::endl;
-
- // JSON --> SmartObjects
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str, dstObj);
-
- ASSERT_EQ(FormatterV1::kSuccess, result) << "Error parsing JSON string";
-
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionID::UnregisterAppInterface; // write the proper enum values
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
-
- compareObjects(srcObj, dstObj);
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_NotificationTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject src_obj, dst_obj;
- std::string str;
-
- src_obj[S_PARAMS][S_FUNCTION_ID] = "SetGlobalProperties"; // a hack, it shouldn't be a string in the SmartObject
- src_obj[S_PARAMS][S_MESSAGE_TYPE] = "notification"; // the same thing
- src_obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- src_obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- src_obj[S_MSG_PARAMS]["appId"] = "APP ID";
- src_obj[S_MSG_PARAMS]["appName"] = "APP NAME";
- src_obj[S_MSG_PARAMS]["item"] = "value";
-
- // SmartObjects --> JSON
- FormatterV1::toString(src_obj, str);
-
- ASSERT_TRUE(str.find("correlation") == std::string::npos)
- << "CorrelationId is present in JSON string";
-
- // JSON --> SmartObjects
- int result = FormatterV1::fromString<FunctionID::eType, messageType::eType>(
- str, dst_obj);
-
- ASSERT_EQ(FormatterV1::kSuccess, result) << "Error parsing JSON string";
-
- src_obj[S_PARAMS][S_FUNCTION_ID] = FunctionID::SetGlobalProperties; // write the proper enum values
- src_obj[S_PARAMS][S_MESSAGE_TYPE] = messageType::notification;
-
- ASSERT_FALSE(dst_obj[S_PARAMS].keyExists(S_CORRELATION_ID))
- << "CorrelationID is present in SmartObject";
-
- compareObjects(src_obj, dst_obj);
-}
-
-namespace so = NsSmartDeviceLink::NsSmartObjects;
-namespace mf = NsSmartDeviceLink::NsJSONHandler::Formatters::meta_formatter_error_code;
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_MetaFormatToString_Empty) {
- std::string result;
- FormatterV1::tMetaFormatterErrorCode error_code;
-
- so::SmartObject empty_object;
- so::CSmartSchema empty_schema;
-
- error_code = FormatterV1::MetaFormatToString(empty_object, empty_schema,
- result);
-
- std::string expected_result("{\n"
- " \"\" : {\n"
- " \"name\" : \"\",\n"
- " \"parameters\" : \"\"\n"
- " }\n"
- "}\n");
-
- ASSERT_EQ(expected_result, result) << "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must be not be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid empty schema";
-
- so::SmartObject object(so::SmartType_Map);
-
- object["1"] = 1;
- object["2"] = "two";
- object["3"] = false;
-
- error_code = FormatterV1::MetaFormatToString(object, empty_schema, result);
-
- ASSERT_EQ(expected_result, result) << "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must be not be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid empty schema";
-
- so::SmartObject function_object(so::SmartType_Map);
-
- function_object[S_PARAMS][S_FUNCTION_ID] = FunctionID::UnregisterAppInterface;
- function_object[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
- function_object[S_MSG_PARAMS]["Some data"] = "Some data";
-
- error_code = FormatterV1::MetaFormatToString(function_object, empty_schema,
- result);
-
- ASSERT_EQ(expected_result, result) << "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_FALSE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid empty schema";
-
- std::map<std::string, so::CObjectSchemaItem::SMember> non_function_schema_members_map;
-
- non_function_schema_members_map["StringField"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- so::TSchemaItemParameter<size_t>(0),
- so::TSchemaItemParameter<size_t>(1000),
- so::TSchemaItemParameter<std::string>()),
- false);
- non_function_schema_members_map["IntField"] = so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(so::TSchemaItemParameter<int>(1),
- so::TSchemaItemParameter<int>(20),
- so::TSchemaItemParameter<int>(10)),
- true);
- non_function_schema_members_map["BoolField"] = so::CObjectSchemaItem::SMember(
- so::CBoolSchemaItem::create(so::TSchemaItemParameter<bool>()), true);
-
- so::CSmartSchema non_function_schema(
- so::CObjectSchemaItem::create(non_function_schema_members_map));
-
- error_code = FormatterV1::MetaFormatToString(empty_object,
- non_function_schema, result);
-
- ASSERT_EQ(expected_result, result) << "Unexpected result string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must not be detected as function";
-
- ASSERT_TRUE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema does not define a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid empty schema";
-}
-
-TEST_F(CFormatterTestHelper, test_SDLRPCv1_MetaFormatToString_Valid) {
- std::string result;
- FormatterV1::tMetaFormatterErrorCode error_code;
-
- so::SmartObject empty_object;
-
- std::set<FunctionID::eType> function_id_items;
- function_id_items.insert(FunctionID::RegisterAppInterface);
- function_id_items.insert(FunctionID::UnregisterAppInterface);
- function_id_items.insert(FunctionID::SetGlobalProperties);
-
- std::set<messageType::eType> message_type_items;
- message_type_items.insert(messageType::request);
- message_type_items.insert(messageType::response);
- message_type_items.insert(messageType::notification);
-
- std::map<std::string, so::CObjectSchemaItem::SMember> test_struct_members;
-
- test_struct_members["mandatory_int_field"] = so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(so::TSchemaItemParameter<int>(1),
- so::TSchemaItemParameter<int>(20),
- so::TSchemaItemParameter<int>(15)),
- true);
-
- test_struct_members["mandatory_string_field"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- so::TSchemaItemParameter<size_t>(0),
- so::TSchemaItemParameter<size_t>(500),
- so::TSchemaItemParameter<std::string>("Mandatory text")),
- true);
-
- test_struct_members["non_mandatory_string_field"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- so::TSchemaItemParameter<size_t>(0),
- so::TSchemaItemParameter<size_t>(500),
- so::TSchemaItemParameter<std::string>("Non-mandatory text")),
- false);
-
- std::map<std::string, so::CObjectSchemaItem::SMember> test_non_mandatory_struct_members;
-
- test_non_mandatory_struct_members["non_mandatory_int_field"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(so::TSchemaItemParameter<int>(1),
- so::TSchemaItemParameter<int>(20),
- so::TSchemaItemParameter<int>(15)),
- false);
-
- std::map<std::string, so::CObjectSchemaItem::SMember> schema_members;
-
- schema_members["mandatory_auto_default_string"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(so::TSchemaItemParameter<size_t>(100)),
- true);
-
- schema_members["non_mandatory_auto_default_string"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(so::TSchemaItemParameter<size_t>(100)),
- false);
-
- schema_members["mandatory_manual_default_string"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- so::TSchemaItemParameter<size_t>(0),
- so::TSchemaItemParameter<size_t>(500),
- so::TSchemaItemParameter<std::string>("String")),
- true);
-
- schema_members["non_mandatory_manual_default_string"] =
- so::CObjectSchemaItem::SMember(
- so::CStringSchemaItem::create(
- so::TSchemaItemParameter<size_t>(0),
- so::TSchemaItemParameter<size_t>(500),
- so::TSchemaItemParameter<std::string>("String")),
- false);
-
- schema_members["mandatory_auto_default_int"] = so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(so::TSchemaItemParameter<int>(1),
- so::TSchemaItemParameter<int>(200)),
- true);
-
- schema_members["mandatory_manual_default_int"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(so::TSchemaItemParameter<int>(1),
- so::TSchemaItemParameter<int>(20),
- so::TSchemaItemParameter<int>(10)),
- true);
-
- schema_members["non_mandatory_manual_default_int"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(so::TSchemaItemParameter<int>(1),
- so::TSchemaItemParameter<int>(20),
- so::TSchemaItemParameter<int>(10)),
- false);
-
- schema_members["non_mandatory_auto_default_int"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(
- so::TSchemaItemParameter<int>(1),
- so::TSchemaItemParameter<int>(200)),
- false);
-
- schema_members["non_mandatory_auto_default_float"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<double>::create(
- so::TSchemaItemParameter<double>(0.0),
- so::TSchemaItemParameter<double>(100.0)),
- false);
-
- schema_members["non_mandatory_manual_default_float"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<double>::create(
- so::TSchemaItemParameter<double>(0.0),
- so::TSchemaItemParameter<double>(100.0),
- so::TSchemaItemParameter<double>(33.33)),
- false);
-
- schema_members["mandatory_auto_default_float"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<double>::create(
- so::TSchemaItemParameter<double>(0.0),
- so::TSchemaItemParameter<double>(100.0)),
- false);
-
- schema_members["mandatory_manual_default_float"] =
- so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<double>::create(
- so::TSchemaItemParameter<double>(0.0),
- so::TSchemaItemParameter<double>(100.0),
- so::TSchemaItemParameter<double>(33.33)),
- false);
-
- schema_members["non_mandatory_auto_default_bool"] =
- so::CObjectSchemaItem::SMember(so::CBoolSchemaItem::create(), false);
-
- schema_members["non_mandatory_manual_default_bool"] =
- so::CObjectSchemaItem::SMember(
- so::CBoolSchemaItem::create(so::TSchemaItemParameter<bool>(true)),
- false);
-
- schema_members["mandatory_auto_default_bool"] =
- so::CObjectSchemaItem::SMember(so::CBoolSchemaItem::create(), true);
-
- schema_members["mandatory_manual_default_bool"] =
- so::CObjectSchemaItem::SMember(
- so::CBoolSchemaItem::create(so::TSchemaItemParameter<bool>(true)),
- true);
-
- schema_members["mandatory_auto_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(message_type_items),
- true);
-
- schema_members["mandatory_manual_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(
- message_type_items,
- so::TSchemaItemParameter<messageType::eType>(
- messageType::request)),
- true);
-
- schema_members["non_mandatory_auto_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(message_type_items),
- false);
-
- schema_members["non_mandatory_manual_default_enum"] =
- so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(
- message_type_items,
- so::TSchemaItemParameter<messageType::eType>(
- messageType::request)),
- false);
-
- schema_members["non_mandatory_struct"] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(test_struct_members), false);
-
- schema_members["mandatory_struct"] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(test_struct_members), true);
-
- schema_members["mandatory_struct_nm"] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(test_non_mandatory_struct_members), true);
-
- schema_members["non_mandatory_struct_nm"] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(test_non_mandatory_struct_members), false);
-
- schema_members["non_mandatory_non_empty_array"] =
- so::CObjectSchemaItem::SMember(
- so::CArraySchemaItem::create(so::TNumberSchemaItem<int>::create()),
- false);
-
- schema_members["mandatory_empty_array"] = so::CObjectSchemaItem::SMember(
- so::CArraySchemaItem::create(
- so::TNumberSchemaItem<int>::create(so::TSchemaItemParameter<int>(0),
- so::TSchemaItemParameter<int>(0),
- so::TSchemaItemParameter<int>(0))),
- true);
-
- schema_members["mandatory_empty_map"] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(
- std::map<std::string, so::CObjectSchemaItem::SMember>()),
- true);
-
- schema_members["non_mandatory_empty_map"] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(
- std::map<std::string, so::CObjectSchemaItem::SMember>()),
- false);
-
- std::map<std::string, so::CObjectSchemaItem::SMember> function_params_members;
-
- function_params_members[S_FUNCTION_ID] = so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<FunctionID::eType>::create(function_id_items), true);
- function_params_members[S_MESSAGE_TYPE] = so::CObjectSchemaItem::SMember(
- so::TEnumSchemaItem<messageType::eType>::create(message_type_items),
- true);
- function_params_members[S_CORRELATION_ID] = so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(), true);
- function_params_members[S_PROTOCOL_VERSION] = so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(), true);
- function_params_members[S_PROTOCOL_TYPE] = so::CObjectSchemaItem::SMember(
- so::TNumberSchemaItem<int>::create(), true);
-
- std::map<std::string, so::CObjectSchemaItem::SMember> functiom_root_members;
-
- functiom_root_members[S_MSG_PARAMS] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(schema_members), true);
- functiom_root_members[S_PARAMS] = so::CObjectSchemaItem::SMember(
- so::CObjectSchemaItem::create(function_params_members), true);
-
- so::CSmartSchema function_schema(
- so::CObjectSchemaItem::create(functiom_root_members));
-
- std::string expected_result1(
- "{\n"
- " \"-1\" : {\n"
- " \"correlationID\" : 0,\n"
- " \"name\" : \"-1\",\n"
- " \"parameters\" : {\n"
- " \"mandatory_auto_default_bool\" : false,\n"
- " \"mandatory_auto_default_enum\" : -1,\n"
- " \"mandatory_auto_default_int\" : 0,\n"
- " \"mandatory_auto_default_string\" : \"\",\n"
- " \"mandatory_empty_array\" : [],\n"
- " \"mandatory_empty_map\" : {},\n"
- " \"mandatory_manual_default_bool\" : true,\n"
- " \"mandatory_manual_default_enum\" : \"request\",\n"
- " \"mandatory_manual_default_int\" : 10,\n"
- " \"mandatory_manual_default_string\" : \"String\",\n"
- " \"mandatory_struct\" : {\n"
- " \"mandatory_int_field\" : 15,\n"
- " \"mandatory_string_field\" : \"Mandatory text\"\n"
- " },\n"
- " \"mandatory_struct_nm\" : {}\n"
- " }\n"
- " }\n"
- "}\n");
-
- error_code = FormatterV1::MetaFormatToString(empty_object, function_schema,
- result);
-
- ASSERT_EQ(expected_result1, result) << "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must not be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid schema";
-
- so::SmartObject function_object(so::SmartType_Map);
-
- function_object[S_PARAMS][S_MESSAGE_TYPE] = messageType::response;
- function_object[S_PARAMS][S_FUNCTION_ID] = FunctionID::RegisterAppInterface;
- function_object[S_PARAMS][S_PROTOCOL_VERSION] = 13;
-
- std::string expected_result2(
- "{\n"
- " \"response\" : {\n"
- " \"correlationID\" : 0,\n"
- " \"name\" : \"RegisterAppInterface\",\n"
- " \"parameters\" : {\n"
- " \"mandatory_auto_default_bool\" : false,\n"
- " \"mandatory_auto_default_enum\" : -1,\n"
- " \"mandatory_auto_default_int\" : 0,\n"
- " \"mandatory_auto_default_string\" : \"\",\n"
- " \"mandatory_empty_array\" : [],\n"
- " \"mandatory_empty_map\" : {},\n"
- " \"mandatory_manual_default_bool\" : true,\n"
- " \"mandatory_manual_default_enum\" : \"request\",\n"
- " \"mandatory_manual_default_int\" : 10,\n"
- " \"mandatory_manual_default_string\" : \"String\",\n"
- " \"mandatory_struct\" : {\n"
- " \"mandatory_int_field\" : 15,\n"
- " \"mandatory_string_field\" : \"Mandatory text\"\n"
- " },\n"
- " \"mandatory_struct_nm\" : {}\n"
- " }\n"
- " }\n"
- "}\n");
-
- error_code = FormatterV1::MetaFormatToString(function_object, function_schema,
- result);
-
- ASSERT_EQ(expected_result2, result) << "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_TRUE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must not be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid schema";
-
- function_object[S_MSG_PARAMS]["non_schema_int_field"] = 13;
- function_object[S_MSG_PARAMS]["non_schema_string_field"] = "xxx";
- function_object[S_PARAMS]["Noise"] = "bzzzz";
-
- error_code = FormatterV1::MetaFormatToString(function_object, function_schema,
- result);
-
- ASSERT_EQ(expected_result2, result) << "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_FALSE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid schema";
-
- function_object[S_MSG_PARAMS]["mandatory_auto_default_int"] = 25;
- function_object[S_MSG_PARAMS]["non_mandatory_auto_default_int"] = 100;
- function_object[S_MSG_PARAMS]["non_mandatory_struct_nm"]["non_mandatory_int_field"] =
- 3;
- function_object[S_MSG_PARAMS]["mandatory_empty_map"]["x"] = 0;
- function_object[S_MSG_PARAMS]["mandatory_empty_map"]["y"] = 0;
- function_object[S_MSG_PARAMS]["non_mandatory_non_empty_array"][0] = 1;
- function_object[S_MSG_PARAMS]["non_mandatory_non_empty_array"][1] = 2;
- function_object[S_MSG_PARAMS]["non_mandatory_non_empty_array"][2] = 3;
- function_object[S_MSG_PARAMS]["mandatory_empty_array"][0] = 0;
- function_object[S_MSG_PARAMS]["mandatory_empty_array"][1] = 1;
- function_object[S_MSG_PARAMS]["mandatory_empty_array"][2] = 2;
-
- std::string expected_result3(
- "{\n"
- " \"response\" : {\n"
- " \"correlationID\" : 0,\n"
- " \"name\" : \"RegisterAppInterface\",\n"
- " \"parameters\" : {\n"
- " \"mandatory_auto_default_bool\" : false,\n"
- " \"mandatory_auto_default_enum\" : -1,\n"
- " \"mandatory_auto_default_int\" : 25,\n"
- " \"mandatory_auto_default_string\" : \"\",\n"
- " \"mandatory_empty_array\" : [ 0, 1, 2 ],\n"
- " \"mandatory_empty_map\" : {},\n"
- " \"mandatory_manual_default_bool\" : true,\n"
- " \"mandatory_manual_default_enum\" : \"request\",\n"
- " \"mandatory_manual_default_int\" : 10,\n"
- " \"mandatory_manual_default_string\" : \"String\",\n"
- " \"mandatory_struct\" : {\n"
- " \"mandatory_int_field\" : 15,\n"
- " \"mandatory_string_field\" : \"Mandatory text\"\n"
- " },\n"
- " \"mandatory_struct_nm\" : {},\n"
- " \"non_mandatory_auto_default_int\" : 100,\n"
- " \"non_mandatory_non_empty_array\" : [ 1, 2, 3 ],\n"
- " \"non_mandatory_struct_nm\" : {\n"
- " \"non_mandatory_int_field\" : 3\n"
- " }\n"
- " }\n"
- " }\n"
- "}\n");
-
- error_code = FormatterV1::MetaFormatToString(function_object, function_schema,
- result);
-
- ASSERT_EQ(expected_result3, result) << "Invalid result JSON string";
-
- ASSERT_FALSE(mf::kErrorOk & error_code)
- << "Result must not be OK in such case";
-
- ASSERT_FALSE(mf::kErrorObjectIsNotFunction & error_code)
- << "Object must be detected as function";
-
- ASSERT_FALSE(mf::kErrorSchemaIsNotFunction & error_code)
- << "Target schema defines a function";
-
- ASSERT_FALSE(mf::kErrorFailedCreateObjectBySchema & error_code)
- << "This creation shold not fail because of valid schema";
-}
-}
-}
-}
-}
-
-namespace NsSmartDeviceLink {
-namespace NsSmartObjects {
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::EnumToCStringMap
-EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::CStringToEnumMap
-EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::cstring_values_[] = {
- "RegisterAppInterface",
- "UnregisterAppInterface",
- "SetGlobalProperties"
-};
-
-template<>
-const test::components::json_handler::formatters::FunctionID::eType
-EnumConversionHelper<test::components::json_handler::formatters::FunctionID::eType>::enum_values_[] = {
- test::components::json_handler::formatters::FunctionID::RegisterAppInterface,
- test::components::json_handler::formatters::FunctionID::UnregisterAppInterface,
- test::components::json_handler::formatters::FunctionID::SetGlobalProperties
-};
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::EnumToCStringMap
-EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::CStringToEnumMap
-EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::cstring_values_[] = {
- "request",
- "response",
- "notification"
-};
-
-template<>
-const test::components::json_handler::formatters::messageType::eType
-EnumConversionHelper<test::components::json_handler::formatters::messageType::eType>::enum_values_[] = {
- test::components::json_handler::formatters::messageType::request,
- test::components::json_handler::formatters::messageType::response,
- test::components::json_handler::formatters::messageType::notification
-};
-
-}
-}
-
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/json_handler/src/FormatterJsonSDLRPCv2Test.cpp b/test/components/json_handler/src/FormatterJsonSDLRPCv2Test.cpp
deleted file mode 100644
index 84a3d3009..000000000
--- a/test/components/json_handler/src/FormatterJsonSDLRPCv2Test.cpp
+++ /dev/null
@@ -1,298 +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.
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <iostream>
-#include "json/json.h"
-
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-#include "formatters/CSmartFactory.hpp"
-
-#include "smart_objects/array_schema_item.h"
-#include "smart_objects/bool_schema_item.h"
-#include "smart_objects/object_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-#include "smart_objects/enum_schema_item.h"
-#include "smart_objects/number_schema_item.h"
-#include "smart_objects/schema_item_parameter.h"
-
-#include "json_handler/formatter_test_helper.h"
-
-
-namespace test { namespace components { namespace json_handler { namespace formatters {
-
-namespace function_id {
-/**
- * @brief Enumeration FunctionID.
- */
-enum Type {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief RegisterAppInterface.
- */
- kRegisterAppInterface,
-
- /**
- * @brief UnregisterAppInterface.
- */
- kUnregisterAppInterface,
-
- /**
- * @brief SetGlobalProperties.
- */
- kSetGlobalProperties,
-};
-} //namespace FunctionID
-
-namespace message_type {
-/**
- * @brief Enumeration messageType.
- */
-enum Type {
- /**
- * @brief INVALID_ENUM.
- */
- INVALID_ENUM = -1,
-
- /**
- * @brief request.
- */
- kRequest,
-
- /**
- * @brief response.
- */
- kResponse,
-
- /**
- * @brief notification.
- */
- kNotification
-};
-} //namespace messageType
-
-
- using namespace NsSmartDeviceLink::NsJSONHandler::strings;
- typedef NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2 FormatterV2;
-
- TEST_F(CFormatterTestHelper, test_fromObjToSDLRPCv2AndBack)
- {
- Json::Value value; // just a quick workaround to avoid undefined reference to Json
-
- std::string str;
- NsSmartDeviceLink::NsSmartObjects::SmartObject srcObj;
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj;
-
- fillTestObject(srcObj);
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
-
- // SmartObjects --> JSON
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::toString(srcObj, str);
-
- //std::cout << str << std::endl;
-
- // JSON --> SmartObjects
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::
- fromString<std::string, std::string>(str, dstObj, "some function", "request", 12);
-
-
- compareObjects(srcObj, dstObj);
- }
-
- TEST_F(CFormatterTestHelper, test_fromJsonSDLRPCv2)
- {
- std::string str = "\
- {\
- \"appID\": \"APP ID\",\
- \"appName\": \"APP NAME\",\
- \"appType\": [\"SYSTEM\", \"COMMUNICATION\"],\
- \"hmiDisplayLanguageDesired\": \"RU-RU\",\
- \"isMediaApplication\": true,\
- \"languageDesired\": \"EN-US\",\
- \"ngnMediaScreenAppName\": \"SCREEN NAME\",\
- \"syncMsgVersion\": {\
- \"majorVersion\": 2,\
- \"minorVersion\": 10\
- },\
- \"ttsName\": [{\
- \"text\": \"ABC\",\
- \"type\": \"TEXT\"\
- }],\
- \"vrSynonyms\": [\"Synonym 1\", \"Synonym 2\"]\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- bool result;
-
- result = NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::
- fromString<std::string, std::string>(str, obj, "some name", "request", 12);
-
- ASSERT_TRUE(result) << "Error parsing JSON string";
-
- ASSERT_EQ("some name", obj[S_PARAMS][S_FUNCTION_ID].asString());
- ASSERT_EQ(12, obj[S_PARAMS][S_CORRELATION_ID].asInt());
- ASSERT_EQ(2, obj[S_PARAMS][S_PROTOCOL_VERSION].asInt());
- ASSERT_EQ(10, obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"].asInt());
- ASSERT_EQ("TEXT", obj[S_MSG_PARAMS]["ttsName"][0]["type"].asString());
- ASSERT_EQ("Synonym 2", obj[S_MSG_PARAMS]["vrSynonyms"][1].asString());
- }
-
- TEST_F(CFormatterTestHelper, test_SDLRPCv2_EmptyMapArrayTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject srcObj, dstObj;
- std::string str;
-
- fillTestObject(srcObj);
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = 0;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 0;
- srcObj[S_PARAMS][S_FUNCTION_ID] = 0;
- srcObj[S_MSG_PARAMS]["EmptyArray"] = SmartObject(SmartType_Array);
- srcObj[S_MSG_PARAMS]["EmptyMap"] = SmartObject(SmartType_Map);
- srcObj[S_MSG_PARAMS]["AnotherEmptyArray"] = srcObj[S_MSG_PARAMS]["EmptyArray"];
- srcObj[S_MSG_PARAMS]["AnotherEmptyMap"] = srcObj[S_MSG_PARAMS]["EmptyMap"];
-
- // SmartObjects --> JSON
- FormatterV2::toString(srcObj, str);
-
- // JSON --> SmartObjects
- FormatterV2::fromString<int, int>(str, dstObj, 0, 0, 0);
-
- compareObjects(srcObj, dstObj);
- }
-
- TEST_F(CFormatterTestHelper, test_CorrelationIdTest) {
-
- std::string str = "\
- {\
- \"appID\": \"APP ID\",\
- \"appName\": \"APP NAME\",\
- \"appType\": [\"SYSTEM\", \"COMMUNICATION\"],\
- \"syncMsgVersion\": {\
- \"majorVersion\": 2,\
- \"minorVersion\": 10\
- },\
- \"ttsName\": [{\
- \"text\": \"ABC\",\
- \"type\": \"TEXT\"\
- }],\
- \"vrSynonyms\": [\"Synonym 1\", \"Synonym 2\"]\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj1, obj2;
- bool result;
-
- result = NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::
- fromString<std::string, std::string>(str, obj1, "some name", "notification");
-
- ASSERT_TRUE(result) << "Error parsing JSON string";
-
- ASSERT_FALSE(obj1[S_PARAMS].keyExists(S_CORRELATION_ID)) << "CorrelationID exists for notification";
-
- result = NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::
- fromString<std::string, std::string>(str, obj2, "some name", "request", 10);
-
- ASSERT_TRUE(result) << "Error parsing JSON string";
-
- ASSERT_TRUE(obj2[S_PARAMS].keyExists(S_CORRELATION_ID)) << "CorrelationID doesn't exist for request";
- }
-}}}}
-
-namespace NsSmartDeviceLink {
-namespace NsSmartObjects {
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::EnumToCStringMap
-EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::CStringToEnumMap
-EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::cstring_values_[] = {
- "RegisterAppInterface",
- "UnregisterAppInterface",
- "SetGlobalProperties"
-};
-
-template<>
-const test::components::json_handler::formatters::function_id::Type
-EnumConversionHelper<test::components::json_handler::formatters::function_id::Type>::enum_values_[] = {
- test::components::json_handler::formatters::function_id::kRegisterAppInterface,
- test::components::json_handler::formatters::function_id::kUnregisterAppInterface,
- test::components::json_handler::formatters::function_id::kSetGlobalProperties
-};
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::EnumToCStringMap
-EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::CStringToEnumMap
-EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::cstring_values_[] = {
- "request",
- "response",
- "notification"
-};
-
-template<>
-const test::components::json_handler::formatters::message_type::Type
-EnumConversionHelper<test::components::json_handler::formatters::message_type::Type>::enum_values_[] = {
- test::components::json_handler::formatters::message_type::kRequest,
- test::components::json_handler::formatters::message_type::kResponse,
- test::components::json_handler::formatters::message_type::kNotification
-};
-
-}
-}
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
diff --git a/test/components/json_handler/src/formatter_json_alrpcv1_test.cc b/test/components/json_handler/src/formatter_json_alrpcv1_test.cc
deleted file mode 100644
index c4b8d7ca6..000000000
--- a/test/components/json_handler/src/formatter_json_alrpcv1_test.cc
+++ /dev/null
@@ -1,31 +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.
-
-#include "json_handler/formatter_json_alrpcv1_test.h"
diff --git a/test/components/json_handler/src/formatter_json_alrpcv2_test.cc b/test/components/json_handler/src/formatter_json_alrpcv2_test.cc
deleted file mode 100644
index c41aa6a12..000000000
--- a/test/components/json_handler/src/formatter_json_alrpcv2_test.cc
+++ /dev/null
@@ -1,31 +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.
-
-#include "json_handler/formatter_json_alrpcv2_test.h"
diff --git a/test/components/json_handler/src/formatter_json_rpc2_test.cc b/test/components/json_handler/src/formatter_json_rpc2_test.cc
deleted file mode 100644
index 24c972c56..000000000
--- a/test/components/json_handler/src/formatter_json_rpc2_test.cc
+++ /dev/null
@@ -1,31 +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.
-
-#include "json_handler/formatter_json_rpcv2_test.h"
diff --git a/test/components/json_handler/src/formatter_json_rpc_test.cc b/test/components/json_handler/src/formatter_json_rpc_test.cc
deleted file mode 100644
index d55e86232..000000000
--- a/test/components/json_handler/src/formatter_json_rpc_test.cc
+++ /dev/null
@@ -1,855 +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.
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <iostream>
-
-#include "smart_objects/smart_object.h"
-#include "formatters/formatter_json_rpc.h"
-#include "json_handler/formatter_test_helper.h"
-
-#include "test/components/json_handler/test_json_rpc.h"
-#include "test/components/json_handler/test_json_rpc_schema.h"
-
-#include "json/json.h"
-
-namespace test {
-namespace components {
-namespace JSONHandler {
-namespace Formatters {
-
-using namespace gen::test::components::json_rpc;
-using namespace test::components::json_handler::formatters;
-using namespace NsSmartDeviceLink::NsJSONHandler::Formatters;
-using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-
-typedef NsSmartDeviceLink::NsJSONHandler::Formatters::FormatterJsonRpc JSONFormatter;
-
-/**
- * @brief Convert SmartObject to JSON string.
- *
- * @param obj Source SmartObject to convert.
- * @param[out] result_string Output JSON string.
- */
-void AnyObjectToJsonString(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj,
- std::string& result_string) {
-
- Json::Value params(Json::objectValue);
- NsSmartDeviceLink::NsSmartObjects::SmartObject formattedObj(obj);
- CFormatterJsonBase::objToJsonValue(formattedObj, params);
- result_string = params.toStyledString();
-}
-
-TEST_F(CFormatterTestHelper, ToString) {
-
- std::string str;
- NsSmartDeviceLink::NsSmartObjects::SmartObject srcObj;
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj;
-
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema schema;
- test_json_rpc factory;
- factory.GetSchema(FunctionID::interface1_Function1,
- messageType::request,
- schema);
-
- srcObj.setSchema(schema);
-
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionID::interface1_Function1;
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = messageType::request;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 1;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 123;
-
- srcObj[S_MSG_PARAMS]["param1"] = "Param1_string";
- srcObj[S_MSG_PARAMS]["param2"] = 123456789;
-
- srcObj[S_MSG_PARAMS]["param3"]["member1"] = 1;
- srcObj[S_MSG_PARAMS]["param3"]["member2"] = true;
- srcObj[S_MSG_PARAMS]["param3"]["member3"] = 13.3;
- srcObj[S_MSG_PARAMS]["param3"]["member4"][0] = 13;
- srcObj[S_MSG_PARAMS]["param3"]["member4"][1] = 14;
-
- ASSERT_TRUE(srcObj.isValid());
-
- // SmartObjects --> JSON
- ASSERT_TRUE(JSONFormatter::ToString(srcObj, str));
-
- // JSON --> SmartObjects
- int result;
- result = JSONFormatter::FromString<FunctionID::eType, messageType::eType>(str, dstObj);
- ASSERT_TRUE(JSONFormatter::kSuccess == result);
-
- // Compare SmartObjects
- CFormatterTestHelper::compareObjects(srcObj, dstObj);
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject srcObj2;
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj2;
- factory.GetSchema(FunctionID::interface2_Function1,
- messageType::notification,
- schema);
-
- srcObj2.setSchema(schema);
-
- srcObj2[S_PARAMS][S_FUNCTION_ID] = FunctionID::interface2_Function1;
- srcObj2[S_PARAMS][S_MESSAGE_TYPE] = messageType::notification;
- srcObj2[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj2[S_PARAMS][S_PROTOCOL_TYPE] = 1;
-
- srcObj2[S_MSG_PARAMS]["param"] = interface2_enum2::element2;
- srcObj2[S_MSG_PARAMS]["i1"]["m1"] = "if1_struct2";
- srcObj2[S_MSG_PARAMS]["i1"]["m2"][0] = "arr_str";
- srcObj2[S_MSG_PARAMS]["i1"]["m3"] = interface1_enum1::element1;
- srcObj2[S_MSG_PARAMS]["i1"]["m4"][0]["member1"] = 1313;
- srcObj2[S_MSG_PARAMS]["i1"]["m4"][0]["member2"] = true;
- srcObj2[S_MSG_PARAMS]["i1"]["m4"][0]["member3"] = 0.01;
- srcObj2[S_MSG_PARAMS]["i1"]["m4"][0]["member4"][0] = 99;
-
- ASSERT_TRUE(srcObj2.isValid());
-
- // SmartObjects --> JSON
- ASSERT_TRUE(JSONFormatter::ToString(srcObj2, str));
-
- // JSON --> SmartObjects
- result = JSONFormatter::FromString<FunctionID::eType, messageType::eType>(str, dstObj2);
- ASSERT_TRUE(JSONFormatter::kSuccess == result);
-
- factory.attachSchema(dstObj2);
-
- // Compare SmartObjects
- compareObjects(srcObj2, dstObj2);
-}
-
-TEST_F(CFormatterTestHelper, FromString) {
-
- std::string srcStr = "\
- {\
- \"id\": 99,\
- \"jsonrpc\": \"2.0\",\
- \"result\": {\
- \"code\": 0,\
- \"method\": \"interface1.Function1\",\
- \"p1\": 10,\
- \"p2\": 12,\
- \"p3\": true\
- }\
- }";
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject dstObj;
-
- int result =
- JSONFormatter::FromString<FunctionID::eType, messageType::eType>(
- srcStr, dstObj);
-
- ASSERT_TRUE(JSONFormatter::kSuccess == result);
-
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema schema;
- test_json_rpc factory;
- factory.GetSchema(FunctionID::interface1_Function1,
- messageType::response,
- schema);
- dstObj.setSchema(schema);
-
- ASSERT_TRUE(dstObj.isValid());
-
- ASSERT_EQ(99, dstObj[S_PARAMS][S_CORRELATION_ID].asInt());
- ASSERT_EQ(2, dstObj[S_PARAMS][S_PROTOCOL_VERSION].asInt());
- ASSERT_EQ(messageType::response, dstObj[S_PARAMS][S_MESSAGE_TYPE].asInt());
- ASSERT_EQ(0, dstObj[S_PARAMS]["code"].asInt());
- ASSERT_EQ(FunctionID::interface1_Function1, dstObj[S_PARAMS][S_FUNCTION_ID].asInt());
- ASSERT_EQ(interface1_enum1::element1, dstObj[S_MSG_PARAMS]["p1"].asInt());
- ASSERT_EQ(interface1_enum1::element3, dstObj[S_MSG_PARAMS]["p2"].asInt());
- ASSERT_EQ(true, dstObj[S_MSG_PARAMS]["p3"].asBool());
-}
-
-/**
- * @brief Check result of parsing of the specified string for specific error.
- *
- * @param error Error code to check.
- * @param str String to parse.
- *
- * @return true if parsing result contains specified error code.
- */
-bool CheckErrorCode(int error, const std::string &str) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject out;
-
- printf("%s\n", str.c_str());
-
- return error == (error & JSONFormatter::FromString<FunctionID::eType,
- messageType::eType>(
- str, out));
-}
-
-/**
- * @brief Invalid JSON RPC string.
- *
- * Used in several tests because it must generate multiple error codes.
- */
-static const char *g_invalid_jsonrpc_string =
- "{"
- " id: 1"
- " method: \"Method1\""
- " params: {";
-
-TEST(FormatterJsonRpc, ParsingError) {
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kParsingError,
- g_invalid_jsonrpc_string));
-
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kParsingError,
- "{"
- " \"method\": \"Method1\""
- "}"));
-}
-
-TEST(FormatterJsonRpc, InvalidFormat) {
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"id\": 1,"
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": 2,"
- " \"id\": 1,"
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": [],"
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": {},"
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": {}"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": {},"
- " \"method\": 1"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": Null,"
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": \"stringId\","
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"params\": 10"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"params\": {}"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"params\": 10"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"params\": {}"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\": 10"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\": {}"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidFormat,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\": {}"
- "}"));
-}
-
-TEST(FormatterJsonRpc, MethodNotSpecified) {
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- g_invalid_jsonrpc_string));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"params\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"method\": \"Method1\","
- " \"params\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"method\": \"Method1\","
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kMethodNotSpecified,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"data\":"
- " {"
- " \"method\": \"Method1\""
- " },"
- " \"p\": 0"
- " }"
- "}"));
-}
-
-TEST(FormatterJsonRpc, UnknownMethod) {
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- g_invalid_jsonrpc_string));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"method\": \"Method1\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"method\": \"interface1.Function1\""
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"params\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"method\": \"Method1\","
- " \"params\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"method\": \"interface1.Function2\","
- " \"params\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"method\": \"Method1\","
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"method\": \"interface2.Function1\","
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"data\":"
- " {"
- " \"method\": \"Method1\""
- " },"
- " \"p\": 0"
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMethod,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"data\":"
- " {"
- " \"method\": \"interface1.Function1\""
- " },"
- " \"p\": 0"
- " }"
- "}"));
-}
-
-TEST(FormatterJsonRpc, UnknownMessageType) {
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMessageType,
- g_invalid_jsonrpc_string));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMessageType, "{}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kUnknownMessageType,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMessageType,
- "{"
- " \"jsonrpc\": \"2.0\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMessageType,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"params\": {}"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMessageType,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\": {}"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kUnknownMessageType,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\": {}"
- "}"));
-}
-
-TEST(FormatterJsonRpc, InvalidId) {
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidId,
- g_invalid_jsonrpc_string));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidId, "{}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidId,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidId,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1.5"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidId,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": \"StringId\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kInvalidId,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": Null"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidId,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": []"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kInvalidId,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": {}"
- "}"));
-}
-
-TEST(FormatterJsonRpc, ResponseCodeNotAvailable) {
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- g_invalid_jsonrpc_string));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable, "{}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"params\": {}"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\": {}"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"code\": \"c\""
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"code\": 10"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"code\": \"c\""
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kResponseCodeNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"code\": 10"
- " }"
- "}"));
-}
-
-TEST(FormatterJsonRpc, ErrorResponseMessageNotAvailable) {
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- g_invalid_jsonrpc_string));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\""
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"params\": {}"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\": {}"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"message\": \"c\""
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\":"
- " {"
- " \"message\": 1"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"code\": 1"
- " }"
- "}"));
-
- ASSERT_TRUE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"message\": 1"
- " }"
- "}"));
-
- ASSERT_FALSE(CheckErrorCode(JSONFormatter::kErrorResponseMessageNotAvailable,
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\":"
- " {"
- " \"message\": \"Error message\""
- " }"
- "}"));
-}
-
-TEST(FormatterJsonRpc, MessageType) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject out;
-
- ASSERT_TRUE((JSONFormatter::kSuccess ==
- JSONFormatter::FromString<FunctionID::eType, messageType::eType>(
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"method\": \"interface2.Function1\","
- " \"params\": {}"
- "}",
- out)));
-
- ASSERT_TRUE(messageType::notification ==
- out[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- ASSERT_TRUE((JSONFormatter::kSuccess ==
- JSONFormatter::FromString<FunctionID::eType, messageType::eType>(
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"method\": \"interface2.Function1\","
- " \"id\": 1,"
- " \"params\": {}"
- "}",
- out)));
-
- ASSERT_TRUE(messageType::request == out[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- ASSERT_TRUE((JSONFormatter::kSuccess ==
- JSONFormatter::FromString<FunctionID::eType, messageType::eType>(
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"result\": {"
- " \"method\": \"interface2.Function1\","
- " \"code\": 1"
- " }"
- "}",
- out)));
-
- ASSERT_TRUE(messageType::response == out[S_PARAMS][S_MESSAGE_TYPE].asInt());
-
- ASSERT_TRUE((JSONFormatter::kSuccess ==
- JSONFormatter::FromString<FunctionID::eType, messageType::eType>(
- "{"
- " \"jsonrpc\": \"2.0\","
- " \"id\": 1,"
- " \"error\": {"
- " \"data\": {"
- " \"method\": \"interface2.Function1\""
- " },"
- " \"code\": 1,"
- " \"message\": \"Fail\""
- " }"
- "}",
- out)));
-
- ASSERT_TRUE(messageType::error_response ==
- out[S_PARAMS][S_MESSAGE_TYPE].asInt());
-}
-
-} //namespace Formatters
-} //namespace JSONHandler
-} //namespace components
-} //namespace test
-
-
-int main(int argc, char **argv)
-{
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/json_handler/src/formatter_test_helper.cc b/test/components/json_handler/src/formatter_test_helper.cc
deleted file mode 100644
index cc2b55b83..000000000
--- a/test/components/json_handler/src/formatter_test_helper.cc
+++ /dev/null
@@ -1,94 +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.
-
-#include "json_handler/formatter_test_helper.h"
-#include "formatters/CSmartFactory.hpp"
-
-using namespace test::components::json_handler::formatters;
-using namespace NsSmartDeviceLink::NsSmartObjects;
-using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-
-void CFormatterTestHelper::fillTestObject(SmartObject& obj)
-{
- obj[S_PARAMS][S_MESSAGE_TYPE] = "request";
- obj[S_PARAMS][S_FUNCTION_ID] = "some function";
- obj[S_PARAMS][S_CORRELATION_ID] = 12;
- obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- obj[S_MSG_PARAMS]["appId"] = "APP ID";
- obj[S_MSG_PARAMS]["appName"] = "APP NAME";
- obj[S_MSG_PARAMS]["appType"][0] = "SYSTEM";
- obj[S_MSG_PARAMS]["appType"][1] = "COMMUNICATION";
- obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = "RU-RU";
- obj[S_MSG_PARAMS]["isMediaApplication"] = true;
- obj[S_MSG_PARAMS]["languageDesired"] = "EN-US";
- obj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "SCREEN NAME";
- obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
- obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
- obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- obj[S_MSG_PARAMS]["ttsName"][0]["type"] = "TEXT";
- obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
- // obj[S_MSG_PARAMS]["null"] = NsSmartDeviceLink::NsSmartObjects::SmartObject();
- obj[S_MSG_PARAMS]["double"] = -0.1234;
-}
-
-
-void CFormatterTestHelper::compareObjects(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& first,
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& second) {
- if (SmartType_Array == first.getType()) {
- ASSERT_EQ(SmartType_Array, second.getType());
-
- for (size_t i = 0; i < first.length(); i++) {
- compareObjects(first.getElement(i), second.getElement(i));
- }
- } else if (SmartType_Map == first.getType()) {
- ASSERT_EQ(SmartType_Map, second.getType());
-
- std::set<std::string> keys = first.enumerate();
-
- for (std::set<std::string>::const_iterator key = keys.begin();
- key != keys.end(); key++) {
- compareObjects(first.getElement(*key), second.getElement(*key));
- }
- } else if (SmartType_Boolean == first.getType()) {
- ASSERT_EQ(first.asBool(), second.asBool());
- } else if (SmartType_Integer == first.getType()) {
- ASSERT_EQ(first.asInt(), second.asInt());
- } else if (SmartType_Double == first.getType()) {
- ASSERT_EQ(first.asDouble(), second.asDouble());
- } else if (SmartType_String == first.getType()) {
- ASSERT_EQ(first.asString(), second.asString());
- } else if (SmartType_Null == first.getType()) {
- ASSERT_EQ(SmartType_Null, second.getType());
- } else {
- FAIL() << "Unknown SmartObject type: " << first.getType();
- }
-}
diff --git a/test/components/json_handler/src/meta_formatter_test.cc b/test/components/json_handler/src/meta_formatter_test.cc
deleted file mode 100644
index 83ed36765..000000000
--- a/test/components/json_handler/src/meta_formatter_test.cc
+++ /dev/null
@@ -1,502 +0,0 @@
-/**
- * @file meta_formatter_test.cc
- * @brief implementation of test for class CMetaFormatter
- */
-// 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.auto
-
-#include "gtest/gtest.h"
-
-#include <iostream>
-#include <stdio.h>
-
-#include "formatters/meta_formatter.h"
-#include "formatters/CSmartFactory.hpp"
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
-
-#include "smart_objects/always_true_schema_item.h"
-#include "smart_objects/always_false_schema_item.h"
-#include "smart_objects/array_schema_item.h"
-#include "smart_objects/bool_schema_item.h"
-#include "smart_objects/object_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-#include "smart_objects/enum_schema_item.h"
-#include "smart_objects/number_schema_item.h"
-#include "smart_objects/schema_item_parameter.h"
-
-#include "json_handler/meta_formatter_test_helper.h"
-
-using test::components::JSONHandler::formatters::CMetaFormatterTestHelper;
-namespace testhelper_ns = test::components::JSONHandler::formatters;
-namespace formatter_ns = NsSmartDeviceLink::NsJSONHandler::Formatters;
-namespace generated_ns = Gen::test::components::JSONHandler2;
-namespace strings_ns = NsSmartDeviceLink::NsJSONHandler::strings;
-namespace smartobjects_ns = NsSmartDeviceLink::NsSmartObjects;
-
-namespace test {
-namespace components {
-namespace JSONHandler {
-namespace formatters {
-
-TEST_F(CMetaFormatterTestHelper, test_inputObjectIdenticalToSchemaWithAndWithoutMandatoryParams) {
- Json::Value value; // just a quick workaround to avoid undefined reference to Json
- Json::Reader reader; // the same thing
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject object1 =
- factory_.CreateSmartObject(
- generated_ns::FunctionID::RegisterAppInterfaceID,
- generated_ns::messageType::request);
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject object2 =
- factory_.CreateSmartObject(
- generated_ns::FunctionID::RegisterAppInterfaceID,
- generated_ns::messageType::request);
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject result_object1;
- NsSmartDeviceLink::NsSmartObjects::SmartObject result_object2;
- // get schema
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema schema;
- bool get_schema_result = factory_.GetSchema(
- generated_ns::FunctionID::RegisterAppInterfaceID,
- generated_ns::messageType::request,
- schema);
-
- ASSERT_TRUE(get_schema_result);
-
- FillObjectIdenticalToSchema(object1);
- FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(object2);
-
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object1,
- schema, result_object1);
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object2,
- schema, result_object2);
-
- if (true == kIsPrintOut) { // printing out
- std::string formatted_string;
- formatter_ns::CFormatterJsonSDLRPCv1::toString(object1, formatted_string);
- printf("object1 %s\n", formatted_string.c_str());
-
- formatter_ns::CFormatterJsonSDLRPCv1::toString(result_object1, formatted_string);
- printf("result_object1 %s\n", formatted_string.c_str());
-
- formatter_ns::CFormatterJsonSDLRPCv1::toString(object2, formatted_string);
- printf("object2 %s\n", formatted_string.c_str());
-
- formatter_ns::CFormatterJsonSDLRPCv1::toString(result_object2, formatted_string);
- printf("result_object2 %s\n", formatted_string.c_str());
- }
-
- CompareObjects(object1, result_object1);
- CompareObjects(result_object1, object1);
- CompareObjects(object2, result_object2);
- CompareObjects(result_object2, object2);
-
- // enums must be unapplied (converted to string) in order to be compared against strings
- result_object1.getSchema().unapplySchema(result_object1);
- EXPECT_EQ("request",
- result_object1[strings_ns::S_PARAMS][strings_ns::S_MESSAGE_TYPE].asString());
- EXPECT_EQ("RegisterAppInterfaceID",
- result_object1[strings_ns::S_PARAMS][strings_ns::S_FUNCTION_ID].asString());
-
- result_object2.getSchema().unapplySchema(result_object2);
- EXPECT_EQ("request",
- result_object2[strings_ns::S_PARAMS][strings_ns::S_MESSAGE_TYPE].asString());
- EXPECT_EQ("RegisterAppInterfaceID",
- result_object2[strings_ns::S_PARAMS][strings_ns::S_FUNCTION_ID].asString());
-}
-
-
-TEST_F(CMetaFormatterTestHelper, test_NormalSchemaWithEmptyObject) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject object;
- NsSmartDeviceLink::NsSmartObjects::SmartObject result_object;
- NsSmartDeviceLink::NsSmartObjects::SmartObject expected_object;
- // get schema
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema schema;
- bool get_schema_result = factory_.GetSchema(
- generated_ns::FunctionID::RegisterAppInterfaceID,
- generated_ns::messageType::request,
- schema);
-
- ASSERT_TRUE(get_schema_result);
-
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object, schema, result_object);
-
- FillObjectWithDefaultValues(expected_object);
-
- CompareObjects(expected_object, result_object);
- CompareObjects(result_object, expected_object);
-
- if (true == kIsPrintOut) {
- std::string str;
- AnyObjectToJsonString(result_object, str);
- printf("result_object(default) %s", str.c_str());
- }
-}
-
-TEST_F(CMetaFormatterTestHelper, test_NormalSchemaWithObjectWithoutSomeMandatoryFields) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject object;
- NsSmartDeviceLink::NsSmartObjects::SmartObject result_object;
- // get schema
- NsSmartDeviceLink::NsSmartObjects::CSmartSchema schema;
- bool get_schema_result = factory_.GetSchema(
- generated_ns::FunctionID::RegisterAppInterfaceID,
- generated_ns::messageType::request,
- schema);
-
- ASSERT_TRUE(get_schema_result);
-
- FillObjectWithoutSomeMandatoryFields(object);
-
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object, schema, result_object);
-
- CompareObjects(object, result_object);
- EXPECT_EQ(0,
- result_object[strings_ns::S_PARAMS][strings_ns::S_CORRELATION_ID].asInt());
- EXPECT_EQ(0,
- result_object[strings_ns::S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"].asInt());
- EXPECT_EQ(0,
- result_object[strings_ns::S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"].asInt());
-
- if (true == kIsPrintOut) {
- std::string str;
- AnyObjectToJsonString(result_object, str);
- printf("result_object %s", str.c_str());
- }
-}
-
-TEST_F(CMetaFormatterTestHelper, test_SimpleEmptyMap) {
- std::map<std::string, smartobjects_ns::CObjectSchemaItem::SMember> schemaMembersMap;
- smartobjects_ns::CSmartSchema map_schema =
- smartobjects_ns::CSmartSchema(
- smartobjects_ns::CObjectSchemaItem::create(schemaMembersMap));
-
- smartobjects_ns::SmartObject object;
- NsSmartDeviceLink::NsSmartObjects::SmartObject result_object_empty_map;
-
- smartobjects_ns::SmartObject object_empty_map =
- smartobjects_ns::SmartObject(smartobjects_ns::SmartType_Map);
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object_empty_map,
- map_schema, result_object_empty_map);
- ASSERT_EQ(smartobjects_ns::SmartType_Map, result_object_empty_map.getType())
- << "smartObject is not map type";
- ASSERT_EQ(0u, result_object_empty_map.length()) << "non empty map";
-
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object,
- map_schema, result_object_empty_map);
- ASSERT_EQ(smartobjects_ns::SmartType_Map, result_object_empty_map.getType())
- << "smartObject is not map type";
- ASSERT_EQ(0u, result_object_empty_map.length()) << "non empty map";
-
- object["field1"] = 0;
- object["field2"] = smartobjects_ns::SmartObject();
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object,
- map_schema, result_object_empty_map);
- ASSERT_EQ(smartobjects_ns::SmartType_Map, result_object_empty_map.getType())
- << "smartObject is not map type";
- ASSERT_EQ(0u, result_object_empty_map.length()) << "non empty map";
-
- // fill object with any values. Result must be the same
- FillObjectIdenticalToSchema(object);
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object,
- map_schema, result_object_empty_map);
- ASSERT_EQ(smartobjects_ns::SmartType_Map, result_object_empty_map.getType())
- << "smartObject is not map type";
- ASSERT_EQ(0u, result_object_empty_map.length()) << "non empty map";
-
- // fill object with any values. Result must be the same
- FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(object);
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object,
- map_schema, result_object_empty_map);
- ASSERT_EQ(smartobjects_ns::SmartType_Map, result_object_empty_map.getType())
- << "smartObject is not map type";
- ASSERT_EQ(0u, result_object_empty_map.length()) << "non empty map";
-
- if (true == kIsPrintOut) {
- std::string str;
- AnyObjectToJsonString(result_object_empty_map, str);
- printf("result_object(empty map) %s", str.c_str());
- }
-
-
-}
-
-TEST_F(CMetaFormatterTestHelper, test_SimpleEmptyArray) {
- smartobjects_ns::SmartObject object;
-
- smartobjects_ns::SmartObject result_object_empty_array;
- smartobjects_ns::CSmartSchema array_schema =
- smartobjects_ns::CSmartSchema(smartobjects_ns::CArraySchemaItem::create());
-
- smartobjects_ns::SmartObject object_empty_aray =
- smartobjects_ns::SmartObject(smartobjects_ns::SmartType_Array);
-
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object_empty_aray,
- array_schema, result_object_empty_array);
- ASSERT_EQ(smartobjects_ns::SmartType_Array, result_object_empty_array.getType())
- << "smartObject is not array type";
- ASSERT_EQ(0u, result_object_empty_array.length()) << "non empty array";
-
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object,
- array_schema, result_object_empty_array);
- ASSERT_EQ(smartobjects_ns::SmartType_Array, result_object_empty_array.getType())
- << "smartObject is not array type";
- ASSERT_EQ(0u, result_object_empty_array.length()) << "non empty array";
-
- // fill object with any values. Result must be the same
- FillObjectIdenticalToSchema(object);
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object,
- array_schema, result_object_empty_array);
- ASSERT_EQ(smartobjects_ns::SmartType_Array, result_object_empty_array.getType())
- << "smartObject is not array type";
- ASSERT_EQ(0u, result_object_empty_array.length()) << "non empty array";
-
- // fill object with any values. Result must be the same
- FillObjectWithoutSomeMandatoryFields(object);
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object,
- array_schema, result_object_empty_array);
- ASSERT_EQ(smartobjects_ns::SmartType_Array, result_object_empty_array.getType())
- << "smartObject is not array type";
- ASSERT_EQ(0u, result_object_empty_array.length()) << "non empty array";
-
- if (true == kIsPrintOut) {
- std::string str;
- AnyObjectToJsonString(result_object_empty_array, str);
- printf("result_object(empty array) %s", str.c_str());
- }
-}
-
-TEST_F(CMetaFormatterTestHelper, testEmptyArrayAndEmptyMapWithOtherParameters) {
- smartobjects_ns::SmartObject result_object;
- smartobjects_ns::SmartObject object;
-
- std::map<std::string, smartobjects_ns::CObjectSchemaItem::SMember>
- paramsMembersMap;
-
- paramsMembersMap[strings_ns::S_FUNCTION_ID] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::TEnumSchemaItem<function_id::EType>::create(
- function_id_items_), true);
-
- paramsMembersMap[strings_ns::S_MESSAGE_TYPE] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::TEnumSchemaItem<message_type::EType>::create(
- message_type_items_), true);
-
- paramsMembersMap[strings_ns::S_CORRELATION_ID] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::TNumberSchemaItem<int>::create(
- smartobjects_ns::TSchemaItemParameter<int>(0),
- smartobjects_ns::TSchemaItemParameter<int>(100),
- smartobjects_ns::TSchemaItemParameter<int>(55)),
- true);
-
- paramsMembersMap[strings_ns::S_PROTOCOL_VERSION] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::TNumberSchemaItem<int>::create(
- smartobjects_ns::TSchemaItemParameter<int>(1),
- smartobjects_ns::TSchemaItemParameter<int>(2)),
- false);
- paramsMembersMap[strings_ns::S_PROTOCOL_TYPE] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::TNumberSchemaItem<int>::create(), false);
-
- std::map<std::string, smartobjects_ns::CObjectSchemaItem::SMember>
- schemaMembersMap;
-
- schemaMembersMap["mandatory_emptyMap1"] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CObjectSchemaItem::create(
- std::map<std::string, smartobjects_ns::CObjectSchemaItem::SMember>()), true);
-
- schemaMembersMap["mandatory_emptyMap2"] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CObjectSchemaItem::create(
- std::map<std::string, smartobjects_ns::CObjectSchemaItem::SMember>()), true);
-
- schemaMembersMap["mandatory_emptyAray"] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CArraySchemaItem::create(
- smartobjects_ns::TNumberSchemaItem<int>::create()), true);
-
- schemaMembersMap["non_mandatory_Array"] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CArraySchemaItem::create(
- smartobjects_ns::TNumberSchemaItem<int>::create(),
- smartobjects_ns::TSchemaItemParameter<size_t>(1),
- smartobjects_ns::TSchemaItemParameter<size_t>(2)), false);
-
- schemaMembersMap["mandatory_string"] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CStringSchemaItem::create(
- smartobjects_ns::TSchemaItemParameter<size_t>(0),
- smartobjects_ns::TSchemaItemParameter<size_t>(500),
- smartobjects_ns::TSchemaItemParameter<std::string>("defValue")),
- true);
-
- schemaMembersMap["non_mandatory_string"] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CStringSchemaItem::create(
- smartobjects_ns::TSchemaItemParameter<size_t>(0),
- smartobjects_ns::TSchemaItemParameter<size_t>(500),
- smartobjects_ns::TSchemaItemParameter<std::string>(
- "ignoredDefValue")),
- false);
-
- std::map<std::string, smartobjects_ns::CObjectSchemaItem::SMember>
- rootMembersMap;
- rootMembersMap[strings_ns::S_MSG_PARAMS] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CObjectSchemaItem::create(schemaMembersMap), true);
- rootMembersMap[strings_ns::S_PARAMS] =
- smartobjects_ns::CObjectSchemaItem::SMember(
- smartobjects_ns::CObjectSchemaItem::create(paramsMembersMap), true);
-
- smartobjects_ns::CSmartSchema schema =
- smartobjects_ns::CSmartSchema(
- smartobjects_ns::CObjectSchemaItem::create(rootMembersMap));
-
- // set object value
- object[strings_ns::S_PARAMS][strings_ns::S_FUNCTION_ID] = 500;
- object[strings_ns::S_PARAMS][strings_ns::S_PROTOCOL_VERSION] = 11;
- object[strings_ns::S_PARAMS]["new_field"] = "100500 string";
-
- object[strings_ns::S_MSG_PARAMS]["mandatory_emptyMap1"]["field1"] = 123;
- object[strings_ns::S_MSG_PARAMS]["mandatory_emptyMap1"]["field2"][0] = 100;
- object[strings_ns::S_MSG_PARAMS]["mandatory_emptyMap1"]["field2"][1] = 200;
- object[strings_ns::S_MSG_PARAMS]["non_mandatory_Array"][0] = 100;
- object[strings_ns::S_MSG_PARAMS]["non_mandatory_Array"][1] = 200;
- object[strings_ns::S_MSG_PARAMS]["non_mandatory_Array"][2] = 300;
- object[strings_ns::S_MSG_PARAMS]["non_mandatory_string"] = "some string";
-
-
- formatter_ns::CMetaFormatter::CreateObjectByPattern(object, schema, result_object);
- if (true == kIsPrintOut) {
- std::string str;
- AnyObjectToJsonString(object, str);
- printf("object %s", str.c_str());
- AnyObjectToJsonString(result_object, str);
- printf("result_object %s", str.c_str());
- }
-
- EXPECT_EQ(500,
- result_object[strings_ns::S_PARAMS][strings_ns::S_FUNCTION_ID].asInt());
- EXPECT_EQ(-1,
- result_object[strings_ns::S_PARAMS][strings_ns::S_MESSAGE_TYPE].asInt());
- EXPECT_EQ(55,
- result_object[strings_ns::S_PARAMS][strings_ns::S_CORRELATION_ID].asInt());
- EXPECT_EQ(11u,
- result_object[strings_ns::S_PARAMS][strings_ns::S_PROTOCOL_VERSION].asUInt());
-
- EXPECT_EQ(smartobjects_ns::SmartType_Map,
- result_object[strings_ns::S_MSG_PARAMS]["mandatory_emptyMap1"].getType());
- EXPECT_EQ(0u,
- result_object[strings_ns::S_MSG_PARAMS]["mandatory_emptyMap1"].length());
- EXPECT_EQ(smartobjects_ns::SmartType_Map,
- result_object[strings_ns::S_MSG_PARAMS]["mandatory_emptyMap2"].getType());
- EXPECT_EQ(0u,
- result_object[strings_ns::S_MSG_PARAMS]["mandatory_emptyMap2"].length());
- EXPECT_EQ(smartobjects_ns::SmartType_Array,
- result_object[strings_ns::S_MSG_PARAMS]["mandatory_emptyAray"].getType());
- EXPECT_EQ(0u,
- result_object[strings_ns::S_MSG_PARAMS]["mandatory_emptyAray"].length());
- EXPECT_EQ(100,
- result_object[strings_ns::S_MSG_PARAMS]["non_mandatory_Array"][0].asInt());
- EXPECT_EQ(200,
- result_object[strings_ns::S_MSG_PARAMS]["non_mandatory_Array"][1].asInt());
- EXPECT_EQ(300u,
- result_object[strings_ns::S_MSG_PARAMS]["non_mandatory_Array"][2].asUInt());
- EXPECT_EQ(std::string("defValue"),
- result_object[strings_ns::S_MSG_PARAMS]["mandatory_string"].asString());
- EXPECT_EQ(std::string("some string"),
- result_object[strings_ns::S_MSG_PARAMS]["non_mandatory_string"].asString());
-}
-}}}}
-
-namespace NsSmartDeviceLink {
-namespace NsSmartObjects {
-
-template<>
-const EnumConversionHelper<testhelper_ns::function_id::EType>::EnumToCStringMap
-EnumConversionHelper<testhelper_ns::function_id::EType>::enum_to_cstring_map_ =
- EnumConversionHelper<testhelper_ns::function_id::EType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<testhelper_ns::function_id::EType>::CStringToEnumMap
-EnumConversionHelper<testhelper_ns::function_id::EType>::cstring_to_enum_map_ =
- EnumConversionHelper<testhelper_ns::function_id::EType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<testhelper_ns::function_id::EType>::cstring_values_[] = {
- "RegisterAppInterface",
- "UnregisterAppInterface",
- "SetGlobalProperties"
-};
-
-template<>
-const testhelper_ns::function_id::EType
-EnumConversionHelper<testhelper_ns::function_id::EType>::enum_values_[] = {
- testhelper_ns::function_id::kRegisterAppInterfaceID,
- testhelper_ns::function_id::kUnregisterAppInterfaceID,
- testhelper_ns::function_id::kSetGlobalPropertiesID
-};
-
-template<>
-const EnumConversionHelper<testhelper_ns::message_type::EType>::EnumToCStringMap
-EnumConversionHelper<testhelper_ns::message_type::EType>::enum_to_cstring_map_ =
- EnumConversionHelper<testhelper_ns::message_type::EType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<testhelper_ns::message_type::EType>::CStringToEnumMap
-EnumConversionHelper<testhelper_ns::message_type::EType>::cstring_to_enum_map_ =
- EnumConversionHelper<testhelper_ns::message_type::EType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<testhelper_ns::message_type::EType>::cstring_values_[] = {
- "request",
- "response",
- "notification"
-};
-
-template<>
-const testhelper_ns::message_type::EType
-EnumConversionHelper<testhelper_ns::message_type::EType>::enum_values_[] = {
- testhelper_ns::message_type::kRequest,
- testhelper_ns::message_type::kResponse,
- testhelper_ns::message_type::kNotification
-};
-
-}}
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/json_handler/src/meta_formatter_test_helper.cc b/test/components/json_handler/src/meta_formatter_test_helper.cc
deleted file mode 100644
index 856a2ecf9..000000000
--- a/test/components/json_handler/src/meta_formatter_test_helper.cc
+++ /dev/null
@@ -1,245 +0,0 @@
-/**
- * @file meta_formatter_test_helper.cc
- * @brief implementation of class CMetaFormatterTestHelper which is designed to
- * create test environemnt to test class CMetaFormatter
- */
-// 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.
-
-
-#include "formatters/CFormatterJsonBase.hpp"
-#include "json_handler/meta_formatter_test_helper.h"
-
-// using test::components::JSONHandler::formatters;
-using namespace NsSmartDeviceLink::NsJSONHandler::Formatters;
-using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-
-namespace test {
-namespace components {
-namespace JSONHandler {
-namespace formatters {
-
-void CMetaFormatterTestHelper::SetUp() {
-
- function_id_items_.insert(function_id::kRegisterAppInterfaceID);
- function_id_items_.insert(function_id::kUnregisterAppInterfaceID);
- function_id_items_.insert(function_id::kSetGlobalPropertiesID);
-
- message_type_items_.insert(message_type::kRequest);
- message_type_items_.insert(message_type::kResponse);
- message_type_items_.insert(message_type::kNotification);
-}
-
-void CMetaFormatterTestHelper::TearDown() {
- function_id_items_.clear();
- message_type_items_.clear();
-}
-
-//-----------------------------------------------------------
-
-void CMetaFormatterTestHelper::AnyObjectToJsonString(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& obj, std::string& result_string) {
-
- Json::Value params(Json::objectValue);
-
- NsSmartDeviceLink::NsSmartObjects::SmartObject formattedObj(obj);
-
- CFormatterJsonBase::objToJsonValue(formattedObj, params);
-
- result_string = params.toStyledString();
-}
-
-//-----------------------------------------------------------
-
-void CMetaFormatterTestHelper::FillObjectIdenticalToSchema(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj) {
-
- obj[S_PARAMS][S_MESSAGE_TYPE] =
- generated_ns::messageType::request;
- obj[S_PARAMS][S_FUNCTION_ID] =
- generated_ns::FunctionID::RegisterAppInterfaceID;
- obj[S_PARAMS][S_CORRELATION_ID] = 12;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
-
- obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
- obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
- obj[S_MSG_PARAMS]["appName"] = "APP NAME";
- obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
- generated_ns::SpeechCapabilities::SC_TEXT;
- obj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "SCREEN NAME";
- obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
- obj[S_MSG_PARAMS]["isMediaApplication"] = true;
- obj[S_MSG_PARAMS]["languageDesired"] =
- generated_ns::Language::EN_EU;
- obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] =
- generated_ns::Language::RU_RU;
- obj[S_MSG_PARAMS]["appType"][0] = generated_ns::AppType::SYSTEM;
- obj[S_MSG_PARAMS]["appType"][1] = generated_ns::AppType::MEDIA;
- obj[S_MSG_PARAMS]["appID"] = "APP ID";
-}
-
-//-----------------------------------------------------------
-
-void CMetaFormatterTestHelper::FillObjectIdenticalToSchemaWithoutNoMandatoriesParams(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj) {
- obj[S_PARAMS][S_MESSAGE_TYPE] =
- generated_ns::messageType::request;
- obj[S_PARAMS][S_FUNCTION_ID] =
- generated_ns::FunctionID::RegisterAppInterfaceID;
- obj[S_PARAMS][S_CORRELATION_ID] = 12;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
-
- obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
- obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
- obj[S_MSG_PARAMS]["appName"] = "APP NAME";
-// obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC"; // not mandatory
-// obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
-// generated_ns::SpeechCapabilities::SC_TEXT;
- obj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "SCREEN NAME";
-// obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1"; // not mandatory
-// obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
- obj[S_MSG_PARAMS]["isMediaApplication"] = true;
- obj[S_MSG_PARAMS]["languageDesired"] =
- generated_ns::Language::EN_EU;
- obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] =
- generated_ns::Language::RU_RU;
-// obj[S_MSG_PARAMS]["appType"][0] = generated_ns::AppType::SYSTEM; // not mandatory
-// obj[S_MSG_PARAMS]["appType"][1] = generated_ns::AppType::MEDIA;
- obj[S_MSG_PARAMS]["appID"] = "APP ID";
-}
-
-void CMetaFormatterTestHelper::FillObjectWithoutSomeMandatoryFields(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj) {
-obj[S_PARAMS][S_MESSAGE_TYPE] =
- generated_ns::messageType::request;
- obj[S_PARAMS][S_FUNCTION_ID] =
- generated_ns::FunctionID::RegisterAppInterfaceID;
-// obj[S_PARAMS][S_CORRELATION_ID] = 12;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
-
-// obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
-// obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
- obj[S_MSG_PARAMS]["appName"] = "APP NAME";
- obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
- generated_ns::SpeechCapabilities::SC_TEXT;
- obj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "SCREEN NAME";
- obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
- obj[S_MSG_PARAMS]["isMediaApplication"] = true;
- obj[S_MSG_PARAMS]["languageDesired"] =
- generated_ns::Language::EN_EU;
- obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] =
- generated_ns::Language::RU_RU;
- obj[S_MSG_PARAMS]["appType"][0] = generated_ns::AppType::SYSTEM;
- obj[S_MSG_PARAMS]["appType"][1] = generated_ns::AppType::MEDIA;
- obj[S_MSG_PARAMS]["appID"] = "APP ID";
-}
-
-//-----------------------------------------------------------
-
-void CMetaFormatterTestHelper::CompareObjects(
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& first,
- const NsSmartDeviceLink::NsSmartObjects::SmartObject& second) {
-
- if (NsSmartDeviceLink::NsSmartObjects::SmartType_Array == first.getType()) {
- ASSERT_EQ(NsSmartDeviceLink::NsSmartObjects::SmartType_Array, second.getType());
- for (size_t i = 0; i < first.length(); i++) {
- CompareObjects(first.getElement(i), second.getElement(i));
- }
- }
- else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Map == first.getType())
- {
- ASSERT_EQ(NsSmartDeviceLink::NsSmartObjects::SmartType_Map, second.getType());
- std::set<std::string> keys = first.enumerate();
-
- for (std::set<std::string>::const_iterator key = keys.begin();
- key != keys.end(); key++){
- CompareObjects(first.getElement(*key), second.getElement(*key));
- }
- }
- else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Boolean == first.getType()) {
- ASSERT_EQ(first.asBool(), second.asBool());
- }
- else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Integer == first.getType()) {
- ASSERT_EQ(first.asInt(), second.asInt());
- }
- else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Double == first.getType()) {
- ASSERT_EQ(first.asDouble(), second.asDouble());
- }
- else if (NsSmartDeviceLink::NsSmartObjects::SmartType_String == first.getType()) {
- ASSERT_EQ(first.asString(), second.asString());
- }
- else if (NsSmartDeviceLink::NsSmartObjects::SmartType_Null == first.getType()) {
- ASSERT_EQ(NsSmartDeviceLink::NsSmartObjects::SmartType_Null, second.getType());
- }
- else
- {
- FAIL() << "Unknown SmartObject type: " << first.getType();
- }
-}
-
-//-----------------------------------------------------------
-
-void CMetaFormatterTestHelper::FillObjectWithDefaultValues(
- NsSmartDeviceLink::NsSmartObjects::SmartObject& obj) {
-
- obj[S_PARAMS][S_MESSAGE_TYPE] = -1;
- obj[S_PARAMS][S_FUNCTION_ID] = -1;
- obj[S_PARAMS][S_CORRELATION_ID] = 0;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 0;
- obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
-
- obj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 0;
- obj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 0;
- obj[S_MSG_PARAMS]["appName"] = "";
-// obj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC"; // not mandatory
-// obj[S_MSG_PARAMS]["ttsName"][0]["type"] =
-// generated_ns::SpeechCapabilities::SC_TEXT;
- obj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "";
-// obj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1"; // not mandatory
-// obj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
- obj[S_MSG_PARAMS]["isMediaApplication"] = false;
- obj[S_MSG_PARAMS]["languageDesired"] = -1;
- obj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = -1;
-// obj[S_MSG_PARAMS]["appType"][0] = generated_ns::AppType::SYSTEM; // not mandatory
-// obj[S_MSG_PARAMS]["appType"][1] = generated_ns::AppType::MEDIA;
- obj[S_MSG_PARAMS]["appID"] = "";
-}
-
-}
-}
-}
-}
diff --git a/test/components/json_handler/src/smart_schema_draft_test.cc b/test/components/json_handler/src/smart_schema_draft_test.cc
deleted file mode 100644
index 141c01c56..000000000
--- a/test/components/json_handler/src/smart_schema_draft_test.cc
+++ /dev/null
@@ -1,32 +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.
-
-#include "json_handler/smart_schema_draft_test.h"
-
diff --git a/test/components/json_handler/src/test_json_rpc_full_scenario.cpp b/test/components/json_handler/src/test_json_rpc_full_scenario.cpp
deleted file mode 100644
index ba1ee950e..000000000
--- a/test/components/json_handler/src/test_json_rpc_full_scenario.cpp
+++ /dev/null
@@ -1,258 +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.
-
-#include <string>
-
-#include "gtest/gtest.h"
-
-#include "formatters/formatter_json_rpc.h"
-#include "test/components/json_handler/test_json_rpc.h"
-#include "test/components/json_handler/test_json_rpc_schema.h"
-
-
-namespace test {
-namespace components {
-namespace JSONHandler {
-namespace test_json_rpc_full_scenario {
-
-namespace so = NsSmartDeviceLink::NsSmartObjects;
-namespace gen = gen::test::components::json_rpc;
-namespace fm = NsSmartDeviceLink::NsJSONHandler::Formatters;
-namespace jhs = NsSmartDeviceLink::NsJSONHandler::strings;
-
-TEST(test_general, test_json_rpc_full) {
- std::string input_json =
- "{\n"
- " \"id\" : 1,\n"
- " \"jsonrpc\" : \"2.0\",\n"
- " \"method\" : \"interface1.Function1\",\n"
- " \"params\" : {\n"
- " \"param1\" : \"String Value\",\n"
- " \"param2\" : 13,\n"
- " \"param3\" : {\n"
- " \"member1\" : 1,\n"
- " \"member2\" : true,\n"
- " \"member3\" : 13.130,\n"
- " \"member4\" : [ 30, 40, 50 ]\n"
- " }\n"
- " }\n"
- "}\n";
-
- so::SmartObject object;
- ASSERT_TRUE(fm::FormatterJsonRpc::kSuccess ==
- (fm::FormatterJsonRpc::FromString<gen::FunctionID::eType,
- gen::messageType::eType>(
- input_json, object)));
-
- ASSERT_EQ(gen::FunctionID::interface1_Function1,
- object[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt());
- ASSERT_EQ(gen::messageType::request,
- object[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE].asInt());
-
- gen::test_json_rpc factory;
- ASSERT_TRUE(factory.attachSchema(object));
- ASSERT_TRUE(object.isValid());
-
- std::string output_json;
- ASSERT_TRUE(fm::FormatterJsonRpc::ToString(object, output_json));
-
- ASSERT_EQ(input_json, output_json);
-}
-
-TEST(test_JSONRPC_general, test_AttachSchema) {
- so::SmartObject object(so::SmartType_Map);
- gen::test_json_rpc factory;
-
- ASSERT_FALSE(factory.AttachSchema(gen::StructIdentifiers::INVALID_ENUM,
- object));
-
- ASSERT_TRUE(factory.AttachSchema(
- gen::StructIdentifiers::interface1_struct1,
- object));
-
- object["member1"] = 1;
- object["member2"] = true;
- object["member3"] = 13.1313;
- object["member4"][0] = 12;
-
- ASSERT_TRUE(object.isValid());
-
- object["member3"] = 29.0;
-
- ASSERT_FALSE(object.isValid());
-
- object["member3"] = 13.0;
- object["xxx"] = 1234;
-
- ASSERT_FALSE(object.isValid());
-}
-
-TEST(test_JSONRPC_general, test_SmartObjectCreation) {
- gen::test_json_rpc factory;
-
- so::SmartObject object = factory.CreateSmartObject(
- gen::StructIdentifiers::INVALID_ENUM);
-
- ASSERT_EQ(so::SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(gen::FunctionID::INVALID_ENUM,
- gen::messageType::INVALID_ENUM);
-
- ASSERT_EQ(so::SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(gen::FunctionID::interface1_Function1,
- gen::messageType::INVALID_ENUM);
-
- ASSERT_EQ(so::SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(gen::FunctionID::INVALID_ENUM,
- gen::messageType::response);
-
- ASSERT_EQ(so::SmartType_Null, object.getType());
-
- object = factory.CreateSmartObject(
- gen::StructIdentifiers::interface1_struct2);
-
- ASSERT_EQ(so::SmartType_Map, object.getType());
-
- object["m1"] = "xxx";
- object["m2"][0] = "yyy";
- object["m3"] = gen::interface1_enum1::element1;
- object["m4"][0]["member1"] = 1;
- object["m4"][0]["member2"] = true;
- object["m4"][0]["member3"] = 13.1313;
- object["m4"][0]["member4"][0] = 12;
-
- ASSERT_TRUE(object.isValid());
-
- object["zzz"] = "yyy";
-
- ASSERT_FALSE(object.isValid());
-
- object = factory.CreateSmartObject(gen::FunctionID::interface2_Function1,
- gen::messageType::notification);
-
- object[jhs::S_PARAMS][jhs::S_FUNCTION_ID] =
- gen::FunctionID::interface2_Function1;
- object[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] =
- gen::messageType::notification;
- object[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 2;
- object[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 111;
- object[jhs::S_MSG_PARAMS]["param"] = gen::interface2_enum2::element2;
- object[jhs::S_MSG_PARAMS]["i1"]["m1"] = "xxx";
- object[jhs::S_MSG_PARAMS]["i1"]["m2"][0] = "yyy";
- object[jhs::S_MSG_PARAMS]["i1"]["m3"] = gen::interface1_enum1::element1;
- object[jhs::S_MSG_PARAMS]["i1"]["m4"][0]["member1"] = 1;
- object[jhs::S_MSG_PARAMS]["i1"]["m4"][0]["member2"] = true;
- object[jhs::S_MSG_PARAMS]["i1"]["m4"][0]["member3"] = 13.1313;
- object[jhs::S_MSG_PARAMS]["i1"]["m4"][0]["member4"][0] = 12;
-
- ASSERT_TRUE(object.isValid());
-
- object[jhs::S_MSG_PARAMS]["Noise"] = "Bzzzzzz!!!";
-
- ASSERT_FALSE(object.isValid());
-}
-
-TEST(test_JSONRPC_general, test_GetSmartSchema) {
- gen::test_json_rpc factory;
- so::CSmartSchema schema;
-
- ASSERT_FALSE(factory.GetSchema(gen::StructIdentifiers::INVALID_ENUM,
- schema));
-
- ASSERT_FALSE(factory.GetSchema(gen::FunctionID::INVALID_ENUM,
- gen::messageType::INVALID_ENUM,
- schema));
-
- ASSERT_FALSE(factory.GetSchema(gen::FunctionID::interface1_Function1,
- gen:: messageType::INVALID_ENUM,
- schema));
-
- ASSERT_FALSE(factory.GetSchema(gen::FunctionID::INVALID_ENUM,
- gen::messageType::response,
- schema));
-
- ASSERT_TRUE(factory.GetSchema(gen::StructIdentifiers::interface1_struct1,
- schema));
-
- so::SmartObject object(so::SmartType_Map);
- object.setSchema(schema);
-
- object["member1"] = 1;
- object["member2"] = true;
- object["member3"] = 13.1313;
- object["member4"][0] = 12;
-
- ASSERT_TRUE(object.isValid());
-
- object["member3"] = 1000.0;
-
- ASSERT_FALSE(object.isValid());
-
- object["member3"] = 13.1313;
- object["zzzz"] = 200;
-
- ASSERT_FALSE(object.isValid());
-
- ASSERT_TRUE(factory.GetSchema(gen::FunctionID::interface1_Function1,
- gen::messageType::request,
- schema));
-
- object = so::SmartObject(so::SmartType_Map);
- object.setSchema(schema);
-
- object[jhs::S_PARAMS][jhs::S_FUNCTION_ID] =
- gen::FunctionID::interface1_Function1;
- object[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] = gen::messageType::request;
- object[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = 22;
- object[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 1;
- object[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1;
- object[jhs::S_MSG_PARAMS]["param2"] = 10;
-
- ASSERT_TRUE(object.isValid());
-
- object[jhs::S_PARAMS]["blah-blah"] = "YouShallNotPass!";
-
- ASSERT_FALSE(object.isValid());
-}
-
-} // namespace test_json_rpc_full_scenario
-} // namespace JSONHandler
-} // namespace components
-} // namespace test
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-
-
-
diff --git a/test/components/json_handler/test_JSONHandler_v4_protocol_v1_2_no_extra.xml b/test/components/json_handler/test_JSONHandler_v4_protocol_v1_2_no_extra.xml
deleted file mode 100644
index c30e051f8..000000000
--- a/test/components/json_handler/test_JSONHandler_v4_protocol_v1_2_no_extra.xml
+++ /dev/null
@@ -1,1154 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!-- edited with XMLSpy v2011 rel. 3 sp1 (x64) (http://www.altova.com) by Olesksandr Leshchenko (HP) -->
-<?xml-stylesheet type="text/xml" href="protocol2html.xsl"?>
-<interface name="Ford Sync RAPI" version="1.2" date="2011-05-17">
- <enum name="Result">
- <element name="SUCCESS">
- <description>The request succeeded</description>
- </element>
- <element name="INVALID_DATA">
- <description>The data sent is invalid. For example</description>
- <description>Invalid Json syntax</description>
- <description>Parameters out of bounds (number or enum range)</description>
- <description>Mandatory parameters not provided</description>
- <description>Parameter provided with wrong type</description>
- <description>Invalid characters</description>
- <description>Empty string</description>
- </element>
- <element name="UNSUPPORTED_REQUEST">
- <description>The request is not supported by Sync</description>
- </element>
- <element name="OUT_OF_MEMORY">
- <description>The system could not process the request because the necessary memory couldn't be allocated</description>
- </element>
- <element name="TOO_MANY_PENDING_REQUESTS">
- <description>There are too many requests pending (means, that the response has not been delivered, yet).</description>
- <designdescription>There may be a maximum of 1000 pending requests at a time.</designdescription>
- </element>
- <element name="INVALID_ID">
- <description>One of the provided IDs is not valid. For example</description>
- <description>This applies to CorrelationID, SubscriptionID [@TODO if SubscriptionID is used], CommandID, MenuID, [@TODO: missed one?]</description>
- </element>
- <element name="DUPLICATE_NAME">
- <description>There was a conflict with an registered name (application or menu item) or vr command</description>
- </element>
- <element name="TOO_MANY_APPLICATIONS">
- <description>There are already too many registered applications</description>
- </element>
- <element name="APPLICATION_REGISTERED_ALREADY">
- <description>RegisterApplication has been called again, after a RegisterApplication was successful before.</description>
- </element>
- <element name="UNSUPPORTED_VERSION">
- <description>Sync doesn't support the protocol that is requested by the mobile application</description>
- </element>
- <element name="WRONG_LANGUAGE">
- <description>The requested language is currently not supported.</description>
- <description>Might be because of a mismatch of the currently active language on Sync and the requested language</description>
- </element>
- <element name="APPLICATION_NOT_REGISTERED">
- <description>An command can not be executed because no application has been registered with RegisterApplication.</description>
- </element>
- <element name="IN_USE">
- <description>The data may not be changed, because it is currently in use.</description>
- <description>For example when trying to delete a command set that is currently involved in an interaction.</description>
- </element>
- <element name="SUBSCRIBED_ALREADY">
- <description>The item to subscribe to is already subscribed to.</description>
- </element>
- <element name="REJECTED">
- <description>The requested command was rejected, e.g. because mobile app is in background and cannot perform any HMI commands.</description>
- <description>Or an HMI command (e.g. Speak) is rejected because a higher priority HMI command (e.g. Alert) is playing.</description>
- </element>
- <element name="ABORTED">
- <description>A command was aborted, for example due to user interaction (e.g. user pressed button).</description>
- <description>Or an HMI command (e.g. Speak) is aborted because a higher priority HMI command (e.g. Alert) was requested.</description>
- </element>
- <element name="IGNORED">
- <description>A command was ignored, because the intended result is already in effect.</description>
- <description>For example, SetMediaClockTimer was used to pause the media clock although the clock is paused already.</description>
- <description>NOTE: potentially replaces SUBSCRIBED_ALREADY</description>
- </element>
- <element name="UNSUPPORTED_BUTTON">
- <description>A button that was requested for subscription is not supported under the current system.</description>
- <description>NOTE: could become a more generic UNSUPPORTED_RESOURCE by merging with VEHIVLE_DATA_NOT_AVAILABLE.</description>
- </element>
- <element name="FILE_NOT_FOUND">
- <description>A specified file could not be found on Sync.</description>
- </element>
- <element name="GENERIC_ERROR">
- <description>Provided data is valid but something went wrong in the lower layers.</description>
- </element>
- </enum>
- <enum name="ButtonPressMode">
- <element name="LONG">
- <description>A button was released, after it was pressed for a long time</description>
- <description>Actual timing is defined by Sync and may vary</description>
- </element>
- <element name="SHORT">
- <description>A button was released, after it was pressed for a short time</description>
- <description>Actual timing is defined by Sync and may vary</description>
- </element>
- </enum>
- <enum name="ButtonEventMode">
- <element name="BUTTONUP">
- <description>A button has been released up</description>
- </element>
- <element name="BUTTONDOWN">
- <description>A button has been pressed down</description>
- </element>
- </enum>
- <enum name="Language">
- <description>The set of potential languages</description>
- <element name="EN-US" internal_name="EN_US">
- <description>US English</description>
- </element>
- <element name="ES-MX" internal_name="ES_MX">
- <description>Mexican Spanish</description>
- </element>
- <element name="FR-CA" internal_name="FR_CA">
- <description>Canadian French</description>
- </element>
- </enum>
- <enum name="UpdateMode">
- <description>Describes how the media clock timer should behave on the platform</description>
- <element name="COUNTUP"/>
- <description>Starts the media clock timer counting upwards, as in time elapsed.</description>
- <element name="COUNTDOWN"/>
- <description>Starts the media clock timer counting downwards, as in time remaining.</description>
- <element name="PAUSE"/>
- <description>Pauses the media clock timer</description>
- <element name="RESUME"/>
- <description>Resume the media clock timer</description>
- </enum>
- <enum name="InteractionMode">
- <description>For application-requested interactions, this mode indicates the method in which the user is notified and uses the interaction.</description>
- <element name="MANUAL_ONLY"/>
- <description>This mode causes the interaction to only occur on the display, meaning the choices are provided only via the display.</description>
- <description>Selections are made with the OK and Seek Right and Left, Tune Up and Down buttons.</description>
- <element name="VR_ONLY"/>
- <description>This mode causes the interaction to only occur using V4.</description>
- <description>Selections are made by saying the command.</description>
- <element name="BOTH"/>
- <description>This mode causes both a VR and display selection option for an interaction.</description>
- <description>Selections can be made either from the menu display or by speaking the command.</description>
- </enum>
- <enum name="HMILevel">
- <description>Enumeraction that describes current levels of HMI.</description>
- <element name="FULL" internal_name="HMI_FULL"/>
- <element name="LIMITED" internal_name="HMI_LIMITED"/>
- <element name="BACKGROUND" internal_name="HMI_BACKGROUND"/>
- <element name="NONE" internal_name="HMI_NONE"/>
- </enum>
- <enum name="AudioStreamingState">
- <description>Enumeraction that describes possible states of audio streaming.</description>
- <element name="AUDIBLE"/>
- <element name="NOT_AUDIBLE"/>
- </enum>
- <enum name="SystemContext">
- <description>Enumeraction that describes possible contexts and app's HMI might be in.</description>
- <element name="MAIN" internal_name="SYSCTXT_MAIN"/>
- <element name="VRSESSION" internal_name="SYSCTXT_VRSESSION"/>
- <element name="MENU" internal_name="SYSCTXT_MENU"/>
- </enum>
- <enum name="AppInterfaceUnregisteredReason">
- <description>Error code, which comes from sync side.</description>
- <element name="USER_EXIT"/>
- <element name="IGNITION_OFF"/>
- <element name="BLUETOOTH_OFF"/>
- <element name="USB_DISCONNECTED"/>
- <element name="REQUEST_WHILE_IN_NONE_HMI_LEVEL"/>
- <element name="TOO_MANY_REQUESTS"/>
- <element name="DRIVER_DISTRACTION_VIOLATION"/>
- <element name="LANGUAGE_CHANGE"/>
- <element name="MASTER_RESET"/>
- <element name="FACTORY_DEFAULTS"/>
- </enum>
- <enum name="TriggerSource">
- <description>Indicates the source from where the command was triggered.</description>
- <element name="MENU" internal_name="TS_MENU"/>
- <element name="VR" internal_name="TS_VR"/>
- </enum>
- <enum name="HmiZoneCapabilities">
- <description>Contains information about the HMI zone capabilities.</description>
- <description>For future use.</description>
- <element name="FRONT"/>
- <element name="BACK"/>
- </enum>
- <enum name="SpeechCapabilities">
- <description>Contains information about the TTS capabilities.</description>
- <element name="TEXT"/>
- <element name="SAPI_PHONEMES"/>
- <element name="LHPLUS_PHONEMES"/>
- <element name="PRE_RECORDED"/>
- <element name="SILENCE"/>
- </enum>
- <enum name="VrCapabilities">
- <description>Contains information about the VR capabilities.</description>
- <element name="Text"/>
- </enum>
- <enum name="AudioCaptureQuality" platform="pending">
- <description>Describes different quality options for PerformAudioCapture.</description>
- <element name="8KHZ" internal_name="AudioCaptureQuality_8KHZ" />
- <element name="16KHZ" internal_name="AudioCaptureQuality_16KHZ" />
- </enum>
- <enum name="ButtonName">
- <description>Defines the hard (physical) and soft (touchscreen) buttons available from SYNC</description>
- <element name="OK"/>
- <element name="SEEKLEFT"/>
- <element name="SEEKRIGHT"/>
- <element name="TUNEUP"/>
- <element name="TUNEDOWN"/>
- <element name="PRESET_0"/>
- <element name="PRESET_1"/>
- <element name="PRESET_2"/>
- <element name="PRESET_3"/>
- <element name="PRESET_4"/>
- <element name="PRESET_5"/>
- <element name="PRESET_6"/>
- <element name="PRESET_7"/>
- <element name="PRESET_8"/>
- <element name="PRESET_9"/>
- <issue creator="rs">Are these all supported buttons?</issue>
- </enum>
- <enum name="MediaClockFormat">
- <element name="CLOCK1">
- <description>minutesFieldWidth = 2;minutesFieldMax = 19;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 19;maxMinutes = 59;maxSeconds = 59;</description>
- <description>used for Type II and CID headunits</description>
- </element>
- <element name="CLOCK2">
- <description>minutesFieldWidth = 3;minutesFieldMax = 199;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 59;maxMinutes = 59;maxSeconds = 59;</description>
- <description>used for Type V headunit</description>
- </element>
- <element name="CLOCKTEXT1">
- <description>5 characters possible</description>
- <description>Format: 1|sp c :|sp c c</description>
- <description>1|sp : digit "1" or space</description>
- <description>c : character out of following character set: sp|0-9|[letters, see TypeII column in XLS. See [@TODO: create file ref]]</description>
- <description>:|sp : colon or space</description>
- <description>used for Type II headunit</description>
- </element>
- <element name="CLOCKTEXT2">
- <description>5 chars possible</description>
- <description>Format: 1|sp c :|sp c c</description>
- <description>1|sp : digit "1" or space</description>
- <description>c : character out of following character set: sp|0-9|[letters, see CID column in XLS. See [@TODO: create file ref]]</description>
- <description>:|sp : colon or space</description>
- <description>used for CID headunit</description>
- <description>NOTE: difference between CLOCKTEXT1 and CLOCKTEXT2 is the supported character set</description>
- </element>
- <element name="CLOCKTEXT3">
- <description>6 chars possible</description>
- <description>Format: 1|sp c c :|sp c c</description>
- <description>1|sp : digit "1" or space</description>
- <description>c : character out of following character set: sp|0-9|[letters, see Type 5 column in XLS]. See [@TODO: create file ref]</description>
- <description>:|sp : colon or space</description>
- <description>used for Type V headunit</description>
- </element>
- <issue creator="mf">First complete values draft. Review needed.</issue>
- </enum>
- <enum name="DisplayType">
- <description>See DAES for further infos regarding the displays]</description>
- <issue creator="rs">Meaningful description is missing</issue>
- <element name="CID"/>
- <element name="TYPE2"/>
- <element name="TYPE5"/>
- <element name="NGN"/>
- <element name="GEN2_8_DMA"/>
- <element name="GEN2_6_DMA"/>
- <element name="MFD3"/>
- <element name="MFD4"/>
- <element name="MFD5"/>
- </enum>
- <enum name="TextFieldName">
- <element name="mainField1">
- <description>The first line of the main field of persistent display</description>
- <description>Applies to "Show"</description>
- </element>
- <element name="mainField2">
- <description>The second line of the main field of persistent display</description>
- <description>Applies to "Show"</description>
- </element>
- <element name="statusBar">
- <description>The status bar on Nav</description>
- <description>Applies to "Show"</description>
- </element>
- <element name="mediaClock">
- <description>Text value for MediaClock field. Has to be properly formatted by Mobile App according to Sync capabilities.</description>
- <description>Applies to "Show"</description>
- </element>
- <element name="mediaTrack">
- <description>The track field of NGN type ACMs.</description>
- <description>This field is only available for media applications.</description>
- <description>Applies to "Show"</description>
- </element>
- <element name="alertText1">
- <description>The first line of the alert text field</description>
- <description>Applies to "Alert"</description>
- </element>
- <element name="alertText2">
- <description>The second line of the alert text field</description>
- <description>Applies to "Alert"</description>
- </element>
- </enum>
- <enum name="CharacterSet">
- <description>The list of potential character sets</description>
- <element name="TYPE2SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <element name="TYPE5SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <element name="CID1SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <element name="CID2SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <issue creator="rs">Real sets have not been defined yet?</issue>
- </enum>
- <enum name="TextAlignment">
- <description>The list of possible alignments, left, right, or centered</description>
- <element name="LEFT_ALIGNED"/>
- <element name="RIGHT_ALIGNED"/>
- <element name="CENTERED"/>
- </enum>
- <enum name="TBTState">
- <description>Enumeration that describes possible states of turn-by-turn module.</description>
- <element name="ROUTE_UPDATE_REQUEST"/>
- <element name="ROUTE_ACCEPTED"/>
- <element name="ROUTE_REFUSED"/>
- <element name="ROUTE_CANCELLED"/>
- </enum>
- <enum name="DriverDistractionState">
- <description>Enumeration that describes possible states of driver distraction.</description>
- <element name="DD_ON"/>
- <element name="DD_OFF"/>
- </enum>
- <struct name="Choice">
- <description>A choice is an option given to the user, which can be selected either by menu, or through voice recognition system.</description>
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535"/>
- <param name="menuName" type="String" maxlength="500"/>
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true"/>
- </struct>
- <struct name="SyncMsgVersion">
- <description>Specifies the version number of the SYNC V4 protocol, that is supported by the mobile application</description>
- <param name="majorVersion" type="Integer" minvalue="1" maxvalue="1">
- <description>The major version indicates versions that is not-compatible to previous versions.</description>
- </param>
- <param name="minorVersion" type="Integer" minvalue="0" maxvalue="1000">
- <description>The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality)</description>
- </param>
- </struct>
- <enum name="GlobalProperty">
- <description>The different global properties.</description>
- <element name="HELPPROMPT">
- <description>The property helpPrompt of setGlobalProperties</description>
- </element>
- <element name="TIMEOUTPROMPT">
- <description>The property timeoutPrompt of setGlobalProperties</description>
- </element>
- </enum>
- <struct name="StartTime">
- <param name="hours" type="Integer" minvalue="0" maxvalue="59">
- <description>The hour of the media clock.</description>
- <description>Some radios only support a max of 19 hours. If out of range, it will be rejected.</description>
- </param>
- <param name="minutes" type="Integer" minvalue="0" maxvalue="59"/>
- <param name="seconds" type="Integer" minvalue="0" maxvalue="59"/>
- </struct>
- <struct name="TextField">
- <param name="name" type="TextFieldName">
- <description>The name that identifies the field. See TextFieldName.</description>
- </param>
- <param name="characterSet" type="CharacterSet">
- <description>The character set that is supported in this field. See CharacterSet.</description>
- </param>
- <param name="width" type="Integer" minvalue="1" maxvalue="40">
- <description>The number of characters in one row of this field.</description>
- </param>
- <param name="rows" type="Integer" minvalue="1" maxvalue="3">
- <description>The number of rows of this field.</description>
- </param>
- </struct>
- <struct name="DisplayCapabilities">
- <description>Contains information about the display capabilities.</description>
- <param name="displayType" type="DisplayType">
- <description>The type of the display. See DisplayType</description>
- </param>
- <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true">
- <description>A set of all fields that support text data. See TextField</description>
- </param>
- <param name="mediaClockFormats" type="MediaClockFormat" minsize="1" maxsize="100" array="true">
- <description>A set of all supported formats of the media clock. See MediaClockFormat</description>
- </param>
- </struct>
- <struct name="ButtonCapabilities">
- <description>Contains information about a buttons capabilities.</description>
- <param name="name" type="ButtonName">
- <description>The name of the button. See ButtonName.</description>
- </param>
- <param name="shortPressAvailable" type="Boolean">
- <description>The button supports a short press.</description>
- <description>Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked.</description>
- </param>
- <param name="longPressAvailable" type="Boolean">
- <description>The button supports a LONG press.</description>
- <description>Whenever the button is pressed long, onButtonPressed( LONG) will be invoked.</description>
- </param>
- <param name="upDownAvailable" type="Boolean">
- <description>The button supports "button down" and "button up".</description>
- <description>Whenever the button is pressed, onButtonEvent( DOWN) will be invoked.</description>
- <description>Whenever the button is released, onButtonEvent( UP) will be invoked.</description>
- </param>
- </struct>
- <struct name="MenuParams">
- <param name="parentID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
- <description>unique ID of the sub menu, the command will be added to.</description>
- <description>If not provided, it will be provided to the top level of the in application menu.</description>
- </param>
- <param name="position" type="Integer" minvalue="0" maxvalue="1000" mandatory="false">
- <description>Position within the items that are are at top level of the in application menu.</description>
- <description>0 will insert at the front.</description>
- <description>1 will insert at the second position.</description>
- <description>if position is greater or equal than the number of items on top level, the sub menu will be appended to the end.</description>
- <description>If this param was omitted the entry will be added at the end.</description>
- </param>
- <param name="menuName" type="String" maxlength="500">
- <description>Text to show in the menu for this sub menu.</description>
- </param>
- </struct>
- <struct name="TTSChunk">
- <description>A TTS chunk, that consists of the text/phonemes to speak and the type (like text or SAPI)</description>
- <param name="text" maxlength="500" type="String">
- <description>The text or phonemes to speak.</description>
- <description>May not be empty.</description>
- </param>
- <param name="type" type="SpeechCapabilities">
- <description>Describes, whether it is text or a specific phoneme set. See SpeechCapabilities</description>
- </param>
- </struct>
- <!-- Requests/Responses -->
- <function name="RegisterAppInterface" messagetype="request">
- <description>Establishes an interface with a mobile application.</description>
- <description>Before registerAppInterface no other commands will be accepted/executed.</description>
- <param name="syncMsgVersion" type="SyncMsgVersion">
- <description>See SyncMsgVersion</description>
- </param>
- <param name="appName" type="String" maxlength="100">
- <description>The mobile application name, e.g. "Ford Drive Green".</description>
- <description>Needs to be unique over all applications.</description>
- <description>May not be empty.</description>
- <description>May not start with a new line character.</description>
- <description>May not interfere with any name or synonym of previously registered applications and the following list of words @TODO: Create list(global commands)</description>
- <description>Needs to be unique over all applications. Applications with the same name will be rejected.</description>
- <description>Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported.</description>
- </param>
- <param name="ngnMediaScreenAppName" type="String" maxlength="100" mandatory="false">
- <description>Provides an abbreviated version of the app name (if needed), that will be displayed on the NGN media screen.</description>
- <description>If not provided, the appName is used instead (and will be truncated if too long)</description>
- <description>Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported.</description>
- </param>
- <param name="vrSynonyms" type="String" maxlength="40" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Defines an additional voice recognition command.</description>
- <description>May not interfere with any name or synonym of previously registered applications and the following list of words @TODO: Create list(global commands)</description>
- <description>Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported.</description>
- </param>
- <param name="usesVehicleData" type="Boolean" platform="pending" mandatory="false">
- <description>If not provided, the default is equal to False"</description>
- <description>Indicates if the mobile application wants to use vehicle data like GPS or speed.</description>
- </param>
- <param name="isMediaApplication" type="Boolean">
- <description>Indicates if the application is a media or a non-media application.</description>
- <description>Only media applications will be able to stream audio to Sync that is audible outside of the BT media source.</description>
- </param>
- <param name="languageDesired" type="Language">
- <description>See Language</description>
- <description>If the language doesn't match the active language on Sync, it will be rejected.</description>
- <description>If the language is changed, while an app is registered, it will get disconnected.</description>
- </param>
- <param name="autoActivateID" type="String" maxlength="16" mandatory="false">
- <description>Used to support auto activation after an initial successful registerAppInterface (for example after an ignition cycle).</description>
- <description>The app should always provide the id that was provided by the most recent registerAppInterface response.</description>
- <description>If this is the first call to registerAppInterface, then do not provide this parameter at all.</description>
- <description>If not provided or not matching with the id of the last registerAppInterface response, the app will not be automatically put into foreground on startup.</description>
- </param>
- </function>
- <function name="RegisterAppInterface" messagetype="response">
- <description>The response to registerAppInterface</description>
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="GENERIC_ERROR"/>
- <element name="DUPLICATE_NAME"/>
- <element name="TOO_MANY_APPLICATIONS"/>
- <element name="APPLICATION_REGISTERED_ALREADY"/>
- <element name="UNSUPPORTED_VERSION"/>
- <element name="WRONG_LANGUAGE"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- <param name="syncMsgVersion" type="SyncMsgVersion" mandatory="false">
- <description>See SyncMsgVersion</description>
- </param>
- <param name="autoActivateID" type="String" maxlength="16" mandatory="false">
- <description>Provides an id that the app may use on a subsequent registerAppInterface to allow for auto activation (for example after an ignition cycle).</description>
- </param>
- <param name="language" type="Language" mandatory="false">
- <description>The currently active language on Sync. See "Language" for options.</description>
- </param>
- <param name="displayCapabilities" type="DisplayCapabilities" mandatory="false">
- <description>See DisplayCapabilities</description>
- </param>
- <param name="buttonCapabilities" type="ButtonCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>See ButtonCapabilities</description>
- </param>
- <param name="hmiZoneCapabilities" type="HmiZoneCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <issue creator="rs">If not used yet => remove</issue>
- <description>See HmiZoneCapabilities</description>
- </param>
- <param name="speechCapabilities" type="SpeechCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>See SpeechCapabilities</description>
- </param>
- <param name="vrCapabilities" type="VrCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>See VrCapabilities</description>
- </param>
- </function>
- <function name="UnregisterAppInterface" messagetype="request">
- <description>Closes an interface from a mobile application.</description>
- <description>After unregisterAppInterface, no commands other than registerAppInterface will be accepted/executed.</description>
- <description>Will fail, if no registerAppInterface was completed successfully before.</description>
- </function>
- <function name="UnregisterAppInterface" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="SetGlobalProperties" messagetype="request">
- <description>Allows setting global properties.</description>
- <param name="helpPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>The help prompt.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- <param name="timeoutPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Help text for a wait timeout.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- <issue creator="rs">Do we want to add VR threshold params?</issue>
- </function>
- <function name="SetGlobalProperties" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="ResetGlobalProperties" messagetype="request">
- <description>Allows resetting global properties.</description>
- <param name="properties" type="GlobalProperty" minsize="1" maxsize="100" array="true">
- <description>Contains the names of all global properties (like timeoutPrompt) that should be unset. Resetting means, that they have the same value as at start up (default)</description>
- </param>
- </function>
- <function name="ResetGlobalProperties" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="AddCommand" messagetype="request">
- <description>Adds a command to the in application menu.</description>
- <description>Either menuParams or vrCommands must be provided.</description>
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>unique ID of the command to add.</description>
- </param>
- <param name="menuParams" type="MenuParams" mandatory="false">
- <description>Optional sub value containing menu parameters</description>
- </param>
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" mandatory="false">
- <description>An array of strings to be used as VR sysnonyms for this command.</description>
- <description>If this array is provided, it may not be empty.</description>
- </param>
- </function>
- <function name="AddCommand" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="DeleteCommand" messagetype="request">
- <description>Deletes all commands from the in-application menu with the specified command id.</description>
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>ID of the command(s) to delete.</description>
- </param>
- </function>
- <function name="DeleteCommand" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="IN_USE"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="AddSubMenu" messagetype="request">
- <description>Adds a sub menu to the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>unique ID of the sub menu to add.</description>
- </param>
- <param name="position" type="Integer" minvalue="0" maxvalue="1000" mandatory="false">
- <description>Position within the items that are are at top level of the in application menu.</description>
- <description>0 will insert at the front.</description>
- <description>1 will insert at the second position.</description>
- <description>If position is greater or equal than the number of items on top level, the sub menu will be appended to the end.</description>
- <description>Position of any submenu will always be located before the return and exit options</description>
- <description>If this param was omitted the entry will be added at the end.</description>
- </param>
- <param name="menuName" maxlength="500" type="String">
- <description>Text to show in the menu for this sub menu.</description>
- </param>
- </function>
- <function name="AddSubMenu" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="DeleteSubMenu" messagetype="request">
- <description>Deletes a submenu from the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>The "menuID" of the submenu to delete. (See addSubMenu.menuID)</description>
- </param>
- </function>
- <function name="DeleteSubMenu" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="IN_USE"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="CreateInteractionChoiceSet" messagetype="request">
- <description>creates interaction choice set to be used later by performInteraction</description>
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Unique ID used for this interaction choice set.</description>
- </param>
- <param name="choiceSet" type="Choice" minsize="1" maxsize="100" array="true"/>
- </function>
- <function name="CreateInteractionChoiceSet" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="PerformInteraction" messagetype="request">
- <description>Triggers an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow).</description>
- <param name="initialText" type="String" maxlength="500">
- <description>Text to be displayed first.</description>
- </param>
- <param name="initialPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true">
- <description>This is the intial prompt spoken to the user at the start of an interaction</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- <param name="interactionMode" type="InteractionMode">
- <description>See InteractionMode.</description>
- </param>
- <param name="interactionChoiceSetIDList" type="Integer" minsize="1" maxsize="100" minvalue="0" maxvalue="2000000000" array="true">
- <description>List of interaction choice set IDs to use with an interaction.</description>
- </param>
- <param name="helpPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Help text. This is the spoken string when a user speaks "help" when the interaction is occuring.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- <param name="timeoutPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Timeout text. This text is spoken when a VR interaction times out.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- <param name="timeout" type="Integer" minvalue="5000" maxvalue="100000" mandatory="false">
- <description>Timeout in milliseconds.</description>
- <description>If omitted a standard value of 10000 milliseconds is used.</description>
- </param>
- </function>
- <function name="PerformInteraction" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- <!--<element name="REJECTED"/>-->
- <element name="ABORTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
- <description>ID of the choice that was selected in response to PerformInteraction.</description>
- </param>
- <param name="triggerSource" type="TriggerSource" mandatory="false">
- <description>See TriggerSource</description>
- </param>
- </function>
- <function name="DeleteInteractionChoiceSet" messagetype="request">
- <description>Deletes interaction choice set that has been created with "CreateInteractionChoiceSet".</description>
- <description>The interaction may only be deleted when not currently in use by a "performInteraction".</description>
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>ID of the interaction choice set to delete.</description>
- </param>
- </function>
- <function name="DeleteInteractionChoiceSet" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="IN_USE"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="Alert" messagetype="request">
- <description>Shows an alert which typically consists of text-to-speech message and text on the display. At least either alertText1, alertText2 or TTSChunks need to be provided.</description>
- <param name="alertText1" type="String" maxlength="500" mandatory="false">
- <description>The first line of the alert text field</description>
- </param>
- <param name="alertText2" type="String" maxlength="500" mandatory="false">
- <description>The second line of the alert text field</description>
- </param>
- <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- <param name="duration" type="Integer" minvalue="3000" maxvalue="10000" mandatory="false">
- <description>Timeout in milliseconds.</description>
- <description>Typical timeouts are 3-5 seconds</description>
- <description>If omitted, timeout is set to 5s.</description>
- </param>
- <param name="playTone" type="Boolean" mandatory="false">
- <description>Defines if tone should be played. Tone is played before TTS.</description>
- <description>If omitted, no tone is played.</description>
- </param>
- </function>
- <function name="Alert" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="ABORTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="Show" messagetype="request">
- <description>Updates the persistent display. Supported fields depend on display capabilities.</description>
- <param name="mainField1" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed in a single or upper display line.</description>
- <description>If this text is not set, the text of mainField1 stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
- <param name="mainField2" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed on the second dispay line.</description>
- <description>If this text is not set, the text of mainField2 stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
- <param name="alignment" type="TextAlignment" mandatory="false">
- <description>Specifies how mainField1 and mainField2 texts should be aligned on display.</description>
- <description>If omitted, texts will be centered</description>
- </param>
- <param name="statusBar" type="String" maxlength="500" mandatory="false">
- <description>Requires investigation regarding the nav display capabilities. Potentially lower lowerStatusBar, upperStatusBar, titleBar, etc.</description>
- </param>
- <param name="mediaClock" type="String" maxlength="500" mandatory="false">
- <description>Text value for MediaClock field. Has to be properly formatted by Mobile App according to Sync capabilities.</description>
- <description>If this text is set, any automatic media clock updates previously set with SetMediaClockTimer will be stopped.</description>
- </param>
- <param name="mediaTrack" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed in the track field.</description>
- <description>This field is only valid for media applications on NGN type ACMs.</description>
- <description>If this text is not set, the text of mediaTrack stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
- </function>
- <function name="Show" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="Speak" messagetype="request">
- <description>Speaks a text.</description>
- <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true">
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- </function>
- <function name="Speak" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="ABORTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="SetMediaClockTimer" messagetype="request">
- <description>Sets the initial media clock value and automatic update method.</description>
- <param name="startTime" type="StartTime" mandatory="false">
- <description>See StartTime</description>
- <description>startTime must be provided for "run"</description>
- <description>startTime will be ignored for "pause" and "resum"</description>
- </param>
- <param name="updateMode" type="UpdateMode">
- <description>Enumeration to control the media clock.</description>
- <description>In case of pause or resume, the start time value is ignored and shall be left out. For resume, the time continues with the same value as it was when paused.</description>
- </param>
- </function>
- <function name="SetMediaClockTimer" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="IGNORED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="EncodedSyncPData" messagetype="request">
- <description>Allows encoded data in the form of SyncP packets to be sent to the SYNC module</description>
- <param name="data" type="String" maxlength="10000" minsize="1" maxsize="100" array="true" mandatory="true">
- <description>Contains base64 encoded string of SyncP packets.</description>
- <todo>What is the maxlength</todo>
- </param>
- </function>
- <function name="EncodedSyncPData" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="SubscribeButton" messagetype="request">
- <description>Subscribes to built-in HMI buttons.</description>
- <description>The application will be notified by the OnButtonEvent and OnButtonPress.</description>
- <description>To unsubscribe the notifications, use unsubscribeButton.</description>
- <param name="buttonName" type="ButtonName">
- <description>Name of the button to subscribe.</description>
- </param>
- </function>
- <function name="SubscribeButton" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="UNSUPPORTED_BUTTON"/>
- <element name="IGNORED"/>
- <element name="REJECTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="UnsubscribeButton" messagetype="request">
- <description>Unsubscribes from built-in HMI buttons.</description>
- <param name="buttonName" type="ButtonName">
- <description>Name of the button to unsubscribe.</description>
- </param>
- </function>
- <function name="UnsubscribeButton" messagetype="response">
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="UNSUPPORTED_BUTTON"/>
- <element name="IGNORED"/>
- <element name="REJECTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="GenericResponse" messagetype="response">
- <description>Generic Response is sent, when the name of a received msg cannot be retrieved. Only used in case of an error.</description>
- <description>Currently, only resultCode INVALID_DATA is used.</description>
- <param name="success" type="Boolean">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result">
- <description>See Result</description>
- <element name="INVALID_DATA"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <!-- Notifications -->
- <function name="OnHMIStatus" messagetype="notification">
- <param name="hmiLevel" type="HMILevel">
- <description>See HMILevel</description>
- </param>
- <param name="audioStreamingState" type="AudioStreamingState">
- <description>See AudioStreamingState</description>
- </param>
- <param name="systemContext" type="SystemContext">
- <description>See SystemContext</description>
- </param>
- </function>
- <function name="OnAppInterfaceUnregistered" messagetype="notification">
- <param name="reason" type="AppInterfaceUnregisteredReason">
- <description>See AppInterfaceUnregisteredReason</description>
- </param>
- </function>
- <function name="OnButtonEvent" messagetype="notification">
- <description>Notifies application of UP/DOWN events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonEventMode" type="ButtonEventMode">
- <description>Indicates whether this is an UP or DOWN event.</description>
- </param>
- </function>
- <function name="OnButtonPress" messagetype="notification">
- <description>Notifies application of LONG/SHORT press events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonPressMode" type="ButtonPressMode">
- <description>Indicates whether this is a LONG or SHORT button press event.</description>
- </param>
- </function>
- <function name="OnCommand" messagetype="notification">
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Command ID, which is related to a specific menu entry.</description>
- </param>
- <param name="triggerSource" type="TriggerSource">
- <description>See TriggerSource</description>
- </param>
- </function>
- <function name="OnEncodedSyncPData" messagetype="notification">
- <description>Callback including encoded data of any SyncP packets that SYNC needs to send back to the mobile device.</description>
- <param name="data" type="String" maxlength="10000" minsize="1" maxsize="100" mandatory="true" array="true">
- <description>Contains base64 encoded string of SyncP packets.</description>
- </param>
- </function>
- <function name="OnTBTClientState" messagetype="notification">
- <description>Provides applications with notifications specific to the current TBT client status on the module</description>
- <param name="state" type="TBTState">
- <description>Current State of TBT client</description>
- </param>
- </function>
- <function name="OnDriverDistraction" messagetype="notification">
- <description>Provides driver distraction state to mobile applications</description>
- <param name="state" type="DriverDistractionState">
- <description>Current State of Driver Distraction</description>
- </param>
- </function>
-
-
-</interface>
diff --git a/test/components/json_handler/test_JSONHandler_v4_protocol_v2_0_revP.xml b/test/components/json_handler/test_JSONHandler_v4_protocol_v2_0_revP.xml
deleted file mode 100644
index f37fcd9bc..000000000
--- a/test/components/json_handler/test_JSONHandler_v4_protocol_v2_0_revP.xml
+++ /dev/null
@@ -1,3174 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<?xml-stylesheet type="text/xml" href="protocol2html.xsl"?>
-
-<interface name="Ford Sync RAPI" version="2.0O" date="2012-11-02">
-
- <enum name="Result" internal_scope="base">
- <element name="SUCCESS">
- <description>The request succeeded</description>
- </element>
- <element name="INVALID_DATA">
- <description>The data sent is invalid. For example</description>
- <description>Invalid Json syntax</description>
- <description>Parameters out of bounds (number or enum range)</description>
- <description>Mandatory parameters not provided</description>
- <description>Parameter provided with wrong type</description>
- <description>Invalid characters</description>
- <description>Empty string</description>
- </element>
- <element name="UNSUPPORTED_REQUEST">
- <description>The request is not supported by Sync</description>
- </element>
- <element name="OUT_OF_MEMORY">
- <description>The system could not process the request because the necessary memory couldn't be allocated</description>
- </element>
- <element name="TOO_MANY_PENDING_REQUESTS">
- <description>There are too many requests pending (means, that the response has not been delivered, yet).</description>
- <designdescription>There may be a maximum of 1000 pending requests at a time.</designdescription>
- </element>
- <element name="INVALID_ID">
- <description>One of the provided IDs is not valid. For example</description>
- <description>This applies to CorrelationID, SubscriptionID [@TODO if SubscriptionID is used], CommandID, MenuID, [@TODO: missed one?]</description>
- </element>
- <element name="DUPLICATE_NAME">
- <description>There was a conflict with an registered name (application or menu item) or vr command</description>
- </element>
- <element name="TOO_MANY_APPLICATIONS">
- <description>There are already too many registered applications</description>
- </element>
- <element name="APPLICATION_REGISTERED_ALREADY">
- <description>RegisterApplication has been called again, after a RegisterApplication was successful before.</description>
- </element>
- <element name="UNSUPPORTED_VERSION">
- <description>Sync doesn't support the protocol that is requested by the mobile application</description>
- </element>
- <element name="WRONG_LANGUAGE">
- <description>The requested language is currently not supported.</description>
- <description>Might be because of a mismatch of the currently active language on Sync and the requested language</description>
- </element>
- <element name="APPLICATION_NOT_REGISTERED">
- <description>An command can not be executed because no application has been registered with RegisterApplication.</description>
- </element>
- <element name="IN_USE">
- <description>The data may not be changed, because it is currently in use.</description>
- <description>For example when trying to delete a command set that is currently involved in an interaction.</description>
- </element>
- <element name="SUBSCRIBED_ALREADY">
- <description>The item to subscribe to is already subscribed to.</description>
- </element>
- <element name="VEHICLE_DATA_NOT_ALLOWED">
- <description>The user has turned off access to vehicle data, and it is globally unavailable to mobile applications.</description>
- </element>
- <element name="VEHICLE_DATA_NOT_AVAILABLE">
- <description>The requested vehicle data is not available on this vehicle or is not published.</description>
- </element>
- <element name="REJECTED">
- <description>The requested command was rejected, e.g. because mobile app is in background and cannot perform any HMI commands.</description>
- <description>Or an HMI command (e.g. Speak) is rejected because a higher priority HMI command (e.g. Alert) is playing.</description>
- </element>
- <element name="ABORTED">
- <description>A command was aborted, for example due to user interaction (e.g. user pressed button).</description>
- <description>Or an HMI command (e.g. Speak) is aborted because a higher priority HMI command (e.g. Alert) was requested.</description>
- </element>
- <element name="IGNORED">
- <description>A command was ignored, because the intended result is already in effect.</description>
- <description>For example, SetMediaClockTimer was used to pause the media clock although the clock is paused already.</description>
- <description>NOTE: potentially replaces SUBSCRIBED_ALREADY</description>
- </element>
- <element name="UNSUPPORTED_BUTTON">
- <description>A button that was requested for subscription is not supported under the current system.</description>
- <description>NOTE: could become a more generic UNSUPPORTED_RESOURCE by merging with VEHIVLE_DATA_NOT_AVAILABLE.</description>
- </element>
- <element name="FILE_NOT_FOUND">
- <description>A specified file could not be found on Sync.</description>
- </element>
- <element name="GENERIC_ERROR">
- <description>Provided data is valid but something went wrong in the lower layers.</description>
- </element>
- <element name="DISALLOWED">
- <description>RPC is not authorized in local policy table.</description>
- </element>
- <element name="USER_DISALLOWED">
- <description>RPC is included in a functional group explicitly blocked by the user.</description>
- </element>
- <element name="TIMED_OUT">
- <description>Overlay reached the maximum timeout and closed.</description>
- </element>
- <element name="CANCEL_ROUTE">
- <description>User selected to Cancel Route.</description>
- </element>
- <element name="CLOSED">
- <description>User chose a Close command for the overlay.</description>
- </element>
- <element name="ENCRYPTED">
- <description>The data is being returned through an OnEncodedSYNCPData notification.</description>
- <description>The data is intended to be passed by the proxy to the designated server URL.</description>
- </element>
- <element name="WARNINGS">
- <description>The RPC (e.g. SubscribeVehicleData) executed successfully but one or more items have a warning or failure.</description>
- </element>
- </enum>
-
- <enum name="ButtonPressMode">
- <element name="LONG">
- <description>A button was released, after it was pressed for a long time</description>
- <description>Actual timing is defined by Sync and may vary</description>
- </element>
- <element name="SHORT">
- <description>A button was released, after it was pressed for a short time</description>
- <description>Actual timing is defined by Sync and may vary</description>
- </element>
- </enum>
-
- <enum name="ButtonEventMode">
- <element name="BUTTONUP">
- <description>A button has been released up</description>
- </element>
- <element name="BUTTONDOWN">
- <description>A button has been pressed down</description>
- </element>
- </enum>
-
- <enum name="Language">
- <element name="EN-US" internal_name="EN_US">
- <description>US English</description>
- </element>
- <element name="ES-MX" internal_name="ES_MX">
- <description>Mexican Spanish</description>
- </element>
- <element name="FR-CA" internal_name="FR_CA">
- <description>Canadian French</description>
- </element>
- <element name="DE-EU" internal_name="DE_EU">
- <description>EU German</description>
- </element>
- <element name="ES-EU" internal_name="ES_EU">
- <description>EU Spanish</description>
- </element>
- <element name="EN-EU" internal_name="EN_EU">
- <description>UK English</description>
- </element>
- <element name="RU-RU" internal_name="RU_RU">
- <description>Russian</description>
- </element>
- <element name="TR-TR" internal_name="TR_TR">
- <description>Turkish</description>
- </element>
- <element name="PL-EU" internal_name="PL_EU">
- <description>EU Polish</description>
- </element>
- <element name="FR-EU" internal_name="FR_EU">
- <description>French</description>
- </element>
- <element name="IT-EU" internal_name="IT_EU">
- <description>Italian</description>
- </element>
- <element name="SV-EU" internal_name="SV_EU">
- <description>Swedish</description>
- </element>
- <element name="PT-EU" internal_name="PT_EU">
- <description>Portuguese</description>
- </element>
- <element name="NL-EU" internal_name="NL_EU">
- <description>Dutch (Standard)</description>
- </element>
- <element name="EN-AU" internal_name="EN_AU">
- <description>Australian English</description>
- </element>
- <element name="ZH-CN" internal_name="ZH_CN">
- <description>Chinese (Mandarin)</description>
- </element>
- <element name="ZH-TW" internal_name="ZH_TW">
- <description>Taiwanese (Mandarin)</description>
- </element>
- <element name="JA-JP" internal_name="JA_JP">
- <description>Japanese</description>
- </element>
- <element name="AR" internal_name="AR">
- <description>Arabic</description>
- </element>
- <element name="KO-KR" internal_name="KO_KR">
- <description>Korean</description>
- </element>
-</enum>
-
- <enum name="UpdateMode">
- <description>Describes how the media clock timer should behave on the platform</description>
- <element name="COUNTUP" />
- <description>Starts the media clock timer counting upwards, as in time elapsed.</description>
- <element name="COUNTDOWN" />
- <description>Starts the media clock timer counting downwards, as in time remaining.</description>
- <element name="PAUSE" />
- <description>Pauses the media clock timer</description>
- <element name="RESUME" />
- <description>Resume the media clock timer</description>
- <element name="CLEAR" />
- <description>Clears the media clock timer (previously done through Show->mediaClock)</description>
- </enum>
-
- <enum name="TimerMode">
- <element name="UP" />
- <description>Causes the media clock timer to update from 0:00 to a specified time</description>
- <element name="DOWN" />
- <description>Causes the media clock timer to update from a specified time to 0:00</description>
- <element name="NONE" />
- <description>Indicates to not use the media clock timer</description>
- </enum>
-
- <enum name="InteractionMode">
- <description>For application-requested interactions, this mode indicates the method in which the user is notified and uses the interaction.</description>
- <element name="MANUAL_ONLY" />
- <description>This mode causes the interaction to only occur on the display, meaning the choices are provided only via the display.</description>
- <description>Selections are made with the OK and Seek Right and Left, Tune Up and Down buttons.</description>
- <element name="VR_ONLY" />
- <description>This mode causes the interaction to only occur using V4.</description>
- <description>Selections are made by saying the command.</description>
- <element name="BOTH" />
- <description>This mode causes both a VR and display selection option for an interaction.</description>
- <description>Selections can be made either from the menu display or by speaking the command.</description>
- </enum>
-
- <enum name="HMILevel">
- <description>Enumeraction that describes current levels of HMI.</description>
- <element name="FULL" internal_name="HMI_FULL" />
- <element name="LIMITED" internal_name="HMI_LIMITED" />
- <element name="BACKGROUND" internal_name="HMI_BACKGROUND" />
- <element name="NONE" internal_name="HMI_NONE" />
- </enum>
-
- <enum name="AudioStreamingState">
- <description>Enumeraction that describes possible states of audio streaming.</description>
- <element name="AUDIBLE" />
- <element name="ATTENUATED" />
- <element name="NOT_AUDIBLE" />
- </enum>
-
- <enum name="SystemAction">
- <description>Enumeration that describes system actions that can be triggered.</description>
- <element name="DEFAULT_ACTION">
- <description>Default action occurs. Standard behavior (e.g. SoftButton clears overlay).</description>
- </element>
- <element name="STEAL_FOCUS">
- <description>App is brought into HMI_FULL.</description>
- </element>
- <element name="KEEP_CONTEXT">
- <description>Current system context is maintained. An overlay is persisted even though a SoftButton has been pressed and the notification sent.</description>
- </element>
- </enum>
-
- <enum name="SystemContext">
- <description>Enumeration that describes possible contexts an app's HMI might be in.</description>
- <description>Communicated to whichever app is in HMI FULL, except Alert.</description>
- <element name="MAIN" internal_name="SYSCTXT_MAIN">
- <description>The app's persistent display (whether media/non-media/navigation) is fully visible onscreen.</description>
- </element>
- <element name="VRSESSION" internal_name="SYSCTXT_VRSESSION">
- <description>The system is currently in a VR session (with whatever dedicated VR screen being overlaid onscreen).</description>
- </element>
- <element name="MENU" internal_name="SYSCTXT_MENU">
- <description>The system is currently displaying a system or in-App menu onscreen.</description>
- </element>
- <element name="HMI_OBSCURED" internal_name="SYSCTXT_HMI_OBSCURED">
- <description>The app's display HMI is currently being obscured by either a system or other app's overlay.</description>
- </element>
- <element name="ALERT" internal_name="SYSCTXT_ALERT">
- <description>Broadcast only to whichever app has an alert currently being displayed.</description>
- </element>
- </enum>
-
- <enum name="SoftButtonType">
- <description>Contains information about the SoftButton capabilities.</description>
- <element name="TEXT" internal_name="SBT_TEXT"/>
- <element name="IMAGE" internal_name="SBT_IMAGE"/>
- <element name="BOTH" internal_name="SBT_BOTH"/>
- </enum>
-
- <enum name="AppInterfaceUnregisteredReason">
- <description>Error code, which comes from sync side.</description>
- <element name="USER_EXIT" />
- <element name="IGNITION_OFF" />
- <element name="BLUETOOTH_OFF" />
- <element name="USB_DISCONNECTED" />
- <element name="REQUEST_WHILE_IN_NONE_HMI_LEVEL" />
- <element name="TOO_MANY_REQUESTS" />
- <element name="DRIVER_DISTRACTION_VIOLATION" />
- <element name="LANGUAGE_CHANGE" />
- <element name="MASTER_RESET" />
- <element name="FACTORY_DEFAULTS" />
- <element name="APP_UNAUTHORIZED" />
- </enum>
-
- <enum name="TriggerSource">
- <description>Indicates the source from where the command was triggered.</description>
- <element name="MENU" internal_name="TS_MENU" />
- <element name="VR" internal_name="TS_VR" />
- </enum>
-
- <enum name="HmiZoneCapabilities">
- <description>Contains information about the HMI zone capabilities.</description>
- <description>For future use.</description>
- <element name="FRONT" />
- <element name="BACK" />
- </enum>
-
- <enum name="SpeechCapabilities">
- <description>Contains information about the TTS capabilities.</description>
- <element name="TEXT" internal_name="SC_TEXT"/>
- <element name="SAPI_PHONEMES" />
- <element name="LHPLUS_PHONEMES" />
- <element name="PRE_RECORDED" />
- <element name="SILENCE" />
- </enum>
-
- <enum name="VrCapabilities">
- <description>Contains information about the VR capabilities.</description>
- <element name="TEXT" internal_name="VR_TEXT"/>
- </enum>
-
- <enum name="SamplingRate">
- <description>Describes different sampling options for PerformAudioPassThru.</description>
- <element name="8KHZ" internal_name="SamplingRate_8KHZ"/>
- <element name="16KHZ" internal_name="SamplingRate_16KHZ"/>
- <element name="22KHZ" internal_name="SamplingRate_22KHZ"/>
- <element name="44KHZ" internal_name="SamplingRate_44KHZ"/>
- </enum>
-
- <enum name="AudioCaptureQuality">
- <description>Describes different quality options for PerformAudioPassThru.</description>
- <element name="8_BIT" internal_name="AudioCaptureQuality_8_BIT"/>
- <element name="16_BIT" internal_name="AudioCaptureQuality_16_BIT"/>
- </enum>
-
- <enum name="AudioType">
- <description>Describes different audio type options for PerformAudioPassThru.</description>
- <element name="PCM" />
-<!-- TODO: remove?
- <element name="MP3" />
- <element name="WAV" />
--->
- </enum>
-
- <enum name="VehicleDataType">
- <description>Defines the data types that can be published and subscribed to.</description>
- <element name="VEHICLEDATA_GPS">
- <description>Notifies GPSData</description>
- <description>may be subscribed</description>
- </element>
- <element name="VEHICLEDATA_SPEED" />
- <element name="VEHICLEDATA_FUELLEVEL" />
- <element name="VEHICLEDATA_FUELECONOMY" />
- <element name="VEHICLEDATA_ENGINERPM" />
- <element name="VEHICLEDATA_BATTVOLTS" />
- <element name="VEHICLEDATA_RAINSENSOR">
- <issue creator="rs">Cansignals not identified yet</issue>
- </element>
- <element name="VEHICLEDATA_ODOMETER" />
- <element name="VEHICLEDATA_VIN" />
- <element name="VEHICLEDATA_EXTERNTEMP" />
- <element name="VEHICLEDATA_PRNDLSTATUS" />
- <element name="VEHICLEDATA_TIREPRESSURE" />
- <element name="VEHICLEDATA_BATTERYPACKVOLTAGE">
- <description>Battery pack voltage of hybrid and electrical vehicles</description>
- </element>
- <element name="VEHICLEDATA_BATTERYCURRENT">
- <description>Battery current of hybrid and electrical vehicles</description>
- </element>
- <element name="VEHICLEDATA_BATTERYTEMPERATURE">
- <description>Battery temperature of hybrid and electrical vehicles</description>
- </element>
- <element name="VEHICLEDATA_SATESN">
- <description>Satellite radio serial number (ESN)</description>
- </element>
-
- </enum>
-
- <enum name="ButtonName">
- <description>Defines the hard (physical) and soft (touchscreen) buttons available from SYNC</description>
- <element name="OK" />
- <element name="SEEKLEFT" />
- <element name="SEEKRIGHT" />
- <element name="TUNEUP" />
- <element name="TUNEDOWN" />
- <element name="PRESET_0" />
- <element name="PRESET_1" />
- <element name="PRESET_2" />
- <element name="PRESET_3" />
- <element name="PRESET_4" />
- <element name="PRESET_5" />
- <element name="PRESET_6" />
- <element name="PRESET_7" />
- <element name="PRESET_8" />
- <element name="PRESET_9" />
- <element name="CUSTOM_BUTTON" />
- </enum>
-
- <enum name="MediaClockFormat">
- <element name="CLOCK1">
- <description>minutesFieldWidth = 2;minutesFieldMax = 19;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 19;maxMinutes = 59;maxSeconds = 59;</description>
- <description>used for Type II and CID headunits</description>
- </element>
- <element name="CLOCK2">
- <description>minutesFieldWidth = 3;minutesFieldMax = 199;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 59;maxMinutes = 59;maxSeconds = 59;</description>
- <description>used for Type V headunit</description>
- </element>
- <element name="CLOCKTEXT1">
- <description>5 characters possible</description>
- <description>Format: 1|sp c :|sp c c</description>
- <description>1|sp : digit "1" or space</description>
- <description>c : character out of following character set: sp|0-9|[letters, see TypeII column in XLS. See [@TODO: create file ref]]</description>
- <description>:|sp : colon or space</description>
- <description>used for Type II headunit</description>
- </element>
- <element name="CLOCKTEXT2">
- <description>5 chars possible</description>
- <description>Format: 1|sp c :|sp c c</description>
- <description>1|sp : digit "1" or space</description>
- <description>c : character out of following character set: sp|0-9|[letters, see CID column in XLS. See [@TODO: create file ref]]</description>
- <description>:|sp : colon or space</description>
- <description>used for CID headunit</description>
- <description>NOTE: difference between CLOCKTEXT1 and CLOCKTEXT2 is the supported character set</description>
- </element>
- <element name="CLOCKTEXT3">
- <description>6 chars possible</description>
- <description>Format: 1|sp c c :|sp c c</description>
- <description>1|sp : digit "1" or space</description>
- <description>c : character out of following character set: sp|0-9|[letters, see Type 5 column in XLS]. See [@TODO: create file ref]</description>
- <description>:|sp : colon or space</description>
- <description>used for Type V headunit</description>
- </element>
- <issue creator="mf">First complete values draft. Review needed.</issue>
- </enum>
-
- <enum name="DisplayType">
- <description>See DAES for further infos regarding the displays</description>
- <element name="CID"/>
- <element name="TYPE2" />
- <element name="TYPE5" />
- <element name="NGN" />
- <element name="GEN2_8_DMA" />
- <element name="GEN2_6_DMA" />
- <element name="MFD3" />
- <element name="MFD4" />
- <element name="MFD5" />
- </enum>
-
- <enum name="TextFieldName">
- <element name="mainField1">
- <description>The first line of first set of main fields of the persistent display</description>
- <description>Applies to "Show"</description>
- </element>
-
- <element name="mainField2">
- <description>The second line of first set of main fields of the persistent display</description>
- <description>Applies to "Show"</description>
- </element>
-
- <element name="mainField3">
- <description>The first line of second set of main fields of persistent display</description>
- <description>Applies to "Show"</description>
- </element>
-
- <element name="mainField4">
- <description>The second line of second set of main fields of the persistent display</description>
- <description>Applies to "Show"</description>
- </element>
-
- <element name="statusBar">
- <description>The status bar on Nav</description>
- <description>Applies to "Show"</description>
- </element>
-
- <element name="mediaClock">
- <description>Text value for MediaClock field.</description>
- <description>Applies to "Show"</description>
- </element>
-
- <element name="mediaTrack">
- <description>The track field of NGN type ACMs.</description>
- <description>This field is only available for media applications.</description>
- <description>Applies to "Show"</description>
- </element>
-
- <element name="alertText1">
- <description>The first line of the alert text field</description>
- <description>Applies to "Alert"</description>
- </element>
-
- <element name="alertText2">
- <description>The second line of the alert text field</description>
- <description>Applies to "Alert"</description>
- </element>
-
- <element name="alertText3">
- <description>The third line of the alert text field</description>
- <description>Applies to "Alert"</description>
- </element>
-
- <element name="scrollableMessageBody">
- <description> Long form body of text that can include newlines and tabs.</description>
- <description>Applies to "ScrollableMessage"</description>
- </element>
-
- <element name="initialInteractionText">
- <description> First line suggestion for a user response (in the case of VR enabled interaction</description>
- </element>
-
- <element name="navigationText1">
- <description> First line of navigation text</description>
- </element>
-
- <element name="navigationText2">
- <description> Second line of navigation text</description>
- </element>
-
- <element name="ETA">
- <description> Estimated Time of Arrival time for navigation</description>
- </element>
-
- <element name="totalDistance">
- <description> Total distance to destination for navigation</description>
- </element>
-
- <element name="audioPassThruDisplayText1">
- <description> First line of text for audio pass thru</description>
- </element>
-
- <element name="audioPassThruDisplayText2">
- <description> Second line of text for audio pass thru</description>
- </element>
-
- <element name="sliderHeader">
- <description> Header text for slider</description>
- </element>
-
- <element name="sliderFooter">
- <description> Footer text for slider</description>
- </element>
-
- </enum>
-
- <enum name="CharacterSet">
- <description>The list of potential character sets</description>
- <element name="TYPE2SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <element name="TYPE5SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <element name="CID1SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <element name="CID2SET">
- <description>See [@TODO: create file ref]</description>
- </element>
- <issue creator="rs">Real sets have not been defined yet?</issue>
- </enum>
-
- <enum name="TextAlignment">
- <description>The list of possible alignments, left, right, or centered</description>
- <element name="LEFT_ALIGNED" />
- <element name="RIGHT_ALIGNED" />
- <element name="CENTERED" />
- </enum>
-
- <enum name="TBTState">
- <description>Enumeration that describes possible states of turn-by-turn client or AppLink app.</description>
- <element name="ROUTE_UPDATE_REQUEST" />
- <element name="ROUTE_ACCEPTED" />
- <element name="ROUTE_REFUSED" />
- <element name="ROUTE_CANCELLED" />
- <element name="ETA_REQUEST" />
- <element name="NEXT_TURN_REQUEST" />
- <element name="ROUTE_STATUS_REQUEST" />
- <element name="ROUTE_SUMMARY_REQUEST" />
- <element name="TRIP_STATUS_REQUEST" />
- <element name="ROUTE_UPDATE_REQUEST_TIMEOUT" />
- </enum>
-
- <enum name="DriverDistractionState">
- <description>Enumeration that describes possible states of driver distraction.</description>
- <element name="DD_ON" />
- <element name="DD_OFF" />
- </enum>
-
-<!-- TODO: REMOVE
- <enum name="DataType">
- <description>Contains information about the type of data.</description>
- <element name="HEX" />
- <element name="BINARY" />
- </enum>
--->
-
- <enum name="ImageType">
- <description>Contains information about the type of image.</description>
- <element name="STATIC" />
- <element name="DYNAMIC" />
- </enum>
-
- <struct name="Image">
- <param name="value" maxlength="65535" type="String">
- <description>Either the static hex icon value or the binary image file name identifier (sent by PutFile).</description>
- </param>
- <param name="imageType" type="ImageType">
- <description>Describes, whether it is a static or dynamic image.</description>
- </param>
- </struct>
-
- <struct name="SoftButton">
- <param name="type" type="SoftButtonType">
- <description>Describes, whether it is text, highlighted text, icon, or dynamic image. See softButtonType</description>
- </param>
- <param name="text" maxlength="500" type="String" mandatory="false">
- <description>Optional text to display (if defined as TEXT or BOTH)</description>
- </param>
- <param name="image" type="Image" mandatory="false">
- <description>Optional image struct for SoftButton (if defined as IMAGE or BOTH)</description>
- </param>
- <param name="isHighlighted" type="Boolean">
- <description>True, if highlighted</description>
- <description>False, if not highlighted</description>
- </param>
- <param name="softButtonID" type="Integer" minvalue="0" maxvalue="65536">
- <description>Value which is returned via OnButtonPress / OnButtonEvent</description>
- </param>
- <param name="systemAction" type="SystemAction">
- <description>Parameter indicating whether selecting a SoftButton shall call a specific system action. This is intended to allow Notifications to bring the callee into full / focus; or in the case of persistent overlays, the overlay can persist when a SoftButton is pressed.</description>
- </param>
- </struct>
-
- <struct name="Choice">
- <description>A choice is an option given to the user, which can be selected either by menu, or through voice recognition system.</description>
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535" />
- <param name="menuName" type="String" maxlength="500" />
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" />
- <param name="image" type="Image"/>
- </struct>
-
- <struct name="VrHelpItem">
- <param name="text" maxlength="500" type="String">
- <description>Text to display for VR Help item</description>
- </param>
- <param name="image" type="Image">
- <description>Image struct for VR Help item</description>
- </param>
- <param name="position" type="Integer" minvalue="1" maxvalue="8">
- <description>Position to display item in VR Help list</description>
-
- </param>
- </struct>
-
- <struct name="SyncMsgVersion">
- <description>Specifies the version number of the SYNC V4 protocol, that is supported by the mobile application</description>
-
- <param name="majorVersion" type="Integer" minvalue="1" maxvalue="10">
- <description>The major version indicates versions that is not-compatible to previous versions.</description>
- </param>
- <param name="minorVersion" type="Integer" minvalue="0" maxvalue="1000">
- <description>The minor version indicates a change to a previous version that should still allow to be run on an older version (with limited functionality)</description>
- </param>
- </struct>
-
- <enum name="GlobalProperty">
- <description>The different global properties.</description>
- <element name="HELPPROMPT">
- <description>The property helpPrompt of setGlobalProperties</description>
- </element>
- <element name="TIMEOUTPROMPT">
- <description>The property timeoutPrompt of setGlobalProperties</description>
- </element>
- <element name="VRHELPTITLE">
- <description>The property vrHelpTitle of setGlobalProperties</description>
- </element>
- <element name="VRHELPITEMS">
- <description>The property array of vrHelp of setGlobalProperties</description>
- </element>
- </enum>
-
- <enum name="CompassDirection">
- <description>The list of potential compass directions</description>
- <element name="NORTH">
- </element>
- <element name="NORTHWEST">
- </element>
- <element name="WEST">
- </element>
- <element name="SOUTHWEST">
- </element>
- <element name="SOUTH">
- </element>
- <element name="SOUTHEAST">
- </element>
- <element name="EAST">
- </element>
- <element name="NORTHEAST">
- </element>
- </enum>
-
- <enum name="Dimension">
- <description>The supported dimensions of the GPS</description>
- <element name="NO_FIX">
- <description>No GPS at all</description>
- </element>
- <element name="2D" internal_name="Dimension_2D">
- <description>Longitude and lattitude</description>
- </element>
- <element name="3D" internal_name="Dimension_3D">
- <description>Longitude and lattitude and altitude</description>
- </element>
- </enum>
-
- <enum name="PRNDL">
- <description>The selected gear.</description>
- <element name="PARK">
- <description>Parking</description>
- </element>
- <element name="REVERSE">
- <description>Reverse gear</description>
- </element>
- <element name="NEUTRAL">
- <description>No gear</description>
- </element>
- <element name="LOWGEAR">
- <description>1st gear hold</description>
- </element>
- <element name="FORWARD_DRIVE_2">
- </element>
- <element name="FORWARD_DRIVE_3">
- </element>
- <element name="FORWARD_DRIVE_4">
- <description>Or Overdrive</description>
- </element>
- <element name="FORWARD_DRIVE_5">
- <description>Or Overdrive</description>
- </element>
- <element name="FORWARD_DRIVE_6">
- <description>Or Overdrive</description>
- </element>
- <element name="SECOND_GEAR_HOLD">
- </element>
- <element name="THIRD_GEAR_HOLD">
- </element>
- <element name="FOURTH_GEAR_HOLD">
- </element>
- <element name="FIFTH_GEAR_HOLD">
- </element>
- <element name="SIXTH_GEAR_HOLD">
- </element>
- </enum>
-
- <enum name="SingleTirePressureStatus">
- <description>The pressure status of a tire.</description>
- <element name="UNKNOWN">
- </element>
- <element name="NORMAL">
- </element>
- <element name="LOW">
- </element>
- <element name="FAULT">
- </element>
- <element name="NOT_SUPPORTED">
- </element>
- </enum>
-
- <struct name="SingleTireStatus">
- <param name="status" type="SingleTirePressureStatus">
- <description>See SingleTirePressureStatus.</description>
- </param>
- <param name="pressure" type="Integer" minvalue="0" maxvalue="255">
- <description>The tire pressure in PSI.</description>
- </param>
- </struct>
-
- <enum name="TirePressureTellTale">
- <description>Reflects the status of the cluster instrument warning light.</description>
- <element name="OFF">
- </element>
- <element name="ON">
- </element>
- <element name="FLASH">
- </element>
- </enum>
-
- <enum name="VehicleDataResultCode">
- <description>Enumeration that describes possible result codes of a vehicle data entry request.</description>
- <element name="SUCCESS" internal_name="VDRC_SUCCESS"/>
- <element name="DISALLOWED" internal_name="VDRC_DISALLOWED"/>
- <element name="USER_DISALLOWED" internal_name="VDRC_USER_DISALLOWED"/>
- <element name="INVALID_ID" internal_name="VDRC_INVALID_ID"/>
- <element name="VEHICLE_DATA_NOT_AVAILABLE" internal_name="VDRC_DATA_NOT_AVAILABLE"/>
- <element name="DATA_ALREADY_SUBSCRIBED" internal_name="VDRC_DATA_ALREADY_SUBSCRIBED"/>
- <element name="DATA_NOT_SUBSCRIBED" internal_name="VDRC_DATA_NOT_SUBSCRIBED"/>
- <element name="IGNORED" internal_name="VDRC_IGNORED"/>
- </enum>
-
- <struct name="TireStatus">
- <description>The status and pressure of the tires.</description>
-
- <param name="pressureTellTale" type="TirePressureTellTale">
- <description>See TirePressureTellTale.</description>
- </param>
- <param name="leftFront" type="SingleTireStatus">
- <description>The status of the left front tire.</description>
- </param>
- <param name="rightFront" type="SingleTireStatus">
- <description>The status of the right front tire.</description>
- </param>
- <param name="leftRear" type="SingleTireStatus">
- <description>The status of the left rear tire.</description>
- </param>
- <param name="rightRear" type="SingleTireStatus">
- <description>The status of the right rear tire.</description>
- </param>
- <param name="innerLeftRear" type="SingleTireStatus">
- <description>The status of the inner left rear.</description>
- </param>
- <param name="innerRightRear" type="SingleTireStatus">
- <description>The status of the inner right rear.</description>
- </param>
- </struct>
-
- <struct name="GPSData">
- <description>Struct with the GPS data.</description>
- <issue creator="rs">Ford to define, which values are really needed. For efficiency it might make sense to support a basic and extended data type</issue>
- <param name="longitudeDegrees" type="Integer" minvalue="-1000000000" maxvalue="1000000000">
- <issue creator="rs">Format needs to be defined explicitely.</issue>
- </param>
- <param name="latitudeDegrees" type="Integer" minvalue="-1000000000" maxvalue="1000000000">
- <issue creator="rs">Format needs to be defined explicitely.</issue>
- </param>
- <param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100">
- <description>The current UTC year.</description>
- </param>
- <param name="utcMonth" type="Integer" minvalue="1" maxvalue="12">
- <description>The current UTC month.</description>
- </param>
- <param name="utcDay" type="Integer" minvalue="1" maxvalue="31">
- <description>The current UTC day.</description>
- </param>
- <param name="utcHours" type="Integer" minvalue="0" maxvalue="23">
- <description>The current UTC hour.</description>
- </param>
- <param name="utcMinutes" type="Integer" minvalue="0" maxvalue="59">
- <description>The current UTC minute.</description>
- </param>
- <param name="utcSeconds" type="Integer" minvalue="0" maxvalue="59">
- <description>The current UTC second.</description>
- </param>
- <param name="compassDirection" type="CompassDirection">
- <description>See CompassDirection.</description>
- </param>
- <param name="pdop" type="Integer" minvalue="0" maxvalue="31">
- <description>PDOP.</description>
- </param>
- <param name="hdop" type="Integer" minvalue="0" maxvalue="31">
- <description>HDOP.</description>
- </param>
- <param name="vdop" type="Integer" minvalue="0" maxvalue="31">
- <description>VDOP.</description>
- </param>
- <param name="actual" type="Boolean">
- <description>True, if actual.</description>
- <description>False, if infered.</description>
- </param>
- <param name="satellites" type="Integer" minvalue="0" maxvalue="31">
- <description>Number of satellites in view</description>
- </param>
- <param name="dimension" type="Dimension">
- <description>See Dimension</description>
- </param>
- <param name="altitude" type="Integer" minvalue="-10000" maxvalue="10000">
- <description>Altitude in meters</description>
- </param>
- <param name="heading" type="Integer" minvalue="0" maxvalue="360">
- <description>The heading. North is 0</description>
- </param>
- <param name="speed" type="Integer" minvalue="0" maxvalue="400">
- <description>The speed in KPH</description>
- </param>
- </struct>
-
- <struct name="VehicleDataResult">
- <description>Individual published data request result</description>
- <param name="dataType" type="VehicleDataType">
- <description>Defined published data element type.</description>
- </param>
- <param name="resultCode" type="VehicleDataResultCode">
- <description>Published data result code.</description>
- </param>
- </struct>
-
- <struct name="StartTime">
- <param name="hours" type="Integer" minvalue="0" maxvalue="59">
- <description>The hour of the media clock.</description>
- <description>Some radios only support a max of 19 hours. If out of range, it will be rejected.</description>
- </param>
- <param name="minutes" type="Integer" minvalue="0" maxvalue="59" />
- <param name="seconds" type="Integer" minvalue="0" maxvalue="59" />
- </struct>
-
- <struct name="TextField">
- <param name="name" type="TextFieldName">
- <description>The name that identifies the field. See TextFieldName.</description>
- </param>
- <param name="characterSet" type="CharacterSet">
- <description>The character set that is supported in this field. See CharacterSet.</description>
- </param>
- <param name="width" type="Integer" minvalue="1" maxvalue="500">
- <description>The number of characters in one row of this field.</description>
- </param>
- <param name="rows" type="Integer" minvalue="1" maxvalue="3">
- <description>The number of rows of this field.</description>
- </param>
- </struct>
-
- <enum name="PermissionStatus">
- <description>Enumeration that describes possible permission states of a policy table entry.</description>
- <element name="ALLOWED" internal_name="PS_ALLOWED"/>
- <element name="DISALLOWED" internal_name="PS_DISALLOWED"/>
- <element name="USER_DISALLOWED" internal_name="PS_USER_DISALLOWED"/>
- <element name="USER_CONSENT_PENDING" internal_name="PS_USER_CONSENT_PENDING"/>
- </enum>
-
- <struct name="HMIPermissions">
- <param name="allowed" type="HMILevel" minsize="0" maxsize="100" array="true">
- <description>A set of all HMI levels that are permitted for this given RPC.</description>
- </param>
- <param name="userDisallowed" type="HMILevel" minsize="0" maxsize="100" array="true">
- <description>A set of all HMI levels that are prohibited for this given RPC.</description>
- </param>
- </struct>
-
- <struct name="ParameterPermissions">
- <param name="allowed" type="String" minsize="0" maxsize="100" maxlength = "100" array="true">
- <description>A set of all parameters that are permitted for this given RPC.</description>
- </param>
- <param name="userDisallowed" type="String" minsize="0" maxsize="100" array="true">
- <description>A set of all parameters that are prohibited for this given RPC.</description>
- </param>
- </struct>
-
- <struct name="PermissionItem">
- <param name="rpcName" type="String" maxlength="100">
- <description>Name of the individual RPC in the policy table.</description>
- </param>
- <param name="hmiPermissions" type="HMIPermissions" />
- <param name="parameterPermissions" type="ParameterPermissions" />
- </struct>
-
- <struct name="DisplayCapabilities">
- <description>Contains information about the display capabilities.</description>
- <param name="displayType" type="DisplayType">
- <description>The type of the display. See DisplayType</description>
- </param>
- <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true">
- <description>A set of all fields that support text data. See TextField</description>
- </param>
- <param name="mediaClockFormats" type="MediaClockFormat" minsize="1" maxsize="100" array="true">
- <description>A set of all supported formats of the media clock. See MediaClockFormat</description>
- </param>
- </struct>
-
- <struct name="ButtonCapabilities">
- <description>Contains information about a button's capabilities.</description>
- <param name="name" type="ButtonName">
- <description>The name of the button. See ButtonName.</description>
- </param>
- <param name="shortPressAvailable" type="Boolean">
- <description>The button supports a short press.</description>
- <description>Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked.</description>
- </param>
- <param name="longPressAvailable" type="Boolean">
- <description>The button supports a LONG press.</description>
- <description>Whenever the button is pressed long, onButtonPressed( LONG) will be invoked.</description>
- </param>
- <param name="upDownAvailable" type="Boolean">
- <description>The button supports "button down" and "button up".</description>
- <description>Whenever the button is pressed, onButtonEvent( DOWN) will be invoked.</description>
- <description>Whenever the button is released, onButtonEvent( UP) will be invoked.</description>
- </param>
- </struct>
-
- <struct name="SoftButtonCapabilities">
- <description>Contains information about a SoftButton's capabilities.</description>
- <param name="shortPressAvailable" type="Boolean">
- <description>The button supports a short press.</description>
- <description>Whenever the button is pressed short, onButtonPressed( SHORT) will be invoked.</description>
- </param>
- <param name="longPressAvailable" type="Boolean">
- <description>The button supports a LONG press.</description>
- <description>Whenever the button is pressed long, onButtonPressed( LONG) will be invoked.</description>
- </param>
- <param name="upDownAvailable" type="Boolean">
- <description>The button supports "button down" and "button up".</description>
- <description>Whenever the button is pressed, onButtonEvent( DOWN) will be invoked.</description>
- <description>Whenever the button is released, onButtonEvent( UP) will be invoked.</description>
- </param>
- <param name="imageSupported" type="Boolean">
- <description>The button supports referencing a static or dynamic image.</description>
- </param>
- </struct>
-
- <struct name="PresetBankCapabilities">
- <description>Contains information about on-screen preset capabilities.</description>
- <param name="onScreenPresetsAvailable" type="Boolean">
- <description>Onscreen custom presets are available.</description>
- </param>
- </struct>
-
-<!-- TODO: REMOVE
- <enum name="DisplayLayout">
- <description>Dynamic enumeration that contains predefined alternate screen layouts as well as app-defined layouts.</description>
- <issue creator="sb">Can an enumeration be dynamically changed (custom elements added by an app at runtime?)</issue>
- <element name="ONSCREEN_PRESETS">
- <description>Custom screen containing app-defined onscreen presets. Currently defined for GEN2.</description>
- </element>
- </enum>
--->
-
- <struct name="MenuParams">
- <param name="parentID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
- <description>unique ID of the sub menu, the command will be added to.</description>
- <description>If not provided, it will be provided to the top level of the in application menu.</description>
- </param>
-
- <param name="position" type="Integer" minvalue="0" maxvalue="1000" mandatory="false">
- <description>Position within the items that are are at top level of the in application menu.</description>
- <description>0 will insert at the front.</description>
- <description>1 will insert at the second position.</description>
- <description>if position is greater or equal than the number of items on top level, the sub menu will be appended to the end.</description>
- <description>If this param was omitted the entry will be added at the end.</description>
- </param>
-
- <param name="menuName" type="String" maxlength="500">
- <description>Text to show in the menu for this sub menu.</description>
- </param>
- </struct>
-
- <struct name="TTSChunk">
- <description>A TTS chunk, that consists of the text/phonemes to speak and the type (like text or SAPI)</description>
- <param name="text" maxlength="500" type="String">
- <description>The text or phonemes to speak.</description>
- <description>May not be empty.</description>
- </param>
- <param name="type" type="SpeechCapabilities">
- <description>Describes, whether it is text or a specific phoneme set. See SpeechCapabilities</description>
- </param>
- </struct>
-
- <struct name="DTC">
- <param name="identifier" type="String" maxlength="500">
- <description>String containing hexadecimal identifier as well as other common names.</description>
- </param>
- <param name="statusByte" type="String" maxlength="500">
- <description>Hexadecimal byte string.</description>
- </param>
- </struct>
-
- <struct name="Turn">
- <param name="navigationText" type="String" maxlength="500" mandatory="false">
- </param>
- <param name="turnIcon" type="Image">
- </param>
- </struct>
-
- <struct name="VehicleType">
- <param name="make" type="String" maxlength="500" mandatory="false">
- <description>Make of the vehicle</description>
- <description>e.g. Ford</description>
- </param>
- <param name="model" type="String" maxlength="500" mandatory="false">
- <description>Model of the vehicle</description>
- <description>e.g. Fiesta</description>
- </param>
- <param name="modelYear" type="String" maxlength="500" mandatory="false">
- <description>Model Year of the vehicle</description>
- <description>e.g. 2013</description>
- </param>
- <param name="trim" type="String" maxlength="500" mandatory="false">
- <description>Trim of the vehicle</description>
- <description>e.g. SE</description>
- </param>
-
- </struct>
-
- <enum name="FileType">
- <description>Enumeration listing possible file types.</description>
- <element name="GRAPHIC_BMP" />
- <element name="GRAPHIC_JPEG" />
- <element name="GRAPHIC_PNG" />
- <element name="AUDIO_WAVE" />
- <element name="AUDIO_MP3" />
- </enum>
-
- <enum name="AppType">
- <description>Enumeration listing possible app types.</description>
- <element name="DEFAULT" />
- <element name="COMMUNICATION" />
- <element name="MEDIA" />
- <element name="MESSAGING" />
- <element name="NAVIGATION" />
- <element name="INFORMATION" />
- <element name="SOCIAL" />
- <element name="BACKGROUND_PROCESS" />
- <element name="TESTING" />
- <element name="SYSTEM" />
- </enum>
-
- <enum name="FunctionID">
- <description>Enumeration linking function names with function IDs in WiPro protocol.</description>
- <description>Assumes enumeration starts at value 0.</description>
- <element name="RESERVED" value="0" />
- <element name="RegisterAppInterfaceID" value="1" />
- <element name="UnregisterAppInterfaceID" value="2" />
- <element name="SetGlobalPropertiesID" value="3" />
- <element name="ResetGlobalPropertiesID" value="4" />
- <element name="AddCommandID" value="5" />
- <element name="DeleteCommandID" value="6" />
- <element name="AddSubMenuID" value="7" />
- <element name="DeleteSubMenuID" value="8" />
- <element name="CreateInteractionChoiceSetID" value="9" />
- <element name="PerformInteractionID" value="10" />
- <element name="DeleteInteractionChoiceSetID" value="11" />
- <element name="AlertID" value="12" />
- <element name="ShowID" value="13" />
- <element name="SpeakID" value="14" />
- <element name="SetMediaClockTimerID" value="15" />
- <element name="EncodedSyncPDataID" value="16" />
- <element name="DialNumberID" value="17" />
- <element name="PerformAudioPassThruID" value="18" />
- <element name="EndAudioPassThruID" value="19" />
- <element name="SubscribeButtonID" value="20" />
- <element name="UnsubscribeButtonID" value="21" />
- <element name="SubscribeVehicleDataID" value="22" />
- <element name="UnsubscribeVehicleDataID" value="23" />
- <element name="GetVehicleDataID" value="24" />
- <element name="ReadDIDID" value="25" />
- <element name="GetDTCsID" value="26" />
- <element name="ScrollableMessageID" value="27" />
- <element name="SliderID" value="28" />
- <element name="ShowConstantTBTID" value="29" />
- <element name="AlertManeuverID" value="30" />
- <element name="UpdateTurnListID" value="31" />
- <element name="ChangeRegistrationID" value="32" />
- <element name="GenericResponseID" value="33" />
- <element name="PutFileID" value="34" />
- <element name="DeleteFileID" value="35" />
- <element name="ListFilesID" value="36" />
- <element name="SetAppIconID" value="37" />
- <element name="SetDisplayLayoutID" value="38" />
- <element name="OnHMIStatusID" value="39" />
- <element name="OnAppInterfaceUnregisteredID" value="40" />
- <element name="OnButtonEventID" value="41" />
- <element name="OnButtonPressID" value="42" />
- <element name="OnVehicleDataID" value="43" />
- <element name="OnCommandID" value="44" />
- <element name="OnEncodedSyncPDataID" value="45" />
- <element name="OnTBTClientStateID" value="46" />
- <element name="OnDriverDistractionID" value="47" />
- <element name="OnPermissionsChangeID" value="48" />
- <element name="OnAudioPassThruID" value="49" />
- <element name="OnLanguageChangeID" value="50" />
- </enum>
-
- <enum name="messageType">
- <description>Enumeration linking message types with function types in WiPro protocol.</description>
- <description>Assumes enumeration starts at value 0.</description>
- <element name="request" value="0" />
- <element name="response" value="1" />
- <element name="notification" value="2" />
- </enum>
-
- <!-- Requests/Responses -->
-
- <function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="request">
- <description>Establishes an interface with a mobile application.</description>
- <description>Before registerAppInterface no other commands will be accepted/executed.</description>
- <param name="syncMsgVersion" type="SyncMsgVersion">
- <description>See SyncMsgVersion</description>
- </param>
- <param name="appName" type="String" maxlength="100">
- <description>The mobile application name, e.g. "Ford Drive Green".</description>
- <description>Needs to be unique over all applications.</description>
- <description>May not be empty.</description>
- <description>May not start with a new line character.</description>
- <description>May not interfere with any name or synonym of previously registered applications and the following list of words @TODO: Create list(global commands)</description>
- <description>Needs to be unique over all applications. Applications with the same name will be rejected.</description>
- <description>Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported.</description>
- </param>
-
- <param name="ttsName" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false" >
- <description>TTS string for VR recognition of the mobile application name, e.g. "Ford Drive Green".</description>
- <description>Meant to overcome any failing on speech engine in properly pronouncing / understanding app name.</description>
- <description>Needs to be unique over all applications.</description>
- <description>May not be empty.</description>
- <description>May not start with a new line character.</description>
- <description>May not interfere with any name or synonym of previously registered applications and the following list of words @TODO: Create list(global commands)</description>
- <description>Needs to be unique over all applications. Applications with the same name will be rejected.</description>
- <description>Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported.</description>
- </param>
-
- <param name="ngnMediaScreenAppName" type="String" maxlength="100" mandatory="false">
- <description>Provides an abbreviated version of the app name (if needed), that will be displayed on the NGN media screen.</description>
- <description>If not provided, the appName is used instead (and will be truncated if too long)</description>
- <description>Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported.</description>
- </param>
-
- <param name="vrSynonyms" type="String" maxlength="40" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Defines an additional voice recognition command.</description>
- <description>May not interfere with any name or synonym of previously registered applications and the following list of words @TODO: Create list(global commands)</description>
- <description>Only characters from char set [@TODO: Create char set (character/hex value) for each ACM and refer to] are supported.</description>
- </param>
-<!-- deprecating
- <param name="usesVehicleData" type="Boolean" defvalue="false" mandatory="false">
- <description>If not provided, the default is equal to False"</description>
- <description>Indicates if the mobile application wants to use vehicle data like GPS or speed.</description>
- </param>
--->
- <param name="isMediaApplication" type="Boolean">
- <description>Indicates if the application is a media or a non-media application.</description>
- <description>Only media applications will be able to stream audio to Sync that is audible outside of the BT media source.</description>
- </param>
- <param name="languageDesired" type="Language" mandatory="true">
- <description>See Language</description>
- <description>Current app’s expected VR+TTS language</description>
- <description>If there is a mismatch with SYNC, the app will be able to change this registration with changeRegistration prior to app being brought into focus.</description>
- </param>
- <param name="hmiDisplayLanguageDesired" type="Language" mandatory="true">
- <description>See Language</description>
- <description>Current app’s expected display language</description>
- <description>If there is a mismatch with SYNC, the app will be able to change this registration with changeRegistration prior to app being brought into focus.</description>
- </param>
-<!-- deprecating
- <param name="autoActivateID" type="String" maxlength="16" mandatory="false">
- <description>Used to support auto activation after an initial successful registerAppInterface (for example after an ignition cycle).</description>
- <description>The app should always provide the id that was provided by the most recent registerAppInterface response.</description>
- <description>If this is the first call to registerAppInterface, then do not provide this parameter at all.</description>
- <description>If not provided or not matching with the id of the last registerAppInterface response, the app will not be automatically put into foreground on startup.</description>
- </param>
--->
- <param name="appType" type="AppType" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>See AppType</description>
- <description>List of all applicable app types stating which classifications to be given to the app.</description>
- <description>e.g. for platforms like GEN2, this will determine which "corner(s)" the app can populate.</description>
- </param>
- <param name="appID" type="String" maxlength="100" mandatory="true">
- <description>ID used to validate app with policy table entries</description>
- </param>
- </function>
-
- <function name="RegisterAppInterface" functionID="RegisterAppInterfaceID" messagetype="response">
- <description>The response to registerAppInterface</description>
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="GENERIC_ERROR"/>
- <element name="DUPLICATE_NAME"/>
- <element name="TOO_MANY_APPLICATIONS"/>
- <element name="APPLICATION_REGISTERED_ALREADY"/>
- <element name="UNSUPPORTED_VERSION"/>
- <element name="WRONG_LANGUAGE"/>
- <element name="DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="syncMsgVersion" type="SyncMsgVersion" mandatory="false">
- <description>See SyncMsgVersion</description>
- </param>
-
-<!-- deprecating
- <param name="autoActivateID" type="String" maxlength="16" mandatory="false">
- <description>Provides an id that the app may use on a subsequent registerAppInterface to allow for auto activation (for example after an ignition cycle).</description>
- </param>
--->
-
- <param name="language" type="Language" mandatory="false">
- <description>The currently active VR+TTS language on Sync. See "Language" for options.</description>
- </param>
-
- <param name="hmiDisplayLanguage" type="Language" mandatory="false">
- <description>The currently active display language on Sync. See "Language" for options.</description>
- </param>
-
- <param name="displayCapabilities" type="DisplayCapabilities" mandatory="false">
- <description>See DisplayCapabilities</description>
- </param>
-
- <param name="buttonCapabilities" type="ButtonCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>See ButtonCapabilities</description >
- </param>
-
- <param name="softButtonCapabilities" type="SoftButtonCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>If returned, the platform supports on-screen SoftButtons.</description>
- <description>See SoftButtonCapabilities</description >
- </param>
-
- <param name="presetBankCapabilities" type="PresetBankCapabilities" mandatory="false">
- <description>If returned, the platform supports custom on-screen Presets.</description>
- <description>See PresetBankCapabilities</description >
- </param>
-
- <param name="hmiZoneCapabilities" type="HmiZoneCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <issue creator="rs">If not used yet => remove</issue>
- <description>See HmiZoneCapabilities</description>
- </param>
-
- <param name="speechCapabilities" type="SpeechCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>See SpeechCapabilities</description>
- </param>
-
- <param name="vrCapabilities" type="VrCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>See VrCapabilities</description>
- </param>
-
- <param name="vehicleType" type="VehicleType" mandatory="false">
- <description>Specifies the vehicle's type. See VehicleType.</description>
- </param>
-
- </function>
-
- <function name="UnregisterAppInterface" functionID="UnregisterAppInterfaceID" messagetype="request">
- <description>Closes an interface from a mobile application.</description>
- <description>After unregisterAppInterface, no commands other than registerAppInterface will be accepted/executed.</description>
- <description>Will fail, if no registerAppInterface was completed successfully before.</description>
- </function>
-
- <function name="UnregisterAppInterface" functionID="UnregisterAppInterfaceID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="SetGlobalProperties" functionID="SetGlobalPropertiesID" messagetype="request">
- <description>Allows setting global properties.</description>
-
- <param name="helpPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false" >
- <description>The help prompt.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
-
- <param name="timeoutPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false" >
- <description>Help text for a wait timeout.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
-
- <param name="vrHelpTitle" type="String" maxlength="500" mandatory="false">
- <description>VR Help Title text.</description>
- <description>If omitted on supported displays, the default SYNC help title shall be used.</description>
- </param>
-
- <param name="vrHelp" type="VrHelpItem" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>VR Help Items.</description>
- <description>If omitted on supported displays, the default SYNC generated help items shall be used.</description>
- <description>If the list of VR Help Items contains nonsequential positions (e.g. [1,2,4]), the RPC shall be rejected.</description>
- </param>
-
- </function>
-
- <function name="SetGlobalProperties" functionID="SetGlobalPropertiesID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="ResetGlobalProperties" functionID="ResetGlobalPropertiesID" messagetype="request">
- <description>Allows resetting global properties.</description>
-
- <param name="properties" type="GlobalProperty" minsize="1" maxsize="100" array="true" >
- <description>Contains the names of all global properties (like timeoutPrompt) that should be unset. Resetting means, that they have the same value as at start up (default)</description>
- </param>
- </function>
-
- <function name="ResetGlobalProperties" functionID="ResetGlobalPropertiesID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="AddCommand" functionID="AddCommandID" messagetype="request">
- <description>Adds a command to the in application menu.</description>
- <description>Either menuParams or vrCommands must be provided.</description>
-
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
- <description>unique ID of the command to add.</description>
- </param>
-
- <param name="menuParams" type="MenuParams" mandatory="false">
- <description>Optional sub value containing menu parameters</description>
- </param>
-
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" array="true" mandatory="false">
- <description>An array of strings to be used as VR synonyms for this command.</description>
- <description>If this array is provided, it may not be empty.</description>
- </param>
-
- <param name="cmdIcon" type="Image" mandatory="false">
- <description>Image struct determining whether static or dynamic icon.</description>
- <description>If omitted on supported displays, no (or the default if applicable) icon shall be displayed.</description>
- </param>
-
- </function>
-
- <function name="AddCommand" functionID="AddCommandID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- <element name="DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="DeleteCommand" functionID="DeleteCommandID" messagetype="request">
- <description>Deletes all commands from the in-application menu with the specified command id.</description>
-
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>ID of the command(s) to delete.</description>
- </param>
-
- </function>
-
- <function name="DeleteCommand" functionID="DeleteCommandID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="IN_USE"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="AddSubMenu" functionID="AddSubMenuID" messagetype="request">
- <description>Adds a sub menu to the in-application menu.</description>
-
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>unique ID of the sub menu to add.</description>
- </param>
-
- <param name="position" type="Integer" minvalue="0" maxvalue="1000" defvalue="1000" mandatory="false">
- <description>Position within the items that are are at top level of the in application menu.</description>
- <description>0 will insert at the front.</description>
- <description>1 will insert at the second position.</description>
- <description>If position is greater or equal than the number of items on top level, the sub menu will be appended to the end.</description>
- <description>Position of any submenu will always be located before the return and exit options</description>
- <description>If this param was omitted the entry will be added at the end.</description>
- </param>
-
- <param name="menuName" maxlength="500" type="String">
- <description>Text to show in the menu for this sub menu.</description>
- </param>
- </function>
-
- <function name="AddSubMenu" functionID="AddSubMenuID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="DeleteSubMenu" functionID="DeleteSubMenuID" messagetype="request">
- <description>Deletes a submenu from the in-application menu.</description>
-
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>The "menuID" of the submenu to delete. (See addSubMenu.menuID)</description>
- </param>
-
- </function>
-
- <function name="DeleteSubMenu" functionID="DeleteSubMenuID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="IN_USE"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="CreateInteractionChoiceSet" functionID="CreateInteractionChoiceSetID" messagetype="request">
- <description>creates interaction choice set to be used later by performInteraction</description>
-
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Unique ID used for this interaction choice set.</description>
- </param>
-
- <param name="choiceSet" type="Choice" minsize="1" maxsize="100" array="true" />
- </function>
-
- <function name="CreateInteractionChoiceSet" functionID="CreateInteractionChoiceSetID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="PerformInteraction" functionID="PerformInteractionID" messagetype="request">
- <description>Triggers an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow).</description>
-
- <param name="initialText" type="String" maxlength="500" >
- <description>Text to be displayed first.</description>
- </param>
-
- <param name="initialPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true">
- <description>This is the intial prompt spoken to the user at the start of an interaction</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
-
- <param name="interactionMode" type="InteractionMode">
- <description>See InteractionMode.</description>
- </param>
-
- <param name="interactionChoiceSetIDList" type="Integer" minsize="1" maxsize="100" minvalue="0" maxvalue="2000000000" array="true">
- <description>List of interaction choice set IDs to use with an interaction.</description>
- </param>
-
- <param name="helpPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Help text. This is the spoken string when a user speaks "help" when the interaction is occuring.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
-
- <param name="timeoutPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Timeout text. This text is spoken when a VR interaction times out.</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
-
- <param name="timeout" type="Integer" minvalue="5000" maxvalue="100000" defvalue="10000" mandatory="false">
- <description>Timeout in milliseconds.</description>
- <description>If omitted a standard value of 10000 milliseconds is used.</description>
- </param>
-
- <param name="vrHelp" type="VrHelpItem" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Ability to send suggested VR Help Items to display on-screen during Perform Interaction.</description>
- <description>If omitted on supported displays, the default SYNC generated list of suggested choices shall be displayed.</description>
- </param>
-
- </function>
-
- <function name="PerformInteraction" functionID="PerformInteractionID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- <element name="TIMED_OUT"/>
- <element name="ABORTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
- <description>ID of the choice that was selected in response to PerformInteraction.</description>
- </param>
-
- <param name="triggerSource" type="TriggerSource" mandatory="false">
- <description>See TriggerSource</description>
- </param>
-
- </function>
-
- <function name="DeleteInteractionChoiceSet" functionID="DeleteInteractionChoiceSetID" messagetype="request">
- <description>Deletes interaction choice set that has been created with "CreateInteractionChoiceSet".</description>
- <description>The interaction may only be deleted when not currently in use by a "performInteraction".</description>
-
- <param name="interactionChoiceSetID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>ID of the interaction choice set to delete.</description>
- </param>
- </function>
-
- <function name="DeleteInteractionChoiceSet" functionID="DeleteInteractionChoiceSetID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="IN_USE"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="Alert" functionID="AlertID" messagetype="request">
- <description>Shows an alert which typically consists of text-to-speech message and text on the display. At least either alertText1, alertText2 or TTSChunks need to be provided.</description>
-
- <param name="alertText1" type="String" maxlength="500" mandatory="false">
- <description>The first line of the alert text field</description>
- </param>
-
- <param name="alertText2" type="String" maxlength="500" mandatory="false">
- <description>The second line of the alert text field</description>
- </param>
-
- <param name="alertText3" type="String" maxlength="500" mandatory="false">
- <description>The optional third line of the alert text field</description>
- </param>
-
- <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
-
- <param name="duration" type="Integer" minvalue="3000" maxvalue="10000" defvalue="5000" mandatory="false">
- <description>Timeout in milliseconds.</description>
- <description>Typical timeouts are 3-5 seconds</description>
- <description>If omitted, timeout is set to 5s.</description>
- </param>
-
- <param name="playTone" type="Boolean" mandatory="false">
- <description>Defines if tone should be played. Tone is played before TTS.</description>
- <description>If omitted, no tone is played.</description>
- </param>
-
- <param name="softButtons" type="SoftButton" minsize="0" maxsize="4" array="true" mandatory="false">
- <description>App defined SoftButtons.</description>
- <description>If omitted on supported displays, the displayed alert shall not have any SoftButtons.</description>
- </param>
-
- </function>
-
- <function name="Alert" functionID="AlertID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="ABORTED"/>
- <element name="DISALLOWED"/>
- <element name="USER_DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="tryAgainTime" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Amount of time (in seconds) that an app must wait before resending an alert.</description>
- <description>If provided, another system event or overlay currently has a higher priority than this alert.</description>
- <description>An app must not send an alert without waiting at least the amount of time dictated.</description>
- </param>
-
- </function>
-
- <function name="Show" functionID="ShowID" messagetype="request">
- <description>Updates the persistent display. Supported fields depend on display capabilities.</description>
-
- <param name="mainField1" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed in a single or upper display line.</description>
- <description>If this text is not set, the text of mainField1 stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
-
- <param name="mainField2" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed on the second display line.</description>
- <description>If this text is not set, the text of mainField2 stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
-
- <param name="mainField3" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed on the second "page" first display line.</description>
- <description>If this text is not set, the text of mainField3 stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
-
- <param name="mainField4" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed on the second "page" second display line.</description>
- <description>If this text is not set, the text of mainField4 stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
-
- <param name="alignment" type="TextAlignment" mandatory="false">
- <description>Specifies how mainField1 and mainField2 texts should be aligned on display.</description>
- <description>If omitted, texts will be centered</description>
- </param>
-
- <param name="statusBar" type="String" maxlength="500" mandatory="false">
- <description>Requires investigation regarding the nav display capabilities. Potentially lower lowerStatusBar, upperStatusBar, titleBar, etc.</description>
- </param>
-
- <param name="mediaClock" type="String" maxlength="500" mandatory="false">
- <description>Text value for MediaClock field. Has to be properly formatted by Mobile App according to Sync capabilities.</description>
- <description>If this text is set, any automatic media clock updates previously set with SetMediaClockTimer will be stopped.</description>
- <issue creator="rs">To be deprecated (Clearing should be done in SetMediaClockTimer)</issue>
- </param>
-
- <param name="mediaTrack" type="String" maxlength="500" mandatory="false">
- <description>The text that should be displayed in the track field.</description>
- <description>This field is only valid for media applications on NGN type ACMs.</description>
- <description>If this text is not set, the text of mediaTrack stays unchanged.</description>
- <description>If this text is empty "", the field will be cleared.</description>
- </param>
-
- <param name="graphic" type="Image" mandatory="false">
- <description>Image struct determining whether static or dynamic image to display in app.</description>
- <description>If omitted on supported displays, the displayed graphic shall not change.</description>
- </param>
-
- <param name="softButtons" type="SoftButton" minsize="0" maxsize="8" array="true" mandatory="false">
- <description>App defined SoftButtons.</description>
- <description>If omitted on supported displays, the currently displayed SoftButton values will not change.</description>
- </param>
-
- <param name="customPresets" type="String" maxlength="500" minsize="0" maxsize="6" array="true" mandatory="false">
- <description>App labeled on-screen presets (i.e. GEN2).</description>
- <description>If omitted on supported displays, the presets will be shown as not defined.</description>
- </param>
-
- </function>
-
- <function name="Show" functionID="ShowID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- <element name="ABORTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="Speak" functionID="SpeakID" messagetype="request">
- <description>Speaks a text.</description>
-
- <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true">
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
-
- </function>
-
- <function name="Speak" functionID="SpeakID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- <element name="ABORTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="SetMediaClockTimer" functionID="SetMediaClockTimerID" messagetype="request">
- <description>Sets the initial media clock value and automatic update method.</description>
-
- <param name="startTime" type="StartTime" mandatory="false">
- <description>See StartTime</description>
- <description>startTime must be provided for "COUNTUP" and "COUNTDOWN"</description>
- <description>startTime will be ignored for "PAUSE", "RESUME", and "CLEAR"</description>
- </param>
-
- <param name="updateMode" type="UpdateMode" mandatory="true">
- <description>Enumeration to control the media clock.</description>
- <description>In case of pause, resume, or clear, the start time value is ignored and shall be left out. For resume, the time continues with the same value as it was when paused.</description>
- </param>
- </function>
-
- <function name="SetMediaClockTimer" functionID="SetMediaClockTimerID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="IGNORED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="EncodedSyncPData" functionID="EncodedSyncPDataID" messagetype="request">
- <description>Allows encoded data in the form of SyncP packets to be sent to the SYNC module</description>
-
- <param name="data" type="String" maxlength="10000" minsize="1" maxsize="100" array="true" mandatory="true">
- <description>Contains base64 encoded string of SyncP packets.</description>
- <todo>What is the maxlength</todo>
- </param>
- </function>
-
- <function name="EncodedSyncPData" functionID="EncodedSyncPDataID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="DialNumber" functionID="DialNumberID" messagetype="request">
- <description>Dials a phone number and switches to phone application.</description>
-
- <param name="number" type="String" maxlength="500">
- <issue creator="rs">Should it really be a simple string?</issue>
- <description>Phone number is a string consisting of only the digits and "+", which can be up to 40 chars.</description>
- </param>
- </function>
-
- <function name="DialNumber" functionID="DialNumberID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="PerformAudioPassThru" functionID="PerformAudioPassThruID" messagetype="request">
- <description>Starts audio pass thru session </description>
- <param name="initialPrompt" type="TTSChunk" minsize="1" maxsize="100" array="true">
- <description>SYNC will speak this prompt before opening the audio pass thru session</description>
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- <description>The array must have at least one item</description>
- </param>
- <param name="audioPassThruDisplayText1" type="String" mandatory="false" maxlength="500">
- <description>First line of text displayed during audio capture.</description>
- </param>
- <param name="audioPassThruDisplayText2" type="String" mandatory="false" maxlength="500">
- <description>Second line of text displayed during audio capture.</description>
- </param>
- <param name="samplingRate" type="SamplingRate" mandatory="true">
- <description> This value shall be allowed at 8 khz or 16 or 22 or 44 khz.</description>
- </param>
- <param name="maxDuration" type="Integer" minvalue="0" maxvalue="1000000" mandatory="true">
- <description>The maximum duration of audio recording in milliseconds. </description>
- </param>
- <param name="bitsPerSample" type="AudioCaptureQuality" mandatory="true">
- <description>Specifies the quality the audio is recorded. Currently 8 bit or 16 bit.</description>
- </param>
- <param name="audioType" type="AudioType" mandatory="true">
- <description>Specifies the type of audio data being requested.</description>
- </param>
- </function>
-
- <function name="PerformAudioPassThru" functionID="PerformAudioPassThruID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="DISALLOWED"/>
- <element name="REJECTED"/>
- <element name="ABORTED"/>
- <!-- <element name="RETRY"/>-->
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="EndAudioPassThru" functionID="EndAudioPassThruID" messagetype="request">
- <description>When this request is invoked, the audio capture stops.</description>
- </function>
-
- <function name="EndAudioPassThru" functionID="EndAudioPassThruID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="SubscribeButton" functionID="SubscribeButtonID" messagetype="request">
- <description>Subscribes to built-in HMI buttons.</description>
- <description>The application will be notified by the OnButtonEvent and OnButtonPress.</description>
- <description>To unsubscribe the notifications, use unsubscribeButton.</description>
-
- <param name="buttonName" type="ButtonName">
- <description>Name of the button to subscribe.</description>
- </param>
- </function>
-
- <function name="SubscribeButton" functionID="SubscribeButtonID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="UNSUPPORTED_BUTTON" />
- <element name="IGNORED" />
- <element name="REJECTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="UnsubscribeButton" functionID="UnsubscribeButtonID" messagetype="request">
- <description>Unsubscribes from built-in HMI buttons.</description>
-
- <param name="buttonName" type="ButtonName">
- <description>Name of the button to unsubscribe.</description>
- </param>
- </function>
-
- <function name="UnsubscribeButton" functionID="UnsubscribeButtonID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="UNSUPPORTED_BUTTON" />
- <element name="IGNORED" />
- <element name="REJECTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="SubscribeVehicleData" functionID="SubscribeVehicleDataID" messagetype="request">
- <description>Subscribes for specific published data items.</description>
- <description>The data will be only sent if it has changed.</description>
- <description>The application will be notified by the onVehicleData notification whenever new data is available.</description>
- <description>To unsubscribe the notifications, use unsubscribe with the same subscriptionType.</description>
-
- <param name="dataType" type="VehicleDataType" array="true" mandatory="true" minsize="1" maxsize="100">
- <description>List of defined vehicle data elements.</description>
- <description>See VehicleDataType</description>
- </param>
-
- </function>
-
- <function name="SubscribeVehicleData" functionID="SubscribeVehicleDataID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="WARNINGS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="IGNORED" />
- <element name="DISALLOWED"/>
- <element name="USER_DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="dataResult" type="VehicleDataResult" mandatory="false" array="true" minsize="1" maxsize="100">
- <description>Permission status of vehicle data element.</description>
- </param>
-
- </function>
-
- <function name="UnsubscribeVehicleData" functionID="UnsubscribeVehicleDataID" messagetype="request">
- <description>This function is used to unsubscribe the notifications from the subscribeVehicleData function.</description>
-
- <param name="dataType" type="VehicleDataType" array="true" mandatory="true" minsize="1" maxsize="100">
- <description>Refers to the vehicle data elements specified by subscribeVehicleData.</description>
- <description>See VehicleDataType</description>
- </param>
- </function>
-
- <function name="UnsubscribeVehicleData" functionID="UnsubscribeVehicleDataID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="WARNINGS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="IGNORED" />
- <element name="DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="dataResult" type="VehicleDataResult" mandatory="false" array="true" minsize="1" maxsize="100">
- <description>Permission status of vehicle data element.</description>
- </param>
-
- </function>
-
- <function name="GetVehicleData" functionID="GetVehicleDataID" messagetype="request">
- <description>Non periodic vehicle data read request.</description>
-
- <param name="dataType" type="VehicleDataType">
- <description>Complex signals like "GPS" should not be transferred as separate notifications, but all together in one notification.</description>
- </param>
- </function>
-
- <function name="GetVehicleData" functionID="GetVehicleDataID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="VEHICLE_DATA_NOT_ALLOWED"/>
- <element name="VEHICLE_DATA_NOT_AVAILABLE"/>
- <element name="USER_DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="gps" type="GPSData" mandatory="false">
- <description>See GPSData</description>
- <description>Subscribable</description>
- </param>
- <param name="speed" type="Float" minvalue="-100" maxvalue="500" mandatory="false">
- <description>The vehicle speed in kilometers per hour</description>
- <description>Subscribable</description>
- </param>
- <param name="rpm" type="Integer" minvalue="0" maxvalue="20000" mandatory="false">
- <description>The number of revolutions per minute of the engine</description>
- <description>Subscribable</description>
- </param>
- <param name="fuelLevel" type="Float" minvalue="0" maxvalue="100" mandatory="false">
- <description>The fuel level</description>
- </param>
- <param name="avgFuelEconomy" type="Float" minvalue="0" maxvalue="7000" mandatory="false">
- <description>The average fuel economy in litres/100km</description>
- </param>
- <param name="batteryVoltage" type="Float" minvalue="0" maxvalue="26" mandatory="false">
- <description>The voltage in Volts</description>
- </param>
- <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="false">
- <description>The external temperature in degrees celsius.</description>
- </param>
- <param name="vin" type="String" maxlength="17" mandatory="false">
- <description>Vehicle identification number.</description>
- </param>
- <param name="prndl" type="PRNDL" mandatory="false">
- <description>See PRNDL.</description>
- <description>Subscribable</description>
- <issue creator="rs">Is this a good name? Wouldn't be selectedGear better?</issue>
- </param>
- <param name="tirePressure" type="TireStatus" mandatory="false">
- <description>See TireStatus.</description>
- <description>Subscribable</description>
- </param>
- <param name="batteryPackVoltage" type="Float" minvalue="-1000" maxvalue="1000" mandatory="false">
- <description>Battery pack voltage of hybrid and electrical vehicles in volts</description>
- </param>
- <param name="batteryPackCurrent" type="Float" minvalue="-1000" maxvalue="1000" mandatory="false">
- <description>Battery current of hybrid and electrical vehicles in amperes</description>
- </param>
- <param name="batteryPackTemperature" type="Integer" minvalue="-50" maxvalue="250" mandatory="false">
- <description>Battery temperature of hybrid and electrical vehicles in degrees celsius</description>
- </param>
- <param name="engineTorque" type="Integer" minvalue="-10000" maxvalue="55000" mandatory="false">
- <description>Engine torque in Nm</description>
- <description>Subscribable</description>
- </param>
- <param name="odometer" type="Integer" minvalue="0" maxvalue="2000000" mandatory="false">
- <description>Odometer in km</description>
- </param>
- <param name="tripOdometer" type="Integer" minvalue="0" maxvalue="2000000" mandatory="false">
- <description>Odometer of trip in km</description>
- <issue creator="rs">This mixes up "Trip A" and "Total distance during this trip". Shall we seperate these two instead</issue>
- </param>
- <param name="satRadioESN" type="String" maxlength="500" mandatory="false">
- <description>The hexadecimal ESN of the satellite radio (if supported).</description>
- </param>
-
- </function>
-
- <function name="ReadDID" functionID="ReadDIDID" messagetype="request">
- <description>Non periodic vehicle data read request.</description>
-
- <param name="ecuName" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Name of ECU.</description>
- </param>
- <param name="didLocation" type="Integer" minvalue="0" maxvalue="65535" minsize="0" maxsize="1000" array="true" mandatory="true">
- <description>Get raw data from vehicle data DID location(s).</description>
- </param>
- <param name="encrypted" type="Boolean" mandatory="false">
- <description>If not provided, the default is equal to False"</description>
- <description>Indicates if the DID data requested should be returned as encrypted through an OnEncodedSYNCPData response.</description>
- <description>If set to true, the data will return instead through OnEncodedSYNCPData and be passed through the proxy to the designated server URL.</description>
- </param>
-
- </function>
-
- <function name="ReadDID" functionID="ReadDIDID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- <element name="ENCRYPTED"/>
- <element name="USER_DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="dataResult" type="VehicleDataResultCode" minsize="0" maxsize="1000" array="true" mandatory="false">
- <description>Permission status of data element.</description>
- </param>
-
- <param name="data" type="String" maxlength="5000" minsize="0" maxsize="1000" array="true" mandatory="false">
- <description>Raw DID-based data returned for requested element.</description>
- </param>
-
- </function>
-
- <function name="GetDTCs" functionID="GetDTCsID" messagetype="request">
- <description>Vehicle module diagnostic trouble code request.</description>
-
- <param name="ecuName" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Name of ECU.</description>
- </param>
-
- <param name="encrypted" type="Boolean" defvalue="false" mandatory="false">
- <description>If not provided, the default is equal to False"</description>
- <description>Indicates if the DTC data requested should be returned as encrypted through an OnEncodedSYNCPData response.</description>
- <description>If set to true, the data will return instead through OnEncodedSYNCPData and be passed through the proxy to the designated server URL.</description>
- </param>
-
- </function>
-
- <function name="GetDTCs" functionID="GetDTCsID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- <element name="USER_DISALLOWED"/>
- <element name="ENCRYPTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="dtcList" type="DTC" mandatory="false" array="true" minsize="1" maxsize="100">
- <description>Array of all reported DTCs on module.</description>
- </param>
-
- </function>
-
- <function name="ScrollableMessage" functionID="ScrollableMessageID" messagetype="request">
- <description>Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined</description>
- <param name="scrollableMessageBody" type="String" maxlength="500">
- <description>Body of text that can include newlines and tabs.</description>
- </param>
- <param name="timeout" type="Integer" minvalue="0" maxvalue="65535" defvalue="30000" mandatory="false">
- <description>App defined timeout.</description>
- </param>
- <param name="softButtons" type="SoftButton" minsize="0" maxsize="8" array="true" mandatory="false">
- <description>App defined SoftButtons.</description>
- <description>If omitted on supported displays, only the system defined "Close" SoftButton will be displayed.</description>
- </param>
- </function>
-
- <function name="ScrollableMessage" functionID="ScrollableMessageID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <!--<element name="CHAR_LIMIT_EXCEEDED"/>-->
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="DISALLOWED"/>
- <element name="REJECTED"/>
- <element name="ABORTED"/>
- </param>
- </function>
-
- <function name="Slider" functionID="SliderID" messagetype="request">
- <description>Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider.</description>
- <param name="numTicks" type="Integer" minvalue="2" maxvalue="26" mandatory="true">
- <description>Number of selectable items on a horizontal axis</description>
- </param>
- <param name="position" type="Integer" minvalue="1" maxvalue="26" mandatory="true">
- <description>Initial position of slider control (cannot exceed numTicks)</description>
- </param>
- <param name="sliderHeader" type="String" maxlength="500" mandatory="true">
- <description>Text header to display</description>
- </param>
- <param name="sliderFooter" type="String" maxlength="500" minsize="1" maxsize="26" array="true" mandatory="false">
- <description>Text footer to display (meant to display min/max threshold descriptors).</description>
- <description>For a static text footer, only one footer string shall be provided in the array.</description>
- <description>For a dynamic text footer, the number of footer text string in the array must match the numTicks value.</description>
- <description>For a dynamic text footer, text array string should correlate with potential slider position index.</description>
- <description>If omitted on supported displays, no footer text shall be displayed.</description>
- </param>
- <param name="timeout" type="Integer" minvalue="0" maxvalue="65535" defvalue="10000">
- <description>App defined timeout.</description>
- </param>
- </function>
-
- <function name="Slider" functionID="SliderID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <!--<element name="SAVED"/>-->
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="DISALLOWED"/>
- <element name="REJECTED"/>
- <element name="ABORTED"/>
- </param>
- <param name="sliderPosition" type="Integer" minvalue="1" maxvalue="26">
- <description>Current slider value returned when saved or canceled</description>
- </param>
- </function>
-
- <function name="ShowConstantTBT" functionID="ShowConstantTBTID" messagetype="request">
- <param name="navigationText1" type="String" maxlength="500" mandatory="false">
- </param>
- <param name="navigationText2" type="String" maxlength="500" mandatory="false">
- </param>
- <param name="eta" type="String" maxlength="500" mandatory="false">
- </param>
- <param name="totalDistance" type="String" maxlength="500" mandatory="false">
- </param>
- <param name="turnIcon" type="Image">
- </param>
- <param name="distanceToManeuver" type="Float" minvalue="0" maxvalue="1000000000">
- <description>Distance till next maneuver (starting from) from previous maneuver.</description>
- <description>Used to calculate progress bar.</description>
- </param>
- <param name="distanceToManeuverScale" type="Float" minvalue="0" maxvalue="1000000000">
- <description>Fraction of distance till next maneuver (starting from when AlertManeuver is triggered).</description>
- <description>Used to calculate progress bar.</description>
- </param>
- <param name="maneuverComplete" type="Boolean" mandatory="false">
- <description>If and when a maneuver has completed while an AlertManeuver is active, the app must send this value set to TRUE in order to clear the AlertManeuver overlay.</description>
- <description>If omitted the value will be assumed as FALSE.</description>
- </param>
- <param name="softButtons" type="SoftButton" minsize="0" maxsize="3" array="true">
- <description>Three dynamic SoftButtons available (second SoftButton is fixed to "Turns").</description>
- <description>If omitted on supported displays, the currently displayed SoftButton values will not change.</description>
- </param>
- </function>
-
- <function name="ShowConstantTBT" functionID="ShowConstantTBTID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="AlertManeuver" functionID="AlertManeuverID" messagetype="request">
- <param name="ttsChunks" type="TTSChunk" minsize="1" maxsize="100" array="true">
- <description>An array of text chunks of type TTSChunk. See TTSChunk</description>
- </param>
- <param name="softButtons" type="SoftButton" minsize="0" maxsize="3" array="true">
- <description>If omitted on supported displays, only the system defined "Close" SoftButton shall be displayed.</description>
- </param>
- </function>
-
- <function name="AlertManeuver" functionID="AlertManeuverID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="IGNORED"/>
- <element name="DISALLOWED"/>
- <element name="ABORTED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="UpdateTurnList" functionID="UpdateTurnListID" messagetype="request">
- <param name="turnList" type="Turn" minsize="1" maxsize="100" array="true">
- </param>
- <param name="softButtons" type="SoftButton" minsize="0" maxsize="1" array="true">
- <description>If omitted on supported displays, app-defined SoftButton will be left blank.</description>
- </param>
- </function>
-
- <function name="UpdateTurnList" functionID="UpdateTurnListID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- </param>
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="ChangeRegistration" functionID="ChangeRegistrationID" messagetype="request">
- <param name="language" type="Language" mandatory="true">
- <description>Requested SYNC voice engine (VR+TTS) language registration</description>
- </param>
- <param name="hmiDisplayLanguage" type="Language" mandatory="true">
- <description>Request display language registration</description>
- </param>
- </function>
-
- <function name="ChangeRegistration" functionID="ChangeRegistrationID" messagetype="response">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="GenericResponse" functionID="GenericResponseID" messagetype="response">
- <description>Generic Response is sent, when the name of a received msg cannot be retrieved. Only used in case of an error.</description>
- <description>Currently, only resultCode INVALID_DATA is used.</description>
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="INVALID_DATA"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
-<!--
- <function name="GetFile" messagetype="request">
- <param name="syncFileName" type="String" >
- <description>File source on sync.</description>
- </param>
-
- </function>
--->
-<!--
- <function name="GetFile" messagetype="response">
- <description>Response is sent, when the file data was copied (success case). Or when an error occured.</description>
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="FILE_NOT_FOUND"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
--->
-
- <function name="PutFile" functionID="PutFileID" messagetype="request" platform="gen2">
- <description>Used to push a binary data onto the SYNC module from a mobile device, such as icons and album art</description>
- <description>Not supported on first generation SYNC vehicles. </description>
-
- <param name="syncFileName" type="String" maxlength="500" mandatory="true">
- <description>File reference name.</description>
- </param>
-
- <param name="fileType" type="FileType">
- <description>Selected file type.</description>
- </param>
-
- <param name="persistentFile" type="Boolean" defvalue="false" mandatory="false">
- <description>Indicates if the file is meant to persist between sessions / ignition cycles.</description>
- <description>If set to TRUE, then the system will aim to persist this file through session / cycles.</description>
- <description>While files with this designation will have priority over others, they are subject to deletion by the system at any time.</description>
- <description>In the event of automatic deletion by the system, the app will receive a rejection and have to resend the file.</description>
- <description>If omitted, the value will be set to false.</description>
- </param>
-
- <param name="fileData" type="String" mandatory="false" >
- <description>Binary data.</description>
- </param>
- </function>
-
- <function name="PutFile" functionID="PutFileID" messagetype="response" platform="gen2">
- <description>Response is sent, when the file data was copied (success case). Or when an error occured.</description>
- <description>Not supported on First generation SYNC vehicles. </description>
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
-
- <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Provides the total local space available on SYNC for the registered app.</description>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="DeleteFile" functionID="DeleteFileID" messagetype="request" platform="gen2">
- <description>Used to delete a file resident on the SYNC module in the app's local cache.</description>
- <description>Not supported on first generation SYNC vehicles. </description>
-
- <param name="syncFileName" type="String" maxlength="500" mandatory="true">
- <description>File reference name.</description>
- </param>
-
- </function>
-
- <function name="DeleteFile" functionID="DeleteFileID" messagetype="response" platform="gen2">
- <description>Response is sent, when the file data was deleted (success case). Or when an error occured.</description>
- <description>Not supported on First generation SYNC vehicles. </description>
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
-
- <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Provides the total local space available on SYNC for the registered app.</description>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="ListFiles" functionID="ListFilesID" messagetype="request" platform="gen2">
- <description>Requests the current list of resident filenames for the registered app</description>
- <description>Not supported on first generation SYNC vehicles. </description>
- </function>
-
- <function name="ListFiles" functionID="ListFilesID" messagetype="response" platform="gen2">
- <description>Returns the current list of resident filenames for the registered app along with the current space available</description>
- <description>Not supported on First generation SYNC vehicles. </description>
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
-
- <param name="filenames" type="String" maxlength="500" minsize="0" maxsize="1000" array="true" mandatory="false">
- <description>An array of all filenames resident on SYNC for the given registered app.</description>
- <description>If omitted, then no files currently reside on the system.</description>
- </param>
-
- <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Provides the total local space available on SYNC for the registered app.</description>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
- <function name="SetAppIcon" functionID="SetAppIconID" messagetype="request" platform="gen2">
- <description>Used to set existing local file on SYNC as the app's icon</description>
- <description>Not supported on first generation SYNC vehicles. </description>
-
- <param name="syncFileName" type="String" maxlength="500" mandatory="true">
- <description>File reference name.</description>
- </param>
-
- </function>
-
- <function name="SetAppIcon" functionID="SetAppIconID" messagetype="response" platform="gen2">
- <description>Response is sent, when the file data was copied (success case). Or when an error occured.</description>
- <description>Not supported on First generation SYNC vehicles. </description>
- <description>Response is sent, when the file data was copied (success case). Or when an error occured.</description>
- <description>Not supported on First generation SYNC vehicles. </description>
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <function name="SetDisplayLayout" functionID="SetDisplayLayoutID" messagetype="request" platform="gen2">
- <description>Used to set an alternate display layout.</description>
- <description>If not sent, default screen for given platform will be shown.</description>
-
- <param name="displayLayout" type="String" mandatory="true">
- <description>Predefined or dynamically created screen layout.</description>
- <description>Currently only predefined screen layouts are defined.</description>
- <description>Predefined layouts include:</description>
- <description> "ONSCREEN_PRESETS"</description>
- <description> Custom screen containing app-defined onscreen presets. Currently defined for GEN2.</description>
- </param>
-
- </function>
-
- <function name="SetDisplayLayout" functionID="SetDisplayLayoutID" messagetype="response" platform="gen2">
-
- <param name="success" type="Boolean" platform="documentation">
- <description>true, if successful</description>
- <description>false, if failed</description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- </function>
-
- <!-- Notifications -->
-
- <function name="OnHMIStatus" functionID="OnHMIStatusID" messagetype="notification">
- <param name="hmiLevel" type="HMILevel">
- <description>See HMILevel</description>
- </param>
-
- <param name="audioStreamingState" type="AudioStreamingState">
- <description>See AudioStreamingState</description>
- </param>
-
- <param name="systemContext" type="SystemContext">
- <description>See SystemContext</description>
- </param>
- </function>
-
- <function name="OnAppInterfaceUnregistered" functionID="OnAppInterfaceUnregisteredID" messagetype="notification">
- <param name="reason" type="AppInterfaceUnregisteredReason">
- <description>See AppInterfaceUnregisteredReason</description>
- </param>
- </function>
-
- <function name="OnButtonEvent" functionID="OnButtonEventID" messagetype="notification">
- <description>Notifies application of UP/DOWN events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonEventMode" type="ButtonEventMode">
- <description>Indicates whether this is an UP or DOWN event.</description>
- </param>
- <param name="customButtonID" type="Integer" minvalue="0" maxvalue="65536">
- <description>If ButtonName is “CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID)</description>
- </param>
- </function>
-
- <function name="OnButtonPress" functionID="OnButtonPressID" messagetype="notification">
- <description>Notifies application of LONG/SHORT press events for buttons to which the application is subscribed.</description>
- <param name="buttonName" type="ButtonName"/>
- <param name="buttonPressMode" type="ButtonPressMode">
- <description>Indicates whether this is a LONG or SHORT button press event.</description>
- </param>
- <param name="customButtonID" type="Integer" minvalue="0" maxvalue="65536">
- <description>If ButtonName is “CUSTOM_BUTTON", this references the integer ID passed by a custom button. (e.g. softButton ID)</description>
- </param>
- </function>
-
- <function name="OnVehicleData" functionID="OnVehicleDataID" messagetype="notification">
- <description>Callback for the periodic and non periodic vehicle data read function.</description>
- <param name="gps" type="GPSData" mandatory="false">
- <description>See GPSData</description>
- <description>Subscribable</description>
- </param>
- <param name="speed" type="Float" minvalue="-100" maxvalue="500" mandatory="false">
- <description>The vehicle speed in kilometers per hour</description>
- <description>Subscribable</description>
- </param>
- <param name="rpm" type="Integer" minvalue="0" maxvalue="20000" mandatory="false">
- <description>The number of revolutions per minute of the engine</description>
- <description>Subscribable</description>
- </param>
- <param name="fuelLevel" type="Float" minvalue="0" maxvalue="100" mandatory="false">
- <description>The fuel level</description>
- </param>
- <param name="avgFuelEconomy" type="Float" minvalue="0" maxvalue="7000" mandatory="false">
- <description>The average fuel economy in litres/100km</description>
- </param>
- <param name="batteryVoltage" type="Float" minvalue="0" maxvalue="26" mandatory="false">
- <description>The voltage in Volts</description>
- </param>
- <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="false">
- <description>The external temperature in degrees celsius.</description>
- </param>
- <param name="vin" type="String" maxlength="17" mandatory="false">
- <description>Vehicle identification number.</description>
- </param>
- <param name="prndl" type="PRNDL" mandatory="false">
- <description>See PRNDL.</description>
- <description>Subscribable</description>
- <issue creator="rs">Is this a good name? Wouldn't be selectedGear better?</issue>
- </param>
- <param name="tirePressure" type="TireStatus" mandatory="false">
- <description>See TireStatus.</description>
- <description>Subscribable</description>
- </param>
- <param name="batteryPackVoltage" type="Float" minvalue="-1000" maxvalue="1000" mandatory="false">
- <description>Battery pack voltage of hybrid and electrical vehicles in volts</description>
- </param>
- <param name="batteryPackCurrent" type="Float" minvalue="-1000" maxvalue="1000" mandatory="false">
- <description>Battery current of hybrid and electrical vehicles in amperes</description>
- </param>
- <param name="batteryPackTemperature" type="Integer" minvalue="-50" maxvalue="250" mandatory="false">
- <description>Battery temperature of hybrid and electrical vehicles in degrees celsius</description>
- </param>
- <param name="engineTorque" type="Integer" minvalue="-10000" maxvalue="55000" mandatory="false">
- <description>Engine torque in Nm</description>
- <description>Subscribable</description>
- </param>
- <param name="odometer" type="Integer" minvalue="0" maxvalue="2000000" mandatory="false">
- <description>Odometer in km</description>
- </param>
- <param name="tripOdometer" type="Integer" minvalue="0" maxvalue="2000000" mandatory="false">
- <description>Odometer of trip in km</description>
- <issue creator="rs">This mixes up "Trip A" and "Total distance during this trip". Shall we seperate these two instead</issue>
- </param>
- <param name="genericbinary" type="String" maxlength="500" mandatory="false">
- <description>The hex value string is a string of hexadecimal chars, for example "FE12" or "1234ABCD".</description>
- </param>
- </function>
-
- <function name="OnCommand" functionID="OnCommandID" messagetype="notification">
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000">
- <description>Command ID, which is related to a specific menu entry.</description>
- </param>
-
- <param name="triggerSource" type="TriggerSource">
- <description>See TriggerSource</description>
- </param>
- </function>
-
- <function name="OnEncodedSyncPData" functionID="OnEncodedSyncPDataID" messagetype="notification">
- <description>Callback including encoded data of any SyncP packets that SYNC needs to send back to the mobile device.</description>
- <param name="data" type="String" maxlength="10000" minsize="1" maxsize="100" mandatory="true" array="true">
- <description>Contains base64 encoded string of SyncP packets.</description>
- </param>
- <param name="URL" type="String" maxlength="1000" mandatory="false">
- <description>If blank, the SyncP data shall be forwarded to the app.</description>
- <description>If not blank, the SyncP data shall be forwarded to the provided URL.</description>
- </param>
- <param name="Timeout" type="Integer" minvalue="-2000000000" maxvalue="2000000000" mandatory="false">
- <description>If blank, the SyncP data shall be forwarded to the app.</description>
- <description>If not blank, the SyncP data shall be forwarded with the provided timeout in seconds.</description>
- </param>
- </function>
-
- <function name="OnTBTClientState" functionID="OnTBTClientStateID" messagetype="notification" >
- <description>Provides applications with notifications specific to the current TBT client status on the module</description>
- <param name="state" type="TBTState">
- <description>Current State of TBT client</description>
- </param>
- </function>
-
- <function name="OnDriverDistraction" functionID="OnDriverDistractionID" messagetype="notification" >
- <description>Provides driver distraction state to mobile applications</description>
- <param name="state" type="DriverDistractionState">
- <description>Current State of Driver Distraction</description>
- </param>
- </function>
-
- <function name="OnPermissionsChange" functionID="OnPermissionsChangeID" messagetype="notification" >
- <description>Provides update to app of which policy-table-enabled functions are available</description>
- <param name="permissionItem" type="PermissionItem" minsize="1" maxsize="100" array="true">
- <description>Change in permissions for a given set of RPCs.</description>
- </param>
- </function>
-
- <function name="OnAudioPassThru" functionID="OnAudioPassThruID" messagetype="notification">
-<!-- TODO: REMOVE
- <param name="audioPacket" type="DataType">
- <description>Binary packet of APT data.</description>
- </param>
--->
- </function>
-
- <function name="OnLanguageChange" functionID="OnLanguageChangeID" messagetype="notification">
- <param name="language" type="Language">
- <description>Current SYNC voice engine (VR+TTS) language</description>
- </param>
- <param name="hmiDisplayLanguage" type="Language">
- <description>Current display language</description>
- </param>
- </function>
-
-
- <struct name="HMIApplication">
- <description>Data type containing information about application needed by HMI.</description>
- <param name="appName" type="String" maxlength="100"/>
- <param name="ngnMediaScreenAppName" type="String" maxlength="100" mandatory="false"/>
- <param name="icon" type="String" mandatory="false"/>
- <param name="deviceName" type="String"/>
- <param name="vrSynonyms" type="String" array="true" minsize="1" maxsize="100" maxlength="40" mandatory="false"/>
- <param name="appId" type="Integer"/>
- <param name="languageDesired" type="Language"/>
- <param name="hmiDisplayLanguageDesired" type="Language"/>
- <param name="ttsName" type="TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false"/>
- <param name="isMediaApplication" type="Boolean"/>
- <param name="appType" type="AppType" minsize="1" maxsize="100" array="true" mandatory="false"/>
-</struct>
-<enum name="DeactivateReason">
- <description>Enum of reasons of user navigating from application used by HMI.</description>
- <element name="AUDIO">
- <description>Navigated to audio(radio, etc)</description>
- </element>
- <element name="PHONECALL">
- <description>Navigated to make a call.</description>
- </element>
- <element name="NAVIGATIONMAP">
- <description>Navigated to navigation screen.</description>
- </element>
- <element name="PHONEMENU">
- <description>Navigated to phone menu.</description>
- </element>
- <element name="SYNCSETTINGS">
- <description>Navigated to settings menu.</description>
- </element>
- <element name="GENERAL">
- <description>Other screens navigation apart from other mobile app.</description>
- </element>
-</enum>
-
- </interface>
diff --git a/test/components/json_handler/test_json_rpc.xml b/test/components/json_handler/test_json_rpc.xml
deleted file mode 100644
index a754e5714..000000000
--- a/test/components/json_handler/test_json_rpc.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-<?xml version="1.0"?>
-<interfaces attr1="v1" attr2="v2">
- <interface name="interface1" attribute1="value1" attribute2="value2">
- <struct name="struct1">
- <param name="member1" type="Integer">
- <description>Param1 description</description>
- </param>
- <issue creator="creator1">Issue1</issue>
- <param name="member2" type="Boolean" mandatory="true" platform="member2 platform"/>
- <param name="member3" type="Float" maxvalue="20.5" mandatory="false"/>
- <description>Struct description</description>
- <issue creator="creator2">Issue2</issue>
- <param name="member4" type="Integer" minvalue="11" maxvalue="100" array="true"/>
- </struct>
- <issue creator="c">Issue1</issue>
- <function name="Function1" messagetype="request">
- <description>Description of request Function1</description>
- <param name="param1" type="String" mandatory="false" defvalue="String default value">
- <issue creator=""/>
- </param>
- <param name="param2" type="Integer" platform="param2 platform">
- <description>Param2 description</description>
- <todo>Param2 todo</todo>
- <description/>
- </param>
- <todo>Function1 request todo</todo>
- <param name="param3" type="struct1" mandatory="false"/>
- </function>
- <enum name="enum1" internal_scope="scope" platform="enum1 platform">
- <element name="element1" value="10"/>
- <element name="element2" internal_name="element2_internal" value="11"/>
- <element name="element3" platform="element3 platform">
- <designdescription>Element design description</designdescription>
- </element>
- </enum>
- <designdescription>dd</designdescription>
- <issue creator="c">Issue2</issue>
- <function name="Function1" messagetype="response" platform="">
- <param name="p1" type="enum1"/>
- <issue creator="c1"/>
- <issue creator="c2"></issue>
- <param name="p2" type="enum1" defvalue="element2"/>
- <param name="p3" type="Boolean" defvalue="false">
- <designdescription/>
- </param>
- </function>
- <struct name="struct2" platform="struct2 platform">
- <description>Description of struct2</description>
- <param name="m1" type="String"/>
- <param name="m2" type="String" maxlength="100" array="true" minsize="1" maxsize="50"/>
- <param name="m3" type="enum1"/>
- <param name="m4" type="struct1" array="true" maxsize="10"/>
- </struct>
- <function name="Function2" messagetype="notification" platform="function2 platform">
- <description>Function2 description</description>
- <param name="n1" type="enum1">
- <element name="element2"/>
- <element name="element3"/>
- <todo>n1 todo</todo>
- </param>
- <param name="n2" type="enum1" array="true" minsize="1" maxsize="100">
- <element name="element3"/>
- <todo>n2 todo</todo>
- <element name="element1"/>
- </param>
- <param name="n3" type="struct2" mandatory="false"/>
- </function>
- </interface>
- <interface name="interface2" attribute="value">
- <description>Description of interface2</description>
- <enum name="enum1">
- <description>Interface2 enum1 description</description>
- <element name="e1" internal_name="int_e1" value="0"/>
- <element name="e2" internal_name="int_e2" value="10"/>
- </enum>
- <enum name="enum2" internal_scope="e2 scope" platform="e2 platform">
- <element name="element1"/>
- <element name="element2"/>
- <element name="element3"/>
- </enum>
- <struct name="struct1">
- <param name="m_1" type="enum1" minsize="1" maxsize="10" array="true"/>
- <param name="m_2" type="enum2"/>
- <param name="m_3" type="String" maxlength="20"/>
- </struct>
- <function name="Function1" messagetype="request">
- <param name="param1" type="enum1" mandatory="false"/>
- <param name="param2" type="struct1" array="true" minsize="5" maxsize="25"/>
- </function>
- <todo>i2 todo</todo>
- <function name="Function1" messagetype="notification" platform="platform">
- <issue creator="c">Issue text</issue>
- <param name="param" type="enum2">
- <element name="element2"/>
- <element name="element3"/>
- </param>
- <param name="i1" type="interface1.struct2"/>
- </function>
- </interface>
-</interfaces> \ No newline at end of file
diff --git a/test/components/media_manager/CMakeLists.txt b/test/components/media_manager/CMakeLists.txt
deleted file mode 100644
index 3d7cae0f1..000000000
--- a/test/components/media_manager/CMakeLists.txt
+++ /dev/null
@@ -1,51 +0,0 @@
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ../../../src/components/media_manager/include
- ../../../src/components/utils/include/
- ../../../test/components/media_manager/include
- /usr/lib/i386-linux-gnu/glib-2.0/include
- /usr/lib/x86_64-linux-gnu/glib-2.0/include/
- ${GSTREAMER_gst_INCLUDE_DIR}
- ${GLIB_glib_2_INCLUDE_DIR}
- ${CMAKE_BINARY_DIR}/src/components/
-)
-
-if (EXTENDED_MEDIA_MODE)
- include_directories (
- ${GSTREAMER_gst_INCLUDE_DIR}
- ${GLIB_glib_2_INCLUDE_DIR}
- )
-endif()
-
-set (SOURCES
- ./src/media_manager_impl_test.cc
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- MediaManager
- ApplicationManager
- connectionHandler
- SmartObjects
- Utils
- pulse-simple
- ConfigProfile
- formatters
- jsoncpp
-)
-
-if (EXTENDED_MEDIA_MODE)
- list(APPEND LIBRARIES
- ${GSTREAMER_gstreamer_LIBRARY})
-endif()
-
-create_test("test_MediaManager" "${SOURCES}" "${LIBRARIES}")
-
-if(ENABLE_LOG)
- target_link_libraries("test_MediaManager" log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
-endif()
-# vim: set ts=2 sw=2 et:
diff --git a/test/components/media_manager/include/media_manager/media_manager_impl_test.h b/test/components/media_manager/include/media_manager/media_manager_impl_test.h
deleted file mode 100644
index 6e74677ec..000000000
--- a/test/components/media_manager/include/media_manager/media_manager_impl_test.h
+++ /dev/null
@@ -1,119 +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_AUDIO_MANAGER_INCLUDE_AUDIO_MANAGER_AUDIO_MANAGER_IMPL_TEST_H_
-#define SRC_COMPONENTS_AUDIO_MANAGER_INCLUDE_AUDIO_MANAGER_AUDIO_MANAGER_IMPL_TEST_H_
-
-#include <net/if.h>
-#include "gmock/gmock.h"
-#include "media_manager/media_manager_impl.h"
-#include "utils/threads/thread.h"
-#include "utils/threads/thread_delegate.h"
-#include "utils/logger.h"
-#include "utils/date_time.h"
-
-namespace test {
-namespace components {
-namespace media_manager_test {
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "MediaManagerImplTest")
-
-class MediaManagerTest : public ::testing::Test {
- protected:
- virtual void SetUp();
- virtual void TearDown();
-};
-
-void MediaManagerTest::SetUp() {
-}
-
-void MediaManagerTest::TearDown() {
-}
-
-TEST_F(MediaManagerTest, RecordMicrophoneStream) {
-// media_manager::MediaManager* mediaManager =
-// media_manager::MediaManagerImpl::instance();
-
- //mediaManager->startMicrophoneRecording(std::string("record.wav"),
- // mobile_apis::SamplingRate::SamplingRate_44KHZ,
- // 5,
- // mobile_apis::BitsPerSample::BitsPerSample_16_BIT);
-
- /*usleep(40000000);
-
- // Sleep for 15 sec
- usleep(15000000);
-
- mediaManager->stopMicrophoneRecording();*/
-}
-
-TEST_F(MediaManagerTest, AddAndPlayStream) {
- media_manager::MediaManager* mediaManager =
- media_manager::MediaManagerImpl::instance();
-
- const useconds_t sleeptime = 100;
-
- mediaManager->PlayA2DPSource(1);
- LOG4CXX_INFO(logger_, ".Playing stream");
-
- usleep(sleeptime);
-
- mediaManager->StopA2DPSource(1);
-
- usleep(sleeptime);
-
- mediaManager->PlayA2DPSource(1);
-
- usleep(sleeptime);
-
- mediaManager->StopA2DPSource(1);
-
- usleep(sleeptime);
-
- mediaManager->PlayA2DPSource(1);
-
- usleep(sleeptime);
-
- mediaManager->StopA2DPSource(1);
-
- usleep(sleeptime);
-
- mediaManager->StopA2DPSource(1);
-}
-
-} // namespace media_manager_test
-} // namespace components
-} // namespace test
-
-#endif // SRC_COMPONENTS_AUDIO_MANAGER_INCLUDE_AUDIO_MANAGER_AUDIO_MANAGER_IMPL_TEST_H_
-
diff --git a/test/components/media_manager/src/media_manager_impl_test.cc b/test/components/media_manager/src/media_manager_impl_test.cc
deleted file mode 100644
index 3b35691cf..000000000
--- a/test/components/media_manager/src/media_manager_impl_test.cc
+++ /dev/null
@@ -1,34 +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.
-*/
-
-#include "media_manager/media_manager_impl_test.h"
diff --git a/test/components/mobile_message_handler/CMakeLists.txt b/test/components/mobile_message_handler/CMakeLists.txt
deleted file mode 100644
index 0506f69d5..000000000
--- a/test/components/mobile_message_handler/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ../../../src/components/application_manager/include
- ../../../src/components/mobile_message_handler/include/
- ../../../test/components/mobile_message_handler/include
-)
-
-set(LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- MobileMessageHandler
- ProtocolHandler
- ApplicationManager
- Utils
-)
-
-create_test("test_mobile_message_handler"
- "./src/mobile_message_handler_test.cc"
- "${LIBRARIES}")
-
-if(ENABLE_LOG)
- target_link_libraries("test_mobile_message_handler" log4cxx -L${LOG4CXX_LIBS_DIRECTORY})
-endif()
-
-add_library("test_MobileMessageHandlerTest" "./src/mobile_message_handler_test.cc")
diff --git a/test/components/mobile_message_handler/include/mobile_message_handler/mobile_message_handler_test.h b/test/components/mobile_message_handler/include/mobile_message_handler/mobile_message_handler_test.h
deleted file mode 100644
index 296e75726..000000000
--- a/test/components/mobile_message_handler/include/mobile_message_handler/mobile_message_handler_test.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * \file mobile_message_handler_test.h
- * \brief MobileMessageHandler test header file.
- *
- * 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 TEST_COMPONENTS_MOBILE_MESSAGE_HANDLER_INCLUDE_MOBILE_MESSAGE_HANDLER_MOBILE_MESSAGE_HANDLER_TEST_H_
-#define TEST_COMPONENTS_MOBILE_MESSAGE_HANDLER_INCLUDE_MOBILE_MESSAGE_HANDLER_MOBILE_MESSAGE_HANDLER_TEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "mobile_message_handler/mobile_message_handler_impl.h"
-#include "protocol_handler/protocol_handler_impl.h"
-#include "utils/lock.h"
-#include "utils/conditional_variable.h"
-#include "utils/threads/thread.h"
-#include "utils/threads/thread_delegate.h"
-
-//! ---------------------------------------------------------------------------
-
-sync_primitives::Lock lock;
-sync_primitives::ConditionalVariable cond_var;
-const unsigned int kTimeout = 2;
-bool flag = false;
-
-//! ---------------------------------------------------------------------------
-namespace test {
-namespace components {
-namespace mobile_message_handler_test {
-/**
- * @class MobileMessageHandlerTester implements ApplicationManager
- * and ProtocolHandler logic.
- */
-class MobileMessageHandlerTester :
- public mobile_message_handler::MobileMessageObserver,
- public protocol_handler::ProtocolHandler {
- public:
- virtual void AddProtocolObserver(protocol_handler::ProtocolObserver* observer) {}
-
- virtual void RemoveProtocolObserver(protocol_handler::ProtocolObserver* observer) {}
-
- /**
- * \brief Sets pointer for Connection Handler layer for managing sessions
- * \param observer Pointer to object of the class implementing
- * ISessionObserver
- */
- virtual void set_session_observer(protocol_handler::SessionObserver* observer) {}
-
- /**
- * \brief Method for sending message to Mobile Application.
- * \param message RawMessage with params to be sent to Mobile App.
- */
- void SendMessageToMobileApp(const protocol_handler::RawMessagePtr& message) {}
-
- void SendFramesNumber(int connection_key, int number_of_frames) {}
-
- MobileMessageHandlerTester()
- : mmh_(NULL) {
- }
-
- bool init(const MobileMessage& message) {
- message_ = message;
- mmh_ = mobile_message_handler::MobileMessageHandlerImpl::instance();
- DCHECK(mmh_ != NULL);
-
- return true;
- }
-
- void OnMobileMessageReceived(const MobileMessage& message) {
- ASSERT_TRUE(message_->operator ==(*message));
-
- flag = true;
- cond_var.NotifyOne();
- }
-
- void sendMessageToMobileApp(const protocol_handler::RawMessagePtr message) {
- // mmh_->OnMessageReceived(message);//todo: YK uncoment sometime
- }
-
- private:
- mobile_message_handler::MobileMessageHandlerImpl* mmh_;
- MobileMessage message_;
-
- DISALLOW_COPY_AND_ASSIGN(MobileMessageHandlerTester);
-};
-
-/**
- * @class MobileMessageHandlerTestObserverThread
- */
-class MobileMessageHandlerTestObserverThread : public threads::ThreadDelegate {
- public:
- explicit MobileMessageHandlerTestObserverThread(const MobileMessage& message)
- : message_(message) {
- }
- ~MobileMessageHandlerTestObserverThread() {
- }
-
- void threadMain() {
- mobile_message_handler::MobileMessageHandlerImpl* mmh =
- mobile_message_handler::MobileMessageHandlerImpl::instance();
- DCHECK(mmh != NULL);
-
- mmh->SendMessageToMobileApp(message_);
- sync_primitives::AutoLock auto_lock(lock);
- cond_var.WaitFor(auto_lock, kTimeout * 1000);
- //ASSERT_TRUE(flag);
- }
-
- private:
- MobileMessage message_;
- DISALLOW_COPY_AND_ASSIGN(MobileMessageHandlerTestObserverThread);
-};
-
-//! ---------------------------------------------------------------------------
-
-TEST(mobile_message_handler_test, component_test) {
- // Example message
- MobileMessage message(new application_manager::Message);
- application_manager::BinaryData binary_data;
- binary_data.push_back('X');
- message->set_binary_data(&binary_data);
- message->set_connection_key(100);
- message->set_correlation_id(10);
- message->set_function_id(5);
- message->set_json_message("test json string!!!");
- message->set_message_type(application_manager::kRequest);
- message->set_protocol_version(application_manager::kV2);
-
- // Component initialization.
- MobileMessageHandlerTester observer;
- observer.init(message);
-
- mobile_message_handler::MobileMessageHandlerImpl* mmh =
- mobile_message_handler::MobileMessageHandlerImpl::instance();
- DCHECK(mmh != NULL);
- mmh->set_protocol_handler(&observer);
- mmh->AddMobileMessageListener(&observer);
-
- // Message processing
- threads::Thread* observer_thread = new threads::Thread(
- "MobileMessageHandler::MobileMessageHandlerTestObserverThread",
- new MobileMessageHandlerTestObserverThread(message));
-
- observer_thread->start();
- observer_thread->join();
-}
-} // namespace mobile_message_handler_test
-} // namespace components
-} // namespace test
-
-#endif // TEST_COMPONENTS_MOBILE_MESSAGE_HANDLER_INCLUDE_MOBILE_MESSAGE_HANDLER_MOBILE_MESSAGE_HANDLER_TEST_H_
diff --git a/test/components/mobile_message_handler/src/mobile_message_handler_test.cc b/test/components/mobile_message_handler/src/mobile_message_handler_test.cc
deleted file mode 100644
index 3ae77ca8f..000000000
--- a/test/components/mobile_message_handler/src/mobile_message_handler_test.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * \file mobile_message_handler_test.h
- * \brief MobileMessageHandler test header file.
-*
-* 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.
-*/
-
-#include "mobile_message_handler/mobile_message_handler_test.h"
diff --git a/test/components/protocol_handler/CMakeLists.txt b/test/components/protocol_handler/CMakeLists.txt
deleted file mode 100644
index 5c0dbbdcd..000000000
--- a/test/components/protocol_handler/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-include_directories(
- ${GMOCK_INCLUDE_DIRECTORY}
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ./include
- ${CMAKE_SOURCE_DIR}/src/components/protocol_handler/include
- ${SecurityManagerIncludeDir}
- ${CMAKE_SOURCE_DIR}/src/components/config_profile/include
-)
-
-set(LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- ProtocolHandler
- connectionHandler
- Utils
- ConfigProfile
- ${RTLIB}
- ProtocolLibrary
-)
-
-set(SOURCES
- src/protocol_handler_tm_test.cc
- src/incoming_data_handler_test.cc
- src/protocol_header_validator_test.cc
-)
-
-create_test(test_ProtocolHandler "${SOURCES}" "${LIBRARIES}")
-add_library(test_ProtocolHandlerTest ${SOURCES})
diff --git a/test/components/protocol_handler/include/protocol_handler/incoming_data_handler_test.h b/test/components/protocol_handler/include/protocol_handler/incoming_data_handler_test.h
deleted file mode 100644
index 3906778d8..000000000
--- a/test/components/protocol_handler/include/protocol_handler/incoming_data_handler_test.h
+++ /dev/null
@@ -1,359 +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.
- */
-#ifndef TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_INCOMING_DATA_HANDLER_TEST_H_
-#define TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_INCOMING_DATA_HANDLER_TEST_H_
-#include <gtest/gtest.h>
-#include <vector>
-#include <list>
-
-#include "utils/macro.h"
-#include "protocol_handler/incoming_data_handler.h"
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-using namespace protocol_handler;
-
-class IncomingDataHandlerTest : public ::testing::Test {
- protected:
- void SetUp() OVERRIDE {
- data_handler.set_validator(&header_validator);
- uid1 = 0x1234560;
- data_handler.AddConnection(uid1);
- uid2 = 0x1234561;
- data_handler.AddConnection(uid2);
- uid_unknown = 0xFEFEFE;
- EXPECT_NE(uid1, uid_unknown);
- EXPECT_NE(uid2, uid_unknown);
- some_data_size = 4;
- some_data2_size = 512;
- some_data = new uint8_t[some_data_size];
- some_data2 = new uint8_t[some_data2_size];
- protov1_message_id = 0x0;
- some_message_id = 0xABCDEF0;
- some_session_id = 0xFEDCBA0;
- payload_bigger_mtu.resize(MAXIMUM_FRAME_DATA_SIZE + 1);
- }
- void TearDown() OVERRIDE {
- delete[] some_data;
- delete[] some_data2;
- }
- void ProcessData(transport_manager::ConnectionUID uid, const uint8_t *const data,
- const uint32_t data_size ) {
- actual_frames = data_handler.ProcessData(RawMessage(uid, 0, data, data_size),
- &result_code);
- }
-
- void AppendPacketToTMData(const ProtocolPacket& packet) {
- const RawMessagePtr msg = packet.serializePacket();
- EXPECT_TRUE(msg.valid());
- EXPECT_GT(msg->data_size(), 0u);
- tm_data.insert(tm_data.end(), msg->data(), msg->data() + msg->data_size());
- }
- void ProcessPacket(const ProtocolPacket& packet) {
- AppendPacketToTMData(packet);
- ProcessData(uid1, &tm_data[0], tm_data.size());
- tm_data.clear();
- }
-
- protocol_handler::ProtocolPacket::ProtocolHeaderValidator header_validator;
- protocol_handler::IncomingDataHandler data_handler;
- transport_manager::ConnectionUID uid1, uid2, uid_unknown;
- typedef std::list<ProtocolFramePtr> FrameList;
- FrameList actual_frames;
- RESULT_CODE result_code;
- uint8_t* some_data, *some_data2;
- size_t some_data_size, some_data2_size;
- uint32_t protov1_message_id;
- uint32_t some_message_id;
- uint32_t some_session_id;
- std::vector<uint8_t> tm_data;
- std::vector<uint8_t> payload_bigger_mtu;
-};
-
-TEST_F(IncomingDataHandlerTest, NullData) {
- ProcessData(uid1, NULL, 0);
- EXPECT_EQ(RESULT_FAIL, result_code);
- EXPECT_TRUE(actual_frames.empty());
-
- ProcessData(uid2, NULL, 1);
- EXPECT_EQ(RESULT_FAIL, result_code);
- EXPECT_TRUE(actual_frames.empty());
-
- uint8_t invalide_data[] = {0, 1, 2, 3, 4};
- ProcessData(uid_unknown, invalide_data, 0);
- EXPECT_EQ(RESULT_FAIL, result_code);
- EXPECT_TRUE(actual_frames.empty());
-}
-
-TEST_F(IncomingDataHandlerTest, DataForUnknownConnection) {
- actual_frames = data_handler.ProcessData(RawMessage(uid_unknown, 0, NULL, 0),
- &result_code);
- EXPECT_EQ(RESULT_FAIL, result_code);
- EXPECT_TRUE(actual_frames.empty());
-
- AppendPacketToTMData(ProtocolPacket());
- actual_frames = data_handler.ProcessData(RawMessage(uid_unknown, 0, tm_data.data(), tm_data.size()),
- &result_code);
- EXPECT_EQ(RESULT_FAIL, result_code);
- EXPECT_TRUE(actual_frames.empty());
-}
-
-TEST_F(IncomingDataHandlerTest, Heartbeat_per_byte) {
- const ProtocolPacket hb_packet(uid1, PROTOCOL_VERSION_1, PROTECTION_OFF, FRAME_TYPE_CONTROL,
- kControl, FRAME_DATA_HEART_BEAT, some_session_id, 0u,
- protov1_message_id, NULL);
- const size_t hb_count = 100;
- for (size_t i = 0; i < hb_count; ++i) {
- AppendPacketToTMData(hb_packet);
- // Send per 1 byte (except last byte)
- for (size_t i = 0; i < tm_data.size() - 1; ++i) {
- ProcessData(uid1, &tm_data[i] , 1);
- EXPECT_EQ(RESULT_OK, result_code);
- EXPECT_TRUE(actual_frames.empty());
- }
- ProcessData(uid1, &*(tm_data.end()-1), 1);
- EXPECT_EQ(RESULT_OK, result_code);
- EXPECT_EQ(1u, actual_frames.size());
- EXPECT_EQ(hb_packet, **actual_frames.begin());
- tm_data.clear();
- }
-}
-
-TEST_F(IncomingDataHandlerTest, Heartbeat_pack) {
- const ProtocolPacket hb_packet(uid1, PROTOCOL_VERSION_2, PROTECTION_OFF, FRAME_TYPE_CONTROL,
- kControl, FRAME_DATA_HEART_BEAT, some_session_id, 0u,
- some_message_id, NULL);
- const size_t hb_count = 100;
- for (size_t i = 0u; i < hb_count; ++i) {
- AppendPacketToTMData(hb_packet);
- }
- ProcessData(uid1, &tm_data[0], tm_data.size());
- EXPECT_EQ(RESULT_OK, result_code);
- EXPECT_EQ(hb_count, actual_frames.size());
- for (FrameList::iterator it = actual_frames.begin(); it != actual_frames.end(); ++it) {
- EXPECT_EQ(hb_packet, **it);
- }
-}
-
-TEST_F(IncomingDataHandlerTest, MixedPayloadData_TwoConnections) {
- FrameList mobile_packets;
- // single packet RPC
- mobile_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_1, PROTECTION_OFF, FRAME_TYPE_SINGLE,
- kRpc, FRAME_DATA_SINGLE, some_session_id, some_data_size,
- protov1_message_id, some_data));
- // consecutive packet Audio
- mobile_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_2, PROTECTION_ON, FRAME_TYPE_CONSECUTIVE,
- kAudio, FRAME_DATA_LAST_CONSECUTIVE, ++some_session_id, some_data2_size,
- some_message_id, some_data2));
- // single packet Nav
- mobile_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_SINGLE,
- kMobileNav, FRAME_DATA_SINGLE, ++some_session_id, some_data_size,
- ++some_message_id, some_data));
- // consecutive packet Bulk
- mobile_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_CONSECUTIVE,
- kBulk, FRAME_DATA_LAST_CONSECUTIVE, ++some_session_id, some_data2_size,
- ++some_message_id, some_data2));
- for (FrameList::iterator it = mobile_packets.begin(); it != mobile_packets.end(); ++it) {
- AppendPacketToTMData(**it);
- }
- ProcessData(uid1, &tm_data[0], tm_data.size());
- EXPECT_EQ(RESULT_OK, result_code);
- EXPECT_EQ(actual_frames.size(), mobile_packets.size());
- FrameList::const_iterator it2 = mobile_packets.begin();
- for (FrameList::const_iterator it = actual_frames.begin(); it != actual_frames.end();
- ++it, ++it2) {
- // TODO(EZamakhov): investigate valgrind warning (unitialized value)
- EXPECT_EQ(**it, **it2);
- }
-}
-
-// TODO(EZamakhov): add validator abstraction and replace next test with check only return frames
-
-// Protocol version shall be from 1 to 3
-TEST_F(IncomingDataHandlerTest, MalformedPacket_Version) {
- FrameList malformed_packets;
- std::vector<uint8_t> malformed_versions;
- malformed_versions.push_back(0);
- for (uint8_t version = PROTOCOL_VERSION_3 + 1; version <= PROTOCOL_VERSION_MAX; ++version) {
- malformed_versions.push_back(version);
- }
- for (size_t i = 0; i < malformed_versions.size(); ++i) {
- malformed_packets.push_back(
- new ProtocolPacket(
- uid1, malformed_versions[i], PROTECTION_OFF, FRAME_TYPE_CONTROL, kControl,
- FRAME_DATA_HEART_BEAT, some_session_id, 0u, some_message_id, NULL));
- }
- for (FrameList::iterator it = malformed_packets.begin(); it != malformed_packets.end(); ++it) {
- ProcessPacket(**it);
- EXPECT_EQ(RESULT_FAIL, result_code)
- << "Malformed vesion " << static_cast<int>((*it)->protocol_version());
- // All malformed messages shall be ignored
- EXPECT_EQ(0u, actual_frames.size());
- }
-}
-
-// ServiceType shall be equal 0x0 (Control), 0x07 (RPC), 0x0A (PCM), 0x0B (Video), 0x0F (Bulk)
-TEST_F(IncomingDataHandlerTest, MalformedPacket_ServiceType) {
- FrameList malformed_packets;
- std::vector<uint8_t> malformed_serv_types;
- for (uint8_t service_type = kControl + 1; service_type < kRpc; ++service_type) {
- malformed_serv_types.push_back(service_type);
- }
- malformed_serv_types.push_back(0x08);
- malformed_serv_types.push_back(0x09);
- malformed_serv_types.push_back(0x0C);
- malformed_serv_types.push_back(0x0D);
- malformed_serv_types.push_back(0x0E);
- for (size_t i = 0; i < malformed_serv_types.size(); ++i) {
- malformed_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_CONTROL,
- malformed_serv_types[i], FRAME_DATA_HEART_BEAT, some_session_id, 0u,
- some_message_id, NULL));
- }
- for (FrameList::iterator it = malformed_packets.begin(); it != malformed_packets.end(); ++it) {
- ProcessPacket(**it);
- EXPECT_EQ(RESULT_FAIL, result_code)
- << "Malformed service type " << static_cast<int>((*it)->service_type());
- // All malformed messages shall be ignored
- EXPECT_EQ(0u, actual_frames.size());
- }
-}
-
-// Frame type shall be 0x00 (Control), 0x01 (Single), 0x02 (First), 0x03 (Consecutive)
-TEST_F(IncomingDataHandlerTest, MalformedPacket_FrameType) {
- FrameList malformed_packets;
- std::vector<uint8_t> malformed_frame_types;
- for (uint8_t frame_type = FRAME_TYPE_CONSECUTIVE + 1;
- frame_type <= FRAME_TYPE_MAX_VALUE; ++frame_type) {
- malformed_frame_types.push_back(frame_type);
- }
- for (size_t i = 0; i < malformed_frame_types.size(); ++i) {
- malformed_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_3, PROTECTION_OFF, malformed_frame_types[i],
- kControl, FRAME_DATA_HEART_BEAT, some_session_id, 0u, some_message_id, NULL));
- }
- for (FrameList::iterator it = malformed_packets.begin(); it != malformed_packets.end(); ++it) {
- ProcessPacket(**it);
- EXPECT_EQ(RESULT_FAIL, result_code)
- << "Malformed frame type " << static_cast<int>((*it)->service_type());
- // All malformed messages shall be ignored
- EXPECT_EQ(0u, actual_frames.size());
- }
-}
-
-// For Control frames Frame info value shall be from 0x00 to 0x06 or 0xFE(Data Ack), 0xFF(HB Ack)
-TEST_F(IncomingDataHandlerTest, MalformedPacket_ControlFrame) {
- FrameList malformed_packets;
- std::vector<uint8_t> malformed_frame_data;
- for (uint8_t frame_type = FRAME_DATA_END_SERVICE_NACK + 1;
- frame_type < FRAME_DATA_SERVICE_DATA_ACK; ++frame_type) {
- malformed_frame_data.push_back(frame_type);
- }
- for (size_t i = 0; i < malformed_frame_data.size(); ++i) {
- malformed_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_CONTROL, kControl,
- malformed_frame_data[i], some_session_id, 0u, some_message_id, NULL));
- }
- for (FrameList::iterator it = malformed_packets.begin(); it != malformed_packets.end(); ++it) {
- ProcessPacket(**it);
- EXPECT_EQ(RESULT_FAIL, result_code)
- << "Malformed Control frame with data " << static_cast<int>((*it)->frame_data());
- // All malformed messages shall be ignored
- EXPECT_EQ(0u, actual_frames.size());
- }
-}
-// For Single and First frames Frame info value shall be equal 0x00
-TEST_F(IncomingDataHandlerTest, MalformedPacket_SingleFrame) {
- FrameList malformed_packets;
- std::vector<uint8_t> malformed_frame_data;
- for (uint8_t frame_type = FRAME_DATA_SINGLE + 1;
- frame_type < FRAME_DATA_MAX_VALUE; ++frame_type) {
- malformed_frame_data.push_back(frame_type);
- }
- malformed_frame_data.push_back(FRAME_DATA_MAX_VALUE);
- for (size_t i = 0; i < malformed_frame_data.size(); ++i) {
- malformed_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE, kControl,
- malformed_frame_data[i], some_session_id, 0u, some_message_id, NULL));
- }
- for (FrameList::iterator it = malformed_packets.begin(); it != malformed_packets.end(); ++it) {
- ProcessPacket(**it);
- EXPECT_EQ(RESULT_FAIL, result_code)
- << "Malformed Single frame with data " << static_cast<int>((*it)->frame_data());
- // All malformed messages shall be ignored
- EXPECT_EQ(0u, actual_frames.size());
- }
-}
-
-// For Single and First frames Frame info value shall be equal 0x00
-TEST_F(IncomingDataHandlerTest, MalformedPacket_FirstFrame) {
- FrameList malformed_packets;
- std::vector<uint8_t> malformed_frame_data;
- for (uint8_t frame_type = FRAME_DATA_FIRST + 1;
- frame_type < FRAME_DATA_MAX_VALUE; ++frame_type) {
- malformed_frame_data.push_back(frame_type);
- }
- malformed_frame_data.push_back(FRAME_DATA_MAX_VALUE);
- for (size_t i = 0; i < malformed_frame_data.size(); ++i) {
- malformed_packets.push_back(
- new ProtocolPacket(
- uid1, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE, kControl,
- malformed_frame_data[i], some_session_id, 0u, some_message_id, NULL));
- }
- for (FrameList::iterator it = malformed_packets.begin(); it != malformed_packets.end(); ++it) {
- ProcessPacket(**it);
- EXPECT_EQ(RESULT_FAIL, result_code)
- << "Malformed First frame with data " << static_cast<int>((*it)->frame_data());
- // All malformed messages shall be ignored
- EXPECT_EQ(0u, actual_frames.size());
- }
-}
-
-// TODO(EZamakhov): add correctness on handling 2+ connection data
-
-} // namespace protocol_handler_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_INCOMING_DATA_HANDLER_TEST_H_
diff --git a/test/components/protocol_handler/include/protocol_handler/protocol_handler_mock.h b/test/components/protocol_handler/include/protocol_handler/protocol_handler_mock.h
deleted file mode 100644
index 6401c2185..000000000
--- a/test/components/protocol_handler/include/protocol_handler/protocol_handler_mock.h
+++ /dev/null
@@ -1,169 +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.
- */
-#ifndef TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_MOCK_H_
-#define TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_MOCK_H_
-
-#include "transport_manager/transport_manager.h"
-#include "transport_manager/transport_adapter/transport_adapter_event.h"
-#include "transport_manager/transport_manager_listener.h"
-
-#include "protocol_handler/session_observer.h"
-#include "protocol_handler/protocol_packet.h"
-#ifdef ENABLE_SECURITY
-#include "security_manager/security_manager.h"
-#include "security_manager/security_manager_mock.h"
-#endif // ENABLE_SECURITY
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-
-using namespace protocol_handler;
-using namespace transport_manager;
-
-/*
- * MOCK implementation of transport_manager::TransportManager interface
- */
-class TransportManagerMock: public TransportManager{
- public:
- MOCK_METHOD0(Init,
- int());
- MOCK_METHOD0(SearchDevices,
- int());
- MOCK_METHOD1(ConnectDevice,
- int(const DeviceHandle&));
- MOCK_METHOD1(DisconnectDevice,
- int(const DeviceHandle&));
- MOCK_METHOD1(Disconnect,
- int(const ConnectionUID &));
- MOCK_METHOD1(DisconnectForce,
- int(const ConnectionUID &));
- MOCK_METHOD1(SendMessageToDevice,
- int(const ::protocol_handler::RawMessagePtr));
- MOCK_METHOD1(ReceiveEventFromDevice,
- int(const TransportAdapterEvent&));
- MOCK_METHOD1(AddTransportAdapter,
- int(transport_adapter::TransportAdapter *));
- MOCK_METHOD1(AddEventListener,
- int(TransportManagerListener *));
- MOCK_METHOD0(Stop,
- int());
- MOCK_METHOD1(RemoveDevice,
- int(const DeviceHandle& ));
- MOCK_CONST_METHOD1(Visibility,
- int(const bool &));
-};
-
-/*
- * MOCK implementation of protocol_handler::SessionObserver interface
- */
-class SessionObserverMock: public protocol_handler::SessionObserver {
- public:
-#ifdef ENABLE_SECURITY
- MOCK_METHOD2(SetSSLContext,
- int (const uint32_t& key,
- security_manager::SSLContext* context));
- MOCK_METHOD2(GetSSLContext,
- security_manager::SSLContext* (
- const uint32_t& key,
- const protocol_handler::ServiceType& service_type));
-#endif // ENABLE_SECURITY
- MOCK_METHOD2(SetProtectionFlag,
- void(
- const uint32_t& key,
- const protocol_handler::ServiceType& service_type));
- MOCK_METHOD4(OnSessionStartedCallback,
- uint32_t(
- const transport_manager::ConnectionUID& connection_handle,
- const uint8_t session_id,
- const protocol_handler::ServiceType& service_type,
- const bool is_protected, uint32_t* hash_id));
- MOCK_METHOD4(OnSessionEndedCallback,
- uint32_t(
- const transport_manager::ConnectionUID& connection_handle,
- const uint8_t sessionId,
- const uint32_t& hashCode,
- const protocol_handler::ServiceType& service_type));
- MOCK_METHOD1(OnApplicationFloodCallBack,
- void(const uint32_t&));
- MOCK_METHOD2(KeyFromPair,
- uint32_t(
- transport_manager::ConnectionUID connection_handle,
- uint8_t sessionId));
- MOCK_METHOD3(PairFromKey,
- void(
- uint32_t key,
- transport_manager::ConnectionUID* connection_handle,
- uint8_t* sessionId));
- MOCK_METHOD4(GetDataOnSessionKey,
- int32_t(uint32_t key,
- uint32_t* app_id,
- std::list<int32_t>* sessions_list,
- uint32_t* device_id));
- MOCK_METHOD4(GetDataOnDeviceID,
- int32_t(
- uint32_t device_handle,
- std::string* device_name,
- std::list<uint32_t>* applications_list,
- std::string* mac_address));
- MOCK_METHOD2(IsHeartBeatSupported,
- bool( transport_manager::ConnectionUID connection_handle,
- uint8_t session_id));
- MOCK_METHOD3(ProtocolVersionUsed,
- bool(uint32_t connection_id, uint8_t session_id,
- uint8_t& protocol_version));
-};
-
-#ifdef ENABLE_SECURITY
-using test::components::security_manager_test::SSLContextMock;
-/*
- * MOCK implementation of security_manager::SecurityManager
- */
-class SecurityManagerMock: public security_manager::SecurityManager {
- public:
- MOCK_METHOD1(AddListener,
- void(security_manager::SecurityManagerListener *));
- MOCK_METHOD1(CreateSSLContext,
- security_manager::SSLContext*(const uint32_t &));
- MOCK_METHOD1(StartHandshake,
- void(uint32_t));
- MOCK_METHOD4(SendInternalError,
- void(const uint32_t ,
- const uint8_t&,
- const std::string&,
- const uint32_t ));
-};
-#endif // ENABLE_SECURITY
-} // namespace test
-} // namespace components
-} // namespace protocol_handler_test
-#endif // TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_MOCK_H_
diff --git a/test/components/protocol_handler/include/protocol_handler/protocol_handler_tm_test.h b/test/components/protocol_handler/include/protocol_handler/protocol_handler_tm_test.h
deleted file mode 100644
index 08f661b80..000000000
--- a/test/components/protocol_handler/include/protocol_handler/protocol_handler_tm_test.h
+++ /dev/null
@@ -1,759 +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.
- */
-#ifndef TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_TM_TEST_H_
-#define TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_TM_TEST_H_
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include <string>
-
-#include "utils/shared_ptr.h"
-
-#include "protocol_handler/protocol_handler_impl.h"
-#include "protocol/common.h"
-
-#include "protocol_handler/protocol_handler_mock.h"
-#include "protocol_handler/protocol_observer_mock.h"
-#include "protocol_handler/session_observer_mock.h"
-#include "protocol_handler/control_message_matcher.h"
-#include "security_manager/security_manager_mock.h"
-#include "security_manager/ssl_context_mock.h"
-#include "transport_manager/transport_manager_mock.h"
-#include "protocol_handler/control_message_matcher.h"
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-
-// id passed as NULL for new session establishing
-#define NEW_SESSION_ID 0u
-#define SESSION_START_REJECT 0u
-
-using namespace ::protocol_handler;
-using namespace ::transport_manager; // For TM states
-//using namespace ::security_manager;
-using ::transport_manager::TransportManagerListener;
-using protocol_handler_test::ControlMessage;
-using ::testing::Return;
-using ::testing::ReturnNull;
-using ::testing::AnyOf;
-using ::testing::Ge;
-using ::testing::Le;
-using ::testing::_;
-using ::testing::Invoke;
-
-class ProtocolHandlerImplTest : public ::testing::Test {
- protected:
- void IntitProtocolHandlerImpl(const size_t period_msec, const size_t max_messages) {
- protocol_handler_impl.reset(new ProtocolHandlerImpl(&transport_manager_mock,
- period_msec, max_messages));
- protocol_handler_impl->set_session_observer(&session_observer_mock);
- tm_listener = protocol_handler_impl.get();
- }
- void SetUp() OVERRIDE {
- IntitProtocolHandlerImpl(0u, 0u);
- connection_id = 0xAu;
- session_id = 0xFFu;
- connection_key = 0xFF00AAu;
- message_id = 0xABCDEFu;
- some_date.resize(256, 0xAB);
-
- // expect ConnectionHandler support methods call (conversion, check heartbeat)
- EXPECT_CALL(session_observer_mock,
- KeyFromPair(connection_id, _)).
- //return some connection_key
- WillRepeatedly(Return(connection_key));
- EXPECT_CALL(session_observer_mock,
- IsHeartBeatSupported(connection_id, _)).
- //return false to avoid call KeepConnectionAlive
- WillRepeatedly(Return(false));
- }
-
- void TearDown() OVERRIDE {
- // Wait call methods in thread
- usleep(100000);
- }
-
- // Emulate connection establish
- void AddConnection() {
- tm_listener->OnConnectionEstablished(
- DeviceInfo(DeviceHandle(1u),
- std::string("mac"),
- std::string("name"),
- std::string("BTMAC")),
- connection_id);
- }
- void AddSession() {
- AddConnection();
- const ServiceType start_service = kRpc;
- #ifdef ENABLE_SECURITY
- // For enabled protection callback shall use protection ON
- const bool callback_protection_flag = PROTECTION_ON;
- #else
- // For disabled protection callback shall ignore protection income flad and use protection OFF
- const bool callback_protection_flag = PROTECTION_OFF;
- #endif // ENABLE_SECURITY
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service,
- callback_protection_flag, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // expect send Ack with PROTECTION_OFF (on no Security Manager)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- }
-
-#ifdef ENABLE_SECURITY
- // Emulate security manager initilization establish
- void AddSecurityManager() {
- protocol_handler_impl->set_security_manager(&security_manager_mock);
- }
-#endif // ENABLE_SECURITY
- void SendTMMessage(uint8_t connection_id,
- uint8_t version, bool protection, uint8_t frameType,
- uint8_t serviceType, uint8_t frameData,
- uint8_t sessionId, uint32_t dataSize,
- uint32_t messageID, const uint8_t *data = 0) {
- // Create packet
- const ProtocolPacket packet(
- connection_id, version, protection, frameType,
- serviceType, frameData, sessionId, dataSize,
- messageID, data);
- // Emulate resive packet from transoprt manager
- tm_listener->OnTMMessageReceived(packet.serializePacket());
- }
- void SendControlMessage(bool protection, uint8_t service_type,
- uint8_t sessionId, uint32_t frame_data,
- uint32_t dataSize = 0u, const uint8_t *data = NULL) {
- SendTMMessage(connection_id, PROTOCOL_VERSION_3, protection, FRAME_TYPE_CONTROL,
- service_type, frame_data, sessionId, dataSize, message_id, data);
- }
-
- ::utils::SharedPtr<ProtocolHandlerImpl> protocol_handler_impl;
- TransportManagerListener* tm_listener;
- // Uniq connection
- ::transport_manager::ConnectionUID connection_id;
- // id of established session
- uint8_t session_id;
- // uniq id as connection_id and session_id in one
- uint32_t connection_key;
- uint32_t message_id;
- std::vector<uint8_t> some_date;
- // Strict mocks (same as all methods EXPECT_CALL().Times(0))
- testing::StrictMock<transport_manager_test::TransportManagerMock> transport_manager_mock;
- testing::StrictMock<protocol_handler_test::SessionObserverMock> session_observer_mock;
-#ifdef ENABLE_SECURITY
- testing::NiceMock<security_manager_test::SecurityManagerMock> security_manager_mock;
- testing::NiceMock<security_manager_test::SSLContextMock> ssl_context_mock;
-#endif // ENABLE_SECURITY
-};
-
-#ifdef ENABLE_SECURITY
-class OnHandshakeDoneFunctor {
-public:
- OnHandshakeDoneFunctor(const uint32_t connection_key, const bool result)
- : connection_key(connection_key), result(result) {}
- void operator()(security_manager::SecurityManagerListener * listener) const {
- listener->OnHandshakeDone(connection_key, result);
- }
-private:
- const uint32_t connection_key;
- const bool result;
-};
-#endif // ENABLE_SECURITY
-
-/*
- * ProtocolHandler shall skip empty message
- */
-TEST_F(ProtocolHandlerImplTest, RecieveEmptyRawMessage) {
- tm_listener->OnTMMessageReceived(RawMessagePtr());
-}
-/*
- * ProtocolHandler shall disconnect on no connection
- */
-TEST_F(ProtocolHandlerImplTest, RecieveOnUnknownConenction) {
- // expect force dicsonnect on no connection for received data
- EXPECT_CALL(transport_manager_mock,
- DisconnectForce(connection_id)).
- WillOnce(Return(E_SUCCESS));
-
- SendTMMessage(connection_id, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_CONTROL,
- kRpc, FRAME_DATA_START_SERVICE, NEW_SESSION_ID, 0, message_id);
-}
-/*
- * ProtocolHandler shall send NAck on session_observer rejection
- * Check protection flag OFF for all services from kControl to kBulk
- */
-TEST_F(ProtocolHandlerImplTest, StartSession_Unprotected_SessionObserverReject) {
- const int call_times = 5;
- AddConnection();
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, AnyOf(kControl, kRpc, kAudio,
- kMobileNav, kBulk), PROTECTION_OFF, _)).
- Times(call_times).
- //return sessions start rejection
- WillRepeatedly(Return(SESSION_START_REJECT));
-
- // expect send NAck
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, PROTECTION_OFF))).
- Times(call_times).
- WillRepeatedly(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_OFF, kControl, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_OFF, kRpc, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_OFF, kAudio, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_OFF, kMobileNav,NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_OFF, kBulk, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send NAck on session_observer rejection
- * Emulate getting PROTECTION_ON and check protection flag OFF in NAck
- * For ENABLE_SECURITY=OFF session_observer shall be called with protection flag OFF
- */
-TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) {
- const int call_times = 5;
- AddConnection();
-#ifdef ENABLE_SECURITY
- // For enabled protection callback shall use protection ON
- const bool callback_protection_flag = PROTECTION_ON;
-#else
- // For disabled protection callback shall ignore protection income flad and use protection OFF
- const bool callback_protection_flag = PROTECTION_OFF;
-#endif // ENABLE_SECURITY
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(
- connection_id, NEW_SESSION_ID, AnyOf(kControl, kRpc, kAudio,
- kMobileNav, kBulk), callback_protection_flag, _)).
- Times(call_times).
- //return sessions start rejection
- WillRepeatedly(Return(SESSION_START_REJECT));
-
- // expect send NAck with encryption OFF
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, PROTECTION_OFF))).
- Times(call_times).
- WillRepeatedly(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, kControl, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_ON, kRpc, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_ON, kAudio, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_ON, kMobileNav,NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
- SendControlMessage(PROTECTION_ON, kBulk, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack on session_observer accept
- * Check protection flag OFF
- */
-TEST_F(ProtocolHandlerImplTest, StartSession_Unprotected_SessionObserverAccept) {
- AddConnection();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_OFF, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // expect send Ack
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack on session_observer accept
- * Emulate getting PROTECTION_ON and check protection flag OFF in Ack
- * For ENABLE_SECURITY=OFF session_observer shall be called with protection flag OFF
- */
-TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverAccept) {
- AddSession();
-}
-// TODO(EZamakhov): add test for get_hash_id/set_hash_id from protocol_handler_impl.cc
-/*
- * ProtocolHandler shall send NAck on session_observer rejection
- */
-TEST_F(ProtocolHandlerImplTest, EndSession_SessionObserverReject) {
- AddSession();
- const ServiceType service = kRpc;
-
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionEndedCallback(connection_id, session_id, _, service)).
- // reject session start
- WillOnce(Return(SESSION_START_REJECT));
-
- // expect send NAck
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_END_SERVICE_NACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_OFF, service, session_id, FRAME_DATA_END_SERVICE);
-}
-/*
- * ProtocolHandler shall send NAck on wrong hash code
- */
-TEST_F(ProtocolHandlerImplTest, EndSession_Success) {
- AddSession();
- const ServiceType service = kRpc;
-
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionEndedCallback(connection_id, session_id, _, service)).
- // return sessions start success
- WillOnce(Return(connection_key));
-
- // expect send Ack
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_END_SERVICE_ACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_OFF, service, session_id, FRAME_DATA_END_SERVICE);
-}
-
-#ifdef ENABLE_SECURITY
-/*
- * ProtocolHandler shall not call Security logics with Protocol version 1
- * Check session_observer with PROTECTION_OFF and Ack with PROTECTION_OFF
- */
-TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) {
- AddConnection();
- // Add security manager
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_OFF, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // expect send Ack with PROTECTION_OFF (on no Security Manager)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendTMMessage(connection_id, PROTOCOL_VERSION_1, PROTECTION_ON, FRAME_TYPE_CONTROL,
- start_service, FRAME_DATA_START_SERVICE, NEW_SESSION_ID, 0, message_id);
-}
-/*
- * ProtocolHandler shall not call Security logics on start session with PROTECTION_OFF
- */
-TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) {
- AddConnection();
- // Add security manager
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_OFF, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // expect send Ack with PROTECTION_OFF (on no Security Manager)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack with PROTECTION_OFF on fail SLL creation
- */
-TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) {
- AddConnection();
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // expect start protection for unprotected session
- EXPECT_CALL(security_manager_mock,
- CreateSSLContext(connection_key)).
- //return fail protection
- WillOnce(ReturnNull());
-
- // expect send Ack with PROTECTION_OFF (on fail SLL creation)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack with PROTECTION_ON on already established and initialized SLLContext
- */
-TEST_F(ProtocolHandlerImplTest,SecurityEnable_StartSessionProtected_SSLInitialized) {
- AddConnection();
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // call new SSLContext creation
- EXPECT_CALL(security_manager_mock,
- CreateSSLContext(connection_key)).
- //return new SSLContext
- WillOnce(Return(&ssl_context_mock));
-
- // initilization check
- EXPECT_CALL(ssl_context_mock,
- IsInitCompleted()).
- //emulate SSL is initilized
- WillOnce(Return(true));
-
- // Expect service protection enable
- EXPECT_CALL(session_observer_mock,
- SetProtectionFlag(connection_key, start_service));
-
- // expect send Ack with PROTECTION_ON (on SSL is initilized)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack with PROTECTION_OFF on session handshhake fail
- */
-TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_HandshakeFail) {
- AddConnection();
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // call new SSLContext creation
- EXPECT_CALL(security_manager_mock,
- CreateSSLContext(connection_key)).
- //return new SSLContext
- WillOnce(Return(&ssl_context_mock));
-
- // initilization check
- EXPECT_CALL(ssl_context_mock,
- IsInitCompleted()).
- //emulate SSL is not initilized
- WillOnce(Return(false));
-
- // Pending handshake check
- EXPECT_CALL(ssl_context_mock,
- IsHandshakePending()).
- //emulate is pending
- WillOnce(Return(true));
-
- // expect add listener for handshake result
- EXPECT_CALL(security_manager_mock,
- AddListener(_))
- // emulate handshake fail
- .WillOnce(Invoke(OnHandshakeDoneFunctor(connection_key, PROTECTION_OFF)));
-
- // Listener check SSLContext
- EXPECT_CALL(session_observer_mock,
- GetSSLContext(connection_key, start_service)).
- // emulate protection for service is not enabled
- WillOnce(ReturnNull());
-
- // expect send Ack with PROTECTION_OFF (on fail handshake)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack with PROTECTION_ON on session handshhake success
- */
-TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_HandshakeSuccess) {
- AddConnection();
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // call new SSLContext creation
- EXPECT_CALL(security_manager_mock,
- CreateSSLContext(connection_key)).
- //return new SSLContext
- WillOnce(Return(&ssl_context_mock));
-
- // initilization check
- EXPECT_CALL(ssl_context_mock,
- IsInitCompleted()).
- //emulate SSL is not initilized
- WillOnce(Return(false));
-
- // Pending handshake check
- EXPECT_CALL(ssl_context_mock,
- IsHandshakePending()).
- //emulate is pending
- WillOnce(Return(true));
-
- // expect add listener for handshake result
- EXPECT_CALL(security_manager_mock,
- AddListener(_))
- // emulate handshake fail
- .WillOnce(Invoke(OnHandshakeDoneFunctor(connection_key, PROTECTION_ON)));
-
- // Listener check SSLContext
- EXPECT_CALL(session_observer_mock,
- GetSSLContext(connection_key, start_service)).
- // emulate protection for service is not enabled
- WillOnce(ReturnNull());
-
- // Expect service protection enable
- EXPECT_CALL(session_observer_mock,
- SetProtectionFlag(connection_key, start_service));
-
- // expect send Ack with PROTECTION_OFF (on fail handshake)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack with PROTECTION_ON on session handshhake success
- */
-TEST_F(ProtocolHandlerImplTest,
- SecurityEnable_StartSessionProtected_HandshakeSuccess_ServiceProtectedBefore) {
- AddConnection();
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // call new SSLContext creation
- EXPECT_CALL(security_manager_mock,
- CreateSSLContext(connection_key)).
- //return new SSLContext
- WillOnce(Return(&ssl_context_mock));
-
- // initilization check
- EXPECT_CALL(ssl_context_mock,
- IsInitCompleted()).
- //emulate SSL is not initilized
- WillOnce(Return(false));
-
- // Pending handshake check
- EXPECT_CALL(ssl_context_mock,
- IsHandshakePending()).
- //emulate is pending
- WillOnce(Return(true));
-
- // expect add listener for handshake result
- EXPECT_CALL(security_manager_mock,
- AddListener(_))
- // emulate handshake fail
- .WillOnce(Invoke(OnHandshakeDoneFunctor(connection_key, PROTECTION_ON)));
-
- // Listener check SSLContext
- EXPECT_CALL(session_observer_mock,
- GetSSLContext(connection_key, start_service)).
- // emulate protection for service is not enabled
- WillOnce(ReturnNull());
-
- // Expect service protection enable
- EXPECT_CALL(session_observer_mock,
- SetProtectionFlag(connection_key, start_service));
-
- // expect send Ack with PROTECTION_OFF (on fail handshake)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-/*
- * ProtocolHandler shall send Ack with PROTECTION_ON on session handshhake success
- */
-TEST_F(ProtocolHandlerImplTest,
- SecurityEnable_StartSessionProtected_HandshakeSuccess_SSLIsNotPending) {
- AddConnection();
- AddSecurityManager();
- const ServiceType start_service = kRpc;
- // expect ConnectionHandler check
- EXPECT_CALL(session_observer_mock,
- OnSessionStartedCallback(connection_id, NEW_SESSION_ID, start_service, PROTECTION_ON, _)).
- //return sessions start success
- WillOnce(Return(session_id));
-
- // call new SSLContext creation
- EXPECT_CALL(security_manager_mock,
- CreateSSLContext(connection_key)).
- //return new SSLContext
- WillOnce(Return(&ssl_context_mock));
-
- // initilization check
- EXPECT_CALL(ssl_context_mock,
- IsInitCompleted()).
- //emulate SSL is not initilized
- WillOnce(Return(false));
-
- // Pending handshake check
- EXPECT_CALL(ssl_context_mock,
- IsHandshakePending()).
- //emulate is pending
- WillOnce(Return(false));
-
- // Wait restart handshake operation
- EXPECT_CALL(security_manager_mock,
- StartHandshake(connection_key));
-
- // expect add listener for handshake result
- EXPECT_CALL(security_manager_mock,
- AddListener(_))
- // emulate handshake fail
- .WillOnce(Invoke(OnHandshakeDoneFunctor(connection_key, PROTECTION_ON)));
-
- // Listener check SSLContext
- EXPECT_CALL(session_observer_mock,
- GetSSLContext(connection_key, start_service)).
- // emulate protection for service is not enabled
- WillOnce(ReturnNull());
-
- // Expect service protection enable
- EXPECT_CALL(session_observer_mock,
- SetProtectionFlag(connection_key, start_service));
-
- // expect send Ack with PROTECTION_OFF (on fail handshake)
- EXPECT_CALL(transport_manager_mock,
- SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))).
- WillOnce(Return(E_SUCCESS));
-
- SendControlMessage(PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE);
-}
-TEST_F(ProtocolHandlerImplTest,
- FloodVerification) {
- const size_t period_msec = 1000;
- const size_t max_messages = 1000;
- IntitProtocolHandlerImpl(period_msec, max_messages);
- AddConnection();
- AddSession();
-
- // expect flood notification to CH
- EXPECT_CALL(session_observer_mock,
- OnApplicationFloodCallBack(connection_key)).
- Times(1);
-
- for (size_t i = 0; i < max_messages + 1; ++i) {
- SendTMMessage(connection_id, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE,
- kControl, FRAME_DATA_SINGLE, session_id,
- some_date.size(), message_id, &some_date[0]);
- }
-}
-TEST_F(ProtocolHandlerImplTest,
- FloodVerification_ThresholdValue) {
- const size_t period_msec = 1000;
- const size_t max_messages = 1000;
- IntitProtocolHandlerImpl(period_msec, max_messages);
- AddConnection();
- AddSession();
-
- // expect NO flood notification to CH
- for (size_t i = 0; i < max_messages - 1; ++i) {
- SendTMMessage(connection_id, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE,
- kControl, FRAME_DATA_SINGLE, session_id,
- some_date.size(), message_id, &some_date[0]);
- }
-}
-TEST_F(ProtocolHandlerImplTest,
- FloodVerification_VideoFrameSkip) {
- const size_t period_msec = 1000;
- const size_t max_messages = 1000;
- IntitProtocolHandlerImpl(period_msec, max_messages);
- AddConnection();
- AddSession();
-
- // expect NO flood notification to CH on video data streaming
- for (size_t i = 0; i < max_messages + 1; ++i) {
- SendTMMessage(connection_id, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE,
- kMobileNav, FRAME_DATA_SINGLE, session_id,
- some_date.size(), message_id, &some_date[0]);
- }
-}
-TEST_F(ProtocolHandlerImplTest,
- FloodVerification_AudioFrameSkip) {
- const size_t period_msec = 1000;
- const size_t max_messages = 1000;
- IntitProtocolHandlerImpl(period_msec, max_messages);
- AddConnection();
- AddSession();
-
- // expect NO flood notification to CH on video data streaming
- for (size_t i = 0; i < max_messages + 1; ++i) {
- SendTMMessage(connection_id, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE,
- kAudio, FRAME_DATA_SINGLE, session_id,
- some_date.size(), message_id, &some_date[0]);
- }
-}
-TEST_F(ProtocolHandlerImplTest,
- FloodVerificationDisable) {
- const size_t period_msec = 0;
- const size_t max_messages = 0;
- IntitProtocolHandlerImpl(period_msec, max_messages);
- AddConnection();
- AddSession();
-
- // expect NO flood notification to session observer
- for (size_t i = 0; i < max_messages + 1; ++i) {
- SendTMMessage(connection_id, PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE,
- kControl, FRAME_DATA_SINGLE, session_id,
- some_date.size(), message_id, &some_date[0]);
- }
-}
-#endif // ENABLE_SECURITY
-} // namespace test
-} // namespace components
-} // namespace protocol_handler_test
-#endif //TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HANDLER_TM_TEST_H_
diff --git a/test/components/protocol_handler/include/protocol_handler/protocol_header_validator_test.h b/test/components/protocol_handler/include/protocol_handler/protocol_header_validator_test.h
deleted file mode 100644
index 91762c427..000000000
--- a/test/components/protocol_handler/include/protocol_handler/protocol_header_validator_test.h
+++ /dev/null
@@ -1,249 +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.
- */
-#ifndef TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HEADER_VALIDATOR_TEST_H_
-#define TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HEADER_VALIDATOR_TEST_H_
-#include <gtest/gtest.h>
-#include <vector>
-#include <list>
-
-#include "utils/macro.h"
-#include "protocol_handler/protocol_packet.h"
-
-namespace test {
-namespace components {
-namespace protocol_handler_test {
-using namespace ::protocol_handler;
-
-class ProtocolHeaderValidatorTest : public ::testing::Test {
- protected:
- void SetUp() OVERRIDE {
- some_message_id = 0xABCDEF0;
- some_session_id = 0xFEDCBA0;
- }
- ProtocolPacket::ProtocolHeaderValidator header_validator;
- uint32_t some_message_id;
- uint32_t some_session_id;
-};
-
-// Protocol version shall be from 1 to 3
-TEST_F(ProtocolHeaderValidatorTest, MaxPayloadSizeSetGet) {
- EXPECT_EQ(std::numeric_limits<size_t>::max(),
- header_validator.max_payload_size());
- for (size_t value = 0; value < MAXIMUM_FRAME_DATA_SIZE * 2; ++value) {
- header_validator.set_max_payload_size(value);
- EXPECT_EQ(value, header_validator.max_payload_size());
- }
-}
-
-// Protocol version shall be from 1 to 3
-TEST_F(ProtocolHeaderValidatorTest, Malformed_Version) {
- std::vector<uint8_t> malformed_versions;
- malformed_versions.push_back(0);
- for (uint8_t version = PROTOCOL_VERSION_3 + 1; version <= PROTOCOL_VERSION_MAX; ++version) {
- malformed_versions.push_back(version);
- }
-
- for (size_t i = 0; i < malformed_versions.size(); ++i) {
- const ProtocolPacket::ProtocolHeader malformed_message_header(
- malformed_versions[i], PROTECTION_OFF, FRAME_TYPE_CONTROL, kControl,
- FRAME_DATA_HEART_BEAT, some_session_id, 0u, some_message_id);
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(malformed_message_header))
- << "Malformed version " << malformed_message_header.version;
-
- }
-}
-
-// ServiceType shall be equal 0x0 (Control), 0x07 (RPC), 0x0A (PCM), 0x0B (Video), 0x0F (Bulk)
-TEST_F(ProtocolHeaderValidatorTest, Malformed_ServiceType) {
- std::vector<uint8_t> malformed_serv_types;
- for (uint8_t service_type = kControl + 1; service_type < kRpc; ++service_type) {
- malformed_serv_types.push_back(service_type);
- }
- malformed_serv_types.push_back(0x08);
- malformed_serv_types.push_back(0x09);
- malformed_serv_types.push_back(0x0C);
- malformed_serv_types.push_back(0x0D);
- malformed_serv_types.push_back(0x0E);
-
- for (size_t i = 0; i < malformed_serv_types.size(); ++i) {
- const ProtocolPacket::ProtocolHeader malformed_message_header(
- PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_CONTROL, malformed_serv_types[i],
- FRAME_DATA_HEART_BEAT, some_session_id, 0u, some_message_id);
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(malformed_message_header))
- << "Malformed service type " << malformed_message_header.serviceType;
- }
-}
-
-// Frame type shall be 0x00 (Control), 0x01 (Single), 0x02 (First), 0x03 (Consecutive)
-TEST_F(ProtocolHeaderValidatorTest, Malformed_FrameType) {
- std::vector<uint8_t> malformed_frame_types;
- for (uint8_t frame_type = FRAME_TYPE_CONSECUTIVE + 1;
- frame_type <= FRAME_TYPE_MAX_VALUE; ++frame_type) {
- malformed_frame_types.push_back(frame_type);
- }
- for (size_t i = 0; i < malformed_frame_types.size(); ++i) {
- const ProtocolPacket::ProtocolHeader malformed_message_header(
- PROTOCOL_VERSION_3, PROTECTION_OFF, malformed_frame_types[i],
- kControl, FRAME_DATA_HEART_BEAT, some_session_id, 0u, some_message_id);
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(malformed_message_header))
- << "Malformed frame type " << malformed_message_header.frameType;
- }
-}
-
-// For Control frames Frame info value shall be from 0x00 to 0x06 or 0xFE(Data Ack), 0xFF(HB Ack)
-TEST_F(ProtocolHeaderValidatorTest, Malformed_ControlFrame) {
- std::vector<uint8_t> malformed_frame_data;
- for (uint8_t frame_type = FRAME_DATA_END_SERVICE_NACK + 1;
- frame_type < FRAME_DATA_SERVICE_DATA_ACK; ++frame_type) {
- malformed_frame_data.push_back(frame_type);
- }
- for (size_t i = 0; i < malformed_frame_data.size(); ++i) {
- const ProtocolPacket::ProtocolHeader malformed_message_header(
- PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_CONTROL, kControl,
- malformed_frame_data[i], some_session_id, 0u, some_message_id);
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(malformed_message_header))
- << "Malformed Control frame with data " << malformed_message_header.frameData;
- }
-}
-// For Single and First frames Frame info value shall be equal 0x00
-TEST_F(ProtocolHeaderValidatorTest, Malformed_SingleFrame) {
- std::vector<uint8_t> malformed_frame_data;
- for (uint8_t frame_type = FRAME_DATA_SINGLE + 1;
- frame_type < FRAME_DATA_MAX_VALUE; ++frame_type) {
- malformed_frame_data.push_back(frame_type);
- }
- malformed_frame_data.push_back(FRAME_DATA_MAX_VALUE);
- for (size_t i = 0; i < malformed_frame_data.size(); ++i) {
- const ProtocolPacket::ProtocolHeader malformed_message_header(
- PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE, kControl,
- malformed_frame_data[i], some_session_id, 0u, some_message_id);
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(malformed_message_header))
- << "Malformed Single frame with data " << malformed_message_header.frameData;
- // All malformed messages shall be ignored
- }
-}
-
-// For Single and First frames Frame info value shall be equal 0x00
-TEST_F(ProtocolHeaderValidatorTest, Malformed_FirstFrame) {
- std::vector<uint8_t> malformed_frame_data;
- for (uint8_t frame_type = FRAME_DATA_FIRST + 1;
- frame_type < FRAME_DATA_MAX_VALUE; ++frame_type) {
- malformed_frame_data.push_back(frame_type);
- }
- malformed_frame_data.push_back(FRAME_DATA_MAX_VALUE);
- for (size_t i = 0; i < malformed_frame_data.size(); ++i) {
- const ProtocolPacket::ProtocolHeader malformed_message_header(
- PROTOCOL_VERSION_3, PROTECTION_OFF, FRAME_TYPE_SINGLE, kControl,
- malformed_frame_data[i], some_session_id, 0u, some_message_id);
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(malformed_message_header))
- << "Malformed First frame with data " << malformed_message_header.frameData;
- }
-}
-
-TEST_F(ProtocolHeaderValidatorTest, Malformed_ControlFrame_EmptyPayload) {
- const size_t payload_size = 0u;
- const ProtocolPacket::ProtocolHeader control_message_header(
- PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_CONTROL, kControl,
- FRAME_DATA_HEART_BEAT, some_session_id, payload_size, some_message_id);
- const ProtocolPacket::ProtocolHeader single_message_header(
- PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_SINGLE, kControl,
- FRAME_DATA_SINGLE, some_session_id, payload_size, some_message_id);
- const ProtocolPacket::ProtocolHeader consecutive_message_header(
- PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_CONSECUTIVE, kControl,
- FRAME_DATA_LAST_CONSECUTIVE, some_session_id, payload_size, some_message_id);
-
- for (uint32_t max_payload_size = 0; max_payload_size < MAXIMUM_FRAME_DATA_SIZE * 2;
- ++max_payload_size) {
- header_validator.set_max_payload_size(MAXIMUM_FRAME_DATA_SIZE + max_payload_size);
-
- // For Control frames Data Size value could be zero
- EXPECT_EQ(RESULT_OK, header_validator.validate(control_message_header));
- // For Control frames Data Size value could be zero
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(single_message_header));
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(consecutive_message_header));
- }
-}
-
-// For Control frames Data Size value shall be less than MTU header
-TEST_F(ProtocolHeaderValidatorTest, Malformed_Payload) {
- const size_t payload_size = MAXIMUM_FRAME_DATA_SIZE;
- const ProtocolPacket::ProtocolHeader control_message_header(
- PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_CONTROL, kControl,
- FRAME_DATA_HEART_BEAT, some_session_id, payload_size, some_message_id);
- const ProtocolPacket::ProtocolHeader single_message_header(
- PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_SINGLE, kControl,
- FRAME_DATA_SINGLE, some_session_id, payload_size, some_message_id);
- const ProtocolPacket::ProtocolHeader consecutive_message_header(
- PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_CONSECUTIVE, kControl,
- FRAME_DATA_LAST_CONSECUTIVE, some_session_id, payload_size, some_message_id);
-
- for (uint32_t max_payload_size = 0; max_payload_size < MAXIMUM_FRAME_DATA_SIZE;
- ++max_payload_size) {
- header_validator.set_max_payload_size(max_payload_size);
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(control_message_header));
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(single_message_header));
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(consecutive_message_header));
- }
-
- for (uint32_t max_payload_size = MAXIMUM_FRAME_DATA_SIZE + 1; max_payload_size < MAXIMUM_FRAME_DATA_SIZE * 2;
- ++max_payload_size) {
- header_validator.set_max_payload_size(max_payload_size);
- EXPECT_EQ(RESULT_OK, header_validator.validate(control_message_header));
- EXPECT_EQ(RESULT_OK, header_validator.validate(single_message_header));
- EXPECT_EQ(RESULT_OK, header_validator.validate(consecutive_message_header));
- }
-}
-
-// Message ID be equal or greater than 0x01
-TEST_F(ProtocolHeaderValidatorTest, Malformed_MessageID) {
- const uint32_t malformed_message_id = 0x0u;
- ProtocolPacket::ProtocolHeader message_header(
- PROTOCOL_VERSION_3, PROTECTION_ON, FRAME_TYPE_FIRST, kControl,
- FRAME_DATA_HEART_BEAT, some_session_id, 0u, malformed_message_id);
-
- message_header.frameType = FRAME_TYPE_FIRST;
- message_header.version = PROTOCOL_VERSION_1;
- EXPECT_EQ(RESULT_OK, header_validator.validate(message_header));
-
- message_header.version = PROTOCOL_VERSION_2;
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(message_header));
- message_header.version = PROTOCOL_VERSION_3;
- EXPECT_EQ(RESULT_FAIL, header_validator.validate(message_header));
-
- message_header.frameType = FRAME_TYPE_CONTROL;
- EXPECT_EQ(RESULT_OK, header_validator.validate(message_header));
-}
-
-} // namespace protocol_handler_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_PROTOCOL_HANDLER_INCLUDE_PROTOCOL_HANDLER_PROTOCOL_HEADER_VALIDATOR_TEST_H_
diff --git a/test/components/protocol_handler/src/incoming_data_handler_test.cc b/test/components/protocol_handler/src/incoming_data_handler_test.cc
deleted file mode 100644
index bb94c47c2..000000000
--- a/test/components/protocol_handler/src/incoming_data_handler_test.cc
+++ /dev/null
@@ -1,33 +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 "protocol_handler/incoming_data_handler_test.h"
diff --git a/test/components/protocol_handler/src/protocol_handler_tm_test.cc b/test/components/protocol_handler/src/protocol_handler_tm_test.cc
deleted file mode 100644
index b0e60c8db..000000000
--- a/test/components/protocol_handler/src/protocol_handler_tm_test.cc
+++ /dev/null
@@ -1,32 +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 "protocol_handler/protocol_handler_tm_test.h"
diff --git a/test/components/protocol_handler/src/protocol_header_validator_test.cc b/test/components/protocol_handler/src/protocol_header_validator_test.cc
deleted file mode 100644
index 90c348c14..000000000
--- a/test/components/protocol_handler/src/protocol_header_validator_test.cc
+++ /dev/null
@@ -1,32 +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 "protocol_handler/protocol_header_validator_test.h"
diff --git a/test/components/qt_hmi/CMakeLists.txt b/test/components/qt_hmi/CMakeLists.txt
deleted file mode 100644
index 3ba90228d..000000000
--- a/test/components/qt_hmi/CMakeLists.txt
+++ /dev/null
@@ -1,52 +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.
-
-cmake_minimum_required(VERSION 2.8.11)
-
-include_directories(
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}
- ${LOG4CXX_INCLUDE_DIRECTORY}
- )
-
-set(CONFIG
- warn_on
- qmltestcase
-)
-
-set(SOURCES
- qt_hmi_test.cc
-)
-
-set(target test_QtHMI)
-
-create_test("test_QtHMI" "${SOURCES}" "")
-qt5_use_modules(${target} Core Qml Quick QuickTest)
-
diff --git a/test/components/qt_hmi/log4cxx.properties b/test/components/qt_hmi/log4cxx.properties
deleted file mode 100644
index 0bc5ac8fd..000000000
--- a/test/components/qt_hmi/log4cxx.properties
+++ /dev/null
@@ -1,41 +0,0 @@
-# Socket logger
-log4j.appender.SocketHub=org.apache.log4j.net.SocketHubAppender
-log4j.appender.SocketHub.port=4555
-log4j.appender.SocketHub.locationInfo=true
-
-# Only ERROR and FATAL messages are logged to console
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.ImmediateFlush=true
-log4j.appender.Console.layout=org.apache.log4j.PatternLayout
-log4j.appender.Console.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %m%n
-log4j.appender.Console.Threshold=ERROR
-
-# Log for all DBus plugin messages
-log4j.appender.DBusPluginLogFile=org.apache.log4j.FileAppender
-log4j.appender.DBusPluginLogFile.File=DBusPlugin.log
-log4j.appender.DBusPluginLogFile.append=false
-log4j.appender.DBusPluginLogFile.DatePattern='.' yyyy-MM-dd
-log4j.appender.DBusPluginLogFile.ImmediateFlush=true
-log4j.appender.DBusPluginLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.DBusPluginLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for all HMI Framework plugin
-log4j.appender.HmiFrameworkPluginLogFile=org.apache.log4j.FileAppender
-log4j.appender.HmiFrameworkPluginLogFile.File=HmiFrameworkPlugin.log
-log4j.appender.HmiFrameworkPluginLogFile.append=false
-log4j.appender.HmiFrameworkPluginLogFile.DatePattern='.' yyyy-MM-dd
-log4j.appender.HmiFrameworkPluginLogFile.ImmediateFlush=true
-log4j.appender.HmiFrameworkPluginLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.HmiFrameworkPluginLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for all Qt HMI
-log4j.rootLogger=ALL, Console
-
-# Log for DBus plugin QtHMI
-log4j.logger.DBusPlugin=ALL, DBusPluginLogFile
-
-# Log for HMI Framework plugin
-log4j.logger.HmiFrameworkPlugin=ALL, HmiFrameworkPluginLogFile
-
-# Log by log4cxx plugin
-log4j.logger.Log4cxxPlugin=ALL, HmiFrameworkPluginLogFile
diff --git a/test/components/qt_hmi/qt_hmi_test.cc b/test/components/qt_hmi/qt_hmi_test.cc
deleted file mode 100644
index 84f6bb0b3..000000000
--- a/test/components/qt_hmi/qt_hmi_test.cc
+++ /dev/null
@@ -1,33 +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.
- */
-#include <QtQuickTest/quicktest.h>
-QUICK_TEST_MAIN(QtHMI) \ No newline at end of file
diff --git a/test/components/qt_hmi/readme.txt b/test/components/qt_hmi/readme.txt
deleted file mode 100644
index 99cf4f7d8..000000000
--- a/test/components/qt_hmi/readme.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-A few comments on test writting for QML Unit Testing
-
-- set TestCase inside Item - this allows to send Mouse and keyboard events to contorls
-- content of QML is reachable directly from tests. It is necessary to add getters into source QML file to handle internal items
-- test execution order is alfabetical. If you need manage this order use numbers in test function names
-- all functions that starts with "test_" prefix is treated as test case
-- all files tath starts with "tst_" prefix will be executed as test set
-- for async testing use timer
-- each system's entity that changes during RPC must be tested
-- test incoming arguments is not necessary as it will be verified by Qt abstraction layer
-- run test with following command "./test_QtHMI -import ./../../../src/components/qt_hmi/qml_model"
-
diff --git a/test/components/qt_hmi/src/tst_AddCommand.qml b/test/components/qt_hmi/src/tst_AddCommand.qml
deleted file mode 100644
index 90f671db8..000000000
--- a/test/components/qt_hmi/src/tst_AddCommand.qml
+++ /dev/null
@@ -1,320 +0,0 @@
-/**
- * @file tst_AddSubMenu.qml
- * @brief Test Case for OptionsView.
- * 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.
- */
-
-import QtTest 1.0
-import QtQuick 2.0
-import QtMultimedia 5.0
-import com.ford.sdl.hmi.dbus_adapter 1.0
-import com.ford.sdl.hmi.hw_buttons 1.0
-import com.ford.sdl.hmi.log4cxx 1.0
-import "../../../../src/components/qt_hmi/qml_model_qt5/controls"
-import "../../../../src/components/qt_hmi/qml_model_qt5/views"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api" as HmiApi
-import "../../../../src/components/qt_hmi/qml_model_qt5/models"
-import "../../../../src/components/qt_hmi/qml_model_qt5/popups"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api/Common.js" as Common
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Constants.js" as Constants
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Internal.js" as Internal
-
-Item {
- width : mainWindowLoader.width
- height: mainWindowLoader.height
-
- Loader {
- id: mainWindowLoader
- asynchronous : false
- }
-
- TestCase {
- name: "AddCommand"
- when: windowShown
- property var dataContainer
- property var sdlUIProxy
- property var contentLoader
- property var messageModel
-
- function createView(appID) {
- mainWindowLoader.source = "../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml"
- var mainWindowObject = mainWindowLoader.item
- sdlUIProxy = mainWindowObject.getUIProxy()
- dataContainer = mainWindowObject.getDataStorage()
- dataContainer.addApplication({appName:"TestAppName", appId:appID})
- }
-
- function destroyView() {
- mainWindowLoader.source = ""
- }
-
- /*
- * Test Cases
- */
-
- function test_01_addCommand_Command_Positive() {
- console.debug("enter")
-
- var initData = {
- cmdID: 1,
- cmdIcon: {
- value: "123.jpg",
- imageType: "DYNAMIC"
- },
- menuParams: {
- position: 500,
- menuName: "Command positive"
- },
- appID: 1
- }
-
- createView(initData.appID)
- sdlUIProxy.addCommand(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.cmdID, "Command id")
- compare(app.options.get(0).position, initData.menuParams.position, "Command position")
- compare(app.options.get(0).name, initData.menuParams.menuName, "Command name")
- compare(app.options.get(0).icon.value, initData.cmdIcon.value, "Image path")
-
- destroyView()
- console.debug("exit")
- }
-
- function test_02_addCommand_Without_Position() {
- console.debug("enter")
- var initData = {
- appID: 1,
- Commands: []
- }
- initData.Commands.push({
- cmdID:1,
- comIcon: {
- value: "123.jpg",
- imageType: "DYNAMIC"
- },
- menuParams: {
- menuName: "Command 1"
- },
- appID: 1
- })
- initData.Commands.push({
- cmdID:2,
- cmdIcon: {
- value: "345.jpg",
- imageType: "DYNAMIC"
- },
- menuParams: {
- position: 500,
- menuName: "Command 1"
- },
- appID: 1
- })
- createView(initData.appID)
- sdlUIProxy.addCommand(initData.Commands[0])
- sdlUIProxy.addCommand(initData.Commands[1])
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(1).id, initData.Commands[0].cmdID, "Command id")
- compare(app.options.get(1).name, initData.Commands[0].menuParams.menuName, "Command name")
- compare(app.options.get(0).id, initData.Commands[1].cmdID, "Command id")
- compare(app.options.get(0).name, initData.Commands[1].menuParams.menuName, "Command name")
-
- destroyView()
- console.debug("exit")
- }
-
- function test_03_1010_addCommands() {
- console.debug("enter")
- var initData = {
- appID: 1,
- Commands: []
- }
-
- for (var i = 0; i < 1010; i++) {
- initData.Commands.push({
- cmdID: i,
- cmdIcon: {
- value: "",
- imageType: ""
- },
- menuParams: {
- position: i,
- menuName: "Command " + i
- },
- appID: 1
- })
- }
-
- createView(initData.appID)
- for (var i = 0; i < initData.Commands.length; i++) {
- sdlUIProxy.addCommand(initData.Commands[i])
- }
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.count, 1000, "Command count")
-
- for (var i = 0; i < 1000; i++) {
- compare(app.options.get(i).id, initData.Commands[i].cmdID, "Command id")
- compare(app.options.get(i).position, initData.Commands[i].menuParams.position, "Command position")
- compare(app.options.get(i).name, initData.Commands[i].menuParams.menuName, "Command name")
- }
-
- destroyView()
- console.debug("exit")
- }
-
- function test_04_Command_Upper_Bound() {
- console.debug("enter")
- var initData = {
- cmdID: 2000000000,
- cmdIcon: {
- value: "00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890aAaaaaaaaaaaaaaa",
- imageType: ""
- },
- menuParams: {
- position: 100000,
- menuName: "00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890aAaaaaaaaaaaaaaa"
- },
- appID: 1
- }
-
- createView(initData.appID)
- sdlUIProxy.addCommand(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.cmdID, "Command id")
- compare(app.options.get(0).position, initData.menuParams.position, "Command position")
- compare(app.options.get(0).name.length, initData.menuParams.menuName.length, "Command name")
- compare(app.options.get(0).icon.value.length, initData.cmdIcon.value.length, "Image path")
-
- destroyView()
- console.debug("exit")
- }
-
- function test_05_addCommand_Lower_Bound() {
- console.debug("enter")
- var initData = {
- cmdID: 0,
- cmdIcon: {
- value: "",
- imageType: ""
- },
- menuParams: {
- position: 0,
- menuName: "0",
- parentID: 0
- },
- appID: 0
- }
-
- createView(initData.appID)
- sdlUIProxy.addCommand(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.cmdID, "Command id")
- compare(app.options.get(0).position, initData.menuParams.position, "Command position")
- compare(app.options.get(0).name, initData.menuParams.menuName, "Command name")
- compare(app.options.get(0).icon.value, initData.cmdIcon.value, "Image path")
-
- destroyView()
- console.debug("exit")
- }
-
- function test_06_addCommand_With_Fake_Parameter() {
- console.debug("enter")
- var initData = {
- cmdID: 1,
- cmdIcon: {
- value: "345.jpg",
- imageType: "DYNAMIC"
- },
- menuParams: {
- menuName: "Command fake param",
- position: 1,
- fakeParam: "fakeParam"
- },
- appID: 1
- }
-
- createView(initData.appID)
- sdlUIProxy.addCommand(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.cmdID, "Command id")
- compare(app.options.get(0).position, initData.menuParams.position, "Command position")
- compare(app.options.get(0).name, initData.menuParams.menuName, "Command name")
- compare(app.options.get(0).icon.value, initData.cmdIcon.value, "Image path")
-
- destroyView()
- console.debug("exit")
- }
-
- function test_07_addCommand_No_Menu_Params() {
- console.debug("enter")
-
- var initData = {
- appID: 1,
- Commands:[]
- }
-
- var n = 10;
- initData.Commands.push({
- cmdID: 123,
- menuParams: {},
- appID: 1
- })
- for (var i = 0; i < n; i++) {
- initData.Commands.push({
- cmdID: i,
- menuParams: {
- position: i,
- menuName: "Command " + i
- },
- appID: 1
- })
- }
-
- createView(initData.appID)
- for (var i = 0; i < initData.Commands.length; i++) {
- sdlUIProxy.addCommand(initData.Commands[i])
- }
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.count, initData.Commands.length, "Command count")
- compare(app.options.get(n).id, initData.Commands[0].cmdID, "Command 11 id")
- compare(app.options.get(0).id, initData.Commands[1].cmdID, "Command 12 id")
-
- destroyView()
- console.debug("exit")
- }
- }
-}
diff --git a/test/components/qt_hmi/src/tst_AddSubMenu.qml b/test/components/qt_hmi/src/tst_AddSubMenu.qml
deleted file mode 100644
index 1ddfeefed..000000000
--- a/test/components/qt_hmi/src/tst_AddSubMenu.qml
+++ /dev/null
@@ -1,328 +0,0 @@
-/**
- * @file tst_AddSubMenu.qml
- * @brief Test Case for OptionsView.
- * 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.
- */
-
-
-import QtTest 1.0
-import QtQuick 2.0
-import QtMultimedia 5.0
-import com.ford.sdl.hmi.dbus_adapter 1.0
-import com.ford.sdl.hmi.hw_buttons 1.0
-import com.ford.sdl.hmi.log4cxx 1.0
-import "../../../../src/components/qt_hmi/qml_model_qt5/controls"
-import "../../../../src/components/qt_hmi/qml_model_qt5/views"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api" as HmiApi
-import "../../../../src/components/qt_hmi/qml_model_qt5/models"
-import "../../../../src/components/qt_hmi/qml_model_qt5/popups"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api/Common.js" as Common
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Constants.js" as Constants
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Internal.js" as Internal
-
-Item {
- width : mainWindowLoader.width
- height: mainWindowLoader.height
-
- Loader {
- id: mainWindowLoader
- asynchronous : false
- }
-
- TestCase {
- name: "AddSubMenu"
- when: windowShown
- property var dataContainer
- property var sdlUIProxy
- property var contentLoader
- property var messageModel
-
- //initialization for each test
- function createMessageView(appID) {
- mainWindowLoader.source = ""
- mainWindowLoader.source = "../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml"
- var mainWindowObject = mainWindowLoader.item
- if(!mainWindowObject)
- qtest_fail("mainWindowObject is undefined");
- var mainScreen = mainWindowObject.getMainScreen()
- mainScreen.visible = true
- var warningInfo = mainWindowObject.getWarningInfo()
- warningInfo.visible = false
- contentLoader = mainWindowObject.getContentLoader()
- contentLoader.asynchronous = false
- sdlUIProxy = mainWindowObject.getUIProxy()
- dataContainer = mainWindowObject.getDataStorage()
- dataContainer.addApplication({appName:"TestAppName", appId:appID})
- }
-
- //cleanup for each test
- function destroyView() {
- //Clear Loader with MainWindow, which delete own models and views
- mainWindowLoader.source = ""
- }
-
- /*
- * Test Cases
- */
-
- //Positive case and in boundary conditions
- function test_01_addSubMenu() {
- console.debug("enter")
- var initData = {
- menuID: 1000,
- menuParams: {
- position: 500,
- menuName: "SubMenu positive"
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.menuID, "SubMenu id")
- compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position")
- compare(app.options.get(0).name, initData.menuParams.menuName, "SubMenu name")
-
- destroyView()
- console.debug("exit")
- }
-
- // Only mandatory - without Position
- function test_02_addSubMenu_WithoutPosition() {
- console.debug("enter")
- var initData = {
- menuID: 1001,
- menuParams: {
- menuName: "SubMenu mandatory only"
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.menuID, "SubMenu id")
- //How to verify if value was not set?
- //compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position")
- compare(app.options.get(0).name, initData.menuParams.menuName, "SubMenu name")
-
- destroyView()
- console.debug("exit")
- }
-
- //Create AddSubMenu and check data
- function test_03_1000_SubMenu() {
- console.debug("enter")
- var initData = {
- appID: 1,
- subMenus: []
- }
-
- for (var i = 0; i < 1010; i++) {
-
- initData.subMenus.push({
- menuID: i,
- menuParams: {
- position: i,
- menuName: "Submenu" + i
- },
- appID: 1
- })
- }
-
- createMessageView(initData.appID)
- for (var i = 0; i < initData.subMenus.length; i++) {
- sdlUIProxy.addSubMenu(initData.subMenus[i])
- }
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.count, 1000, "SubMenus count")
-
- for (var i = 0; i < 1000; i++) {
- compare(app.options.get(i).id, initData.subMenus[i].menuID, "SubMenu id")
- compare(app.options.get(i).position, initData.subMenus[i].menuParams.position, "SubMenu position")
- compare(app.options.get(i).name, initData.subMenus[i].menuParams.menuName, "SubMenu name")
- }
-
- destroyView()
- console.debug("exit")
- }
-
- //Create AddSubMenu and check data
- function test_04_addSubMenu_UpperBound() {
- console.debug("enter")
- var initData = {
- menuID: 2000000000,
- menuParams: {
- position: 1000,
- menuName: "00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890a00012Ã¥/678'90abc!def@ghi#jkl$mno%pqr^stu*vwx:yz()ABC-DEF_GHI=JKL+MNO|PQR~STU{}WXY[]Z,01234567890aAaaaaaaaaaaaaaa"
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.menuID, "SubMenu id")
- compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position")
- compare(app.options.get(0).name.length, 500, "SubMenu name")
-
- destroyView()
- console.debug("exit")
- }
-
- //Create AddSubMenu and check data
- function test_05_addSubMenu_LowerBound() {
- console.debug("enter")
- var initData = {
- menuID: 0,
- menuParams: {
- position: 0,
- menuName: "0"
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.menuID, "SubMenu id")
- compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position")
- compare(app.options.get(0).name.length, 1, "SubMenu name")
-
- destroyView()
- console.debug("exit")
- }
-
- // With fake parameter
- function test_06_addSubMenu_With_Fake_Parameter() {
- console.debug("enter")
- var initData = {
- menuID: 1001,
- menuParams: {
- menuName: "SubMenu fake param",
- position: 1,
- fakeParam: "fakeParam"
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.get(0).id, initData.menuID, "SubMenu id")
- compare(app.options.get(0).position, initData.menuParams.position, "SubMenu position")
- compare(app.options.get(0).name, initData.menuParams.menuName, "SubMenu name")
-
- destroyView()
- console.debug("exit")
- }
-
- // With fake parameter
- function test_07_addSubMenu_menuIDOutLowerBound() {
- console.debug("enter")
- var initData = {
- menuID: -1,
- menuParams: {
- menuName: "100",
- position: 1,
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.count, 0, "SubMenus count")
-
- compare(app.options.get(1), !undefined, "SubMenu duplicated")
-
- destroyView()
- console.debug("exit")
- }
-
- // With fake parameter
- function test_08_addSubMenu_menuIDOutUpperBound() {
- console.debug("enter")
- var initData = {
- menuID: 2000000001,
- menuParams: {
- menuName: "100",
- position: 1,
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.count, 0, "SubMenus count")
-
- compare(app.options.get(1), !undefined, "SubMenu duplicated")
-
- destroyView()
- console.debug("exit")
- }
-
- // With fake parameter
- function test_09_addSubMenu_duplicatedSubMenus() {
- console.debug("enter")
- var initData = {
- menuID: 2000000001,
- menuParams: {
- menuName: "100",
- position: 1,
- },
- appID: 1
- }
-
- createMessageView(initData.appID)
- sdlUIProxy.addSubMenu(initData)
- sdlUIProxy.addSubMenu(initData)
- var app = dataContainer.getApplication(initData.appID)
-
- compare(app.options.count, 1, "SubMenus count")
-
- compare(app.options.get(1), undefined, "SubMenu duplicated")
-
- destroyView()
- console.debug("exit")
- }
- }
-}
diff --git a/test/components/qt_hmi/src/tst_DeleteCommand.qml b/test/components/qt_hmi/src/tst_DeleteCommand.qml
deleted file mode 100644
index cd176bd77..000000000
--- a/test/components/qt_hmi/src/tst_DeleteCommand.qml
+++ /dev/null
@@ -1,210 +0,0 @@
-/**
- * @file tst_ScrollableMessage.qml
- * @brief Test Case for ScrollableMessageView.
- * 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.
- */
-
-import QtTest 1.0
-import QtQuick 2.0
-import QtMultimedia 5.0
-import com.ford.sdl.hmi.dbus_adapter 1.0
-import com.ford.sdl.hmi.hw_buttons 1.0
-import com.ford.sdl.hmi.log4cxx 1.0
-import "../../../../src/components/qt_hmi/qml_model_qt5/controls"
-import "../../../../src/components/qt_hmi/qml_model_qt5/views"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api" as HmiApi
-import "../../../../src/components/qt_hmi/qml_model_qt5/models"
-import "../../../../src/components/qt_hmi/qml_model_qt5/popups"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api/Common.js" as Common
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Constants.js" as Constants
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Internal.js" as Internal
-
-Item
-{
- width : mainWindowLoader.width
- height: mainWindowLoader.height
-
- Loader
- {
- id: mainWindowLoader
- asynchronous : false
- }
-
- TestCase
- {
- name: "DeleteCommand"
- when: windowShown
- property var dataContainer
- property var sdlUIProxy
- property var contentLoader
- property var messageModel
-
-
- //initialization for each test
- function createMessageView(appID)
- {
- mainWindowLoader.source = ""
- mainWindowLoader.source = "../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml"
- var mainWindowObject = mainWindowLoader.item
- if(!mainWindowObject)
- qtest_fail("mainWindowObject is undefined");
- var mainScreen = mainWindowObject.getMainScreen()
- mainScreen.visible = true
- var warningInfo = mainWindowObject.getWarningInfo()
- warningInfo.visible = false
- contentLoader = mainWindowObject.getContentLoader()
- contentLoader.asynchronous = false
- sdlUIProxy = mainWindowObject.getUIProxy()
- dataContainer = mainWindowObject.getDataStorage()
- dataContainer.addApplication({appName:"TestAppName", appId:appID})
- }
-
- //cleanup for each test
- function destroyView()
- {
- //Clear Loader with MainWindow, which delete own models and views
- mainWindowLoader.source = ""
- }
-
- /*
- * Test Cases
- */
-
- function test_01_deleteCommand()
- {
- console.debug("enter")
- var initData = {
- cmdID: 1,
- menuParams:
- {
- menuName:"",
- },
- cmdIcon:"",
- appID: 1
- }
- var initData2 = {
- cmdID: 2,
- menuParams:
- {
- menuName:"",
- },
- cmdIcon:"",
- appID: 1
- }
-
- createMessageView(initData.appID)
- var app = dataContainer.getApplication(initData.appID)
- var MenuCount = app.options.count
- app.options.append(
- { id: initData.cmdID,
- name: initData.menuParams.menuName,
- type: Internal.MenuItemType.MI_NODE,
- position: Constants.positionOfElementWithoutPosition,
- icon: initData.cmdIcon ? cmdIcon : {},
- subMenu: []
- }
- )
-
- compare(app.options.count, MenuCount+1, "Command into menu not added")
- sdlUIProxy.deleteCommand(initData2)
-
- var a = 0
- for(var i = 0;((a === 0) && ( i < app.options.count)); i++)
- {
- if (app.options.get(i).id===initData2.menuID)
- {
- a = 1
- }
- }
- compare (a, 0, "Command in menu isn't removed")
-
-
- destroyView()
- console.debug("exit")
- }
-
- function test_02_deleteCommand() {
- console.debug("enter")
- var initData = {
- menuID: 1000,
- menuParams: {
- position: 1,
- menuName: "SubMenu"
- },
- appID: 1
- }
-
- var initData2 = {
- cmdID: 1,
- menuParams: {
- menuName:"",
- },
- cmdIcon:"",
- appID: 1
- }
-
- createMessageView(initData.appID)
- var app = dataContainer.getApplication(initData.appID)
- var MenuCount = app.options.count
- app.options.append ({
- "id": initData.menuID,
- "name": initData.menuParams.menuName,
- "position": initData.menuParams.position,
- "type": Internal.MenuItemType.MI_SUBMENU,
- "icon": undefined,
- "subMenu":[{
- "id":initData2.cmdID,
- "name": initData2.menuParams.menuName,
- "position": Constants.positionOfElementWithoutPosition,
- "type": Internal.MenuItemType.MI_PARENT,
- "icon": {
- "imageType": Common.ImageType.DYNAMIC,
- "value": "../res/nav/turnArrow.png"
- },
-
- "subMenu": []
- }]
- })
-
- compare(app.options.count, MenuCount+1, "SubMenu into added")
- var SubMenuCount = app.options.get(0).subMenu.count
- compare( SubMenuCount, 1, "Command is not added into SubMenu")
-
- sdlUIProxy.deleteCommand(initData2)
-
- compare(app.options.count , MenuCount+1, "Menu is changed")
- compare(app.options.get(0).subMenu.count, SubMenuCount-1, "Command into SubMenu is not removed")
-
- destroyView()
- console.debug("exit")
- }
- }
-}
diff --git a/test/components/qt_hmi/src/tst_ScrollableMessage.qml b/test/components/qt_hmi/src/tst_ScrollableMessage.qml
deleted file mode 100644
index 17777c7db..000000000
--- a/test/components/qt_hmi/src/tst_ScrollableMessage.qml
+++ /dev/null
@@ -1,421 +0,0 @@
-/**
- * @file tst_ScrollableMessage.qml
- * @brief Test Case for ScrollableMessageView.
- * 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.
- */
-
-
-import QtTest 1.0
-import QtQuick 2.0
-import QtMultimedia 5.0
-import com.ford.sdl.hmi.dbus_adapter 1.0
-import com.ford.sdl.hmi.hw_buttons 1.0
-import com.ford.sdl.hmi.log4cxx 1.0
-import "../../../../src/components/qt_hmi/qml_model_qt5/controls"
-import "../../../../src/components/qt_hmi/qml_model_qt5/views"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api" as HmiApi
-import "../../../../src/components/qt_hmi/qml_model_qt5/models"
-import "../../../../src/components/qt_hmi/qml_model_qt5/popups"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api/Common.js" as Common
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Constants.js" as Constants
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Internal.js" as Internal
-
-Item {
- width : mainWindowLoader.width
- height: mainWindowLoader.height
-
- Loader {
- id: mainWindowLoader
- asynchronous : false
- }
-
- TestCase {
- name: "ScrollableMessageView"
- when: windowShown
- property var dataContainer
- property var sdlUIProxy
- property var contentLoader
- property var messageModel
- property var messageView
- property var timer
-
- property var softButtonsListExample : [
- {softButtonID:0, isHighlighted:true, systemAction:Common.SystemAction.DEFAULT_ACTION,
- type:Common.SoftButtonType.SBT_TEXT, text:"Default Action"},
- {softButtonID:1, isHighlighted:false, systemAction:Common.SystemAction.STEAL_FOCUS,
- type:Common.SoftButtonType.SBT_IMAGE, text:"Steal Focus"},
- {softButtonID:2, isHighlighted:false, systemAction:Common.SystemAction.KEEP_CONTEXT,
- type:Common.SoftButtonType.SBT_BOTH, text:"Keep context"}]
-
- //initialization for each test
- function createMessageView(appID) {
- mainWindowLoader.source = ""
- mainWindowLoader.source = "../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml"
- var mainWindowObject = mainWindowLoader.item
- if(!mainWindowObject)
- qtest_fail("mainWindowObject is undefined");
- var mainScreen = mainWindowObject.getMainScreen()
- mainScreen.visible = true
- var warningInfo = mainWindowObject.getWarningInfo()
- warningInfo.visible = false
- contentLoader = mainWindowObject.getContentLoader()
- contentLoader.asynchronous = false
- sdlUIProxy = mainWindowObject.getUIProxy()
- dataContainer = mainWindowObject.getDataStorage()
- dataContainer.addApplication({appName:"TestAppName", appId:appID})
- }
-
- //get messageModel and messageView after call @scrollableMessage
- function getMessageViewModel() {
- messageModel = dataContainer.scrollableMessageModel
- if(!messageModel)
- qtest_fail("messageModel is undefined");
- messageView = contentLoader.item
- if(!messageView)
- qtest_fail("messageView is undefined");
- }
-
- //cleanup for each test
- function destroyView() {
- //Clear Loader with MainWindow, which delete own models and views
- mainWindowLoader.source = ""
- }
-
- //return button from messageView by ommon.SystemAction
- function findButtonByAction(systemAction){
- var listViewItems = messageView.getSoftButtonsListView()
- for (var i = 0, len = listViewItems.count; i < len; i++) {
- //get SoftButton by setting current item (ListView has no getter)
- listViewItems.currentIndex = i
- var buttonItem = listViewItems.currentItem
- if (buttonItem.button.systemAction === systemAction) {
- return buttonItem
- }
- }
- }
-
- /*
- * Test Cases
- */
-
- //Create ScrollableMessageView and check data
- function test_01_create() {
- console.debug("enter")
- var initData = {appID:1, timeout:2000,
- messageText:{fieldText:"Simple ScrollableMessage text"},
- softButtons:softButtonsListExample}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- verify(result.__errno === undefined, "ScrollableMessage return error state")
- timer = messageView.getTimer()
- if(!timer)
- qtest_fail("timer is undefined");
- //check button equals to init data
- compare(messageModel.softButtons.count, initData.softButtons.length, "wrong buttons count created")
- for (var i = 0, len = messageModel.softButtons.count; i < len; i++) {
- var act = messageModel.softButtons.get(i)
- var exp = initData.softButtons[i]
- compare(act.softButtonID, exp.softButtonID, "wrong softButtonID in button")
- compare(act.isHighlighted, exp.isHighlighted, "wrong isHighlighted in button")
- compare(act.systemAction, exp.systemAction, "wrong systemAction in button")
- compare(act.text, exp.text, "wrong text in button")
- }
- //check model data equals to init data
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- compare(messageModel.longMessageText, initData.messageText.fieldText, "wrong messageText")
- compare(messageModel.appId, initData.appID, "wrong application ID")
- compare(messageModel.timeout, initData.timeout, "wrong timeout")
- verify(messageModel.async !== undefined, "async in undefined")
- destroyView()
- console.debug("exit")
- }
-
- //Create ScrollableMessageView with empty data
- function test_02_emptyInit() {
- console.debug("enter")
- var initData = {appID:1, timeout:0, messageText:{fieldText:""}, softButtons:[]}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- verify(result.__errno === undefined, "ScrollableMessage return error state")
- //NOTE: don't check timer - it has been triggered immediately (timeout is 0)
- //MessageView call @complete immediately
- compare(messageModel.running, false, "ScrollableMessage didn't stop")
- compare(messageModel.softButtons.count, initData.softButtons.length, "wrong buttons count")
- compare(messageModel.longMessageText, initData.messageText.fieldText, "wrong messageText")
- compare(messageModel.timeout, initData.timeout, "wrong timeout")
- destroyView()
- console.debug("exit")
- }
-
- //call @scrollableMessage twice (after first view has closed)
- function test_03_doubleCreate() {
- console.debug("enter")
- var initData = {appID:1, timeout:0, messageText:{fieldText:"Simple text"},
- softButtons:softButtonsListExample}
- var initData2 = {appID:1, timeout:10000, messageText:{fieldText:"Simple text 2"},
- softButtons:[]}
- createMessageView(initData.appID)
-
- //create view
- var actualResult = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- //create new view
- var actualResult2 = sdlUIProxy.scrollableMessage(initData2)
- getMessageViewModel()
-
- verify(actualResult.__errno === undefined, "ScrollableMessage return error state")
- verify(actualResult2.__errno === undefined, "ScrollableMessage return error state")
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- compare(messageModel.longMessageText, initData2.messageText.fieldText, "wrong messageText")
- compare(messageModel.timeout, initData2.timeout, "wrong timeout")
- compare(messageModel.appId, initData2.appID, "wrong application ID")
- verify(messageModel.async !== undefined, "async in undefined")
- destroyView()
- console.debug("exit")
- }
-
- //call @scrollableMessage twice (before first view is closed)
- function test_04_doubleCreateError() {
- console.debug("enter")
- var initData = {appID:1, timeout:20000, messageText:{fieldText:"Simple text"},
- softButtons:softButtonsListExample}
- var initData2 = {appID:1, timeout:10000, messageText:{fieldText:"Simple text 2"},
- softButtons:[]}
- createMessageView(initData.appID)
-
- //create view
- var actualResult = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
- var firstView = messageView;
-
- //create new view
- var actualResult2 = sdlUIProxy.scrollableMessage(initData2)
- getMessageViewModel()
- verify(actualResult.__errno === undefined, "ScrollableMessage return error state")
- verify(actualResult2.__errno !== undefined, "ScrollableMessage don't return error state")
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- compare(messageView, firstView, "creating new view insteed stay first")
- compare(messageModel.longMessageText, initData.messageText.fieldText, "wrong messageText")
- compare(messageModel.timeout, initData.timeout, "wrong timeout")
- compare(messageModel.appId, initData.appID, "wrong application ID")
- verify(messageModel.async !== undefined, "async in undefined")
- destroyView()
- console.debug("exit")
- }
-
- //call @scrollableMessage and check close
- function test_05_ClickBackButton() {
- console.debug("enter")
- var initData = {appID:1, timeout:20000,
- messageText:{fieldText:"Simple ScrollableMessage text"},
- softButtons:softButtonsListExample}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- verify(result.__errno === undefined, "ScrollableMessage return error state")
- //look for back button
- var backButton = messageView.getBackButton()
- verify(backButton !== undefined, "Not created back button")
- //wait rendering for correct click position
- waitForRendering(mainWindowLoader)
- //Press back button
- mouseClick(backButton, backButton.width/2, backButton.height/2,
- Qt.LeftButton, Qt.NoModifier, 0)
- //check that MessageView (in contentLoader) is unloaded and deleted
- var isLoaded = (contentLoader.source.toString().indexOf("ScrollableMessageView.qml") > 0)
- verify(!isLoaded, "MessageView should be unloaded")
- //wait for delete messageView by GC
- wait(0);
- verify(messageView === null, "MessageView should be deleted")
- destroyView()
- console.debug("exit")
- }
- //call @scrollableMessage and check close
- function test_06_ClickDefaultAction() {
- console.debug("enter")
- var initData = {appID:1, timeout:20000,
- messageText:{fieldText:"Simple ScrollableMessage text"},
- softButtons:softButtonsListExample}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- verify(result.__errno === undefined, "ScrollableMessage return error state")
- //look for DEFAULT_ACTION button
- var defaultActionButton = findButtonByAction(Common.SystemAction.DEFAULT_ACTION)
- verify(defaultActionButton !== undefined, "Not created button with DEFAULT_ACTION")
- //wait rendering for correct click position
- waitForRendering(mainWindowLoader)
- //Press default button
- mouseClick(defaultActionButton, defaultActionButton.width/2, defaultActionButton.height/2,
- Qt.LeftButton, Qt.NoModifier, 0)
- //check that MessageView (in contentLoader) is unloaded and deleted
- var isLoaded = (contentLoader.source.toString().indexOf("ScrollableMessageView.qml") > 0)
- verify(!isLoaded, "MessageView should be unloaded")
- //wait for delete messageView by GC
- wait(0);
- verify(messageView === null, "MessageView should be deleted")
- destroyView()
- console.debug("exit")
- }
-
- //call @scrollableMessage and check restart timer
- function test_07_ClickStealFocus() {
- console.debug("enter")
- var initData = {appID:1, timeout:20000, messageText:{fieldText:"Simple ScrollableMessage text"},
- softButtons:softButtonsListExample}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- //check
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- verify(result.__errno === undefined, "ScrollableMessage return error state")
- //look for STEAL_FOCUS button
- var stealFocusButton = findButtonByAction(Common.SystemAction.STEAL_FOCUS)
- verify(stealFocusButton !== undefined, "Not created button with STEAL_FOCUS")
- //wait rendering for correct buttons size for correct click position
- waitForRendering(mainWindowLoader)
- mouseClick(stealFocusButton, stealFocusButton.width/2, stealFocusButton.height/2,
- Qt.LeftButton, Qt.NoModifier, 0)
- //check that MediaView loaded in loade
- var viewQMlFileName = dataContainer.currentApplication.isMediaApplication ?
- "SDLPlayerView.qml" : "SDLNonMediaView.qml"
- var isLoaded = (contentLoader.source.toString().indexOf(viewQMlFileName) > 0)
- verify(isLoaded, "SDLPlayerView/SDLNonMediaView should be loaded")
- destroyView()
- console.debug("exit")
- }
-
- //call @scrollableMessage and check restart timer
- function test_08_ClickKeepContex() {
- console.debug("enter")
- var initData = {appID:1, timeout:20000, messageText:{fieldText:"Simple ScrollableMessage text"},
- softButtons:softButtonsListExample}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- //check
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- verify(result.__errno === undefined, "ScrollableMessage return error state")
- //look for KEEP_CONTEXT button
- var keepContexButton = findButtonByAction(Common.SystemAction.KEEP_CONTEXT)
- verify(keepContexButton !== undefined, "Not created button with KEEP_CONTEXT")
- //wait rendering for correct click position
- waitForRendering(mainWindowLoader)
- //Press button
- mouseClick(keepContexButton, keepContexButton.width/2, keepContexButton.height/2,
- Qt.LeftButton, Qt.NoModifier, 0)
- //check that MessageView is still unloaded loaded
- var isLoaded = (contentLoader.source.toString().indexOf("ScrollableMessageView.qml") > 0)
- verify(isLoaded, "MessageView should be loaded")
- //verify restarted timer
- timer = messageView.getTimer()
- verify(timer.running === true, "Timer is not restarted by KEEP_CONTEXT button")
- destroyView()
- console.debug("exit")
- }
-
- //add long text to model and check scrollBar visibility
- function test_09_ScrollBarShown() {
- console.debug("enter")
- //generate string with (10!) lines
- var longText = "It is very long text!\n"
- for(var i = 1; i < 10; ++i)
- longText += longText
- var initData = {appID:1, timeout:20000, messageText:{fieldText:longText}, softButtons:[]}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- //check
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- verify(result.__errno === undefined, "ScrollableMessage return error state")
-
- //wait rendering
- waitForRendering(mainWindowLoader)
- var scrollBar = messageView.getScrollbar()
- verify(scrollBar.visible === true, "ScrollBar is not shown for long text")
-
- destroyView()
- console.debug("exit")
- }
-
- //compare text width with and without buttons at top of SrollableMessage
- function test_10_MessageTextHeight() {
- console.debug("enter")
- var initData = {appID:1, timeout:500, messageText:{fieldText:"Simple text"}, softButtons:[]}
- createMessageView(initData.appID)
-
- var result = sdlUIProxy.scrollableMessage(initData)
- getMessageViewModel()
-
- //check
- compare(messageModel.running, true, "ScrollableMessage didn't start")
- verify(result.__errno === undefined, "ScrollableMessage return error state")
-
- var textAreaHeight = messageView.getTextArea().height
- wait(initData.timeout)
-
- var initData2 = {appID:1, timeout:20000, messageText:{fieldText:"Simple text"},
- softButtons:softButtonsListExample}
- createMessageView(initData.appID)
-
- var result2 = sdlUIProxy.scrollableMessage(initData2)
- getMessageViewModel()
-
- //wait rendering
- waitForRendering(mainWindowLoader)
- var textAreaHeight2 = messageView.getTextArea().height
- console.debug("messageTextH", textAreaHeight, textAreaHeight2)
- verify(textAreaHeight2 <= textAreaHeight, "Height of text area shoud be less with buttons")
-
- destroyView()
- console.debug("exit")
- }
- }
-}
diff --git a/test/components/qt_hmi/src/tst_SetMediaClockTimer.qml b/test/components/qt_hmi/src/tst_SetMediaClockTimer.qml
deleted file mode 100644
index 2216ba767..000000000
--- a/test/components/qt_hmi/src/tst_SetMediaClockTimer.qml
+++ /dev/null
@@ -1,292 +0,0 @@
-/**
- * @file tst_Slider.qml
- * @brief Test Case for Slider.
- * 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.
- */
-
-import QtTest 1.0
-import QtQuick 2.0
-import QtMultimedia 5.0
-import com.ford.sdl.hmi.dbus_adapter 1.0
-import com.ford.sdl.hmi.hw_buttons 1.0
-import com.ford.sdl.hmi.log4cxx 1.0
-import "../../../../src/components/qt_hmi/qml_model_qt5/controls"
-import "../../../../src/components/qt_hmi/qml_model_qt5/views"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api" as HmiApi
-import "../../../../src/components/qt_hmi/qml_model_qt5/models"
-import "../../../../src/components/qt_hmi/qml_model_qt5/popups"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api/Common.js" as Common
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Constants.js" as Constants
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Internal.js" as Internal
-
-Item {
- id:item123
- TestCase {
- name: "time"
- property var mainWindowComponent : Qt.createComponent("./../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml")
- property var mainObject
- property var sdlUI
- property var dataContainer
-
- function createTime() {
- mainObject = mainWindowComponent.createObject(parent)
- sdlUI = mainObject.getUIProxy()
- dataContainer = mainObject.getDataStorage()
- }
-
- function destroyTime() {
- mainObject.destroy()
- }
-
- //No end time, works like a timer
- function test_01_noEndTimeInCountUp() {
- console.debug("enter")
-
- var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:undefined , updateMode: 0, appID: 1}
-
- var expectedResult = {endTimeResult:-1, resultCode : Common.Result.SUCCESS}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- var actualResult = sdlUI.setMediaClockTimer(initData)
-
- try {
- compare(dataContainer.getApplication(initData.appID).mediaClock.endTime, expectedResult.endTimeResult, "time position")
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
- //No start time. Function process error
- function test_02_noStartTime() {
- console.debug("enter")
-
- var initData = {startTime:undefined, endTime:{hours: 4, minutes: 0, seconds: 0} , updateMode: 1, appID: 1}
- var expectedResult = {resultCode : Common.Result.INVALID_DATA}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- var actualResult = sdlUI.setMediaClockTimer(initData)
-
- try {
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
- //Receive "pause", when onready paused
- function test_03_pauseAfterPause() {
- console.debug("enter")
-
- var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1}
- var expectedResult = {resultCode : Common.Result.IGNORED}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- sdlUI.setMediaClockTimer(initData)
-
- initData.updateMode=2
- sdlUI.setMediaClockTimer(initData)
-
- var actualResult = sdlUI.setMediaClockTimer(initData)
-
- try {
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
- //Receive "RESUME" after "CLEAR"
- function test_04_resumeAfterClear() {
- console.debug("enter")
-
- var initData = {startTime:{hours: 10, minutes: 0, seconds: 0},endTime:{ }, updateMode:0, appID:1}
-
- var expectedResult = {resultCode : Common.Result.IGNORED}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- sdlUI.setMediaClockTimer(initData)
-
- initData.updateMode=4
- sdlUI.setMediaClockTimer(initData)
-
- initData.updateMode=3
- sdlUI.setMediaClockTimer(initData)
-
- var actualResult = sdlUI.setMediaClockTimer(initData)
- try {
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
- function test_05_resumeAfterEnd() {
- console.debug("enter")
-
- var initData = {startTime:{hours: 0, minutes: 12, seconds: 33},endTime:{hours: 0, minutes: 12, seconds: 33}, updateMode:0, appID:1}
-
- var expectedResult = {resultCode : Common.Result.IGNORED}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- sdlUI.setMediaClockTimer(initData)
-
- dataContainer.setApplicationProperties(initData.appID, {
- "mediaClock": {
- "updateMode": 0,
- "runningMode": 1,
- "startTime": initData.StartTime,
- "endTime": initData.EndTime,
- "startTimeForProgress": 753
- }
- })
- initData.updateMode=3
- var actualResult = sdlUI.setMediaClockTimer(initData)
-
- try {
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
- //Launch "COUNTUP" twice
- function test_06_twoCountUp() {
- console.debug("enter")
-
- var initData1 = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1}
- var initData2 = {startTime:{hours: 5, minutes: 0, seconds: 0}, endTime:{hours: 18, minutes: 00, seconds: 00}, updateMode: 0, appID: 1}
- var expectedResult = {startTime:18000, endTime: 64800, updateMode: 0, resultCode : Common.Result.SUCCESS}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData1.appID})
-
- sdlUI.setMediaClockTimer(initData1)
-
- var actualResult = sdlUI.setMediaClockTimer(initData2)
-
- try {
- compare(dataContainer.getApplication(initData1.appID).mediaClock.startTime, expectedResult.startTime, "startTime")
- compare(dataContainer.getApplication(initData1.appID).mediaClock.endTime, expectedResult.endTime, "endTime")
- compare(dataContainer.getApplication(initData1.appID).mediaClock.updateMode, expectedResult.updateMode, "updateMode")
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
- //Get "RESUME", when clock is paused
- function test_07_resumeAfterResume() {
- console.debug("enter")
-
- var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1}
- var expectedResult = {resultCode : Common.Result.IGNORED}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- sdlUI.setMediaClockTimer(initData)
-
- initData.updateMode=3
- var actualResult = sdlUI.setMediaClockTimer(initData)
-
- try {
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
-
- function test_08_countDownAfterCountUp() {
- console.debug("enter")
-
- var initData1 = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:{hours: 12, minutes: 00, seconds: 00}, updateMode: 0, appID: 1}
- var initData2 = {startTime:{hours: 18, minutes: 0, seconds: 0}, endTime:{hours: 5, minutes: 00, seconds: 00}, updateMode: 1, appID: 1}
- var expectedResult = {startTime:64800, endTime: 18000, updateMode: 1, resultCode : Common.Result.SUCCESS}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData1.appID})
-
- sdlUI.setMediaClockTimer(initData1)
-
- var actualResult = sdlUI.setMediaClockTimer(initData2)
-
- try {
- compare(dataContainer.getApplication(initData1.appID).mediaClock.startTime, expectedResult.startTime, "startTime")
- compare(dataContainer.getApplication(initData1.appID).mediaClock.endTime, expectedResult.endTime, "endTime")
- compare(dataContainer.getApplication(initData1.appID).mediaClock.updateMode, expectedResult.updateMode, "updateMode")
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
-
- function test_09_noEndTimeInCountDown() {
- console.debug("enter")
-
- var initData = {startTime:{hours: 4, minutes: 0, seconds: 0}, endTime:undefined, updateMode: 0, appID: 1}
-
- var expectedResult = {startTimeForProgress:14400, resultCode : Common.Result.SUCCESS}
-
- createTime()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- var actualResult = sdlUI.setMediaClockTimer(initData)
-
- try {
- compare(dataContainer.getApplication(initData.appID).mediaClock.startTimeForProgress, expectedResult.startTimeForProgress, "time position")
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
-
- destroyTime()
- console.debug("exit")
- }
- }
-}
diff --git a/test/components/qt_hmi/src/tst_Show.qml b/test/components/qt_hmi/src/tst_Show.qml
deleted file mode 100644
index 75991097e..000000000
--- a/test/components/qt_hmi/src/tst_Show.qml
+++ /dev/null
@@ -1,363 +0,0 @@
-/**
- * @file tst_Slider.qml
- * @brief Test Case for Slider.
- * 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.
- */
-
-import QtTest 1.0
-import QtQuick 2.0
-import QtMultimedia 5.0
-import com.ford.sdl.hmi.dbus_adapter 1.0
-import com.ford.sdl.hmi.hw_buttons 1.0
-import com.ford.sdl.hmi.log4cxx 1.0
-import "../../../../src/components/qt_hmi/qml_model_qt5/controls"
-import "../../../../src/components/qt_hmi/qml_model_qt5/views"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api" as HmiApi
-import "../../../../src/components/qt_hmi/qml_model_qt5/models"
-import "../../../../src/components/qt_hmi/qml_model_qt5/popups"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api/Common.js" as Common
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Constants.js" as Constants
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Internal.js" as Internal
-
-Item {
- width : mainWindowLoader.width
- height: mainWindowLoader.height
- Loader {
- id: mainWindowLoader
- asynchronous : false
- }
-
- TestCase {
- name: "Show"
- when: windowShown
- property var mainWindowComponent : Qt.createComponent("./../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml")
- property var mainObject
- property var sldUI
- property var dataContainer
- property var contentLoader
-
- property var softButtonsListExample : [
- {softButtonID:0, isHighlighted:true, systemAction:Common.SystemAction.DEFAULT_ACTION,
- type:Common.SoftButtonType.SBT_TEXT, text:"Default Action"},
- {softButtonID:1, isHighlighted:false, systemAction:Common.SystemAction.STEAL_FOCUS,
- type:Common.SoftButtonType.SBT_IMAGE, text:"Steal Focus"},
- {softButtonID:2, isHighlighted:false, systemAction:Common.SystemAction.KEEP_CONTEXT,
- type:Common.SoftButtonType.SBT_BOTH, text:"Keep context"}]
-
-
- //initialization for each test
- function createShow(appID) {
- mainWindowLoader.source = ""
- mainWindowLoader.source = "../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml"
- var mainWindowObject = mainWindowLoader.item
- if(!mainWindowObject)
- qtest_fail("mainWindowObject is undefined");
- var mainScreen = mainWindowObject.getMainScreen()
- mainScreen.visible = true
- var warningInfo = mainWindowObject.getWarningInfo()
- warningInfo.visible = false
- contentLoader = mainWindowObject.getContentLoader()
- contentLoader.asynchronous = false
- sldUI = mainWindowObject.getUIProxy()
- dataContainer = mainWindowObject.getDataStorage()
- dataContainer.addApplication({appName:"TestAppName", appId:appID})
- }
-
-
-
- //cleanup for each test
- function destroyShow() {
- //Clear Loader with MainWindow, which delete own models and views
- mainWindowLoader.source = ""
- }
-
-
- //Fill up all fields, check save process to dataContainer
- function test_01_create() {
- console.debug("enter")
- var initData = {
- appID:1,
- showStrings:[
- {fieldName:Common.TextFieldName.mainField1 ,fieldText:"showString1"},
- {fieldName:Common.TextFieldName.mainField2,fieldText:"showString2"},
- {fieldName:Common.TextFieldName.mainField3,fieldText:"showString3"},
- {fieldName:Common.TextFieldName.mainField4,fieldText:"showString4"},
- {fieldName:Common.TextFieldName.mediaTrack,fieldText:"mediaTrack"},
- {fieldName:Common.TextFieldName.statusBar,fieldText:"StatusBar"},
- {fieldName:Common.TextFieldName.mediaClock,fieldText:"12:34"}
- ],
- softButtons:softButtonsListExample,
- alignment:2,
- graphic:{value:"/home/user/applink/bin/SPTAlice9675308/action.png",imageType: "DYNAMIC"},
- secondaryGraphic:{value:"/home/user/applink/bin/SPTAlice9675308/action.png",imageType: "DYNAMIC"},
- customPresets:["GEN0","GEN1","GEN2","GEN3"]
- }
-
- createShow(1)
- var app = dataContainer.getApplication(initData.appID)
- sldUI.show (initData)
-
- try {
-
- compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1")
- compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2")
- compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3")
- compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4")
- compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack")
- compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" )
- compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock")
- var a;
- if(app.hmiUITextAlignment === 1) a=0;
- if(app.hmiUITextAlignment === 2) a=1;
- if(app.hmiUITextAlignment === 4) a=2;
- compare(initData.alignment, a, "Alignment")
- compare(app.hmiUIText.image, initData.graphic.value, "image")
- compare(app.hmiUIText.secondaryImage, initData.secondaryGraphic.value, "secdondImage")
- compare(app.softButtons.count, initData.softButtons.length, "wrong buttons count created")
- for (var i = 0, len = app.softButtons.count; i < len; i++)
- {
- var act = app.softButtons.get(i)
- var exp = initData.softButtons[i]
- compare(act.softButtonID, exp.softButtonID, "wrong softButtonID in button")
- compare(act.isHighlighted, exp.isHighlighted, "wrong isHighlighted in button")
- compare(act.systemAction, exp.systemAction, "wrong systemAction in button")
- compare(act.text, exp.text, "wrong text in button")
- }
- compare(app.customPresets.count, initData.customPresets.length, "wrong buttons count created")
- for (var j = 0, len2 = app.customPresets.count; j < len; j++)
- {
- var act2 = app.customPresets.get(j)
- var exp2 = initData.customPresets[j]
- compare(act2.text, exp2, "wrong text in button")
- }
- }
- catch (e) {}
- destroyShow()
- console.debug("exit")
- }
- //All fields are empty
- function test_02_emptyInit()
- {
- console.debug("enter")
- var initData = {
- appID:1,
- showStrings:[
- {fieldName:Common.TextFieldName.mainField1 ,fieldText:""},
- {fieldName:Common.TextFieldName.mainField2,fieldText:""},
- {fieldName:Common.TextFieldName.mainField3,fieldText:""},
- {fieldName:Common.TextFieldName.mainField4,fieldText:""},
- {fieldName:Common.TextFieldName.mediaTrack,fieldText:""},
- {fieldName:Common.TextFieldName.statusBar,fieldText:""},
- {fieldName:Common.TextFieldName.mediaClock,fieldText:""}
- ],
- softButtons:[],
- alignment:0,
- graphic:{value:"",imageType: "DYNAMIC"},
- secondaryGraphic:{value:"",imageType: "DYNAMIC"},
- customPresets:[]
- }
-
- createShow(1)
- var app = dataContainer.getApplication(initData.appID)
- sldUI.show (initData)
-
- try {
-
- compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1")
- compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2")
- compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3")
- compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4")
- compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack")
- compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" )
- compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock")
- var a;
- if(app.hmiUITextAlignment === 1) a=0;
- if(app.hmiUITextAlignment === 2) a=1;
- if(app.hmiUITextAlignment === 4) a=2;
- compare(initData.alignment, a, "Alignment")
- compare(app.hmiUIText.image, initData.graphic.value, "image")
- compare(app.hmiUIText.secondaryImage, initData.secondaryGraphic.value, "secdondImage")
- compare(app.softButtons.count, initData.softButtons.length, "wrong buttons count created")
- for (var i = 0, len = app.softButtons.count; i < len; i++)
- {
- var act = app.softButtons.get(i)
- var exp = initData.softButtons[i]
- compare(act.softButtonID, exp.softButtonID, "wrong softButtonID in button")
- compare(act.isHighlighted, exp.isHighlighted, "wrong isHighlighted in button")
- compare(act.systemAction, exp.systemAction, "wrong systemAction in button")
- compare(act.text, exp.text, "wrong text in button")
- }
- compare(app.customPresets.count, initData.customPresets.length, "wrong buttons count created")
- for (var j = 0, len2 = app.customPresets.count; j < len; j++)
- {
- var act2 = app.customPresets.get(j)
- var exp2 = initData.customPresets[j]
- compare(act2.text, exp2, "wrong text in button")
- }
- }
- catch (e) {}
- destroyShow()
- console.debug("exit")
- }
-
- //Mandatory fields only
- function test_03_create_mandatory_only() {
- console.debug("enter")
- var initData = {
- appID:1,
- showStrings:[
- {fieldName:Common.TextFieldName.mainField1 ,fieldText:"showString1"},
- {fieldName:Common.TextFieldName.mainField2,fieldText:"showString2"},
- {fieldName:Common.TextFieldName.mainField3,fieldText:"showString3"},
- {fieldName:Common.TextFieldName.mainField4,fieldText:"showString4"},
- {fieldName:Common.TextFieldName.mediaTrack,fieldText:"mediaTrack"},
- {fieldName:Common.TextFieldName.statusBar,fieldText:"StatusBar"},
- {fieldName:Common.TextFieldName.mediaClock,fieldText:"12:34"}
- ]
- }
-
- createShow(1)
- var app = dataContainer.getApplication(initData.appID)
- sldUI.show (initData)
-
- try {
-
- compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1")
- compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2")
- compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3")
- compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4")
- compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack")
- compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" )
- compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock")
-
- }
- catch (e) {}
- destroyShow()
- console.debug("exit")
- }
- //Field with extra param
- function test_04_fake_param() {
- console.debug("enter")
- var initData = {
- appID:1,
- showStrings:[
- {fieldName:Common.TextFieldName.mainField1 ,fieldText:"showString1"},
- {fieldName:Common.TextFieldName.mainField2,fieldText:"showString2"},
- {fieldName:Common.TextFieldName.mainField3,fieldText:"showString3"},
- {fieldName:Common.TextFieldName.mainField4,fieldText:"showString4"},
- {fieldName:Common.TextFieldName.mediaTrack,fieldText:"mediaTrack"},
- {fieldName:Common.TextFieldName.statusBar,fieldText:"StatusBar",fakeParam:"FakeParam"},
- {fieldName:Common.TextFieldName.mediaClock,fieldText:"12:34"}
- ]
- }
-
- createShow(1)
- var app = dataContainer.getApplication(initData.appID)
- sldUI.show (initData)
-
- try {
-
- compare(app.hmiUIText.mainField1 , initData.showStrings[0].fieldText, "mainField1")
- compare(app.hmiUIText.mainField2 , initData.showStrings[1].fieldText, "mainField2")
- compare(app.hmiUIText.mainField3 , initData.showStrings[2].fieldText, "mainField3")
- compare(app.hmiUIText.mainField4 , initData.showStrings[3].fieldText, "mainField4")
- compare(app.hmiUIText.mediaTrack , initData.showStrings[4].fieldText, "mediaTrack")
- compare(app.hmiUIText.statusBar , initData.showStrings[5].fieldText, "StatusBar" )
- compare(app.hmiUIText.mediaClock , initData.showStrings[6].fieldText, "mediaClock")
-
- }
- catch (e) {}
- destroyShow()
- console.debug("exit")
- }
- //aligment of mainField1, mainField2
- function test_05_alignment() {
- console.debug("enter")
- var initData = {
- appID:1,
- showStrings:[],
- alignment:0,
- }
-
- createShow(1)
- var app = dataContainer.getApplication(initData.appID)
- sldUI.show (initData)
-
- try {
- //Magic with digits - because enum of text.Alighnment enum and sdl alignment doesn't match
- var a;
- if(app.hmiUITextAlignment === 1) a=0;
- if(app.hmiUITextAlignment === 2) a=1;
- if(app.hmiUITextAlignment === 4) a=2;
- compare(initData.alignment, a, "Alignment")
- initData.alignment=1
- sldUI.show (initData)
- var b;
- if(app.hmiUITextAlignment === 1) b=0;
- if(app.hmiUITextAlignment === 2) b=1;
- if(app.hmiUITextAlignment === 4) b=2;
- compare(initData.alignment, b, "Alignment")
- initData.alignment=2
- sldUI.show (initData)
- var c;
- if(app.hmiUITextAlignment === 1) c=0;
- if(app.hmiUITextAlignment === 2) c=1;
- if(app.hmiUITextAlignment === 4) c=2;
- compare(initData.alignment, c, "Alignment")
- }
- catch (e) {}
- destroyShow()
- console.debug("exit")
- }
- //pole bez parametra
- function test_06_no_param() {
- console.debug("enter")
- var initData = {
- appID:1,
- showStrings:[],
- graphic:{imageType: "DYNAMIC"},
- }
-
- createShow(1)
- var app = dataContainer.getApplication(initData.appID)
- sldUI.show (initData)
-
- try {
-
- compare(app.hmiUIText.image, undefined, "image")
-
- }
- catch (e) {}
- destroyShow()
- console.debug("exit")
- }
-}
-}
diff --git a/test/components/qt_hmi/src/tst_Slider.qml b/test/components/qt_hmi/src/tst_Slider.qml
deleted file mode 100644
index c88439d16..000000000
--- a/test/components/qt_hmi/src/tst_Slider.qml
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * @file tst_Slider.qml
- * @brief Test Case for Slider.
- * 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.
- */
-
-import QtTest 1.0
-import QtQuick 2.0
-import QtMultimedia 5.0
-import com.ford.sdl.hmi.dbus_adapter 1.0
-import com.ford.sdl.hmi.hw_buttons 1.0
-import com.ford.sdl.hmi.log4cxx 1.0
-import "../../../../src/components/qt_hmi/qml_model_qt5/controls"
-import "../../../../src/components/qt_hmi/qml_model_qt5/views"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api" as HmiApi
-import "../../../../src/components/qt_hmi/qml_model_qt5/models"
-import "../../../../src/components/qt_hmi/qml_model_qt5/popups"
-import "../../../../src/components/qt_hmi/qml_model_qt5/hmi_api/Common.js" as Common
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Constants.js" as Constants
-import "../../../../src/components/qt_hmi/qml_model_qt5/models/Internal.js" as Internal
-
-Item {
- TestCase {
- name: "Slider"
- when: windowShown
- property var mainWindowComponent : Qt.createComponent("./../../../../src/components/qt_hmi/qml_model_qt5/MainWindow.qml")
- property var mainObject
- property var sldUI
- property var dataContainer
- property var sliderPopup
- property var timer
-
- function createSlider() {
- mainObject = mainWindowComponent.createObject(parent)
- var mainScreen = mainObject.getMainScreen()
- mainScreen.visible = true
- sldUI = mainObject.getUIProxy()
- dataContainer = mainObject.getDataStorage()
- sliderPopup = mainObject.getSlider()
- timer = sliderPopup.getTimer()
- }
-
-
- function destroySlider() {
- mainObject.destroy()
- }
-
- function test_01_timeoutZero() {
- console.debug("enter")
- var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:0, appID:1}
- createSlider()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
- var actualResult = sldUI.slider(initData)
- try {
- compare(actualResult.sliderPosition, initData.position, "slider position")
- } catch(e){}
- destroySlider()
- console.debug("exit")
- }
-
- function test_02_changePosition() {
- console.debug("enter")
- var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1}
- var expectedResult = {position : 2, resultCode : Common.Result.SUCCESS}
- createSlider()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
- sliderPopup.onReady.connect(function simulateUserAction(){sliderPopup.position = expectedResult.position})
-
- sldUI.slider(initData)
-
- timer.onTriggered()
- try {
- compare(dataContainer.uiSlider.position, expectedResult.position, "slider position")
- compare(sliderPopup.resultCode, expectedResult.resultCode, "result code")
- } catch (e) {}
- destroySlider()
- console.debug("exit")
- }
-
- function test_03_unChangedPosition() {
- console.debug("enter")
- var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1}
- var expectedResult = {position : 4, resultCode : Common.Result.SUCCESS}
- createSlider()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- sldUI.slider(initData)
-
- timer.onTriggered()
- try {
- compare(dataContainer.uiSlider.position, expectedResult.position, "slider position")
- compare(sliderPopup.resultCode, expectedResult.resultCode, "result code")
- } catch (e) {}
- destroySlider()
- console.debug("exit")
- }
-
-
- function test_04_changePositionBackPressed() {
- console.debug("enter")
- var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1}
- var expectedResult = {position : 4, resultCode : Common.Result.ABORTED}
- createSlider()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
- sliderPopup.onReady.connect(function simulateUserAction(){sliderPopup.position = expectedResult.position})
-
- sldUI.slider(initData)
- sliderPopup.getBackButton().clicked()
-
- try {
- compare(dataContainer.uiSlider.position, expectedResult.position, "slider position")
- compare(sliderPopup.resultCode, expectedResult.resultCode, "result code")
- } catch (e) {}
- destroySlider()
- console.debug("exit")
- }
-
- function test_05_secondCall() {
- console.debug("enter")
- var initData = {numTicks:9, position:4, sliderHeader:"header", sliderFooter:["footer"], timeout:1, appID:1}
- var expectedResult = {position : 5, resultCode : Common.Result.ABORTED}
- createSlider()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
- sliderPopup.onReady.connect(function simulateUserAction(){sliderPopup.position = expectedResult.position})
-
- sldUI.slider(initData)
- initData.position = 5
- var actualResult = sldUI.slider(initData)
-
- try {
- compare(actualResult.sliderPosition, expectedResult.position, "slider position")
- compare(actualResult.__retCode, expectedResult.resultCode, "result code")
- } catch (e) {}
- destroySlider()
- console.debug("exit")
- }
-
- function test_06_footerValueNoChange() {
- console.debug("enter")
- var initData = {numTicks:4, position:3, sliderHeader:"header", sliderFooter:["footer1", "footer2", "footer3", "footer4"], timeout:1, appID:1}
- var expectedResult = {position: 3, footers:["footer1", "footer2", "footer3", "footer4"]}
- createSlider()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
-
- sldUI.slider(initData)
-
- try {
- compare(sliderPopup.getFooterText().text, expectedResult.footers[expectedResult.position - 1], "current footer")
- } catch (e) {}
- destroySlider()
- console.debug("exit")
- }
-
- function test_07_footerValueChange() {
- console.debug("enter")
- var initData = {numTicks:4, position:2, sliderHeader:"header", sliderFooter:["footer1", "footer2", "footer3", "footer4"], timeout:1, appID:1}
- var expectedResult = {position: 3, footers:["footer1", "footer2", "footer3", "footer4"]}
- createSlider()
- dataContainer.addApplication({appName:"TestAppName", appId:initData.appID})
- sliderPopup.onReady.connect(function simulateUserAction(){
- var rect = sliderPopup.getBorderRectangle()
- console.debug("visible", sliderPopup.visible)
- mouseClick(rect, rect.width / initData.numTicks * expectedResult.position, 1)
- })
-
- sldUI.slider(initData)
-
- try {
- compare(sliderPopup.getFooterText().text, expectedResult.footers[expectedResult.position - 1], "current footer")
- } catch (e) {}
- destroySlider()
- console.debug("exit")
- }
-
- }
-}
diff --git a/test/components/rpc_base/CMakeLists.txt b/test/components/rpc_base/CMakeLists.txt
deleted file mode 100644
index 5ebf73541..000000000
--- a/test/components/rpc_base/CMakeLists.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/dbus/include
- ${CMAKE_SOURCE_DIR}/src/components/rpc_base/include
- ${GMOCK_INCLUDE_DIRECTORY}
- ${JSONCPP_INCLUDE_DIRECTORY}
-)
-
-set (LIBRARIES
- gmock
- gmock_main
- gtest
- gtest_main
- jsoncpp
-)
-
-set (SOURCES
- rpc_base_json_test.cc
- rpc_base_test.cc
-)
-
-if (${HMI_DBUS_API})
- # Build dbus tests
- include_directories(${DBUS_INCLUDE_DIRS})
- set (LIBRARIES ${LIBRARIES} DBus)
- set (SOURCES ${SOURCES} rpc_base_dbus_test.cc)
-endif ()
-
-create_test("rpc_base_test" ${SOURCES}" "${LIBRARIES})
diff --git a/test/components/rpc_base/rpc_base_dbus_test.cc b/test/components/rpc_base/rpc_base_dbus_test.cc
deleted file mode 100644
index 96ab291f6..000000000
--- a/test/components/rpc_base/rpc_base_dbus_test.cc
+++ /dev/null
@@ -1,689 +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 "gtest/gtest-spi.h"
-
-#include "dbus/dbus_message.h"
-#include "rpc_base/rpc_base.h"
-#include "rpc_base/rpc_base_dbus_inl.h"
-
-namespace test {
-using namespace rpc;
-
-enum TestEnum {
- kValue0,
- kValue1,
- kInvalidValue
-};
-
-bool IsValidEnum(TestEnum val) {
- return val == kValue0 || val == kValue1;
-}
-
-bool EnumFromJsonString(const std::string& value, TestEnum* enm) {
- if (value == "kValue0") {
- *enm = kValue0;
- return true;
- } else if (value == "kValue1") {
- *enm = kValue1;
- return true;
- } else {
- return false;
- }
-}
-
-const char* EnumToJsonString(TestEnum enm) {
- switch(enm) {
- case kValue0: return "kValue0";
- case kValue1: return "kValue1";
- default: return "UNKNOWN";
- }
-}
-
-struct DbusDeserialization: public testing::Test {
- dbus::MessageRef msgref;
- DbusDeserialization()
- : msgref(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)) {
- }
-};
-
-TEST_F(DbusDeserialization, DeserializeBool) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutBool(true);
- }
- {
- dbus::MessageReader reader(msgref);
- Boolean booln(&reader);
- ASSERT_TRUE(booln);
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeByte) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutByte(200);
- }
- {
- dbus::MessageReader reader(msgref);
- Integer<uint8_t, 1, 220> byte(&reader);
- ASSERT_TRUE(byte.is_initialized());
- ASSERT_TRUE(byte.is_valid());
- ASSERT_EQ(byte, 200);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeInt64) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutInt64(-1);
- }
- {
- dbus::MessageReader reader(msgref);
- Integer<int64_t, -5, 220> int64(&reader);
- ASSERT_TRUE(int64.is_initialized());
- ASSERT_TRUE(int64.is_valid());
- ASSERT_EQ(int64, -1);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeFloat) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutDouble(3.14);
- }
- {
- dbus::MessageReader reader(msgref);
- Float<3, 4> pi(&reader);
- ASSERT_TRUE(pi.is_initialized());
- ASSERT_TRUE(pi.is_valid());
- ASSERT_DOUBLE_EQ(pi, 3.14);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeString) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutString("Hello");
- }
- {
- dbus::MessageReader reader(msgref);
- String<3, 10> hello(&reader);
- ASSERT_TRUE(hello.is_initialized());
- ASSERT_TRUE(hello.is_valid());
- ASSERT_EQ(std::string(hello), "Hello");
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeEnum) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutInt32(kValue1);
- }
- {
- dbus::MessageReader reader(msgref);
- Enum<TestEnum> enm(&reader);
- ASSERT_TRUE(enm.is_initialized());
- ASSERT_TRUE(enm.is_valid());
- ASSERT_EQ(enm, kValue1);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeArray) {
- {
- dbus::MessageWriter writer(msgref);
- std::string array_signature;
- rpc::DbusSignature<Integer<int32_t, 1, 50> >(&array_signature);
- dbus::MessageWriter array_writer(&writer,
- dbus::kArray,
- array_signature.c_str());
- array_writer.PutInt32(5);
- array_writer.PutInt32(33);
- }
- {
- dbus::MessageReader reader(msgref);
- Array< Integer<int32_t, 1, 50>, 1, 100 > array(&reader);
- ASSERT_TRUE(array.is_initialized());
- ASSERT_TRUE(array.is_valid());
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- ASSERT_EQ(array.size(), 2u);
- ASSERT_EQ(array[0], 5);
- ASSERT_EQ(array[1], 33);
-
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeArrayOfArrays) {
- {
- dbus::MessageWriter writer(msgref);
- std::string array_signature;
- rpc::DbusSignature<Array<Integer<int32_t, 1, 50>, 1, 5> >(&array_signature);
- dbus::MessageWriter array_writer(&writer,
- dbus::kArray,
- array_signature.c_str());
- int val = 5;
- for (int i = 0; i < 2; ++i) {
- std::string subarray_signature;
- rpc::DbusSignature<Integer<int32_t, 1, 50> >(&subarray_signature);
- dbus::MessageWriter subarray_wirter(&array_writer, dbus::kArray,
- subarray_signature.c_str());
-
- subarray_wirter.PutInt32(val++);
- subarray_wirter.PutInt32(val++);
- }
- }
- {
- dbus::MessageReader reader(msgref);
- Array<Array<Integer<int32_t, 1, 50>, 1, 5>, 1, 5> array(&reader);
- ASSERT_TRUE(array.is_initialized());
- ASSERT_TRUE(array.is_valid());
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- ASSERT_EQ(array.size(), 2u);
- ASSERT_EQ(array[0].size(), 2u);
- ASSERT_EQ(array[1].size(), 2u);
- ASSERT_EQ(array[0][0], 5);
- ASSERT_EQ(array[0][1], 6);
- ASSERT_EQ(array[1][0], 7);
- ASSERT_EQ(array[1][1], 8);
-
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeMap) {
- {
- dbus::MessageWriter writer(msgref);
- std::string dict_signature;
- rpc::DbusSignature<Map<Enum<TestEnum>, 1, 5 >::value_type>(&dict_signature);
- dbus::MessageWriter array_writer(&writer,
- dbus::kArray,
- dict_signature.c_str());
- const char* keys[] = { "Hello", "World" };
- int val = 0;
- for (int i = 0; i < 2; ++i) {
- dbus::MessageWriter dictval_wirter(&array_writer, dbus::kDictEntry, NULL);
- dictval_wirter.PutString(keys[val]);
- dictval_wirter.PutInt32(val++);
- }
- }
- {
- dbus::MessageReader reader(msgref);
- Map<Enum<TestEnum>, 1, 5 > amap(&reader);
- ASSERT_TRUE(amap.is_initialized());
- ASSERT_TRUE(amap.is_valid());
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- ASSERT_EQ(amap.size(), 2u);
- ASSERT_EQ(amap["Hello"], kValue0);
- ASSERT_EQ(amap["World"], kValue1);
-
- }
-}
-
-TEST_F(DbusDeserialization, InconsistentTypesTest) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutString("Hello");
- }
- {
- dbus::MessageReader reader(msgref);
- Boolean badbool(&reader);
- ASSERT_TRUE(badbool.is_initialized());
- ASSERT_FALSE(badbool.is_valid());
- ASSERT_TRUE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeOptionalString) {
- {
- dbus::MessageWriter writer(msgref);
- dbus::MessageWriter optwriter(&writer, dbus::kStruct, NULL);
- optwriter.PutBool(true);
- optwriter.PutString("Hello dear");
- }
- {
- dbus::MessageReader reader(msgref);
- Optional<String<1, 100> > readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(std::string(*readback), "Hello dear");
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, DeserializeOptionalInt) {
- {
- dbus::MessageWriter writer(msgref);
- dbus::MessageWriter optwriter(&writer, dbus::kStruct, NULL);
- optwriter.PutBool(false);
- optwriter.PutInt32(42);
- }
- {
- dbus::MessageReader reader(msgref);
- Optional<Integer<int32_t, 1, 90> > readback(&reader);
- ASSERT_FALSE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeBool) {
- {
- Boolean true_bool(true);
- dbus::MessageWriter writer(msgref);
- true_bool.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Boolean readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(readback, true);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeInt8t) {
- {
- Integer<int8_t, 1, 100> int8(42);
- dbus::MessageWriter writer(msgref);
- int8.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Integer<int8_t, 1, 100> readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(readback, 42);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, BadSerializeDeserializeInt8t) {
- {
- Integer<int8_t, 1, 12> int8(42);
- dbus::MessageWriter writer(msgref);
- int8.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Integer<int8_t, 1, 12> readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_FALSE(readback.is_valid());
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeInt64t) {
- {
- Integer<int64_t, 1, 0xFFFFFFFFFF> int64(0xFFFFFFFFF1);
- dbus::MessageWriter writer(msgref);
- int64.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Integer<int64_t, 1, 0xFFFFFFFFFF> readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(readback, 0xFFFFFFFFF1);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeDouble) {
- {
- Float<1, 5> flt(3.14);
- dbus::MessageWriter writer(msgref);
- flt.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Float<1, 5> readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_DOUBLE_EQ(readback, 3.14);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeString) {
- {
- String<1, 12> hello("Hello");
- dbus::MessageWriter writer(msgref);
- hello.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- String<1, 12> readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(std::string(readback), "Hello");
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeEnum) {
- {
- Enum<TestEnum> te(kValue1);
- dbus::MessageWriter writer(msgref);
- te.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Enum<TestEnum> readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(readback, kValue1);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeArray) {
- {
- Array<Integer<int32_t, 1, 100>, 1, 90 > ints;
- ints.push_back(42);
- ints.push_back(17);
- dbus::MessageWriter writer(msgref);
- ints.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Array<Integer<int32_t, 1, 100>, 1, 90 > readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(readback[0], 42);
- ASSERT_EQ(readback[1], 17);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeMap) {
- {
- Map<Integer<int32_t, 1, 100>, 1, 90 > ints;
- ints["first"] = 42;
- ints["second"] = 17;
- dbus::MessageWriter writer(msgref);
- ints.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Map<Integer<int32_t, 1, 100>, 1, 90 > readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(readback["first"], 42);
- ASSERT_EQ(readback["second"], 17);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusDeserialization, SerializeDeserializeMapOfArrays) {
- {
- Map<Array<Integer<int32_t, 1, 100>, 1, 5>,1, 90 > ints;
- ints["first"].push_back(1);
- ints["first"].push_back(42);
- ints["second"].push_back(17);
- ints["second"].push_back(3);
- dbus::MessageWriter writer(msgref);
- ints.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msgref);
- Map<Array<Integer<int32_t, 1, 100>, 1, 5>,1, 90 > readback(&reader);
- ASSERT_TRUE(readback.is_initialized());
- ASSERT_TRUE(readback.is_valid());
- ASSERT_EQ(readback.size(), 2u);
- ASSERT_EQ(readback["first"].size(), 2u);
- ASSERT_EQ(readback["second"].size(), 2u);
- ASSERT_EQ(readback["first"][0], 1);
- ASSERT_EQ(readback["first"][1], 42);
- ASSERT_EQ(readback["second"][0], 17);
- ASSERT_EQ(readback["second"][1], 3);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST(ValidatedTypes, TestBooleanDbusSignature) {
- std::string sign;
- DbusSignature<Boolean>(&sign);
- ASSERT_EQ(sign, "b");
-}
-
-TEST(ValidatedTypes, TestIntDbusSignature) {
- std::string sign;
- DbusSignature<Integer<int32_t, 1, 2> >(&sign);
- ASSERT_EQ(sign, "i");
-}
-
-TEST(ValidatedTypes, TestFloatDbusSignature) {
- std::string sign;
- DbusSignature<Float<1, 2> >(&sign);
- ASSERT_EQ(sign, "d");
-}
-
-TEST(ValidatedTypes, TestStringDbusSignature) {
- std::string sign;
- DbusSignature<String<1, 2> >(&sign);
- ASSERT_EQ(sign, "s");
-}
-
-TEST(ValidatedTypes, TestEnumDbusSignature) {
- std::string sign;
- DbusSignature<Enum<TestEnum> >(&sign);
- ASSERT_EQ(sign, "i");
-}
-
-TEST(ValidatedTypes, TestIntArrayDbusSignature) {
- std::string sign;
- DbusSignature< Array<Integer<int32_t, 1, 2>, 1, 3> >(&sign);
- ASSERT_EQ(sign, "ai");
-}
-
-TEST(ValidatedTypes, TestIntArrayArrayDbusSignature) {
- std::string sign;
- DbusSignature< Array<Array<Integer<int32_t, 1, 2>, 1, 3>, 4, 5> >(&sign);
- ASSERT_EQ(sign, "aai");
-}
-
-TEST(ValidatedTypes, TestMapDbusSignature) {
- std::string sign;
- DbusSignature< Map<Integer<int32_t, 1, 2>, 3, 4> >(&sign);
- ASSERT_EQ(sign, "a{si}");
-}
-
-TEST(ValidatedTypes, TestMandatoryEnumDbusSignature) {
- std::string sign;
- DbusSignature< Enum<TestEnum> >(&sign);
- ASSERT_EQ(sign, "i");
-}
-
-TEST(ValidatedTypes, TestOptionalEnumDbusSignature) {
- std::string sign;
- DbusSignature< Optional<Enum<TestEnum> > >(&sign);
- ASSERT_EQ(sign, "(bi)");
-}
-
-TEST(ValidatedTypes, TestOptionalFloatArrayDbusSignature) {
- std::string sign;
- DbusSignature< Optional< Array<Float<1,2>, 3, 4> > >(&sign);
- ASSERT_EQ(sign, "(bad)");
-}
-
-TEST(DbusMessageConstructionTest, DbusMessageConstruction) {
- DBusMessage* rawmsg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL);
- dbus::MessageRef msgref(rawmsg);
-}
-
-class DbusTest: public testing::Test {
-public:
- dbus::MessageRef msgref;
- DbusTest():
- msgref(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)) {
- }
-};
-
-TEST_F(DbusTest, DbusWriterConstructionTest) {
- dbus::MessageWriter writer(msgref);
-}
-
-TEST_F(DbusTest, DbusEmptyMessageReaderTest) {
- dbus::MessageReader reader(msgref);
- ASSERT_TRUE(reader.has_failed());
-}
-
-TEST_F(DbusTest, DbusMessageWriterBoolWriteRead) {
- dbus::MessageWriter writer(msgref);
- writer.PutBool(true);
- dbus::MessageReader reader(msgref);
- bool redback_value = reader.TakeBool();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_TRUE(redback_value);
-}
-
-TEST_F(DbusTest, DbusMessageWriterInt32WriteRead) {
- dbus::MessageWriter writer(msgref);
- writer.PutInt32(42);
- dbus::MessageReader reader(msgref);
- int32_t readback_value = reader.TakeInt32();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_EQ(readback_value, 42);
-}
-
-TEST_F(DbusTest, DbusMessageWriterStringWriteRead) {
- dbus::MessageWriter writer(msgref);
- writer.PutString("Hello DBus!");
- dbus::MessageReader reader(msgref);
- std::string readback_value = reader.TakeString();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_EQ(readback_value, "Hello DBus!");
-}
-
-TEST_F(DbusTest, DbusMultipleParamsReadWrite) {
- {
- dbus::MessageWriter writer(msgref);
- writer.PutString("Hello DBus!");
- writer.PutInt16(42);
- writer.PutDouble(3.14);
- }
- {
- dbus::MessageReader reader(msgref);
- std::string readback_string = reader.TakeString();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_EQ(readback_string, "Hello DBus!");
- int16_t readback_int = reader.TakeInt16();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_EQ(readback_int, 42);
- double readback_double = reader.TakeDouble();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_DOUBLE_EQ(readback_double, 3.14);
- ASSERT_FALSE(reader.HasNext());
- }
-}
-
-TEST_F(DbusTest, DbusArrayTest) {
- {
- dbus::MessageWriter writer(msgref);
- dbus::MessageWriter array_writer(&writer, dbus::kArray,
- DBUS_TYPE_INT16_AS_STRING);
- array_writer.PutInt16(3);
- array_writer.PutInt16(4);
- array_writer.PutInt16(5);
- }
- {
- dbus::MessageReader reader(msgref);
- dbus::MessageReader array_reader = reader.TakeArrayReader();
- int16_t readback_val = array_reader.TakeInt16();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_EQ(readback_val, 3);
- readback_val = array_reader.TakeInt16();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_EQ(readback_val, 4);
- readback_val = array_reader.TakeInt16();
- ASSERT_FALSE(reader.has_failed());
- ASSERT_EQ(readback_val, 5);
- ASSERT_FALSE(array_reader.HasNext());
- }
-}
-
-class DbusFailuresTest: public testing::Test {
-public:
- dbus::MessageRef int_msg;
- DbusFailuresTest()
- : int_msg(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL)) {
- dbus::MessageWriter writer(int_msg);
- writer.PutInt64(42);
- }
-};
-
-TEST_F(DbusFailuresTest, DbusInconsistentTypeReadFailureTest) {
- dbus::MessageReader reader(int_msg);
- std::string str = reader.TakeString();
- ASSERT_EQ(str, std::string(""));
- ASSERT_TRUE(reader.has_failed());
-}
-
-TEST_F(DbusFailuresTest, DbusNonExistentArrayReadTest) {
- dbus::MessageReader reader(int_msg);
- ASSERT_FALSE(reader.has_failed());
- dbus::MessageReader array_reader = reader.TakeArrayReader();
- ASSERT_TRUE(array_reader.has_failed());
- ASSERT_TRUE(reader.has_failed());
- int64_t val = array_reader.TakeInt64();
- ASSERT_TRUE(array_reader.has_failed());
- ASSERT_EQ(val, 0);
-}
-
-
-} // namespace test
diff --git a/test/components/rpc_base/rpc_base_json_test.cc b/test/components/rpc_base/rpc_base_json_test.cc
deleted file mode 100644
index a5566512c..000000000
--- a/test/components/rpc_base/rpc_base_json_test.cc
+++ /dev/null
@@ -1,378 +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 "json/value.h"
-#include "rpc_base/rpc_base.h"
-#include "rpc_base/rpc_base_json_inl.h"
-
-namespace test {
-using namespace rpc;
-using Json::Value;
-
-namespace {
-enum TestEnum {
- kValue0,
- kValue1,
- kInvalidValue
-};
-
-bool IsValidEnum(TestEnum val) {
- return val == kValue0 || val == kValue1;
-}
-
-bool EnumFromJsonString(const std::string& value, TestEnum* enm) {
- if (value == "kValue0") {
- *enm = kValue0;
- return true;
- } else if (value == "kValue1") {
- *enm = kValue1;
- return true;
- } else {
- return false;
- }
-}
-
-const char* EnumToJsonString(TestEnum enm) {
- switch(enm) {
- case kValue0: return "kValue0";
- case kValue1: return "kValue1";
- default: return "UNKNOWN";
- }
-}
-
-} // namespace
-
-TEST(ValidatedTypesJson, BooleanFromJsonTest) {
- Value val(true);
- Boolean boolean(&val);
- ASSERT_TRUE(boolean.is_initialized());
- ASSERT_TRUE(boolean.is_valid());
- ASSERT_EQ(boolean, true);
- Value readback = boolean.ToJsonValue();
- ASSERT_TRUE(readback.isBool());
- ASSERT_EQ(readback.asBool(), true);
-}
-
-TEST(ValidatedTypesJson, BooleanNullTest) {
- Boolean boolean(&Value::null);
- ASSERT_TRUE(boolean.is_initialized());
- ASSERT_FALSE(boolean.is_valid());
-}
-
-TEST(ValidatedTypesJson, BooleanAbsentValueTest) {
- Value* novalue = NULL;
- Boolean boolean(novalue);
- ASSERT_FALSE(boolean.is_initialized());
- ASSERT_FALSE(boolean.is_valid());
-}
-
-TEST(ValidatedTypesJson, BooleanFromInvalidJsonTest) {
- Value inv(7);
- Boolean boolean(&inv);
- ASSERT_TRUE(boolean.is_initialized());
- ASSERT_FALSE(boolean.is_valid());
-}
-
-TEST(ValidatedTypesJson, IntegerFromJsonTest) {
- Value int_val(42);
- Integer<int32_t, -5, 192> integer(&int_val);
- ASSERT_TRUE(integer.is_initialized());
- ASSERT_TRUE(integer.is_valid());
- Value readback = integer.ToJsonValue();
- ASSERT_TRUE(readback.isInt());
- ASSERT_EQ(readback.asInt(), 42);
-}
-
-TEST(ValidatedTypesJson, IntegerNullTest) {
- Integer<int32_t, -5, 192> integer(&Value::null);
- ASSERT_TRUE(integer.is_initialized());
- ASSERT_FALSE(integer.is_valid());
-}
-
-TEST(ValidatedTypesJson, IntegerAbsentValueTest) {
- Value* novalue = NULL;
- Integer<int32_t, -5, 192> integer(novalue);
- ASSERT_FALSE(integer.is_initialized());
- ASSERT_FALSE(integer.is_valid());
-}
-
-TEST(ValidatedTypesJson, IntegerFromOverflowingJsonTest) {
- Value int_val(0xFFFFFFFFFFll);
- Integer<int32_t, -5, 192> integer(&int_val);
- ASSERT_TRUE(integer.is_initialized());
- ASSERT_FALSE(integer.is_valid());
-}
-
-TEST(ValidatedTypesJson, IntegerFromInvalidJsonTest) {
- Value str_val("Hello");
- Integer<int8_t, -3, 15> integer(&str_val);
- ASSERT_TRUE(integer.is_initialized());
- ASSERT_FALSE(integer.is_valid());
-}
-
-TEST(ValidatedTypesJson, IntegerFromOutOfRangeValueTest) {
- Value big_int_val(500);
- Integer<int8_t, 0, 100> integer(&big_int_val);
- ASSERT_TRUE(integer.is_initialized());
- ASSERT_FALSE(integer.is_valid());
-}
-
-TEST(ValidatedTypesJson, FloatFromJsonTest) {
- Value float_value(4.2);
- Float<1, 7> flt(&float_value);
- ASSERT_TRUE(flt.is_initialized());
- ASSERT_TRUE(flt.is_valid());
- Value readback = flt.ToJsonValue();
- ASSERT_TRUE(readback.isDouble());
- ASSERT_EQ(readback.asDouble(), 4.2);
-}
-
-TEST(ValidatedTypesJson, FloatNullTest) {
- Float<1, 7> flt(&Value::null);
- ASSERT_TRUE(flt.is_initialized());
- ASSERT_FALSE(flt.is_valid());
-}
-
-TEST(ValidatedTypesJson, FloatAbsentValueTest) {
- Value* novalue = NULL;
- Float<1, 7> flt(novalue);
- ASSERT_FALSE(flt.is_initialized());
- ASSERT_FALSE(flt.is_valid());
-}
-
-TEST(ValidatedTypesJson, FloatFromInvalidJsonTest) {
- Value str_val("Hello");
- Float<-5, 3> flt(&str_val);
- ASSERT_TRUE(flt.is_initialized());
- ASSERT_FALSE(flt.is_valid());
-}
-
-TEST(ValidatedTypesJson, StringFromJsonTest) {
- Value str_val("Hello");
- String<1, 42> str(&str_val);
- ASSERT_TRUE(str.is_initialized());
- ASSERT_TRUE(str.is_valid());
- Value readback = str.ToJsonValue();
- ASSERT_TRUE(readback.isString());
- ASSERT_STREQ(readback.asCString(), "Hello");
-}
-
-TEST(ValidatedTypesJson, StringNullTest) {
- String<1, 42> str(&Value::null);
- ASSERT_TRUE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
-}
-
-TEST(ValidatedTypesJson, StringFromInvalidJsonTest) {
- Value int_val(42);
- String<1, 500> str(&int_val);
- ASSERT_TRUE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
-}
-
-TEST(ValidatedTypesJson, StringAbsentValueTest) {
- Value* novalue = NULL;
- String<1, 500> str(novalue);
- ASSERT_FALSE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
-}
-
-TEST(ValidatedTypesJson, StringFromToLongJsonString) {
- Value str_val("Too long string");
- String<1, 5> str(&str_val);
- ASSERT_TRUE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
-}
-
-TEST(ValidatedTypesJson, EnumFromJsonTest) {
- Value str_enum("kValue1");
- Enum<TestEnum> enm(&str_enum);
- ASSERT_TRUE(enm.is_initialized());
- ASSERT_TRUE(enm.is_valid());
- Value readback = enm.ToJsonValue();
- ASSERT_TRUE(readback.isString());
- ASSERT_STREQ(readback.asCString(), "kValue1");
-}
-
-TEST(ValidatedTypesJson, EnumNullTest) {
- Enum<TestEnum> enm(&Value::null);
- ASSERT_TRUE(enm.is_initialized());
- ASSERT_FALSE(enm.is_valid());
-}
-
-TEST(ValidatedTypesJson, EnumAbsentValueTest) {
- Value* novalue = NULL;
- Enum<TestEnum> enm(novalue);
- ASSERT_FALSE(enm.is_initialized());
- ASSERT_FALSE(enm.is_valid());
-}
-
-TEST(ValidatedTypesJson, EnumFromInvalidJsonTest) {
- Value str_value("Random string");
- Enum<TestEnum> enm(&str_value);
- ASSERT_TRUE(enm.is_initialized());
- ASSERT_FALSE(enm.is_valid());
-}
-
-TEST(ValidatedTypesJson, ArrayFromJsonTest) {
- Value array_value;
- array_value.append(Value("haha"));
- array_value.append(Value("hoho"));
- Array<String<1, 32>, 2, 5> arr(&array_value);
- ASSERT_TRUE(arr.is_initialized());
- ASSERT_TRUE(arr.is_valid());
- Value readback = arr.ToJsonValue();
- ASSERT_TRUE(readback.isArray());
- ASSERT_EQ(readback.size(), array_value.size());
-}
-
-TEST(ValidatedTypesJson, MandatoryArrayNullTest) {
- Array<String<1, 32>, 2, 5> arr(&Value::null);
- ASSERT_TRUE(arr.is_initialized());
- ASSERT_FALSE(arr.is_valid());
-}
-
-TEST(ValidatedTypesJson, ArrayAbsentValueTest) {
- Value* novalue = NULL;
- Array<String<1, 32>, 2, 5> arr(novalue);
- ASSERT_FALSE(arr.is_initialized());
- ASSERT_FALSE(arr.is_valid());
-}
-
-TEST(ValidatedTypesJson, MandatoryMapNullTest) {
- Map<String<1, 32>, 2, 5> map(&Value::null);
- ASSERT_TRUE(map.is_initialized());
- ASSERT_FALSE(map.is_valid());
-}
-
-TEST(ValidatedTypesJson, OptionalMapAbsentValueTest) {
- Value* novalue = NULL;
- Optional< Map<String<1, 32>, 0, 5> > map(novalue);
- ASSERT_FALSE(map.is_initialized());
- ASSERT_TRUE(map.is_valid());
-}
-
-TEST(ValidatedTypesJson, ArrayFromInvalidJsonTest) {
- Value array_value;
- array_value.append(Value("Hello"));
- array_value.append(Value("World"));
- Array<Integer<int8_t, 0, 32>, 2, 4> int_array(&array_value);
- ASSERT_TRUE(int_array.is_initialized());
- ASSERT_FALSE(int_array.is_valid());
- ASSERT_EQ(int_array.size(), array_value.size());
-}
-
-TEST(ValidatedTypesJson, ArrayFromNonArrayJsonTest) {
- Value array_value = "Hello";
- Array<Integer<int8_t, 0, 32>, 0, 4> int_array(&array_value);
- ASSERT_TRUE(int_array.is_initialized());
- ASSERT_FALSE(int_array.is_valid());
- ASSERT_TRUE(int_array.empty());
-}
-
-TEST(ValidatedTypesJson, MapFromNonArrayJsonTest) {
- Value array_value = "Hello";
- Map<Integer<int8_t, 0, 32>, 0, 4> int_map(&array_value);
- ASSERT_TRUE(int_map.is_initialized());
- ASSERT_FALSE(int_map.is_valid());
- ASSERT_TRUE(int_map.empty());
-}
-
-TEST(ValidatedTypesJson, OptionalBoolFromJsonTest) {
- Value bool_value(true);
- Optional< Boolean > optional_bool;
- *optional_bool = Boolean(&bool_value);
- ASSERT_TRUE(optional_bool.is_initialized());
- ASSERT_TRUE(optional_bool.is_valid());
- Value readback = optional_bool->ToJsonValue();
- ASSERT_TRUE(readback.isBool());
- ASSERT_EQ(readback.asBool(), true);
-}
-
-TEST(ValidatedTypesJson, OptionalBoolFromAbsentValueTest) {
- Value* none = NULL;
- Optional< Boolean > optional_bool;
- *optional_bool = Boolean(none);
- ASSERT_FALSE(optional_bool.is_initialized());
- // It is ok for Optional value to be absent
- ASSERT_TRUE(optional_bool.is_valid());
-}
-
-TEST(ValidatedTypesJson, OptionalBoolFromNullValueTest) {
- Optional< Boolean > optional_bool;
- *optional_bool = Boolean(&Value::null);
- ASSERT_TRUE(optional_bool.is_initialized());
- // Optional values should not be absent
- ASSERT_FALSE(optional_bool.is_valid());
-}
-
-TEST(ValidatedTypesJson, NullableIntFromNullValueTest) {
- Nullable< Integer<int8_t, 1, 15> > nullable_int(&Value::null);
- ASSERT_TRUE(nullable_int.is_initialized());
- ASSERT_TRUE(nullable_int.is_valid());
- ASSERT_TRUE(nullable_int.is_null());
-}
-
-TEST(ValidatedTypesJson, NullableIntFromNonNullValueTest) {
- Value json(3);
- Nullable< Integer<int8_t, 1, 15> > nullable_int(&json);
- ASSERT_TRUE(nullable_int.is_initialized());
- ASSERT_TRUE(nullable_int.is_valid());
- ASSERT_FALSE(nullable_int.is_null());
- ASSERT_EQ(3, nullable_int);
-}
-
-TEST(ValidatedTypesJson, NullableIntFromAbsentValueTest) {
- Value* noval = NULL;
- Nullable< Integer<int8_t, 1, 15> > nullable_int(noval);
- ASSERT_FALSE(nullable_int.is_initialized());
- ASSERT_FALSE(nullable_int.is_valid());
- ASSERT_FALSE(nullable_int.is_null());
-}
-
-TEST(ValidatedTypesJson, OptionalIntFromJsonTest) {
- Value int_value(42);
- Optional< Integer<int64_t, 42, 43> > optional_int;
- *optional_int = Integer<int64_t, 42, 43> (&int_value);
- ASSERT_TRUE(optional_int.is_initialized());
- ASSERT_TRUE(optional_int.is_valid());
- Value readback = optional_int->ToJsonValue();
- ASSERT_TRUE(readback.isInt());
- ASSERT_EQ(readback.asInt(), 42);
-}
-
-
-} // namespace test
-
-
-
diff --git a/test/components/rpc_base/rpc_base_test.cc b/test/components/rpc_base/rpc_base_test.cc
deleted file mode 100644
index ce7ea7a5c..000000000
--- a/test/components/rpc_base/rpc_base_test.cc
+++ /dev/null
@@ -1,438 +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 "json/writer.h"
-#include "rpc_base/gtest_support.h"
-#include "rpc_base/rpc_base.h"
-#include "rpc_base/rpc_base_json_inl.h"
-
-namespace test {
-using namespace rpc;
-
-namespace {
-
-enum TestEnum {
- kValue0,
- kValue1,
- kInvalidValue
-};
-
-bool IsValidEnum(TestEnum val) {
- return val == kValue0 || val == kValue1;
-}
-
-} // namespace
-
-TEST(ValidatedTypes, TestBooleanDefaultConstructor) {
- Boolean boolean;
- ASSERT_FALSE(boolean.is_valid());
- ASSERT_FALSE(boolean.is_initialized());
- boolean = true;
- bool val = boolean;
- ASSERT_TRUE(val);
- ASSERT_TRUE(boolean.is_initialized());
-}
-
-TEST(ValidatedTypes, TestBooleanInitializingConstructor) {
- Boolean true_boolean(true);
- ASSERT_RPCTYPE_VALID(true_boolean);
- ASSERT_TRUE(true_boolean.is_initialized());
- ASSERT_EQ(true_boolean, true);
-
- Boolean false_boolean(false);
- ASSERT_RPCTYPE_VALID(false_boolean);
- ASSERT_TRUE(false_boolean.is_initialized());
- ASSERT_EQ(false_boolean, false);
-}
-
-TEST(ValidatedTypes, TestIntegerDefaultConstructor) {
- Integer<int32_t, 4, 100> integer;
- ASSERT_FALSE(integer.is_valid());
- ASSERT_FALSE(integer.is_initialized());
- ASSERT_EQ(integer, 4);
- integer = 5;
- ASSERT_RPCTYPE_VALID(integer);
- ASSERT_TRUE(integer.is_initialized());
- ASSERT_EQ(integer, 5);
- integer = 700;
- ASSERT_FALSE(integer.is_valid());
- ASSERT_TRUE(integer.is_initialized());
- ASSERT_EQ(integer, 700);
-}
-
-TEST(ValidatedTypes, TestIntegerInitializingConstructor) {
- Integer<int32_t, 0, 100> invalid_integer(200);
- ASSERT_FALSE(invalid_integer.is_valid());
- ASSERT_TRUE(invalid_integer.is_initialized());
- ASSERT_EQ(invalid_integer, 200);
-
- Integer<int32_t, 0, 100> valid_integer(42);
- ASSERT_RPCTYPE_VALID(valid_integer);
- ASSERT_TRUE(valid_integer.is_initialized());
- ASSERT_EQ(valid_integer, 42);
-}
-
-TEST(ValidatedTypes, TestFloatDefaultConstructor) {
- Float<-5, 12> flt;
- ASSERT_FALSE(flt.is_initialized());
- ASSERT_FALSE(flt.is_valid());
- ASSERT_EQ(flt, -5.);
-
- flt = 12.3;
- ASSERT_TRUE(flt.is_initialized());
- ASSERT_FALSE(flt.is_valid());
- ASSERT_EQ(flt, 12.3);
-}
-
-TEST(ValidatedTypes, TestFloatInitializingConstructor) {
- Float<13, 999, 10, 10> flt(4);
- ASSERT_TRUE(flt.is_initialized());
- ASSERT_RPCTYPE_VALID(flt);
- ASSERT_EQ(flt, 4.);
-
- flt = 1.2;
- ASSERT_FALSE(flt.is_valid());
- ASSERT_EQ(flt, 1.2);
-}
-
-TEST(ValidatedTypes, TestStringDefaultConstructor) {
- String<1, 6> str;
- ASSERT_FALSE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
- std::string val = str;
- ASSERT_EQ(val, "");
- str = "Test";
- ASSERT_TRUE(str.is_initialized());
- ASSERT_RPCTYPE_VALID(str);
- val = str;
- ASSERT_EQ(val, "Test");
- str = "Long string";
- ASSERT_TRUE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
- val = str;
- ASSERT_EQ(val, "Long string");
-}
-
-TEST(ValidatedTypes, TestStringLengthRange) {
- String<4, 10> str;
- ASSERT_FALSE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
- str = "Hello";
- ASSERT_TRUE(str.is_initialized());
- ASSERT_RPCTYPE_VALID(str);
- str = "Sh";
- ASSERT_TRUE(str.is_initialized());
- ASSERT_FALSE(str.is_valid());
-}
-
-TEST(ValidatedTypes, TestStringInitializingConstructor) {
- String<1, 4> invalid_str("A string");
- ASSERT_TRUE(invalid_str.is_initialized());
- ASSERT_FALSE(invalid_str.is_valid());
-}
-
-TEST(ValidatedTypes, TestStringAssignment) {
- String<1, 5> short_str("Short");
- String<1, 10> long_str("A long string");
- short_str = long_str;
- ASSERT_TRUE(short_str.is_initialized());
- ASSERT_FALSE(short_str.is_valid());
-}
-
-TEST(ValidatedTypes, TestArray) {
- Array<String<1, 5>, 2, 10> arr;
- ASSERT_FALSE(arr.is_initialized());
- ASSERT_FALSE(arr.is_valid());
- arr.push_back("Text");
- arr.push_back("Dext");
- ASSERT_RPCTYPE_VALID(arr);
- ASSERT_TRUE(arr.is_initialized());
- arr.push_back("Too long");
- ASSERT_FALSE(arr.is_valid());
-}
-
-TEST(ValidatedTypes, TestArrayInitializingConstructor) {
- std::vector<std::string> strings;
- strings.push_back("One");
- strings.push_back("Two");
- Array<String<1, 5>, 2, 10> arr(strings);
- ASSERT_TRUE(arr.is_initialized());
- ASSERT_RPCTYPE_VALID(arr);
-}
-
-TEST(ValidatedTypes, TestOptionalEmptyArray) {
- Optional< Array<Integer<int8_t, 0, 10>, 0, 5> > ai;
- ASSERT_RPCTYPE_VALID(ai);
- ASSERT_FALSE(ai.is_initialized());
- Json::FastWriter fw;
- std::string serialized = fw.write(ai.ToJsonValue());
- ASSERT_EQ(serialized, "[]\n");
-}
-
-TEST(ValidatedTypes, TestMandatoryEmptyArray) {
- Array<Integer<int8_t, 0, 10>, 0, 5> ai;
- ASSERT_FALSE(ai.is_valid());
- ASSERT_FALSE(ai.is_initialized());
- Json::FastWriter fw;
- std::string serialized = fw.write(ai.ToJsonValue());
- ASSERT_EQ(serialized, "[]\n");
-}
-
-TEST(ValidatedTypes, TestMap) {
- Map<String<1, 6>, 2, 10> map;
- ASSERT_FALSE(map.is_initialized());
- ASSERT_FALSE(map.is_valid());
- map["a"] = "Hello";
- map["b"] = "World";
- ASSERT_TRUE(map.is_initialized());
- ASSERT_RPCTYPE_VALID(map);
- map["c"] = "Too long";
- ASSERT_FALSE(map.is_valid());
-}
-
-TEST(ValidatedTypes, TestMapInitializingConstructor) {
- std::map< std::string, std::string > init_map;
- init_map["a"] = "Hello";
- init_map["b"] = "World";
- Map<String<1, 6>, 2, 10 > map(init_map);
- ASSERT_TRUE(map.is_initialized());
- ASSERT_RPCTYPE_VALID(map);
-}
-
-TEST(ValidatedTypes, TestEmptyMandatoryMap) {
- Map<Integer<int8_t, 0, 10>, 0, 5> im;
- ASSERT_FALSE(im.is_valid());
- ASSERT_FALSE(im.is_initialized());
- Json::FastWriter fw;
- std::string serialized = fw.write(im.ToJsonValue());
- ASSERT_EQ(serialized, "{}\n");
-}
-
-TEST(ValidatedTypes, TestEnumConstructor) {
- Enum<TestEnum> te;
- ASSERT_FALSE(te.is_initialized());
- ASSERT_FALSE(te.is_valid());
- te = kValue1;
- ASSERT_TRUE(te.is_initialized());
- ASSERT_RPCTYPE_VALID(te);
- ASSERT_EQ(te, kValue1);
- te = TestEnum(42);
- ASSERT_TRUE(te.is_initialized());
- ASSERT_FALSE(te.is_valid());
-}
-
-TEST(ValidatedTypes, TestNullableConstructor) {
- Nullable< Integer<int8_t, 2, 10> >nullable_int;
- ASSERT_FALSE(nullable_int.is_initialized());
- ASSERT_FALSE(nullable_int.is_null());
- ASSERT_FALSE(nullable_int.is_valid());
- nullable_int = 5;
- ASSERT_TRUE(nullable_int.is_initialized());
- ASSERT_FALSE(nullable_int.is_null());
- ASSERT_RPCTYPE_VALID(nullable_int);
- nullable_int.set_to_null();
- ASSERT_TRUE(nullable_int.is_initialized());
- ASSERT_TRUE(nullable_int.is_null());
- ASSERT_RPCTYPE_VALID(nullable_int);
-}
-
-TEST(ValidatedTypes, TestOptionalNullableConstructor) {
- Optional< Nullable< Integer<int8_t, 2, 10> > > optional_nullable_int;
- ASSERT_FALSE(optional_nullable_int.is_initialized());
- ASSERT_FALSE(optional_nullable_int->is_null());
- ASSERT_RPCTYPE_VALID(optional_nullable_int);
- ASSERT_FALSE(optional_nullable_int);
-
- *optional_nullable_int = 9;
- ASSERT_TRUE(optional_nullable_int.is_initialized());
- ASSERT_FALSE(optional_nullable_int->is_null());
- ASSERT_RPCTYPE_VALID(optional_nullable_int);
- ASSERT_EQ(9, *optional_nullable_int);
- ASSERT_TRUE(optional_nullable_int);
-
- optional_nullable_int->set_to_null();
- ASSERT_TRUE(optional_nullable_int.is_initialized());
- ASSERT_TRUE(optional_nullable_int->is_null());
- ASSERT_RPCTYPE_VALID(optional_nullable_int);
-}
-
-TEST(ValidatedTypes, TestOptionalConstructor) {
- Optional< Integer<int16_t, 3, 15> > optional_int;
- ASSERT_FALSE(optional_int.is_initialized());
- ASSERT_RPCTYPE_VALID(optional_int);
- *optional_int = 42;
- ASSERT_TRUE(optional_int.is_initialized());
- ASSERT_FALSE(optional_int.is_valid());
- *optional_int = 12;
- ASSERT_TRUE(optional_int.is_initialized());
- ASSERT_RPCTYPE_VALID(optional_int);
- int readback = *optional_int;
- ASSERT_EQ(readback, 12);
-}
-
-TEST(ValidatedTypes, TestOptionalInitializingConstructor) {
- Optional< String<1, 12> > optional_string("Hello world");
- ASSERT_TRUE(optional_string.is_initialized());
- ASSERT_RPCTYPE_VALID(optional_string);
- std::string value = *optional_string;
- ASSERT_EQ(value, "Hello world");
-}
-
-TEST(ValidatedTypes, TestDifferentTypesAssignment) {
- Integer<int8_t, 1, 3> val;
- Integer<int32_t, 5, 90> val2(45);
- val = val2;
- ASSERT_TRUE(val2.is_initialized());
- ASSERT_RPCTYPE_VALID(val2);
- ASSERT_TRUE(val.is_initialized());
- ASSERT_FALSE(val.is_valid());
-}
-
-TEST(ValidatedTypes, ReportUninitializedIntType) {
- Integer<int8_t, 1, 3> val;
- ASSERT_FALSE(val.is_valid());
- ValidationReport report("val");
- val.ReportErrors(&report);
- ASSERT_EQ("val: value is not initialized\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportIncorrectInitializedIntType) {
- Integer<int8_t, 1, 3> val(5);
- ASSERT_FALSE(val.is_valid());
- ValidationReport report("val");
- val.ReportErrors(&report);
- ASSERT_EQ("val: value initialized incorrectly\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportUninitializedOptionalType) {
- Optional< Integer<int8_t, 1, 3> > val;
- ASSERT_RPCTYPE_VALID(val);
- ValidationReport report("val");
- val.ReportErrors(&report);
- ASSERT_EQ("", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportIncorrectInitializedOptionalType) {
- Optional< Integer<int8_t, 1, 3> > val(5);
- ASSERT_FALSE(val.is_valid());
- ValidationReport report("val");
- val.ReportErrors(&report);
- ASSERT_EQ("val: value initialized incorrectly\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportUninitializedNullableIntType) {
- Nullable< Integer<int8_t, 1, 3> > val;
- ASSERT_FALSE(val.is_valid());
- ValidationReport report("val");
- val.ReportErrors(&report);
- ASSERT_EQ("val: value is not initialized\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportNullInitializedNullableIntType) {
- Nullable< Integer<int8_t, 1, 3> > val;
- val.set_to_null();
- ASSERT_RPCTYPE_VALID(val);
- ValidationReport report("val");
- val.ReportErrors(&report);
- ASSERT_EQ("", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportNoninitializedIntArray) {
- Array< Enum<TestEnum>, 1, 3 > array;
- ASSERT_FALSE(array.is_valid());
- ValidationReport report("array");
- array.ReportErrors(&report);
- ASSERT_EQ("array: object is not initialized\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray1) {
- Array< Integer<int8_t, 1, 10>, 1, 3 > array;
- array.push_back(11);
- ASSERT_FALSE(array.is_valid());
- ValidationReport report("array");
- array.ReportErrors(&report);
- ASSERT_EQ("array[0]: value initialized incorrectly\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportIncorrectlyInitializedIntArray2) {
- Array< Integer<int8_t, 1, 10>, 1, 3 > array;
- array.push_back(1);
- array.push_back(2);
- array.push_back(3);
- array.push_back(4);
- ASSERT_FALSE(array.is_valid());
- ValidationReport report("array");
- array.ReportErrors(&report);
- ASSERT_EQ("array: array has invalid size\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportIncorrectlyInitializedArray3) {
- Array< Integer<int8_t, 1, 10>, 1, 3 > array;
- array.push_back(1);
- array.push_back(2);
- array.push_back(42);
- array.push_back(4);
- ValidationReport report("array");
- array.ReportErrors(&report);
- ASSERT_EQ("array: array has invalid size\n"
- "array[2]: value initialized incorrectly\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportUninitializedMap) {
- Map< Integer<int8_t, 1, 10>, 1, 3 > map;
- ValidationReport report("map");
- map.ReportErrors(&report);
- ASSERT_EQ("map: object is not initialized\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportIncorrectlyInitializedMap1) {
- Map< Integer<int8_t, 1, 10>, 1, 3 > map;
- map["aha"] = 42;
- ValidationReport report("map");
- map.ReportErrors(&report);
- ASSERT_EQ("map[\"aha\"]: value initialized incorrectly\n", PrettyFormat(report));
-}
-
-TEST(ValidatedTypes, ReportIncorrectlyInitializedMap2) {
- Map< Integer<int8_t, 1, 10>, 1, 3 > map;
- map["aha"] = 3;
- map["haha"] = 12;
- map["muhahaha"] = 17;
- map["muhahaha"] = 22;
- ValidationReport report("map");
- map.ReportErrors(&report);
- ASSERT_EQ("map[\"haha\"]: value initialized incorrectly\n"
- "map[\"muhahaha\"]: value initialized incorrectly\n", PrettyFormat(report));
-}
-
-} // namespace codegen
diff --git a/test/components/security_manager/CMakeLists.txt b/test/components/security_manager/CMakeLists.txt
deleted file mode 100644
index c7c5b3dde..000000000
--- a/test/components/security_manager/CMakeLists.txt
+++ /dev/null
@@ -1,69 +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.
-
-set (COMPONENTS_DIR ${CMAKE_SOURCE_DIR}/src/components)
-
-include_directories(
- include
- ${SecurityManagerIncludeDir}
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ${CMAKE_SOURCE_DIR}/src/components/protocol_handler/include
- ${CMAKE_SOURCE_DIR}/src/components/utils/include/
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${GMOCK_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/gmock-1.7.0/include
- ${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/gmock-1.7.0/gtest/include
-)
-
-set(SOURCES
- src/crypto_manager_impl_test.cc
- src/security_manager_test.cc
- src/security_query_test.cc
- src/security_query_matcher.cc
-)
-
-set(LIBRARIES
- gmock
- gmock_main
- ${SecurityManagerLibrary}
- crypto
- ssl
- ProtocolHandler
- connectionHandler
- Utils
- ${RTLIB}
- ProtocolLibrary
-)
-
-add_library(test_SecurityManager ${SOURCES})
-target_link_libraries(test_SecurityManager ${LIBRARIES} )
-create_test(test_SecurityManagerTest "${SOURCES}" "${LIBRARIES}")
-
-# vim: set ts=2 sw=2 et:
diff --git a/test/components/security_manager/include/security_manager/crypto_manager_impl_test.h b/test/components/security_manager/include/security_manager/crypto_manager_impl_test.h
deleted file mode 100644
index d818803f9..000000000
--- a/test/components/security_manager/include/security_manager/crypto_manager_impl_test.h
+++ /dev/null
@@ -1,459 +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.
- */
-
-#ifndef CRYPTO_MANAGER_IMPL_TEST_H_
-#define CRYPTO_MANAGER_IMPL_TEST_H_
-
-#include <gtest/gtest.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <unistd.h>
-
-#include "security_manager/crypto_manager.h"
-#include "security_manager/crypto_manager_impl.h"
-#include "security_manager/ssl_context.h"
-
-#ifdef __QNXNTO__
-#include <openssl/ssl3.h>
-#else
-#include <openssl/tls1.h>
-#endif
-
-#ifdef __QNXNTO__
-#define FORD_CIPHER SSL3_TXT_RSA_DES_192_CBC3_SHA
-#else
-// Used cipehr from ford protocolo requirment
-#define FORD_CIPHER TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384
-#endif
-
-#define ALL_CIPHERS "ALL"
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-
-namespace {
-bool isErrorFatal(SSL *connection, int res) {
- const int error = SSL_get_error(connection, res);
- return (error != SSL_ERROR_WANT_READ &&
- error != SSL_ERROR_WANT_WRITE);
-}
-}
-// TODO(EZamakhov): May be split to SSLContext and Cyptomanager tests (separate files)
-// TODO(EZamakhov): add test for EnsureBufferSizeEnough
-class SSLTest : public testing::Test {
- protected:
- static void SetUpTestCase() {
- crypto_manager = new security_manager::CryptoManagerImpl();
- const bool crypto_manager_initialization =
- crypto_manager->Init(security_manager::SERVER, security_manager::TLSv1_2, "mycert.pem",
- "mykey.pem", FORD_CIPHER, false);
- EXPECT_TRUE(crypto_manager_initialization);
-
- client_manager = new security_manager::CryptoManagerImpl();
- const bool client_manager_initialization =
- client_manager->Init(security_manager::CLIENT, security_manager::TLSv1_2, "", "",
- FORD_CIPHER, false);
- EXPECT_TRUE(client_manager_initialization);
- }
-
- static void TearDownTestCase() {
- crypto_manager->Finish();
- client_manager->Finish();
- delete crypto_manager;
- delete client_manager;
- }
-
- virtual void SetUp() {
- server_ctx = crypto_manager->CreateSSLContext();
- client_ctx = client_manager->CreateSSLContext();
- }
-
- virtual void TearDown() {
- crypto_manager->ReleaseSSLContext(server_ctx);
- client_manager->ReleaseSSLContext(client_ctx);
- }
-
- static security_manager::CryptoManager* crypto_manager;
- static security_manager::CryptoManager* client_manager;
- security_manager::SSLContext *server_ctx;
- security_manager::SSLContext *client_ctx;
-};
-
-security_manager::CryptoManager* SSLTest::crypto_manager;
-security_manager::CryptoManager* SSLTest::client_manager;
-
-TEST(CryptoManagerTest, UsingBeforeInit) {
- security_manager::CryptoManager *crypto_manager = new security_manager::CryptoManagerImpl();
- EXPECT_TRUE(crypto_manager->CreateSSLContext() == NULL);
- EXPECT_EQ(crypto_manager->LastError(), std::string ("Initialization is not completed"));
- delete crypto_manager;
-}
-
-TEST(CryptoManagerTest, WrongInit) {
- security_manager::CryptoManager *crypto_manager = new security_manager::CryptoManagerImpl();
- // TODO(EZamakhov): Unkown protocol version
-// EXPECT_FALSE(crypto_manager->Init(security_manager::SERVER, security_manager::UNKNOWN,
-// "mycert.pem", "mykey.pem", FORD_CIPHER, false));
-// EXPECT_FALSE(crypto_manager->LastError().empty());
- // Unexistent cert file
- EXPECT_FALSE(crypto_manager->Init(security_manager::SERVER, security_manager::TLSv1_2,
- "unexists_file.pem", "mykey.pem", FORD_CIPHER, false));
- EXPECT_FALSE(crypto_manager->LastError().empty());
- // Unexistent key file
- EXPECT_FALSE(crypto_manager->Init(security_manager::SERVER, security_manager::TLSv1_2,
- "mycert.pem", "unexists_file.pem", FORD_CIPHER, false));
- EXPECT_FALSE(crypto_manager->LastError().empty());
- // Unexistent cipher value
- EXPECT_FALSE(crypto_manager->Init(security_manager::SERVER, security_manager::TLSv1_2,
- "mycert.pem", "mykey.pem", "INVALID_UNKNOWN_CIPHER", false));
- EXPECT_FALSE(crypto_manager->LastError().empty());
- delete crypto_manager;
-}
-
-TEST(CryptoManagerTest, CorrectInit) {
- security_manager::CryptoManager *crypto_manager = new security_manager::CryptoManagerImpl();
- // Empty cert and key values for SERVER
- EXPECT_TRUE(crypto_manager->Init(security_manager::SERVER, security_manager::TLSv1_2,
- "", "", FORD_CIPHER, false));
- EXPECT_TRUE(crypto_manager->LastError().empty());
- // Recall init
- EXPECT_TRUE(crypto_manager->Init(security_manager::CLIENT, security_manager::TLSv1_2,
- "", "", FORD_CIPHER, false));
- EXPECT_TRUE(crypto_manager->LastError().empty());
- // Recall init with other protocols
- EXPECT_TRUE(crypto_manager->Init(security_manager::CLIENT, security_manager::TLSv1_1,
- "", "", FORD_CIPHER, false));
- EXPECT_TRUE(crypto_manager->LastError().empty());
- EXPECT_TRUE(crypto_manager->Init(security_manager::CLIENT, security_manager::TLSv1,
- "", "", FORD_CIPHER, false));
- EXPECT_TRUE(crypto_manager->LastError().empty());
-
- // Cipher value
- EXPECT_TRUE(crypto_manager->Init(security_manager::SERVER, security_manager::TLSv1_2,
- "mycert.pem", "mykey.pem", ALL_CIPHERS, false));
- EXPECT_TRUE(crypto_manager->LastError().empty());
- delete crypto_manager;
-}
-
-TEST(CryptoManagerTest, ReleaseNull) {
- using security_manager::CryptoManager;
- using security_manager::CryptoManagerImpl;
-
- CryptoManager *cm = new CryptoManagerImpl();
- EXPECT_NO_THROW(cm->ReleaseSSLContext(NULL));
- delete cm;
-}
-
-TEST_F(SSLTest, BrokenHandshake) {
- const uint8_t *server_buf;
- const uint8_t *client_buf;
- size_t server_buf_len;
- size_t client_buf_len;
- ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success,
- client_ctx->StartHandshake(&client_buf,
- &client_buf_len));
- ASSERT_FALSE(client_buf == NULL);
- ASSERT_GT(client_buf_len, 0u);
- // Broke 3 bytes for get abnormal fail of handshake
- const_cast<uint8_t*>(client_buf)[0] ^= 0xFF;
- const_cast<uint8_t*>(client_buf)[client_buf_len / 2] ^= 0xFF;
- const_cast<uint8_t*>(client_buf)[client_buf_len - 1] ^= 0xFF;
- ASSERT_EQ(security_manager::SSLContext::Handshake_Result_AbnormalFail,
- server_ctx->DoHandshakeStep(client_buf,
- client_buf_len,
- &server_buf,
- &server_buf_len));
-}
-
-// TODO(EZamakhov): split to SSL/TLS1/1.1/1.2 tests
-TEST_F(SSLTest, Positive) {
-
- const uint8_t *server_buf;
- const uint8_t *client_buf;
- size_t server_buf_len;
- size_t client_buf_len;
- ASSERT_EQ(client_ctx->StartHandshake(&client_buf,
- &client_buf_len),
- security_manager::SSLContext::Handshake_Result_Success);
- ASSERT_FALSE(client_buf == NULL);
- ASSERT_GT(client_buf_len, 0u);
-
- for (;;) {
- ASSERT_EQ(server_ctx->DoHandshakeStep(client_buf,
- client_buf_len,
- &server_buf,
- &server_buf_len),
- security_manager::SSLContext::Handshake_Result_Success);
- ASSERT_FALSE(server_buf == NULL);
- ASSERT_GT(server_buf_len, 0u);
-
- ASSERT_EQ(client_ctx->DoHandshakeStep(server_buf,
- server_buf_len,
- &client_buf,
- &client_buf_len),
- security_manager::SSLContext::Handshake_Result_Success);
- if (server_ctx->IsInitCompleted()) {
- break;
- }
-
- ASSERT_FALSE(client_buf == NULL);
- ASSERT_GT(client_buf_len, 0u);
- }
- // expect empty buffers after init complete
- ASSERT_TRUE(client_buf == NULL);
- ASSERT_EQ(client_buf_len, 0u);
- // expect both side initialization complete
- EXPECT_TRUE(client_ctx->IsInitCompleted());
- EXPECT_TRUE(server_ctx->IsInitCompleted());
-
- // Encrypt text on client side
- const uint8_t *text = reinterpret_cast<const uint8_t*>("abra");
- const uint8_t *encrypted_text = 0;
- size_t text_len = 4;
- size_t encrypted_text_len;
- EXPECT_TRUE(client_ctx->Encrypt(text, text_len, &encrypted_text, &encrypted_text_len));
-
- ASSERT_NE(encrypted_text, (void*)NULL);
- ASSERT_GT(encrypted_text_len, 0u);
-
- // Decrypt text on server side
- EXPECT_TRUE(server_ctx->Decrypt(encrypted_text, encrypted_text_len, &text, &text_len));
- ASSERT_NE(text, (void*)NULL);
- ASSERT_GT(text_len, 0u);
-
- ASSERT_EQ(strncmp(reinterpret_cast<const char*>(text),
- "abra",
- 4), 0);
-}
-
-TEST_F(SSLTest, EcncryptionFail) {
-
- const uint8_t *server_buf;
- const uint8_t *client_buf;
- size_t server_buf_len;
- size_t client_buf_len;
- ASSERT_EQ(client_ctx->StartHandshake(&client_buf,
- &client_buf_len),
- security_manager::SSLContext::Handshake_Result_Success);
-
- while (!server_ctx->IsInitCompleted()) {
- ASSERT_FALSE(client_buf == NULL);
- ASSERT_GT(client_buf_len, 0u);
- ASSERT_EQ(server_ctx->DoHandshakeStep(client_buf, client_buf_len,
- &server_buf, &server_buf_len),
- security_manager::SSLContext::Handshake_Result_Success);
- ASSERT_FALSE(server_buf == NULL);
- ASSERT_GT(server_buf_len, 0u);
-
- ASSERT_EQ(client_ctx->DoHandshakeStep(server_buf, server_buf_len,
- &client_buf, &client_buf_len),
- security_manager::SSLContext::Handshake_Result_Success);
- }
- // expect empty buffers after init complete
- ASSERT_TRUE(client_buf == NULL);
- ASSERT_EQ(client_buf_len, 0u);
- // expect both side initialization complete
- EXPECT_TRUE(client_ctx->IsInitCompleted());
- EXPECT_TRUE(server_ctx->IsInitCompleted());
-
- // Encrypt text on client side
- const uint8_t *text = reinterpret_cast<const uint8_t*>("abra");
- const uint8_t *encrypted_text = 0;
- size_t text_len = 4;
- size_t encrypted_text_len;
- EXPECT_TRUE(client_ctx->Encrypt(text, text_len, &encrypted_text, &encrypted_text_len));
- ASSERT_NE(encrypted_text, (void*)NULL);
- ASSERT_GT(encrypted_text_len, 0u);
-
- std::vector<uint8_t> broken(encrypted_text, encrypted_text + encrypted_text_len);
- // Broke message
- broken[encrypted_text_len / 2] ^= 0xFF;
-
- const uint8_t *out_text;
- size_t out_text_size;
- // Decrypt broken text on server side
- EXPECT_FALSE(server_ctx->Decrypt(&broken[0], broken.size(), &out_text, &out_text_size));
-
- // Check after broken message that server encryption and decryption fail
- // Encrypte message on server side
- EXPECT_FALSE(server_ctx->Decrypt(encrypted_text, encrypted_text_len, &out_text, &out_text_size));
- EXPECT_FALSE(server_ctx->Encrypt(text, text_len, &encrypted_text, &encrypted_text_len));
-}
-
-/*
-TEST_F(SSLTest, DISABLED_BadData) {
- using security_manager::LastError;
- int res = 0;
-
- uint8_t *outBuf = new uint8_t[1024 * 1024];
- const uint8_t *inBuf;
-
- for(;;) {
- res = SSL_do_handshake(connection);
- if (res >= 0) {
- break;
- }
-
- if (isErrorFatal(connection, res)) {
- break;
- }
-
- size_t outLen = BIO_ctrl_pending(bioOut);
- if (outLen) {
- BIO_read(bioOut, outBuf, outLen);
- }
- size_t inLen;
- server_ctx->DoHandshakeStep(outBuf, outLen, &inBuf, &inLen);
- EXPECT_TRUE(inBuf != NULL);
-
- if (inLen) {
- BIO_write(bioIn, inBuf, inLen);
- }
- }
- delete[] outBuf;
-
- EXPECT_EQ(res, 1);
-
- BIO *bioF = BIO_new(BIO_f_ssl());
- BIO_set_ssl(bioF, connection, BIO_NOCLOSE);
-
- const char *text = "Hello, it's the text to be encrypted";
- uint8_t *encryptedText = new uint8_t[1024];
- const uint8_t *decryptedText;
- size_t text_len;
-
- // Encrypt text on client side
- BIO_write(bioF, text, sizeof(text));
- text_len = BIO_ctrl_pending(bioOut);
- size_t len = BIO_read(bioOut, encryptedText, text_len);
-
- // Make improvements
- encryptedText[len / 3] ^= 0x80;
-
- // Decrypt text on server
- server_ctx->Decrypt(encryptedText, len, &decryptedText, &text_len);
-
- delete[] encryptedText;
-
- EXPECT_FALSE(decryptedText == NULL);
- EXPECT_GT(LastError().length(), 0u);
- delete[] encryptedText;
-}
-
-
-
-TEST_F(SSLTest, Positive2) {
- using security_manager::LastError;
- int res = 0;
-
- uint8_t *outBuf = new uint8_t[1024 * 1024];
- const uint8_t *inBuf;
-
- for(;;) {
- res = SSL_do_handshake(connection);
- if (res >= 0) {
- break;
- }
-
- if (isErrorFatal(connection, res)) {
- break;
- }
-
- size_t outLen = BIO_ctrl_pending(bioOut);
- if (outLen) {
- BIO_read(bioOut, outBuf, outLen);
- }
- size_t inLen;
- server_ctx->DoHandshakeStep(outBuf, outLen, &inBuf, &inLen);
- EXPECT_TRUE(inBuf != NULL);
-
- if (inLen) {
- BIO_write(bioIn, inBuf, inLen);
- }
- }
- delete[] outBuf;
-
- EXPECT_EQ(res, 1);
-
- EXPECT_NE(SSL_is_init_finished(connection), 0u);
-
- BIO *bioF = BIO_new(BIO_f_ssl());
- BIO_set_ssl(bioF, connection, BIO_NOCLOSE);
-
- const int N =1000;
- int last_max = 0;
- int min_oh = N , max_oh = 0;
- for (int l = 1; l < N; ++l) {
- char *text = new char[l+1];
- text[l]='\0';
- uint8_t *encryptedText = new uint8_t[1024*N];
- const uint8_t *decryptedText;
- size_t text_len;
- // Encrypt text on client side
- BIO_write(bioF, text, l);
- text_len = BIO_ctrl_pending(bioOut);
- size_t len = BIO_read(bioOut, encryptedText, text_len);
- const int temp = len - l;
- min_oh = temp < min_oh ? temp : min_oh;
- max_oh = temp > max_oh ? temp : max_oh;
- if (last_max < len) {
- std::cout << l << "->" << len;
- if (l > 1) {
- std::cout << ", last overhead = " << last_max << "-" << l-1
- << " = " << last_max - (l - 1) << "bytes || ";
- std::cout << " overhead = " << len << "-" << l
- << " = " << len - l << "bytes";
- }
- std::cout << std::endl;
- last_max = len;
-
- // Decrypt text on server
- server_ctx->Decrypt(encryptedText, len, &decryptedText, &text_len);
- const_cast<uint8_t*>(decryptedText)[text_len] = 0;
-
- EXPECT_TRUE(decryptedText != NULL);
- EXPECT_EQ(strcmp(reinterpret_cast<const char*>(decryptedText), text), 0u);
- delete[] text;
- }
- std::cout << " min = " << min_oh << ", max = " << max_oh << std::endl;
-}
-//*/
-
-} // namespace crypto_manager_test
-} // namespace components
-} // namespace test
-
-#endif /* CRYPTO_MANAGER_IMPL_TEST_H_ */
diff --git a/test/components/security_manager/include/security_manager/security_manager_mock.h b/test/components/security_manager/include/security_manager/security_manager_mock.h
deleted file mode 100644
index 8051153c6..000000000
--- a/test/components/security_manager/include/security_manager/security_manager_mock.h
+++ /dev/null
@@ -1,261 +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.
- */
-
-#ifndef TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_MOCK_H_
-#define TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_MOCK_H_
-#include <gmock/gmock.h>
-#include <string>
-#include <list>
-#include "utils/byte_order.h"
-#include "security_manager/security_manager.h"
-#include "security_manager/ssl_context.h"
-#include "security_manager/security_query.h"
-
-namespace test {
-namespace components {
-namespace security_manager_test {
- /*
- * MOCK implementation of protocol_handler::SessionObserver interface
- */
- class SessionObserverMock: public protocol_handler::SessionObserver {
- public:
- MOCK_METHOD2(SetSSLContext,
- int (const uint32_t& key,
- security_manager::SSLContext* context));
- MOCK_METHOD2(GetSSLContext,
- security_manager::SSLContext* (
- const uint32_t& key,
- const protocol_handler::ServiceType& service_type));
- MOCK_METHOD2(SetProtectionFlag,
- void(
- const uint32_t& key,
- const protocol_handler::ServiceType& service_type));
- MOCK_METHOD4(OnSessionStartedCallback,
- uint32_t(
- const transport_manager::ConnectionUID& connection_handle,
- const uint8_t session_id,
- const protocol_handler::ServiceType& service_type,
- const bool is_protected, uint32_t* hash_id));
- MOCK_METHOD4(OnSessionEndedCallback,
- uint32_t(
- const transport_manager::ConnectionUID& connection_handle,
- const uint8_t sessionId,
- const uint32_t& hashCode,
- const protocol_handler::ServiceType& service_type));
- MOCK_METHOD1(OnApplicationFloodCallBack,
- void(const uint32_t&));
- MOCK_METHOD2(KeyFromPair,
- uint32_t(
- transport_manager::ConnectionUID connection_handle,
- uint8_t sessionId));
- MOCK_METHOD3(PairFromKey,
- void(
- uint32_t key,
- transport_manager::ConnectionUID* connection_handle,
- uint8_t* sessionId));
- MOCK_METHOD4(GetDataOnSessionKey,
- int32_t(uint32_t key,
- uint32_t* app_id,
- std::list<int32_t>* sessions_list,
- uint32_t* device_id));
- MOCK_METHOD4(GetDataOnDeviceID,
- int32_t(
- uint32_t device_handle,
- std::string* device_name,
- std::list<uint32_t>* applications_list,
- std::string* mac_address));
- MOCK_METHOD2(IsHeartBeatSupported,
- bool( transport_manager::ConnectionUID connection_handle,
- uint8_t session_id));
- MOCK_METHOD3(ProtocolVersionUsed,
- bool(uint32_t connection_id, uint8_t session_id,
- uint8_t& protocol_version));
-
- };
-
- /*
- * MOCK implementation of protocol_handler::ProtocolObserver interface
- */
- class ProtocoloObserverMock: public protocol_handler::ProtocolHandler {
- public:
- MOCK_METHOD2(SendMessageToMobileApp,
- void(const protocol_handler::RawMessagePtr message,
- bool final_message));
- MOCK_METHOD1(AddProtocolObserver,
- void(protocol_handler::ProtocolObserver* observer));
- MOCK_METHOD1(RemoveProtocolObserver,
- void(protocol_handler::ProtocolObserver* observer));
- MOCK_METHOD2(SendFramesNumber,
- void(uint32_t connection_key, int32_t number_of_frames));
- MOCK_METHOD2(SendHeartBeat,
- void(int32_t connection_id, uint8_t session_id));
- MOCK_METHOD2(SendEndSession,
- void(int32_t connection_id, uint8_t session_id));
- };
- /*
- * MOCK implementation of security_manager::SSLContext interface
- */
- class CryptoManagerMock: public security_manager::CryptoManager {
- public:
- MOCK_METHOD6(Init,
- bool (security_manager::Mode mode,
- security_manager::Protocol protocol,
- const std::string& cert_filename,
- const std::string& key_filename,
- const std::string& ciphers_list,
- bool verify_peer));
- MOCK_METHOD0(Finish,
- void ());
- MOCK_METHOD0(CreateSSLContext,
- security_manager::SSLContext* ());
- MOCK_METHOD1(ReleaseSSLContext,
- void(security_manager::SSLContext*));
- MOCK_CONST_METHOD0(LastError,
- std::string());
- };
- /*
- * MOCK implementation of security_manager::SSLContext interface
- */
- class SSLContextMock: public security_manager::SSLContext {
- public:
- MOCK_CONST_METHOD0(mode, int ());
- MOCK_METHOD2(StartHandshake,
- security_manager::SSLContext::HandshakeResult (
- const uint8_t** const, size_t*));
- MOCK_METHOD4(DoHandshakeStep,
- security_manager::SSLContext::HandshakeResult (
- const uint8_t* const, size_t,
- const uint8_t** const, size_t*));
- MOCK_METHOD4(Encrypt,
- bool (const uint8_t* const, size_t,
- const uint8_t** const, size_t*));
- MOCK_METHOD4(Decrypt,
- bool (const uint8_t* const, size_t,
- const uint8_t** const, size_t*));
- MOCK_CONST_METHOD1(get_max_block_size, size_t (size_t));
- MOCK_CONST_METHOD0(IsInitCompleted, bool());
- MOCK_CONST_METHOD0(IsHandshakePending, bool());
- MOCK_CONST_METHOD0(LastError,
- std::string());
- };
- /*
- * MOCK implementation of security_manager::SecurityManagerListener
- */
- class SMListenerMock: public security_manager::SecurityManagerListener {
- public:
- MOCK_METHOD2(OnHandshakeDone,
- bool(uint32_t connection_key,
- bool success));
- };
-
- /*
- * Matcher for RawMessages
- * Check binary data of RawMessages
- */
- MATCHER_P2(RawMessageEq, exp_data, exp_data_size,
- std::string(negation ? "is not" : "is") + " RawMessages ") {
- const size_t arg_data_size = arg->data_size();
- if (arg_data_size != exp_data_size) {
- *result_listener << "Got " << arg_data_size << " bytes "
- << " expected " << exp_data_size << " bytes";
- return false;
- }
- const uint8_t *arg_data = arg->data();
- for (int i = 0; i < arg_data_size; ++i) {
- if (arg_data[i] != exp_data[i]) {
- *result_listener << "Fail in " << i << " byte";
- return false;
- }
- }
- return true;
- }
-
- /*
- * Matcher for checking RawMessage with InternalError Query
- * Check error id
- */
- MATCHER_P(InternalErrorWithErrId, expectedErrorId,
- std::string(negation ? "is not" : "is")
- + " InternalError with selected error" ) {
- const size_t header_size = sizeof(security_manager::SecurityQuery::QueryHeader);
- if (arg->data_size() <= header_size) {
- *result_listener << "Size " << arg->data_size()
- << " bytes less or equal sizeof(QueryHeader)="
- << header_size;
- return false;
- }
- const uint8_t *data = arg->data();
- const uint8_t query_type = data[0];
- if (security_manager::SecurityQuery::NOTIFICATION != query_type) {
- *result_listener << "RawMessage is not notification, type=0x"
- << std::hex << static_cast<int>(query_type);
- return false;
- }
- // Read Big-Endian number
- const uint32_t query_id = data[1] << 16 |
- data[2] << 8 |
- data[3];
- if (security_manager::SecurityQuery::SEND_INTERNAL_ERROR != query_id) {
- *result_listener << "Notification is not InternalError, id=0x"
- << std::hex << query_id;
- return false;
- }
- const uint32_t json_size = data[8] << 24 |
- data[9] << 16 |
- data[10] << 8 |
- data[11];
- if (header_size + json_size >= arg->data_size()) {
- *result_listener << "InternalError contains only JSON data.";
- return false;
- }
- // Read err_id as bin data number
- const uint8_t* err_id =
- reinterpret_cast<const uint8_t*>(data + header_size + json_size);
- if (expectedErrorId != *err_id) {
- *result_listener << "InternalError id " << static_cast<int>(*err_id)
- << " and not equal error " << expectedErrorId;
- return false;
- }
- return true;
- }
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-/*
- * Matcher for checking QueryHeader equal in GTests
- */
-::testing::AssertionResult QueryHeader_EQ(
- const char* m_expr, const char* n_expr,
- const ::security_manager::SecurityQuery::QueryHeader& q1,
- const ::security_manager::SecurityQuery::QueryHeader& q2);
-
-#endif // TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_MOCK_H_
diff --git a/test/components/security_manager/include/security_manager/security_manager_test.h b/test/components/security_manager/include/security_manager/security_manager_test.h
deleted file mode 100644
index e4dd9d1bb..000000000
--- a/test/components/security_manager/include/security_manager/security_manager_test.h
+++ /dev/null
@@ -1,798 +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.
- */
-
-#ifndef TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_TEST_H_
-#define TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_TEST_H_
-
-#include <gtest/gtest.h>
-#include <string>
-
-#include "utils/byte_order.h"
-#include "protocol/common.h"
-#include "security_manager/security_manager_impl.h"
-
-#include "protocol_handler/session_observer_mock.h"
-#include "protocol_handler/protocol_handler_mock.h"
-#include "protocol_handler/protocol_observer_mock.h"
-#include "security_manager/security_manager_mock.h"
-#include "security_manager/security_query_matcher.h"
-#include "security_manager/crypto_manager_mock.h"
-#include "security_manager/ssl_context_mock.h"
-#include "security_manager/security_manager_listener_mock.h"
-#include "transport_manager/transport_manager_mock.h"
-
-// TODO(EZamakhov): add test on get correct/wrong InternalError
-// TODO(EZamakhov): check connection_key the same and seq_number
-// TODO(EZamakhov): check ::SendData with correct query_id and query_type
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-
-using namespace ::protocol_handler;
-using ::protocol_handler::ServiceType;
-using namespace ::transport_manager;
-using namespace ::security_manager;
-
- // Sample data for handshake data emulation
- const int32_t key = 0x1;
- const int32_t seq_number = 0x2;
- const ServiceType secureServiceType = kControl;
- const uint32_t protocolVersion = PROTOCOL_VERSION_2;
- const bool is_final = false;
-
- const uint8_t handshake_data[] = {0x1, 0x2, 0x3, 0x4, 0x5};
- const size_t handshake_data_size =
- sizeof(handshake_data)/sizeof(handshake_data[0]);
-
- uint8_t handshake_data_out[] = {0x6, 0x7, 0x8};
- uint8_t *handshake_data_out_pointer = handshake_data_out;
- const size_t handshake_data_out_size =
- sizeof(handshake_data_out)/sizeof(handshake_data_out[0]);
-
- using ::security_manager::SecurityQuery;
- using security_manager_test::InternalErrorWithErrId;
- using ::testing::Return;
- using ::testing::ReturnNull;
- using ::testing::DoAll;
- using ::testing::SetArgPointee;
- using ::testing::_;
- using ::security_manager::SecurityManager;
- using ::security_manager::SecurityManagerImpl;
-
- class SecurityManagerTest: public ::testing::Test {
- protected:
- void SetUp() OVERRIDE {
- security_manager_.reset(new SecurityManagerImpl());
- security_manager_->set_session_observer(&mock_session_observer);
- security_manager_->set_protocol_handler(&mock_protocol_handler);
- security_manager_->AddListener(&mock_sm_listener);
- }
- void TearDown() OVERRIDE {
- // Wait call methods in thread
- usleep(100000);
- }
-
- void SetMockCryptoManger() {
- security_manager_->set_crypto_manager(&mock_crypto_manager);
- }
- /*
- * Wrapper for fast emulate recieve SecurityManager::OnMessageReceived
- */
- void call_OnMessageReceived(const uint8_t* const data, uint32_t dataSize,
- const ServiceType serviceType) {
- const ::protocol_handler::RawMessagePtr rawMessagePtr(
- new ::protocol_handler::RawMessage(key, protocolVersion, data, dataSize, serviceType));
- security_manager_->OnMessageReceived(rawMessagePtr);
- }
- /*
- * Wrapper for fast emulate recieve query
- */
- void EmulateMobileMessage(SecurityQuery::QueryHeader header,
- const uint8_t* const data, const uint32_t data_size) {
- // convert to Big-Endian (network) order
- const uint32_t query_id = header.query_id << 8;
- header.query_id = LE_TO_BE32(query_id);
- header.json_size = LE_TO_BE32(header.json_size);
- header.seq_number = LE_TO_BE32(header.seq_number);
-
- const size_t data_sending_size = sizeof(header) + data_size;
- uint8_t* data_sending = new uint8_t[data_sending_size];
- memcpy(data_sending, &header, sizeof(header));
- memcpy(data_sending + sizeof(header), data, data_size);
-
- call_OnMessageReceived(data_sending, data_sending_size,
- kControl);
- delete[] data_sending;
- }
- /*
- * Wrapper for fast emulate recieve Handshake
- */
- void EmulateMobileMessageHandShake(const uint8_t* const data,
- const uint32_t data_size,
- const int repeat_count = 1) {
- const SecurityQuery::QueryHeader header(
- SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_HANDSHAKE_DATA, seq_number);
- for (int c = 0; c < repeat_count; ++c) {
- EmulateMobileMessage(header, data, data_size);
- }
- }
- ::utils::SharedPtr<SecurityManagerImpl> security_manager_;
- // Strict mocks (same as all methods EXPECT_CALL().Times(0))
- testing::StrictMock<protocol_handler_test::SessionObserverMock> mock_session_observer;
- testing::StrictMock<protocol_handler_test::ProtocolHandlerMock> mock_protocol_handler;
- testing::StrictMock<security_manager_test::CryptoManagerMock> mock_crypto_manager;
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context_new;
- testing::StrictMock<security_manager_test::SSLContextMock> mock_ssl_context_exists;
- testing::StrictMock<security_manager_test::SMListenerMock> mock_sm_listener;
- };
- // Test Bodies
-
- /*
- * SecurityManager shall not set NULL interfaces
- * and shall not call any methodes
- */
- TEST_F(SecurityManagerTest, SetNULL_Intefaces) {
- security_manager_.reset(new SecurityManagerImpl());
- security_manager_->set_session_observer(NULL);
- security_manager_->set_protocol_handler(NULL);
- security_manager_->set_crypto_manager(NULL);
- security_manager_->AddListener(NULL);
- // additional check not null config section
- EXPECT_TRUE(SecurityManagerImpl::ConfigSection());
- }
- /*
- * Add/Remove NULL listeners do not any additional logics
- */
- TEST_F(SecurityManagerTest, Listeners_NULL) {
- security_manager_->AddListener(NULL);
- security_manager_->RemoveListener(NULL);
- }
- /*
- * Twice remove listener
- */
- TEST_F(SecurityManagerTest, Listeners_TwiceRemoveListeners) {
- security_manager_->RemoveListener(&mock_sm_listener);
- security_manager_->RemoveListener(&mock_sm_listener);
- }
- /*
- * Add and remove listeners
- */
- TEST_F(SecurityManagerTest, Listeners_NoListeners) {
- // Check correct removing listener
- security_manager_->RemoveListener(&mock_sm_listener);
-
- // Expect no calls
- testing::StrictMock<SMListenerMock> mock_listener2;
- security_manager_->AddListener(&mock_listener2);
- security_manager_->RemoveListener(&mock_listener2);
-
- security_manager_->NotifyListenersOnHandshakeDone(key, true);
- security_manager_->NotifyListenersOnHandshakeDone(key, false);
- }
- /*
- * Notifying two listeners
- */
- TEST_F(SecurityManagerTest, Listeners_Notifying) {
- // Check correct removing listener
- security_manager_->RemoveListener(&mock_sm_listener);
-
- testing::StrictMock<SMListenerMock> mock_listener1;
- testing::StrictMock<SMListenerMock> mock_listener2;
-
- const bool first_call_value = true;
- // Expect call both listeners on 1st call
- EXPECT_CALL(mock_listener1,
- OnHandshakeDone(key, first_call_value)).
- // Emulate false (reject) result
- WillOnce(Return(false));
- EXPECT_CALL(mock_listener2,
- OnHandshakeDone(key, first_call_value)).
- // Emulate true (accept) result
- WillOnce(Return(true));
-
- const bool second_call_value = false;
- // Expect call last listener on 2d call
- EXPECT_CALL(mock_listener1,
- OnHandshakeDone(key, second_call_value)).
- // Emulate false (reject) result
- WillOnce(Return(true));
-
- // Expect no call 3d call
-
- security_manager_->AddListener(&mock_listener1);
- security_manager_->AddListener(&mock_listener2);
- // 1st call
- security_manager_->NotifyListenersOnHandshakeDone(key, first_call_value);
- // 2nd call
- security_manager_->NotifyListenersOnHandshakeDone(key, second_call_value);
- // 3nd call
- security_manager_->NotifyListenersOnHandshakeDone(key, false);
- }
- /*
- * SecurityManager with NULL CryptoManager shall send
- * InternallError (ERROR_NOT_SUPPORTED) on any Query
- */
- TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) {
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_NOT_SUPPORTED), is_final)).
- Times(1);
- const SecurityQuery::QueryHeader header(
- SecurityQuery::REQUEST,
- // It could be any query id
- SecurityQuery::INVALID_QUERY_ID);
- const uint8_t data = 0;
- EmulateMobileMessage(header, &data, 1);
- }
- /*
- * Shall skip all OnMobileMessageSent
- */
- TEST_F(SecurityManagerTest, OnMobileMessageSent) {
- const ::protocol_handler::RawMessagePtr rawMessagePtr(
- new ::protocol_handler::RawMessage(key, protocolVersion, NULL, 0));
- security_manager_->OnMobileMessageSent(rawMessagePtr);
- }
- /*
- * Shall skip all not-Secure messages
- */
- TEST_F(SecurityManagerTest, GetWrongServiceType) {
- // Call with wrong Service type
- call_OnMessageReceived(NULL, 0, kRpc);
- call_OnMessageReceived(NULL, 0, kAudio);
- call_OnMessageReceived(NULL, 0, kMobileNav);
- call_OnMessageReceived(NULL, 0, kBulk);
- call_OnMessageReceived(NULL, 0, kInvalidServiceType);
- }
- /*
- * Shall send InternallError on null data received
- */
- TEST_F(SecurityManagerTest, GetEmptyQuery) {
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final)).
- Times(1);
- // Call with NULL data
- call_OnMessageReceived(NULL, 0, secureServiceType);
- }
- /*
- * Shall send InternallError on null data received
- */
- TEST_F(SecurityManagerTest, GetWrongJSONSize) {
- SetMockCryptoManger();
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final)).
- Times(1);
- SecurityQuery::QueryHeader header(
- SecurityQuery::REQUEST,
- SecurityQuery::INVALID_QUERY_ID);
- header.json_size = 0x0FFFFFFF;
- EmulateMobileMessage(header, NULL, 0);
- }
- /*
- * Shall send InternallError on INVALID_QUERY_ID
- */
- TEST_F(SecurityManagerTest, GetInvalidQueryId) {
- SetMockCryptoManger();
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_INVALID_QUERY_ID), is_final)).
- Times(1);
- const SecurityQuery::QueryHeader header(
- SecurityQuery::REQUEST,
- SecurityQuery::INVALID_QUERY_ID);
- const uint8_t data = 0;
- EmulateMobileMessage(header, &data, 1);
- }
- /*
- * Shall send Internall Error on call
- * CreateSSLContext for already protected connections
- */
- TEST_F(SecurityManagerTest, CreateSSLContext_ServiceAlreadyProtected) {
- SetMockCryptoManger();
-
- // Return mock SSLContext
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(Return(&mock_ssl_context_new));
-
- const security_manager::SSLContext* rezult = security_manager_->CreateSSLContext(key);
- EXPECT_EQ(rezult, &mock_ssl_context_new);
- }
- /*
- * Shall send Internall Error on error create SSL
- */
- TEST_F(SecurityManagerTest, CreateSSLContext_ErrorCreateSSL) {
- SetMockCryptoManger();
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_INTERNAL), is_final)).
- Times(1);
-
- // Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
- EXPECT_CALL(mock_crypto_manager,
- CreateSSLContext()).
- WillOnce(ReturnNull());
-
- const bool rezult = security_manager_->CreateSSLContext(key);
- EXPECT_FALSE(rezult);
- }
- /*
- * Shall send InternalError with SERVICE_NOT_FOUND
- * on getting any Error with call SetSSLContext
- */
- TEST_F(SecurityManagerTest, CreateSSLContext_SetSSLContextError) {
- SetMockCryptoManger();
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_UNKWOWN_INTERNAL_ERROR), is_final)).
- Times(1);
-
- // Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
- EXPECT_CALL(mock_crypto_manager,
- CreateSSLContext()).
- WillOnce(Return(&mock_ssl_context_new));
- EXPECT_CALL(mock_crypto_manager,
- ReleaseSSLContext(&mock_ssl_context_new)).
- Times(1);
- EXPECT_CALL(mock_session_observer,
- SetSSLContext(key, &mock_ssl_context_new)).
- WillOnce(Return(SecurityManager::ERROR_UNKWOWN_INTERNAL_ERROR));
-
- const bool rezult = security_manager_->CreateSSLContext(key);
- EXPECT_FALSE(rezult);
- }
- /*
- * Shall protect connection on correct call CreateSSLContext
- */
- TEST_F(SecurityManagerTest, CreateSSLContext_Success) {
- SetMockCryptoManger();
- // Expect no Errors
- // Expect no notifying listeners - it will be done after handshake
-
- // Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(ReturnNull()).
- // additional check for debug code
- WillOnce(Return(&mock_ssl_context_exists));
- EXPECT_CALL(mock_crypto_manager,
- CreateSSLContext()).
- WillOnce(Return(&mock_ssl_context_new));
- EXPECT_CALL(mock_session_observer,
- SetSSLContext(key, &mock_ssl_context_new)).
- WillOnce(Return(SecurityManager::ERROR_SUCCESS));
-
- const bool rezult = security_manager_->CreateSSLContext(key);
- EXPECT_TRUE(rezult);
- }
- /*
- * Shall send InternallError on call StartHandshake for uprotected service
- */
- TEST_F(SecurityManagerTest, StartHandshake_ServiceStillUnprotected) {
- SetMockCryptoManger();
- // Expect InternalError with ERROR_INTERNAL
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_INTERNAL), is_final)).
- Times(1);
- // Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, false)).
- WillOnce(Return(true));
-
- // Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
-
- security_manager_->StartHandshake(key);
- }
- /*
- * Shall send InternallError on SSL error and notify listeners
- */
- TEST_F(SecurityManagerTest, StartHandshake_SSLInternalError) {
- SetMockCryptoManger();
-
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_INTERNAL), is_final)).
- Times(1);
- // Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, false)).
- WillOnce(Return(true));
-
- // Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(Return(&mock_ssl_context_exists));
- EXPECT_CALL(mock_ssl_context_exists,
- IsInitCompleted()).
- WillOnce(Return(false));
- EXPECT_CALL(mock_ssl_context_exists,
- StartHandshake(_, _)).
- WillOnce(DoAll(SetArgPointee<0>(handshake_data_out_pointer),
- SetArgPointee<1>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail)));
-
- security_manager_->StartHandshake(key);
- }
- /*
- * Shall send data on call StartHandshake
- */
- TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsNotComplete) {
- SetMockCryptoManger();
-
- // Expect send one message (with correct pointer and size data)
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(_, is_final)).
- Times(1);
-
- // Return mock SSLContext
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- Times(3).
- WillRepeatedly(Return(&mock_ssl_context_exists));
- // Expect initialization check on each call StartHandshake
- EXPECT_CALL(mock_ssl_context_exists,
- IsInitCompleted()).
- Times(3).
- WillRepeatedly(Return(false));
-
- // Emulate SSLContext::StartHandshake with different parameters
- // Only on both correct - data and size shall be send message to mobile app
- EXPECT_CALL(mock_ssl_context_exists,
- StartHandshake(_, _)).
- WillOnce(DoAll(SetArgPointee<0>(handshake_data_out_pointer),
- SetArgPointee<1>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<0>((uint8_t*)NULL),
- SetArgPointee<1>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<0>(handshake_data_out_pointer),
- SetArgPointee<1>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success)));
-
- security_manager_->StartHandshake(key);
- security_manager_->StartHandshake(key);
- security_manager_->StartHandshake(key);
- }
- /*
- * Shall notify listeners on call StartHandshake after SSLContext initialization complete
- */
- TEST_F(SecurityManagerTest, StartHandshake_SSLInitIsComplete) {
- SetMockCryptoManger();
- // Expect no message send
- // Expect notifying listeners (success)
- EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, true)).
- WillOnce(Return(true));
-
- // Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(Return(&mock_ssl_context_exists));
- EXPECT_CALL(mock_ssl_context_exists,
- IsInitCompleted()).
- WillOnce(Return(true));
-
- security_manager_->StartHandshake(key);
- }
- /*
- * Shall send InternallError on
- * getting SEND_HANDSHAKE_DATA with NULL data
- */
- TEST_F(SecurityManagerTest, ProccessHandshakeData_WrongDataSize) {
- SetMockCryptoManger();
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_INVALID_QUERY_SIZE), is_final)).
- Times(1);
- EmulateMobileMessageHandShake(NULL, 0);
- }
- /*
- * Shall send InternallError on
- * getting SEND_HANDSHAKE_DATA from mobile side
- * for service which is not protected
- */
- TEST_F(SecurityManagerTest, ProccessHandshakeData_ServiceNotProtected) {
- SetMockCryptoManger();
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_SERVICE_NOT_PROTECTED), is_final)).
- Times(1);
- // Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, false)).
- WillOnce(Return(true));
-
- // Emulate SessionObserver result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- WillOnce(ReturnNull());
-
- const uint8_t data[] = {0x1, 0x2};
- EmulateMobileMessageHandShake(data, sizeof(data)/sizeof(data[0]));
- }
- /*
- * Shall send InternallError on getting
- * SEND_HANDSHAKE_DATA from mobile side with invalid handshake
- * data (DoHandshakeStep return NULL pointer)
- */
- TEST_F(SecurityManagerTest, ProccessHandshakeData_InvalidData) {
- SetMockCryptoManger();
-
- // Count handshake calls
- const int handshake_emulates = 4;
-
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- InternalErrorWithErrId(
- SecurityManager::ERROR_SSL_INVALID_DATA), is_final)).
- Times(handshake_emulates);
- // Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, false)).
- WillOnce(Return(true));
-
- // Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- Times(handshake_emulates).
- WillRepeatedly(Return(&mock_ssl_context_exists));
- // Emulate DoHandshakeStep fail logics
- EXPECT_CALL(mock_ssl_context_exists,
- DoHandshakeStep(_, handshake_data_size, _, _)).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail))).
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail))).
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_AbnormalFail)));
-
-
- // On each wrong handshake will be asked error
- EXPECT_CALL(mock_ssl_context_exists,
- LastError()).Times(handshake_emulates);
-
- // Emulate handshare #handshake_emulates times for 5 cases
- EmulateMobileMessageHandShake(handshake_data, handshake_data_size,
- handshake_emulates);
- }
- /*
- * Shall send HandshakeData on getting SEND_HANDSHAKE_DATA from mobile side
- * with correct handshake data Check Fail and sussecc states
- */
- TEST_F(SecurityManagerTest, ProccessHandshakeData_Answer) {
- SetMockCryptoManger();
- // Count handshake calls
- const int handshake_emulates = 2;
-
- // Expect InternalError with ERROR_ID
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(
- // FIXME : !!!
- _, is_final)).
- Times(handshake_emulates);
- // Expect notifying listeners (unsuccess)
- EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, false)).
- WillOnce(Return(true));
-
- // Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_ssl_context_exists,
- IsInitCompleted()).
- Times(handshake_emulates).
- WillRepeatedly(Return(false));
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- Times(handshake_emulates).
- WillRepeatedly(Return(&mock_ssl_context_exists));
-
- // Emulate DoHandshakeStep correct logics
- EXPECT_CALL(mock_ssl_context_exists,
- DoHandshakeStep(_, handshake_data_size, _, _)).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail)));
-
- EmulateMobileMessageHandShake(handshake_data, handshake_data_size,
- handshake_emulates);
- }
- /*
- * Shall call all listeners on success end handshake
- * and return handshake data
- * Check Fail and sussecc states
- */
- TEST_F(SecurityManagerTest, ProccessHandshakeData_HandShakeFinished) {
- SetMockCryptoManger();
- // Count handshake calls
- const int handshake_emulates = 6;
- // Expect no errors
- // Expect notifying listeners (success)
- EXPECT_CALL(mock_sm_listener,
- OnHandshakeDone(key, true)).
- WillOnce(Return(true));
-
- // Emulate SessionObserver and CryptoManager result
- EXPECT_CALL(mock_session_observer,
- GetSSLContext(key, kControl)).
- Times(handshake_emulates).
- WillRepeatedly(Return(&mock_ssl_context_exists));
- EXPECT_CALL(mock_ssl_context_exists,
- IsInitCompleted()).
- Times(handshake_emulates).
- WillRepeatedly(Return(true));
- // FIXME(EZamakhov): add DoHandshakeStep matcher for compare handshake data
- EXPECT_CALL(mock_ssl_context_exists,
- DoHandshakeStep(_, handshake_data_size, _, _)).
- // two states with correct out data
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail))).
- // two states with with null pointer data
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL),
- SetArgPointee<3>(handshake_data_out_size),
- Return(security_manager::SSLContext::
- Handshake_Result_Fail))).
- // two states with with null data size
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_Success))).
- WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer),
- SetArgPointee<3>(0),
- Return(security_manager::SSLContext::
- Handshake_Result_Success)));
-
- // Expect send two message (with correct pointer and size data)
- EXPECT_CALL(mock_protocol_handler,
- SendMessageToMobileApp(_, is_final)).
- Times(2);
-
- // Expect NO InternalError with ERROR_ID
- EmulateMobileMessageHandShake(handshake_data, handshake_data_size,
- handshake_emulates);
- }
- /*
- * Shall not any query on getting empty SEND_INTERNAL_ERROR
- */
- TEST_F(SecurityManagerTest, GetInternalError_NullData) {
- SetMockCryptoManger();
-
- const SecurityQuery::QueryHeader header(
- SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
- EmulateMobileMessage(header, NULL, 0);
- }
- /*
- * Shall not send any query on getting SEND_INTERNAL_ERROR
- */
- TEST_F(SecurityManagerTest, GetInternalError) {
- SetMockCryptoManger();
-
- const SecurityQuery::QueryHeader header(
- SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
- const uint8_t data[] = {0x1, 0x2};
- EmulateMobileMessage(header, data, sizeof(data)/sizeof(data[0]));
- }
- /*
- * Shall not send any query on getting SEND_INTERNAL_ERROR with error string
- */
- TEST_F(SecurityManagerTest, GetInternalError_WithErrText) {
- SetMockCryptoManger();
-
- SecurityQuery::QueryHeader header(
- SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
- std::string error("JSON wrong string");
- header.json_size = error.size();
- EmulateMobileMessage(header,
- reinterpret_cast<const uint8_t*>(error.c_str()),
- error.size());
- }
- /*
- * Shall not send any query on getting SEND_INTERNAL_ERROR with error string
- */
- TEST_F(SecurityManagerTest, GetInternalError_WithErrJSONText) {
- SetMockCryptoManger();
-
- SecurityQuery::QueryHeader header(
- SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_INTERNAL_ERROR, 0);
- std::string error(" { \"id\": 1 } ");
- header.json_size = error.size();
- EmulateMobileMessage(header,
- reinterpret_cast<const uint8_t*>(error.c_str()),
- error.size());
- }
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_TEST_H_
diff --git a/test/components/security_manager/include/security_manager/security_query_matcher.h b/test/components/security_manager/include/security_manager/security_query_matcher.h
deleted file mode 100644
index 178db9d2a..000000000
--- a/test/components/security_manager/include/security_manager/security_query_matcher.h
+++ /dev/null
@@ -1,105 +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.
- */
-
-#ifndef TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_QUERY_MATCHER_H_
-#define TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_QUERY_MATCHER_H_
-
-#include <gmock/gmock.h>
-#include <string>
-#include "utils/byte_order.h"
-#include "security_manager/security_query.h"
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-
-/*
- * Matcher for checking RawMessage with InternalError Query
- * Check error id
- */
-MATCHER_P(InternalErrorWithErrId, expectedErrorId,
- std::string(negation ? "is not" : "is")
- + " InternalError with selected error" ) {
- const size_t header_size =
- sizeof(security_manager::SecurityQuery::QueryHeader);
- if (arg->data_size() <= header_size) {
- *result_listener << "Size " << arg->data_size()
- << " bytes less or equal sizeof(QueryHeader)="
- << header_size;
- return false;
- }
- const uint8_t *data = arg->data();
- const uint8_t query_type = data[0];
- if (security_manager::SecurityQuery::NOTIFICATION != query_type) {
- *result_listener << "RawMessage is not notification, type=0x"
- << std::hex << static_cast<int>(query_type);
- return false;
- }
- // Read Big-Endian number
- const uint32_t query_id = data[1] << 16 |
- data[2] << 8 |
- data[3];
- if (security_manager::SecurityQuery::SEND_INTERNAL_ERROR != query_id) {
- *result_listener << "Notification is not InternalError, id=0x"
- << std::hex << query_id;
- return false;
- }
- const uint32_t json_size = data[8] << 24 |
- data[9] << 16 |
- data[10] << 8 |
- data[11];
- if (header_size + json_size >= arg->data_size()) {
- *result_listener << "InternalError contains only JSON data.";
- return false;
- }
- // Read err_id as bin data number
- const uint8_t *err_id =
- reinterpret_cast<const uint8_t *>(data + header_size + json_size);
- if (expectedErrorId != *err_id) {
- *result_listener << "InternalError id " << static_cast<int>(*err_id)
- << " and not equal error " << expectedErrorId;
- return false;
- }
- return true;
-}
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-/*
- * Matcher for checking QueryHeader equal in GTests
- */
-::testing::AssertionResult QueryHeader_EQ(
- const char *m_expr, const char *n_expr,
- const ::security_manager::SecurityQuery::QueryHeader &q1,
- const ::security_manager::SecurityQuery::QueryHeader &q2);
-
-#endif // TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_QUERY_MATCHER_H_
diff --git a/test/components/security_manager/include/security_manager/security_query_test.h b/test/components/security_manager/include/security_manager/security_query_test.h
deleted file mode 100644
index a6d363e72..000000000
--- a/test/components/security_manager/include/security_manager/security_query_test.h
+++ /dev/null
@@ -1,461 +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.
- */
-
-#ifndef TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_QUERY_TEST_H_
-#define TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_QUERY_TEST_H_
-
-#include <gtest/gtest.h>
-#include <vector>
-#include <string>
-#include "security_manager/security_query.h"
-#include "protocol_handler/protocol_payload.h"
-#include "utils/byte_order.h"
-#include "security_manager/security_manager_mock.h"
-#include "security_manager/security_query_matcher.h"
-
-// Test values for compare after serialization and byteorder conversion
-#define SEQ_NUMBER 0x12345678u
-#define CONNECTION_KEY 0xABCDEF0u
-
-namespace test {
-namespace components {
-namespace security_manager_test {
-
- using ::security_manager::SecurityQuery;
-
- class SecurityQueryTest: public ::testing::Test {
- protected:
- void SetUp() OVERRIDE {
- // init_header used for SecurityQuery initialization
- init_header.query_type = SecurityQuery::NOTIFICATION;
- init_header.query_id = SecurityQuery::SEND_HANDSHAKE_DATA;
- init_header.seq_number = SEQ_NUMBER;
- init_header.json_size = 0u;
-
- // invalid_header is default (not initialized) QueryHeader
- invalid_header.query_type = SecurityQuery::INVALID_QUERY_TYPE;
- invalid_header.query_id = SecurityQuery::INVALID_QUERY_ID;
- invalid_header.seq_number = 0u;
- invalid_header.json_size = 0u;
- }
- /*
- * Wrapper for fast call SecurityQuery::SerializeQuery
- * Used for handling header and data array to byte array for serialization
- */
- std::vector<uint8_t> DeserializeData(
- SecurityQuery::QueryHeader header,
- const uint8_t *const binary_data,
- const size_t bin_data_size) const {
- // convert to Big-Endian (network) order
- const uint32_t query_id = header.query_id << 8;
- header.query_id = LE_TO_BE32(query_id);
- header.seq_number = LE_TO_BE32(header.seq_number);
- header.json_size = LE_TO_BE32(header.json_size);
- std::vector<uint8_t> vector;
- vector.reserve(sizeof(header) + bin_data_size);
- // copy header data
- const uint8_t* header_data = reinterpret_cast<uint8_t*>(&header);
- vector.insert(vector.end(), header_data, header_data + sizeof(header));
- // copy all data
- vector.insert(vector.end(), binary_data, binary_data + bin_data_size);
- return vector;
- }
- SecurityQuery::QueryHeader init_header, invalid_header;
- };
- /*
- * Security QueryHeader shall be the same size as RPC header
- * for correct working on Mobile side (3*8 byte)
- */
- TEST_F(SecurityQueryTest, Equal_RPCHeader) {
- ASSERT_EQ(sizeof(SecurityQuery::QueryHeader)*8,
- ::protocol_handler::ProtocolPayloadV2SizeBits());
- }
- /*
- * Security QueryHeader default construction
- */
- TEST_F(SecurityQueryTest, QueryHeaderConstructor) {
- const SecurityQuery::QueryHeader new_header;
-
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, new_header, invalid_header);
- }
- /*
- * Security QueryHeader shall construct with correct fields
- */
- TEST_F(SecurityQueryTest, QueryHeaderConstructor2) {
- SecurityQuery::QueryHeader new_header(SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_HANDSHAKE_DATA,
- SEQ_NUMBER);
- ASSERT_EQ(new_header.query_type, SecurityQuery::NOTIFICATION);
- ASSERT_EQ(new_header.query_id, SecurityQuery::SEND_HANDSHAKE_DATA);
- ASSERT_EQ(new_header.seq_number, SEQ_NUMBER);
- ASSERT_EQ(new_header.json_size, 0u);
-
- SecurityQuery::QueryHeader new_header2(SecurityQuery::RESPONSE,
- SecurityQuery::SEND_INTERNAL_ERROR,
- SEQ_NUMBER + 1);
- ASSERT_EQ(new_header2.query_type, SecurityQuery::RESPONSE);
- ASSERT_EQ(new_header2.query_id, SecurityQuery::SEND_INTERNAL_ERROR);
- ASSERT_EQ(new_header2.seq_number, SEQ_NUMBER + 1);
- ASSERT_EQ(new_header2.json_size, 0u);
- }
- /*
- * Security QueryHeader shall copy of all filed on construction from copy
- */
- TEST_F(SecurityQueryTest, QueryHeaderCopyConstructor) {
- SecurityQuery::QueryHeader new_header(init_header);
-
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, new_header, init_header);
- }
- /*
- * Security QueryHeader shall construct with NULL fields
- */
- TEST_F(SecurityQueryTest, QueryConstructor) {
- const SecurityQuery query;
-
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_TRUE(query.get_json_message().empty());
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_header);
-
- // Deserialization shall return invalid header as vector
- const std::vector<uint8_t> vector = DeserializeData(invalid_header, NULL, 0);
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
- /*
- * Security QueryHeader shall construct with specified fields
- */
- TEST_F(SecurityQueryTest, QueryConstructor2) {
- const SecurityQuery query(init_header, CONNECTION_KEY);
-
- ASSERT_EQ(query.get_connection_key(), CONNECTION_KEY);
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_TRUE(query.get_json_message().empty());
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
-
- // Deserialization shall return init header as vector
- const std::vector<uint8_t> vector = DeserializeData(init_header, NULL, 0);
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
- /*
- * Security QueryHeader shall construct with specified fields
- */
- TEST_F(SecurityQueryTest, QueryConstructor3) {
- uint8_t raw_data[] = {0x0, 0x1, 0x2};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
-
- SecurityQuery query(init_header,
- CONNECTION_KEY,
- raw_data, raw_data_size);
-
- ASSERT_EQ(query.get_connection_key(), CONNECTION_KEY);
- ASSERT_EQ(query.get_data_size(), raw_data_size);
- // query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- for (size_t i = 0; i < raw_data_size; ++i) {
- ASSERT_EQ(query.get_data()[i], raw_data[i]);
- }
- ASSERT_TRUE(query.get_json_message().empty());
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
-
- // Deserialization shall return vector equal header + data array
- const std::vector<uint8_t> vector =
- DeserializeData(init_header, raw_data, raw_data_size);
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
- /*
- * Security Query setters
- */
- TEST_F(SecurityQueryTest, Setters) {
- const std::string str = "test example string";
- uint8_t raw_data[] = {0x6, 0x7, 0x8};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
-
- SecurityQuery query;
- query.set_connection_key(CONNECTION_KEY);
- query.set_data(raw_data, raw_data_size);
- query.set_json_message(str);
- query.set_header(init_header);
-
- ASSERT_EQ(query.get_connection_key(), CONNECTION_KEY);
- ASSERT_EQ(query.get_data_size(), raw_data_size);
- // query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- for (size_t i = 0; i < raw_data_size; ++i) {
- ASSERT_EQ(query.get_data()[i], raw_data[i]);
- }
- ASSERT_EQ(query.get_json_message(), str);
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
- }
- /*
- * SecurityQuery serializes NULL data
- */
- TEST_F(SecurityQueryTest, Parse_NullData) {
- SecurityQuery query;
- const bool result = query.SerializeQuery(NULL, 0u);
-
- ASSERT_FALSE(result);
- // check side-effects
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_TRUE(query.get_json_message().empty());
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_header);
- }
- /*
- * SecurityQuery serializes few (less header size) data
- */
- TEST_F(SecurityQueryTest, Parse_LessHeaderData) {
- std::vector<uint8_t> vector(sizeof(init_header) - 1, 0);
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
-
- ASSERT_FALSE(result);
- // check side-effects
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_TRUE(query.get_json_message().empty());
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_header);
- }
- /*
- * SecurityQuery serializes data equal header size
- */
- TEST_F(SecurityQueryTest, Parse_HeaderData) {
- const std::vector<uint8_t> vector =
- DeserializeData(init_header, NULL, 0u);
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
-
- ASSERT_TRUE(result);
- // check side-effects
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_TRUE(query.get_json_message().empty());
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
-
- // Deserialization shall return vector equal serialization vector
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
- /*
- * SecurityQuery serializes wrong header
- */
- TEST_F(SecurityQueryTest, Parse_HeaderDataWrong) {
- // Wrong json size
- init_header.json_size = 0x0FFFFFFF;
- const std::vector<uint8_t> vector =
- DeserializeData(init_header, NULL, 0u);
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
-
- ASSERT_FALSE(result);
- // check side-effects
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_TRUE(query.get_json_message().empty());
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), init_header);
-
- // Deserialization shall return vector equal serialization vector
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
- /*
- * SecurityQuery serializes data contains header and binary data
- * with INVALID_QUERY_TYPE
- */
- TEST_F(SecurityQueryTest, Parse_InvalidQuery) {
- SecurityQuery::QueryHeader invalid_query_header(
- SecurityQuery::INVALID_QUERY_TYPE,
- SecurityQuery::INVALID_QUERY_ID,
- SEQ_NUMBER);
-
- // some sample data
- uint8_t raw_data[] = {0x6, 0x7, 0x8};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
-
- const std::vector<uint8_t> vector =
- DeserializeData(invalid_query_header, raw_data, raw_data_size);
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
-
- ASSERT_TRUE(result);
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_query_header);
- ASSERT_EQ(query.get_data_size(), raw_data_size);
- // query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- for (size_t i = 0; i < raw_data_size; ++i) {
- ASSERT_EQ(query.get_data()[i], raw_data[+ i]);
- }
- // check side-effects
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_TRUE(query.get_json_message().empty());
-
- // Deserialization shall return vector equal serialization vector
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
- /*
- * SecurityQuery serializes data contains header and binary data
- * with unknown types and ids
- */
- TEST_F(SecurityQueryTest, Parse_InvalidQuery_UnknownTypeId) {
- SecurityQuery::QueryHeader invalid_type_id_header(
- SecurityQuery::INVALID_QUERY_TYPE - 1,
- // Use not enum value for additional testing
- SecurityQuery::INVALID_QUERY_ID - 1,
- SEQ_NUMBER);
-
- const std::vector<uint8_t> vector =
- DeserializeData(invalid_type_id_header, NULL, 0u);
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
- ASSERT_TRUE(result);
- // Parse set all unknown types and ids to INVALID_QUERY_ID
- invalid_type_id_header.query_type = SecurityQuery::INVALID_QUERY_TYPE;
- invalid_type_id_header.query_id = SecurityQuery::INVALID_QUERY_ID;
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_type_id_header);
- // check side-effects
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_TRUE(query.get_json_message().empty());
- }
- /*
- * Security QueryH Parse data contains header and binary data
- * with unknown types and ids
- */
- TEST_F(SecurityQueryTest, Parse_InvalidQuery_UnknownId_Response) {
- SecurityQuery::QueryHeader invalid_id_header(
- SecurityQuery::RESPONSE,
- // Use not enum value for additional testing
- SecurityQuery::INVALID_QUERY_ID - 2,
- SEQ_NUMBER);
- const std::vector<uint8_t> vector =
- DeserializeData(invalid_id_header, NULL, 0u);
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
- ASSERT_TRUE(result);
- // Parse set all unknown types and ids to INVALID_QUERY_ID
- invalid_id_header.query_id = SecurityQuery::INVALID_QUERY_ID;
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), invalid_id_header);
- // check side-effects
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_TRUE(query.get_json_message().empty());
- }
- /*
- * SecurityQuery serializes data contains header and binary data
- * with INVALID_QUERY_TYPE
- */
- TEST_F(SecurityQueryTest, Parse_Handshake) {
- SecurityQuery::QueryHeader handshake_header(
- SecurityQuery::NOTIFICATION,
- SecurityQuery::SEND_HANDSHAKE_DATA,
- SEQ_NUMBER);
- // some sample data
- uint8_t raw_data[] = {0x6, 0x7, 0x8};
- const size_t raw_data_size =
- sizeof(raw_data)/sizeof(raw_data[0]);
-
- const std::vector<uint8_t> vector =
- DeserializeData(handshake_header, raw_data, raw_data_size);
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
- ASSERT_TRUE(result);
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), handshake_header);
- ASSERT_EQ(query.get_data_size(), raw_data_size);
- // query shall handle own array of byte data
- ASSERT_NE(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- for (size_t i = 0; i < raw_data_size; ++i) {
- ASSERT_EQ(query.get_data()[i], raw_data[+ i]);
- }
- // check side-effects
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_TRUE(query.get_json_message().empty());
-
- // Deserialization shall return vector equal serialization vector
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
- /*
- * SecurityQuery serializes data contains header and binary data
- * with SEND_HANDSHAKE_DATA
- */
- TEST_F(SecurityQueryTest, Parse_InternalError) {
- std::string error_str = "{some error}";
- SecurityQuery::QueryHeader internal_error_header(
- SecurityQuery::REQUEST,
- SecurityQuery::SEND_INTERNAL_ERROR,
- SEQ_NUMBER);
- internal_error_header.json_size = error_str.size();
-
- const uint8_t* raw_data = reinterpret_cast<const uint8_t*>(error_str.c_str());
-
- const std::vector<uint8_t> vector =
- DeserializeData(internal_error_header, raw_data, error_str.size());
-
- SecurityQuery query;
- const bool result = query.SerializeQuery(&vector[0], vector.size());
- ASSERT_TRUE(result);
- EXPECT_PRED_FORMAT2(QueryHeader_EQ, query.get_header(), internal_error_header);
- // check side-effects
- ASSERT_EQ(query.get_data_size(), 0u);
- ASSERT_EQ(query.get_data(), reinterpret_cast<uint8_t *>(NULL));
- ASSERT_EQ(query.get_connection_key(), 0u);
- ASSERT_EQ(query.get_json_message(), error_str);
-
- // Deserialization shall return vector equal serialization vector
- const std::vector<uint8_t> deserialize_vector = query.DeserializeQuery();
- ASSERT_EQ(deserialize_vector, vector);
- }
-} // namespace security_manager_test
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_SECURITY_MANAGER_INCLUDE_SECURITY_MANAGER_SECURITY_QUERY_TEST_H_
diff --git a/test/components/security_manager/src/crypto_manager_impl_test.cc b/test/components/security_manager/src/crypto_manager_impl_test.cc
deleted file mode 100644
index 324d7def8..000000000
--- a/test/components/security_manager/src/crypto_manager_impl_test.cc
+++ /dev/null
@@ -1,33 +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 "security_manager/crypto_manager_impl_test.h"
diff --git a/test/components/security_manager/src/security_manager_test.cc b/test/components/security_manager/src/security_manager_test.cc
deleted file mode 100644
index b6e2d104a..000000000
--- a/test/components/security_manager/src/security_manager_test.cc
+++ /dev/null
@@ -1,33 +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 "security_manager/security_manager_test.h"
diff --git a/test/components/security_manager/src/security_query_matcher.cc b/test/components/security_manager/src/security_query_matcher.cc
deleted file mode 100644
index 93f7082af..000000000
--- a/test/components/security_manager/src/security_query_matcher.cc
+++ /dev/null
@@ -1,55 +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 "security_manager/security_query_matcher.h"
-
-::testing::AssertionResult QueryHeader_EQ(
- const char* m_expr, const char* n_expr,
- const ::security_manager::SecurityQuery::QueryHeader& q1,
- const ::security_manager::SecurityQuery::QueryHeader& q2 ) {
- ::testing::AssertionResult fail_result = ::testing::AssertionFailure();
- fail_result << "(\"" << m_expr << " and \"" << n_expr << "\") are not equal "
- << " : different ";
- if (q1.json_size != q2.json_size)
- return fail_result << "json_size_1=" << q1.json_size
- << ", json_size_2=" << q2.json_size;
- if (q1.query_id != q2.query_id)
- return fail_result << "query_id_1=" << q1.query_id
- << ", query_id_2=" << q2.query_id;
- if (q1.query_type != q2.query_type)
- return fail_result << "query_type_1=" << q1.query_type
- << ", query_type_2=" << q2.query_type;
- if (q1.seq_number != q2.seq_number)
- return fail_result << "seq_number_1=" << q1.seq_number
- << ", seq_number_2=" << q2.seq_number;
- return ::testing::AssertionSuccess();
-}
diff --git a/test/components/security_manager/src/security_query_test.cc b/test/components/security_manager/src/security_query_test.cc
deleted file mode 100644
index 715305b34..000000000
--- a/test/components/security_manager/src/security_query_test.cc
+++ /dev/null
@@ -1,33 +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 "security_manager/security_query_test.h"
diff --git a/test/components/smart_objects/CMakeLists.txt b/test/components/smart_objects/CMakeLists.txt
deleted file mode 100644
index aec00f197..000000000
--- a/test/components/smart_objects/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-add_definitions(-DUNIT_TESTS)
-
-# --- SchemaItems
-add_subdirectory(./SchemaItem)
-
-include_directories (
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
- ${GMOCK_INCLUDE_DIRECTORY}
- ../../../src/components/smart_objects/include
- ../../../src/components/formatters/include/
- ${JSONCPP_INCLUDE_DIRECTORY}
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- SmartObjects
- formatters
- jsoncpp
- ${RTLIB}
- ProtocolLibrary
-)
-
-set (SOURCES
- ./SmartObjectDraftTest.cc
- ./SmartObjectInvalidTest.cc
- ./SmartObjectStressTest.cc
- ./SmartObjectUnitTest.cc
- ./TSharedPtrTest.cc
-)
-
-add_library(test_SmartObject ${SOURCES})
-create_test(test_SmartObjectTest "${SOURCES}" "${LIBRARIES}")
-
-create_test("test_SmartObject_ConvertionTimeTest" "./SmartObjectConvertionTimeTest.cc" "${LIBRARIES}")
-create_test("test_SmartObject_PerformanceTest" "./smart_object_performance_test.cc" "${LIBRARIES}")
-create_test("test_Map_PerformanceTest" "./map_performance_test.cc" "${LIBRARIES}")
diff --git a/test/components/smart_objects/SchemaItem/AlwaysFalseSchemaItemTest.cpp b/test/components/smart_objects/SchemaItem/AlwaysFalseSchemaItemTest.cpp
deleted file mode 100644
index 0073a5d65..000000000
--- a/test/components/smart_objects/SchemaItem/AlwaysFalseSchemaItemTest.cpp
+++ /dev/null
@@ -1,92 +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.
-
-#include <string>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/always_false_schema_item.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SchemaItem {
-using namespace NsSmartDeviceLink::NsSmartObjects;
-
-/**
- * Test AlwaysFalseSchemaItem
- **/
-TEST(test_AlwaysFalseSchemaItemTest, simple_test) {
- SmartObject obj;
-
- ISchemaItemPtr item = CAlwaysFalseSchemaItem::create();
-
- obj = 5;
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::ERROR, resultType);
- EXPECT_EQ(5, obj.asInt());
-
- obj = true;
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::ERROR, resultType);
- EXPECT_TRUE(obj.asBool());
-
- obj = "Test";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::ERROR, resultType);
- EXPECT_EQ(std::string("Test"), obj.asString());
-
- obj["First"] = "Some string";
- obj["Second"] = 555;
- resultType = item->validate(obj["First"]);
- EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj["Second"]);
- EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::ERROR, resultType);
- EXPECT_EQ(std::string("Some string"), obj["First"].asString());
- EXPECT_EQ(555, obj["Second"].asInt());
-
- obj[0] = true;
- obj[1] = false;
- resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::ERROR, resultType);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::ERROR, resultType);
- EXPECT_TRUE(obj[0].asBool());
- EXPECT_FALSE(obj[1].asBool());
-}
-} // namespace SchemaItem
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
diff --git a/test/components/smart_objects/SchemaItem/AlwaysTrueSchemaItemTest.cpp b/test/components/smart_objects/SchemaItem/AlwaysTrueSchemaItemTest.cpp
deleted file mode 100644
index 676eb4040..000000000
--- a/test/components/smart_objects/SchemaItem/AlwaysTrueSchemaItemTest.cpp
+++ /dev/null
@@ -1,94 +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.
-
-#include <string>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/always_true_schema_item.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SchemaItem {
-
-using namespace NsSmartDeviceLink::NsSmartObjects;
-
-/**
- * Test AlwaysTrueSchemaItem
- **/
-TEST(test_AlwaysTrueSchemaItemTest, simple_test) {
- SmartObject obj;
-
- ISchemaItemPtr item = CAlwaysTrueSchemaItem::create();
-
- obj = 5;
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(5, obj.asInt());
-
- obj = true;
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_TRUE(obj.asBool());
-
- obj = "Test";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(std::string("Test"), obj.asString());
-
- obj["First"] = "Some string";
- obj["Second"] = 555;
- resultType = item->validate(obj["First"]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["Second"]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(std::string("Some string"), obj["First"].asString());
- EXPECT_EQ(555, obj["Second"].asInt());
-
-
- obj[0] = true;
- obj[1] = false;
- resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_TRUE(obj[0].asBool());
- EXPECT_FALSE(obj[1].asBool());
-}
-} // namespace SchemaItem
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
diff --git a/test/components/smart_objects/SchemaItem/CMakeLists.txt b/test/components/smart_objects/SchemaItem/CMakeLists.txt
deleted file mode 100644
index bc2f0a1ff..000000000
--- a/test/components/smart_objects/SchemaItem/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-include_directories (
- ../../../../src/components/utils/include
- ${GMOCK_INCLUDE_DIRECTORY}
- ../../../../src/components/smart_objects/include
- ../../../../src/components/formatters/include/
- ${JSONCPP_INCLUDE_DIRECTORY}
- ../../../../src/components/formatters/include/
-)
-
-# Libraries are the same for all SchemaItem tests
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- SmartObjects
- formatters
- jsoncpp
-)
-
-set (SOURCES
- ./test_BoolSchemaItemTest.cpp
- ./test_NumberSchemaItemTest.cpp
- ./test_StringSchemaItemTest.cpp
- ./test_ArraySchemaItemTest.cpp
- ./test_CObjectSchemaItem.cpp
- ./AlwaysTrueSchemaItemTest.cpp
- ./AlwaysFalseSchemaItemTest.cpp
-)
-
-add_library(test_SmartObjectSchema ${SOURCES})
-create_test(test_SmartObjectSchemaTest "${SOURCES}" "${LIBRARIES}")
diff --git a/test/components/smart_objects/SchemaItem/EnumSchemaItemTest.cpp b/test/components/smart_objects/SchemaItem/EnumSchemaItemTest.cpp
deleted file mode 100644
index b1c267128..000000000
--- a/test/components/smart_objects/SchemaItem/EnumSchemaItemTest.cpp
+++ /dev/null
@@ -1,277 +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.
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/enum_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-
-#include <string>
-
-
-namespace test { namespace components { namespace SmartObjects { namespace SchemaItem {
-
- using namespace NsSmartDeviceLink::NsSmartObjects;
- namespace TestType {
- enum eType {
- INVALID_ENUM = -1,
- USER_EXIT = 0,
- IGNITION_OFF,
- BLUETOOTH_OFF,
- USB_DISCONNECTED,
- TOO_MANY_REQUESTS,
- MASTER_RESET,
- FACTORY_DEFAULTS,
- APP_UNAUTHORIZED
- };
- }
-
- class EnumSchemaItemTest : public ::testing::Test {
- public:
-
- protected:
- EnumSchemaItemTest() {
- testEnum.insert(TestType::USER_EXIT);
- testEnum.insert(TestType::IGNITION_OFF);
- testEnum.insert(TestType::BLUETOOTH_OFF);
- testEnum.insert(TestType::USB_DISCONNECTED);
- testEnum.insert(TestType::TOO_MANY_REQUESTS);
- testEnum.insert(TestType::MASTER_RESET);
- testEnum.insert(TestType::FACTORY_DEFAULTS);
- testEnum.insert(TestType::APP_UNAUTHORIZED);
- }
-
- virtual void SetUp() {
- }
-
- std::set<TestType::eType> testEnum;
- };
-
- /**
- * Test EnumSchemaItem
- *
- * Create SchemaItem with default value. Method setDefaultValue should return true,
- * SmartObject should contain default value.
- * Not Enum SmartObject should converted to intObject and setted up by the default value.
- **/
- TEST_F(EnumSchemaItemTest, test_item_with_default_value)
- {
- SmartObject obj;
- ISchemaItemPtr item = TEnumSchemaItem<TestType::eType>::create(testEnum,
- TSchemaItemParameter<TestType::eType>(TestType::FACTORY_DEFAULTS));
-
- //Object - valid enum
- obj = TestType::BLUETOOTH_OFF;
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
-
- //Obj - bool
- obj = true;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
-
- //Object - number
- obj = 3.1415926;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
-
- //Object - string
- obj = "Some string";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
- }
-
- /**
- * Test EnumSchemaItem with default value
- *
- * Create SchemaItem without default value. Method setDefaultValue should return false,
- * SmartObject should contain previous value.
- **/
- TEST_F(EnumSchemaItemTest, test_item_without_default_value)
- {
- SmartObject obj;
-
- ISchemaItemPtr item = TEnumSchemaItem<TestType::eType>::create(testEnum,
- TSchemaItemParameter<TestType::eType>());
-
- //Object - valid enum
- obj = TestType::BLUETOOTH_OFF;
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_EQ(TestType::BLUETOOTH_OFF, obj.asInt());
-
- //Obj - bool
- obj = true;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_TRUE(obj.asBool());
-
- //Object - number
- obj = 3.1415926;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_EQ(3.1415926, obj.asDouble());
-
- //Object - string
- obj = "Some string";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_EQ(std::string("Some string"), obj.asString());
-
- //Object - int in range of enum
- obj = 6;
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object - int out of enum range
- obj = 15;
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- }
-
- /**
- * Test apply and unapply EnumSchemaItem
- **/
- TEST_F(EnumSchemaItemTest, test_apply_unapply_schema)
- {
- SmartObject obj;
-
- ISchemaItemPtr item = TEnumSchemaItem<TestType::eType>::create(testEnum,
- TSchemaItemParameter<TestType::eType>(TestType::FACTORY_DEFAULTS));
-
- //Object - valid enum
- obj = TestType::BLUETOOTH_OFF;
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
-
- item->unapplySchema(obj);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- EXPECT_EQ(std::string("FACTORY_DEFAULTS"), obj.asString());
-
- item->applySchema(obj);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(TestType::FACTORY_DEFAULTS, obj.asInt());
-
- obj = "TOO_MANY_REQUESTS";
- item->applySchema(obj);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(TestType::TOO_MANY_REQUESTS, obj.asInt());
-
- obj = "ENOUGH_REQUESTS";
- item->applySchema(obj);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- EXPECT_EQ(std::string("ENOUGH_REQUESTS"), obj.asString());
- }
-
-}}}}
-
-namespace NsSmartDeviceLink {
-namespace NsSmartObjects {
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::EnumToCStringMap
-EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::CStringToEnumMap
-EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::cstring_values_[] = {
- "USER_EXIT",
- "IGNITION_OFF",
- "BLUETOOTH_OFF",
- "USB_DISCONNECTED",
- "TOO_MANY_REQUESTS",
- "MASTER_RESET",
- "FACTORY_DEFAULTS",
- "APP_UNAUTHORIZED"
-};
-
-template<>
-const test::components::SmartObjects::SchemaItem::TestType::eType
-EnumConversionHelper<test::components::SmartObjects::SchemaItem::TestType::eType>::enum_values_[] = {
- test::components::SmartObjects::SchemaItem::TestType::USER_EXIT,
- test::components::SmartObjects::SchemaItem::TestType::IGNITION_OFF,
- test::components::SmartObjects::SchemaItem::TestType::BLUETOOTH_OFF,
- test::components::SmartObjects::SchemaItem::TestType::USB_DISCONNECTED,
- test::components::SmartObjects::SchemaItem::TestType::TOO_MANY_REQUESTS,
- test::components::SmartObjects::SchemaItem::TestType::MASTER_RESET,
- test::components::SmartObjects::SchemaItem::TestType::FACTORY_DEFAULTS,
- test::components::SmartObjects::SchemaItem::TestType::APP_UNAUTHORIZED
-};
-
-}
-}
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/smart_objects/SchemaItem/test_ArraySchemaItemTest.cpp b/test/components/smart_objects/SchemaItem/test_ArraySchemaItemTest.cpp
deleted file mode 100644
index d923d1855..000000000
--- a/test/components/smart_objects/SchemaItem/test_ArraySchemaItemTest.cpp
+++ /dev/null
@@ -1,347 +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.
-
-#include <string>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/array_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SchemaItem {
-
-/**
- * Test ArraySchemaItem no schema item, no min and max size
- **/
-TEST(test_no_default_value, test_ArraySchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CArraySchemaItem::create(); // No schema item, no min and max size
-
- obj[0] = 38;
- obj[1] = true;
- obj[2] = "New String";
- obj[3][0] = 39;
- obj[3][1] = false;
- obj[3][2] = "Another String";
-
- EXPECT_EQ(38, obj[0].asInt());
- EXPECT_TRUE(obj[1].asBool());
- EXPECT_EQ(std::string("New String"), obj[2].asString());
- EXPECT_EQ(39, obj[3][0].asInt());
- EXPECT_FALSE(obj[3][1].asBool());
- EXPECT_EQ(std::string("Another String"), obj[3][2].asString());
-
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[3]);
- EXPECT_EQ(Errors::OK, resultType);
-
- item->applySchema(obj);
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[3]);
- EXPECT_EQ(Errors::OK, resultType);
-
- EXPECT_EQ(38, obj[0].asInt());
- EXPECT_TRUE(obj[1].asBool());
- EXPECT_EQ(std::string("New String"), obj[2].asString());
- EXPECT_EQ(39, obj[3][0].asInt());
- EXPECT_FALSE(obj[3][1].asBool());
- EXPECT_EQ(std::string("Another String"), obj[3][2].asString());
-
- //Object - valid string
- obj = "New valid string";
- ASSERT_EQ(std::string("New valid string"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- //Obj - bool
- obj = true;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- //Object - number
- obj = 3.1415926;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-}
-
-/**
- * Test ArraySchemaItem with schema item
- *
- * Create ArraySchemaItem with schema item. Method validate should return true
- * only if all array elements are valid schema item objects
- **/
-TEST(test_item_with_default_value, test_ArraySchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CArraySchemaItem::create(); // No min and max size
-
- obj[0] = "Some String";
- obj[1] = "true";
- obj[2] = "New String";
-
- EXPECT_EQ(std::string("Some String"), obj[0].asString());
- EXPECT_EQ(std::string("true"), obj[1].asString());
- EXPECT_EQ(std::string("New String"), obj[2].asString());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- item->applySchema(obj);
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[2]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- EXPECT_EQ(std::string("Some String"), obj[0].asString());
- EXPECT_EQ(std::string("true"), obj[1].asString());
- EXPECT_EQ(std::string("New String"), obj[2].asString());
-
- obj[3][0] = "39";
- obj[3][1] = "false";
- obj[3][2] = "Another String";
-
- EXPECT_EQ(std::string("39"), obj[3][0].asString());
- EXPECT_EQ(std::string("false"), obj[3][1].asString());
- EXPECT_EQ(std::string("Another String"), obj[3][2].asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[3]);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj[3][3] = "Another very very loooooong String";
-
- resultType = item->validate(obj[3]);
- EXPECT_EQ(Errors::OK, resultType);
-}
-
-/**
- * Test ArraySchemaItem with min size
- **/
-TEST(test_array_with_min_size, test_ArraySchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CArraySchemaItem::create(
- CStringSchemaItem::create(TSchemaItemParameter<size_t>(25)),
- TSchemaItemParameter<size_t>(3));
-
- obj[0] = "Some String";
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- obj[1] = "true";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- obj[2] = "New String";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- EXPECT_EQ(std::string("Some String"), obj[0].asString());
- EXPECT_EQ(std::string("true"), obj[1].asString());
- EXPECT_EQ(std::string("New String"), obj[2].asString());
-}
-
-/**
- * Test ArraySchemaItem with min size
- **/
-TEST(test_array_with_max_size, test_ArraySchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CArraySchemaItem::create(
- CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(),
- TSchemaItemParameter<size_t>(25)),
- TSchemaItemParameter<size_t>(),
- TSchemaItemParameter<size_t>(3)); // No min size
-
- obj[0] = "Some String";
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj[1] = "true";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj[2] = "New String";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj[3] = "Another String";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- EXPECT_EQ(std::string("Some String"), obj[0].asString());
- EXPECT_EQ(std::string("true"), obj[1].asString());
- EXPECT_EQ(std::string("New String"), obj[2].asString());
- EXPECT_EQ(std::string("Another String"), obj[3].asString());
-}
-
-/**
- * Test ArraySchemaItem with min and max size
- **/
-TEST(test_array_with_min_and_max_size, test_ArraySchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CArraySchemaItem::create(
- CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(),
- TSchemaItemParameter<size_t>(25)),
- TSchemaItemParameter<size_t>(2),
- TSchemaItemParameter<size_t>(4));
-
- obj[0] = "Some String";
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- obj[1] = "true";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj[2] = "New String";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj[3] = "Another String";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj[4] = "Out of array";
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- EXPECT_EQ(std::string("Some String"), obj[0].asString());
- EXPECT_EQ(std::string("true"), obj[1].asString());
- EXPECT_EQ(std::string("New String"), obj[2].asString());
- EXPECT_EQ(std::string("Another String"), obj[3].asString());
- EXPECT_EQ(std::string("Out of array"), obj[4].asString());
-}
-
-TEST(test_map_validate, test_ArraySchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CArraySchemaItem::create(
- CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(),
- TSchemaItemParameter<size_t>(25)),
- TSchemaItemParameter<size_t>(2),
- TSchemaItemParameter<size_t>(4));
-
- obj["array"][0] = "Some String";
-
- int resultType = item->validate(obj["array"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- obj["array"][1] = "true";
-
- resultType = item->validate(obj["array"]);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj["array"][2] = "New String";
-
- resultType = item->validate(obj["array"]);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj["array"][3] = "Another String";
-
- resultType = item->validate(obj["array"]);
- EXPECT_EQ(Errors::OK, resultType);
-
- obj["array"][4] = "Out of array";
-
- resultType = item->validate(obj["array"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- EXPECT_EQ(std::string("Some String"), obj["array"][0].asString());
- EXPECT_EQ(std::string("true"), obj["array"][1].asString());
- EXPECT_EQ(std::string("New String"), obj["array"][2].asString());
- EXPECT_EQ(std::string("Another String"), obj["array"][3].asString());
- EXPECT_EQ(std::string("Out of array"), obj["array"][4].asString());
-}
-} // namespace SchemaItem
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
-
diff --git a/test/components/smart_objects/SchemaItem/test_BoolSchemaItemTest.cpp b/test/components/smart_objects/SchemaItem/test_BoolSchemaItemTest.cpp
deleted file mode 100644
index 18c6404ad..000000000
--- a/test/components/smart_objects/SchemaItem/test_BoolSchemaItemTest.cpp
+++ /dev/null
@@ -1,198 +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.
-
-#include <string>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "utils/shared_ptr.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/bool_schema_item.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SchemaItem {
-using NsSmartDeviceLink::NsSmartObjects::ISchemaItemPtr;
-
-/**
- * Test BoolSchemaItem no default value
- *
- * Create SchemaItem without default value. Method setDefaultValue should always return false
- * and leave SmartObject in previous state.
- **/
-TEST(test_no_default_value, test_BoolSchemaItemTest) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
-
- ISchemaItemPtr item =
- NsSmartDeviceLink::NsSmartObjects::CBoolSchemaItem::create(); // No default value
-
- obj = 5;
- ASSERT_EQ(5, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- obj = true;
- ASSERT_TRUE(obj.asBool());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_TRUE(obj.asBool());
-
- obj = "Test";
- ASSERT_EQ(std::string("Test"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-}
-
-/**
- * Test BoolSchemaItem with default value
- *
- * Create SchemaItem with default value. Method setDefaultValue should return true,
- * Bool SmartObject should contain default value.
- * Not bool SmartObject should converted to BoolObject and setted up by default value.
- **/
-TEST(test_item_with_default_value, test_BoolSchemaItemTest) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
-
- ISchemaItemPtr item =
- NsSmartDeviceLink::NsSmartObjects::CBoolSchemaItem::create(
- NsSmartDeviceLink::NsSmartObjects::TSchemaItemParameter<bool>
- (false)); // Default value = false
-
- obj = 5;
- ASSERT_EQ(5, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- obj = true;
- ASSERT_TRUE(obj.asBool());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_FALSE(obj.asBool());
-
- obj = "Test";
- ASSERT_EQ(std::string("Test"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_FALSE(obj.asBool());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
- EXPECT_FALSE(obj.asBool());
-}
-
-TEST(test_map_validate, test_BoolSchemaItemTest) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- ISchemaItemPtr item =
- NsSmartDeviceLink::NsSmartObjects::CBoolSchemaItem::create(
- NsSmartDeviceLink::NsSmartObjects::TSchemaItemParameter<bool>
- (false)); // Default value = false
-
- obj["aa"] = true;
- ASSERT_TRUE(obj["aa"].asBool());
-
- int resultType = item->validate(obj["aa"]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- bool resDefault = item->setDefaultValue(obj["aa"]);
- EXPECT_TRUE(resDefault);
- EXPECT_FALSE(obj["aa"].asBool());
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_FALSE(obj.asBool());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- obj["ind"] = true;
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-}
-
-TEST(test_array_validate, test_BoolSchemaItemTest) {
- NsSmartDeviceLink::NsSmartObjects::SmartObject obj;
- ISchemaItemPtr item = NsSmartDeviceLink::NsSmartObjects::CBoolSchemaItem::create();
-
- obj[0] = true;
- obj[1] = false;
-
- ASSERT_TRUE(obj[0].asBool());
- ASSERT_FALSE(obj[1].asBool());
-
- int resultType = item->validate(obj[0]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj[1]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- bool resDefault = item->setDefaultValue(obj[0]);
- EXPECT_FALSE(resDefault);
- EXPECT_TRUE(obj[0].asBool());
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_FALSE(obj[1].asBool());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- obj = false;
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-}
-} // namespace SchemaItem"
-} // namespace SmartObjects"
-} // namespace components"
-} // namespace test"
diff --git a/test/components/smart_objects/SchemaItem/test_CObjectSchemaItem.cpp b/test/components/smart_objects/SchemaItem/test_CObjectSchemaItem.cpp
deleted file mode 100644
index 54187e0d7..000000000
--- a/test/components/smart_objects/SchemaItem/test_CObjectSchemaItem.cpp
+++ /dev/null
@@ -1,488 +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 <string>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/smart_schema.h"
-#include "smart_objects/array_schema_item.h"
-#include "smart_objects/bool_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-#include "smart_objects/enum_schema_item.h"
-#include "smart_objects/number_schema_item.h"
-#include "smart_objects/schema_item_parameter.h"
-#include "smart_objects/object_schema_item.h"
-#include "formatters/generic_json_formatter.h"
-#include "formatters/CSmartFactory.hpp"
-
-namespace formatters = NsSmartDeviceLink::NsJSONHandler::Formatters;
-namespace smartobj = NsSmartDeviceLink::NsSmartObjects;
-
-using namespace NsSmartDeviceLink::NsSmartObjects;
-using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SchemaItem {
-
-namespace FunctionID {
-enum eType {
- INVALID_ENUM = -1,
- Function0 = 0,
- Function1,
- Function2,
- Function3,
- Function4,
- Function5,
- Function6
-};
-} // namespace FunctionID
-
-namespace ResultType {
-enum eType {
- INVALID_ENUM = -1,
- APPLICATION_NOT_REGISTERED = 0,
- SUCCESS,
- TOO_MANY_PENDING_REQUESTS,
- REJECTED,
- INVALID_DATA,
- OUT_OF_MEMORY,
- ABORTED,
- USER_DISALLOWED,
- GENERIC_ERROR,
- DISALLOWED
-};
-} // namespace ResultType
-
-namespace Keys {
-const char RESULT_CODE[] = "resultCode";
-const char INFO[] = "info";
-const char SUCCESS[] = "success";
-}
-
-class ObjectSchemaItemTest : public ::testing::Test {
- protected:
- ISchemaItemPtr schema_item;
- // Create SmartObjectSchema for test object
- void SetUp() {
- std::set<FunctionID::eType> function_values;
- function_values.insert(FunctionID::Function0);
- function_values.insert(FunctionID::Function1);
- function_values.insert(FunctionID::Function2);
- function_values.insert(FunctionID::Function3);
- function_values.insert(FunctionID::Function4);
- function_values.insert(FunctionID::Function5);
- function_values.insert(FunctionID::Function6);
-
- std::set<ResultType::eType> resultCode_values;
- resultCode_values.insert(ResultType::APPLICATION_NOT_REGISTERED);
- resultCode_values.insert(ResultType::SUCCESS);
- resultCode_values.insert(ResultType::TOO_MANY_PENDING_REQUESTS);
- resultCode_values.insert(ResultType::REJECTED);
- resultCode_values.insert(ResultType::INVALID_DATA);
- resultCode_values.insert(ResultType::OUT_OF_MEMORY);
- resultCode_values.insert(ResultType::ABORTED);
- resultCode_values.insert(ResultType::USER_DISALLOWED);
- resultCode_values.insert(ResultType::GENERIC_ERROR);
- resultCode_values.insert(ResultType::DISALLOWED);
-
- CObjectSchemaItem::Members paramsMembersMap;
- paramsMembersMap[S_FUNCTION_ID] =
- CObjectSchemaItem::SMember(
- TEnumSchemaItem<FunctionID::eType>::create(function_values), true);
- paramsMembersMap[S_CORRELATION_ID] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- paramsMembersMap[S_PROTOCOL_VERSION] =
- CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(1),
- TSchemaItemParameter<int>(2)), true);
-
- CObjectSchemaItem::Members schemaMembersMap;
- schemaMembersMap[Keys::RESULT_CODE] =
- CObjectSchemaItem::SMember(
- TEnumSchemaItem<ResultType::eType>::create(resultCode_values), false);
- schemaMembersMap[Keys::INFO] =
- CObjectSchemaItem::SMember(
- CStringSchemaItem::create(TSchemaItemParameter<size_t>(0),
- TSchemaItemParameter<size_t>(10)), false);
- schemaMembersMap[Keys::SUCCESS] =
- CObjectSchemaItem::SMember(CBoolSchemaItem::create(), false);
-
- CObjectSchemaItem::Members rootMembersMap;
- rootMembersMap[S_PARAMS] =
- CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), true);
- rootMembersMap[S_MSG_PARAMS] =
- CObjectSchemaItem::SMember(CObjectSchemaItem::create(schemaMembersMap), true);
-
- schema_item = CObjectSchemaItem::create(rootMembersMap);
- }
-};
-
-TEST_F(ObjectSchemaItemTest, validation_correct) {
- SmartObject obj;
- obj[S_PARAMS][S_FUNCTION_ID] = 0;
- obj[S_PARAMS][S_CORRELATION_ID] = 0XFF0;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 0;
- obj[S_MSG_PARAMS][Keys::INFO] = "0123456789";
- obj[S_MSG_PARAMS][Keys::SUCCESS] = true;
-
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-}
-
-TEST_F(ObjectSchemaItemTest, validation_correct_skip_not_mandatory) {
- SmartObject obj;
- obj[S_PARAMS][S_FUNCTION_ID] = 1;
- obj[S_PARAMS][S_CORRELATION_ID] = -0xFF1;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 1;
- // skip non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
- obj[S_MSG_PARAMS][Keys::SUCCESS] = false;
-
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-}
-
-TEST_F(ObjectSchemaItemTest, validation_invalid_param) {
- SmartObject obj;
- obj[S_PARAMS] = "some parameters";
- obj[S_MSG_PARAMS] = "some message parameters";
-
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- obj[S_PARAMS][S_FUNCTION_ID] = "some function";
- obj[S_PARAMS][S_CORRELATION_ID] = "some correlation id";
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 3;
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = "some result";
- obj[S_MSG_PARAMS][Keys::SUCCESS] = 0xABC;
-
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- obj[S_PARAMS][S_FUNCTION_ID] = 1;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- obj[S_PARAMS][S_CORRELATION_ID] = -0xFF1;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 1;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- obj[S_MSG_PARAMS][Keys::SUCCESS] = false;
-
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-}
-TEST_F(ObjectSchemaItemTest, validation_invalid_not_mandatory_param) {
- SmartObject obj;
- obj[S_PARAMS][S_FUNCTION_ID] = 0;
- obj[S_PARAMS][S_CORRELATION_ID] = 0XFF0;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 0;
- obj[S_MSG_PARAMS][Keys::SUCCESS] = true;
-
- // invalid non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
- obj[S_MSG_PARAMS][Keys::INFO] = 0x10;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- // invalid non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
- obj[S_MSG_PARAMS][Keys::INFO] = true;
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- // invalid non-mandatory obj[S_MSG_PARAMS][Keys::INFO]
- obj[S_MSG_PARAMS][Keys::INFO] = SmartObject();
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-
- obj[S_MSG_PARAMS][Keys::INFO] = "info";
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-}
-
-TEST_F(ObjectSchemaItemTest, validation_missing_mandatory) {
- SmartObject obj;
- // missed obj[S_PARAMS][S_FUNCTION_ID]
- // missed obj[S_PARAMS][S_CORRELATION_ID]
- // missed obj[S_PARAMS][S_PROTOCOL_VERSION]
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 2;
- obj[S_MSG_PARAMS][Keys::INFO] = "123";
- obj[S_MSG_PARAMS][Keys::SUCCESS] = false;
-
- EXPECT_EQ(Errors::MISSING_MANDATORY_PARAMETER, schema_item->validate(obj));
-
- obj[S_PARAMS][S_FUNCTION_ID] = 2;
- // S_CORRELATION_ID and S_PROTOCOL_VERSION is still missed
- EXPECT_EQ(Errors::MISSING_MANDATORY_PARAMETER, schema_item->validate(obj));
-
- obj[S_PARAMS][S_CORRELATION_ID] = 0XFF2;
- // S_PROTOCOL_VERSION is still missed
- EXPECT_EQ(Errors::MISSING_MANDATORY_PARAMETER, schema_item->validate(obj));
-
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-}
-
-TEST_F(ObjectSchemaItemTest, validation_unexpected_param) {
- const char* fake1 = "FAKE_PARAM1";
- const char* fake2 = "FAKE_PARAM2";
- const char* fake3 = "FAKE_PARAM3";
-
- SmartObject obj;
- obj[S_PARAMS][S_FUNCTION_ID] = 0;
- obj[S_PARAMS][S_CORRELATION_ID] = 0XFF;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 2;
- obj[S_MSG_PARAMS][Keys::INFO] = "123";
- obj[S_MSG_PARAMS][Keys::SUCCESS] = true;
-
- obj[fake1] = SmartObject(static_cast<int64_t>(0));
- // any fake parameter is OK
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-
- obj[S_PARAMS][fake2] = SmartObject("123");
- // any fake parameters are OK
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-
- obj[S_MSG_PARAMS][fake3] = true;
- // any fake parameters are OK
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-}
-
-TEST_F(ObjectSchemaItemTest, validation_unexpected_param_remove) {
- const char* fake1 = "FAKE_PARAM1";
- const char* fake2 = "FAKE_PARAM2";
- const char* fake3 = "FAKE_PARAM3";
-
- SmartObject obj = SmartObject(SmartType::SmartType_Map);
- obj[S_PARAMS][S_FUNCTION_ID] = 0;
- obj[S_PARAMS][S_CORRELATION_ID] = 0XFF;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- obj[S_MSG_PARAMS][Keys::RESULT_CODE] = 2;
- obj[S_MSG_PARAMS][Keys::INFO] = "123";
- obj[S_MSG_PARAMS][Keys::SUCCESS] = true;
-
- obj[fake1] = SmartObject(static_cast<int64_t>(0));
- obj[S_PARAMS][fake2] = SmartObject("123");
- obj[S_MSG_PARAMS][fake3] = true;
-
- // Check apply schema
- schema_item->applySchema(obj);
-
- EXPECT_TRUE(obj.keyExists(fake1));
- EXPECT_TRUE(obj[S_PARAMS].keyExists(fake2));
- EXPECT_TRUE(obj[S_MSG_PARAMS].keyExists(fake3));
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-
- // all fake parameters are removed on unapply schema
- schema_item->unapplySchema(obj);
-
- EXPECT_FALSE(obj.keyExists(fake1));
- EXPECT_FALSE(obj[S_PARAMS].keyExists(fake2));
- EXPECT_FALSE(obj[S_MSG_PARAMS].keyExists(fake3));
-
- obj[fake1] = SmartObject(static_cast<int64_t>(0));
- obj[S_PARAMS][fake2] = SmartObject("123");
- obj[S_MSG_PARAMS][fake3] = true;
-
- // Check unapply schema
- schema_item->unapplySchema(obj);
- // all fake parameters are removed on apply schema
- EXPECT_FALSE(obj.keyExists(fake1));
- EXPECT_FALSE(obj[S_PARAMS].keyExists(fake2));
- EXPECT_FALSE(obj[S_MSG_PARAMS].keyExists(fake3));
- // Invalide state after enum convertion
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-}
-
-TEST_F(ObjectSchemaItemTest, validation_empty_params) {
- SmartObject obj;
- obj[S_PARAMS][S_FUNCTION_ID] = 1;
- obj[S_PARAMS][S_CORRELATION_ID] = 0xFF;
- obj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- obj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- // S_MSG_PARAMS has only fake parameter
- obj[S_MSG_PARAMS]["FAKE_PARAM1"] = SmartObject();
- obj[S_MSG_PARAMS]["FAKE_PARAM2"] = SmartObject(0x1);
- obj[S_MSG_PARAMS]["FAKE_PARAM3"] = SmartObject("2");
-
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-
- schema_item->applySchema(obj);
- EXPECT_EQ(Errors::OK, schema_item->validate(obj));
-
- schema_item->unapplySchema(obj);
- // Invalide state after enum convertion
- EXPECT_EQ(Errors::INVALID_VALUE, schema_item->validate(obj));
-}
-
-TEST_F(ObjectSchemaItemTest, test_strings_to_enum_conversion) {
- SmartObject object;
- object[S_PARAMS][S_FUNCTION_ID] = SmartObject();
- object[S_PARAMS][S_CORRELATION_ID] = 0XFF0;
- object[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- object[S_MSG_PARAMS][Keys::RESULT_CODE] = SmartObject();
- object[S_MSG_PARAMS][Keys::INFO] = "0123456789";
- object[S_MSG_PARAMS][Keys::SUCCESS] = true;
-
- typedef EnumConversionHelper<ResultType::eType>::CStringToEnumMap Results;
- const Results results = EnumConversionHelper<ResultType::eType>::cstring_to_enum_map();
-
- typedef EnumConversionHelper<FunctionID::eType>::CStringToEnumMap Functions;
- const Functions functions =
- EnumConversionHelper<FunctionID::eType>::cstring_to_enum_map();
-
- for (Results::const_iterator res_it = results.begin(); res_it != results.end();
- ++res_it) {
- for (Functions::const_iterator func_it = functions.begin(); func_it != functions.end();
- ++func_it) {
- const char* const function_str = func_it->first;
- const char* const result_type_str = res_it->first;
- const FunctionID::eType function_type = func_it->second;
- const ResultType::eType result_type = res_it->second;
-
- object[S_PARAMS][S_FUNCTION_ID] = function_str;
- object[S_MSG_PARAMS][Keys::RESULT_CODE] = result_type_str;
-
- // S_FUNCTION_ID and RESULT_CODE are not converted to int
- EXPECT_NE(Errors::OK, schema_item->validate(object));
-
- schema_item->applySchema(object);
- EXPECT_EQ(Errors::OK, schema_item->validate(object));
-
- // check conversion result
- EXPECT_EQ(function_type,
- object[S_PARAMS][S_FUNCTION_ID].asInt());
- EXPECT_EQ(result_type,
- object[S_MSG_PARAMS][Keys::RESULT_CODE].asInt());
-
- schema_item->unapplySchema(object);
- // S_FUNCTION_ID and RESULT_CODE are string
- EXPECT_NE(Errors::OK, schema_item->validate(object));
-
- // check conversion result
- EXPECT_EQ(function_str,
- object[S_PARAMS][S_FUNCTION_ID].asString());
- EXPECT_EQ(result_type_str,
- object[S_MSG_PARAMS][Keys::RESULT_CODE].asString());
- }
- }
-}
-// ----------------------------------------------------------------------------
-} // namespace SchemaItem
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
-
-namespace NsSmartDeviceLink {
-namespace NsSmartObjects {
-
-namespace FunctionID = test::components::SmartObjects::SchemaItem::FunctionID;
-typedef EnumConversionHelper<FunctionID::eType> FunctionConvertor;
-
-template<>
-const FunctionConvertor::EnumToCStringMap
-FunctionConvertor::enum_to_cstring_map_ = FunctionConvertor::InitEnumToCStringMap();
-
-template<>
-const FunctionConvertor::CStringToEnumMap
-FunctionConvertor::cstring_to_enum_map_ = FunctionConvertor::InitCStringToEnumMap();
-
-template<>
-const char* const
-FunctionConvertor::cstring_values_[] = {
- "Function0",
- "Function1",
- "Function2",
- "Function3",
- "Function4",
- "Function5",
- "Function6"
-};
-
-template<>
-const FunctionID::eType
-FunctionConvertor::enum_values_[] = {
- FunctionID::Function0,
- FunctionID::Function1,
- FunctionID::Function2,
- FunctionID::Function3,
- FunctionID::Function4,
- FunctionID::Function5,
- FunctionID::Function6
-};
-
-// ----------------------------------------------------------------------------
-
-namespace ResultType = test::components::SmartObjects::SchemaItem::ResultType;
-typedef EnumConversionHelper<ResultType::eType> ResultTypeConvertor;
-
-template<>
-const ResultTypeConvertor::EnumToCStringMap
-ResultTypeConvertor::enum_to_cstring_map_ = ResultTypeConvertor::InitEnumToCStringMap();
-
-template<>
-const ResultTypeConvertor::CStringToEnumMap
-ResultTypeConvertor::cstring_to_enum_map_ = ResultTypeConvertor::InitCStringToEnumMap();
-
-template<>
-const char* const
-ResultTypeConvertor::cstring_values_[] = {
- "APPLICATION_NOT_REGISTERED",
- "SUCCESS",
- "TOO_MANY_PENDING_REQUESTS",
- "REJECTED",
- "INVALID_DATA",
- "OUT_OF_MEMORY",
- "ABORTED",
- "USER_DISALLOWED",
- "GENERIC_ERROR",
- "DISALLOWED"
-};
-
-template<>
-const ResultType::eType
-ResultTypeConvertor::enum_values_[] = {
- ResultType::APPLICATION_NOT_REGISTERED,
- ResultType::SUCCESS,
- ResultType::TOO_MANY_PENDING_REQUESTS,
- ResultType::REJECTED,
- ResultType::INVALID_DATA,
- ResultType::OUT_OF_MEMORY,
- ResultType::ABORTED,
- ResultType::USER_DISALLOWED,
- ResultType::GENERIC_ERROR,
- ResultType::DISALLOWED
-};
-} // namespace NsSmartObjects
-} // namespace NsSmartDeviceLink
diff --git a/test/components/smart_objects/SchemaItem/test_NumberSchemaItemTest.cpp b/test/components/smart_objects/SchemaItem/test_NumberSchemaItemTest.cpp
deleted file mode 100644
index 25d8fbdb7..000000000
--- a/test/components/smart_objects/SchemaItem/test_NumberSchemaItemTest.cpp
+++ /dev/null
@@ -1,781 +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.
-
-#include <string>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/number_schema_item.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SchemaItem {
-
-using NsSmartDeviceLink::NsSmartObjects::ISchemaItemPtr;
-
-/**
- * Test NumberSchemaItem as INT with no default value
- *
- * Create SchemaItem without default value. Method setDefaultValue should always return false
- * and leave SmartObject in previous state.
- **/
-TEST(test_int_no_default_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item =
- TNumberSchemaItem<int>::create(); // No default value, no min, no max
-
- //Object int
- obj = 5;
- ASSERT_EQ(5, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Obj bool
- obj = true;
- ASSERT_TRUE(obj.asBool());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- //Set default value
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- EXPECT_TRUE(obj.asBool());
-
- //Obj string
- obj = "Test";
- ASSERT_EQ(std::string("Test"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-}
-
-/**
- * Test NumberSchemaItem as INT with setted min value
- **/
-TEST(test_int_min_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<int>::create(TSchemaItemParameter<int>
- (10)); // No default value, no max value
-
- //Object int correct
- obj = 15;
- ASSERT_EQ(15, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = 9;
- ASSERT_EQ(9, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object int correct
- obj = 10;
- ASSERT_EQ(10, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-}
-
-/**
- * Test NumberSchemaItem as INT with setted max value
- **/
-TEST(test_int_max_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(),
- TSchemaItemParameter<int>(749) ); // No default value, no min value
-
- //Object int correct
- obj = 749;
- ASSERT_EQ(749, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = 750;
- ASSERT_EQ(750, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object int correct
- obj = -750;
- ASSERT_EQ(-750, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-}
-
-/**
- * Test NumberSchemaItem as INT with setted min and max value
- **/
-TEST(test_int_min_max_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(-949), TSchemaItemParameter<int>(749) ); // No default value
-
- //Object int correct
- obj = 749;
- ASSERT_EQ(749, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = 750;
- ASSERT_EQ(750, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object int correct
- obj = -949;
- ASSERT_EQ(-949, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = -950;
- ASSERT_EQ(-950, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
-}
-
-/**
- * Test NumberSchemaItem as INT with correct default value
- **/
-TEST(test_int_correct_default_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(-12000),
- TSchemaItemParameter<int>(100),
- TSchemaItemParameter<int>(-38));
-
- //Object int correct
- obj = -12000;
- ASSERT_EQ(-12000, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = -12001;
- ASSERT_EQ(-12001, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object int correct
- obj = 100;
- ASSERT_EQ(100, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = 101;
- ASSERT_EQ(101, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Set default value
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(-38, obj.asInt());
-
- //Object string
- obj = "string";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(-38, obj.asInt());
-}
-
-/**
- * Test NumberSchemaItem as INT with default value out of range
- **/
-TEST(test_int_default_value_out_of_range, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(90),
- TSchemaItemParameter<int>(100),
- TSchemaItemParameter<int>(50)); // Default value out of range
-
- //Object int correct
- obj = 90;
- ASSERT_EQ(90, obj.asInt());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = 89;
- ASSERT_EQ(89, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object int correct
- obj = 100;
- ASSERT_EQ(100, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object int incorrect
- obj = 101;
- ASSERT_EQ(101, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Set default value
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- EXPECT_EQ(50, obj.asInt());
-
- //Object string
- obj = "string";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- EXPECT_EQ(50, obj.asInt());
-}
-
-TEST(test_int_map_validate, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(-120),
- TSchemaItemParameter<int>(100),
- TSchemaItemParameter<int>(-38));
-
- obj["min"] = -120;
- obj["out_of_min"] = -121;
- obj["max"] = 100;
- obj["out_of_max"] = 101;
-
- int resultType = item->validate(obj["min"]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["max"]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["out_of_min"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj["out_of_max"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- //Set default value
- bool resDefault = item->setDefaultValue(obj["aa"]);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38, obj["aa"].asInt());
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- resultType = item->validate(obj["min"]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-}
-
-TEST(test_int_array_validate, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(-120),
- TSchemaItemParameter<int>(100),
- TSchemaItemParameter<int>(-38) );
-
- obj[0] = -121;
- obj[1] = -120;
- obj[2] = 100;
- obj[3] = 101;
-
- int resultType = item->validate(obj[0]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE, resultType);
-
- resultType = item->validate(obj[1]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj[2]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj[3]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- bool resDefault = item->setDefaultValue(obj[0]);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38, obj[0].asInt());
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj[0]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-}
-
-/**
- * Test NumberSchemaItem as DOUBLE with no default value
- *
- * Create SchemaItem without default value. Method setDefaultValue should always return false
- * and leave SmartObject in previous state.
- **/
-TEST(test_double_no_default_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item =
- TNumberSchemaItem<double>::create(); // No default value, no min, no max
-
- //Object int
- obj = 5.79;
- ASSERT_EQ(5.79, obj.asDouble());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Obj bool
- obj = true;
- ASSERT_TRUE(obj.asBool());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- //Set default value
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- EXPECT_TRUE(obj.asBool());
-
- //Obj string
- obj = "Test";
- ASSERT_EQ(std::string("Test"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- //Set default value
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-}
-
-/**
- * Test NumberSchemaItem as DOUBLE with setted min value
- **/
-TEST(test_double_min_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<double>::create(TSchemaItemParameter<double>
- (10.0)); // No default value, no max value
-
- //Object double correct
- obj = 10.000001;
- ASSERT_EQ(10.000001, obj.asDouble());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = 9.999999;
- ASSERT_EQ(9.999999, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- /*
- //Object int
- obj = 10;
- ASSERT_EQ(10, obj.asInt());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);*/
-}
-
-/**
- * Test NumberSchemaItem as DOUBLE with setted max value
- **/
-TEST(test_double_max_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<double>::create(
- TSchemaItemParameter<double>(),
- TSchemaItemParameter<double>(749.0)); // No default value, no min value
-
- //Object double correct
- obj = 749.0;
- ASSERT_EQ(749.0, obj.asDouble());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = 749.0001;
- ASSERT_EQ(749.0001, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object double correct
- obj = -750.0;
- ASSERT_EQ(-750.0, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-}
-
-/**
- * Test NumberSchemaItem as DOUBLE with setted min and max value
- **/
-TEST(test_double_min_max_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<double>::create(
- TSchemaItemParameter<double>(-949.0),
- TSchemaItemParameter<double>(749.0)); // No default value
-
- //Object double correct
- obj = 749.0;
- ASSERT_EQ(749.0, obj.asDouble());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = 749.001;
- ASSERT_EQ(749.001, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object double correct
- obj = -949.0;
- ASSERT_EQ(-949.0, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = -949.00001;
- ASSERT_EQ(-949.00001, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
-}
-
-/**
- * Test NumberSchemaItem as DOUBLE with correct default value
- **/
-TEST(test_double_correct_default_value, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<double>::create(
- TSchemaItemParameter<double>(-12000.0),
- TSchemaItemParameter<double>(100.0),
- TSchemaItemParameter<double>(-38.0));
-
- //Object double correct
- obj = -12000.0;
- ASSERT_EQ(-12000.0, obj.asDouble());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = -12000.01;
- ASSERT_EQ(-12000.01, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object double correct
- obj = 100.0;
- ASSERT_EQ(100.0, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = 100.001;
- ASSERT_EQ(100.001, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Set default value
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(-38.0, obj.asDouble());
-
- //Object string
- obj = "string";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(-38.0, obj.asDouble());
-}
-
-/**
- * Test NumberSchemaItem as DOUBLE with default value out of range
- **/
-TEST(test_double_default_value_out_of_range, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<double>::create(
- TSchemaItemParameter<double>(90.0),
- TSchemaItemParameter<double>(100.0),
- TSchemaItemParameter<double>(50.0)); // Default value out of range
-
- //Object double correct
- obj = 90.0;
- ASSERT_EQ(90.0, obj.asDouble());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = 89.999;
- ASSERT_EQ(89.999, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Object double correct
- obj = 100.0;
- ASSERT_EQ(100.0, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- //Object double incorrect
- obj = 100.001;
- ASSERT_EQ(100.001, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- //Set default value
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- EXPECT_EQ(50.0, obj.asDouble());
-
- //Object string
- obj = "string";
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- EXPECT_EQ(50.0, obj.asDouble());
-}
-
-TEST(test_double_map_validate, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<double>::create(
- TSchemaItemParameter<double>(-120.0),
- TSchemaItemParameter<double>(100.0),
- TSchemaItemParameter<double>(-38.0));
-
- obj["min"] = -120.0;
- obj["out_of_min"] = -120.001;
- obj["max"] = 100.0;
- obj["out_of_max"] = 100.001;
-
- int resultType = item->validate(obj["min"]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["max"]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj["out_of_min"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj["out_of_max"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- bool resDefault = item->setDefaultValue(obj["aa"]);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38.0, obj["aa"].asDouble());
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38.0, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-
- resultType = item->validate(obj["min"]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-}
-
-TEST(test_double_array_validate, test_NumberSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- SmartObject obj;
-
- ISchemaItemPtr item = TNumberSchemaItem<double>::create(
- TSchemaItemParameter<double>(-120.0),
- TSchemaItemParameter<double>(100.0),
- TSchemaItemParameter<double>(-38.0));
-
- obj[0] = -120.001;
- obj[1] = -120.0;
- obj[2] = 100.0;
- obj[3] = 100.000001;
-
- int resultType = item->validate(obj[0]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE, resultType);
-
- resultType = item->validate(obj[1]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj[2]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj[3]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OUT_OF_RANGE, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- bool resDefault = item->setDefaultValue(obj[0]);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38.0, obj[0].asDouble());
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(-38.0, obj.asDouble());
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::OK, resultType);
-
- resultType = item->validate(obj[0]);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(NsSmartDeviceLink::NsSmartObjects::Errors::INVALID_VALUE, resultType);
-}
-} // namespace SchemaItem
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
diff --git a/test/components/smart_objects/SchemaItem/test_StringSchemaItemTest.cpp b/test/components/smart_objects/SchemaItem/test_StringSchemaItemTest.cpp
deleted file mode 100644
index a7929e5f2..000000000
--- a/test/components/smart_objects/SchemaItem/test_StringSchemaItemTest.cpp
+++ /dev/null
@@ -1,305 +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.
-
-#include <string>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/string_schema_item.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SchemaItem {
-
-/**
- * Test StringSchemaItem no default value
- *
- * Create SchemaItem without default value. Method setDefaultValue should always return false
- * and leave SmartObject in previous state.
- **/
-TEST(test_no_default_value, test_StringSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CStringSchemaItem::create(); // No default value, no max length
-
- //Object - valid string
- obj = "New valid string";
- ASSERT_EQ(std::string("New valid string"), obj.asString());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_EQ(std::string("New valid string"), obj.asString());
-
- //Obj - bool
- obj = true;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- EXPECT_TRUE(obj.asBool());
-
- //Object - number
- obj = 3.1415926;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_FALSE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- EXPECT_EQ(3.1415926, obj.asDouble());
-}
-
-/**
- * Test StringSchemaItem with default value
- *
- * Create SchemaItem with default value. Method setDefaultValue should return true,
- * String SmartObject should contain default value.
- * Not string SmartObject should converted to StringObject and setted up by the default value.
- **/
-TEST(test_item_with_default_value, test_StringSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(),
- TSchemaItemParameter<size_t>(),
- TSchemaItemParameter<std::string>("Default string")); // Default value, no max length
-
- //Object - valid string
- obj = "New valid string";
- ASSERT_EQ(std::string("New valid string"), obj.asString());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj.asString());
-
- //Obj - bool
- obj = true;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj.asString());
-
- //Object - number
- obj = 3.1415926;
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- EXPECT_EQ(std::string("Default string"), obj.asString());
-}
-
-/**
- * Test StringSchemaItem with max length
- **/
-TEST(test_item_with_max_length, test_StringSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0),
- TSchemaItemParameter<size_t>(25),
- TSchemaItemParameter<std::string>("Default string"));
-
- //Object - valid string
- obj = "New valid string";
- ASSERT_EQ(std::string("New valid string"), obj.asString());
-
- int resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
- bool resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj.asString());
-
- //Object - too long string
- obj = "New very very loooooong string";
- ASSERT_EQ(std::string("New very very loooooong string"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj.asString());
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-}
-
-
-TEST(test_map_validate, test_StringSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0),
- TSchemaItemParameter<size_t>(25),
- TSchemaItemParameter<std::string>("Default string"));
-
- obj["str"] = "New valid string";
- obj["long"] = "New very very loooooong string";
- obj["bool"] = true;
- obj["num"] = 3.14;
-
- int resultType = item->validate(obj["str"]);
- EXPECT_EQ(Errors::OK, resultType);
-
- resultType = item->validate(obj["long"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- resultType = item->validate(obj["bool"]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj["num"]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- bool resDefault = item->setDefaultValue(obj["str"]);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj["str"].asString());
-
- resDefault = item->setDefaultValue(obj["bool"]);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj["bool"].asString());
-
- resDefault = item->setDefaultValue(obj["num"]);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj["num"].asString());
-
- resultType = item->validate(obj["str"]);
- EXPECT_EQ(Errors::OK, resultType);
-
- resultType = item->validate(obj["long"]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- resultType = item->validate(obj["bool"]);
- EXPECT_EQ(Errors::OK, resultType);
-
- resultType = item->validate(obj["num"]);
- EXPECT_EQ(Errors::OK, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-}
-
-TEST(test_array_validate, test_StringSchemaItemTest) {
- using namespace NsSmartDeviceLink::NsSmartObjects;
- SmartObject obj;
-
- ISchemaItemPtr item = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0),
- TSchemaItemParameter<size_t>(25),
- TSchemaItemParameter<std::string>("Default string"));
-
- obj[0] = "New valid string";
- obj[1] = "New very very loooooong string";
- obj[2] = true;
- obj[3] = 3.14;
- obj[4] = "New valid string";
-
- int resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::OK, resultType);
-
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
-
- resultType = item->validate(obj[2]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj[3]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- resultType = item->validate(obj[4]);
- EXPECT_EQ(Errors::OK, resultType);
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
-
- bool resDefault = item->setDefaultValue(obj[0]);
- EXPECT_TRUE(resDefault);
- resDefault = item->setDefaultValue(obj[2]);
- EXPECT_TRUE(resDefault);
- resDefault = item->setDefaultValue(obj[4]);
- EXPECT_TRUE(resDefault);
-
- //Set default value for non-initialized element
- resDefault = item->setDefaultValue(obj[5]);
- EXPECT_TRUE(resDefault);
-
- EXPECT_EQ(std::string("Default string"), obj[0].asString());
- EXPECT_EQ(std::string("Default string"), obj[2].asString());
- EXPECT_EQ(std::string("Default string"), obj[4].asString());
- EXPECT_EQ(std::string("Default string"), obj[5].asString());
-
- resultType = item->validate(obj[0]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[1]);
- EXPECT_EQ(Errors::OUT_OF_RANGE, resultType);
- resultType = item->validate(obj[2]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[3]);
- EXPECT_EQ(Errors::INVALID_VALUE, resultType);
- resultType = item->validate(obj[4]);
- EXPECT_EQ(Errors::OK, resultType);
- resultType = item->validate(obj[5]);
- EXPECT_EQ(Errors::OK, resultType);
-
- resDefault = item->setDefaultValue(obj);
- EXPECT_TRUE(resDefault);
- EXPECT_EQ(std::string("Default string"), obj.asString());
-
- resultType = item->validate(obj);
- EXPECT_EQ(Errors::OK, resultType);
-}
-} // namespace SchemaItem
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
diff --git a/test/components/smart_objects/SmartObjectConvertionTimeTest.cc b/test/components/smart_objects/SmartObjectConvertionTimeTest.cc
deleted file mode 100644
index 196e8ce8a..000000000
--- a/test/components/smart_objects/SmartObjectConvertionTimeTest.cc
+++ /dev/null
@@ -1,32 +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.
-*/
-
-#include "SmartObjectConvertionTimeTest.h"
diff --git a/test/components/smart_objects/SmartObjectConvertionTimeTest.h b/test/components/smart_objects/SmartObjectConvertionTimeTest.h
deleted file mode 100644
index f28761e7d..000000000
--- a/test/components/smart_objects/SmartObjectConvertionTimeTest.h
+++ /dev/null
@@ -1,676 +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.
- */
-
-#ifndef TEST_COMPONENTS_SMARTOBJECTS_SMARTOBJECTCONVERTIONTIMETEST_H_
-#define TEST_COMPONENTS_SMARTOBJECTS_SMARTOBJECTCONVERTIONTIMETEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "utils/shared_ptr.h"
-
-#include "smart_objects/smart_object.h"
-#include "smart_objects/smart_schema.h"
-#include "smart_objects/schema_item.h"
-#include "formatters/CFormatterJsonSDLRPCv2.hpp"
-#include "formatters/CFormatterJsonSDLRPCv1.hpp"
-#include "smart_objects/array_schema_item.h"
-#include "smart_objects/bool_schema_item.h"
-#include "smart_objects/object_schema_item.h"
-#include "smart_objects/string_schema_item.h"
-#include "smart_objects/enum_schema_item.h"
-#include "smart_objects/number_schema_item.h"
-#include "smart_objects/schema_item_parameter.h"
-
-#include <string>
-#include <time.h>
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SmartObjectConvertionTimeTest {
-
-using namespace NsSmartDeviceLink::NsJSONHandler::strings;
-using namespace NsSmartDeviceLink::NsSmartObjects;
-
-namespace TestType {
-enum eType {
- INVALID_ENUM = -1,
- APPLICATION_NOT_REGISTERED = 0,
- SUCCESS,
- TOO_MANY_PENDING_REQUESTS,
- REJECTED,
- INVALID_DATA,
- OUT_OF_MEMORY,
- ABORTED,
- USER_DISALLOWED,
- GENERIC_ERROR,
- DISALLOWED
-};
-}
-
-namespace FunctionIdTest {
-enum eType {
- INVALID_ENUM = -1,
- RegisterAppInterface,
- UnregisterAppInterface,
- SetGlobalProperties,
-};
-}
-
-namespace MessageTypeTest {
-enum eType {
- INVALID_ENUM = -1,
- request,
- response,
- notification
-};
-}
-
-class SmartObjectConvertionTimeTest : public ::testing::Test {
- protected:
-
- double getConvertionTimeToJsonV2Format(const SmartObject& srcObj, std::string& jsonString) {
- timespec convertionStartTime, convertionEndTime;
- clock_gettime(CLOCK_REALTIME, &convertionStartTime);
-
- // SmartObjects --> JSON
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::toString(srcObj, jsonString);
-
- clock_gettime(CLOCK_REALTIME, &convertionEndTime);
-
- return static_cast<double>(convertionEndTime.tv_sec - convertionStartTime.tv_sec)
- + static_cast<double>(convertionEndTime.tv_nsec - convertionStartTime.tv_nsec) * 1e-9;
- }
-
- double getConvertionTimeFromJsonV2Format(std::string& jsonString, SmartObject& dstObj) {
- timespec convertionStartTime, convertionEndTime;
- clock_gettime(CLOCK_REALTIME, &convertionStartTime);
-
- // JSON --> SmartObjects
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::fromString
- <FunctionIdTest::eType, MessageTypeTest::eType>
- (jsonString, dstObj, FunctionIdTest::RegisterAppInterface, MessageTypeTest::request, 13);
-
- clock_gettime(CLOCK_REALTIME, &convertionEndTime);
- return static_cast<double>(convertionEndTime.tv_sec - convertionStartTime.tv_sec)
- + static_cast<double>(convertionEndTime.tv_nsec - convertionStartTime.tv_nsec) * 1e-9;
- }
-
- double getConvertionTimeToJsonV1Format(const SmartObject& srcObj, std::string& jsonString) {
- timespec convertionStartTime, convertionEndTime;
- clock_gettime(CLOCK_REALTIME, &convertionStartTime);
-
- // SmartObjects --> JSON
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv1::toString(srcObj, jsonString);
-
- clock_gettime(CLOCK_REALTIME, &convertionEndTime);
- return static_cast<double>(convertionEndTime.tv_sec - convertionStartTime.tv_sec)
- + static_cast<double>(convertionEndTime.tv_nsec - convertionStartTime.tv_nsec) * 1e-9;
- }
-
- double getConvertionTimeFromJsonV1Format(std::string& jsonString, SmartObject& dstObj) {
- timespec convertionStartTime, convertionEndTime;
- clock_gettime(CLOCK_REALTIME, &convertionStartTime);
-
- // JSON --> SmartObjects
- NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv1::fromString
- <FunctionIdTest::eType,MessageTypeTest::eType>(jsonString, dstObj);
-
- clock_gettime(CLOCK_REALTIME, &convertionEndTime);
- return static_cast<double>(convertionEndTime.tv_sec - convertionStartTime.tv_sec)
- + static_cast<double>(convertionEndTime.tv_nsec - convertionStartTime.tv_nsec) * 1e-9;
- }
-
- void calculateConvertionTime(SmartObject& srcObj, SmartObject& dstObj) {
- std::string jsonString;
- double convertionToTime = 0.0;
- double convertionFromTime = 0.0;
- const int cycles = 1;
-
- for (int i = 0; i < cycles; i++) {
- convertionToTime += getConvertionTimeToJsonV1Format(srcObj, jsonString);
-// printf("%s\n", jsonString.c_str());
- convertionFromTime += getConvertionTimeFromJsonV1Format(jsonString, dstObj);
- }
- printf("Format V1. Convertion TO time = %.8f, Convertion FROM time = %.8f\n",
- convertionToTime / cycles, convertionFromTime / cycles);
-
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1; // adjust protocol version
-
- srcObj.getSchema().applySchema(dstObj);
- // The objects are different after remove non-schemed fields
- EXPECT_TRUE(srcObj == dstObj);
-
- convertionToTime = 0.0;
- convertionFromTime = 0.0;
- for (int i = 0; i < cycles; i++) {
- convertionToTime += getConvertionTimeToJsonV2Format(srcObj, jsonString);
- convertionFromTime += getConvertionTimeFromJsonV2Format(jsonString, dstObj);
- }
- printf("Format V2. Convertion TO time = %.8f, Convertion FROM time = %.8f\n",
- convertionToTime / cycles, convertionFromTime / cycles);
-
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; // adjust protocol version
-
- dstObj.getSchema().applySchema(dstObj);
- // The objects are different after remove non-schemed fields
- EXPECT_TRUE(srcObj == dstObj);
- }
-
- void calculateConvertionTimeWithJsonStringOutput(const SmartObject& srcObj, SmartObject& dstObj) {
- std::string jsonString;
- double convertionToTime = getConvertionTimeToJsonV1Format(srcObj, jsonString);
- double convertionFromTime = getConvertionTimeFromJsonV1Format(jsonString, dstObj);
- printf("\nJSON string V1 = %s", jsonString.c_str());
- printf("\nFormat V1. Convertion TO time = %.8f, Convertion FROM time = %.8f\n",
- convertionToTime, convertionFromTime);
-
- convertionToTime = getConvertionTimeToJsonV2Format(srcObj, jsonString);
- convertionFromTime = getConvertionTimeFromJsonV2Format(jsonString, dstObj);
- printf("\nJSON string V2 = %s", jsonString.c_str());
- printf("\nFormat V2. Convertion TO time = %.8f, Convertion FROM time = %.8f\n",
- convertionToTime, convertionFromTime);
- }
-
- // The basic Schema just for enum conversion (FunctionId and MessageType)
- CSmartSchema initBasicObjectSchema() {
- std::set<FunctionIdTest::eType> functionId_allowedEnumSubsetValues;
- functionId_allowedEnumSubsetValues.insert(FunctionIdTest::RegisterAppInterface);
- functionId_allowedEnumSubsetValues.insert(FunctionIdTest::UnregisterAppInterface);
- functionId_allowedEnumSubsetValues.insert(FunctionIdTest::SetGlobalProperties);
-
- std::set<MessageTypeTest::eType> messageType_allowedEnumSubsetValues;
- messageType_allowedEnumSubsetValues.insert(MessageTypeTest::request);
- messageType_allowedEnumSubsetValues.insert(MessageTypeTest::response);
- messageType_allowedEnumSubsetValues.insert(MessageTypeTest::notification);
-
- ISchemaItemPtr functionId_SchemaItem = TEnumSchemaItem<FunctionIdTest::eType>::create(
- functionId_allowedEnumSubsetValues);
-
- ISchemaItemPtr messageType_SchemaItem = TEnumSchemaItem<MessageTypeTest::eType>::create(
- messageType_allowedEnumSubsetValues);
-
- CObjectSchemaItem::Members paramsMembersMap;
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_FUNCTION_ID]
- = CObjectSchemaItem::SMember(functionId_SchemaItem, true);
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_MESSAGE_TYPE]
- = CObjectSchemaItem::SMember(messageType_SchemaItem, true);
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_CORRELATION_ID]
- = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
-
- std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
- rootMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- = CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), true);
-
- return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
- }
-
- //Create SmartObjectSchema for test object
- CSmartSchema initObjectSchema() {
- std::set<TestType::eType> resultCode_allowedEnumSubsetValues;
- resultCode_allowedEnumSubsetValues.insert(TestType::APPLICATION_NOT_REGISTERED);
- resultCode_allowedEnumSubsetValues.insert(TestType::SUCCESS);
- resultCode_allowedEnumSubsetValues.insert(TestType::TOO_MANY_PENDING_REQUESTS);
- resultCode_allowedEnumSubsetValues.insert(TestType::REJECTED);
- resultCode_allowedEnumSubsetValues.insert(TestType::INVALID_DATA);
- resultCode_allowedEnumSubsetValues.insert(TestType::OUT_OF_MEMORY);
- resultCode_allowedEnumSubsetValues.insert(TestType::ABORTED);
- resultCode_allowedEnumSubsetValues.insert(TestType::USER_DISALLOWED);
- resultCode_allowedEnumSubsetValues.insert(TestType::GENERIC_ERROR);
- resultCode_allowedEnumSubsetValues.insert(TestType::DISALLOWED);
-
- std::set<FunctionIdTest::eType> functionId_allowedEnumSubsetValues;
- functionId_allowedEnumSubsetValues.insert(FunctionIdTest::RegisterAppInterface);
- functionId_allowedEnumSubsetValues.insert(FunctionIdTest::UnregisterAppInterface);
- functionId_allowedEnumSubsetValues.insert(FunctionIdTest::SetGlobalProperties);
-
- std::set<MessageTypeTest::eType> messageType_allowedEnumSubsetValues;
- messageType_allowedEnumSubsetValues.insert(MessageTypeTest::request);
- messageType_allowedEnumSubsetValues.insert(MessageTypeTest::response);
- messageType_allowedEnumSubsetValues.insert(MessageTypeTest::notification);
-
- ISchemaItemPtr success_SchemaItem = CBoolSchemaItem::create(TSchemaItemParameter<bool>());
-
- ISchemaItemPtr resultCode_SchemaItem = TEnumSchemaItem<TestType::eType>::create(
- resultCode_allowedEnumSubsetValues, TSchemaItemParameter<TestType::eType>());
-
- ISchemaItemPtr info_SchemaItem = CStringSchemaItem::create(
- TSchemaItemParameter<size_t>(0)
- , TSchemaItemParameter<size_t>(1000)
- , TSchemaItemParameter<std::string>());
-
- ISchemaItemPtr tryAgainTime_SchemaItem = TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(0)
- , TSchemaItemParameter<int>(2000000000)
- , TSchemaItemParameter<int>());
-
- std::map<std::string, CObjectSchemaItem::SMember> schemaMembersMap;
-
- schemaMembersMap["success"] = CObjectSchemaItem::SMember(success_SchemaItem, true);
- schemaMembersMap["resultCode"] = CObjectSchemaItem::SMember(resultCode_SchemaItem, true);
- schemaMembersMap["info"] = CObjectSchemaItem::SMember(info_SchemaItem, false);
- schemaMembersMap["tryAgainTime"] = CObjectSchemaItem::SMember(tryAgainTime_SchemaItem, true);
-
- std::map<std::string, CObjectSchemaItem::SMember> paramsMembersMap;
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_FUNCTION_ID]
- = CObjectSchemaItem::SMember(TEnumSchemaItem<FunctionIdTest::eType>::create(
- functionId_allowedEnumSubsetValues), true);
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_MESSAGE_TYPE]
- = CObjectSchemaItem::SMember(TEnumSchemaItem<MessageTypeTest::eType>::create(
- messageType_allowedEnumSubsetValues), true);
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_CORRELATION_ID]
- = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_PROTOCOL_VERSION]
- = CObjectSchemaItem::SMember(
- TNumberSchemaItem<int>::create(
- TSchemaItemParameter<int>(1),
- TSchemaItemParameter<int>(2)), true);
- paramsMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_PROTOCOL_TYPE]
- = CObjectSchemaItem::SMember(TNumberSchemaItem<int>::create(), true);
-
- std::map<std::string, CObjectSchemaItem::SMember> rootMembersMap;
- rootMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_MSG_PARAMS]
- = CObjectSchemaItem::SMember(CObjectSchemaItem::create(schemaMembersMap), true);
- rootMembersMap[NsSmartDeviceLink::NsJSONHandler::strings::S_PARAMS]
- = CObjectSchemaItem::SMember(CObjectSchemaItem::create(paramsMembersMap), true);
- return CSmartSchema(CObjectSchemaItem::create(rootMembersMap));
- }
-};
-
-TEST_F(SmartObjectConvertionTimeTest, test_int_object_convertion) {
- SmartObject srcObj, dstObj;
- CSmartSchema schema = initObjectSchema();
-
- srcObj.setSchema(schema);
- dstObj.setSchema(schema);
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1;
- srcObj[S_MSG_PARAMS]["value"] = 5;
-
- printf("\n INT value.\n");
- calculateConvertionTime(srcObj, dstObj);
-}
-
-TEST_F(SmartObjectConvertionTimeTest, test_double_object_convertion) {
- SmartObject srcObj, dstObj;
- CSmartSchema schema = initObjectSchema();
-
- srcObj.setSchema(schema);
- dstObj.setSchema(schema);
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["value1"] = 3.1415926;
- srcObj[S_MSG_PARAMS]["value2"] = 32.6;
- srcObj[S_MSG_PARAMS]["value3"] = 33.945;
- srcObj[S_MSG_PARAMS]["value4"] = -12.5487698;
- srcObj[S_MSG_PARAMS]["value5"] = 0.61287346;
-
- printf("\n Double value.\n");
- calculateConvertionTime(srcObj, dstObj);
-}
-
-TEST_F(SmartObjectConvertionTimeTest, test_some_object_convertion) {
- SmartObject srcObj, dstObj;
- CSmartSchema schema = initObjectSchema();
-
- srcObj.setSchema(schema);
- dstObj.setSchema(schema);
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["appId"] = "APP ID";
- srcObj[S_MSG_PARAMS]["appName"] = "APP NAME";
- srcObj[S_MSG_PARAMS]["appType"][0] = "SYSTEM";
- srcObj[S_MSG_PARAMS]["appType"][1] = "COMMUNICATION";
- srcObj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = "RU-RU";
- srcObj[S_MSG_PARAMS]["isMediaApplication"] = true;
- srcObj[S_MSG_PARAMS]["languageDesired"] = "EN-US";
- srcObj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "SCREEN NAME";
- srcObj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2;
- srcObj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10;
- srcObj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC";
- srcObj[S_MSG_PARAMS]["ttsName"][0]["type"] = "TEXT";
- srcObj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1";
- srcObj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2";
- srcObj[S_MSG_PARAMS]["null"] = SmartObject();
- srcObj[S_MSG_PARAMS]["double"] = -0.1234;
-
- printf("\n Random object.\n");
- calculateConvertionTime(srcObj, dstObj);
-}
-
-TEST_F(SmartObjectConvertionTimeTest, test_map_object_convertion) {
- SmartObject srcObj, dstObj, mapObj, innerObj;
- CSmartSchema schema = initObjectSchema();
-
- srcObj.setSchema(schema);
- dstObj.setSchema(schema);
-
- // First iteration
- mapObj["request"]["name"] = "My Request";
- mapObj["request"]["id"] = 123;
- mapObj["response"]["name"] = "My Response";
- mapObj["response"]["id"] = 456;
- mapObj["we"]["need"]["to"]["go"]["deeper"] = true;
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["value"] = mapObj;
-
- printf("\n MAP object.\n");
- calculateConvertionTime(srcObj, dstObj);
-
- // Second iteration
- innerObj = mapObj;
- mapObj["request"]["value"] = innerObj;
- mapObj["response"]["value"] = innerObj;
- mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj;
- srcObj[S_MSG_PARAMS]["value"] = mapObj;
-
- printf("\n Complex MAP object.\n");
- calculateConvertionTime(srcObj, dstObj);
-
- // Third iteration
- innerObj = mapObj;
- mapObj["request"]["value"] = innerObj;
- mapObj["response"]["value"] = innerObj;
- mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj;
- srcObj[S_MSG_PARAMS]["value"] = mapObj;
-
- printf("\n Very Complex MAP object.\n");
- calculateConvertionTime(srcObj, dstObj);
-
- // Last iteration
- innerObj = mapObj;
- mapObj["request"]["value"] = innerObj;
- mapObj["response"]["value"] = innerObj;
- mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj;
- srcObj[S_MSG_PARAMS]["value"] = mapObj;
-
- printf("\n Very Very Complex MAP object.\n");
- calculateConvertionTime(srcObj, dstObj);
-}
-
-TEST_F(SmartObjectConvertionTimeTest, test_array_convertion) {
- SmartObject srcObj, dstObj, arrayObj, innerObj;
- CSmartSchema schema = initObjectSchema();
- int arraySize = 10;
-
- srcObj.setSchema(schema);
- dstObj.setSchema(schema);
-
- // First iteration
- for (int i = 0; i < arraySize; i++) {
- arrayObj[i] = rand();
- }
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["array"] = arrayObj;
-
- printf("\n Array object [%d].\n", arraySize);
- calculateConvertionTime(srcObj, dstObj);
-
- // Second iteration
- printf("\n Array object [%d x %d].\n", arraySize, arraySize);
- innerObj = arrayObj;
- for (int i = 0; i < arraySize; i++) {
- arrayObj[i] = innerObj;
- }
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["array"] = arrayObj;
-
- calculateConvertionTime(srcObj, dstObj);
-
- // Third iteration
- printf("\n Array object [%d x %d x %d].\n"
- , arraySize, arraySize, arraySize);
- innerObj = arrayObj;
- for (int i = 0; i < arraySize; i++) {
- arrayObj[i] = innerObj;
- }
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["array"] = arrayObj;
-
- calculateConvertionTime(srcObj, dstObj);
-
- // Fourth iteration
- printf("\n Array object [%d x %d x %d x %d].\n"
- , arraySize, arraySize, arraySize, arraySize);
- innerObj = arrayObj;
- for (int i = 0; i < arraySize; i++) {
- arrayObj[i] = innerObj;
- }
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["array"] = arrayObj;
-
- calculateConvertionTime(srcObj, dstObj);
-
- // Last iteration
- printf("\n Array object [%d x %d x %d x %d x %d].\n"
- , arraySize, arraySize, arraySize, arraySize, arraySize);
- innerObj = arrayObj;
- for (int i = 0; i < arraySize; i++) {
- arrayObj[i] = innerObj;
- }
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["array"] = arrayObj;
-
- calculateConvertionTime(srcObj, dstObj);
-}
-
-
-TEST_F(SmartObjectConvertionTimeTest, test_object_with_enum_convertion) {
- SmartObject srcObj, dstObj;
- CSmartSchema schema = initObjectSchema();
-
- srcObj.setSchema(schema);
- dstObj.setSchema(schema);
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["success"] = true;
- srcObj[S_MSG_PARAMS]["resultCode"] = 2;
- srcObj[S_MSG_PARAMS]["info"] = "Some string";
- srcObj[S_MSG_PARAMS]["tryAgainTime"] = 322;
- srcObj.setSchema(schema);
-
- printf("\n Object with enum.\n");
- calculateConvertionTime(srcObj, dstObj);
-}
-
-TEST_F(SmartObjectConvertionTimeTest, test_object_without_enum_convertion) {
- SmartObject srcObj, dstObj;
- CSmartSchema schema = initObjectSchema();
-
- srcObj.setSchema(schema);
- dstObj.setSchema(schema);
-
- srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request;
- srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface;
- srcObj[S_PARAMS][S_CORRELATION_ID] = 13;
- srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0;
- srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2;
- srcObj[S_MSG_PARAMS]["success"] = true;
- srcObj[S_MSG_PARAMS]["resultCode"] = 2;
- srcObj[S_MSG_PARAMS]["info"] = "Some string";
- srcObj[S_MSG_PARAMS]["tryAgainTime"] = 322;
-
- printf("\n Object without enum.\n");
- calculateConvertionTime(srcObj, dstObj);
-}
-
-}
-}
-}
-}
-
-namespace NsSmartDeviceLink {
-namespace NsSmartObjects {
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::EnumToCStringMap
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::CStringToEnumMap
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::cstring_values_[] = {
- "APPLICATION_NOT_REGISTERED",
- "SUCCESS",
- "TOO_MANY_PENDING_REQUESTS",
- "REJECTED",
- "INVALID_DATA",
- "OUT_OF_MEMORY",
- "ABORTED",
- "USER_DISALLOWED",
- "GENERIC_ERROR",
- "DISALLOWED"
-};
-
-template<>
-const test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::eType>::enum_values_[] = {
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::APPLICATION_NOT_REGISTERED,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::SUCCESS,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::TOO_MANY_PENDING_REQUESTS,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::REJECTED,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::INVALID_DATA,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::OUT_OF_MEMORY,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::ABORTED,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::USER_DISALLOWED,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::GENERIC_ERROR,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::TestType::DISALLOWED
-};
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::EnumToCStringMap
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::CStringToEnumMap
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::cstring_values_[] = {
- "RegisterAppInterface",
- "UnregisterAppInterface",
- "SetGlobalProperties"
-};
-
-template<>
-const test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::eType>::enum_values_[] = {
- test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::RegisterAppInterface,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::UnregisterAppInterface,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::FunctionIdTest::SetGlobalProperties
-};
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::EnumToCStringMap
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::enum_to_cstring_map_ =
- EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::InitEnumToCStringMap();
-
-template<>
-const EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::CStringToEnumMap
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::cstring_to_enum_map_ =
- EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::InitCStringToEnumMap();
-
-template<>
-const char* const
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::cstring_values_[] = {
- "request",
- "response",
- "notification"
-};
-
-template<>
-const test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType
-EnumConversionHelper<test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::eType>::enum_values_[] = {
- test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::request,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::response,
- test::components::SmartObjects::SmartObjectConvertionTimeTest::MessageTypeTest::notification
-};
-
-}
-}
-
-#endif // TEST_COMPONENTS_SMARTOBJECTS_SMARTOBJECTCONVERTIONTIMETEST_H_
diff --git a/test/components/smart_objects/SmartObjectDraftTest.cc b/test/components/smart_objects/SmartObjectDraftTest.cc
deleted file mode 100644
index c205a3563..000000000
--- a/test/components/smart_objects/SmartObjectDraftTest.cc
+++ /dev/null
@@ -1,32 +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.
-*/
-
-#include "SmartObjectDraftTest.h"
diff --git a/test/components/smart_objects/SmartObjectDraftTest.h b/test/components/smart_objects/SmartObjectDraftTest.h
deleted file mode 100644
index 6f4f785cd..000000000
--- a/test/components/smart_objects/SmartObjectDraftTest.h
+++ /dev/null
@@ -1,368 +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 TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTDRAFTTEST_H_
-#define TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTDRAFTTEST_H_
-
-#include <string>
-#include <vector>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-
-using ::testing::ElementsAre;
-using ::testing::ContainerEq;
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SmartObjectDraftTest {
-
-using NsSmartDeviceLink::NsSmartObjects::SmartObject;
-using NsSmartDeviceLink::NsSmartObjects::SmartType;
-
-TEST(SmartObjectsDraftTest, primitive_types) {
- SmartObject obj;
-
- obj = true;
- ASSERT_TRUE(obj.asBool());
- ASSERT_EQ(SmartType::SmartType_Boolean, obj.getType());
-
- obj = 5;
- ASSERT_EQ(5, obj.asInt());
- ASSERT_EQ(SmartType::SmartType_Integer, obj.getType());
-
- obj = 'A';
- ASSERT_DOUBLE_EQ('A', obj.asChar());
- ASSERT_EQ(SmartType::SmartType_Character, obj.getType());
-
- obj = "Test";
- ASSERT_EQ(std::string("Test"), obj.asString());
- ASSERT_EQ(SmartType::SmartType_String, obj.getType());
-
- obj = 6.0;
- ASSERT_DOUBLE_EQ(6.0, obj.asDouble());
- ASSERT_EQ(SmartType::SmartType_Double, obj.getType());
-}
-
-TEST(SmartObjectsDraftTest, test_map_access) {
- SmartObject obj;
-
- obj["aa"] = true;
- ASSERT_TRUE(obj["aa"].asInt());
- ASSERT_EQ(SmartType::SmartType_Map, obj.getType());
-
- obj["aa"]["fds"]["Fsdf"] = 123;
- ASSERT_EQ(123, obj["aa"]["fds"]["Fsdf"].asInt());
- ASSERT_EQ(SmartType::SmartType_Map, obj.getType());
-}
-
-TEST(SmartObjectsDraftTest, test_array_access) {
- SmartObject obj;
-
- obj[0] = 5;
- obj[-1] = 6; // Appending new item to array
-
- ASSERT_EQ(5, obj[0].asInt());
- ASSERT_EQ(6, obj[1].asInt());
- ASSERT_EQ(SmartType::SmartType_Array, obj.getType());
-}
-
-TEST(SmartObjectsDraftTest, test_public_interface) {
- SmartObject obj;
-
- // ---- INTEGER ---- //
- obj = 1;
- ASSERT_EQ(1, obj.asInt());
-
- // ---- unsigned int ---- //
- obj = static_cast<unsigned int>(100);
- ASSERT_EQ(100u, obj.asUInt());
-
- // ---- DOUBLE ---- //
- obj = 3.14;
- ASSERT_EQ(3.14, obj.asDouble());
-
- // ---- CHAR ---- //
- obj = 'a';
- ASSERT_EQ('a', obj.asChar());
-
- // ---- BOOL ---- //
- obj = true;
- ASSERT_TRUE(obj.asBool());
-
- // ---- CHAR* ---- //
- obj = "Hello, world";
- ASSERT_EQ(std::string("Hello, world"), obj.asString());
-
- // ---- STD::STRING ---- //
- obj = std::string("Hello, world");
- ASSERT_EQ(std::string("Hello, world"), obj.asString());
-
- // ---- Binary ---- //
- NsSmartDeviceLink::NsSmartObjects::SmartBinary binaryData;
- binaryData.push_back('\0');
- binaryData.push_back('a');
- obj = binaryData;
- ASSERT_THAT(obj.asBinary(), ElementsAre('\0', 'a'));
-
- // ---- ARRAY ---- //
- obj[0] = 1;
- obj[1] = true;
- obj[2] = 'a';
- obj[3] = 3.14;
-
- ASSERT_EQ(1, obj[0].asInt());
- ASSERT_TRUE(obj[1].asBool());
- ASSERT_EQ('a', obj[2].asChar());
- ASSERT_EQ(3.14, obj[3].asDouble());
-
- // ---- DEEP ARRAY ---- //
- obj[0] = 1;
- obj[1][0] = 3.14;
- obj[1][1][0] = true;
-
- ASSERT_EQ(1, obj[0].asInt());
- ASSERT_EQ(3.14, obj[1][0].asDouble());
- ASSERT_TRUE(obj[1][1][0].asBool());
-
- // ---- MAP ---- //
- obj["name"] = "My name";
- obj["count"] = 10;
- obj["isValid"] = true;
-
- ASSERT_EQ(std::string("My name"), obj["name"].asString());
- ASSERT_EQ(10, obj["count"].asInt());
- ASSERT_TRUE(obj["isValid"].asBool());
-
- // ---- DEEP MAP ---- //
- obj["request"]["name"] = "My Request";
- obj["request"]["id"] = 123;
- obj["response"]["name"] = "My Response";
- obj["response"]["id"] = 456;
- obj["we"]["need"]["to"]["go"]["deeper"] = true;
-
- ASSERT_EQ(std::string("My Request"), obj["request"]["name"].asString());
- ASSERT_EQ(123, obj["request"]["id"].asInt());
- ASSERT_EQ(std::string("My Response"), obj["response"]["name"].asString());
- ASSERT_EQ(456, obj["response"]["id"].asInt());
- ASSERT_TRUE(obj["we"]["need"]["to"]["go"]["deeper"].asBool());
-}
-
-TEST(SmartObjectsDraftTest, test_helper_methods) {
- SmartObject obj;
-
- // ---- INTEGER ---- //
- obj = 1;
- ASSERT_EQ(1, obj.asInt());
-
- // ---- unsigned int ---- //
- obj = static_cast<unsigned int>(100);
- ASSERT_EQ(100u, obj.asUInt());
-
- // ---- DOUBLE ---- //
- obj = 3.14;
- ASSERT_EQ(3.14, obj.asDouble());
- TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTDRAFTTEST_H_
- // ---- CHAR ---- //
- obj = 'a';
- ASSERT_EQ('a', obj.asChar());
-
- // ---- BOOL ---- //
- obj = true;
- ASSERT_TRUE(obj.asBool());
-
- // ---- STD::STRING ---- //
- obj = std::string("Hello, world");
- ASSERT_EQ(std::string("Hello, world"), obj.asString());
-
- // ---- Binary ---- //
- NsSmartDeviceLink::NsSmartObjects::SmartBinary binaryData;
- binaryData.push_back('\0');
- binaryData.push_back('a');
- obj = binaryData;
- ASSERT_THAT(obj.asBinary(), ElementsAre('\0', 'a'));
-}
-
-TEST(SmartObjectsDraftTest, compare_empty_objects_by_types) {
- ASSERT_EQ(SmartObject(), SmartObject());
-
- std::vector<SmartType> smart_types;
- smart_types.push_back(SmartType::SmartType_Null);
- smart_types.push_back(SmartType::SmartType_Boolean);
- smart_types.push_back(SmartType::SmartType_Integer);
- smart_types.push_back(SmartType::SmartType_Character);
- smart_types.push_back(SmartType::SmartType_String);
- smart_types.push_back(SmartType::SmartType_Double);
- smart_types.push_back(SmartType::SmartType_Map);
- smart_types.push_back(SmartType::SmartType_Array);
- smart_types.push_back(SmartType::SmartType_Binary);
- smart_types.push_back(SmartType::SmartType_Invalid);
-
- for (size_t i = 0u; i < smart_types.size(); ++i) {
- const SmartType type_i = smart_types[i];
- for (size_t j = 0u; j < smart_types.size(); ++j) {
- const SmartType type_j = smart_types[i];
- if (type_i == type_j) {
- ASSERT_EQ(SmartObject(type_i), SmartObject(type_j));
- ASSERT_EQ(SmartObject(type_j), SmartObject(type_i));
- } else {
- ASSERT_NE(SmartObject(type_i), SmartObject(type_j));
- ASSERT_EQ(SmartObject(type_j), SmartObject(type_i));
- }
- }
- }
-}
-
-TEST(SmartObjectsDraftTest, compare_integer_type) {
- SmartObject value = SmartObject(0xFFFFF);
- SmartObject same_value = SmartObject(static_cast<int64_t>(value.asInt()));
-
- ASSERT_EQ(value, same_value);
- ASSERT_EQ(same_value, value);
-
- SmartObject other_value = SmartObject(0x00000);
-
- ASSERT_NE(value, other_value);
- ASSERT_NE(other_value, value);
-
- ASSERT_NE(other_value, same_value);
- ASSERT_NE(same_value, other_value);
-
- ASSERT_NE(value, SmartObject());
- ASSERT_NE(other_value, SmartObject());
- ASSERT_NE(same_value, SmartObject());
-}
-
-TEST(SmartObjectsDraftTest, compare_double_type) {
- SmartObject value = SmartObject(6.0);
- SmartObject same_value = SmartObject(6.0);
-
- ASSERT_EQ(value, same_value);
- ASSERT_EQ(same_value, value);
-
- SmartObject other_value = SmartObject(6.0000001);
-
- ASSERT_NE(value, other_value);
- ASSERT_NE(other_value, value);
-
- ASSERT_NE(other_value, same_value);
- ASSERT_NE(same_value, other_value);
-
-
- ASSERT_NE(value, SmartObject());
- ASSERT_NE(other_value, SmartObject());
- ASSERT_NE(same_value, SmartObject());
-}
-
-TEST(SmartObjectsDraftTest, compare_bool_type) {
- SmartObject value = SmartObject(true);
- SmartObject same_value = SmartObject(true);
-
- ASSERT_EQ(value, same_value);
- ASSERT_EQ(same_value, value);
-
- SmartObject other_value = SmartObject(false);
-
- ASSERT_NE(value, other_value);
- ASSERT_NE(other_value, value);
-
- ASSERT_NE(other_value, same_value);
- ASSERT_NE(same_value, other_value);
-
-
- ASSERT_NE(value, SmartObject());
- ASSERT_NE(other_value, SmartObject());
- ASSERT_NE(same_value, SmartObject());
-}
-
-TEST(SmartObjectsDraftTest, compare_string_type) {
- SmartObject value = SmartObject("Test string");
- SmartObject same_value = SmartObject(std::string("Test string"));
-
- ASSERT_EQ(value, same_value);
- ASSERT_EQ(same_value, value);
-
- SmartObject other_value = SmartObject("Other string");
-
- ASSERT_NE(value, other_value);
- ASSERT_NE(other_value, value);
-
- ASSERT_NE(other_value, same_value);
- ASSERT_NE(same_value, other_value);
-
- ASSERT_NE(value, SmartObject());
- ASSERT_NE(other_value, SmartObject());
- ASSERT_NE(same_value, SmartObject());
-}
-
-TEST(SmartObjectsDraftTest, compare_map_type) {
- SmartObject value;
- value["KEY1"] = "VALUE1";
- value["KEY2"] = 0;
- value["KEY3"] = false;
-
- SmartObject same_value;
- same_value["KEY1"] = "VALUE1";
- same_value["KEY2"] = 0;
- same_value["KEY3"] = false;
-
- ASSERT_EQ(value, same_value);
- ASSERT_EQ(same_value, value);
-
- SmartObject other_value;
- other_value["KEY1"] = "VALUE1";
- other_value["KEY2"] = 0;
- // no KEY3 field
-
- SmartObject other_value2;
- other_value2["KEY1"] = "VALUE1";
- other_value2["KEY2"] = 0;
- // other ype of KEY3 field
- other_value2["KEY3"] = "VALUE3";
-
- ASSERT_NE(value, other_value);
- ASSERT_NE(other_value, value);
-
- ASSERT_NE(value, other_value2);
- ASSERT_NE(other_value2, value);
-
- ASSERT_NE(value, SmartObject());
- ASSERT_NE(same_value, SmartObject());
- ASSERT_NE(other_value, SmartObject());
- ASSERT_NE(other_value2, SmartObject());
-}
-// TODO(Ezamakhov): add test for conversion string/int/double
-} // namespace SmartObjectDraftTest
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTDRAFTTEST_H_
diff --git a/test/components/smart_objects/SmartObjectInvalidTest.cc b/test/components/smart_objects/SmartObjectInvalidTest.cc
deleted file mode 100644
index 86dae5866..000000000
--- a/test/components/smart_objects/SmartObjectInvalidTest.cc
+++ /dev/null
@@ -1,32 +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.
-*/
-
-#include "SmartObjectInvalidTest.h"
diff --git a/test/components/smart_objects/SmartObjectInvalidTest.h b/test/components/smart_objects/SmartObjectInvalidTest.h
deleted file mode 100644
index 9beac08c9..000000000
--- a/test/components/smart_objects/SmartObjectInvalidTest.h
+++ /dev/null
@@ -1,178 +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 TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTINVALIDTEST_H_
-#define TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTINVALIDTEST_H_
-
-#include <string>
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SmartObjectInvalidTest {
-using namespace NsSmartDeviceLink::NsSmartObjects;
-
-TEST(test_SmartObjectInvalidTest, simple_type_can_be_set_in_constructor) {
- SmartObject objMap(SmartType_Map);
- ASSERT_EQ(SmartType_Map, objMap.getType());
-
- SmartObject objArray(SmartType_Array);
- ASSERT_EQ(SmartType_Array, objArray.getType());
-
- SmartObject objInt(SmartType_Integer);
- ASSERT_EQ(SmartType_Integer, objInt.getType());
-
- SmartObject objDouble(SmartType_Double);
- ASSERT_EQ(SmartType_Double, objDouble.getType());
-
- SmartObject objBoolean(SmartType_Boolean);
- ASSERT_EQ(SmartType_Boolean, objBoolean.getType());
-
- SmartObject objChar(SmartType_Character);
- ASSERT_EQ(SmartType_Character, objChar.getType());
-
- SmartObject objString(SmartType_String);
- ASSERT_EQ(SmartType_String, objString.getType());
-
- SmartObject objBinary(SmartType_Binary);
- ASSERT_EQ(SmartType_Binary, objBinary.getType());
-
- SmartObject objInvalid(SmartType_Invalid);
- ASSERT_EQ(SmartType_Invalid, objInvalid.getType());
-
- SmartObject objNullConstructor(SmartType_Null);
- ASSERT_EQ(SmartType_Null, objNullConstructor.getType());
-
- SmartObject objNullDefault;
- ASSERT_EQ(SmartType_Null, objNullDefault.getType());
-}
-
-TEST(test_SmartObjectInvalidTest, invalid_object_remains_invalid) {
- SmartObject obj(SmartType_Invalid);
- ASSERT_EQ(SmartType_Invalid, obj.getType());
-
- obj = 1;
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_int_value, obj.asInt());
-
- // ---- unsigned int ---- //
- obj = static_cast<unsigned int>(100);
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_unsigned_int_value, obj.asUInt());
-
- // ---- DOUBLE ---- //
- obj = 3.14;
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_double_value, obj.asDouble());
-
- // ---- CHAR ---- //
- obj = 'a';
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_char_value, obj.asChar());
-
- // ---- BOOL ---- //
- obj = true;
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_bool_value, obj.asBool());
-
- // ---- CHAR* ---- //
- obj = "Hello, world";
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_string_value, obj.asString());
-
- // ---- STD::STRING ---- //
- obj = std::string("Hello, world");
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_string_value, obj.asString());
-
- // ---- BINARY ---- //
- NsSmartDeviceLink::NsSmartObjects::SmartBinary binaryData;
- binaryData.push_back('\0');
- binaryData.push_back('a');
- obj = binaryData;
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-
- // ---- ARRAY ---- //
- obj[0] = 1;
- obj[1] = true;
- obj[2] = 'a';
- obj[3] = 3.14;
-
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_int_value, obj[0].asInt());
- ASSERT_EQ(invalid_bool_value, obj[1].asBool());
- ASSERT_EQ(invalid_char_value, obj[2].asChar());
- ASSERT_EQ(invalid_double_value, obj[3].asDouble());
-
- // ---- DEEP ARRAY ---- //
- obj[0] = 1;
- obj[1][0] = 3.14;
- obj[1][1][0] = true;
-
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_int_value, obj[0].asInt());
- ASSERT_EQ(invalid_double_value, obj[1][0].asDouble());
- ASSERT_EQ(invalid_bool_value, obj[1][1][0].asBool());
-
- // ---- MAP ---- //
- obj["name"] = "My name";
- obj["count"] = 10;
- obj["isValid"] = true;
-
- ASSERT_EQ(SmartType_Invalid, obj.getType());
- ASSERT_EQ(invalid_string_value, obj["name"].asString());
- ASSERT_EQ(invalid_int_value, obj["count"].asInt());
- ASSERT_EQ(invalid_bool_value, obj["isValid"].asBool());
-
- // ---- DEEP MAP ---- //
- obj["request"]["name"] = "My Request";
- obj["request"]["id"] = 123;
- obj["response"]["name"] = "My Response";
- obj["response"]["id"] = 456;
- obj["we"]["need"]["to"]["go"]["deeper"] = true;
-
- ASSERT_EQ(SmartType_Invalid, obj.getType());
-
- ASSERT_EQ(invalid_string_value, obj["request"]["name"].asString());
- ASSERT_EQ(invalid_int_value, obj["request"]["id"].asInt());
- ASSERT_EQ(invalid_string_value, obj["response"]["name"].asString());
- ASSERT_EQ(invalid_int_value, obj["response"]["id"].asInt());
- ASSERT_EQ(invalid_bool_value, obj["we"]["need"]["to"]["go"]["deeper"].asBool());
-}
-} // namespace SmartObjectInvalidTest
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTINVALIDTEST_H_
diff --git a/test/components/smart_objects/SmartObjectStressTest.cc b/test/components/smart_objects/SmartObjectStressTest.cc
deleted file mode 100644
index 2a45f603b..000000000
--- a/test/components/smart_objects/SmartObjectStressTest.cc
+++ /dev/null
@@ -1,32 +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.
-*/
-
-#include "SmartObjectStressTest.h"
diff --git a/test/components/smart_objects/SmartObjectStressTest.h b/test/components/smart_objects/SmartObjectStressTest.h
deleted file mode 100644
index 7ad56a94b..000000000
--- a/test/components/smart_objects/SmartObjectStressTest.h
+++ /dev/null
@@ -1,358 +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 TEST_COMPONENTS_SMARTOBJECTS_SMARTOBJECTSTRESSTEST_H_
-#define TEST_COMPONENTS_SMARTOBJECTS_SMARTOBJECTSTRESSTEST_H_
-
-#include <sstream>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-
-
-//#define NO_INCLUSIVE_MAPS
-//#define COPY_SUB_OBJECTS_WORKAROUND
-
-
-namespace test { namespace components { namespace SmartObjects { namespace SmartObjectStressTest {
-
- using namespace NsSmartDeviceLink::NsSmartObjects;
-
- class StressTestHelper : public ::testing::Test
- {
- private:
- char get_random_char() const
- {
- return static_cast<char>('A' + (rand()%52));
- }
-
- std::string to_string(const int value) const
- {
- std::ostringstream oss;
- oss << value;
- return oss.str();
- }
-
- std::string to_string(const double value) const
- {
- // Content is the same as in SmartObject::convert_double_to_string
- std::stringstream ss;
- ss << std::fixed << std::setprecision(10) << value; //convert double to string w fixed notation, hi precision
- std::string s = ss.str(); //output to std::string
- s.erase(s.find_last_not_of('0') + 1, std::string::npos); //remove trailing 000s (123.1200 => 123.12, 123.000 => 123.)
- if(s[s.size()-1] == '.') {
- s.erase(s.end()-1); //remove dangling decimal (123. => 123)
- }
- return s;
- }
-
- std::string to_string(const char ch) const
- {
- char buff[2];
- sprintf(buff, "%c", ch);
- return std::string(buff);
- }
-
- std::string to_string(const bool b) const
- {
- return std::string( (b) ? "true" : "false");
- }
-
- protected:
- typedef std::map<std::string, std::string> VerificationMap;
- VerificationMap mVerifyMap;
-
- std::vector<std::string>split(const std::string &s, char delim) const
- {
- std::vector<std::string> elems;
-
- std::stringstream ss(s);
- std::string item;
- while(std::getline(ss, item, delim))
- {
- elems.push_back(item);
- }
-
- return elems;
- }
-
- std::string generate_key(const char *pPrefix, const int index) const
- {
- char buff[32];
- sprintf(buff, "%s%d", pPrefix, index);
- return std::string(buff);
- }
-
- void makeRandomObject(SmartObject &obj, const int size, std::string key_path)
- {
- int type_id = rand() % 8;
-
- switch (type_id)
- {
- case 0: // int
- {
- int iVal = rand();
- obj = iVal;
- mVerifyMap[key_path] = to_string(iVal);
- //std::cout << "Created int, value: " << iVal << std::endl;
- break;
- }
- case 1: // bool
- {
- bool bVal = static_cast<bool>(rand()%2);
- obj = bVal;
- mVerifyMap[key_path] = to_string(bVal);
- //std::cout << "Created bool, value: " << to_string(bVal) << std::endl;
- break;
- }
- case 2: // double
- {
- double dVal = 100.0 / (rand()%200);
- obj = dVal;
- mVerifyMap[key_path] = to_string(dVal);
- //std::cout << "Created double, value: " << dVal << std::endl;
- break;
- }
- case 3: // char
- {
- char cVal = get_random_char();
- obj = cVal;
- mVerifyMap[key_path] = to_string(cVal);
- //std::cout << "Created char, value: " << cVal << std::endl;
- break;
- }
- case 4: // string
- {
- std::string strVal(rand()%200, get_random_char());
- obj = strVal; // string with random char filled random size
- mVerifyMap[key_path] = strVal;
- //std::cout << "Created string, value: " << strVal << std::endl;
- break;
- }
- case 5: // map
- if (size <= 0)
- break;
-
- //std::cout << "Creating a map with size: " << size << std::endl;
- mVerifyMap[key_path] = "map";
- for (int i = 0; i < size; i++)
- {
- std::string key = generate_key("M", i);
-#ifdef NO_INCLUSIVE_MAPS
- obj[key] = key;
-#else
- obj[key] = SmartObject();
- makeRandomObject(obj[key], size - 1, key_path + key + ' '); // recursion
-#endif // MAP_WORKAROUND
- }
- break;
- case 6: // array
- if (size <= 0)
- break;
-
- //std::cout << "Creating an array with size: " << size << std::endl;
- mVerifyMap[key_path] = "array";
- for (int i = 0; i < size; i++)
- {
- obj[i] = SmartObject(); // just init it as an array
- makeRandomObject(obj[i], size - 1, key_path + generate_key("A", i) + ' '); // recursion
- }
- break;
- case 7: // binary
- int dataSize = rand()%200;
- char randomChar = get_random_char();
- std::string strDataVal(dataSize, randomChar);
- std::string strVal("c:");
- strVal += strDataVal;
-
- NsSmartDeviceLink::NsSmartObjects::SmartBinary binaryVal(dataSize, randomChar);
-
- obj = binaryVal; // string with binary data filled with random chars
- mVerifyMap[key_path] = strVal;
- //std::cout << "Created string, value: " << strVal << std::endl;
- break;
- }
- }
-
- SmartObject get_object(SmartObject &rootObj, const std::string &path) const
- {
- std::vector<std::string> obj_tokens;
- SmartObject lastObj = rootObj;
-
- obj_tokens = split(path, ' ');
-
- for (size_t i = 0; i < obj_tokens.size(); i++)
- {
- if (obj_tokens[i][0] == 'A') // array
- {
- int index = atoi(&(obj_tokens[i].c_str()[1])); // get integer skipping first char
-#ifdef COPY_SUB_OBJECTS_WORKAROUND
- lastObj = SmartObject(lastObj[index]);
-#else
- lastObj = lastObj[index]; // go to the child object
-#endif
- }
- else if (obj_tokens[i][0] == 'M') // map
- {
-#ifdef COPY_SUB_OBJECTS_WORKAROUND
- lastObj = SmartObject(lastObj[obj_tokens[i]]);
-#else
- lastObj = lastObj[obj_tokens[i]]; // go to the child object
-#endif
- }
- else
- {
- //FAIL();
- EXPECT_TRUE(false);
- }
- }
- return lastObj;
- }
- };
-
- /*
- * The test creates the initial SmartObject and use it as an array for the next SmartObjects.
- * Each next SmartObject is randomly assigned to some type.
- * If one of the object happens to be a container it fills it with SmartObject of random type. The amount of these
- * objects is the size of the parent container -1.
- * The iteration continues until all nodes are simple SmartObjects (not arrays or maps)
- */
- TEST_F(StressTestHelper, StressTest)
- {
- SmartObject objects;
-
- const int size = 11;
-
- for (int i = 0; i < size; i++)
- {
- SmartObject obj;
-
- makeRandomObject(obj, size - 1, generate_key("A", i) + ' ');
-
- objects[i] = obj;
- }
-
- for (VerificationMap::const_iterator it = mVerifyMap.begin(); it != mVerifyMap.end(); it++)
- {
- std::string value(it->second);
- SmartObject obj = get_object(objects, it->first);
-
- // Binary data check
- if(!value.compare(0, 2, "c:"))
- {
- std::string etalonData = value.substr(2);
-
- ASSERT_EQ(NsSmartDeviceLink::NsSmartObjects::SmartType_Binary, obj.getType());
-
- NsSmartDeviceLink::NsSmartObjects::SmartBinary binaryData = obj.asBinary();
- ASSERT_EQ(etalonData.size(), binaryData.size());
-
- for (size_t i = 0; i < etalonData.size() ; ++i)
- { {
- std::string etalonData = value.substr(2);
-
- ASSERT_EQ(NsSmartDeviceLink::NsSmartObjects::SmartType_Binary, obj.getType());
-
- NsSmartDeviceLink::NsSmartObjects::SmartBinary binaryData = obj.asBinary();
- ASSERT_EQ(etalonData.size(), binaryData.size());
-
- for (size_t i = 0; i < etalonData.size() ; ++i)
- {
- ASSERT_EQ(etalonData.at(i), binaryData.at(i));
- }
- continue;
- }
-
- ASSERT_EQ(etalonData.at(i), binaryData.at(i));
- }
- continue;
- }
-
-#ifdef NO_INCLUSIVE_MAPS
- if (!value.compare("map"))
- {
- std::vector<std::string> path = split(it->first, ' ');
-
- std::string map_value = path[path.size()-1];
- ASSERT_EQ(map_value, static_cast<std::string>(obj));
- continue;
- }
-#endif
- if (value.compare("map") && value.compare("array"))
- {
- //std::cout << "Verification key: " << it->first << " Value: " << value << std::endl;
- //std::cout << "Object Value: " << static_cast<std::string>(obj) << std::endl;
-
- if (!value.compare("true"))
- {
- ASSERT_TRUE(obj.asBool());
- }
- else if (!value.compare("false"))
- {
- ASSERT_FALSE(obj.asBool());
- }
- else
- {
- ASSERT_EQ(value, obj.asString()) << "Object value is not correct. Object path: " << it->first;
- }
- }
- }
- }
-
- TEST_F(StressTestHelper, ExtraManualDebugTest)
- {
- SmartObject obj;
-
- obj[0] = false;
- obj[1] = 0.869495;
- obj[2] = true;
- obj[3] = 'Q';
- obj[4] = true;
- obj[5] = 3.704;
- obj[6] = SmartObject();
- obj[6][0] = std::string("ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt");
- obj[6][1] = 'K';
- obj[6][2] = 0.735294;
- obj[6][3] = 'I';
- obj[6][4] = SmartObject();
- obj[6][4]["M0"] = 0.59432;
- SmartObject & refObj = obj[6][4];
- refObj["M1"]["M0"]["M0"][0] = true;
-
- // FIXME: Figure out why there's a trailing zero while converting from double to string
- ASSERT_EQ("0.59432", get_object(obj, "A6 A4 M0").asString());
- ASSERT_TRUE(get_object(obj, "A6 A4 M1 M0 M0 A0").asBool());
- }
-
-}}}}
-
-#endif // TEST_COMPONENTS_SMARTOBJECTS_SMARTOBJECTSTRESSTEST_H_
diff --git a/test/components/smart_objects/SmartObjectUnitTest.cc b/test/components/smart_objects/SmartObjectUnitTest.cc
deleted file mode 100644
index 29a6fca49..000000000
--- a/test/components/smart_objects/SmartObjectUnitTest.cc
+++ /dev/null
@@ -1,32 +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.
-*/
-
-#include "SmartObjectUnitTest.h"
diff --git a/test/components/smart_objects/SmartObjectUnitTest.h b/test/components/smart_objects/SmartObjectUnitTest.h
deleted file mode 100644
index 02efbfb1e..000000000
--- a/test/components/smart_objects/SmartObjectUnitTest.h
+++ /dev/null
@@ -1,590 +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 TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTUNITTEST_H_
-#define TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTUNITTEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-
-namespace test {
-namespace components {
-namespace SmartObjects {
-namespace SmartObjectUnitTest {
-
-using namespace NsSmartDeviceLink::NsSmartObjects;
-
-
-class TestHelper : public ::testing::Test {
- protected:
-
- void makeMapObject(SmartObject& obj, const int size) const {
- char i_key[8], j_key[8], k_key[8], value[8];
-
- for (int i = 0; i < size; i++)
- for (int j = 0; j < size; j++)
- for (int k = 0; k < size; k++) {
- sprintf(i_key, "i_%d", i);
- sprintf(j_key, "j_%d", j);
- sprintf(k_key, "k_%d", k);
- sprintf(value, "%d", i + j + k);
- obj[i_key][j_key][k_key] = value;
- }
- }
-
- void checkMapObject(SmartObject& obj, const int size) const {
- char i_key[8], j_key[8], k_key[8], value[8];
-
- for (int i = 0; i < size; i++)
- for (int j = 0; j < size; j++)
- for (int k = 0; k < size; k++) {
- sprintf(i_key, "i_%d", i);
- sprintf(j_key, "j_%d", j);
- sprintf(k_key, "k_%d", k);
- sprintf(value, "%d", i + j + k);
-
- ASSERT_EQ(std::string(value), obj[i_key][j_key][k_key].asString()) <<
- "Wrong value in the map at [" << i_key << "][" << j_key << "][" << k_key << "]";
- }
- }
-
- void makeArrayObject(SmartObject& obj, int size, int base = 0) {
- for (int i = 0; i < size; i++)
- for (int j = 0; j < size; j++)
- for (int k = 0; k < size; k++) {
- obj[i][j][k] = base + i + j + k;
- }
- }
-
- void checkArrayObject(SmartObject& obj, int size, int base = 0) {
- for (int i = 0; i < size; i++)
- for (int j = 0; j < size; j++)
- for (int k = 0; k < size; k++) {
- ASSERT_EQ(base + i + j + k, obj[i][j][k].asInt()) <<
- "Wrong value in the array at index: " << i << ", " << j << ", " << k;
- }
- }
-};
-
-/*
- * Tests different types sequentially
- */
-TEST(BasicMixtedTypes, test_SmartObjectUnitTest) {
- SmartObject obj;
-
- ASSERT_EQ(invalid_int_value, obj.asInt()) << "Wrong cast to int just after construction";
-
- obj = 10;
- ASSERT_EQ(10, obj.asInt()) << "Wrong cast to int";
-
- obj = "some string";
- ASSERT_EQ("some string", obj.asString()) << "Wrong cast to std::string";
-
- obj = false;
- ASSERT_FALSE(obj.asBool()) << "Wrong cast to bool";
-
- obj = 'A';
- ASSERT_EQ('A', obj.asChar()) << "Wrong cast to char";
-
- obj = 3.14;
- ASSERT_EQ(3.14, obj.asDouble()) << "Wrong cast to double";
-
- // array test
- for (int i = 0; i < 100; i++) {
- obj[i] = i;
- ASSERT_EQ(i, obj[i].asInt());
- }
-
- // map test
- for (int i = 0; i < 100; i++) {
- char key[8];
- sprintf(key, "%d", i);
- obj[key] = i;
- ASSERT_EQ(i, obj[key].asInt());
- }
-}
-
-TEST_F(TestHelper, BasicArrayTest) {
- SmartObject obj;
-
- ASSERT_EQ(invalid_int_value,
- obj[0].asInt()) << "Wrong value at accessing non existent index";
- ASSERT_EQ(invalid_int_value,
- obj["non_existent_key"].asInt()) << "Wrong value at accessing non existent key";
-
- obj[0] = 1;
- ASSERT_EQ(1, obj[0].asInt()) << "Wrong value at 0 index";
- obj[1] = 2;
- ASSERT_EQ(2, obj[1].asInt()) << "Wrong value at 1 index";
-
- obj[0][0] = 3;
- obj[1][0] = 1;
- ASSERT_EQ(3, obj[0][0].asInt()) << "Wrong value at index 0, 0";
-
- obj[0][0][0] = 4;
- obj[0][1][0] = 5;
- ASSERT_EQ(4, obj[0][0][0].asInt()) << "Wrong value at index 0, 0, 0";
-
- const int size = 32;
- makeArrayObject(obj, size);
-
- checkArrayObject(obj, size);
-}
-
-
-TEST_F(TestHelper, BasicMapTest) {
- SmartObject obj;
-
- ASSERT_EQ(invalid_int_value,
- obj["non_existent_key"].asInt()) << "Wrong value for non existent key";
-
- obj["abc"]["def"]["ghi"] = 5;
- ASSERT_EQ(5, obj["abc"]["def"]["ghi"].asInt()) << "Wrong value for triple map";
-
- obj["123"]["456"]["789"] = "string test";
-
- ASSERT_EQ("string test", obj["123"]["456"]["789"].asString()) <<
- "Wrong value for triple map";
-
- const int size = 32;
-
- makeMapObject(obj, size);
-
- checkMapObject(obj, size);
-}
-
-TEST(ConstructorsTest, test_SmartObjectUnitTest) {
- SmartObject objInt(5678);
- ASSERT_EQ(5678, objInt.asInt()) << "Wrong constructor with int param";
-
- const char* c_str = "test c_string";
- SmartObject obj_c_str(c_str);
- ASSERT_EQ("test c_string", obj_c_str.asString()) << "Wrong constructor with c_str param";
-
- SmartObject obj_std_str(std::string("test std_string"));
- ASSERT_EQ(std::string("test std_string"), obj_std_str.asString());
-
- SmartObject obj_char('R');
- ASSERT_EQ('R', obj_char.asChar()) << "Wrong constructor with char param";
-
- SmartObject obj_double(-0.4321);
- ASSERT_EQ(-0.4321, obj_double.asDouble()) << "Wrong constructor with double param";
-
- SmartObject obj_bool(true);
- ASSERT_TRUE(obj_bool.asBool()) << "Wrong constructor with bool param";
-
- SmartObject src_obj;
-
- src_obj["key_1"] = "value_1"; // FIXME: String assignment crashes test
- src_obj["key_2"]["sub_key_1"] = "value_2";
-
- SmartObject dst_obj(src_obj);
- ASSERT_EQ("value_1", dst_obj["key_1"].asString()) << "Copy constructor is not correct";
- ASSERT_EQ("value_2", dst_obj["key_2"]["sub_key_1"].asString()) <<
- "Copy constructor is not correct";
-}
-
-TEST(FromString, TypeConversion) {
- {
- // String to bool
- SmartObject obj;
- ASSERT_EQ(invalid_bool_value, obj.asBool());
- obj = "true";
- ASSERT_EQ(invalid_bool_value, obj.asBool());
- obj = "false";
- ASSERT_EQ(invalid_bool_value, obj.asBool());
- obj = true;
- ASSERT_TRUE(obj.asBool());
- }
- {
- // String to int
- SmartObject obj;
- ASSERT_EQ(invalid_int_value, obj.asInt());
- obj = "0";
- ASSERT_EQ(0, obj.asInt());
- obj = "-34323";
- ASSERT_EQ(-34323, obj.asInt());
- obj = "+1234";
- ASSERT_EQ(1234, obj.asInt());
- obj = "3232.0";
- ASSERT_EQ(invalid_int_value, obj.asInt());
- obj = "123wtf";
- ASSERT_EQ(invalid_int_value, obj.asInt());
- obj = "";
- ASSERT_EQ(invalid_int_value, obj.asInt());
- obj = " 123 ";
- ASSERT_EQ(invalid_int_value, obj.asInt());
- obj = " 123";
- ASSERT_EQ(123, obj.asInt());
- }
- {
- // String to char
- SmartObject obj;
- ASSERT_EQ(invalid_char_value, obj.asChar());
- obj = "C";
- ASSERT_EQ('C', obj.asChar());
- obj = "\n";
- ASSERT_EQ('\n', obj.asChar());
- obj = " A";
- ASSERT_EQ(invalid_char_value, obj.asChar());
- obj = "";
- ASSERT_EQ(invalid_char_value, obj.asChar());
- }
- {
- // String to double
- SmartObject obj;
- ASSERT_EQ(invalid_double_value, obj.asDouble());
- obj = "1234";
- ASSERT_EQ(1234, obj.asDouble());
- obj = "-0.1234";
- ASSERT_EQ(-0.1234, obj.asDouble());
- obj = ".54321";
- ASSERT_EQ(.54321, obj.asDouble());
- obj = "123.45.6";
- ASSERT_EQ(invalid_double_value, obj.asDouble());
- obj = "123 wtf";
- ASSERT_EQ(invalid_double_value, obj.asDouble());
- obj = " 0.5";
- ASSERT_EQ(0.5, obj.asDouble());
- }
- {
- // String to Map
- SmartObject obj;
- ASSERT_EQ(invalid_int_value, obj["key"].asInt());
- obj = "this is not a map";
- ASSERT_EQ(invalid_char_value, obj["some_key"].asChar());
- }
- {
- // String to Array
- SmartObject obj;
- ASSERT_EQ(invalid_bool_value, obj[0].asBool());
- obj = "this is not an array";
- ASSERT_EQ(invalid_double_value, obj[0].asDouble());
- }
- {
- // String to Binary
- SmartObject obj;
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
- obj = "this is not an array";
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
- }
-}
-
-TEST(FromBool, TypeConversion) {
- SmartObject obj;
-
- obj = true;
-
- ASSERT_EQ(invalid_string_value, obj.asString());
- ASSERT_TRUE(obj.asBool());
- ASSERT_EQ(1, obj.asInt());
- ASSERT_EQ(invalid_char_value, obj.asChar());
- ASSERT_EQ(1.0, obj.asDouble());
- ASSERT_EQ(invalid_int_value, obj["key"].asInt());
- ASSERT_EQ(invalid_char_value, obj[0].asChar());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-
- obj = false;
-
- ASSERT_EQ(invalid_string_value, obj.asString());
- ASSERT_FALSE(obj.asBool());
- ASSERT_EQ(0, obj.asBool());
- ASSERT_EQ(invalid_char_value, obj.asChar());
- ASSERT_EQ(0, obj.asDouble());
- ASSERT_EQ(invalid_int_value, obj["key"].asInt());
- ASSERT_EQ(invalid_char_value, obj[0].asChar());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-}
-
-TEST(FromInt, TypeConversion) {
- SmartObject obj;
-
- obj = 123;
-
- ASSERT_EQ("123", obj.asString());
- ASSERT_TRUE(obj.asBool());
- ASSERT_EQ(invalid_char_value, obj.asChar());
- ASSERT_EQ(123.0, obj.asDouble());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-
- obj = 5;
- ASSERT_EQ("5", obj.asString());
- ASSERT_EQ(invalid_char_value, obj.asChar());
-
- obj = 0;
- ASSERT_EQ("0", obj.asString());
- ASSERT_FALSE(obj.asBool());
-
- obj = 1;
- ASSERT_TRUE(obj.asBool());
-
- obj = -1234;
- ASSERT_EQ(-1234, obj.asInt());
- ASSERT_EQ("-1234", obj.asString());
- ASSERT_EQ(-1234.0, obj.asDouble());
- ASSERT_EQ(invalid_char_value, obj.asChar());
- ASSERT_TRUE(obj.asBool());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-}
-
-TEST(FromChar, TypeConversion) {
- SmartObject obj;
-
- obj = '1';
-
- ASSERT_EQ("1", obj.asString());
- ASSERT_EQ(invalid_int_value, obj.asInt());
- ASSERT_EQ('1', obj.asChar());
- ASSERT_EQ(invalid_double_value, obj.asDouble());
- ASSERT_EQ(invalid_int_value, obj["key"].asInt());
- ASSERT_EQ(invalid_char_value, obj[0].asChar());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-
- obj = '0';
-
- ASSERT_EQ("0", obj.asString());
- ASSERT_EQ(invalid_int_value, obj.asInt());
- ASSERT_EQ('0', obj.asChar());
- ASSERT_EQ(invalid_double_value, obj.asDouble());
- ASSERT_EQ(invalid_int_value, obj["key"].asInt());
- ASSERT_EQ(invalid_char_value, obj[0].asChar());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-}
-
-TEST(FromDouble, TypeConversion) {
- SmartObject obj;
-
- obj = 0.1;
- ASSERT_EQ("0.1", obj.asString()); // FIXME: result 0.100000
- ASSERT_EQ(0, obj.asInt());
- ASSERT_EQ(invalid_char_value, obj.asChar());
- ASSERT_EQ(0.1, obj.asDouble());
- ASSERT_TRUE(obj.asBool());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-
- obj = 0.9;
- ASSERT_EQ("0.9", obj.asString());
- ASSERT_EQ(0, obj.asInt());
- ASSERT_TRUE(obj.asBool());
-
- obj = -12323.999;
- ASSERT_EQ("-12323.999", obj.asString());
- ASSERT_EQ(-12323, obj.asInt());
- ASSERT_TRUE(obj.asBool());
-
- obj = 0.0;
- ASSERT_EQ("0", obj.asString());
- ASSERT_EQ(0, obj.asInt());
- ASSERT_FALSE(obj.asBool());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-}
-
-TEST(FromMap, TypeConversion) {
- SmartObject obj;
-
- obj["key1"] = 123;
-
- ASSERT_EQ(invalid_string_value, obj.asString());
- ASSERT_EQ(invalid_int_value, obj.asInt());
- ASSERT_EQ(invalid_char_value, obj.asChar());
- ASSERT_EQ(invalid_double_value, obj.asDouble());
- ASSERT_EQ(123, obj["key1"].asInt());
- ASSERT_EQ(invalid_char_value, obj[0].asChar());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-}
-
-TEST(FromArray, TypeConversion) {
- SmartObject obj;
-
- obj[0] = 'A';
- obj[1] = -123;
-
- ASSERT_EQ(invalid_string_value, obj.asString());
- ASSERT_EQ(invalid_int_value, obj.asInt());
- ASSERT_EQ(invalid_char_value, obj.asChar());
- ASSERT_EQ(invalid_double_value, obj.asDouble());
- ASSERT_EQ('A', obj[0].asChar());
- ASSERT_EQ(invalid_int_value, obj["key1"].asInt());
- ASSERT_EQ(invalid_binary_value, obj.asBinary());
-}
-
-TEST_F(TestHelper, AssignmentTest) {
- SmartObject objSrc, objDst;
-
- objSrc = -6;
- objDst = 7;
- objDst = objSrc;
- ASSERT_EQ(-6, objDst.asInt()) << "Wrong assignment for int object";
-
- objSrc = "Some test string";
- objDst = "Other string";
- objDst = objSrc;
- ASSERT_EQ("Some test string",
- objDst.asString()) << "Wrong assignment for std::string object";
-
- objSrc = 0.5;
- objDst = 4;
- objDst = objSrc;
- ASSERT_EQ(0.5, objDst.asDouble()) << "Wrong assignment for double object";
-
- objSrc = true;
- objDst = false;
- objDst = objSrc;
- ASSERT_TRUE(objDst.asBool()) << "Wrong assignment for bool object";
-
- const int size = 32;
- makeMapObject(objSrc, size);
- objDst["a"]["b"] = 4;
- objDst = objSrc;
- checkMapObject(objDst, size);
-
- makeArrayObject(objSrc, size, 5);
- makeArrayObject(objDst, 23, 6);
- objDst = objSrc;
- checkArrayObject(objDst, size, 5);
-}
-
-TEST_F(TestHelper, SizeTest) {
- SmartObject obj;
-
- ASSERT_EQ(0u, obj.length()) << "Wrong size for the uninitialized object";
-
- obj = 1234;
- ASSERT_EQ(0u, obj.length()) << "Wrong size for the int object";
-
- std::string str("Some test very long string");
- obj = str;
- ASSERT_EQ(str.size(), obj.length()) <<
- "The size of the object containing string is not correct";
-
- obj = true;
- ASSERT_EQ(0u, obj.length()) << "Wrong size of the true";
-
- obj = 0.1234;
- ASSERT_EQ(0u, obj.length()) << "Wrong size of the double";
-
- obj = 'A';
- ASSERT_EQ(0u, obj.length()) << "Wrong size of the char";
-
- makeMapObject(obj, 12);
- ASSERT_EQ(12u, obj.length()) << "Wrong size of the object containing map";
-
- makeArrayObject(obj, 21);
- ASSERT_EQ(21u, obj.length()) << "Wrong size of the object containing array";
-}
-
-TEST(CopyObjectsTest, SmartObjectTest) {
- SmartObject obj;
-
- obj[0] = "test string";
-
- obj = obj[0];
-
- ASSERT_EQ("test string", obj.asString());
-
- obj["abc"] = "new test string";
- obj = obj["abc"];
-
- ASSERT_EQ("new test string", obj.asString());
-}
-
-TEST(CopyConstructorTest, SmartObjectTest) {
- SmartObject srcObj;
-
- srcObj[0] = "test string";
-
- SmartObject dstObj = srcObj[0];
-
- ASSERT_EQ("test string", dstObj.asString());
-}
-
-TEST(MapEraseTest, SmartObjectTest) {
- SmartObject srcObj;
-
- srcObj["one"] = 1;
- srcObj["two"] = 2;
- srcObj["three"] = 3;
-
- ASSERT_EQ(3u, srcObj.length());
- ASSERT_EQ(2, srcObj["two"].asInt());
-
- ASSERT_TRUE(srcObj.erase("two"));
- ASSERT_FALSE(srcObj.erase("two"));
-
- ASSERT_EQ(2u, srcObj.length());
- ASSERT_EQ(-1, srcObj["two"].asInt());
- // The element "two" was accessed in the previous line so the element has been created
- ASSERT_EQ(3u, srcObj.length());
-
- srcObj["two"] = 2;
-
- ASSERT_EQ(1, srcObj["one"].asInt());
- ASSERT_EQ(2, srcObj["two"].asInt());
- ASSERT_EQ(3, srcObj["three"].asInt());
-
- ASSERT_TRUE(srcObj.erase("one"));
-
- ASSERT_EQ(2u, srcObj.length());
-
- ASSERT_TRUE(srcObj.erase("two"));
-
- ASSERT_EQ(1u, srcObj.length());
-
- ASSERT_TRUE(srcObj.erase("three"));
-
- ASSERT_EQ(0u, srcObj.length());
-
- srcObj["one"]["two"]["three"]["0"] = "1";
- srcObj["one"]["two"]["three"]["1"] = "2";
-
- ASSERT_EQ(1u, srcObj.length());
- ASSERT_EQ(1u, srcObj["one"].length());
- ASSERT_EQ(1u, srcObj["one"]["two"].length());
- ASSERT_EQ(2u, srcObj["one"]["two"]["three"].length());
-
- ASSERT_TRUE(srcObj["one"]["two"]["three"].erase("0"));
- ASSERT_FALSE(srcObj["one"]["two"]["three"].erase("0"));
-
- ASSERT_EQ(1u, srcObj["one"]["two"]["three"].length());
-
- ASSERT_TRUE(srcObj["one"].erase("two"));
- ASSERT_EQ(0u, srcObj["one"].length());
-
- srcObj = 1234; // not a map
- ASSERT_FALSE(srcObj.erase("one"));
-}
-// TODO: Add a test to check accessing an array at strange indexes.
-} // namespace SmartObjectUnitTest
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
-#endif // TEST_COMPONENTS_SMART_OBJECTS_SMARTOBJECTUNITTEST_H_
diff --git a/test/components/smart_objects/TSharedPtrTest.cc b/test/components/smart_objects/TSharedPtrTest.cc
deleted file mode 100644
index 180bc007f..000000000
--- a/test/components/smart_objects/TSharedPtrTest.cc
+++ /dev/null
@@ -1,32 +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.
-*/
-
-#include "TSharedPtrTest.h"
diff --git a/test/components/smart_objects/TSharedPtrTest.h b/test/components/smart_objects/TSharedPtrTest.h
deleted file mode 100644
index 885d1cfd8..000000000
--- a/test/components/smart_objects/TSharedPtrTest.h
+++ /dev/null
@@ -1,209 +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 TEST_COMPONENTS_SMARTOBJECTS_TSHAREDPTRTEST_H_
-#define TEST_COMPONENTS_SMARTOBJECTS_TSHAREDPTRTEST_H_
-
-#include <stdlib.h>
-#include <vector>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "utils/shared_ptr.h"
-
-namespace test {
-namespace components {
-namespace utils {
-namespace SharedPtrTest {
-class CMockObject {
- public:
- CMockObject(int id);
- ~CMockObject(void);
- int getId(void) const;
-
- MOCK_METHOD0(destructor, void ());
-
- private:
- int mId;
-};
-
-class CExtendedMockObject: public CMockObject {
- public:
- CExtendedMockObject(int id);
-};
-} // namespace CMockObject
-} // namespace SmartObjects
-} // namespace components
-} // namespace test
-
-test::components::utils::SharedPtrTest::CMockObject::CMockObject(int id)
- : mId(id) {
-}
-
-test::components::utils::SharedPtrTest::CMockObject::~CMockObject(void) {
- destructor();
-}
-
-int test::components::utils::SharedPtrTest::CMockObject::getId(void) const {
- return mId;
-}
-
-test::components::utils::SharedPtrTest::CExtendedMockObject::CExtendedMockObject(int id)
- : CMockObject(id) {
-}
-
-typedef utils::SharedPtr<test::components::utils::SharedPtrTest::CMockObject>
-tMockObjectPtr;
-typedef utils::SharedPtr<test::components::utils::SharedPtrTest::CExtendedMockObject>
-tExtendedMockObjectPtr;
-
-TEST(SharedPtrTest, Constructor) {
- test::components::utils::SharedPtrTest::CMockObject* object1 = new
- test::components::utils::SharedPtrTest::CMockObject(1);
- test::components::utils::SharedPtrTest::CMockObject* object2 = new
- test::components::utils::SharedPtrTest::CMockObject(2);
-
- EXPECT_CALL(*object1, destructor()).Times(0);
- EXPECT_CALL(*object2, destructor()).Times(0);
-
- tMockObjectPtr p1(object1);
- ASSERT_EQ(1, p1->getId());
-
- tMockObjectPtr p2(p1);
- ASSERT_EQ(1, p2->getId());
-
- tMockObjectPtr p3 = p2;
- ASSERT_EQ(1, p3->getId());
-
- tMockObjectPtr p4 = object2;
- ASSERT_EQ(2, p4->getId());
-
- p3 = p4;
- ASSERT_EQ(2, p3->getId());
-
- EXPECT_CALL(*object1, destructor()).Times(1);
- EXPECT_CALL(*object2, destructor()).Times(1);
-}
-
-TEST(SharedPtrTest, PointerTypeCast) {
- test::components::utils::SharedPtrTest::CExtendedMockObject* object1 = new
- test::components::utils::SharedPtrTest::CExtendedMockObject(1);
- test::components::utils::SharedPtrTest::CExtendedMockObject* object2 = new
- test::components::utils::SharedPtrTest::CExtendedMockObject(2);
-
- EXPECT_CALL(*object1, destructor()).Times(0);
- EXPECT_CALL(*object2, destructor()).Times(0);
-
- tExtendedMockObjectPtr ep1(object1);
- ASSERT_EQ(1, ep1->getId());
-
- tMockObjectPtr p1(ep1);
- ASSERT_EQ(1, p1->getId());
-
- tExtendedMockObjectPtr ep2(object2);
- ASSERT_EQ(2, ep2->getId());
-
- p1 = ep2;
- ASSERT_EQ(2, p1->getId());
-
- EXPECT_CALL(*object1, destructor()).Times(1);
- EXPECT_CALL(*object2, destructor()).Times(1);
-}
-
-TEST(SharedPtrTest, AddedOperators) {
- test::components::utils::SharedPtrTest::CExtendedMockObject* object1 = new
- test::components::utils::SharedPtrTest::CExtendedMockObject(1);
- test::components::utils::SharedPtrTest::CExtendedMockObject* object2 = new
- test::components::utils::SharedPtrTest::CExtendedMockObject(2);
-
- EXPECT_CALL(*object1, destructor()).Times(0);
- EXPECT_CALL(*object2, destructor()).Times(0);
-
- tExtendedMockObjectPtr ep1(object1);
- tMockObjectPtr p1(ep1);
- tExtendedMockObjectPtr ep2(object2);
- p1 = ep2;
-
- ASSERT_EQ(2, p1->getId());
- ASSERT_EQ(2, (*p1).getId());
-
- ASSERT_FALSE(!p1);
-
- utils::SharedPtr<int> p3(new int(10));
- ASSERT_EQ(10, *p3);
- ASSERT_FALSE(!p3);
-
- utils::SharedPtr<int> p2;
- ASSERT_TRUE(!p2);
-
- p2.reset(new int);
- ASSERT_FALSE(!p2);
- *p2 = 3;
- ASSERT_EQ(3, *p2);
-
- EXPECT_CALL(*object1, destructor()).Times(1);
- EXPECT_CALL(*object2, destructor()).Times(1);
-}
-
-TEST(SharedPtrTest, StressTest) {
- const size_t cNumIterations = 1024U * 1024U;
-
- size_t objectCreated = 0U;
- size_t pointersCopied = 0U;
-
- std::vector<tMockObjectPtr> objects;
-
- for (size_t i = 0U; i < cNumIterations; ++i) {
- if ((true == objects.empty()) ||
- (0 == rand() % 256)) {
- test::components::utils::SharedPtrTest::CMockObject* object = new
- test::components::utils::SharedPtrTest::CMockObject(0);
- EXPECT_CALL(*object, destructor()).Times(1);
-
- objects.push_back(object);
-
- ++objectCreated;
- } else {
- size_t objectIndex = static_cast<size_t>(rand()) % objects.size();
-
- if (rand() % 2) {
- objects.push_back(objects[objectIndex]);
-
- ++pointersCopied;
- } else {
- objects.erase(objects.begin() + objectIndex);
- }
- }
- }
- printf("%zu objects created, %zu pointers copied\n",
- objectCreated, pointersCopied);
-}
-#endif // TEST_COMPONENTS_SMARTOBJECTS_TSHAREDPTRTEST_H_
diff --git a/test/components/smart_objects/map_performance_test.cc b/test/components/smart_objects/map_performance_test.cc
deleted file mode 100644
index 3e5bbc1b8..000000000
--- a/test/components/smart_objects/map_performance_test.cc
+++ /dev/null
@@ -1,79 +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 TEST_COMPONENTS_MAP_TSHAREDPTRTEST_H_
-#define TEST_COMPONENTS_MAP_TSHAREDPTRTEST_H_
-
-#include <string>
-#include <vector>
-#include <map>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-typedef std::string Key;
-typedef std::vector<std::string> Value;
-typedef std::map<Key, Value > Map;
-
-namespace {
-void MakeMapObject(Map &obj, const int size) {
- char i_key[8], j_key[8];
-
- Value array;
- for (int i = 0; i < size; i++) {
- for (int j = 0; j < size; j++) {
- sprintf(j_key, "j_%d", j);
- array.push_back(j_key);
- }
-
- sprintf(i_key, "i_%d", i);
- obj[i_key] = array;
- }
-}
-}
-
-TEST(SmartObjectPerformanceTest, SmartObjectMapPerformance) {
- Map object;
- MakeMapObject(object, 100);
-
- for (Map::const_iterator i = object.begin(); i != object.end(); ++i) {
- printf("%s - ", i->first.c_str());
- const Value& value = i->second;
-
- Value::const_iterator item = std::find(value.begin(), value.end(), "j_9");
- if (item != value.end()) {
- printf("%s\n", item->c_str());
- } else {
- printf("none...\n");
- }
- }
-}
-
-#endif // TEST_COMPONENTS_MAP_TSHAREDPTRTEST_H_
diff --git a/test/components/smart_objects/smart_object_performance_test.cc b/test/components/smart_objects/smart_object_performance_test.cc
deleted file mode 100644
index 5a2b828fa..000000000
--- a/test/components/smart_objects/smart_object_performance_test.cc
+++ /dev/null
@@ -1,79 +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 TEST_COMPONENTS_SMARTOBJECTS_TSHAREDPTRTEST_H_
-#define TEST_COMPONENTS_SMARTOBJECTS_TSHAREDPTRTEST_H_
-
-#include <string>
-#include <set>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "smart_objects/smart_object.h"
-
-using namespace NsSmartDeviceLink::NsSmartObjects;
-
-namespace {
-void MakeMapObject(SmartObject &obj, const int size) {
- char i_key[8], j_key[8];
-
- SmartObject array;
- for (int i = 0; i < size; i++) {
- for (int j = 0; j < size; j++) {
- sprintf(j_key, "j_%d", j);
- array[-1] = j_key;
- }
-
- sprintf(i_key, "i_%d", i);
- obj[i_key] = array;
- }
-}
-}
-
-TEST(SmartObjectPerformanceTest, SmartObjectPerformance) {
- SmartObject object;
- MakeMapObject(object, 100);
-
- std::set<std::string> keys = object.enumerate();
- for (std::set<std::string>::iterator i = keys.begin(); i != keys.end(); ++i) {
- printf("%s - ", i->c_str());
- SmartArray* array = object[*i].asArray();
-
- SmartArray::iterator item = std::find(array->begin(), array->end(), "j_9");
- if (item != array->end()) {
- printf("%s\n", item->asString().c_str());
- } else {
- printf("none...\n");
- }
- }
-}
-
-#endif // TEST_COMPONENTS_SMARTOBJECTS_TSHAREDPTRTEST_H_
diff --git a/test/components/transport_manager/CMakeLists.txt b/test/components/transport_manager/CMakeLists.txt
deleted file mode 100644
index 502978366..000000000
--- a/test/components/transport_manager/CMakeLists.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-include_directories (
- ${GMOCK_INCLUDE_DIRECTORY}
- ./include
- ${CMAKE_SOURCE_DIR}/src/components/transport_manager/include
- ${CMAKE_SOURCE_DIR}/src/components/config_profile/include/
- ${CMAKE_SOURCE_DIR}/src/components/utils/include/
- ${LIBUSB_INCLUDE_DIRECTORY}
- ${LOG4CXX_INCLUDE_DIRECTORY}
- ${CMAKE_SOURCE_DIR}/src/components/utils/include
-)
-
-set (LIBRARIES
- gmock
- gmock_main
- TransportManager
- ProtocolHandler
- Resumption
- Utils
- ConfigProfile
- jsoncpp
- ${RTLIB}
- ProtocolLibrary
-)
-
-if (BUILD_AVAHI_SUPPORT)
- list(APPEND LIBRARIES avahi-client)
-endif()
-
-if (BUILD_USB_SUPPORT)
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- list(APPEND LIBRARIES Libusb-1.0.16)
-endif()
-endif()
-
-set (SOURCES
- ./src/mock_connection.cc
- ./src/mock_connection_factory.cc
- ./src/mock_application.cc
- ./src/mock_device.cc
- ./src/mock_transport_adapter.cc
- ./src/mock_device_scanner.cc
- ./src/raw_message_matcher.cc
- ./src/transport_manager_test.cc
-)
-
-set (TESTUSBSOURCES
- ./src/test_usb.cc
-)
-
-create_test("test_TransportManagerTest" "${SOURCES}" "${LIBRARIES}")
-create_test("test_TcpTransportAdapter" "src/test_tcp_transport_adapter.cc" "${LIBRARIES}")
-#create_test("test_usb" "${TESTUSBSOURCES}" "${LIBRARIES}")
-
-#add_executable("test_DnssdServiceDiscovery" "src/test_dnssd_service_browser.cc")
-#target_link_libraries("test_DnssdServiceDiscovery" ${LIBRARIES})
-#add_test(test_DnssdServiceDiscovery, ./test_DnssdServiceDiscovery.sh)
-
-target_link_libraries("test_TransportManagerTest" TransportManager )
-
-if (BUILD_USB_SUPPORT)
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- target_link_libraries("test_TransportManagerTest" Libusb-1.0.16)
-endif()
-endif()
-# vim: set ts=2 sw=2 et:
diff --git a/test/components/transport_manager/HandleGeneratorsTest.cpp b/test/components/transport_manager/HandleGeneratorsTest.cpp
deleted file mode 100644
index 6ba2f598f..000000000
--- a/test/components/transport_manager/HandleGeneratorsTest.cpp
+++ /dev/null
@@ -1,114 +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.
-//
-
-/*
- Tests correct generation of Device and Connection handles used in TransportManager.
- - tests that generated handles are valid
- - generates 10000 handles
- */
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "TransportManager/ITransportManager.hpp"
-
-using ::testing::_;
-
-namespace test
-{
- namespace components
- {
- namespace TransportManager
- {
- namespace HandleGeneratorsTest
- {
-
- class TestTransportManager: public NsSmartDeviceLink::NsTransportManager::ITransportManager
- {
- public:
- void run()
- {
- // Preventing parent function processing.
- // Does not needed inside this test.
- }
- };
- }
- }
- }
-}
-
-TEST(test_TransportManagerHandleGenerators, singleDeviceHandleCanBeGenerated)
-{
- test::components::TransportManager::HandleGeneratorsTest::TestTransportManager tm;
- NsSmartDeviceLink::NsTransportManager::tDeviceHandle handle;
-
- handle = tm.generateNewDeviceHandle();
- ASSERT_NE(handle, NsSmartDeviceLink::NsTransportManager::InvalidDeviceHandle);
-}
-
-TEST(test_TransportManagerHandleGenerators, manyDeviceHandlesCanBeGenerated)
-{
- test::components::TransportManager::HandleGeneratorsTest::TestTransportManager tm;
- NsSmartDeviceLink::NsTransportManager::tDeviceHandle handle;
-
- for (int i = 0; i < 10000; i++)
- {
- handle = tm.generateNewDeviceHandle();
- ASSERT_NE(handle, NsSmartDeviceLink::NsTransportManager::InvalidDeviceHandle);
- }
-}
-
-TEST(test_TransportManagerHandleGenerators, singleConnectionHandleCanBeGenerated)
-{
- test::components::TransportManager::HandleGeneratorsTest::TestTransportManager tm;
- NsSmartDeviceLink::NsTransportManager::tConnectionHandle handle;
-
- handle = tm.generateNewConnectionHandle();
- ASSERT_NE(handle, NsSmartDeviceLink::NsTransportManager::InvalidConnectionHandle);
-}
-
-TEST(test_TransportManagerHandleGenerators, manyConnectionHandlesCanBeGenerated)
-{
- test::components::TransportManager::HandleGeneratorsTest::TestTransportManager tm;
- NsSmartDeviceLink::NsTransportManager::tConnectionHandle handle;
-
- for (int i = 0; i < 10000; i++)
- {
- handle = tm.generateNewConnectionHandle();
- ASSERT_NE(handle, NsSmartDeviceLink::NsTransportManager::InvalidConnectionHandle);
- }
-}
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/ListenersTest.cpp b/test/components/transport_manager/ListenersTest.cpp
deleted file mode 100644
index 4b9078203..000000000
--- a/test/components/transport_manager/ListenersTest.cpp
+++ /dev/null
@@ -1,236 +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.
-//
-
-/*
- Tests correct registration/removal of various TransportManager listeners.
- - tests that all registered device listeners received callbacks
- - tests that all registered data listeners received callbacks
- - tests that not registered device listeners was not received callbacks
- - tests that not registered data listeners was not received callbacks
- - tests that registered and then removed device listeners was not received callbacks
- - tests that registered and then removed data listeners was not received callbacks
- */
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-#include "TransportManager/ITransportManagerDataListener.hpp"
-#include "TransportManager/ITransportManagerDeviceListener.hpp"
-
-using ::testing::_;
-
-namespace test
-{
- namespace components
- {
- namespace TransportManager
- {
- namespace ListenersTest
- {
-
- /**
- * @brief Class to check data listener callbacks calling
- **/
- class MockDataListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener
- {
- public:
- //MOCK_METHOD2(onFrameReceived, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, const Blob & Data));
- MOCK_METHOD3(onFrameSendCompleted, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, int FrameSequenceNumber, NsSmartDeviceLink::NsTransportManager::ESendStatus SendStatus));
- };
-
- /**
- * @brief Class to check device listener callbacks calling
- **/
- class MockDeviceListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener
- {
- public:
- MOCK_METHOD1(onDeviceListUpdated, void(const NsSmartDeviceLink::NsTransportManager::tDeviceList & DeviceList));
- MOCK_METHOD2(onApplicationConnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & ConnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
- MOCK_METHOD2(onApplicationDisconnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & DisconnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
- };
-
- class TestTransportManager: public NsSmartDeviceLink::NsTransportManager::CTransportManager
- {
- public:
- void run()
- {
- // Preventing parent function processing.
- // Does not needed inside this test.
- }
-
- void test()
- {
- //Calling callbacks on all listeners
-
- NsSmartDeviceLink::NsTransportManager::tConnectionHandle dummyConnectionHandle = 1;
- std::vector<NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener*>::const_iterator dataListenersIterator;
-
- for (dataListenersIterator = mDataListeners.begin(); dataListenersIterator != mDataListeners.end(); ++dataListenersIterator)
- {
- (*dataListenersIterator)->onFrameSendCompleted(dummyConnectionHandle, 0, NsSmartDeviceLink::NsTransportManager::SendStatusOK);
- }
-
- NsSmartDeviceLink::NsTransportManager::SDeviceInfo dummyDeviceInfo;
- std::vector<NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener*>::const_iterator deviceListenersIterator;
-
- for (deviceListenersIterator = mDeviceListeners.begin(); deviceListenersIterator != mDeviceListeners.end(); ++deviceListenersIterator)
- {
- (*deviceListenersIterator)->onApplicationConnected(dummyDeviceInfo, NsSmartDeviceLink::NsTransportManager::InvalidConnectionHandle);
- }
- }
- };
- }
- }
- }
-}
-
-TEST(test_TransportManagerListeners, allRegisteredDataListenersCalled)
-{
- test::components::TransportManager::ListenersTest::MockDataListener mockDataListener1;
- test::components::TransportManager::ListenersTest::MockDataListener mockDataListener2;
-
- EXPECT_CALL(mockDataListener1, onFrameSendCompleted(_, _, _))
- .Times(1)
- ;
-
- EXPECT_CALL(mockDataListener2, onFrameSendCompleted(_, _, _))
- .Times(1)
- ;
-
- test::components::TransportManager::ListenersTest::TestTransportManager tm;
- tm.addDataListener(&mockDataListener1);
- tm.addDataListener(&mockDataListener2);
-
- tm.test();
-}
-
-TEST(test_TransportManagerListeners, allRegisteredDeviceListenersCalled)
-{
- test::components::TransportManager::ListenersTest::MockDeviceListener mockDeviceListener1;
- test::components::TransportManager::ListenersTest::MockDeviceListener mockDeviceListener2;
-
- EXPECT_CALL(mockDeviceListener1, onApplicationConnected(_, _))
- .Times(1)
- ;
-
- EXPECT_CALL(mockDeviceListener2, onApplicationConnected(_, _))
- .Times(1)
- ;
-
- test::components::TransportManager::ListenersTest::TestTransportManager tm;
- tm.addDeviceListener(&mockDeviceListener1);
- tm.addDeviceListener(&mockDeviceListener2);
-
- tm.test();
-}
-
-TEST(test_TransportManagerListeners, notRegisteredDataListenersAreNotCalled)
-{
- test::components::TransportManager::ListenersTest::MockDataListener mockDataListener1;
- test::components::TransportManager::ListenersTest::MockDataListener mockDataListener2;
-
- EXPECT_CALL(mockDataListener1, onFrameSendCompleted(_, _, _))
- .Times(0)
- ;
-
- EXPECT_CALL(mockDataListener2, onFrameSendCompleted(_, _, _))
- .Times(0)
- ;
-
- test::components::TransportManager::ListenersTest::TestTransportManager tm;
- tm.test();
-}
-
-TEST(test_TransportManagerListeners, notRegisteredDeviceListenersAreNotCalled)
-{
- test::components::TransportManager::ListenersTest::MockDeviceListener mockDeviceListener1;
- test::components::TransportManager::ListenersTest::MockDeviceListener mockDeviceListener2;
-
- EXPECT_CALL(mockDeviceListener1, onApplicationConnected(_, _))
- .Times(0)
- ;
-
- EXPECT_CALL(mockDeviceListener2, onApplicationConnected(_, _))
- .Times(0)
- ;
-
- test::components::TransportManager::ListenersTest::TestTransportManager tm;
- tm.test();
-}
-
-TEST(test_TransportManagerListeners, dataListenersCanBeRemoved)
-{
- test::components::TransportManager::ListenersTest::MockDataListener mockDataListener1;
- test::components::TransportManager::ListenersTest::MockDataListener mockDataListener2;
-
- EXPECT_CALL(mockDataListener1, onFrameSendCompleted(_, _, _))
- .Times(1)
- ;
-
- EXPECT_CALL(mockDataListener2, onFrameSendCompleted(_, _, _))
- .Times(0)
- ;
-
- test::components::TransportManager::ListenersTest::TestTransportManager tm;
- tm.addDataListener(&mockDataListener1);
- tm.addDataListener(&mockDataListener2);
- tm.removeDataListener(&mockDataListener2);
-
- tm.test();
-}
-
-TEST(test_TransportManagerListeners, deviceListenersCanBeRemoved)
-{
- test::components::TransportManager::ListenersTest::MockDeviceListener mockDeviceListener1;
- test::components::TransportManager::ListenersTest::MockDeviceListener mockDeviceListener2;
-
- EXPECT_CALL(mockDeviceListener1, onApplicationConnected(_, _))
- .Times(1)
- ;
-
- EXPECT_CALL(mockDeviceListener2, onApplicationConnected(_, _))
- .Times(0)
- ;
-
- test::components::TransportManager::ListenersTest::TestTransportManager tm;
- tm.addDeviceListener(&mockDeviceListener1);
- tm.addDeviceListener(&mockDeviceListener2);
- tm.removeDeviceListener(&mockDeviceListener2);
-
- tm.test();
-}
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/TcpSimulator.cpp b/test/components/transport_manager/TcpSimulator.cpp
deleted file mode 100644
index e95bf8211..000000000
--- a/test/components/transport_manager/TcpSimulator.cpp
+++ /dev/null
@@ -1,862 +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.
-//
-
-/*
- Test application that connects to the Transport Manager using TCP and sends predefined data.
- There are two possible usages of application:
- - Size of data to be sent is provided. Application generates correct packets and sents them.
- - Path to file with commands is provided. Application generates correct packets for each command
- and send it
- */
-#include <iostream>
-#include <string>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdint.h>
-#include <getopt.h>
-#include <fstream>
-
-
-// -------------------------------------------------------------------------
-
-/**
- * @brief Confituration of the application
- */
-struct Config
-{
- std::string ipAddress;
- int port;
- int protocolVersion;
- uint32_t actualDataSize;
- uint32_t reportedDataSize;
- std::string fileName;
- bool bulk;
-};
-
-
-
-/**
- *
- * @brief The common part of the header for both protocol versions
- */
-struct PacketHeaderBase
-{
- uint8_t frameType:3;
- bool compressionFlag:1;
- uint8_t version:4;
- uint8_t serviceType;
- uint8_t frameData;
- uint8_t sessionId;
- uint32_t dataSize;
-};
-
-/**
- * @brief The header of the protocol version 1
- */
-struct PacketHeaderV1
-{
- PacketHeaderBase base;
-
- bool isValidVersion() const { return (base.version == 0x01); }
-
- // no additional fields
-};
-
-/**
- * @brief The header of the protocol version 2
- */
-struct PacketHeaderV2
-{
- PacketHeaderBase base;
-
- uint32_t messageId;
-
- bool isValidVersion() const { return (base.version == 0x02); }
-};
-
-// -------------------------------------------------------------------------
-/**
- * @brief Default config values
- */
-const Config DefaultConfigValues =
-{
- std::string("127.0.0.1"), // Default IP address
- 12345, // Default TCP port
- 2, // Default protocol version
- 32, // Default actual data size
- 32, // Default reported data size
- std::string(""), // Default file name (no default)
- false // Default bulk
-};
-
-// -------------------------------------------------------------------------
-
-
-
-
-
-/**
- * @brief The class incapsulates connection routines to the TCP socket of the Transport Manager
- */
-class CTranspMgrTcpClient
-{
-public:
-
- /**
- * @brief CTranspMgrTcpClient receives all necesary parameters via this constructor
- *
- * @param ipAddress The IP address of the host where Transport Manager is running
- * @param port The TCP port of Transport Manager
- */
- CTranspMgrTcpClient(const std::string ipAddress, const int port);
-
- /**
- * @brief Destructor closes the socket if necessary
- */
- ~CTranspMgrTcpClient();
-
- /**
- * @brief Tries to Establish TCP connection to the Transport Manager
- */
- void Connect();
-
- /**
- * @brief Closes the socket (if it was opened before)
- */
- void Disconnect();
-
- /**
- * @brief Sends data packet to the Transport Manager
- *
- * @brief pData Pointer to the data to send
- * @brief dataSize Size of the buffer to send
- */
- void Send(const void *pData, size_t dataSize);
-
- /**
- * @brief check if socket connected
- * @return if socket conncted, TRUE; otherwise FALSE
- */
- inline bool isConnected() { return mIsConencted; }
-
-private:
- int mPort;
- std::string mIpAddress;
- bool mIsConencted;
-
- int mSocketFd; // socket file descriptor
-};
-
-// ----------------------------------------------------------------------------
-
-CTranspMgrTcpClient::CTranspMgrTcpClient(const std::string ipAddress, const int port)
- : mPort(port)
- , mIpAddress(ipAddress)
- , mIsConencted(false)
- , mSocketFd(-1)
-{
-}
-
-// ----------------------------------------------------------------------------
-
-CTranspMgrTcpClient::~CTranspMgrTcpClient()
-{
- if (mSocketFd != -1)
- {
- close(mSocketFd);
- }
-}
-
-// ----------------------------------------------------------------------------
-
-void CTranspMgrTcpClient::Connect()
-{
- struct hostent *server;
- struct sockaddr_in serverAddr;
-
- mSocketFd = socket(AF_INET, SOCK_STREAM, 0);
- if (mSocketFd < 0)
- {
- throw new std::string("Error opening socket\n");
- }
-
- server = gethostbyname(mIpAddress.c_str());
- if (server == NULL)
- {
- throw new std::string("Error, no such host\n");
- }
-
- bzero( (char*) &serverAddr, sizeof(serverAddr) );
- serverAddr.sin_family = AF_INET;
- bcopy((char*)server->h_addr, (char*)&serverAddr.sin_addr.s_addr, server->h_length);
- serverAddr.sin_port = htons(mPort);
-
- if (::Connect(mSocketFd, (struct sockaddr*)&serverAddr, sizeof(serverAddr)) < 0)
- {
- //throw new std::string("Error connecting\n");
- printf("\n WARNING: No TCP connection\n");
- mIsConencted = false;
- }
- mIsConencted = true;
-}
-
-// ----------------------------------------------------------------------------
-
-void CTranspMgrTcpClient::Disconnect()
-{
- close(mSocketFd);
-
- mSocketFd = -1;
-}
-
-// ----------------------------------------------------------------------------
-
-void CTranspMgrTcpClient::Send(const void* pData, size_t dataSize)
-{
- if (pData != NULL)
- {
- ssize_t written = write(mSocketFd, pData, dataSize);
-
- if (written == -1)
- {
- throw new std::string("Error writing into the socket");
- }
- if (written != dataSize)
- {
- std::cout << "Warning: expected to send " << dataSize <<
- " bytes, but sent " << written << " bytes\n";
- }
- }
-}
-
-/**
- * function prototype. servicetype - is deafult value method.
- *
- */
-static void makePacketHeader(size_t version, PacketHeaderV1 *& phv1, PacketHeaderV2 *& phv2, int8_t servicetype, int8_t sessionId);
-
-/**
- * @brief class providing paylod data for testing of smartDeviceLinkCore via TCP(WiFi) link
- *
- */
-class CAppTester
-{
-private:
- PacketHeaderV1* mPacketheaderV1;
- PacketHeaderV2* mPacketheaderV2;
- CTranspMgrTcpClient& mTCPClient;
-
-
-public:
-
- static uint8_t INVALID_PROTOCOL_VERSION;
- /**
- * Default constructor
- */
- CAppTester(PacketHeaderV2 *hV2, PacketHeaderV1 *hV1, CTranspMgrTcpClient& tcplCient)
- : mPacketheaderV1(hV1)
- , mPacketheaderV2(hV2)
- , mTCPClient(tcplCient)
- {}
-
-private:
-
- /**
- *
- * @brief got protocol version
- */
- uint8_t getProtocolVersion()
- {
- uint8_t protocolVersion = INVALID_PROTOCOL_VERSION; // invalid value
- if (mPacketheaderV2) protocolVersion = 0x02;
- else if (mPacketheaderV1) protocolVersion = 0x01;
- return protocolVersion;
- }
-
-
-public:
- /**
- * @brief startSession
- */
- void startSession(bool bIsBulk)
- {
- printf("\n%s:%d CAppTester::startSession()\n", __FILE__, __LINE__);
-
- uint8_t protocolVersion = getProtocolVersion();
- if (protocolVersion == INVALID_PROTOCOL_VERSION)
- {
- return;
- }
-
- printf("Start session (RPC Service) version = %d\n", protocolVersion);
-
-
- PacketHeaderV1* phv1;
- PacketHeaderV2* phv2;
- makePacketHeader(protocolVersion, phv1, phv2, 0x07/*service type*/, 0 /*session id*/);
-
- if (protocolVersion == 0x01)
- {
- SendData(phv1, sizeof(PacketHeaderV1));
- if (phv1) free(phv1);
- }
- else if (protocolVersion == 0x02)
- {
- SendData(phv2, sizeof(PacketHeaderV2));
- if (phv2) free(phv2);
- }
-
-
-
-
- if (bIsBulk)
- {
- printf("Start session (Bulk Service)\n");
-
- makePacketHeader(protocolVersion, phv1, phv2, 0x0f, 0);
-
- if (protocolVersion == 0x01)
- {
- SendData(phv1, sizeof(PacketHeaderV1));
- if (phv1) free(phv1);
- }
- else if (protocolVersion == 0x02)
- {
- SendData(phv2, sizeof(PacketHeaderV2));
- if (phv2) free(phv2);
- }
- }
-
- }
-
- /**
- * \brief Sends data from file to smartDeviceLinkCore
- * \param fileName name of file with json messages
- * \return Error code (-1 in case of any errors)
- */
- // -------------------------------------------------------------------------
- int sendDataFromFile(const char * fileName)
- // -------------------------------------------------------------------------
- {
- using namespace std;
- printf("%s:%d CAppTester::sendDataFromFile()\n", __FILE__, __LINE__);
-
- ifstream file_str;
- file_str.open (fileName);
-
- if (!file_str.is_open())
- {
- printf("File wasn't opened!\n");
- return -1;
- }
-
- int startpos = 0;
- file_str.seekg(0, ios::end);
- int length = file_str.tellg();
- file_str.seekg(0, ios::beg);
- printf("length = %d \n", length);
- while (startpos < length)
- {
- char * raw_data = new char[length];
- file_str.getline(raw_data, length);
- printf("strlen = %ld \n", strlen(raw_data));
- startpos += strlen(raw_data)+1;
- std::string instr = std::string(raw_data, strlen(raw_data));
- delete[] raw_data;
- printf("Input string:\n %s\n", instr.c_str());
-
- void* packet2Send = 0;
- int32_t packet2SendLength = 0;
- packet2SendLength = generateSingleMessage(mPacketheaderV2, mPacketheaderV1, instr, packet2Send);
- SendData(packet2Send, packet2SendLength);
- if (packet2Send) free (packet2Send);
-
- printf("packet2SendLength = %d \n", packet2SendLength);
- printf("packet2Send = %p \n", packet2Send);
- }
- file_str.close();
- return 0;
- }
-
-
-private:
-
- /**
- * @brief send data (over tcp)
- *
- * @param data data to send
- * @param length data length
- *
- */
- // -------------------------------------------------------------------------
- void SendData(const void *const data, const int length)
- // -------------------------------------------------------------------------
- {
- if ((length > 0) && data != 0)
- {
- if (length >= 3)
- printf("SendData. length = %d, [0]=0x%.2x, [1]=0x%02.2x, [2]==0x%2.2x\n", length, *((const char *const)data), *((const char *const)data+1), *((const char *const)data+2));
- if (mTCPClient.isConnected() == false)
- {
- mTCPClient.Connect();
- }
- mTCPClient.Send(data, length);
- }
- else
- {
- printf("\n CAppTester::SendData error: no data to send\n");
- }
- }
-
-private:
- /**
- * @brief generate single message (i.e. frameType will be forcible set to 0x1 Single Frame in PacketHeader)
- *
- * If both parameters are not 0, mesage will be generated for first parameter hv2
- * @note returned packet should be freed by invoker
- *
- * @param hv2 packet header pf protocol version 2. If value is 0, ignored
- * @param hv1 packet header pf protocol version 1. If value is 0, ignored
- * @param payload payload data
- * @param resultData generated data
- * @return length of generated packet
- */
- // -------------------------------------------------------------------------
- int32_t generateSingleMessage(const PacketHeaderV2 *hV2, const PacketHeaderV1 *hV1, const std::string payload, void *& resultData)
- // -------------------------------------------------------------------------
- {
- if (hV2 == 0 && hV1 == 0)
- {
- printf("\n CAppTester::generateSingleMessage() error: null input parameters");
- return 0;
- }
-
- uint8_t protocolVersion = (hV2 != 0 ? 0x02 : 0x01);
- if ((protocolVersion == 0x02) && (hV2->isValidVersion() == false))
- {
- printf("\n generateSingleMessage() error. Incorrect version of PacketHeaderV2");
- return 0;
- }
- if ((protocolVersion == 0x01) && (hV1->isValidVersion() == false))
- {
- printf("\n generateSingleMessage() error. Incorrect version of PacketHeaderV1");
- return 0;
- }
-
- PacketHeaderBase phb = ( (hV2 !=0 ) ? hV2->base : hV1->base );
-
- uint32_t headerSize = 8;
- if (protocolVersion == 0x02)
- headerSize = 12;
-
- uint8_t sVersion = protocolVersion;
- uint8_t sCompressedFlag = phb.compressionFlag;
- uint8_t sFrameType = 0x01; //Single is set forcible over phb.frameType for this method
- uint8_t sServiceType = phb.serviceType;
- uint8_t sFrameData = phb.frameData;
- uint8_t sSessionID = phb.sessionId;
- uint32_t sDataSize = payload.length();//' + 1; //
- uint32_t sMessageID = (protocolVersion == 0x02 ? hV2->messageId : 12345);
-
- void* sPacketData = malloc(headerSize + sDataSize);
-
- uint8_t firstByte = ( (sVersion << 4) & 0xF0 )
- | ( (sCompressedFlag << 3) & 0x08)
- | (sFrameType & 0x07);
-
- uint32_t offset = 0;
- memcpy((uint8_t*)sPacketData + offset++, &firstByte, 1);
- memcpy((uint8_t*)sPacketData + offset++, &sServiceType, 1);
- memcpy((uint8_t*)sPacketData + offset++, &sFrameData, 1);
- memcpy((uint8_t*)sPacketData + offset++, &sSessionID, 1);
-
- uint8_t tmp = sDataSize >> 24;
- memcpy((uint8_t*)sPacketData + offset++, &tmp, 1);
- tmp = sDataSize >> 16;
- memcpy((uint8_t*)sPacketData + offset++, &tmp, 1);
- tmp = sDataSize >> 8;
- memcpy((uint8_t*)sPacketData + offset++, &tmp, 1);
- tmp = sDataSize;
- memcpy((uint8_t*)sPacketData + offset++, &tmp, 1);
-
-
- if (protocolVersion == 0x02)
- {
- uint8_t tmp1 = sMessageID >> 24;
- memcpy((uint8_t*)sPacketData + offset++, &tmp1, 1);
- tmp1 = sMessageID >> 16;
- memcpy((uint8_t*)sPacketData + offset++, &tmp1, 1);
- tmp1 = sMessageID >> 8;
- memcpy((uint8_t*)sPacketData + offset++, &tmp1, 1);
- tmp1 = sMessageID;
- memcpy((uint8_t*)sPacketData + offset++, &tmp1, 1);
- }
-
- memcpy((uint8_t*)sPacketData + offset, (void*)const_cast<char*>(payload.c_str()), sDataSize);
-
- resultData = sPacketData;
- printf("SINGLE MESSAGE GENERATED!\n");
-
- return (headerSize + sDataSize);
- }
-};
-
-uint8_t CAppTester::INVALID_PROTOCOL_VERSION = 0xff;
-
-// -------------------------------------------------------------------------
-
-static void printUsage(const std::string &programName)
-{
- std::cout << "Usage: " << programName << " [OPTION]" << std::endl;
- std::cout << "Send test packet to the TransportManager in order to test TCP Adapter" << std::endl;
- std::cout << std::endl;
- std::cout << "-i, --ip IP_ADDRESS IP address where to send the packet (Default: "
- << DefaultConfigValues.ipAddress << ")" << std::endl;
-
- std::cout << "-p, --port PORT_NUMBER TCP port number (Default: "
- << DefaultConfigValues.port << ")" << std::endl;
-
- std::cout << "-v, --version [1 | 2] Protocol version. (Default: "
- << DefaultConfigValues.protocolVersion << ")" << std::endl;
-
- std::cout << "-a, --actual-size SIZE The real size of the data in the packet to send (Default: "
- << DefaultConfigValues.actualDataSize << ")" << std::endl;
-
- std::cout << "-r, --reported-size SIZE The size of the packet which is written in the packet header (Default: "
- << DefaultConfigValues.reportedDataSize << ")" << std::endl;
-
- std::cout << "-f, --file FILE The name of the file whose content to be sent over TCP (if option is set '--actual-size' and '--reported-size' are ignored)"
- << std::endl;
-
- std::cout << "-b, --bulk Is bulk data"
- << std::endl;
-
- std::cout << "-h, --help Print this help" << std::endl << std::endl;
-}
-
-// -------------------------------------------------------------------------
-
-static bool initConfig(int argc, char **argv, Config *pConfig)
-{
- bool result = true;
-
- struct option long_options[] =
- {
- {"help", no_argument, 0, 'h'},
- {"ip", required_argument, 0, 'i'},
- {"port", required_argument, 0, 'p'},
- {"version", required_argument, 0, 'v'},
- {"actual-size", required_argument, 0, 'a'},
- {"reported-size", required_argument, 0, 'r'},
- {"file", required_argument, 0, 'f'},
- {"bulk", required_argument, 0, 'b'},
- {0, 0, 0, 0}
- };
-
- *pConfig = DefaultConfigValues;
-
-
- while (true)
- {
- int option_index = 0;
- int c;
-
- c = getopt_long(argc, argv, "hi:p:v:a:r:f:b:", long_options, &option_index);
-
- if (c == -1)
- break;
-
- switch (c)
- {
- case 'i':
- if (optarg)
- {
- // Todo: parse this string for valid IP address
- pConfig->ipAddress = optarg;
- }
- else
- {
- std::cout << "Error: IP address is missing" << std::endl;
- result = false;
- }
- break;
-
- case 'p':
- if (optarg)
- {
- pConfig->port = atoi(optarg);
- }
- else
- {
- std::cout << "Error: port is missing" << std::endl;
- result = false;
- }
- break;
-
- case 'v':
- if (optarg)
- {
- pConfig->protocolVersion = atoi(optarg);
- }
- else
- {
- std::cout << "Default protocol version is" << DefaultConfigValues.protocolVersion << std::endl;
- }
- break;
-
- case 'a':
- if (optarg)
- {
- pConfig->actualDataSize = atoi(optarg);
- }
- else
- {
- std::cout << "Error: data size is missing" << std::endl;
- result = false;
- }
- break;
-
- case 'r':
- if (optarg)
- {
- pConfig->reportedDataSize = atoi(optarg);
- }
- else
- {
- std::cout << "Error: data size is missing" << std::endl;
- result = false;
- }
- break;
-
- case 'f':
- if (optarg)
- {
- pConfig->fileName = optarg;
- }
- else
- {
- std::cout << "Error: file name is missing" << std::endl;
- result = false;
- }
- break;
- case 'b':
- if (optarg)
- {
- int val = atoi(optarg);
- pConfig->bulk = (val == 0 ? false : true);
- }
- else
- {
- std::cout << "Error: bulk is missing" << std::endl;
- result = false;
- }
- break;
-
- default:
- result = false;
- }
- }
-
- if (result == false)
- {
- printUsage(argv[0]);
- }
-
- return result;
-}
-
-// -------------------------------------------------------------------------
-
-static uint32_t uint32ToNetOrder(const uint32_t value)
-{
- uint32_t result = 0;
-
- result |= (value & 0x000000FF) << 24;
- result |= (value & 0x0000FF00) << 8;
- result |= (value & 0x00FF0000) >> 8;
- result |= (value & 0xFF000000) >> 24;
-
- return result;
-}
-
-// -------------------------------------------------------------------------
-
-static uint8_t* makePacket(const Config &config, int &packetSize)
-{
- uint8_t *pBuff = 0;
- PacketHeaderBase *pBase;
- size_t headerSize;
-
- if (config.protocolVersion == 1)
- {
- headerSize = sizeof(PacketHeaderV1);
- }
- else if (config.protocolVersion == 2)
- {
- headerSize = sizeof(PacketHeaderV2);
- }
- else
- {
- throw new std::string("Unsupported protocol version");
- }
-
- packetSize = headerSize + config.actualDataSize;
-
- pBuff = new uint8_t[packetSize];
- pBase = (PacketHeaderBase*)pBuff;
-
- pBase->version = config.protocolVersion;
- pBase->compressionFlag = false;
- pBase->frameType = 1;
- pBase->serviceType = 0x0F;
- pBase->frameData = 0;
- pBase->sessionId = 0;
- pBase->dataSize = uint32ToNetOrder(config.reportedDataSize); // convert data size to network order
-
- if (config.protocolVersion == 2)
- {
- PacketHeaderV2 *pHeader = (PacketHeaderV2*)pBuff;
-
- pHeader->messageId = 0;
- }
-
- // just fill the data with the single value
- memset(&(pBuff[headerSize]), 0xFF, config.actualDataSize);
-
- return pBuff;
-}
-
-
-static void makePacketHeader(size_t version, PacketHeaderV1 *& phv1, PacketHeaderV2 *& phv2, int8_t servicetype = 0x07, int8_t sessionId = 1)
-{
- uint8_t *pBuff = 0;
- PacketHeaderBase *pBase;
- size_t headerSize;
-
- phv1 = 0; phv2 = 0;
-
- if (version == 1)
- {
- headerSize = sizeof(PacketHeaderV1);
- }
- else if (version == 2)
- {
- headerSize = sizeof(PacketHeaderV2);
- }
- else
- {
- throw new std::string("Unsupported protocol version");
- }
-
- pBuff = new uint8_t[headerSize];
- pBase = (PacketHeaderBase*)pBuff;
-
- pBase->version = version;
- pBase->compressionFlag = false;
- pBase->frameType = 0;
- pBase->serviceType = servicetype;
- pBase->frameData = 1;
- pBase->sessionId = sessionId;
-
- if (version == 2)
- {
- PacketHeaderV2 *pHeader = (PacketHeaderV2*)pBuff;
-
- pHeader->messageId = 0;
-
- phv2 = pHeader;
- }
- else
- {
- phv1 = (PacketHeaderV1*)pBuff;
- }
-
-}
-
-// ----------------------------------------------------------------------------
-
-int main(int argc, char **argv)
-{
- Config config;
- uint8_t *pBuff = 0;
- int buffSize;
-
- if (initConfig(argc, argv, &config) == false)
- {
- return 0; // can't continue, do not have enough configuration data
- }
-
- CTranspMgrTcpClient client(config.ipAddress, config.port);
-
- if (config.fileName.empty())
- {
- try
- {
- pBuff = makePacket(config, /*out*/buffSize);
-
- client.Connect();
-
- client.Send(pBuff, buffSize);
-
- std::cout << "The packet has been sent successfully" << std::endl;
- }
- catch (std::string *pError)
- {
- std::cout << *pError << std::endl;
- }
- delete pBuff;
- }
- else
- {
- PacketHeaderV1* phv1;
- PacketHeaderV2* phv2;
-
- makePacketHeader(config.protocolVersion, phv1, phv2);
-
- CAppTester appTester(phv2, phv1, client);
- appTester.startSession(config.bulk);
- appTester.sendDataFromFile(config.fileName.c_str());
- }
-
-
-
- client.Disconnect();
-
- return 0;
-}
-
-
diff --git a/test/components/transport_manager/TransportManagerTestWithCorrectDeviceAdapter.cpp b/test/components/transport_manager/TransportManagerTestWithCorrectDeviceAdapter.cpp
deleted file mode 100644
index 07f0ae64a..000000000
--- a/test/components/transport_manager/TransportManagerTestWithCorrectDeviceAdapter.cpp
+++ /dev/null
@@ -1,406 +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.
-//
-
-/*
- Tests transport manager functionality with single device adapter that behaves correctly and single client
- Following sequence is tested:
- - TM created and runned
- - TM client registered as listener
- - TM client requests device scaning
- - single device was returned to TM client with onDeviceListUpdated callback
- - TM client calls "connect" on found device
- - device adapter sends onApplicationConnected
- - TM client receives onApplicationConnected
- - device adapter sends three data parts that represents single frame
- - TM client receives single frame with onFrameReceived callback
- - TM client calls sendFrame with some frame data and user data
- - TM client receives onFrameSendCompleted
- - TM client calls disconnectDevice
- - TM client receives onApplicationDisconnected
- */
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "../../../src/components/TransportManager/src/ITransportAdapter.hpp"
-#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-#include "TransportManager/ITransportManagerDataListener.hpp"
-#include "TransportManager/ITransportManagerDeviceListener.hpp"
-
-#include <stddef.h>
-#include <stdio.h>
-
-using ::testing::_;
-using ::testing::Invoke;
-using ::testing::StrEq;
-using ::testing::Property;
-using ::testing::Field;
-using ::testing::Contains;
-using ::testing::AllOf;
-using ::testing::ElementsAre;
-using ::testing::ContainerEq;
-using ::testing::Eq;
-using ::testing::InSequence;
-
-using namespace NsSmartDeviceLink::NsTransportManager;
-
-namespace test { namespace components { namespace TransportManager { namespace TestWithCorrectTransportAdapter {
-
- // ---------------- TEST DATA ---------------- //
- namespace Data
- {
- static const tDeviceHandle DeviceHandle = 123;
- static const EDeviceType DeviceType = DeviceBluetooth;
- static const std::string UserFriendlyName("MY USER FRIENDLY NAME");
- static const std::string UniqueDeviceId("MY_UNIQUE_DEVICE_ID");
-
- static const tConnectionHandle ConnectionHandle = 666;
-
- static const int UserData = 123;
- }
-
- // ---------------- TEST CLASSES ---------------- //
-
- /**
- * @brief Class that represents custom device adapter that will send known data
- * and check it's methods calls
- **/
- class MockTransportAdapter : public ITransportAdapter
- {
- public:
- MockTransportAdapter(ITransportAdapterListener & Listener, IHandleGenerator & HandleGenerator)
- : mListener(Listener)
- , mHandleGenerator(HandleGenerator)
- , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
- {
- }
-
- virtual EDeviceType GetDeviceType(void ) const
- {
- return DeviceBluetooth;
- }
- MOCK_METHOD1(connectDevice, void (const tDeviceHandle DeviceHandle));
- MOCK_METHOD1(disconnectDevice, void (const tDeviceHandle DeviceHandle));
- MOCK_METHOD0(run, void());
- MOCK_METHOD0(scanForNewDevices, void());
- MOCK_METHOD4(sendFrame, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, int UserData));
-
- void doScanForNewDevices()
- {
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- Scanning new devices -----------------");
- SInternalDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- tInternalDeviceList list;
- list.push_back(deviceInfo);
-
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending device list update -----------------");
- mListener.onDeviceListUpdated(this, list);
- }
-
- void doConnectDevice(const tDeviceHandle DeviceHandle)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- Connecting device -----------------");
- // Application connect
-
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending ApplicationConnected -----------------");
- mListener.onApplicationConnected(this, deviceInfo, Data::ConnectionHandle);
-
- // Send three frames to transport manager
-
- uint8_t raw_data[] = {
- 0x22, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8,
- 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF
- };
-
- // Sending only header first
- uint8_t *pSendBuff = raw_data;
-
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #1 -----------------");
- mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, 12);
-
- // Sending first part of the data
- pSendBuff+=12;
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #2 -----------------");
- mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
-
- // Sending last part of the data
- pSendBuff+=100;
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #3 -----------------");
- mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
- }
-
- void doSendFrame(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, const int UserData)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- doSendFrame called. Sending FrameSendCompleted -----------------");
- mListener.onFrameSendCompleted(this, Data::ConnectionHandle, Data::UserData, SendStatusOK);
- }
-
- void doDisconnectDevice(const tDeviceHandle DeviceHandle)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- doDisconnectDevice -----------------");
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- sending ApplicationDisconnected -----------------");
- mListener.onApplicationDisconnected(this, deviceInfo, Data::ConnectionHandle);
- }
-
- protected:
- ITransportAdapterListener & mListener;
- IHandleGenerator & mHandleGenerator;
- Logger mLogger;
- };
-
- /**
- * @brief Custom transport manager client that will check data, sent by transport manager
- **/
- class MockTransportManagerClient : public ITransportManagerDataListener
- , public ITransportManagerDeviceListener
- {
- public:
- MockTransportManagerClient(ITransportManager & TransportManager)
- : mTransportManager(TransportManager)
- , mDeviceList()
- , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
- {
-
- }
- MOCK_METHOD2(onApplicationConnected, void(const SDeviceInfo& ConnectedDevice, const tConnectionHandle Connection));
- MOCK_METHOD2(onApplicationDisconnected, void(const SDeviceInfo& DisconnectedDevice, const tConnectionHandle Connection));
- MOCK_METHOD1(onDeviceListUpdated, void(const tDeviceList& DeviceList));
- MOCK_METHOD3(onFrameReceived, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize));
- MOCK_METHOD3(onFrameSendCompleted, void(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus));
-
- void doDeviceListUpdated(const tDeviceList& DeviceList)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- doDeviceListUpdated -----------------");
- mDeviceList = DeviceList;
-
- tDeviceList::const_iterator device;
- for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
- {
- mTransportManager.connectDevice(device->mDeviceHandle);
- }
- }
-
- void doFrameReceived(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- doFrameReceived -----------------");
- // Sending frame
- uint8_t data[512]={1};
- mTransportManager.sendFrame(ConnectionHandle, data, 512, Data::UserData);
- }
-
- void doFrameSendCompleted(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "-------------- doFrameSendCompleted -----------------");
-
- tDeviceList::const_iterator device;
- for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
- {
- mTransportManager.disconnectDevice(device->mDeviceHandle);
- }
- }
-
- protected:
- ITransportManager & mTransportManager;
- tDeviceList mDeviceList;
- Logger mLogger;
- };
-
- /**
- * @brief Inherited transport manager class used for some small preparation of class for
- * testing (disabling another adapters etc.)
- **/
- class TestTransportManager : public CTransportManager
- {
- public:
- TestTransportManager(void )
- : CTransportManager()
- , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
- {
- }
-
- virtual ~TestTransportManager(void )
- {
-
- }
-
- virtual void initializeTransportAdapters()
- {
- // Preparing custom device adapter
- mpTransportAdapter = new MockTransportAdapter(*this, *this);
-
- EXPECT_CALL(*mpTransportAdapter, run()).Times(1);
- EXPECT_CALL(*mpTransportAdapter, scanForNewDevices())
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doScanForNewDevices))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, connectDevice(Data::DeviceHandle))
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doConnectDevice))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, sendFrame(Data::ConnectionHandle, _, 512, Data::UserData))
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doSendFrame))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, disconnectDevice(Data::DeviceHandle))
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doDisconnectDevice))
- ;
-
- addTransportAdapter(mpTransportAdapter);
- LOG4CPLUS_INFO_EXT(mLogger, "Transport adapters initialized");
- }
-
- protected:
- MockTransportAdapter *mpTransportAdapter;
- Logger mLogger;
- };
-
- // ----------------------- TESTS ----------------------- //
-
- TEST(test_TestWithCorrectTransportAdapter, CorrectTransportAdapterBehavior)
- {
- Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest"));
-
- LOG4CPLUS_INFO_EXT(logger, "*************************** Starting test *****************************");
- // All expectations must be sequenced
- //InSequence dummy;
-
- // Creating transport manager
- TestTransportManager *pTm = new TestTransportManager();
-
- // Preparing transport manage client
- MockTransportManagerClient tmClient(*pTm);
-
- // Expected device list
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
- tDeviceList deviceList;
- deviceList.push_back(deviceInfo);
-
- EXPECT_CALL(tmClient, onDeviceListUpdated(ContainerEq(deviceList)))
- .Times(1)
- .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doDeviceListUpdated))
- ;
-
- EXPECT_CALL(tmClient, onApplicationConnected(deviceInfo, Data::ConnectionHandle))
- .Times(1)
- ;
-
- EXPECT_CALL(tmClient, onFrameReceived(Data::ConnectionHandle, _, 212))
- .Times(1)
- .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doFrameReceived))
- ;
-
- EXPECT_CALL(tmClient, onFrameSendCompleted(Data::ConnectionHandle, Data::UserData, SendStatusOK))
- .Times(1)
- .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doFrameSendCompleted))
- ;
-
- EXPECT_CALL(tmClient, onApplicationDisconnected(deviceInfo, Data::ConnectionHandle))
- .Times(1)
- ;
-
-
-
- // Running test
-
- pTm->addDataListener(&tmClient);
- pTm->addDeviceListener(&tmClient);
-
- LOG4CPLUS_INFO_EXT(logger, "*************************** Calling RUN *****************************");
- pTm->run();
-
- sleep(1);
-
- LOG4CPLUS_INFO_EXT(logger, "*************************** Calling SCAN FOR DEVICES *****************************");
- pTm->scanForNewDevices();
-
- sleep(2);
-
- LOG4CPLUS_INFO_EXT(logger, "*************************** Deleting TM and shutting down *****************************");
-
- // Shutdown transport manager
- delete pTm;
- pTm = 0;
-
- }
-}}}} // End of namespaces
-
-
-
-int main(int argc, char **argv) {
- PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties"));
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/TransportManagerTestWithHighDataTransferRate.cpp b/test/components/transport_manager/TransportManagerTestWithHighDataTransferRate.cpp
deleted file mode 100644
index 6eb7ee660..000000000
--- a/test/components/transport_manager/TransportManagerTestWithHighDataTransferRate.cpp
+++ /dev/null
@@ -1,406 +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.
-//
-
-/*
- Tests huge amount of data tranfer through Transport Manager. Currently there are 10000 iterations, on each iteration
- data randomly sent from TM client to device or from device to TM client. Size of sent data is up to 1 MiB.
- Average amount of transfered data is 2.4 GiB
- */
-#define __STDC_FORMAT_MACROS
-
-#include <algorithm>
-#include <inttypes.h>
-#include <netinet/in.h>
-#include <pthread.h>
-#include <time.h>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "TransportManager/ITransportManagerDataListener.hpp"
-#include "TransportManager/ITransportManagerDeviceListener.hpp"
-#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-#include "../../../src/components/TransportManager/src/ITransportAdapter.hpp"
-
-namespace test
-{
- namespace components
- {
- namespace TransportManager
- {
- namespace HighDataTransferRate
- {
- class MockDataListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener
- {
- public:
- MockDataListener(pthread_mutex_t & Mutex);
-
- MOCK_METHOD3(onFrameReceived, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize));
- MOCK_METHOD3(onFrameSendCompleted, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, int FrameSequenceNumber, NsSmartDeviceLink::NsTransportManager::ESendStatus SendStatus));
-
- void unlockMutexAfterFrameReceived(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t);
- void unlockMutexAfterFrameSendCompleted(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, int, NsSmartDeviceLink::NsTransportManager::ESendStatus);
-
- private:
- pthread_mutex_t & mMutex;
- };
-
- class MockDeviceListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener
- {
- public:
- MockDeviceListener(pthread_mutex_t & Mutex);
-
- MOCK_METHOD1(onDeviceListUpdated, void(const NsSmartDeviceLink::NsTransportManager::tDeviceList & DeviceList));
- MOCK_METHOD2(onApplicationConnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & ConnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
- MOCK_METHOD2(onApplicationDisconnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & DisconnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
-
- void unlockMutexAfterDeviceListUpdate(const NsSmartDeviceLink::NsTransportManager::tDeviceList &);
- void unlockMutexAfterApplicationConnectedDisconnected(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo &, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle);
-
- private:
- pthread_mutex_t & mMutex;
- };
-
- class MockTransportAdapter: public NsSmartDeviceLink::NsTransportManager::ITransportAdapter
- {
- public:
- MockTransportAdapter(pthread_mutex_t & Mutex);
- virtual NsSmartDeviceLink::NsTransportManager::EDeviceType GetDeviceType(void) const;
-
- MOCK_METHOD1(connectDevice, void (const NsSmartDeviceLink::NsTransportManager::tDeviceHandle DeviceHandle));
- MOCK_METHOD1(disconnectDevice, void (const NsSmartDeviceLink::NsTransportManager::tDeviceHandle DeviceHandle));
- MOCK_METHOD0(run, void());
- MOCK_METHOD0(scanForNewDevices, void());
- MOCK_METHOD4(sendFrame, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize, int UserData));
-
- void unlockMutexAfterSendFrame(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t, int UserData);
-
- NsSmartDeviceLink::NsTransportManager::SDeviceInfo mMockDeviceInfo;
- NsSmartDeviceLink::NsTransportManager::tConnectionHandle mMockConnectionHandle;
-
- private:
- pthread_mutex_t & mMutex;
- };
-
- class TestTransportManager: public NsSmartDeviceLink::NsTransportManager::CTransportManager
- {
- public:
- TestTransportManager(test::components::TransportManager::HighDataTransferRate::MockTransportAdapter * TransportAdapter);
- ~TestTransportManager(void);
- protected:
- virtual void initializeTransportAdapters(void);
-
- private:
- MockTransportAdapter * mMockTransportAdapter;
- };
-
- std::string formatDataSize(const uint64_t DataSize);
- }
- }
- }
-}
-
-test::components::TransportManager::HighDataTransferRate::MockDataListener::MockDataListener(pthread_mutex_t & Mutex):
-mMutex(Mutex)
-{
-}
-
-void test::components::TransportManager::HighDataTransferRate::MockDataListener::unlockMutexAfterFrameReceived(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-void test::components::TransportManager::HighDataTransferRate::MockDataListener::unlockMutexAfterFrameSendCompleted(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, int, NsSmartDeviceLink::NsTransportManager::ESendStatus)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-test::components::TransportManager::HighDataTransferRate::MockDeviceListener::MockDeviceListener(pthread_mutex_t & Mutex):
-mMutex(Mutex)
-{
-}
-
-void test::components::TransportManager::HighDataTransferRate::MockDeviceListener::unlockMutexAfterDeviceListUpdate(const NsSmartDeviceLink::NsTransportManager::tDeviceList &)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-void test::components::TransportManager::HighDataTransferRate::MockDeviceListener::unlockMutexAfterApplicationConnectedDisconnected(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo &, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-test::components::TransportManager::HighDataTransferRate::MockTransportAdapter::MockTransportAdapter(pthread_mutex_t & Mutex):
-mMockDeviceInfo(),
-mMockConnectionHandle(NsSmartDeviceLink::NsTransportManager::InvalidConnectionHandle),
-mMutex(Mutex)
-{
- mMockDeviceInfo.mDeviceHandle = NsSmartDeviceLink::NsTransportManager::InvalidDeviceHandle;
- mMockDeviceInfo.mDeviceType = NsSmartDeviceLink::NsTransportManager::DeviceBluetooth;
-}
-
-NsSmartDeviceLink::NsTransportManager::EDeviceType test::components::TransportManager::HighDataTransferRate::MockTransportAdapter::GetDeviceType(void) const
-{
- return mMockDeviceInfo.mDeviceType;
-}
-
-void test::components::TransportManager::HighDataTransferRate::MockTransportAdapter::unlockMutexAfterSendFrame(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t, int UserData)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-test::components::TransportManager::HighDataTransferRate::TestTransportManager::TestTransportManager(test::components::TransportManager::HighDataTransferRate::MockTransportAdapter * TransportAdapter):
-CTransportManager(),
-mMockTransportAdapter(TransportAdapter)
-{
-}
-
-test::components::TransportManager::HighDataTransferRate::TestTransportManager::~TestTransportManager(void)
-{
-}
-
-void test::components::TransportManager::HighDataTransferRate::TestTransportManager::initializeTransportAdapters(void)
-{
- addTransportAdapter(mMockTransportAdapter);
-}
-
-MATCHER_P2(BuffersSame, buffer, size, "Matches two buffers contents")
-{
- bool result = false;
-
- if (size == std::tr1::get<1>(arg))
- {
- result = (0 == memcmp(buffer, std::tr1::get<0>(arg), size));
- }
-
- return result;
-}
-
-#define TRY_LOCK_AND_FAIL_ON_TIMEOUT(mutex) \
- { \
- timespec timeoutTime; \
- \
- clock_gettime(CLOCK_REALTIME, &timeoutTime); \
- timeoutTime.tv_sec += 1; \
- \
- if (0 != pthread_mutex_timedlock(&mutex, &timeoutTime)) \
- { \
- FAIL() << "Mutex lock timeout"; \
- } \
- }
-
-std::string test::components::TransportManager::HighDataTransferRate::formatDataSize(const uint64_t DataSize)
-{
- const uint64_t cKiB = 1024u;
- const uint64_t cMiB = cKiB * 1024u;
- const uint64_t cGiB = cMiB * 1024u;
- const uint64_t cTiB = cGiB * 1024u;
-
- std::stringstream s;
-
- s << std::fixed << std::setprecision(2);
-
- if (DataSize < cKiB)
- {
- s << DataSize << " B";
- }
- else if (DataSize < cMiB)
- {
- s << static_cast<double>(DataSize) / cKiB << " KiB";
- }
- else if (DataSize < cGiB)
- {
- s << static_cast<double>(DataSize) / cMiB << " MiB";
- }
- else if (DataSize < cTiB)
- {
- s << static_cast<double>(DataSize) / cGiB << " GiB";
- }
- else
- {
- s << static_cast<double>(DataSize) / cTiB << " TiB";
- }
-
- return s.str();
-}
-
-TEST(TransportManager, HighDataTransferRate)
-{
- pthread_mutex_t callbacksMutex;
-
- pthread_mutex_init(&callbacksMutex, 0);
-
- test::components::TransportManager::HighDataTransferRate::MockTransportAdapter * mockTransportAdapter = new test::components::TransportManager::HighDataTransferRate::MockTransportAdapter(callbacksMutex);
- test::components::TransportManager::HighDataTransferRate::MockDataListener mockDataListener(callbacksMutex);
- test::components::TransportManager::HighDataTransferRate::MockDeviceListener mockDeviceListener(callbacksMutex);
- test::components::TransportManager::HighDataTransferRate::TestTransportManager transportManager(mockTransportAdapter);
-
- EXPECT_CALL(*mockTransportAdapter, run()).Times(1);
-
- transportManager.run();
-
- transportManager.addDeviceListener(&mockDeviceListener);
- transportManager.addDataListener(&mockDataListener);
-
- NsSmartDeviceLink::NsTransportManager::tDeviceList deviceList;
-
- mockTransportAdapter->mMockDeviceInfo.mDeviceHandle = 1;
- mockTransportAdapter->mMockDeviceInfo.mUniqueDeviceId = std::string("id");
- mockTransportAdapter->mMockDeviceInfo.mUserFriendlyName = std::string("Name");
- deviceList.push_back(mockTransportAdapter->mMockDeviceInfo);
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(::testing::_)).Times(0);
- EXPECT_CALL(mockDeviceListener, onApplicationConnected(::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDeviceListener, onApplicationDisconnected(::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDataListener, onFrameReceived(::testing::_, ::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDataListener, onFrameSendCompleted(::testing::_, ::testing::_, ::testing::_)).Times(0);
-
- NsSmartDeviceLink::NsTransportManager::tInternalDeviceList internalDeviceList;
- internalDeviceList.push_back(NsSmartDeviceLink::NsTransportManager::SInternalDeviceInfo(mockTransportAdapter->mMockDeviceInfo.mDeviceHandle, mockTransportAdapter->mMockDeviceInfo.mUserFriendlyName, mockTransportAdapter->mMockDeviceInfo.mUniqueDeviceId));
-
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(::testing::ContainerEq(deviceList)))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDeviceListener, &test::components::TransportManager::HighDataTransferRate::MockDeviceListener::unlockMutexAfterDeviceListUpdate))
- .RetiresOnSaturation();
-
- transportManager.onDeviceListUpdated(mockTransportAdapter, internalDeviceList);
-
- mockTransportAdapter->mMockConnectionHandle = 1;
-
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDeviceListener, onApplicationConnected(mockTransportAdapter->mMockDeviceInfo, mockTransportAdapter->mMockConnectionHandle))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDeviceListener, &test::components::TransportManager::HighDataTransferRate::MockDeviceListener::unlockMutexAfterApplicationConnectedDisconnected))
- .RetiresOnSaturation();
-
- transportManager.onApplicationConnected(mockTransportAdapter, mockTransportAdapter->mMockDeviceInfo, mockTransportAdapter->mMockConnectionHandle);
-
- static const uint32_t cMaxFramePayloadSize = 1048576u;
-
- uint8_t * frameData = new uint8_t[cMaxFramePayloadSize + 8u];
- frameData[0] = 0x11;
- frameData[1] = 0x07;
- frameData[2] = 0x00;
- frameData[3] = 0x01;
-
- for (uint32_t b = 8u; b < cMaxFramePayloadSize + 8u; b += sizeof(int))
- {
- *((int*)&frameData[b]) = rand();
- }
-
- uint64_t bytesSent = 0u, bytesReceived = 0u;
-
- timespec dataTransferStartTime;
- clock_gettime(CLOCK_REALTIME, &dataTransferStartTime);
-
- for (int i = 0; i < 10000; ++i)
- {
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- uint32_t framePayloadSize = static_cast<uint32_t>(rand()) % cMaxFramePayloadSize;
- uint32_t frameSize = framePayloadSize + 8u;
- *((unsigned int*)(&frameData[4])) = htonl(framePayloadSize);
-
- if (0 == rand() % 2)
- {
- EXPECT_CALL(mockDataListener, onFrameReceived(mockTransportAdapter->mMockConnectionHandle, ::testing::_, ::testing::_))
- .With(::testing::Args<1, 2>(BuffersSame(frameData, frameSize)))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDataListener, &test::components::TransportManager::HighDataTransferRate::MockDataListener::unlockMutexAfterFrameReceived))
- .RetiresOnSaturation();
-
- transportManager.onFrameReceived(mockTransportAdapter, mockTransportAdapter->mMockConnectionHandle, frameData, frameSize);
-
- bytesReceived += frameSize;
- }
- else
- {
- int userData = 1234;
- EXPECT_CALL(*mockTransportAdapter, sendFrame(mockTransportAdapter->mMockConnectionHandle, ::testing::_, ::testing::_, userData))
- .With(::testing::Args<1, 2>(BuffersSame(frameData, frameSize)))
- .Times(1)
- .WillOnce(::testing::Invoke(mockTransportAdapter, &test::components::TransportManager::HighDataTransferRate::MockTransportAdapter::unlockMutexAfterSendFrame))
- .RetiresOnSaturation();
-
- transportManager.sendFrame(mockTransportAdapter->mMockConnectionHandle, frameData, frameSize, userData);
-
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDataListener, onFrameSendCompleted(mockTransportAdapter->mMockConnectionHandle, userData, NsSmartDeviceLink::NsTransportManager::SendStatusOK))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDataListener, &test::components::TransportManager::HighDataTransferRate::MockDataListener::unlockMutexAfterFrameSendCompleted))
- .RetiresOnSaturation();
-
- transportManager.onFrameSendCompleted(mockTransportAdapter, mockTransportAdapter->mMockConnectionHandle, userData, NsSmartDeviceLink::NsTransportManager::SendStatusOK);
-
- bytesSent += frameSize;
- }
- }
-
- timespec dataTransferEndTime;
- clock_gettime(CLOCK_REALTIME, &dataTransferEndTime);
-
- double dataTransferTime = static_cast<double>(dataTransferEndTime.tv_sec - dataTransferStartTime.tv_sec) + static_cast<double>(dataTransferEndTime.tv_nsec - dataTransferStartTime.tv_nsec) * 1e-9;
-
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDeviceListener, onApplicationDisconnected(mockTransportAdapter->mMockDeviceInfo, mockTransportAdapter->mMockConnectionHandle))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDeviceListener, &test::components::TransportManager::HighDataTransferRate::MockDeviceListener::unlockMutexAfterApplicationConnectedDisconnected))
- .RetiresOnSaturation();
-
- transportManager.onApplicationDisconnected(mockTransportAdapter, mockTransportAdapter->mMockDeviceInfo, mockTransportAdapter->mMockConnectionHandle);
-
- sleep(1);
-
- delete [] frameData;
-
- pthread_mutex_destroy(&callbacksMutex);
-
- printf("Sent %s (%s/s), received %s (%s/s)\n",
- test::components::TransportManager::HighDataTransferRate::formatDataSize(bytesSent).c_str(),
- test::components::TransportManager::HighDataTransferRate::formatDataSize(bytesSent / dataTransferTime).c_str(),
- test::components::TransportManager::HighDataTransferRate::formatDataSize(bytesReceived).c_str(),
- test::components::TransportManager::HighDataTransferRate::formatDataSize(bytesReceived / dataTransferTime).c_str());
-}
-
-int main(int argc, char **argv)
-{
- PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus_disabled.properties"));
-
- ::testing::InitGoogleMock(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/TransportManagerTestWithIncorrectDeviceAdapter.cpp b/test/components/transport_manager/TransportManagerTestWithIncorrectDeviceAdapter.cpp
deleted file mode 100644
index 64e156d8a..000000000
--- a/test/components/transport_manager/TransportManagerTestWithIncorrectDeviceAdapter.cpp
+++ /dev/null
@@ -1,224 +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.
-//
-
-/*
- Tests TransportManager behavior when device adapter behaves completely incorrectly.
- Tested cases are:
- - receiving data without available devices
- - receiving frameSendCompleted statuses without available devices/connections
- - receiving application disconnects without connected applications
- - receiving new frames with invalid/null data or it's size
- - receiving application disconnects for already disconnected applications
- - receiving application connect without available devices
- */
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "TransportManager/ITransportManagerDataListener.hpp"
-#include "TransportManager/ITransportManagerDeviceListener.hpp"
-#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-#include "../../../src/components/TransportManager/src/ITransportAdapter.hpp"
-
-namespace test
-{
- namespace components
- {
- namespace TransportManger
- {
- namespace IncorrectTransportAdapterTest
- {
- class MockDataListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener
- {
- public:
- MOCK_METHOD3(onFrameReceived, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize));
- MOCK_METHOD3(onFrameSendCompleted, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, int UserData, NsSmartDeviceLink::NsTransportManager::ESendStatus SendStatus));
- };
-
- class MockDeviceListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener
- {
- public:
- MOCK_METHOD1(onDeviceListUpdated, void(const NsSmartDeviceLink::NsTransportManager::tDeviceList & DeviceList));
- MOCK_METHOD2(onApplicationConnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & ConnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
- MOCK_METHOD2(onApplicationDisconnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & DisconnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
- };
-
- class MockTransportAdapter: public NsSmartDeviceLink::NsTransportManager::ITransportAdapter
- {
- public:
- virtual NsSmartDeviceLink::NsTransportManager::EDeviceType GetDeviceType(void) const;
-
- MOCK_METHOD1(connectDevice, void (const NsSmartDeviceLink::NsTransportManager::tDeviceHandle DeviceHandle));
- MOCK_METHOD1(disconnectDevice, void (const NsSmartDeviceLink::NsTransportManager::tDeviceHandle DeviceHandle));
- MOCK_METHOD0(run, void());
- MOCK_METHOD0(scanForNewDevices, void());
- MOCK_METHOD4(sendFrame, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize, int UserData));
- };
-
- class TestTransportManager: public NsSmartDeviceLink::NsTransportManager::CTransportManager
- {
- public:
- TestTransportManager(MockTransportAdapter * TransportAdapter);
- ~TestTransportManager(void);
- protected:
- virtual void initializeTransportAdapters(void);
-
- private:
- MockTransportAdapter * mMockTransportAdapter;
- };
- }
- }
- }
-}
-
-NsSmartDeviceLink::NsTransportManager::EDeviceType test::components::TransportManger::IncorrectTransportAdapterTest::MockTransportAdapter::GetDeviceType(void) const
-{
- return NsSmartDeviceLink::NsTransportManager::DeviceBluetooth;
-}
-
-test::components::TransportManger::IncorrectTransportAdapterTest::TestTransportManager::TestTransportManager(test::components::TransportManger::IncorrectTransportAdapterTest::MockTransportAdapter* TransportAdapter):
-CTransportManager(),
-mMockTransportAdapter(TransportAdapter)
-{
-}
-
-test::components::TransportManger::IncorrectTransportAdapterTest::TestTransportManager::~TestTransportManager(void)
-{
-}
-
-void test::components::TransportManger::IncorrectTransportAdapterTest::TestTransportManager::initializeTransportAdapters(void)
-{
- addTransportAdapter(mMockTransportAdapter);
-}
-
-TEST(TransportManager, IncorrectTransportAdapter)
-{
- test::components::TransportManger::IncorrectTransportAdapterTest::MockTransportAdapter* mockTransportAdapter = new test::components::TransportManger::IncorrectTransportAdapterTest::MockTransportAdapter();
- test::components::TransportManger::IncorrectTransportAdapterTest::MockDataListener mockDataListener;
- test::components::TransportManger::IncorrectTransportAdapterTest::MockDeviceListener mockDeviceListener;
- test::components::TransportManger::IncorrectTransportAdapterTest::TestTransportManager transportManager(mockTransportAdapter);
-
- EXPECT_CALL(*mockTransportAdapter, run()).Times(1);
-
- transportManager.run();
-
- transportManager.addDeviceListener(&mockDeviceListener);
- transportManager.addDataListener(&mockDataListener);
-
- NsSmartDeviceLink::NsTransportManager::tDeviceHandle validDeviceHandle = 123;
- NsSmartDeviceLink::NsTransportManager::tDeviceHandle validConnectionHandle = 321;
-
- NsSmartDeviceLink::NsTransportManager::SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = validDeviceHandle;
- deviceInfo.mUniqueDeviceId = "id";
- deviceInfo.mUserFriendlyName = "Name";
-
- NsSmartDeviceLink::NsTransportManager::tDeviceList deviceList;
- deviceList.push_back(deviceInfo);
-
- NsSmartDeviceLink::NsTransportManager::tInternalDeviceList internalDeviceList;
- internalDeviceList.push_back(NsSmartDeviceLink::NsTransportManager::SInternalDeviceInfo(deviceInfo.mDeviceHandle, deviceInfo.mUserFriendlyName, deviceInfo.mUniqueDeviceId));
-
- uint8_t validFrameData[16] = {0x11, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08};
- uint8_t invalidFrameData[16] = {0x51, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08};
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(::testing::_)).Times(0);
- EXPECT_CALL(mockDeviceListener, onApplicationConnected(::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDeviceListener, onApplicationDisconnected(::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDataListener, onFrameReceived(::testing::_, ::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDataListener, onFrameSendCompleted(::testing::_, ::testing::_, ::testing::_)).Times(0);
-
- transportManager.onFrameReceived(mockTransportAdapter, validConnectionHandle, 0, 5);
-
- transportManager.onFrameReceived(mockTransportAdapter, validConnectionHandle, validFrameData, 0);
-
- transportManager.onFrameReceived(mockTransportAdapter, validConnectionHandle, validFrameData, sizeof(validFrameData));
-
- transportManager.onFrameSendCompleted(mockTransportAdapter, validConnectionHandle, 20, NsSmartDeviceLink::NsTransportManager::SendStatusOK);
-
- transportManager.onApplicationDisconnected(mockTransportAdapter, deviceInfo, validConnectionHandle);
-
- transportManager.onApplicationConnected(mockTransportAdapter, deviceInfo, validConnectionHandle);
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(::testing::ContainerEq(deviceList))).Times(1).RetiresOnSaturation();
- transportManager.onDeviceListUpdated(mockTransportAdapter, internalDeviceList);
-
- transportManager.onApplicationDisconnected(mockTransportAdapter, deviceInfo, validConnectionHandle);
-
- EXPECT_CALL(mockDeviceListener, onApplicationConnected(::testing::Eq(deviceInfo), validConnectionHandle)).Times(1).RetiresOnSaturation();
- transportManager.onApplicationConnected(mockTransportAdapter, deviceInfo, validConnectionHandle);
-
- transportManager.onFrameReceived(mockTransportAdapter, validConnectionHandle, 0, 5);
-
- transportManager.onFrameReceived(mockTransportAdapter, validConnectionHandle, validFrameData, 0);
-
- EXPECT_CALL(mockDataListener, onFrameReceived(validConnectionHandle, ::testing::_, sizeof(validFrameData))).Times(1).RetiresOnSaturation();
- transportManager.onFrameReceived(mockTransportAdapter, validConnectionHandle, validFrameData, sizeof(validFrameData));
-
- transportManager.onFrameReceived(mockTransportAdapter, validConnectionHandle, invalidFrameData, sizeof(invalidFrameData));
-
- // Frame result is now expected even if we do not send any frame before
- EXPECT_CALL(mockDataListener, onFrameSendCompleted(validConnectionHandle, 20, NsSmartDeviceLink::NsTransportManager::SendStatusOK)).Times(1).RetiresOnSaturation();
- transportManager.onFrameSendCompleted(mockTransportAdapter, validConnectionHandle, 20, NsSmartDeviceLink::NsTransportManager::SendStatusOK);
-
- int userData = 123;
- transportManager.sendFrame(validConnectionHandle, validFrameData, sizeof(validFrameData), userData);
- EXPECT_CALL(mockDataListener, onFrameSendCompleted(validConnectionHandle, userData, NsSmartDeviceLink::NsTransportManager::SendStatusOK)).Times(1).RetiresOnSaturation();
- transportManager.onFrameSendCompleted(mockTransportAdapter, validConnectionHandle, userData, NsSmartDeviceLink::NsTransportManager::SendStatusOK);
-
- sleep(1); //We must wait for sending previous callbacks while applicationDisconnect can shutdown connection thread
-
- EXPECT_CALL(mockDeviceListener, onApplicationDisconnected(::testing::Eq(deviceInfo), validConnectionHandle)).Times(1).RetiresOnSaturation();
- transportManager.onApplicationDisconnected(mockTransportAdapter, deviceInfo, validConnectionHandle);
-
- transportManager.onApplicationDisconnected(mockTransportAdapter, deviceInfo, validConnectionHandle);
-
-
- deviceList.clear();
- internalDeviceList.clear();
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(::testing::ContainerEq(deviceList))).Times(1).RetiresOnSaturation();
- transportManager.onDeviceListUpdated(mockTransportAdapter, internalDeviceList);
-
- transportManager.onApplicationConnected(mockTransportAdapter, deviceInfo, validConnectionHandle);
-
- //sleep(2); return;
- sleep(1);
-}
-
-int main(int argc, char **argv)
-{
- PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties"));
-
- ::testing::InitGoogleMock(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/TransportManagerTestWithMultiThreadedClient.cpp b/test/components/transport_manager/TransportManagerTestWithMultiThreadedClient.cpp
deleted file mode 100644
index f288878bf..000000000
--- a/test/components/transport_manager/TransportManagerTestWithMultiThreadedClient.cpp
+++ /dev/null
@@ -1,502 +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.
-//
-
-/*
- Tests Transport Manager behavior with single TM client which sents a lot of data from many different threads (more than 200).
- Sent data was sent back from device adapter to TM client and validated
- */
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "../../../src/components/TransportManager/src/ITransportAdapter.hpp"
-#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-#include "TransportManager/ITransportManagerDataListener.hpp"
-#include "TransportManager/ITransportManagerDeviceListener.hpp"
-
-#include <stddef.h>
-#include <stdio.h>
-#include <vector>
-#include <map>
-
-using ::testing::_;
-using ::testing::Invoke;
-using ::testing::StrEq;
-using ::testing::Property;
-using ::testing::Field;
-using ::testing::Contains;
-using ::testing::AllOf;
-using ::testing::ElementsAre;
-using ::testing::ContainerEq;
-using ::testing::Eq;
-using ::testing::InSequence;
-
-using namespace NsSmartDeviceLink::NsTransportManager;
-
-namespace test { namespace components { namespace TransportManager { namespace TestWithMultiThreadedClient {
-
- // ---------------- TEST DATA ---------------- //
- namespace Data
- {
- static const tDeviceHandle DeviceHandle = 123;
- static const EDeviceType DeviceType = DeviceBluetooth;
- static const std::string UserFriendlyName("MY USER FRIENDLY NAME");
- static const std::string UniqueDeviceId("MY_UNIQUE_DEVICE_ID");
-
- static const tConnectionHandle ConnectionHandle = 666;
-
- static const int BaseSequenceNumber = 1;
- static const int NumberOfThreads = 113;
- static const int NumberOfFramesPerThread = 53;
- static const int TotalNumberOfFrames = NumberOfThreads * NumberOfFramesPerThread;
- static const int FrameSize = 323;
- }
-
- // ---------------- TEST CLASSES ---------------- //
-
- /**
- * @brief Class that represents custom device adapter that will send known data
- * and check it's methods calls
- **/
- class MockTransportAdapter : public ITransportAdapter
- {
- public:
- MockTransportAdapter(ITransportAdapterListener & Listener, IHandleGenerator & HandleGenerator)
- : mListener(Listener)
- , mHandleGenerator(HandleGenerator)
- {
- }
-
- virtual EDeviceType GetDeviceType(void ) const
- {
- return DeviceBluetooth;
- }
- MOCK_METHOD1(connectDevice, void (const tDeviceHandle DeviceHandle));
- MOCK_METHOD1(disconnectDevice, void (const tDeviceHandle DeviceHandle));
- MOCK_METHOD0(run, void());
- MOCK_METHOD0(scanForNewDevices, void());
- MOCK_METHOD4(sendFrame, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, int UserData));
-
- void doScanForNewDevices()
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Scanning new devices -----------------");
- SInternalDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- tInternalDeviceList list;
- list.push_back(deviceInfo);
-
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Sending device list update -----------------");
- mListener.onDeviceListUpdated(this, list);
- }
-
- void doConnectDevice(const tDeviceHandle DeviceHandle)
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Connecting device -----------------");
- // Application connect
-
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Sending ApplicationConnected -----------------");
- mListener.onApplicationConnected(this, deviceInfo, Data::ConnectionHandle);
- }
-
- void doSendFrame(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, int UserData)
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- doSendFrame called -----------------");
-
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Sending frame back to TransportManager. DataSize: " << DataSize << "--------------");
-
- // Loop back. Each recevied frame is sent back.
- mListener.onFrameReceived(this, ConnectionHandle, Data, DataSize);
-
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Calling onFrameSendCompleted. UserData: " << UserData << "--------------");
-
- mListener.onFrameSendCompleted(this, Data::ConnectionHandle, UserData, SendStatusOK);
- }
-
- void doDisconnectDevice(const tDeviceHandle DeviceHandle)
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- doDisconnectDevice -----------------");
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- sending ApplicationDisconnected -----------------");
- mListener.onApplicationDisconnected(this, deviceInfo, Data::ConnectionHandle);
- }
-
- protected:
- ITransportAdapterListener & mListener;
- IHandleGenerator & mHandleGenerator;
- };
-
- /**
- * @brief Custom transport manager client that will check data, sent by transport manager
- **/
- class MockTransportManagerClient : public ITransportManagerDataListener
- , public ITransportManagerDeviceListener
- {
- public:
-
- MockTransportManagerClient(ITransportManager & TransportManager)
- : mTransportManager(TransportManager)
- , mDeviceList()
- , mFrameSequenceNumber(-1)
- , mLogger(LOG4CXX::Logger::getInstance(LOG4CXX_TEXT("TransportManagerTest")))
- , mThreads()
- , mSendFrameMap()
- , mFrameReceivedNumberMutex()
- , mFrameSendCompletedMutex()
- , mNumberOfReceivedFrames(0)
- , mNumberOfCompletelySentFrames(0)
- , mSequenceNumber(Data::BaseSequenceNumber)
- , mSequenceNumberMutex()
- {
- pthread_mutex_init(&mFrameReceivedNumberMutex, 0);
- pthread_mutex_init(&mFrameSendCompletedMutex, 0);
- pthread_mutex_init(&mSequenceNumberMutex, 0);
- }
-
- MOCK_METHOD2(onApplicationConnected, void(const SDeviceInfo& ConnectedDevice, const tConnectionHandle Connection));
- MOCK_METHOD2(onApplicationDisconnected, void(const SDeviceInfo& DisconnectedDevice, const tConnectionHandle Connection));
- MOCK_METHOD1(onDeviceListUpdated, void(const tDeviceList& DeviceList));
- MOCK_METHOD3(onFrameReceived, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize));
- MOCK_METHOD3(onFrameSendCompleted, void(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus));
-
- void doDeviceListUpdated(const tDeviceList& DeviceList)
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- doDeviceListUpdated -----------------");
- mDeviceList = DeviceList;
-
- tDeviceList::const_iterator device;
- for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
- {
- mTransportManager.connectDevice(device->mDeviceHandle);
- }
- }
-
- void doApplicationConnected(const SDeviceInfo& ConnectedDevice, const tConnectionHandle Connection)
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- doApplicationConnected -----------------");
-
- for (int i = 0; i < Data::NumberOfThreads; ++i)
- {
- pthread_t thread;
- pthread_create(&thread, NULL, &threadSendFrames, static_cast<void*>(this));
- mThreads.push_back(thread);
- }
- }
-
- void doFrameSendCompleted(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus)
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- doFrameSendCompleted -----------------");
-
- pthread_mutex_lock(&mFrameSendCompletedMutex);
-
- mNumberOfCompletelySentFrames++;
-
- uint8_t *pData = mSendFrameMap[UserData];
-
- delete pData;
- mSendFrameMap.erase(UserData);
-
- pthread_mutex_unlock(&mFrameSendCompletedMutex);
-
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Number of completely sent frames: "
- << mNumberOfCompletelySentFrames << " -----------------");
- }
-
- void doFrameReceived(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize)
- {
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- doFrameReceived -----------------");
-
- pthread_mutex_lock(&mFrameReceivedNumberMutex);
-
- mNumberOfReceivedFrames++;
-
- pthread_mutex_unlock(&mFrameReceivedNumberMutex);
-
- LOG4CXX_INFO_EXT(mLogger, "\n-------------- Number of received frames: " << mNumberOfReceivedFrames << " -----------------");
- }
-
- void disconnectAllDevices(void)
- {
- tDeviceList::const_iterator device;
-
- for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
- {
- mTransportManager.disconnectDevice(device->mDeviceHandle);
- }
-
- ASSERT_EQ(mNumberOfCompletelySentFrames, Data::TotalNumberOfFrames) << "Wrong number of send frame confirmation";
- ASSERT_EQ(mNumberOfReceivedFrames, Data::TotalNumberOfFrames) << "Wrong number of received frames";
- }
-
- void waitForAllThreads(void)
- {
- int timeOut = 60; // sec
- bool finished = false;
-
- while(timeOut)
- {
- pthread_mutex_lock(&mFrameReceivedNumberMutex);
- finished = mNumberOfReceivedFrames == Data::TotalNumberOfFrames;
- pthread_mutex_unlock(&mFrameReceivedNumberMutex);
-
- if (finished)
- {
- break;
- }
- else
- {
- sleep(1);
- timeOut--;
- }
- }
-
- ASSERT_NE(timeOut, 0) << "Timeout waiting to receive all the frames";
-
- for (int i = 0; i < Data::NumberOfThreads; ++i)
- {
- pthread_join(mThreads[i], NULL);
- }
- }
-
- private:
-
- static void* threadSendFrames(void* Data)
- {
- MockTransportManagerClient *pTMClient = static_cast<MockTransportManagerClient*>(Data);
-
- LOG4CXX_INFO_EXT(pTMClient->mLogger, "\n-------------- Frame Send Thread Started -----------------");
-
- for (int i = 0; i < Data::NumberOfFramesPerThread; ++i)
- {
- uint8_t *pFrameData = new uint8_t[Data::FrameSize];
- uint32_t dataSize = Data::FrameSize - 12; // minus header size
-
- // make a valid packet
- pFrameData[0] = 0x22; // version 2
- pFrameData[1] = 0x0F;
- pFrameData[2] = 0x00;
- pFrameData[3] = 0x00;
- pFrameData[4] = (dataSize>>24) & 0xFF;
- pFrameData[5] = (dataSize>>16) & 0xFF;
- pFrameData[6] = (dataSize>> 8) & 0xFF;
- pFrameData[7] = (dataSize>> 0) & 0xFF;
-
- int sequence = pTMClient->getNextSequenceNumber();
-
- pTMClient->mTransportManager.sendFrame(Data::ConnectionHandle, pFrameData, Data::FrameSize, sequence);
-
- pthread_mutex_lock(&pTMClient->mFrameSendCompletedMutex);
- pTMClient->mSendFrameMap[sequence] = pFrameData;
- pthread_mutex_unlock(&pTMClient->mFrameSendCompletedMutex);
- }
-
- return 0;
- }
-
- int getNextSequenceNumber(void)
- {
- int nextSeq;
-
- pthread_mutex_lock(&mSequenceNumberMutex);
- nextSeq = ++mSequenceNumber;
- pthread_mutex_unlock(&mSequenceNumberMutex);
-
- return nextSeq;
- }
-
- protected:
- ITransportManager & mTransportManager;
- tDeviceList mDeviceList;
- int mFrameSequenceNumber;
- Logger mLogger;
-
- std::vector<pthread_t> mThreads;
- std::map<int, uint8_t*> mSendFrameMap;
-
- int mNumberOfReceivedFrames;
- pthread_mutex_t mFrameReceivedNumberMutex;
-
- int mNumberOfCompletelySentFrames;
- pthread_mutex_t mFrameSendCompletedMutex;
-
- int mSequenceNumber;
- pthread_mutex_t mSequenceNumberMutex;
- };
-
- /**
- * @brief Inherited transport manager class used for some small preparation of class for
- * testing (disabling another adapters etc.)
- **/
- class TestTransportManager : public CTransportManager
- {
- public:
- TestTransportManager(void )
- : CTransportManager()
- , mLogger(LOG4CXX::Logger::getInstance(LOG4CXX_TEXT("TransportManagerTest")))
- {
- }
-
- virtual ~TestTransportManager(void )
- {
-
- }
-
- virtual void initializeTransportAdapters()
- {
- // Preparing custom device adapter
- mpTransportAdapter = new MockTransportAdapter(*this, *this);
-
- EXPECT_CALL(*mpTransportAdapter, run()).Times(1);
- EXPECT_CALL(*mpTransportAdapter, scanForNewDevices())
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doScanForNewDevices))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, connectDevice(Data::DeviceHandle))
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doConnectDevice))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, sendFrame(Data::ConnectionHandle, _, _, _))
- .Times(Data::TotalNumberOfFrames)
- .WillRepeatedly(Invoke(mpTransportAdapter, &MockTransportAdapter::doSendFrame))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, disconnectDevice(Data::DeviceHandle))
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doDisconnectDevice))
- ;
-
- addTransportAdapter(mpTransportAdapter);
- LOG4CXX_INFO_EXT(mLogger, "Transport adapters initialized");
- }
-
- protected:
- MockTransportAdapter *mpTransportAdapter;
- Logger mLogger;
- };
-
- // ----------------------- TESTS ----------------------- //
-
- TEST(test_TestWithMultiThreadedClient, MultiThreadedClientTest)
- {
- Logger logger = LOG4CXX::Logger::getInstance(LOG4CXX_TEXT("TransportManagerTest"));
-
- LOG4CXX_INFO_EXT(logger, "\n*************************** Starting test *****************************");
- // All expectations must be sequenced
- //InSequence dummy;
-
- // Creating transport manager
- TestTransportManager *pTm = new TestTransportManager();
-
- // Preparing transport manage client
- MockTransportManagerClient tmClient(*pTm);
-
- // Expected device list
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
- tDeviceList deviceList;
- deviceList.push_back(deviceInfo);
-
- EXPECT_CALL(tmClient, onDeviceListUpdated(ContainerEq(deviceList)))
- .Times(1)
- .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doDeviceListUpdated))
- ;
-
- EXPECT_CALL(tmClient, onApplicationConnected(deviceInfo, Data::ConnectionHandle))
- .Times(1)
- .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doApplicationConnected))
- ;
-
- EXPECT_CALL(tmClient, onFrameReceived(Data::ConnectionHandle, _, Data::FrameSize))
- .Times(Data::TotalNumberOfFrames)
- .WillRepeatedly(Invoke(&tmClient, &MockTransportManagerClient::doFrameReceived))
- ;
-
- EXPECT_CALL(tmClient, onFrameSendCompleted(Data::ConnectionHandle, _, SendStatusOK))
- .Times(Data::TotalNumberOfFrames)
- .WillRepeatedly(Invoke(&tmClient, &MockTransportManagerClient::doFrameSendCompleted))
- ;
-
- EXPECT_CALL(tmClient, onApplicationDisconnected(deviceInfo, Data::ConnectionHandle))
- .Times(1)
- ;
-
- // Running test
-
- pTm->addDataListener(&tmClient);
- pTm->addDeviceListener(&tmClient);
-
- LOG4CXX_INFO_EXT(logger, "\n*************************** Calling RUN *****************************");
- pTm->run();
-
- sleep(1);
-
- LOG4CXX_INFO_EXT(logger, "\n*************************** Calling SCAN FOR DEVICES *****************************");
- pTm->scanForNewDevices();
-
- LOG4CXX_INFO_EXT(logger, "\n******************* Waiting for all client thread to finish ********************");
- tmClient.waitForAllThreads();
-
- LOG4CXX_INFO_EXT(logger, "\n******************* Disconnecting all devices ********************");
- tmClient.disconnectAllDevices();
-
- sleep(1);
-
- LOG4CXX_INFO_EXT(logger, "\n*************************** Deleting TM and shutting down *****************************");
-
- // Shutdown transport manager
- delete pTm;
- pTm = 0;
-
- }
-}}}} // End of namespaces
-
-
-
-int main(int argc, char **argv) {
- PropertyConfigurator::doConfigure(LOG4CXX_TEXT("log4cxx.properties"));
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/TransportManagerTestWithMultipleClients.cpp b/test/components/transport_manager/TransportManagerTestWithMultipleClients.cpp
deleted file mode 100644
index 3f60fbb36..000000000
--- a/test/components/transport_manager/TransportManagerTestWithMultipleClients.cpp
+++ /dev/null
@@ -1,552 +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.
-//
-
-/*
- Tests transport manager with multiple TM clients.
-
- Each client lives within it's own thread. During his live each client sends a lot of data.
- Also a lot of data also sent from device adapter to all TM clients.
- */
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "../../../src/components/TransportManager/src/ITransportAdapter.hpp"
-#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-#include "TransportManager/ITransportManagerDataListener.hpp"
-#include "TransportManager/ITransportManagerDeviceListener.hpp"
-
-#include <stddef.h>
-#include <stdio.h>
-#include <pthread.h>
-
-
-using ::testing::_;
-using ::testing::Invoke;
-using ::testing::StrEq;
-using ::testing::Property;
-using ::testing::Field;
-using ::testing::Contains;
-using ::testing::AllOf;
-using ::testing::ElementsAre;
-using ::testing::ContainerEq;
-using ::testing::Eq;
-using ::testing::InSequence;
-
-using namespace NsSmartDeviceLink::NsTransportManager;
-
-namespace test { namespace components { namespace TransportManager { namespace TestWithMultipleClients {
-
- // ---------------- TEST DATA ---------------- //
- namespace Data
- {
- static const tDeviceHandle DeviceHandle = 123;
- static const EDeviceType DeviceType = DeviceBluetooth;
- static const std::string UserFriendlyName("MY USER FRIENDLY NAME");
- static const std::string UniqueDeviceId("MY_UNIQUE_DEVICE_ID");
-
- static const tConnectionHandle ConnectionHandle = 666;
-
- static const int NumberOfClients = 100;
- static const int NumberOfIterations = 6;
-
- static const int TotalNumberOfCalls = NumberOfClients * NumberOfIterations;
- }
-
- // ---------------- TEST CLASSES ---------------- //
-
- /**
- * @brief Class that represents custom device adapter that will send known data
- * and check it's methods calls
- **/
- class MockTransportAdapter : public ITransportAdapter
- {
- public:
- MockTransportAdapter(ITransportAdapterListener & Listener, IHandleGenerator & HandleGenerator)
- : mListener(Listener)
- , mHandleGenerator(HandleGenerator)
- , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
- {
- }
-
- virtual EDeviceType GetDeviceType(void ) const
- {
- return DeviceBluetooth;
- }
- MOCK_METHOD1(connectDevice, void (const tDeviceHandle DeviceHandle));
- MOCK_METHOD1(disconnectDevice, void (const tDeviceHandle DeviceHandle));
- MOCK_METHOD0(run, void());
- MOCK_METHOD0(scanForNewDevices, void());
- MOCK_METHOD4(sendFrame, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, int UserData));
-
- void doScanForNewDevices()
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Scanning new devices -----------------");
- SInternalDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- tInternalDeviceList list;
- list.push_back(deviceInfo);
-
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Sending device list update -----------------");
- mListener.onDeviceListUpdated(this, list);
- }
-
- void doConnectDevice(const tDeviceHandle DeviceHandle)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Connecting device -----------------");
- // Application connect
-
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Sending ApplicationConnected -----------------");
- mListener.onApplicationConnected(this, deviceInfo, Data::ConnectionHandle);
-
- // Send three frames to transport manager
-
- uint8_t raw_data[] = {
- 0x22, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8,
- 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF
- };
-
- for (int i = 0; i < Data::NumberOfIterations; ++i)
- {
- // Sending only header first
- uint8_t *pSendBuff = raw_data;
-
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Sending Frame #" << 3 * i + 1 << " -----------------");
- mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, 12);
-
- // Sending first part of the data
- pSendBuff+=12;
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Sending Frame #" << 3 * i + 2 << " -----------------");
- mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
-
- // Sending last part of the data
- pSendBuff+=100;
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Sending Frame #" << 3 * i + 3 << " -----------------");
- mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
- }
- }
-
- void doSendFrame(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, int UserData)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- doSendFrame called. Sending FrameSendCompleted -----------------");
- mListener.onFrameSendCompleted(this, Data::ConnectionHandle, UserData, SendStatusOK);
- }
-
- void doDisconnectDevice(const tDeviceHandle DeviceHandle)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- doDisconnectDevice -----------------");
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- sending ApplicationDisconnected -----------------");
- mListener.onApplicationDisconnected(this, deviceInfo, Data::ConnectionHandle);
- }
-
- protected:
- ITransportAdapterListener & mListener;
- IHandleGenerator & mHandleGenerator;
- Logger mLogger;
- };
-
- /**
- * @brief Custom transport manager client that will check data, sent by transport manager
- **/
- class MockTransportManagerClient : public ITransportManagerDataListener
- , public ITransportManagerDeviceListener
- {
- public:
- MockTransportManagerClient(ITransportManager & TransportManager)
- : mTransportManager(TransportManager)
- , mDeviceList()
- , mFrameSequenceNumber(0)
- , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
- , mCurrentIteration(0)
- , mConnectionHandle(Data::ConnectionHandle) // should be invalid handle but currently it is valid because of the late applicationConnected callback
- , mConnected(false)
- , mNumberOfReceivedFrames(0)
- , mNumberOfReceivedFramesMutex()
- {
- pthread_mutex_init(&mNumberOfReceivedFramesMutex, 0);
- }
- MOCK_METHOD2(onApplicationConnected, void(const SDeviceInfo& ConnectedDevice, const tConnectionHandle Connection));
- MOCK_METHOD2(onApplicationDisconnected, void(const SDeviceInfo& DisconnectedDevice, const tConnectionHandle Connection));
- MOCK_METHOD1(onDeviceListUpdated, void(const tDeviceList& DeviceList));
- MOCK_METHOD3(onFrameReceived, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize));
- MOCK_METHOD3(onFrameSendCompleted, void(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus));
-
- void doDeviceListUpdated(const tDeviceList& DeviceList)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- doDeviceListUpdated -----------------");
- mDeviceList = DeviceList;
-
- tDeviceList::const_iterator device;
- for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
- {
- mTransportManager.connectDevice(device->mDeviceHandle);
- }
- }
-
- void doApplicationConnected(const SDeviceInfo& ConnectedDevice, const tConnectionHandle Connection)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- doApplicationConnected -----------------");
-
- mConnectionHandle = Connection;
- mConnected = true;
- }
-
- void sendTestFrame(void)
- {
- // Sending frame
- uint8_t data[512]={1};
- mTransportManager.sendFrame(mConnectionHandle, data, 512, ++mFrameSequenceNumber);
- }
-
- void doFrameReceived(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- doFrameReceived -----------------");
-
- bool finished = false;
-
- pthread_mutex_lock(&mNumberOfReceivedFramesMutex);
- mNumberOfReceivedFrames++;
- finished = mNumberOfReceivedFrames >= Data::TotalNumberOfCalls;
- pthread_mutex_unlock(&mNumberOfReceivedFramesMutex);
-
- if (finished)
- {
- checkIfFinished();
- }
-
- if (mCurrentIteration == 0)
- { // start sending frame on first iteration
- mCurrentIteration++;
- sendTestFrame();
- }
- }
-
- void doFrameSendCompleted(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- doFrameSendCompleted, UserData: " << UserData << " -----------------");
-
- if (mCurrentIteration < Data::NumberOfIterations)
- {
- sendTestFrame();
- }
- else if (mCurrentIteration == Data::TotalNumberOfCalls) // received all events
- {
- checkIfFinished();
- }
-
- mCurrentIteration++;
- }
-
- void doApplicationDisconnected(const SDeviceInfo& DisconnectedDevice, const tConnectionHandle Connection)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Application disconnected -----------------");
-
- mConnected = false;
- }
-
- bool isConnected(void)
- {
- return mConnected;
- }
-
- void checkIfFinished(void)
- {
- if ( mCurrentIteration >= Data::TotalNumberOfCalls &&
- mNumberOfReceivedFrames >= Data::TotalNumberOfCalls )
- {
- pthread_mutex_lock(&mFinishedMutex);
- mNumberOfClientsFinished++;
- pthread_mutex_unlock(&mFinishedMutex);
-
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- a client has finished -----------------");
- }
- }
-
- static bool isAllClientsFinished(void)
- {
- bool finished = false;
-
- pthread_mutex_lock(&mFinishedMutex);
- finished = mNumberOfClientsFinished >= Data::NumberOfClients;
- pthread_mutex_unlock(&mFinishedMutex);
-
- return finished;
- }
-
-
- void disconnectAllDevices(void)
- {
- LOG4CPLUS_INFO_EXT(mLogger, "\n-------------- Disconnecting devices -----------------");
-
- tDeviceList::const_iterator device;
-
- for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
- {
- mTransportManager.disconnectDevice(device->mDeviceHandle);
- }
- }
-
- protected:
- ITransportManager & mTransportManager;
- tDeviceList mDeviceList;
- int mFrameSequenceNumber;
- Logger mLogger;
- int mCurrentIteration;
- tConnectionHandle mConnectionHandle;
- static int mNumberOfClientsFinished;
- static pthread_mutex_t mFinishedMutex;
- bool mConnected;
-
- int mNumberOfReceivedFrames;
- pthread_mutex_t mNumberOfReceivedFramesMutex;
- };
-
- int MockTransportManagerClient::mNumberOfClientsFinished = 0;
- pthread_mutex_t MockTransportManagerClient::mFinishedMutex = PTHREAD_MUTEX_INITIALIZER;
-
-
- /**
- * @brief Inherited transport manager class used for some small preparation of class for
- * testing (disabling another adapters etc.)
- **/
- class TestTransportManager : public CTransportManager
- {
- public:
- TestTransportManager(void )
- : CTransportManager()
- , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
- {
- }
-
- virtual ~TestTransportManager(void )
- {
-
- }
-
- virtual void initializeTransportAdapters()
- {
- // Preparing custom device adapter
- mpTransportAdapter = new MockTransportAdapter(*this, *this);
-
- EXPECT_CALL(*mpTransportAdapter, run()).Times(1);
- EXPECT_CALL(*mpTransportAdapter, scanForNewDevices())
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doScanForNewDevices))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, connectDevice(Data::DeviceHandle))
- .Times(Data::NumberOfClients)
- .WillRepeatedly(Invoke(mpTransportAdapter, &MockTransportAdapter::doConnectDevice))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, sendFrame(Data::ConnectionHandle, _, 512, _))
- .Times(Data::TotalNumberOfCalls)
- .WillRepeatedly(Invoke(mpTransportAdapter, &MockTransportAdapter::doSendFrame))
- ;
-
- EXPECT_CALL(*mpTransportAdapter, disconnectDevice(Data::DeviceHandle))
- .Times(1)
- .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doDisconnectDevice))
- ;
-
- addTransportAdapter(mpTransportAdapter);
- LOG4CPLUS_INFO_EXT(mLogger, "Transport adapters initialized");
- }
-
- protected:
- MockTransportAdapter *mpTransportAdapter;
- Logger mLogger;
- };
-
- // ------------------------------------------------------------------------
-
- static void* startClientThread(void *pData)
- {
- Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest"));
-
- LOG4CPLUS_INFO_EXT(logger, "\n--------------------- Client thread started ----------------");
-
- TestTransportManager *pTm = static_cast<TestTransportManager*>(pData);
-
- // Preparing transport manage client
- MockTransportManagerClient tmClient(*pTm);
-
- // Expected device list
- SDeviceInfo deviceInfo;
- deviceInfo.mDeviceHandle = Data::DeviceHandle;
- deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
- deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
- tDeviceList deviceList;
- deviceList.push_back(deviceInfo);
-
-
- EXPECT_CALL(tmClient, onDeviceListUpdated(ContainerEq(deviceList)))
- .Times(1)
- .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doDeviceListUpdated))
- ;
-
- EXPECT_CALL(tmClient, onApplicationConnected(deviceInfo, Data::ConnectionHandle))
- .Times(Data::NumberOfClients)
- .WillRepeatedly(Invoke(&tmClient, &MockTransportManagerClient::doApplicationConnected))
- ;
-
- EXPECT_CALL(tmClient, onFrameReceived(Data::ConnectionHandle, _, 212))
- .Times(Data::TotalNumberOfCalls)
- .WillRepeatedly(Invoke(&tmClient, &MockTransportManagerClient::doFrameReceived))
- ;
-
- EXPECT_CALL(tmClient, onFrameSendCompleted(Data::ConnectionHandle, _, SendStatusOK))
- .Times(Data::TotalNumberOfCalls)
- .WillRepeatedly(Invoke(&tmClient, &MockTransportManagerClient::doFrameSendCompleted))
- ;
-
- EXPECT_CALL(tmClient, onApplicationDisconnected(deviceInfo, Data::ConnectionHandle))
- .Times(1)
- .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doApplicationDisconnected));
- ;
-
- pTm->addDataListener(&tmClient);
- pTm->addDeviceListener(&tmClient);
-
- while (!MockTransportManagerClient::isAllClientsFinished())
- {
- sleep(1);
- }
-
- while (tmClient.isConnected()) // wait for a client to receive onApplicationDisconnected
- {
- sleep(1);
- }
-
- pTm->removeDataListener(&tmClient);
- pTm->removeDeviceListener(&tmClient);
-
- return NULL;
- }
-
- // ----------------------- TESTS ----------------------- //
-
- TEST(test_TestWithCorrectTransportAdapter, CorrectTransportAdapterBehavior)
- {
- Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest"));
-
- LOG4CPLUS_INFO_EXT(logger, "*************************** Starting test *****************************");
- // All expectations must be sequenced
- //InSequence dummy;
-
- // Creating transport manager
- TestTransportManager *pTm = new TestTransportManager();
-
- LOG4CPLUS_INFO_EXT(logger, "\n--------------------- Calling RUN ----------------");
- pTm->run();
-
- std::vector<pthread_t> threads;
-
- for (int i = 0; i < Data::NumberOfClients; ++i)
- {
- pthread_t thread;
- pthread_create(&thread, NULL, &startClientThread, pTm);
-
- threads.push_back(thread);
- }
-
- sleep(1);
-
- LOG4CPLUS_INFO_EXT(logger, "\n--------------------- Calling SCAN FOR DEVICES ----------------");
- pTm->scanForNewDevices();
-
- while (!MockTransportManagerClient::isAllClientsFinished())
- {
- sleep(1);
- }
-
- LOG4CPLUS_INFO_EXT(logger, "\n--------------------- All clients have finished ----------------");
-
- pTm->disconnectDevice(Data::DeviceHandle);
-
- for (int i = 0; i < Data::NumberOfClients; ++i)
- {
- pthread_join(threads[i], NULL);
- }
-
- LOG4CPLUS_INFO_EXT(logger, "*************************** Deleting TM and shutting down *****************************");
-
- // Shutdown transport manager
- delete pTm;
- pTm = 0;
- }
-}}}} // End of namespaces
-
-
-
-int main(int argc, char **argv) {
- PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties"));
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/TransportManagerTestWithMultipleDeviceAdapters.cpp b/test/components/transport_manager/TransportManagerTestWithMultipleDeviceAdapters.cpp
deleted file mode 100644
index 2dd4f8cba..000000000
--- a/test/components/transport_manager/TransportManagerTestWithMultipleDeviceAdapters.cpp
+++ /dev/null
@@ -1,435 +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.
-//
-
-/*
- Tests Transport Manager functionality with multiple (256) device adapters that connects/disconnects/sents data
- */
-#include <algorithm>
-#include <pthread.h>
-#include <time.h>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "TransportManager/ITransportManagerDataListener.hpp"
-#include "TransportManager/ITransportManagerDeviceListener.hpp"
-#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-#include "../../../src/components/TransportManager/src/ITransportAdapter.hpp"
-
-namespace test
-{
- namespace components
- {
- namespace TransportManager
- {
- namespace MultipleTransportAdaptersTest
- {
- const size_t cNumberOfMockTransportAdapters = 256u;
-
- class MockDataListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDataListener
- {
- public:
- MockDataListener(pthread_mutex_t & Mutex);
-
- MOCK_METHOD3(onFrameReceived, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize));
- MOCK_METHOD3(onFrameSendCompleted, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, int UserData, NsSmartDeviceLink::NsTransportManager::ESendStatus SendStatus));
-
- void unlockMutexAfterFrameReceived(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t);
- void unlockMutexAfterFrameSendCompleted(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, int, NsSmartDeviceLink::NsTransportManager::ESendStatus);
-
- private:
- pthread_mutex_t & mMutex;
- };
-
- class MockDeviceListener: public NsSmartDeviceLink::NsTransportManager::ITransportManagerDeviceListener
- {
- public:
- MockDeviceListener(pthread_mutex_t & Mutex);
-
- MOCK_METHOD1(onDeviceListUpdated, void(const NsSmartDeviceLink::NsTransportManager::tDeviceList & DeviceList));
- MOCK_METHOD2(onApplicationConnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & ConnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
- MOCK_METHOD2(onApplicationDisconnected, void(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo & DisconnectedDevice, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle Connection));
-
- void unlockMutexAfterDeviceListUpdate(const NsSmartDeviceLink::NsTransportManager::tDeviceList &);
- void unlockMutexAfterApplicationConnectedDisconnected(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo &, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle);
-
- private:
- pthread_mutex_t & mMutex;
- };
-
- class MockTransportAdapter: public NsSmartDeviceLink::NsTransportManager::ITransportAdapter
- {
- public:
- MockTransportAdapter(pthread_mutex_t & Mutex);
- virtual NsSmartDeviceLink::NsTransportManager::EDeviceType GetDeviceType(void) const;
-
- MOCK_METHOD1(connectDevice, void (const NsSmartDeviceLink::NsTransportManager::tDeviceHandle DeviceHandle));
- MOCK_METHOD1(disconnectDevice, void (const NsSmartDeviceLink::NsTransportManager::tDeviceHandle DeviceHandle));
- MOCK_METHOD0(run, void());
- MOCK_METHOD0(scanForNewDevices, void());
- MOCK_METHOD4(sendFrame, void(NsSmartDeviceLink::NsTransportManager::tConnectionHandle ConnectionHandle, const uint8_t * Data, size_t DataSize, int UserData));
-
- void unlockMutexAfterSendFrame(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t, int UserData);
-
- NsSmartDeviceLink::NsTransportManager::SDeviceInfo mMockDeviceInfo;
- NsSmartDeviceLink::NsTransportManager::tConnectionHandle mMockConnectionHandle;
- int mMockUserData;
-
- private:
- pthread_mutex_t & mMutex;
- };
-
- class TestTransportManager: public NsSmartDeviceLink::NsTransportManager::CTransportManager
- {
- public:
- TestTransportManager(test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter * (& TransportAdapters)[cNumberOfMockTransportAdapters]);
- ~TestTransportManager(void);
- protected:
- virtual void initializeTransportAdapters(void);
-
- private:
- MockTransportAdapter * (& mMockTransportAdapters)[cNumberOfMockTransportAdapters];
- };
-
- template <typename Type>
- struct TRemoveReference
- {
- typedef Type tType;
- };
-
- template <typename Type>
- struct TRemoveReference<Type &>
- {
- typedef Type tType;
- };
- }
- }
- }
-}
-
-test::components::TransportManager::MultipleTransportAdaptersTest::MockDataListener::MockDataListener(pthread_mutex_t & Mutex):
-mMutex(Mutex)
-{
-}
-
-void test::components::TransportManager::MultipleTransportAdaptersTest::MockDataListener::unlockMutexAfterFrameReceived(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-void test::components::TransportManager::MultipleTransportAdaptersTest::MockDataListener::unlockMutexAfterFrameSendCompleted(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, int, NsSmartDeviceLink::NsTransportManager::ESendStatus)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener::MockDeviceListener(pthread_mutex_t & Mutex):
-mMutex(Mutex)
-{
-}
-
-void test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener::unlockMutexAfterDeviceListUpdate(const NsSmartDeviceLink::NsTransportManager::tDeviceList &)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-void test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener::unlockMutexAfterApplicationConnectedDisconnected(const NsSmartDeviceLink::NsTransportManager::SDeviceInfo &, const NsSmartDeviceLink::NsTransportManager::tConnectionHandle)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter::MockTransportAdapter(pthread_mutex_t & Mutex):
-mMockDeviceInfo(),
-mMockConnectionHandle(NsSmartDeviceLink::NsTransportManager::InvalidConnectionHandle),
-mMockUserData(-1),
-mMutex(Mutex)
-{
- mMockDeviceInfo.mDeviceHandle = NsSmartDeviceLink::NsTransportManager::InvalidDeviceHandle;
- mMockDeviceInfo.mDeviceType = NsSmartDeviceLink::NsTransportManager::DeviceBluetooth;
-}
-
-NsSmartDeviceLink::NsTransportManager::EDeviceType test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter::GetDeviceType(void) const
-{
- return mMockDeviceInfo.mDeviceType;
-}
-
-void test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter::unlockMutexAfterSendFrame(NsSmartDeviceLink::NsTransportManager::tConnectionHandle, const uint8_t *, size_t, int UserData)
-{
- pthread_mutex_unlock(&mMutex);
-}
-
-test::components::TransportManager::MultipleTransportAdaptersTest::TestTransportManager::TestTransportManager(test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter * (& TransportAdapters)[test::components::TransportManager::MultipleTransportAdaptersTest::cNumberOfMockTransportAdapters]):
-CTransportManager(),
-mMockTransportAdapters(TransportAdapters)
-{
-}
-
-test::components::TransportManager::MultipleTransportAdaptersTest::TestTransportManager::~TestTransportManager(void)
-{
-}
-
-void test::components::TransportManager::MultipleTransportAdaptersTest::TestTransportManager::initializeTransportAdapters(void)
-{
- std::for_each(&mMockTransportAdapters[0], &mMockTransportAdapters[cNumberOfMockTransportAdapters], [this] (MockTransportAdapter * TransportAdapter) {addTransportAdapter(TransportAdapter);});
-}
-
-MATCHER_P(ContainsSameElements, value, "Matches two containers if they contain the same set of elements regardless of order")
-{
- bool result = false;
-
- typedef typename test::components::TransportManager::MultipleTransportAdaptersTest::TRemoveReference<arg_type>::tType::const_iterator tIteratorType;
-
- if (arg.size() == value.size())
- {
- std::set<tIteratorType> matchedValueIterators;
- tIteratorType ai;
-
- for (ai = arg.begin(); ai != arg.end(); ++ai)
- {
- tIteratorType vi;
-
- for (vi = value.begin(); vi != value.end(); ++vi)
- {
- if (matchedValueIterators.end() == matchedValueIterators.find(vi))
- {
- if (*vi == *ai)
- {
- matchedValueIterators.insert(vi);
- break;
- }
- }
- }
-
- if (value.end() == vi)
- {
- break;
- }
- }
-
- result = (arg.end() == ai);
- }
-
- return result;
-}
-
-MATCHER_P2(BuffersSame, buffer, size, "Matches two buffers contents")
-{
- bool result = false;
-
- if (size == std::tr1::get<1>(arg))
- {
- result = (0 == memcmp(buffer, std::tr1::get<0>(arg), size));
- }
-
- return result;
-}
-
-#define TRY_LOCK_AND_FAIL_ON_TIMEOUT(mutex) \
- { \
- timespec timeoutTime; \
- \
- clock_gettime(CLOCK_REALTIME, &timeoutTime); \
- timeoutTime.tv_sec += 1; \
- \
- if (0 != pthread_mutex_timedlock(&mutex, &timeoutTime)) \
- { \
- FAIL() << "Mutex lock timeout"; \
- } \
- }
-
-TEST(TransportManager, MultipleTransportAdapters)
-{
- pthread_mutex_t callbacksMutex; // Mutex restricting access to deviceList, mockDataListener and mockDeviceListener
-
- pthread_mutex_init(&callbacksMutex, 0);
-
- test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter * mockTransportAdapters[test::components::TransportManager::MultipleTransportAdaptersTest::cNumberOfMockTransportAdapters];
- std::for_each(&mockTransportAdapters[0], &mockTransportAdapters[test::components::TransportManager::MultipleTransportAdaptersTest::cNumberOfMockTransportAdapters], [&callbacksMutex] (test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter *& TransportAdapter) {TransportAdapter = new test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter(callbacksMutex);});
-
- test::components::TransportManager::MultipleTransportAdaptersTest::MockDataListener mockDataListener(callbacksMutex);
- test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener mockDeviceListener(callbacksMutex);
- test::components::TransportManager::MultipleTransportAdaptersTest::TestTransportManager transportManager(mockTransportAdapters);
-
- std::for_each(&mockTransportAdapters[0], &mockTransportAdapters[test::components::TransportManager::MultipleTransportAdaptersTest::cNumberOfMockTransportAdapters], [] (test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter * TransportAdapter) {EXPECT_CALL(*TransportAdapter, run()).Times(1);});
-
- transportManager.run();
-
- transportManager.addDeviceListener(&mockDeviceListener);
- transportManager.addDataListener(&mockDataListener);
-
- NsSmartDeviceLink::NsTransportManager::tDeviceHandle lastUsedDeviceHandle = 0;
- NsSmartDeviceLink::NsTransportManager::tConnectionHandle lastUsedConnectionHandle = 0;
-
- NsSmartDeviceLink::NsTransportManager::tDeviceList deviceList;
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(::testing::_)).Times(0);
- EXPECT_CALL(mockDeviceListener, onApplicationConnected(::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDeviceListener, onApplicationDisconnected(::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDataListener, onFrameReceived(::testing::_, ::testing::_, ::testing::_)).Times(0);
- EXPECT_CALL(mockDataListener, onFrameSendCompleted(::testing::_, ::testing::_, ::testing::_)).Times(0);
-
- for (int i = 0; i < 10000; ++i)
- {
- size_t deviceAdapterIndex = static_cast<size_t>(rand()) % test::components::TransportManager::MultipleTransportAdaptersTest::cNumberOfMockTransportAdapters;
- test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter & mockTransportAdapter = *mockTransportAdapters[deviceAdapterIndex];
-
- if (NsSmartDeviceLink::NsTransportManager::InvalidDeviceHandle == mockTransportAdapter.mMockDeviceInfo.mDeviceHandle)
- {
- mockTransportAdapter.mMockDeviceInfo.mDeviceHandle = ++lastUsedDeviceHandle;
-
- char deviceNumberString[16];
- sprintf(deviceNumberString, "%d", mockTransportAdapter.mMockDeviceInfo.mDeviceHandle);
-
- mockTransportAdapter.mMockDeviceInfo.mUniqueDeviceId = std::string("id-") + deviceNumberString;
- mockTransportAdapter.mMockDeviceInfo.mUserFriendlyName = std::string("Name ") + deviceNumberString;
-
- NsSmartDeviceLink::NsTransportManager::tInternalDeviceList internalDeviceList;
- internalDeviceList.push_back(NsSmartDeviceLink::NsTransportManager::SInternalDeviceInfo(mockTransportAdapter.mMockDeviceInfo.mDeviceHandle, mockTransportAdapter.mMockDeviceInfo.mUserFriendlyName, mockTransportAdapter.mMockDeviceInfo.mUniqueDeviceId));
-
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- deviceList.push_back(mockTransportAdapter.mMockDeviceInfo);
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(ContainsSameElements(deviceList)))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDeviceListener, &test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener::unlockMutexAfterDeviceListUpdate))
- .RetiresOnSaturation();
-
- transportManager.onDeviceListUpdated(&mockTransportAdapter, internalDeviceList);
- }
- else if (NsSmartDeviceLink::NsTransportManager::InvalidConnectionHandle == mockTransportAdapter.mMockConnectionHandle)
- {
- if (0 == rand() % 2)
- {
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- for (auto i = deviceList.begin(); i != deviceList.end(); ++i)
- {
- if (i->mDeviceHandle == mockTransportAdapter.mMockDeviceInfo.mDeviceHandle)
- {
- deviceList.erase(i);
- break;
- }
- }
-
- mockTransportAdapter.mMockDeviceInfo.mDeviceHandle = NsSmartDeviceLink::NsTransportManager::InvalidDeviceHandle;
-
- NsSmartDeviceLink::NsTransportManager::tInternalDeviceList internalDeviceList;
-
- EXPECT_CALL(mockDeviceListener, onDeviceListUpdated(ContainsSameElements(deviceList)))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDeviceListener, &test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener::unlockMutexAfterDeviceListUpdate))
- .RetiresOnSaturation();
-
- transportManager.onDeviceListUpdated(&mockTransportAdapter, internalDeviceList);
- }
- else
- {
- mockTransportAdapter.mMockConnectionHandle = ++lastUsedConnectionHandle;
-
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDeviceListener, onApplicationConnected(mockTransportAdapter.mMockDeviceInfo, mockTransportAdapter.mMockConnectionHandle))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDeviceListener, &test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener::unlockMutexAfterApplicationConnectedDisconnected))
- .RetiresOnSaturation();
-
- transportManager.onApplicationConnected(&mockTransportAdapter, mockTransportAdapter.mMockDeviceInfo, mockTransportAdapter.mMockConnectionHandle);
- }
- }
- else
- {
- static const uint8_t frameData[16] = {0x11, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08};
-
- if (0 == rand() % 2)
- {
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDataListener, onFrameReceived(mockTransportAdapter.mMockConnectionHandle, ::testing::_, ::testing::_))
- .With(::testing::Args<1, 2>(BuffersSame(frameData, sizeof(frameData))))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDataListener, &test::components::TransportManager::MultipleTransportAdaptersTest::MockDataListener::unlockMutexAfterFrameReceived))
- .RetiresOnSaturation();
-
- transportManager.onFrameReceived(&mockTransportAdapter, mockTransportAdapter.mMockConnectionHandle, frameData, sizeof(frameData));
- }
- else if (0 == rand() % 2)
- {
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- mockTransportAdapter.mMockUserData = rand();
-
- EXPECT_CALL(mockTransportAdapter, sendFrame(mockTransportAdapter.mMockConnectionHandle, ::testing::_, ::testing::_, mockTransportAdapter.mMockUserData))
- .With(::testing::Args<1, 2>(BuffersSame(frameData, sizeof(frameData))))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockTransportAdapter, &test::components::TransportManager::MultipleTransportAdaptersTest::MockTransportAdapter::unlockMutexAfterSendFrame))
- .RetiresOnSaturation();
-
- transportManager.sendFrame(mockTransportAdapter.mMockConnectionHandle, frameData, sizeof(frameData), mockTransportAdapter.mMockUserData);
-
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDataListener, onFrameSendCompleted(mockTransportAdapter.mMockConnectionHandle, mockTransportAdapter.mMockUserData, NsSmartDeviceLink::NsTransportManager::SendStatusOK))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDataListener, &test::components::TransportManager::MultipleTransportAdaptersTest::MockDataListener::unlockMutexAfterFrameSendCompleted))
- .RetiresOnSaturation();
-
- transportManager.onFrameSendCompleted(&mockTransportAdapter, mockTransportAdapter.mMockConnectionHandle, mockTransportAdapter.mMockUserData, NsSmartDeviceLink::NsTransportManager::SendStatusOK);
- }
- else
- {
- TRY_LOCK_AND_FAIL_ON_TIMEOUT(callbacksMutex);
-
- EXPECT_CALL(mockDeviceListener, onApplicationDisconnected(mockTransportAdapter.mMockDeviceInfo, mockTransportAdapter.mMockConnectionHandle))
- .Times(1)
- .WillOnce(::testing::Invoke(&mockDeviceListener, &test::components::TransportManager::MultipleTransportAdaptersTest::MockDeviceListener::unlockMutexAfterApplicationConnectedDisconnected))
- .RetiresOnSaturation();
-
- transportManager.onApplicationDisconnected(&mockTransportAdapter, mockTransportAdapter.mMockDeviceInfo, mockTransportAdapter.mMockConnectionHandle);
-
- mockTransportAdapter.mMockConnectionHandle = NsSmartDeviceLink::NsTransportManager::InvalidConnectionHandle;
- }
- }
- }
-
- pthread_mutex_destroy(&callbacksMutex);
-
- sleep(1);
-}
-
-int main(int argc, char **argv)
-{
- PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus_disabled.properties"));
-
- ::testing::InitGoogleMock(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/include/transport_manager/mock_application.h b/test/components/transport_manager/include/transport_manager/mock_application.h
deleted file mode 100644
index b8caa1f32..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_application.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * mock_application.h
- *
- * 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 MOCK_APPLICATION_H_
-#define MOCK_APPLICATION_H_
-
-#include <pthread.h>
-
-#include <sstream>
-#include <string>
-
-#include <transport_manager/common.h>
-#include <transport_manager/transport_manager.h>
-#include <transport_manager/transport_adapter/transport_adapter_impl.h>
-#include <transport_manager/transport_manager_impl.h>
-#include <transport_manager/mock_device_scanner.h>
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-class MockDevice;
-using ::transport_manager::ApplicationHandle;
-
-class MockApplication {
- public:
- const MockDevice *device;
- ApplicationHandle handle;
- pthread_t workerThread;
- pthread_cond_t ready_cond;
- pthread_mutex_t ready_mutex;
- int sockfd;
- bool active;
- private:
- std::string socket_name_;
- public:
- MockApplication(const MockDevice* device, ApplicationHandle id);
- void Start();
- void Stop();
- const std::string &socket_name() const {
- return socket_name_;
- }
-};
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* MOCK_APPLICATION_H_ */
diff --git a/test/components/transport_manager/include/transport_manager/mock_connection.h b/test/components/transport_manager/include/transport_manager/mock_connection.h
deleted file mode 100644
index 8f6710706..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_connection.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * \file mock_connection.h
- * \brief
- *
- * 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 APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKCONNECTION_H_
-#define APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKCONNECTION_H_
-
-#include "transport_manager/common.h"
-#include "transport_manager/error.h"
-#include "transport_manager/transport_adapter/transport_adapter_impl.h"
-#include "transport_manager/transport_adapter/threaded_socket_connection.h"
-
-using ::transport_manager::ApplicationHandle;
-using ::transport_manager::DeviceHandle;
-using ::transport_manager::transport_adapter::Connection;
-using ::transport_manager::transport_adapter::TransportAdapterController;
-using ::transport_manager::ConnectError;
-using ::transport_manager::transport_adapter::ThreadedSocketConnection;
-using ::transport_manager::transport_adapter::TransportAdapter;
-namespace test {
-namespace components {
-namespace transport_manager {
-
-class MockTransportAdapter;
-
-class MockConnection : public ThreadedSocketConnection{
- public:
- MockConnection(const ::transport_manager::DeviceUID& device_handle,
- const ApplicationHandle& app_handle,
- TransportAdapterController* adapter);
- bool Establish(ConnectError **error);
-};
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKCONNECTION_H_ */
diff --git a/test/components/transport_manager/include/transport_manager/mock_connection_factory.h b/test/components/transport_manager/include/transport_manager/mock_connection_factory.h
deleted file mode 100644
index afead19cb..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_connection_factory.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * \file mock_connection_factory.h
- * \brief
- *
- * 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 APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKCONNECTIONFACTORY_H_
-#define APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKCONNECTIONFACTORY_H_
-
-#include "transport_manager/transport_adapter/server_connection_factory.h"
-
-using ::transport_manager::ApplicationHandle;
-using ::transport_manager::DeviceHandle;
-using ::transport_manager::transport_adapter::TransportAdapter;
-using ::transport_manager::transport_adapter::ServerConnectionFactory;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-class MockTransportAdapter;
-
-class MockConnectionFactory : public ServerConnectionFactory {
- public:
- MockConnectionFactory(MockTransportAdapter *adapter);
- TransportAdapter::Error Init() { return TransportAdapter::OK; }
- TransportAdapter::Error CreateConnection(const ::transport_manager::DeviceUID& device_handle,
- const ApplicationHandle& app_handle);
- void Terminate() {}
- bool IsInitialised() const { return true; }
-
- private:
- MockTransportAdapter *controller_;
-};
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKCONNECTIONFACTORY_H_ */
diff --git a/test/components/transport_manager/include/transport_manager/mock_device.h b/test/components/transport_manager/include/transport_manager/mock_device.h
deleted file mode 100644
index 6b0efbb51..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_device.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * \file mock_device.h
- * \brief
- *
- * 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 APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICE_H_
-#define APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICE_H_
-
-#include "transport_manager/common.h"
-#include "transport_manager/transport_adapter/transport_adapter_impl.h"
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-#include <transport_manager/transport_adapter/transport_adapter_impl.h>
-#include <transport_manager/transport_manager_impl.h>
-#include <transport_manager/mock_device_scanner.h>
-#include <transport_manager/mock_application.h>
-
-using ::transport_manager::ApplicationList;
-using ::transport_manager::transport_adapter::Device;
-using ::transport_manager::transport_adapter::TransportAdapterController;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-class MockDevice : public ::transport_manager::transport_adapter::Device {
-
- pthread_mutex_t device_started_mutex;
- std::vector<MockApplication> applications_;
- int applications_cnt_;
- TransportAdapterController *controller_;
- public:
- MockDevice(const std::string& name, const std::string& id,
- TransportAdapterController * controller)
- : Device(name, id),
- applications_cnt_(0),
- controller_(controller) {
- }
- const ApplicationHandle addApplication();
- void Start();
- void Stop();
- bool IsSameAs(const Device* other) const;
- ApplicationList GetApplicationList() const;
- bool operator == (const MockDevice &other);
-};
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICE_H_ */
diff --git a/test/components/transport_manager/include/transport_manager/mock_device_scanner.h b/test/components/transport_manager/include/transport_manager/mock_device_scanner.h
deleted file mode 100644
index 6ebae39a7..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_device_scanner.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * \file mock_device_scanner.h
- * \brief
- *
- * 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 APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICESCANNER_H_
-#define APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICESCANNER_H_
-
-#include "transport_manager/transport_adapter/device_scanner.h"
-
-using ::transport_manager::transport_adapter::TransportAdapter;
-using ::transport_manager::transport_adapter::DeviceScanner;
-using ::transport_manager::transport_adapter::DeviceVector;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-class MockTransportAdapter;
-
-class MockDeviceScanner : public DeviceScanner {
- public:
- MockDeviceScanner(MockTransportAdapter *adapter);
- void reset();
- void AddDevice(const std::string& name, const std::string& unique_id, bool start = true);
- void RemoveDevice(const std::string& name);
- void fail_further_search() { is_search_failed_ = true; }
-
- protected:
- TransportAdapter::Error Init();
- TransportAdapter::Error Scan();
- void Terminate();
- bool IsInitialised() const;
-
- private:
- MockTransportAdapter *controller_;
- DeviceVector devices_;
- bool is_initialized_;
- bool is_search_failed_;
-};
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICESCANNER_H_ */
diff --git a/test/components/transport_manager/include/transport_manager/mock_transport_adapter.h b/test/components/transport_manager/include/transport_manager/mock_transport_adapter.h
deleted file mode 100644
index fef37f9b8..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_transport_adapter.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * \file mock_transport_adapter.h
- * \brief
- *
- * 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 APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICEADAPTER_H_
-#define APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICEADAPTER_H_
-
-#include "transport_manager/transport_adapter/transport_adapter_impl.h"
-
-using ::transport_manager::transport_adapter::TransportAdapterImpl;
-using ::transport_manager::transport_adapter::DeviceType;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-class MockDeviceScanner;
-
-class MockTransportAdapter : public TransportAdapterImpl {
- public:
- MockTransportAdapter();
- MockDeviceScanner* get_device_scanner() const;
- DeviceType GetDeviceType() const { return "mock-adapter"; }
- void reset();
-};
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* APPLINK_TEST_COMPONENTS_TRANSPORTMANAGER_INCLUDE_MOCKDEVICEADAPTER_H_ */
diff --git a/test/components/transport_manager/include/transport_manager/mock_transport_adapter_listener.h b/test/components/transport_manager/include/transport_manager/mock_transport_adapter_listener.h
deleted file mode 100644
index 767291152..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_transport_adapter_listener.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * \file mock_transport_adapter_listener.h
- * \brief
- *
- * 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 MOCK_transport_adapter_LISTENER_H_
-#define MOCK_transport_adapter_LISTENER_H_
-
-#include <gmock/gmock.h>
-
-#include "transport_manager/transport_adapter/transport_adapter_listener.h"
-
-using namespace transport_manager;
-using transport_manager::transport_adapter::TransportAdapter;
-using transport_manager::transport_adapter::TransportAdapterListener;
-using ::protocol_handler::RawMessagePtr;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-using namespace ::protocol_handler;
-
-class MockTransportAdapterListener : public TransportAdapterListener {
- public:
- MOCK_METHOD1(OnSearchDeviceDone,
- void(const TransportAdapter* transport_adapter));
- MOCK_METHOD2(OnSearchDeviceFailed,
- void(const TransportAdapter* transport_adapter, const SearchDeviceError& error));
- MOCK_METHOD1(OnFindNewApplicationsRequest,
- void(const TransportAdapter* adapter));
- MOCK_METHOD1(OnDeviceListUpdated,
- void(const TransportAdapter* transport_adapter));
- MOCK_METHOD3(OnConnectDone,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle));
- MOCK_METHOD4(OnConnectFailed,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle, const ConnectError& error));
- MOCK_METHOD4(OnUnexpectedDisconnect,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle, const CommunicationError& error));
- MOCK_METHOD3(OnDisconnectDone,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle));
- MOCK_METHOD4(OnDisconnectFailed,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle, const DisconnectError& error));
- MOCK_METHOD2(OnDisconnectDeviceDone,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle));
- MOCK_METHOD3(OnDisconnectDeviceFailed,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const DisconnectDeviceError& error));
- MOCK_METHOD4(OnDataSendDone,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle, const RawMessagePtr data_container));
- MOCK_METHOD5(OnDataSendFailed,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle, const RawMessagePtr data_container, const DataSendError& error));
- MOCK_METHOD4(OnDataReceiveDone,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle, const RawMessagePtr data_container));
- MOCK_METHOD4(OnDataReceiveFailed,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle, const DataReceiveError& error));
- MOCK_METHOD3(OnCommunicationError,
- void(const TransportAdapter* transport_adapter, const DeviceUID& device_handle, const ApplicationHandle& app_handle));
- MOCK_METHOD3(OnConnectRequested, void(const TransportAdapter*, const DeviceUID&, const ApplicationHandle&));
-};
-
-}
-}
-}
-
-#endif /* MOCK_transport_adapter_LISTENER_H_ */
diff --git a/test/components/transport_manager/include/transport_manager/mock_transport_manager_listener.h b/test/components/transport_manager/include/transport_manager/mock_transport_manager_listener.h
deleted file mode 100644
index 9518e1a92..000000000
--- a/test/components/transport_manager/include/transport_manager/mock_transport_manager_listener.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * \file mock_transport_adapter_listener.h
- * \brief
- *
- * 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 MOCK_TRANSPORT_MANAGER_LISTENER_H
-#define MOCK_TRANSPORT_MANAGER_LISTENER_H
-
-#include <gmock/gmock.h>
-
-#include "transport_manager/common.h"
-#include "transport_manager/info.h"
-#include "transport_manager/transport_adapter/transport_adapter.h"
-#include "transport_manager/transport_manager_listener.h"
-
-using ::transport_manager::ApplicationList;
-using ::transport_manager::ApplicationHandle;
-using ::transport_manager::transport_adapter::TransportAdapter;
-using ::transport_manager::SearchDeviceError;
-using ::transport_manager::ConnectionUID;
-using ::transport_manager::ConnectError;
-using ::transport_manager::DisconnectError;
-using ::transport_manager::DisconnectDeviceError;
-using ::transport_manager::DataSendError;
-using ::transport_manager::DataReceiveError;
-using ::transport_manager::CommunicationError;
-using ::transport_manager::DeviceInfo;
-using ::transport_manager::DeviceHandle;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-class MockTransportManagerListener :
- public ::transport_manager::TransportManagerListener {
- public:
- MOCK_METHOD1(OnDeviceListUpdated, void(const std::vector<DeviceInfo>&));
- MOCK_METHOD0(OnFindNewApplicationsRequest, void());
- MOCK_METHOD1(OnDeviceFound, void(const DeviceInfo &device_info));
- MOCK_METHOD1(OnDeviceAdded, void(const DeviceInfo &device_info));
- MOCK_METHOD1(OnDeviceRemoved, void(const DeviceInfo &device_info));
- MOCK_METHOD0(OnNoDeviceFound, void());
- MOCK_METHOD0(OnScanDevicesFinished, void());
- MOCK_METHOD1(OnScanDevicesFailed, void(const SearchDeviceError& error));
-
- MOCK_METHOD2(OnConnectionEstablished, void(const DeviceInfo& device_info,
- const ConnectionUID &connection_id));
- MOCK_METHOD2(OnConnectionFailed, void(const DeviceInfo& device_info,
- const ConnectError& error));
-
- MOCK_METHOD1(OnConnectionClosed, void(ConnectionUID connection_id));
- MOCK_METHOD2(OnConnectionClosedFailure, void (ConnectionUID connection_id,
- const DisconnectError& error));
- MOCK_METHOD2(OnUnexpectedDisconnect, void (ConnectionUID connection_id,
- const CommunicationError& error));
- MOCK_METHOD2(OnDeviceConnectionLost, void (const DeviceHandle& device,
- const DisconnectDeviceError& error));
- MOCK_METHOD2(OnDisconnectFailed, void (const DeviceHandle& device,
- const DisconnectDeviceError& error));
-
- MOCK_METHOD1(OnTMMessageReceived, void(const RawMessagePtr data_container));
- MOCK_METHOD2(OnTMMessageReceiveFailed, void(ConnectionUID connection_id,
- const DataReceiveError& error));
- MOCK_METHOD1(OnTMMessageSend, void(const RawMessagePtr message));
- MOCK_METHOD2(OnTMMessageSendFailed, void(const DataSendError& error,
- const RawMessagePtr message));
-};
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* MOCK_TRANSPORT_MANAGER_LISTENER_H */
diff --git a/test/components/transport_manager/include/transport_manager/raw_message_matcher.h b/test/components/transport_manager/include/transport_manager/raw_message_matcher.h
deleted file mode 100644
index 899e6e3b2..000000000
--- a/test/components/transport_manager/include/transport_manager/raw_message_matcher.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * \file raw_message_matcher.h
- * \brief matcher RawMessagePtr
- *
- * 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 APPLINK_TEST_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_RAW_MESSAGE_MATCHER_H_
-#define APPLINK_TEST_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_RAW_MESSAGE_MATCHER_H_
-
-#include <gmock/gmock.h>
-
-#include "transport_manager/common.h"
-#include "protocol/common.h"
-
-using ::testing::Matcher;
-using ::testing::MatcherInterface;
-using ::testing::MatchResultListener;
-
-using RawMessagePtr = ::protocol_handler::RawMessagePtr;
-using RawMessage = ::protocol_handler::RawMessage;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-using namespace ::protocol_handler;
-
-class RawMessageMatcher : public MatcherInterface<RawMessagePtr> {
- public:
- explicit RawMessageMatcher(RawMessagePtr ptr);
-
- virtual bool MatchAndExplain(const RawMessagePtr ptr,
- MatchResultListener* listener) const;
- virtual void DescribeTo(::std::ostream* os) const;
- virtual void DescribeNegationTo(::std::ostream* os) const;
-
- private:
- const RawMessagePtr ptr_;
-};
-
-inline const Matcher<RawMessagePtr> RawMessageEq(RawMessagePtr msg) {
- return MakeMatcher(new RawMessageMatcher(msg));
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-#endif /* APPLINK_TEST_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_RAW_MESSAGE_MATCHER_H_ */
diff --git a/test/components/transport_manager/log4cplus.properties b/test/components/transport_manager/log4cplus.properties
deleted file mode 100644
index 81d08328f..000000000
--- a/test/components/transport_manager/log4cplus.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-# Main application logging
-log4cplus.logger.appMain=TRACE, A1
-
-# TransportManager logging
-log4cplus.logger.TransportManager=TRACE, A1
-log4cplus.logger.BluetoothAdapter=TRACE, A1
-
-#log4cplus.logger.TransportManager=ERROR, A1
-#log4cplus.logger.BluetoothAdapter=ERROR, A1
-
-# TransportManagerTest logging
-log4cplus.logger.TransportManagerTest=TRACE, A1
-
-log4cplus.appender.A1=log4cplus::ConsoleAppender
-log4cplus.appender.A1.ImmediateFlush=true
-log4cplus.appender.A1.layout=log4cplus::PatternLayout
-log4cplus.appender.A1.layout.ConversionPattern=%-5p [%d{%H:%M:%S:%q}] %m%n
-#log4cplus.appender.A1.layout.ConversionPattern=%l [%t] %M: %m%n
-
diff --git a/test/components/transport_manager/log4cplus_disabled.properties b/test/components/transport_manager/log4cplus_disabled.properties
deleted file mode 100644
index b6f3521ba..000000000
--- a/test/components/transport_manager/log4cplus_disabled.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-# TransportManager logging
-log4cplus.logger.TransportManager=OFF
-log4cplus.logger.BluetoothAdapter=OFF
diff --git a/test/components/transport_manager/log4cxx.properties b/test/components/transport_manager/log4cxx.properties
deleted file mode 100644
index b38f37353..000000000
--- a/test/components/transport_manager/log4cxx.properties
+++ /dev/null
@@ -1,57 +0,0 @@
-# Log for all SmartDeviceLinkCoreSocketHub messages
-#log4j.appender.SmartDeviceLinkCoreSocketHub=org.apache.log4j.net.SocketHubAppender
-#log4j.appender.SmartDeviceLinkCoreSocketHub.port=4555
-#log4j.appender.SmartDeviceLinkCoreSocketHub.locationInfo=true
-
-# Only ERROR and FATAL messages are logged to console
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.ImmediateFlush=true
-log4j.appender.Console.layout=org.apache.log4j.PatternLayout
-log4j.appender.Console.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %m%n
-log4j.appender.Console.Threshold=ERROR
-
-# Log for all SmartDeviceLinkCore messages
-#log4j.appender.SmartDeviceLinkCoreLogFile=org.apache.log4j.DailyRollingFileAppender
-#log4j.appender.SmartDeviceLinkCoreLogFile.File=SmartDeviceLinkCore.log
-#log4j.appender.SmartDeviceLinkCoreLogFile.ImmediateFlush=true
-#log4j.appender.SmartDeviceLinkCoreLogFile.layout=org.apache.log4j.PatternLayout
-#log4j.appender.SmartDeviceLinkCoreLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-#log4j.appender.SmartDeviceLinkCoreLogFile.Schedule=DAILY
-#log4j.appender.SmartDeviceLinkCoreLogFile.DatePattern='.' yyyy-MM-dd
-
-# Log for SmartDeviceLinkCore WARN, ERROR and FATAL messages
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile=org.apache.log4j.DailyRollingFileAppender
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile.File=SmartDeviceLinkCoreWarn.log
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile.ImmediateFlush=true
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile.layout=org.apache.log4j.PatternLayout
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile.Threshold=WARN
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile.Schedule=DAILY
-#log4j.appender.SmartDeviceLinkCoreWarnLogFile.DatePattern='.' yyyy-MM-dd
-
-# Log for all TransportManager messages
-log4j.appender.TransportManagerLogFile=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.TransportManagerLogFile.File=TransportManager.log
-log4j.appender.TransportManagerLogFile.ImmediateFlush=true
-log4j.appender.TransportManagerLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.TransportManagerLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}] :%L %M: %m%n
-log4j.appender.TransportManagerLogFile.Schedule=DAILY
-log4j.appender.TransportManagerLogFile.DatePattern='.' yyyy-MM-dd
-
-# Log for all ProtocolHandler messages
-log4j.appender.ProtocolHandlerLogFile=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.ProtocolHandlerLogFile.File=ProtocolHandler.log
-log4j.appender.ProtocolHandlerLogFile.ImmediateFlush=true
-log4j.appender.ProtocolHandlerLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.ProtocolHandlerLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}] :%L %M: %m%n
-log4j.appender.ProtocolHandlerLogFile.Schedule=DAILY
-log4j.appender.ProtocolHandlerLogFile.DatePattern='.' yyyy-MM-dd
-
-# All SmartDeviceLinkCore logs
-#log4j.rootLogger=ALL, Console, SmartDeviceLinkCoreLogFile, SmartDeviceLinkCoreWarnLogFile, SmartDeviceLinkCoreSocketHub
-
-# TransportManager logs
-log4j.logger.TransportManager=ALL, TransportManagerLogFile
-
-# ProtocolHandler logs
-log4j.logger.ProtocolHandler=ALL, ProtocolHandlerLogFile \ No newline at end of file
diff --git a/test/components/transport_manager/src/mock_application.cc b/test/components/transport_manager/src/mock_application.cc
deleted file mode 100644
index d9f2bf14d..000000000
--- a/test/components/transport_manager/src/mock_application.cc
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * mock_application.cc
- *
- * 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.
- */
-
-#include <pthread.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <transport_manager/mock_application.h>
-#include <transport_manager/mock_device.h>
-
-namespace {
-
-struct workerData {
- int sockfd;
-};
-
-void *applicationWorker(void *p) {
- workerData *data = static_cast<workerData*>(p);
- char *buf = new char[2 * 1024 * 1024];
- ssize_t len;
-
- while (true) {
- len = recv(data->sockfd, buf, 2 * 1024 * 1024, 0);
- if (len == 0)
- break;
- send(data->sockfd, buf, len, 0);
- }
- delete[] buf;
- delete data;
- return NULL;
-}
-
-void * applicationListener(void *p) {
- using test::components::transport_manager::MockApplication;
- MockApplication *app = static_cast<MockApplication*>(p);
-
- unlink(app->socket_name().c_str());
-
- app->sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (app->sockfd == -1) {
- // TODO: indicate error
- return NULL;
- }
- sockaddr_un my_addr;
- memset(&my_addr, 0, sizeof(my_addr));
- strcpy(my_addr.sun_path, app->socket_name().c_str());
- my_addr.sun_family = AF_UNIX;
- int res = bind(app->sockfd, reinterpret_cast<sockaddr*>(&my_addr),
- sizeof(my_addr));
- if (res == -1) {
- return NULL;
- }
-
- res = listen(app->sockfd, 5);
- if (res == -1) {
- return NULL;
- }
-
- pthread_mutex_lock(&app->ready_mutex);
- app->active = true;
- pthread_cond_signal(&app->ready_cond);
- pthread_mutex_unlock(&app->ready_mutex);
-
- while (app->active) {
- socklen_t addr_size;
- sockaddr peer_addr;
-
- int peer_socket = accept(app->sockfd, &peer_addr, &addr_size);
- if (peer_socket != -1) {
- pthread_t t;
- workerData* data = new workerData();
- data->sockfd = peer_socket;
- pthread_create(&t, NULL, &applicationWorker, data);
- }
- }
-
- unlink(app->socket_name().c_str());
-
- return NULL;
-}
-}
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-MockApplication::MockApplication(const MockDevice *device, ApplicationHandle id)
- : device(device),
- handle(id),
- workerThread(0),
- sockfd(-1),
- active(false) {
- std::ostringstream oss;
- oss << "mockDevice" << device->unique_device_id() << "-" << id;
- socket_name_ = oss.str();
-}
-
-void MockApplication::Start() {
-
- pthread_cond_init(&ready_cond, NULL);
- pthread_mutex_init(&ready_mutex, NULL);
-
- pthread_mutex_lock(&ready_mutex);
- pthread_create(&workerThread, NULL, &applicationListener, this);
- pthread_cond_wait(&ready_cond, &ready_mutex);
- pthread_mutex_unlock(&ready_mutex);
-}
-
-void MockApplication::Stop() {
- active = false;
- shutdown(sockfd, SHUT_RDWR);
- close(sockfd);
- pthread_join(workerThread, NULL);
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
diff --git a/test/components/transport_manager/src/mock_connection.cc b/test/components/transport_manager/src/mock_connection.cc
deleted file mode 100644
index 589716ed1..000000000
--- a/test/components/transport_manager/src/mock_connection.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * \file mock_connection.cc
- * \brief
- *
- * 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.
- */
-
-#include <cstring>
-
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sstream>
-#include "transport_manager/common.h"
-#include "transport_manager/mock_connection.h"
-
-<<<<<<< HEAD:test/components/transport_manager/src/mock_connection.cc
-#include <algorithm>
-=======
-DeviceType MmeTransportAdapter::GetDeviceType() const {
- return MME;
-}
->>>>>>> 35db1ec... APPLINK-12266. Implement ability to handle transport type.:src/components/transport_manager/src/mme/mme_transport_adapter.cc
-
-#include "transport_manager/mock_transport_adapter.h"
-
-using ::transport_manager::transport_adapter::TransportAdapterController;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-MockConnection::MockConnection(const ::transport_manager::DeviceUID& device_handle,
- const ApplicationHandle& app_handle,
- TransportAdapterController* controller)
- : ThreadedSocketConnection(device_handle, app_handle, controller) {
-}
-
-bool MockConnection::Establish(ConnectError **error) {
- int peer_sock = socket(AF_UNIX, SOCK_STREAM, 0);
- sockaddr_un my_addr;
- memset(&my_addr, 0, sizeof(my_addr));
- std::ostringstream iss;
- iss << "mockDevice" << device_handle() << "-" << application_handle();
- strcpy(my_addr.sun_path, iss.str().c_str());
- my_addr.sun_family = AF_UNIX;
- int res = ::connect(peer_sock, reinterpret_cast<sockaddr*>(&my_addr),
- sizeof(my_addr));
- if (res != -1) {
- set_socket(peer_sock);
- return true;
- }
- *error = new ConnectError();
- return false;
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
diff --git a/test/components/transport_manager/src/mock_connection_factory.cc b/test/components/transport_manager/src/mock_connection_factory.cc
deleted file mode 100644
index 1eb3e34a4..000000000
--- a/test/components/transport_manager/src/mock_connection_factory.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * \file mock_connection_factory.cc
- * \brief
- *
- * 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.
- */
-
-
-#include <transport_manager/mock_connection.h>
-#include "transport_manager/mock_connection_factory.h"
-
-#include <algorithm>
-
-#include "transport_manager/mock_device.h"
-#include "transport_manager/mock_transport_adapter.h"
-
-using ::transport_manager::transport_adapter::DeviceSptr;
-using ::transport_manager::ConnectError;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-MockConnectionFactory::MockConnectionFactory(MockTransportAdapter *controller)
- : controller_(controller) {}
-
-TransportAdapter::Error MockConnectionFactory::CreateConnection(
- const ::transport_manager::DeviceUID& device_handle,
- const ApplicationHandle& app_handle) {
-
- MockConnection *conn = new MockConnection(device_handle, app_handle, controller_);
- conn->Start();
- return TransportAdapter::OK;
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
diff --git a/test/components/transport_manager/src/mock_device.cc b/test/components/transport_manager/src/mock_device.cc
deleted file mode 100644
index a021acfbe..000000000
--- a/test/components/transport_manager/src/mock_device.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * \file mock_device.cc
- *
- * 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.
- */
-
-#include "transport_manager/mock_device.h"
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-const ApplicationHandle MockDevice::addApplication() {
- MockApplication app(this, applications_cnt_++);
- app.device = this;
- app.active = false;
- applications_.push_back(app);
- return app.handle;
-}
-
-void MockDevice::Start() {
- for (std::vector<MockApplication>::iterator it = applications_.begin();
- it != applications_.end();
- ++it) {
- it->Start();
- }
-}
-
-void MockDevice::Stop() {
- for (std::vector<MockApplication>::iterator it = applications_.begin();
- it != applications_.end();
- ++it) {
- it->Stop();
- }
-}
-
-bool MockDevice::IsSameAs(const Device* other) const {
- return unique_device_id() == other->unique_device_id();
-}
-
-static ApplicationHandle get_handle(const MockApplication& app) {
- return app.handle;
-}
-
-ApplicationList MockDevice::GetApplicationList() const {
- ApplicationList rc(applications_.size());
- std::transform(
- applications_.begin(), applications_.end(), rc.begin(),
- &get_handle);
- return rc;
-}
-
-bool MockDevice::operator ==(const MockDevice& other) {
- return IsSameAs(&other);
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
diff --git a/test/components/transport_manager/src/mock_device_scanner.cc b/test/components/transport_manager/src/mock_device_scanner.cc
deleted file mode 100644
index 4a08e205d..000000000
--- a/test/components/transport_manager/src/mock_device_scanner.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * \file mock_device_scanner.cc
- * \brief
- *
- * 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.
- */
-
-#include "transport_manager/mock_device_scanner.h"
-#include "transport_manager/mock_transport_adapter.h"
-#include "transport_manager/mock_device.h"
-
-using ::transport_manager::SearchDeviceError;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-MockDeviceScanner::MockDeviceScanner(MockTransportAdapter *controller)
- : controller_(controller),
- is_initialized_(false),
- is_search_failed_(false) {
-}
-
-TransportAdapter::Error MockDeviceScanner::Init() {
- is_initialized_ = true;
- return TransportAdapter::OK;
-}
-
-TransportAdapter::Error MockDeviceScanner::Scan() {
- if (is_search_failed_) {
- controller_->SearchDeviceFailed(SearchDeviceError());
- } else {
- controller_->SearchDeviceDone(devices_);
- }
- return TransportAdapter::OK;
-}
-
-void MockDeviceScanner::Terminate() {
-}
-
-void MockDeviceScanner::reset() {
- is_search_failed_ = false;
- for (DeviceVector::iterator it = devices_.begin();
- it != devices_.end();
- ++it) {
- static_cast<MockDevice*>(it->get())->Stop();
- }
- devices_.clear();
-}
-
-bool MockDeviceScanner::IsInitialised() const {
- return is_initialized_;
-}
-
-void MockDeviceScanner::AddDevice(const std::string& name,
- const std::string& unique_id, bool start) {
- MockDevice* dev = new MockDevice(name, unique_id, controller_);
- dev->addApplication();
- if (start) {
- dev->Start();
- }
- devices_.push_back(dev);
-}
-
-void MockDeviceScanner::RemoveDevice(const std::string& name) {
- for (DeviceVector::iterator t = devices_.begin(); t != devices_.end(); ++t) {
- if ((*t)->name() == name) {
- devices_.erase(t);
- break;
- }
- }
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-// vim: set ts=2 sw=2 et:
diff --git a/test/components/transport_manager/src/mock_transport_adapter.cc b/test/components/transport_manager/src/mock_transport_adapter.cc
deleted file mode 100644
index 1ff1348b0..000000000
--- a/test/components/transport_manager/src/mock_transport_adapter.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * \file mock_transport_adapter.cc
- * \brief
- *
- * 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.
- */
-
-#include "transport_manager/mock_connection.h"
-#include "transport_manager/mock_device.h"
-#include "transport_manager/mock_transport_adapter.h"
-#include "transport_manager/mock_device_scanner.h"
-#include "transport_manager/mock_connection_factory.h"
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-MockTransportAdapter::MockTransportAdapter()
- : TransportAdapterImpl(new MockDeviceScanner(this),
- new MockConnectionFactory(this), NULL) {}
-
-void MockTransportAdapter::reset() {
- get_device_scanner()->reset();
-}
-
-MockDeviceScanner* MockTransportAdapter::get_device_scanner() const {
- return static_cast<MockDeviceScanner*>(device_scanner_);
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
diff --git a/test/components/transport_manager/src/raw_message_matcher.cc b/test/components/transport_manager/src/raw_message_matcher.cc
deleted file mode 100644
index 510c66221..000000000
--- a/test/components/transport_manager/src/raw_message_matcher.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-<<<<<<< HEAD:test/components/transport_manager/src/raw_message_matcher.cc
-/*
- * \file matchers.cc
- * \brief customers matchers for gmock
- *
- * 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.
- */
-
-#include "transport_manager/raw_message_matcher.h"
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-RawMessageMatcher::RawMessageMatcher(RawMessagePtr ptr)
- : ptr_(ptr) {}
-
-bool RawMessageMatcher::MatchAndExplain(const RawMessagePtr msg,
- MatchResultListener* listener) const {
- if (msg->data_size() != ptr_->data_size()) {
- return ::std::equal(msg->data(), msg->data() + msg->data_size(), ptr_->data());
- } else
- return false;
-}
-
-void RawMessageMatcher::DescribeTo(::std::ostream* os) const {
- *os << "data_ is " ;
- ::std::ostream_iterator<unsigned char> out(*os);
- ::std::copy(ptr_->data(), ptr_->data() + ptr_->data_size(), out);
-}
-
-void RawMessageMatcher::DescribeNegationTo(::std::ostream* os) const {
- *os << "data_ is not " ;
- ::std::ostream_iterator<unsigned char> out(*os);
- ::std::copy(ptr_->data(), ptr_->data() + ptr_->data_size(), out);
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-=======
-/*
- * 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 "transport_manager/pasa_bt/bluetooth_PASA_transport_adapter.h"
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-#include <iomanip>
-#include <set>
-
-#include "transport_manager/pasa_bt/bluetooth_PASA_listener.h"
-#include "transport_manager/pasa_bt/bluetooth_PASA_connection_factory.h"
-#include "transport_manager/pasa_bt/bluetooth_PASA_device.h"
-#include "resumption/last_state.h"
-#include "utils/logger.h"
-
-namespace transport_manager {
-namespace transport_adapter {
-
-CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
-
-BluetoothPASATransportAdapter::BluetoothPASATransportAdapter()
- : TransportAdapterImpl(0, new BluetoothPASAConnectionFactory(this),
- new BluetoothPASAListener(this)) {
-}
-
-DeviceType BluetoothPASATransportAdapter::GetDeviceType() const {
- return PASA_BLUETOOTH;
-}
-
-} // namespace transport_adapter
-} // namespace transport_manager
-
->>>>>>> 35db1ec... APPLINK-12266. Implement ability to handle transport type.:src/components/transport_manager/src/pasa_bt/bluetooth_PASA_transport_adapter.cc
diff --git a/test/components/transport_manager/src/test_dnssd_service_browser.cc b/test/components/transport_manager/src/test_dnssd_service_browser.cc
deleted file mode 100644
index e13e294a5..000000000
--- a/test/components/transport_manager/src/test_dnssd_service_browser.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <netinet/in.h>
-#include <sys/types.h>
-#include <ifaddrs.h>
-
-#include "transport_manager/transport_adapter/transport_adapter_controller.h"
-#include "transport_manager/tcp/dnssd_service_browser.h"
-#include "transport_manager/tcp/tcp_device.h"
-
-namespace transport_manager {
-namespace transport_adapter {
-
-class MockTransportAdapterController : public TransportAdapterController {
- public:
- MOCK_METHOD1(AddDevice,
- DeviceSptr(DeviceSptr device));
- MOCK_METHOD1(SearchDeviceDone,
- void(const DeviceVector& devices));
- MOCK_METHOD1(SearchDeviceFailed,
- void(const SearchDeviceError& error));
- MOCK_CONST_METHOD1(FindDevice,
- DeviceSptr(const DeviceUID& device_handle));
- MOCK_METHOD3(ConnectionCreated,
- void(ConnectionSPtr connection, const DeviceUID& device_handle, const ApplicationHandle& app_handle));
- MOCK_METHOD2(ConnectDone,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle));
- MOCK_METHOD3(ConnectFailed,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle, const ConnectError& error));
- MOCK_METHOD2(ConnectionFinished,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle));
- MOCK_METHOD3(ConnectionAborted,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle, const CommunicationError& error));
- MOCK_METHOD2(DisconnectDone,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle));
- MOCK_METHOD3(DataReceiveDone,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle, RawMessagePtr message));
- MOCK_METHOD3(DataReceiveFailed,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle, const DataReceiveError& error));
- MOCK_METHOD3(DataSendDone,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle, RawMessagePtr message));
- MOCK_METHOD4(DataSendFailed,
- void(const DeviceUID& device_handle, const ApplicationHandle& app_handle, RawMessagePtr message, const DataSendError& error));
-};
-
-in_addr_t GetIfaceAddress() {
- in_addr_t result = 0;
- ifaddrs* if_addrs = NULL;
- void * tmpAddrPtr = NULL;
-
- getifaddrs(&if_addrs);
-
- for (ifaddrs* ifa = if_addrs; ifa != NULL; ifa = ifa->ifa_next) {
- if (ifa->ifa_addr->sa_family == AF_INET) {
- result = ((struct sockaddr_in *) ifa->ifa_addr)->sin_addr.s_addr;
- if (result != htonl(INADDR_LOOPBACK )) {
- break;
- }
- }
- }
- if (if_addrs)
- freeifaddrs(if_addrs);
- return result;
-}
-static in_addr_t iface_address = GetIfaceAddress();
-
-MATCHER_P(HasService, service_port, ""){
-for(DeviceVector::const_iterator it = arg.begin(); it != arg.end(); ++it) {
- TcpDevice* tcp_device = dynamic_cast<TcpDevice*>(it->get());
- if(tcp_device && tcp_device->in_addr() == iface_address) {
- ApplicationList app_list = tcp_device->GetApplicationList();
- for(ApplicationList::const_iterator it = app_list.begin(); it != app_list.end(); ++it) {
- if(tcp_device->GetApplicationPort(*it) == service_port) {
- return true;
- }
- }
- }
-}
-return false;
-}
-
-TEST(DnssdServiceBrowser, Basic) {
- MockTransportAdapterController controller;
-
- EXPECT_CALL(controller, SearchDeviceDone(HasService(4444)));
-
- DnssdServiceBrowser dnssd_service_browser(&controller);
- DeviceScanner& device_scanner = dnssd_service_browser;
- device_scanner.Init();
- while (!device_scanner.IsInitialised()) {
- }
- sleep(1);
- device_scanner.Scan();
-}
-
-} // namespace
-} // namespace
diff --git a/test/components/transport_manager/src/test_tcp_transport_adapter.cc b/test/components/transport_manager/src/test_tcp_transport_adapter.cc
deleted file mode 100644
index 614583529..000000000
--- a/test/components/transport_manager/src/test_tcp_transport_adapter.cc
+++ /dev/null
@@ -1,332 +0,0 @@
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-
-#include "transport_manager/tcp/tcp_transport_adapter.h"
-#include "transport_manager/transport_adapter/transport_adapter_listener.h"
-#include "transport_manager/mock_transport_adapter_listener.h"
-
-namespace transport_manager {
-namespace transport_adapter {
-
-using RawMessage = ::protocol_handler::RawMessage;
-using namespace ::protocol_handler;
-
-//TEST(TcpAdapterBasicTest, Basic) {
-// TransportAdapter* transport_adapter = new TcpTransportAdapter(12345);
-//
-// EXPECT_EQ("sdl-tcp", transport_adapter->GetDeviceType());
-// EXPECT_TRUE(transport_adapter->IsServerOriginatedConnectSupported());
-// EXPECT_TRUE(transport_adapter->IsClientOriginatedConnectSupported());
-// EXPECT_TRUE(transport_adapter->IsSearchDevicesSupported());
-//}
-
-
-//--should be changed
-TEST(TcpAdapterBasicTest, GetDeviceType_Return_sdl-tcp) {
- TransportAdapter* transport_adapter = new TcpTransportAdapter(12345);
- EXPECT_EQ("sdl-tcp", transport_adapter->GetDeviceType());
-}
-
-//TEST(TcpAdapterBasicTest, isServerOriginatedConnectSupported_Return_True) {
-// TransportAdapter* transport_adapter = new TcpTransportAdapter(12345);
-// EXPECT_TRUE(transport_adapter->IsServerOriginatedConnectSupported());
-//}
-//
-//TEST(TcpAdapterBasicTest, isClientOriginatedConnectSupported_Return_True) {
-// TransportAdapter* transport_adapter = new TcpTransportAdapter(12345);
-// EXPECT_TRUE(transport_adapter->IsClientOriginatedConnectSupported());
-//}
-//TEST(TcpAdapterBasicTest, isSearchDevicesSupported_Return_True) {
-// TransportAdapter* transport_adapter = new TcpTransportAdapter(12345);
-// EXPECT_TRUE(transport_adapter->IsSearchDevicesSupported());
-//}
-
-
-TEST(TcpAdapterBasicTest, NotInitialised) {
- TransportAdapter* transport_adapter = new TcpTransportAdapter(12345);
-
- EXPECT_EQ(TransportAdapter::BAD_STATE, transport_adapter->SearchDevices());
- EXPECT_EQ(TransportAdapter::OK,
- transport_adapter->Connect(DeviceUID("xxx"), 2));
- EXPECT_EQ(TransportAdapter::BAD_STATE,
- transport_adapter->Disconnect(DeviceUID("xxx"), 2));
- EXPECT_EQ(TransportAdapter::BAD_STATE,
- transport_adapter->DisconnectDevice(DeviceUID("xxx")));
-}
-
-class ClientTcpSocket {
- public:
- bool Connect(uint16_t server_port) {
- socket_ = socket(AF_INET, SOCK_STREAM, 0);
- if (socket_ < 0)
- return false;
-
- struct sockaddr_in addr;
- memset((char*) &addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK );
- addr.sin_port = htons(server_port);
-
- if (::connect(socket_, (struct sockaddr*) &addr, sizeof(addr)) < 0)
- return false;
- else
- return true;
- }
-
- bool Send(const std::string& str) {
- size_t size = str.size();
- ssize_t written = write(socket_, str.c_str(), size);
- if (written != -1) {
- size_t count = static_cast<size_t>(written);
- return count == size;
- }
- else {
- return false;
- }
- }
-
- std::string receive(size_t size) {
- char* buf = new char[size];
- ssize_t read = recv(socket_, buf, size, MSG_WAITALL);
- if (read != -1) {
- return std::string(buf, buf + read);
- }
- else {
- return std::string();
- }
- }
-
- void Disconnect() {
- close(socket_);
- }
-
- private:
- uint16_t port_;
- int socket_;
-};
-
-using ::testing::_;
-using ::testing::Invoke;
-
-void Disconnect(const TransportAdapter* transport_adapter,
- const DeviceUID device_handle,
- const ApplicationHandle app_handle) {
- EXPECT_EQ(
- TransportAdapter::OK,
- const_cast<TransportAdapter*>(transport_adapter)->Disconnect(device_handle,
- app_handle));
-}
-
-class TcpAdapterTest : public ::testing::Test {
- public:
- TcpAdapterTest()
- : port_(ChoosePort()),
- transport_adapter_(new TcpTransportAdapter(port_)),
- suspended_(false),
- finished_(false) {
- pthread_mutex_init(&suspend_mutex_, 0);
- pthread_cond_init(&suspend_cond_, 0);
- }
-
- uint16_t ChoosePort() {
- return getpid() % 1000 + 3000;
- }
-
- virtual void SetUp() {
- const TransportAdapter::Error error = transport_adapter_->Init();
- ASSERT_EQ(TransportAdapter::OK, error);
- transport_adapter_->AddListener(&mock_dal_);
- time_t end_time = time(NULL) + 5;
- while (!transport_adapter_->IsInitialised() && time(NULL) < end_time)
- sleep(0);
- ASSERT_TRUE(transport_adapter_->IsInitialised());
- }
-
- virtual ~TcpAdapterTest() {
- pthread_mutex_lock(&suspend_mutex_);
- if (!finished_)
- suspended_ = true;
- struct timeval now;
- gettimeofday(&now, NULL);
- timespec abs_time;
- abs_time.tv_sec = now.tv_sec + 1;
- abs_time.tv_nsec = now.tv_usec * 1000;
- while (suspended_) {
- if (ETIMEDOUT
- == pthread_cond_timedwait(&suspend_cond_, &suspend_mutex_,
- &abs_time)) {
- break;
- }
- }
- pthread_mutex_unlock(&suspend_mutex_);
- delete transport_adapter_;
- pthread_mutex_destroy(&suspend_mutex_);
- pthread_cond_destroy(&suspend_cond_);
- }
-
- void wakeUp() {
- pthread_mutex_lock(&suspend_mutex_);
- finished_ = true;
- suspended_ = false;
- pthread_cond_signal(&suspend_cond_);
- pthread_mutex_unlock(&suspend_mutex_);
- }
-
- uint16_t port() const {return port_;}
-
- const uint16_t port_;
- TransportAdapter* transport_adapter_;
- ::test::components::transport_manager::MockTransportAdapterListener mock_dal_;
- ClientTcpSocket client_;
-
- pthread_cond_t suspend_cond_;
- pthread_mutex_t suspend_mutex_;
- bool suspended_;
- bool finished_;
-};
-
-class TcpAdapterTestWithListenerAutoStart : public TcpAdapterTest {
- virtual void SetUp() {
- TcpAdapterTest::SetUp();
- transport_adapter_->StartClientListening();
- }
-};
-
-MATCHER_P(ContainsMessage, str, ""){ return strlen(str) == arg->data_size() && 0 == memcmp(str, arg->data(), arg->data_size());}
-
-TEST_F(TcpAdapterTestWithListenerAutoStart, Connect) {
- {
- ::testing::InSequence seq;
- EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _)).WillOnce(
- InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp));
- }
- EXPECT_TRUE(client_.Connect(port()));
-}
-
-TEST_F(TcpAdapterTestWithListenerAutoStart, Receive) {
- {
- ::testing::InSequence seq;
- EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _));
- EXPECT_CALL(
- mock_dal_,
- OnDataReceiveDone(transport_adapter_, _, _, ContainsMessage("abcd"))).
- WillOnce(InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp));
- }
- EXPECT_TRUE(client_.Connect(port()));
- EXPECT_TRUE(client_.Send("abcd"));
-}
-
-struct SendHelper {
- explicit SendHelper(TransportAdapter::Error expected_error)
- : expected_error_(expected_error),
- message_(
- new RawMessage(
- 1,
- 1,
- const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>("efgh")),
- 4)) {
- }
- void sendMessage(const TransportAdapter* transport_adapter,
- const DeviceUID device_handle,
- const ApplicationHandle app_handle) {
- EXPECT_EQ(
- expected_error_,
- const_cast<TransportAdapter*>(transport_adapter)->SendData(device_handle,
- app_handle,
- message_));
- }
- TransportAdapter::Error expected_error_;
- RawMessagePtr message_;
-};
-
-TEST_F(TcpAdapterTestWithListenerAutoStart, Send) {
- SendHelper helper(TransportAdapter::OK);
- {
- ::testing::InSequence seq;
- EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _)).WillOnce(
- Invoke(&helper, &SendHelper::sendMessage));
- EXPECT_CALL(mock_dal_,
- OnDataSendDone(transport_adapter_, _, _, helper.message_)).WillOnce(
- InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp));
- }
-
- EXPECT_TRUE(client_.Connect(port()));
- EXPECT_EQ("efgh", client_.receive(4));
-}
-
-TEST_F(TcpAdapterTestWithListenerAutoStart, DisconnectFromClient) {
- {
- ::testing::InSequence seq;
- EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _));
- EXPECT_CALL(mock_dal_, OnUnexpectedDisconnect(transport_adapter_, _, _, _));
- EXPECT_CALL(mock_dal_, OnDisconnectDone(transport_adapter_, _, _)).WillOnce(
- InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp));
- }
- EXPECT_TRUE(client_.Connect(port()));
- client_.Disconnect();
-}
-
-TEST_F(TcpAdapterTestWithListenerAutoStart, DisconnectFromServer) {
- {
- ::testing::InSequence seq;
- EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _)).WillOnce(
- Invoke(Disconnect));
- EXPECT_CALL(mock_dal_, OnDisconnectDone(transport_adapter_, _, _)).WillOnce(
- InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp));
- }
- EXPECT_TRUE(client_.Connect(port()));
-}
-
-TEST_F(TcpAdapterTestWithListenerAutoStart, SendToDisconnected) {
- SendHelper* helper = new SendHelper(TransportAdapter::BAD_PARAM);
- {
- ::testing::InSequence seq;
- EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _)).WillOnce(
- Invoke(Disconnect));
- EXPECT_CALL(mock_dal_, OnDisconnectDone(transport_adapter_, _, _)).WillOnce(
- ::testing::DoAll(Invoke(helper, &SendHelper::sendMessage),
- InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp)));
- }
- EXPECT_TRUE(client_.Connect(port()));
-}
-
-TEST_F(TcpAdapterTestWithListenerAutoStart, SendFailed) {
- static unsigned char zzz[2000000]; //2000000 is much more than socket buffer
- SendHelper* helper = new SendHelper(TransportAdapter::OK);
- helper->message_ = new RawMessage(1, 1, zzz, sizeof(zzz));
- {
- ::testing::InSequence seq;
- EXPECT_CALL(mock_dal_, OnConnectDone(transport_adapter_, _, _)).WillOnce(
- Invoke(helper, &SendHelper::sendMessage));
- EXPECT_CALL(mock_dal_,
- OnDataSendFailed(transport_adapter_, _, _, helper->message_, _));
- EXPECT_CALL(mock_dal_, OnDisconnectDone(transport_adapter_, _, _)).WillOnce(
- InvokeWithoutArgs(this, &TcpAdapterTest::wakeUp));
- }
- EXPECT_TRUE(client_.Connect(port()));
- client_.receive(2);
- client_.Disconnect();
-}
-
-TEST_F(TcpAdapterTest, StartStop) {
- EXPECT_EQ(TransportAdapter::BAD_STATE, transport_adapter_->StopClientListening());
- EXPECT_FALSE(client_.Connect(port()));
- EXPECT_EQ(TransportAdapter::OK, transport_adapter_->StartClientListening());
- EXPECT_TRUE(client_.Connect(port()));
- client_.Disconnect();
- EXPECT_EQ(TransportAdapter::BAD_STATE, transport_adapter_->StartClientListening());
- EXPECT_TRUE(client_.Connect(port()));
- client_.Disconnect();
- EXPECT_EQ(TransportAdapter::OK, transport_adapter_->StopClientListening());
- EXPECT_FALSE(client_.Connect(port()));
- wakeUp();
-}
-
-} // namespace
-} // namespace
-
diff --git a/test/components/transport_manager/src/transport_manager_test.cc b/test/components/transport_manager/src/transport_manager_test.cc
deleted file mode 100644
index be31dbdd5..000000000
--- a/test/components/transport_manager/src/transport_manager_test.cc
+++ /dev/null
@@ -1,285 +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.
- */
-#include <pthread.h>
-
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "protocol/common.h"
-#include "transport_manager/info.h"
-#include "transport_manager/common.h"
-#include "transport_manager/transport_manager_impl.h"
-
-#include "transport_manager/raw_message_matcher.h"
-#include "transport_manager/mock_transport_adapter.h"
-#include "transport_manager/mock_device.h"
-#include "transport_manager/mock_transport_manager_listener.h"
-#include "transport_manager/transport_manager_listener_empty.h"
-
-using ::testing::_;
-using ::testing::AtLeast;
-
-using ::transport_manager::ApplicationHandle;
-using ::transport_manager::DeviceHandle;
-using ::transport_manager::TransportManager;
-using ::transport_manager::TransportManagerImpl;
-using ::transport_manager::DeviceUID;
-using ::transport_manager::DeviceInfo;
-
-namespace test {
-namespace components {
-namespace transport_manager {
-
-ACTION_P(SignalTest, test) {
- if (test->thread_id != pthread_self()) {
- pthread_mutex_lock(&test->test_mutex);
- pthread_cond_signal(&test->test_cond);
- pthread_mutex_unlock(&test->test_mutex);
- } else {
- test->one_thread = true;
- }
-}
-
-class TransportManagerTest : public ::testing::Test {
- public:
- volatile bool one_thread;
- pthread_t thread_id;
- static pthread_mutex_t test_mutex;
- static pthread_cond_t test_cond;
- int number;
-
- protected:
- static TransportManagerImpl *tm;
- static MockTransportAdapter *mock_adapter;
- static MockTransportManagerListener *tm_listener;
-
- static void SetUpTestCase() {
- pthread_mutex_init(&test_mutex, NULL);
- pthread_cond_init(&test_cond, NULL);
- mock_adapter = new MockTransportAdapter();
- mock_adapter->Init();
- //TransportManagerAttr cfg{0};
- tm = new TransportManagerImpl();
-
- tm_listener = new MockTransportManagerListener();
- tm->AddEventListener(tm_listener);
- tm->AddTransportAdapter(mock_adapter);
- tm->Init();
- }
-
- static void TearDownTestCase() {
- tm->Stop();
- delete tm_listener;
- pthread_cond_destroy(&test_cond);
- pthread_mutex_destroy(&test_mutex);
- }
-
- virtual void SetUp() {
- one_thread = false;
- thread_id = pthread_self();
- mock_adapter->reset();
- pthread_mutex_lock(&test_mutex);
- }
-
- virtual void TearDown() { pthread_mutex_unlock(&test_mutex); }
-
- bool waitCond(int seconds) {
- if (one_thread) return true;
- timespec elapsed;
- clock_gettime(CLOCK_REALTIME, &elapsed);
- elapsed.tv_sec += seconds;
- return pthread_cond_timedwait(&test_cond, &test_mutex, &elapsed) !=
- ETIMEDOUT;
- }
-};
-
-TransportManagerImpl *TransportManagerTest::tm;
-
-class MyTransportListener
- : public ::transport_manager::TransportManagerListenerEmpty {
- public:
- explicit MyTransportListener(TransportManagerTest *test)
- : TransportManagerListenerEmpty(),
- connection(0),
- device_handle(0),
- test(test) {}
- ConnectionUID connection;
- DeviceHandle device_handle;
- void OnConnectionEstablished(const DeviceInfo &device,
- const ConnectionUID &connection_id) {
- connection = connection_id;
-
- pthread_mutex_lock(&test->test_mutex);
- pthread_cond_signal(&test->test_cond);
- pthread_mutex_unlock(&test->test_mutex);
- }
-
- void OnDeviceFound(const DeviceInfo &device_info) {
- device_handle = device_info.device_handle();
- }
-
- void OnScanDevicesFinished() {
- pthread_mutex_lock(&test->test_mutex);
- pthread_cond_signal(&test->test_cond);
- pthread_mutex_unlock(&test->test_mutex);
- }
-
- void OnTMMessageReceived(const RawMessagePtr message) {
- static int count = 0;
- if (++count == 100) {
- pthread_mutex_lock(&test->test_mutex);
- pthread_cond_signal(&test->test_cond);
- pthread_mutex_unlock(&test->test_mutex);
- }
- }
-
- void OnTMMessageSend(const RawMessagePtr message) {
- }
-
- private:
- TransportManagerTest *test;
-};
-
-pthread_mutex_t TransportManagerTest::test_mutex;
-pthread_cond_t TransportManagerTest::test_cond;
-
-MockTransportAdapter *TransportManagerTest::mock_adapter = NULL;
-MockTransportManagerListener *TransportManagerTest::tm_listener = NULL;
-
-TEST_F(TransportManagerTest, ScanDeviceFailed) {
- EXPECT_CALL(*tm_listener, OnDeviceFound(_)).Times(0);
- EXPECT_CALL(*tm_listener, OnScanDevicesFailed(_)).Times(1).WillOnce(
- SignalTest(this));
-
- mock_adapter->get_device_scanner()->fail_further_search();
- tm->SearchDevices();
- EXPECT_TRUE(waitCond(1));
- mock_adapter->get_device_scanner()->reset();
-}
-
-TEST_F(TransportManagerTest, ScanDeviceNoFound) {
- EXPECT_CALL(*tm_listener, OnScanDevicesFailed(_)).Times(0);
- EXPECT_CALL(*tm_listener, OnDeviceFound(_)).Times(0);
- EXPECT_CALL(*tm_listener, OnScanDevicesFinished()).Times(1).WillOnce(
- SignalTest(this));
-
- tm->SearchDevices();
- EXPECT_TRUE(waitCond(1));
- mock_adapter->get_device_scanner()->reset();
-}
-
-TEST_F(TransportManagerTest, ScanDeviceDone) {
- EXPECT_CALL(*tm_listener, OnScanDevicesFailed(_)).Times(0);
- EXPECT_CALL(*tm_listener, OnDeviceFound(_)).Times(1);
- EXPECT_CALL(*tm_listener, OnScanDevicesFinished()).Times(1).WillOnce(
- SignalTest(this));
-
- mock_adapter->get_device_scanner()->AddDevice("TestDevice", "MA:CA:DR:ES:S");
- tm->SearchDevices();
- EXPECT_TRUE(waitCond(1));
- mock_adapter->get_device_scanner()->reset();
-}
-
-TEST_F(TransportManagerTest, ScanManyDeviceDone) {
- EXPECT_CALL(*tm_listener, OnScanDevicesFailed(_)).Times(0);
- EXPECT_CALL(*tm_listener, OnDeviceFound(_)).Times(2);
- EXPECT_CALL(*tm_listener, OnScanDevicesFinished()).Times(1).WillOnce(
- SignalTest(this));
- mock_adapter->get_device_scanner()->AddDevice("TestDevice1",
- "MA:CA:DR:ES:S1");
- mock_adapter->get_device_scanner()->AddDevice("TestDevice2",
- "MA:CA:DR:ES:S2");
- tm->SearchDevices();
- EXPECT_TRUE(waitCond(1));
- mock_adapter->get_device_scanner()->reset();
-}
-
-TEST_F(TransportManagerTest, ConnectDisconnectSendReciveDone) {
- const DeviceInfo kInfo(1, "MA:CA:DR:ES:S", "TestDeviceName", "BTMAC");
- const ConnectionUID kConnection = 1;
-
- EXPECT_CALL(*tm_listener, OnDeviceFound(_)).Times(1);
- EXPECT_CALL(*tm_listener, OnScanDevicesFinished()).Times(1);
- MyTransportListener *myListener = new MyTransportListener(this);
- mock_adapter->get_device_scanner()->AddDevice(kInfo.name(),
- kInfo.mac_address());
- tm->AddEventListener(myListener);
- tm->SearchDevices();
- EXPECT_TRUE(waitCond(10));
-
- EXPECT_CALL(*tm_listener, OnConnectionFailed(_, _)).Times(0);
- EXPECT_CALL(*tm_listener, OnConnectionEstablished(kInfo, kConnection))
- .Times(1);
- tm->ConnectDevice(kInfo.device_handle());
- EXPECT_TRUE(waitCond(10));
-
- const int kTimes = 100; // Times of send message
- const unsigned int kVersionProtocol = 1;
- EXPECT_CALL(*tm_listener, OnTMMessageSendFailed(_, _)).Times(0);
- EXPECT_CALL(*tm_listener, OnTMMessageReceiveFailed(_, _)).Times(0);
- EXPECT_CALL(*tm_listener, OnConnectionClosed(kConnection)).Times(0);
- // EXPECT_CALL(*tm_listener, OnTMMessageSend()).Times(kTimes); // FIXME
- // (dchmerev@luxoft.com): make proper expect_call
- EXPECT_CALL(*tm_listener, OnTMMessageReceived(_)).Times(kTimes);
-
- const unsigned int kSize = 12;
- unsigned char data[kSize] = {0x20, 0x07, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- for (int i = 0; i < kTimes; ++i) {
- const RawMessagePtr kMessage =
- new RawMessage(kConnection, kVersionProtocol, data, kSize);
- tm->SendMessageToDevice(kMessage);
- usleep(1000);
- }
- EXPECT_TRUE(waitCond(10));
-
- EXPECT_CALL(*tm_listener, OnConnectionClosedFailure(_, _)).Times(0);
- EXPECT_CALL(*tm_listener, OnDisconnectFailed(kInfo.device_handle(), _))
- .Times(0);
- EXPECT_CALL(*tm_listener, OnConnectionClosed(kConnection)).Times(1).WillOnce(
- SignalTest(this));
- tm->DisconnectDevice(kInfo.device_handle());
- EXPECT_TRUE(waitCond(10));
-
- tm->Stop();
- delete myListener;
- mock_adapter->get_device_scanner()->reset();
-}
-
-} // namespace transport_manager
-} // namespace components
-} // namespace test
-
-int main(int argc, char **argv) {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
diff --git a/test/components/transport_manager/test_DnssdServiceDiscovery.sh b/test/components/transport_manager/test_DnssdServiceDiscovery.sh
deleted file mode 100755
index deaf42ff0..000000000
--- a/test/components/transport_manager/test_DnssdServiceDiscovery.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/bash
-
-pipe=/tmp/test_DnssdServiceDiscovery
-mkfifo $pipe
-avahi-publish -s TestService _ford-sdlapp._tcp 4444 >$pipe 2>&1 &
-pid=$!
-read line <$pipe
-
-ret=0
-if [[ "$line" == Established* ]]
-then
- ./test_DnssdServiceDiscovery
- ret=$?
-else
- ret=3
-fi
-
-kill $pid
-rm $pipe
-exit $ret
-
diff --git a/test/components/transport_manager/transport_manager_instance_test.cc b/test/components/transport_manager/transport_manager_instance_test.cc
deleted file mode 100644
index f584f443f..000000000
--- a/test/components/transport_manager/transport_manager_instance_test.cc
+++ /dev/null
@@ -1,447 +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.
-//
-
-/*
- Tests transport manager functionality with single device adapter that behaves correctly and single client
- Following sequence is tested:
- - TM created and runned
- - TM client registered as listener
- - TM client requests device scaning
- - single device was returned to TM client with onDeviceListUpdated callback
- - TM client calls "connect" on found device
- - device adapter sends onApplicationConnected
- - TM client receives onApplicationConnected
- - device adapter sends three data parts that represents single frame
- - TM client receives single frame with onFrameReceived callback
- - TM client calls sendFrame with some frame data and user data
- - TM client receives onFrameSendCompleted
- - TM client calls DisconnectDevice
- - TM client receives onApplicationDisconnected
- */
-//
-// 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 TEST_COMPONENTS_TRANSPORT_MANAGER_TRANSPORT_MANAGER_INSTANCE_TEST_H
-#define TEST_COMPONENTS_TRANSPORT_MANAGER_TRANSPORT_MANAGER_INSTANCE_TEST_H
-
-/*
- Tests transport manager functionality with single device adapter that behaves correctly and single client
- Following sequence is tested:
- - TM created and runned
- - TM client registered as listener
- - TM client requests device scaning
- - single device was returned to TM client with onDeviceListUpdated callback
- - TM client calls "connect" on found device
- - device adapter sends onApplicationConnected
- - TM client receives onApplicationConnected
- - device adapter sends three data parts that represents single frame
- - TM client receives single frame with onFrameReceived callback
- - TM client calls sendFrame with some frame data and user data
- - TM client receives onFrameSendCompleted
- - TM client calls DisconnectDevice
- - TM client receives onApplicationDisconnected
- */
-#include <stddef.h>
-#include <stdio.h>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "include/transport_manager/transport_manager.h"
-#include "include/transport_manager/transport_manager_impl.h"
-//#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-//#include "TransportManager/ITransportManagerDataListener.hpp"
-//#include "TransportManager/ITransportManagerDeviceListener.hpp"
-
-
-//using namespace NsSmartDeviceLink::NsTransportManager;
-
-namespace test /*{ namespace components { namespace transport_manager*/ { namespace test_transport_manager_instance {
-TEST(test_transport_manager_instance, test_transport_manager_instance)
-{
- transport_manager::TransportManager *Instance = transport_manager::TransportManagerImpl::Instance();
- ASSERT_EQ(Instance, transport_manager::TransportManagerImpl::Instance());
-}
-//
-// // ---------------- TEST DATA ---------------- //
-// namespace Data
-// {
-// static const tDeviceHandle DeviceHandle = 123;
-// static const EDeviceType DeviceType = DeviceBluetooth;
-// static const std::string UserFriendlyName("MY USER FRIENDLY NAME");
-// static const std::string UniqueDeviceId("MY_UNIQUE_DEVICE_ID");
-//
-// static const tConnectionHandle ConnectionHandle = 666;
-//
-// static const int UserData = 123;
-// }
-//
-// // ---------------- TEST CLASSES ---------------- //
-//
-// /**
-// * @brief Class that represents custom device adapter that will send known data
-// * and check it's methods calls
-// **/
-// class MockTransportAdapter : public ITransportAdapter
-// {
-// public:
-// MockTransportAdapter(ITransportAdapterListener & Listener, IHandleGenerator & HandleGenerator)
-// : mListener(Listener)
-// , mHandleGenerator(HandleGenerator)
-// , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
-// {
-// }
-//
-// virtual EDeviceType GetDeviceType(void ) const
-// {
-// return DeviceBluetooth;
-// }
-// MOCK_METHOD1(ConnectDevice, void (const tDeviceHandle DeviceHandle));
-// MOCK_METHOD1(DisconnectDevice, void (const tDeviceHandle DeviceHandle));
-// MOCK_METHOD0(run, void());
-// MOCK_METHOD0(scanForNewDevices, void());
-// MOCK_METHOD4(sendFrame, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, int UserData));
-//
-// void doScanForNewDevices()
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Scanning new devices -----------------");
-// SInternalDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-//
-// tInternalDeviceList list;
-// list.push_back(deviceInfo);
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending device list update -----------------");
-// mListener.onDeviceListUpdated(this, list);
-// }
-//
-// void doConnectDevice(const tDeviceHandle DeviceHandle)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Connecting device -----------------");
-// // Application connect
-//
-// SDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending ApplicationConnected -----------------");
-// mListener.onApplicationConnected(this, deviceInfo, Data::ConnectionHandle);
-//
-// // Send three frames to transport manager
-//
-// uint8_t raw_data[] = {
-// 0x22, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8,
-// 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF
-// };
-//
-// // Sending only header first
-// uint8_t *pSendBuff = raw_data;
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #1 -----------------");
-// mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, 12);
-//
-// // Sending first part of the data
-// pSendBuff+=12;
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #2 -----------------");
-// mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
-//
-// // Sending last part of the data
-// pSendBuff+=100;
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #3 -----------------");
-// mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
-// }
-//
-// void doSendFrame(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, const int UserData)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doSendFrame called. Sending FrameSendCompleted -----------------");
-// mListener.onFrameSendCompleted(this, Data::ConnectionHandle, Data::UserData, SendStatusOK);
-// }
-//
-// void doDisconnectDevice(const tDeviceHandle DeviceHandle)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doDisconnectDevice -----------------");
-// SDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- sending ApplicationDisconnected -----------------");
-// mListener.onApplicationDisconnected(this, deviceInfo, Data::ConnectionHandle);
-// }
-//
-// protected:
-// ITransportAdapterListener & mListener;
-// IHandleGenerator & mHandleGenerator;
-// Logger mLogger;
-// };
-//
-// /**
-// * @brief Custom transport manager client that will check data, sent by transport manager
-// **/
-// class MockTransportManagerClient : public ITransportManagerDataListener
-// , public ITransportManagerDeviceListener
-// {
-// public:
-// MockTransportManagerClient(ITransportManager & TransportManager)
-// : mTransportManager(TransportManager)
-// , mDeviceList()
-// , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
-// {
-//
-// }
-// MOCK_METHOD2(onApplicationConnected, void(const SDeviceInfo& ConnectedDevice, const tConnectionHandle Connection));
-// MOCK_METHOD2(onApplicationDisconnected, void(const SDeviceInfo& DisconnectedDevice, const tConnectionHandle Connection));
-// MOCK_METHOD1(onDeviceListUpdated, void(const tDeviceList& DeviceList));
-// MOCK_METHOD3(onFrameReceived, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize));
-// MOCK_METHOD3(onFrameSendCompleted, void(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus));
-//
-// void doDeviceListUpdated(const tDeviceList& DeviceList)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doDeviceListUpdated -----------------");
-// mDeviceList = DeviceList;
-//
-// tDeviceList::const_iterator device;
-// for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
-// {
-// mTransportManager.ConnectDevice(device->mDeviceHandle);
-// }
-// }
-//
-// void doFrameReceived(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doFrameReceived -----------------");
-// // Sending frame
-// uint8_t data[512]={1};
-// mTransportManager.sendFrame(ConnectionHandle, data, 512, Data::UserData);
-// }
-//
-// void doFrameSendCompleted(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doFrameSendCompleted -----------------");
-//
-// tDeviceList::const_iterator device;
-// for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
-// {
-// mTransportManager.DisconnectDevice(device->mDeviceHandle);
-// }
-// }
-//
-// protected:
-// ITransportManager & mTransportManager;
-// tDeviceList mDeviceList;
-// Logger mLogger;
-// };
-//
-// /**
-// * @brief Inherited transport manager class used for some small preparation of class for
-// * testing (disabling another adapters etc.)
-// **/
-// class TestTransportManager : public CTransportManager
-// {
-// public:
-// TestTransportManager(void )
-// : CTransportManager()
-// , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
-// {
-// }
-//
-// virtual ~TestTransportManager(void )
-// {
-//
-// }
-//
-// virtual void initializeTransportAdapters()
-// {
-// // Preparing custom device adapter
-// mpTransportAdapter = new MockTransportAdapter(*this, *this);
-//
-// EXPECT_CALL(*mpTransportAdapter, run()).Times(1);
-// EXPECT_CALL(*mpTransportAdapter, scanForNewDevices())
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doScanForNewDevices))
-// ;
-//
-// EXPECT_CALL(*mpTransportAdapter, ConnectDevice(Data::DeviceHandle))
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doConnectDevice))
-// ;
-//
-// EXPECT_CALL(*mpTransportAdapter, sendFrame(Data::ConnectionHandle, _, 512, Data::UserData))
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doSendFrame))
-// ;
-//
-// EXPECT_CALL(*mpTransportAdapter, DisconnectDevice(Data::DeviceHandle))
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doDisconnectDevice))
-// ;
-//
-// AddTransportAdapter(mpTransportAdapter);
-// LOG4CPLUS_INFO_EXT(mLogger, "Transport adapters initialized");
-// }
-//
-// protected:
-// MockTransportAdapter *mpTransportAdapter;
-// Logger mLogger;
-// };
-//
-// // ----------------------- TESTS ----------------------- //
-//
-// TEST(test_TestWithCorrectTransportAdapter, CorrectTransportAdapterBehavior)
-// {
-// Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest"));
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Starting test *****************************");
-// // All expectations must be sequenced
-// //InSequence dummy;
-//
-// // Creating transport manager
-// TestTransportManager *pTm = new TestTransportManager();
-//
-// // Preparing transport manage client
-// MockTransportManagerClient tmClient(*pTm);
-//
-// // Expected device list
-// SDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-// tDeviceList deviceList;
-// deviceList.push_back(deviceInfo);
-//
-// EXPECT_CALL(tmClient, onDeviceListUpdated(ContainerEq(deviceList)))
-// .Times(1)
-// .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doDeviceListUpdated))
-// ;
-//
-// EXPECT_CALL(tmClient, onApplicationConnected(deviceInfo, Data::ConnectionHandle))
-// .Times(1)
-// ;
-//
-// EXPECT_CALL(tmClient, onFrameReceived(Data::ConnectionHandle, _, 212))
-// .Times(1)
-// .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doFrameReceived))
-// ;
-//
-// EXPECT_CALL(tmClient, onFrameSendCompleted(Data::ConnectionHandle, Data::UserData, SendStatusOK))
-// .Times(1)
-// .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doFrameSendCompleted))
-// ;
-//
-// EXPECT_CALL(tmClient, onApplicationDisconnected(deviceInfo, Data::ConnectionHandle))
-// .Times(1)
-// ;
-//
-//
-//
-// // Running test
-//
-// pTm->addDataListener(&tmClient);
-// pTm->addDeviceListener(&tmClient);
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Calling RUN *****************************");
-// pTm->run();
-//
-// sleep(1);
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Calling SCAN FOR DEVICES *****************************");
-// pTm->scanForNewDevices();
-//
-// sleep(2);
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Deleting TM and shutting down *****************************");
-//
-// // Shutdown transport manager
-// delete pTm;
-// pTm = 0;
-//
-// }
-}/*}}*/} // End of namespaces
-
-#endif
-
diff --git a/test/components/transport_manager/transport_manager_instance_test.h b/test/components/transport_manager/transport_manager_instance_test.h
deleted file mode 100644
index 26e3c49c0..000000000
--- a/test/components/transport_manager/transport_manager_instance_test.h
+++ /dev/null
@@ -1,397 +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 TEST_COMPONENTS_TRANSPORT_MANAGER_TRANSPORT_MANAGER_INSTANCE_TEST_H
-#define TEST_COMPONENTS_TRANSPORT_MANAGER_TRANSPORT_MANAGER_INSTANCE_TEST_H
-
-/*
- Tests transport manager functionality with single device adapter that behaves correctly and single client
- Following sequence is tested:
- - TM created and runned
- - TM client registered as listener
- - TM client requests device scaning
- - single device was returned to TM client with onDeviceListUpdated callback
- - TM client calls "connect" on found device
- - device adapter sends onApplicationConnected
- - TM client receives onApplicationConnected
- - device adapter sends three data parts that represents single frame
- - TM client receives single frame with onFrameReceived callback
- - TM client calls sendFrame with some frame data and user data
- - TM client receives onFrameSendCompleted
- - TM client calls DisconnectDevice
- - TM client receives onApplicationDisconnected
- */
-#include <stddef.h>
-#include <stdio.h>
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-#include "../../../src/components/transport_manager/include/transport_manager/transport_manager.h"
-#include "../../../src/components/transport_manager/include/transport_manager/transport_manager_impl.h"
-//#include "../../../src/components/TransportManager/src/CTransportManager.hpp"
-//#include "TransportManager/ITransportManagerDataListener.hpp"
-//#include "TransportManager/ITransportManagerDeviceListener.hpp"
-
-
-//using namespace NsSmartDeviceLink::NsTransportManager;
-
-namespace test /*{ namespace components { namespace transport_manager*/ { namespace test_transport_manager_instance {
-TEST(test_transport_manager_instance, test_transport_manager_instance)
-{
- transport_manager::TransportManager *Instance = transport_manager::TransportManagerImpl::Instance();
- ASSERT_EQ(Instance, transport_manager::TransportManagerImpl::Instance());
-}
-//
-// // ---------------- TEST DATA ---------------- //
-// namespace Data
-// {
-// static const tDeviceHandle DeviceHandle = 123;
-// static const EDeviceType DeviceType = DeviceBluetooth;
-// static const std::string UserFriendlyName("MY USER FRIENDLY NAME");
-// static const std::string UniqueDeviceId("MY_UNIQUE_DEVICE_ID");
-//
-// static const tConnectionHandle ConnectionHandle = 666;
-//
-// static const int UserData = 123;
-// }
-//
-// // ---------------- TEST CLASSES ---------------- //
-//
-// /**
-// * @brief Class that represents custom device adapter that will send known data
-// * and check it's methods calls
-// **/
-// class MockTransportAdapter : public ITransportAdapter
-// {
-// public:
-// MockTransportAdapter(ITransportAdapterListener & Listener, IHandleGenerator & HandleGenerator)
-// : mListener(Listener)
-// , mHandleGenerator(HandleGenerator)
-// , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
-// {
-// }
-//
-// virtual EDeviceType GetDeviceType(void ) const
-// {
-// return DeviceBluetooth;
-// }
-// MOCK_METHOD1(ConnectDevice, void (const tDeviceHandle DeviceHandle));
-// MOCK_METHOD1(DisconnectDevice, void (const tDeviceHandle DeviceHandle));
-// MOCK_METHOD0(run, void());
-// MOCK_METHOD0(scanForNewDevices, void());
-// MOCK_METHOD4(sendFrame, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, int UserData));
-//
-// void doScanForNewDevices()
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Scanning new devices -----------------");
-// SInternalDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-//
-// tInternalDeviceList list;
-// list.push_back(deviceInfo);
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending device list update -----------------");
-// mListener.onDeviceListUpdated(this, list);
-// }
-//
-// void doConnectDevice(const tDeviceHandle DeviceHandle)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Connecting device -----------------");
-// // Application connect
-//
-// SDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending ApplicationConnected -----------------");
-// mListener.onApplicationConnected(this, deviceInfo, Data::ConnectionHandle);
-//
-// // Send three frames to transport manager
-//
-// uint8_t raw_data[] = {
-// 0x22, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8,
-// 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-// 0xFF, 0xFF, 0xFF, 0xFF
-// };
-//
-// // Sending only header first
-// uint8_t *pSendBuff = raw_data;
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #1 -----------------");
-// mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, 12);
-//
-// // Sending first part of the data
-// pSendBuff+=12;
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #2 -----------------");
-// mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
-//
-// // Sending last part of the data
-// pSendBuff+=100;
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- Sending Frame #3 -----------------");
-// mListener.onFrameReceived(this, Data::ConnectionHandle, pSendBuff, static_cast<size_t>(100));
-// }
-//
-// void doSendFrame(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize, const int UserData)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doSendFrame called. Sending FrameSendCompleted -----------------");
-// mListener.onFrameSendCompleted(this, Data::ConnectionHandle, Data::UserData, SendStatusOK);
-// }
-//
-// void doDisconnectDevice(const tDeviceHandle DeviceHandle)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doDisconnectDevice -----------------");
-// SDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-//
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- sending ApplicationDisconnected -----------------");
-// mListener.onApplicationDisconnected(this, deviceInfo, Data::ConnectionHandle);
-// }
-//
-// protected:
-// ITransportAdapterListener & mListener;
-// IHandleGenerator & mHandleGenerator;
-// Logger mLogger;
-// };
-//
-// /**
-// * @brief Custom transport manager client that will check data, sent by transport manager
-// **/
-// class MockTransportManagerClient : public ITransportManagerDataListener
-// , public ITransportManagerDeviceListener
-// {
-// public:
-// MockTransportManagerClient(ITransportManager & TransportManager)
-// : mTransportManager(TransportManager)
-// , mDeviceList()
-// , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
-// {
-//
-// }
-// MOCK_METHOD2(onApplicationConnected, void(const SDeviceInfo& ConnectedDevice, const tConnectionHandle Connection));
-// MOCK_METHOD2(onApplicationDisconnected, void(const SDeviceInfo& DisconnectedDevice, const tConnectionHandle Connection));
-// MOCK_METHOD1(onDeviceListUpdated, void(const tDeviceList& DeviceList));
-// MOCK_METHOD3(onFrameReceived, void(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize));
-// MOCK_METHOD3(onFrameSendCompleted, void(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus));
-//
-// void doDeviceListUpdated(const tDeviceList& DeviceList)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doDeviceListUpdated -----------------");
-// mDeviceList = DeviceList;
-//
-// tDeviceList::const_iterator device;
-// for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
-// {
-// mTransportManager.ConnectDevice(device->mDeviceHandle);
-// }
-// }
-//
-// void doFrameReceived(tConnectionHandle ConnectionHandle, const uint8_t* Data, size_t DataSize)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doFrameReceived -----------------");
-// // Sending frame
-// uint8_t data[512]={1};
-// mTransportManager.sendFrame(ConnectionHandle, data, 512, Data::UserData);
-// }
-//
-// void doFrameSendCompleted(tConnectionHandle ConnectionHandle, int UserData, ESendStatus SendStatus)
-// {
-// LOG4CPLUS_INFO_EXT(mLogger, "-------------- doFrameSendCompleted -----------------");
-//
-// tDeviceList::const_iterator device;
-// for(device = mDeviceList.begin(); device != mDeviceList.end(); ++device)
-// {
-// mTransportManager.DisconnectDevice(device->mDeviceHandle);
-// }
-// }
-//
-// protected:
-// ITransportManager & mTransportManager;
-// tDeviceList mDeviceList;
-// Logger mLogger;
-// };
-//
-// /**
-// * @brief Inherited transport manager class used for some small preparation of class for
-// * testing (disabling another adapters etc.)
-// **/
-// class TestTransportManager : public CTransportManager
-// {
-// public:
-// TestTransportManager(void )
-// : CTransportManager()
-// , mLogger(log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest")))
-// {
-// }
-//
-// virtual ~TestTransportManager(void )
-// {
-//
-// }
-//
-// virtual void initializeTransportAdapters()
-// {
-// // Preparing custom device adapter
-// mpTransportAdapter = new MockTransportAdapter(*this, *this);
-//
-// EXPECT_CALL(*mpTransportAdapter, run()).Times(1);
-// EXPECT_CALL(*mpTransportAdapter, scanForNewDevices())
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doScanForNewDevices))
-// ;
-//
-// EXPECT_CALL(*mpTransportAdapter, ConnectDevice(Data::DeviceHandle))
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doConnectDevice))
-// ;
-//
-// EXPECT_CALL(*mpTransportAdapter, sendFrame(Data::ConnectionHandle, _, 512, Data::UserData))
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doSendFrame))
-// ;
-//
-// EXPECT_CALL(*mpTransportAdapter, DisconnectDevice(Data::DeviceHandle))
-// .Times(1)
-// .WillOnce(Invoke(mpTransportAdapter, &MockTransportAdapter::doDisconnectDevice))
-// ;
-//
-// AddTransportAdapter(mpTransportAdapter);
-// LOG4CPLUS_INFO_EXT(mLogger, "Transport adapters initialized");
-// }
-//
-// protected:
-// MockTransportAdapter *mpTransportAdapter;
-// Logger mLogger;
-// };
-//
-// // ----------------------- TESTS ----------------------- //
-//
-// TEST(test_TestWithCorrectTransportAdapter, CorrectTransportAdapterBehavior)
-// {
-// Logger logger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("TransportManagerTest"));
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Starting test *****************************");
-// // All expectations must be sequenced
-// //InSequence dummy;
-//
-// // Creating transport manager
-// TestTransportManager *pTm = new TestTransportManager();
-//
-// // Preparing transport manage client
-// MockTransportManagerClient tmClient(*pTm);
-//
-// // Expected device list
-// SDeviceInfo deviceInfo;
-// deviceInfo.mDeviceHandle = Data::DeviceHandle;
-// deviceInfo.mUniqueDeviceId = Data::UniqueDeviceId;
-// deviceInfo.mUserFriendlyName = Data::UserFriendlyName;
-// tDeviceList deviceList;
-// deviceList.push_back(deviceInfo);
-//
-// EXPECT_CALL(tmClient, onDeviceListUpdated(ContainerEq(deviceList)))
-// .Times(1)
-// .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doDeviceListUpdated))
-// ;
-//
-// EXPECT_CALL(tmClient, onApplicationConnected(deviceInfo, Data::ConnectionHandle))
-// .Times(1)
-// ;
-//
-// EXPECT_CALL(tmClient, onFrameReceived(Data::ConnectionHandle, _, 212))
-// .Times(1)
-// .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doFrameReceived))
-// ;
-//
-// EXPECT_CALL(tmClient, onFrameSendCompleted(Data::ConnectionHandle, Data::UserData, SendStatusOK))
-// .Times(1)
-// .WillOnce(Invoke(&tmClient, &MockTransportManagerClient::doFrameSendCompleted))
-// ;
-//
-// EXPECT_CALL(tmClient, onApplicationDisconnected(deviceInfo, Data::ConnectionHandle))
-// .Times(1)
-// ;
-//
-//
-//
-// // Running test
-//
-// pTm->addDataListener(&tmClient);
-// pTm->addDeviceListener(&tmClient);
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Calling RUN *****************************");
-// pTm->run();
-//
-// sleep(1);
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Calling SCAN FOR DEVICES *****************************");
-// pTm->scanForNewDevices();
-//
-// sleep(2);
-//
-// LOG4CPLUS_INFO_EXT(logger, "*************************** Deleting TM and shutting down *****************************");
-//
-// // Shutdown transport manager
-// delete pTm;
-// pTm = 0;
-//
-// }
-}/*}}*/} // End of namespaces
-
-#endif
diff --git a/test/gtest-example/CMakeLists.txt b/test/gtest-example/CMakeLists.txt
deleted file mode 100644
index 5be08b33c..000000000
--- a/test/gtest-example/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-include_directories (
- ${GMOCK_INCLUDE_DIRECTORY}
-)
-
-set (SOURCES
- ./example.cpp
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
-)
-
-add_executable("gtest-example" ${SOURCES})
-target_link_libraries("gtest-example" ${LIBRARIES})
-add_test(gtest-example gtest-example)
diff --git a/test/gtest-example/example.cpp b/test/gtest-example/example.cpp
deleted file mode 100644
index 794b13cb5..000000000
--- a/test/gtest-example/example.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-
-namespace test
-{
- namespace gtest_example
- {
- TEST(gtest_example, initial_test)
- {
- EXPECT_TRUE(1 == 1);
- ASSERT_FALSE(0 == 1);
- //ASSERT_FALSE(0 == 0); // Uncomment this and test will fail
- }
- }
-
- namespace gmock_example
- {
- // Class that we test
- class ClassToTest
- {
- public:
- virtual ~ClassToTest(){}
- virtual void doAction() = 0; // We will test that doAction will be called
- virtual void run()
- {
- doAction();
- //doAction(); // Uncomment this and test will fail
- }
- };
-
- // Our mock class
- class MockClassToTest: public ClassToTest
- {
- public:
- MOCK_METHOD0(doAction, void());
- };
-
- TEST(gmock_example, test)
- {
- MockClassToTest c;
- EXPECT_CALL(c, doAction())
- .Times(1)
- ;
-
- c.run();
- }
- }
-}
-
-int main(int argc, char **argv) {
- ::testing::InitGoogleMock(&argc, argv);
- return RUN_ALL_TESTS();
-} \ No newline at end of file
diff --git a/test/log4cxx.properties b/test/log4cxx.properties
deleted file mode 100644
index 6a12f8c9b..000000000
--- a/test/log4cxx.properties
+++ /dev/null
@@ -1,78 +0,0 @@
-# Log for all SmartDeviceLinkCoreSocketHub messages
-log4j.appender.SmartDeviceLinkCoreSocketHub=org.apache.log4j.net.SocketHubAppender
-log4j.appender.SmartDeviceLinkCoreSocketHub.port=4555
-log4j.appender.SmartDeviceLinkCoreSocketHub.locationInfo=true
-
-# Only ERROR and FATAL messages are logged to console
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.ImmediateFlush=true
-log4j.appender.Console.layout=org.apache.log4j.PatternLayout
-log4j.appender.Console.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %m%n
-log4j.appender.Console.Threshold=DEBUG
-
-# Log for all SmartDeviceLinkCore messages
-log4j.appender.SmartDeviceLinkCoreLogFile=SafeFileAppender
-log4j.appender.SmartDeviceLinkCoreLogFile.File=SmartDeviceLinkCore.log
-log4j.appender.SmartDeviceLinkCoreLogFile.append=true
-log4j.appender.SmartDeviceLinkCoreLogFile.DatePattern='.' yyyy-MM-dd HH-mm
-log4j.appender.SmartDeviceLinkCoreLogFile.ImmediateFlush=true
-log4j.appender.SmartDeviceLinkCoreLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.SmartDeviceLinkCoreLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for all TransportManager messages
-log4j.appender.TransportManagerLogFile=SafeFileAppender
-log4j.appender.TransportManagerLogFile.File=TransportManager.log
-log4j.appender.TransportManagerLogFile.append=false
-log4j.appender.TransportManagerLogFile.DatePattern='.' yyyy-MM-dd HH-mm
-log4j.appender.TransportManagerLogFile.ImmediateFlush=true
-log4j.appender.TransportManagerLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.TransportManagerLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for all DBus plugin messages
-log4j.appender.DBusPluginLogFile=SafeFileAppender
-log4j.appender.DBusPluginLogFile.File=DBusPlugin.log
-log4j.appender.DBusPluginLogFile.append=false
-log4j.appender.DBusPluginLogFile.DatePattern='.' yyyy-MM-dd
-log4j.appender.DBusPluginLogFile.ImmediateFlush=true
-log4j.appender.DBusPluginLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.DBusPluginLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for all HMI Framework plugin
-log4j.appender.HmiFrameworkPluginLogFile=SafeFileAppender
-log4j.appender.HmiFrameworkPluginLogFile.File=HmiFrameworkPlugin.log
-log4j.appender.HmiFrameworkPluginLogFile.append=false
-log4j.appender.HmiFrameworkPluginLogFile.DatePattern='.' yyyy-MM-dd
-log4j.appender.HmiFrameworkPluginLogFile.ImmediateFlush=true
-log4j.appender.HmiFrameworkPluginLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.HmiFrameworkPluginLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %F:%L %M: %m%n
-
-# Log for handling Ford protocol info (include ProtocolHandler, ConnectionHandler, SecurityManager, SSLContext)
-log4j.appender.ProtocolFordHandlingLogFile=SafeFileAppender
-log4j.appender.ProtocolFordHandlingLogFile.File=ProtocolFordHandling.log
-log4j.appender.ProtocolFordHandlingLogFile.append=false
-log4j.appender.ProtocolFordHandlingLogFile.DatePattern='.' yyyy-MM-dd
-log4j.appender.ProtocolFordHandlingLogFile.ImmediateFlush=true
-log4j.appender.ProtocolFordHandlingLogFile.layout=org.apache.log4j.PatternLayout
-log4j.appender.ProtocolFordHandlingLogFile.layout.ConversionPattern=%-5p [%d{dd MMM yyyy HH:mm:ss,SSS}][%c] %M: %m%n
-
-# All SmartDeviceLinkCore logs
-log4j.rootLogger=ALL, Console, SmartDeviceLinkCoreLogFile, SmartDeviceLinkCoreSocketHub
-
-# TransportManager logs
-log4j.logger.TransportManager=ALL, TransportManagerLogFile
-
-# Log for DBus plugin QtHMI
-log4j.logger.DBusPlugin=ALL, DBusPluginLogFile
-
-# Log for HMI Framework plugin
-log4j.logger.HmiFrameworkPlugin=ALL, HmiFrameworkPluginLogFile
-
-# Log by log4cxx plugin
-log4j.logger.Log4cxxPlugin=ALL, HmiFrameworkPluginLogFile
-
-# Log by ProtocolHandler
-log4j.logger.ProtocolHandler=ALL, ProtocolFordHandlingLogFile
-# Log by ConnectionHandler
-log4j.logger.ConnectionHandler=ALL, ProtocolFordHandlingLogFile
-# Log by SecurityManager
-log4j.logger.SecurityManager=ALL, ProtocolFordHandlingLogFile
diff --git a/test/scripts/random_stream.py b/test/scripts/random_stream.py
deleted file mode 100755
index aeebdc233..000000000
--- a/test/scripts/random_stream.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding, 0x utf-8 -*-
-
-import socket
-from time import sleep
-
-HOST = '127.0.0.1'
-PORT = 12345
-
-def main():
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((HOST, PORT))
- startSession = bytes([
- # header start
- 0x20, 0x07, 0x01, 0x00,
- # max data size
- 0x00, 0x00, 0x00, 0x00,
- # message ID
- 0x00, 0x00, 0x00, 0x00,
-
- ])
- registerApp = bytes([
- 0x21, 0x07, 0x00, 0x01,
- 0x00, 0x00, 0x01, 0x25,
- 0x00, 0x00, 0x00, 0x01,
-
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0xff, 0xf9, 0x00, 0x00,
- 0x01, 0x19, 0x7b, 0x22, 0x6e, 0x67, 0x6e, 0x4d, 0x65, 0x64,
- 0x69, 0x61, 0x53, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x41, 0x70,
- 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x22, 0x53, 0x79,
- 0x6e, 0x63, 0x50, 0x22, 0x2c, 0x22, 0x61, 0x70, 0x70, 0x4e,
- 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x22, 0x53, 0x79, 0x6e, 0x63,
- 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x65, 0x73, 0x74, 0x65,
- 0x72, 0x22, 0x2c, 0x22, 0x76, 0x72, 0x53, 0x79, 0x6e, 0x6f,
- 0x6e, 0x79, 0x6d, 0x73, 0x22, 0x3a, 0x5b, 0x22, 0x53, 0x79,
- 0x6e, 0x63, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x54, 0x65, 0x73,
- 0x74, 0x65, 0x72, 0x22, 0x5d, 0x2c, 0x22, 0x68, 0x6d, 0x69,
- 0x44, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x4c, 0x61, 0x6e,
- 0x67, 0x75, 0x61, 0x67, 0x65, 0x44, 0x65, 0x73, 0x69, 0x72,
- 0x65, 0x64, 0x22, 0x3a, 0x22, 0x45, 0x4e, 0x2d, 0x55, 0x53,
- 0x22, 0x2c, 0x22, 0x69, 0x73, 0x4d, 0x65, 0x64, 0x69, 0x61,
- 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f,
- 0x6e, 0x22, 0x3a, 0x74, 0x72, 0x75, 0x65, 0x2c, 0x22, 0x73,
- 0x79, 0x6e, 0x63, 0x4d, 0x73, 0x67, 0x56, 0x65, 0x72, 0x73,
- 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x7b, 0x22, 0x6d, 0x69, 0x6e,
- 0x6f, 0x72, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22,
- 0x3a, 0x32, 0x2c, 0x22, 0x6d, 0x61, 0x6a, 0x6f, 0x72, 0x56,
- 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x32, 0x7d,
- 0x2c, 0x22, 0x61, 0x70, 0x70, 0x48, 0x4d, 0x49, 0x54, 0x79,
- 0x70, 0x65, 0x22, 0x3a, 0x5b, 0x22, 0x4e, 0x41, 0x56, 0x49,
- 0x47, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x22, 0x5d, 0x2c, 0x22,
- 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x44, 0x65,
- 0x73, 0x69, 0x72, 0x65, 0x64, 0x22, 0x3a, 0x22, 0x45, 0x4e,
- 0x2d, 0x55, 0x53, 0x22, 0x2c, 0x22, 0x61, 0x70, 0x70, 0x49,
- 0x44, 0x22, 0x3a, 0x22, 0x38, 0x36, 0x37, 0x35, 0x33, 0x30,
- 0x38, 0x22, 0x7d
- ])
- zeroLenRegisterApp = bytes([
- 0x21, 0x07, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x02
- ])
-
- s.sendall(startSession)
- sleep(1)
- s.sendall(registerApp)
- sleep(1)
- s.sendall(zeroLenRegisterApp)
- sleep(1)
- rndfile = open("/dev/urandom","rb")
- while True:
- s.sendall(rndfile.read(1024))
- s.close()
-
-if __name__ == '__main__':
- main()
diff --git a/test/thirdPartyLibs/CMakeLists.txt b/test/thirdPartyLibs/CMakeLists.txt
deleted file mode 100644
index ef1c09072..000000000
--- a/test/thirdPartyLibs/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# --- jsoncpp
-add_subdirectory(./jsoncpp)
diff --git a/test/thirdPartyLibs/jsoncpp/CMakeLists.txt b/test/thirdPartyLibs/jsoncpp/CMakeLists.txt
deleted file mode 100644
index 79658002c..000000000
--- a/test/thirdPartyLibs/jsoncpp/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-include_directories (
- ${GMOCK_INCLUDE_DIRECTORY}
- ${JSONCPP_INCLUDE_DIRECTORY}
- ./include
-)
-
-set (SOURCES
- ./src/json_reader_test.cc
-)
-
-add_library("test_JSONCPPTest" "${SOURCES}")
diff --git a/test/thirdPartyLibs/jsoncpp/include/jsoncpp/json_reader_test.h b/test/thirdPartyLibs/jsoncpp/include/jsoncpp/json_reader_test.h
deleted file mode 100644
index bd85157ba..000000000
--- a/test/thirdPartyLibs/jsoncpp/include/jsoncpp/json_reader_test.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
-* \file json_reader_test.h
-* \brief JSONReaderTest test header file.
-*
-* 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 TEST_THIRDPARTYLIBS_JSONCPP_INCLUDE_JSONCPP_JSON_READER_TEST_H_
-#define TEST_THIRDPARTYLIBS_JSONCPP_INCLUDE_JSONCPP_JSON_READER_TEST_H_
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-#include "json/reader.h"
-
-namespace test {
-namespace third_party_libs {
-namespace json_reader_test {
-
-class JSONReaderTest : public ::testing::Test {
- protected:
- virtual void SetUp();
- virtual void TearDown() {}
-
- std::string normalString_;
- std::string backspaceString_;
- std::string formfeedString_;
- std::string linefeedString_;
- std::string returnString_;
- std::string tabString_;
- std::string bellString_;
- std::string quoteString_;
- std::string slashString_;
- std::string backslashString_;
- std::string singlequoteString_;
- std::string openingbraceString_;
- std::string closingbraceString_;
- std::string openingbracketString_;
- std::string closingbracketString_;
- std::string comaString_;
- std::string colonString_;
-
- Json::Reader reader;
- Json::Value json;
-
-};
-
-void JSONReaderTest::SetUp()
-{
- normalString_ = "{\"field\" : \"value\" }";
- backspaceString_ = "{\"field\" : \"va\blue\" }";
- formfeedString_ = "{\"field\" : \"va\flue\" }";
- linefeedString_ = "{\"field\" : \"va\nlue\" }";
- returnString_ = "{\"field\" : \"va\rlue\" }";
- tabString_ = "{\"field\" : \"va\tlue\" }";
- bellString_ = "{\"field\" : \"va\alue\" }";
- quoteString_ = "{\"field\" : \"va\"lue\" }";
- slashString_ = "{\"field\" : \"va/lue\" }";
- backslashString_ = "{\"field\" : \"va\\lue\" }";
- singlequoteString_ = "{\"field\" : \"va\'lue\" }";
- openingbraceString_ = "{\"field\" : \"va{lue\" }";
- closingbraceString_ = "{\"field\" : \"va}lue\" }";
- openingbracketString_ = "{\"field\" : \"va[lue\" }";
- closingbracketString_ = "{\"field\" : \"va]lue\" }";
- comaString_ = "{\"field\" : \"va,lue\" }";
- colonString_ = "{\"field\" : \"va:lue\" }";
-}
-
-TEST_F(JSONReaderTest, ParseNormalString) {
- ASSERT_TRUE(reader.parse(normalString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseBackspaceString) {
- ASSERT_TRUE(reader.parse(backspaceString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseFormFeedString) {
- ASSERT_TRUE(reader.parse(formfeedString_, json));
-
-}
-
-TEST_F(JSONReaderTest, ParseLineFeedString) {
- ASSERT_TRUE(reader.parse(linefeedString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseReturnString) {
- ASSERT_TRUE(reader.parse(returnString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseTabString) {
- ASSERT_TRUE(reader.parse(tabString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseBellString) {
- ASSERT_TRUE(reader.parse(bellString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseQuoteString) {
- ASSERT_TRUE(reader.parse(quoteString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseSlashString) {
- ASSERT_TRUE(reader.parse(slashString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseBackslashString) {
- ASSERT_TRUE(reader.parse(backslashString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseSinglequoteString) {
- ASSERT_TRUE(reader.parse(singlequoteString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseColonString) {
- ASSERT_FALSE(reader.parse(colonString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseComaString) {
- ASSERT_FALSE(reader.parse(comaString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseOpeningbraceString) {
- ASSERT_FALSE(reader.parse(openingbraceString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseClosingbraceString) {
- ASSERT_FALSE(reader.parse(closingbraceString_, json));
-}
-
-TEST_F(JSONReaderTest, ParseOpeningbracketString) {
- ASSERT_FALSE(reader.parse(openingbracketString_, json));
-}
-TEST_F(JSONReaderTest, ParseClosingbracketString) {
- ASSERT_FALSE(reader.parse(closingbracketString_, json));
-}
-
-} // namespace json_reader_test
-} // namespace components
-} // namespace test
-
-#endif // TEST_THIRDPARTYLIBS_JSONCPP_INCLUDE_JSONCPP_JSON_READER_TEST_H_
diff --git a/test/thirdPartyLibs/jsoncpp/src/json_reader_test.cc b/test/thirdPartyLibs/jsoncpp/src/json_reader_test.cc
deleted file mode 100644
index 0c203c015..000000000
--- a/test/thirdPartyLibs/jsoncpp/src/json_reader_test.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* \file json_reader_test.cc
-* \brief JSONReaderTest test source file.
-*
-* 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.
-*/
-
-#include "jsoncpp/json_reader_test.h"
diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt
deleted file mode 100644
index 81f5933fe..000000000
--- a/test/tools/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_subdirectory(intergen)
-add_subdirectory(policy_table_validator)
diff --git a/test/tools/intergen/CMakeLists.txt b/test/tools/intergen/CMakeLists.txt
deleted file mode 100644
index 4440cdc41..000000000
--- a/test/tools/intergen/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-include(${CMAKE_SOURCE_DIR}/tools/intergen/GenerateInterfaceLibrary.cmake)
-
-if (${HMI_DBUS_API})
- GenerateInterfaceLibrary("test_interface.xml" test_rpc_interface DBUS_SUPPORT)
-else()
- GenerateInterfaceLibrary("test_interface.xml" test_rpc_interface)
-endif()
-
-set (TEST_HMI_INTERFACES
- common
- buttons
- navigation
- basic_communication
- tts
- ui
-)
-
-if (${HMI_DBUS_API})
- GenerateInterfaceLibrary("test_hmi_interafce.xml" "${TEST_HMI_INTERFACES}" AUTO_FUNC_IDS DBUS_SUPPORT)
-else()
- GenerateInterfaceLibrary("test_hmi_interafce.xml" "${TEST_HMI_INTERFACES}" AUTO_FUNC_IDS)
-endif()
-
-include_directories (
- ${CMAKE_SOURCE_DIR}/src/components/rpc_base/include
- ${GMOCK_INCLUDE_DIRECTORY}
- ${JSONCPP_INCLUDE_DIRECTORY}
- ${CMAKE_CURRENT_BINARY_DIR}
-)
-
-set (LIBRARIES
- gtest
- gtest_main
- gmock
- gmock_main
- test_rpc_interface
-)
-
-set (SOURCES
- src/generated_interface_json_tests.cc
-)
-
-if (${HMI_DBUS_API})
- # Build dbus tests
- include_directories(
- ${CMAKE_SOURCE_DIR}/src/components/dbus/include
- ${DBUS_INCLUDE_DIRS}
- )
- set (LIBRARIES ${LIBRARIES} DBus)
- set (SOURCES ${SOURCES} src/generated_interface_dbus_tests.cc)
-endif ()
-
-
-create_test(test_generated_interface "${SOURCES}" "${LIBRARIES}")
diff --git a/test/tools/intergen/src/generated_interface_dbus_tests.cc b/test/tools/intergen/src/generated_interface_dbus_tests.cc
deleted file mode 100644
index 56b094940..000000000
--- a/test/tools/intergen/src/generated_interface_dbus_tests.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-#include "gmock/gmock.h"
-
-#include <test_rpc_interface/interface.h>
-#include <test_rpc_interface/functions.h>
-
-#include "dbus/dbus_message.h"
-
-namespace test {
-using namespace rpc::test_rpc_interface;
-
-TEST(GeneratedInterfaceDbusTests, TestFailedDbusDeserialization) {
- dbus::MessageRef msg(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL));
- {
- dbus::MessageWriter writer(msg);
- }
- {
- dbus::MessageReader reader(msg);
- request::DiagnosticMessage dm(&reader);
- ASSERT_TRUE(reader.has_failed());
- ASSERT_TRUE(dm.is_initialized());
- ASSERT_FALSE(dm.is_valid());
- }
-}
-
-TEST(GeneratedInterfaceDbusTests, TestDbusDeserialization) {
- dbus::MessageRef msg(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL));
- {
- dbus::MessageWriter writer(msg);
- writer.PutUint16(22);
- writer.PutUint16(42);
- dbus::MessageWriter array_writer(&writer, dbus::kArray, DBUS_TYPE_BYTE_AS_STRING);
- array_writer.PutByte(11);
- }
- {
- dbus::MessageReader reader(msg);
- request::DiagnosticMessage dm(&reader);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- ASSERT_TRUE(dm.is_initialized());
- ASSERT_TRUE(dm.is_valid());
- ASSERT_EQ(dm.targetID, 22);
- ASSERT_EQ(dm.messageLength, 42);
- ASSERT_EQ(dm.messageData.size(), 1u);
- }
-}
-
-TEST(GeneratedInterfaceDbusTests, TestDbusSerializationDeserialization) {
- dbus::MessageRef msg(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL));
- {
- dbus::MessageWriter writer(msg);
- request::DiagnosticMessage dm;
- dm.targetID = 70;
- dm.messageLength = 1;
- dm.messageData.push_back(42);
- dm.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msg);
- request::DiagnosticMessage dm(&reader);
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- ASSERT_TRUE(dm.is_initialized());
- ASSERT_TRUE(dm.is_valid());
- ASSERT_EQ(dm.targetID, 70);
- ASSERT_EQ(dm.messageLength, 1);
- ASSERT_EQ(dm.messageData.size(), 1u);
- ASSERT_EQ(dm.messageData[0], 42u);
- }
-}
-
-TEST(GeneratedInterfaceDbusTests, TestDbusAddSubMenuSerializatioDeserialization) {
- dbus::MessageRef msg(dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL));
- {
- dbus::MessageWriter writer(msg);
- notification::DummyNotification dn;
- TdStruct tds;
- tds.resArrMap["Hello"].push_back(R_SUCCESS);
- (*tds.optionalResArrMap)["World"].push_back(R_INVALID_DATA);
- dn.tds.push_back(tds);
- ASSERT_TRUE(dn.is_valid());
- dn.ToDbusWriter(&writer);
- }
- {
- dbus::MessageReader reader(msg);
- notification::DummyNotification dn(&reader);
- ASSERT_TRUE(dn.is_initialized());
- ASSERT_TRUE(dn.is_valid());
- ASSERT_FALSE(reader.has_failed());
- ASSERT_FALSE(reader.HasNext());
- ASSERT_EQ(dn.tds[0].resArrMap["Hello"][0], R_SUCCESS);
- ASSERT_EQ((*dn.tds[0].optionalResArrMap)["World"][0], R_INVALID_DATA);
- }
-}
-
-} // namespace test
diff --git a/test/tools/intergen/src/generated_interface_json_tests.cc b/test/tools/intergen/src/generated_interface_json_tests.cc
deleted file mode 100644
index 3d7532371..000000000
--- a/test/tools/intergen/src/generated_interface_json_tests.cc
+++ /dev/null
@@ -1,593 +0,0 @@
-#include "gmock/gmock.h"
-
-#include <test_rpc_interface/interface.h>
-#include <test_rpc_interface/functions.h>
-
-#include "json/reader.h"
-#include "json/writer.h"
-#include "rpc_base/gtest_support.h"
-
-namespace test {
-using namespace rpc::test_rpc_interface;
-using Json::Value;
-
-class TestRequestHandlerMock: public request::Handler {
-public:
- MOCK_METHOD1(HandleAddSubMenu, void(const request::AddSubMenu& params));
- MOCK_METHOD1(HandleDiagnosticMessage, void(const request::DiagnosticMessage& params));
- ~TestRequestHandlerMock() {}
-};
-
-class GeneratedInterfaceTests: public ::testing::Test {
- public:
- Json::Value JsonValue(const char* json) {
- Json::Value value;
- reader.parse(json, value);
- return value;
- }
- Json::Reader reader;
- Json::FastWriter writer;
-};
-
-TEST_F(GeneratedInterfaceTests, ScrollableMessageTest) {
- const char* org_json = "{\"reason\":\"MASTER_RESET\"}\n";
- Value json_value = JsonValue(org_json);
- notification::OnAppInterfaceUnregistered oaiu(&json_value);
- ASSERT_TRUE(oaiu.is_initialized());
- ASSERT_RPCTYPE_VALID(oaiu);
-
- std::string serialized = writer.write(oaiu.ToJsonValue());
- ASSERT_EQ(org_json, serialized);
-}
-
-TEST_F(GeneratedInterfaceTests, FunctionWithoutParams) {
- notification::OnAudioPassThru oapt;
- ASSERT_FALSE(oapt.is_initialized());
- ASSERT_FALSE(oapt.is_valid());
- oapt.mark_initialized();
- ASSERT_TRUE(oapt.is_initialized());
- ASSERT_RPCTYPE_VALID(oapt);
- std::string serialized = writer.write(oapt.ToJsonValue());
- ASSERT_EQ("{}\n", serialized);
-}
-
-TEST_F(GeneratedInterfaceTests, DefValueTest) {
- const char* org_json = "{\"menuID\":2,\"menuName\":\"Hello\"}";
- const char* awaited_json = "{\"menuID\":2,\"menuName\":\"Hello\",\"position\":1000}\n";
- Value json_value = JsonValue(org_json);
- request::AddSubMenu aasm(&json_value);
- ASSERT_TRUE(aasm.is_initialized());
- ASSERT_RPCTYPE_VALID(aasm);
- ASSERT_EQ(aasm.position, 1000);
-
- std::string serialized = writer.write(aasm.ToJsonValue());
- ASSERT_EQ(awaited_json, serialized);
-}
-
-TEST_F(GeneratedInterfaceTests, MapTest) {
- const char* expected_json =
- "{\"choiceID\":1,\"menuName\":\"Menu name\",\"vrCommands\":{\"one\":\"First value\",\"two\":\"Second value\"}}\n";
-
- Choice choice;
- ASSERT_FALSE(choice.is_initialized());
- ASSERT_FALSE(choice.is_valid());
- std::map<std::string, std::string> init_map;
- init_map.insert(std::make_pair("one", "First value"));
- init_map.insert(std::make_pair("two", "Second value"));
- choice = Choice(1, "Menu name", init_map);
- ASSERT_TRUE(choice.is_initialized());
- ASSERT_RPCTYPE_VALID(choice);
-
- std::string serialized = writer.write(choice.ToJsonValue());
- ASSERT_EQ(expected_json, serialized);
-}
-
-TEST_F(GeneratedInterfaceTests, TypedefTest) {
- const char* expected_json =
- "{\"optionalResArrMap\":{\"World\":[\"INVALID_DATA\"]},\"resArrMap\":{\"Hello\":[\"SUCCESS\"]}}\n";
-
- TdStruct ts;
- ts.resArrMap["Hello"].push_back(R_SUCCESS);
- (*ts.optionalResArrMap)["World"].push_back(R_INVALID_DATA);
- ASSERT_TRUE(ts.is_initialized());
- ASSERT_RPCTYPE_VALID(ts);
- std::string serialized = writer.write(ts.ToJsonValue());
- ASSERT_EQ(expected_json, serialized);
-}
-
-TEST_F(GeneratedInterfaceTests, OverflowedDiagnosticMessageTest) {
- const char* input_json =
- "{\"messageData\":[300, 20],\"messageLength\":2,\"targetID\":5}";
- Value json_value = JsonValue(input_json);
- request::DiagnosticMessage dm(&json_value);
- ASSERT_TRUE(dm.is_initialized());
- ASSERT_FALSE(dm.is_valid());
-}
-
-TEST_F(GeneratedInterfaceTests, OverflowedDiagnosticMessageTest64) {
- const char* input_json =
- "{\"messageData\":[10, 123456789123],\"messageLength\":2,\"targetID\":5}";
- Value json_value = JsonValue(input_json);
- request::DiagnosticMessage dm(&json_value);
- ASSERT_TRUE(dm.is_initialized());
- ASSERT_FALSE(dm.is_valid());
-}
-
-TEST_F(GeneratedInterfaceTests, TestHandlerCalled) {
- testing::StrictMock<TestRequestHandlerMock> mock;
- request::AddSubMenu add_submenu;
- EXPECT_CALL(mock, HandleAddSubMenu(testing::Ref(add_submenu)))
- .Times(1);
- add_submenu.HandleWith(&mock);
-}
-
-TEST_F(GeneratedInterfaceTests, TestFactory) {
- testing::StrictMock<TestRequestHandlerMock> mock;
- Json::Value json_value;
- request::Request* req = request::NewFromJson(&json_value, kAddSubMenuID);
- request::AddSubMenu& add_sub_menu_ref =
- static_cast<request::AddSubMenu&>(*req);
- EXPECT_CALL(mock, HandleAddSubMenu(testing::Ref(add_sub_menu_ref)))
- .Times(1);
- req->HandleWith(&mock);
-}
-
-TEST_F(GeneratedInterfaceTests, TestNullableStructMember) {
- TestStructWithNullableParam with_nullable;
- ASSERT_FALSE(with_nullable.is_initialized());
- ASSERT_FALSE(with_nullable.is_valid());
- ASSERT_FALSE(with_nullable.nullableInt.is_valid());
- ASSERT_FALSE(with_nullable.nullableInt.is_null());
- with_nullable.nullableInt.set_to_null();
- ASSERT_RPCTYPE_VALID(with_nullable);
- ASSERT_TRUE(with_nullable.is_initialized());
- ASSERT_TRUE(with_nullable.nullableInt.is_null());
- ASSERT_RPCTYPE_VALID(with_nullable.nullableInt);
- ASSERT_TRUE(with_nullable.nullableInt.is_initialized());
-}
-
-TEST_F(GeneratedInterfaceTests, TestNullableStructMemberNullInitializationFromJson) {
- const char* input_json =
- "{\"nullableInt\":null}\n";
- Value json_value = JsonValue(input_json);
- TestStructWithNullableParam with_nullable(&json_value);
- ASSERT_TRUE(with_nullable.is_initialized());
- ASSERT_RPCTYPE_VALID(with_nullable);
- ASSERT_TRUE(with_nullable.nullableInt.is_null());
- std::string result = writer.write(with_nullable.ToJsonValue());
- ASSERT_EQ(input_json, result);
-}
-
-TEST_F(GeneratedInterfaceTests, TestNullableStructMemberInitializationFromJson) {
- const char* input_json =
- "{\"nullableInt\":3}\n";
- Value json_value = JsonValue(input_json);
- TestStructWithNullableParam with_nullable(&json_value);
- ASSERT_TRUE(with_nullable.is_initialized());
- ASSERT_RPCTYPE_VALID(with_nullable);
- ASSERT_FALSE(with_nullable.nullableInt.is_null());
- ASSERT_EQ(3, with_nullable.nullableInt);
- std::string result = writer.write(with_nullable.ToJsonValue());
- ASSERT_EQ(input_json, result);
-}
-
-TEST_F(GeneratedInterfaceTests, TestNullableEnumInitialization) {
- TestStructWithNullableStructParam strct_with_nullable;
- strct_with_nullable.nullableEnum = IT_DYNAMIC;
- strct_with_nullable.nonNullableEnum = IT_STATIC;
- ASSERT_TRUE(strct_with_nullable.is_initialized());
- ASSERT_RPCTYPE_VALID(strct_with_nullable);
- std::string result = writer.write(strct_with_nullable.ToJsonValue());
- const char* awaited_json1 = "{\"nonNullableEnum\":\"STATIC\",\"nullableEnum\":\"DYNAMIC\"}\n";
- ASSERT_EQ(awaited_json1, result);
-
- strct_with_nullable.nullableEnum.set_to_null();
- ASSERT_TRUE(strct_with_nullable.is_initialized());
- ASSERT_RPCTYPE_VALID(strct_with_nullable);
- result = writer.write(strct_with_nullable.ToJsonValue());
- const char* awaited_json2 = "{\"nonNullableEnum\":\"STATIC\",\"nullableEnum\":null}\n";
- ASSERT_EQ(awaited_json2, result);
-}
-
-TEST_F(GeneratedInterfaceTests, TestStructWithNullableTypedef) {
- StructWithNullableTypedef swntd;
- ASSERT_FALSE(swntd.is_initialized());
- ASSERT_FALSE(swntd.is_valid());
- swntd.nullableTdResult = R_SUCCESS;
- ASSERT_TRUE(swntd.is_initialized());
- ASSERT_RPCTYPE_VALID(swntd);
- ASSERT_EQ(R_SUCCESS, swntd.nullableTdResult);
-
- swntd.nullableTdResult.set_to_null();
- const char* awaited_json = "{\"nullableTdResult\":null}\n";
- std::string result = writer.write(swntd.ToJsonValue());
- ASSERT_EQ(awaited_json, result);
-}
-
-TEST_F(GeneratedInterfaceTests, TestNullingStructWithNullableMapOfNullableInts) {
- StructWithNullableMapOfNullableInts nmoni;
- ASSERT_FALSE(nmoni.is_initialized());
- ASSERT_FALSE(nmoni.is_valid());
- ASSERT_FALSE(nmoni.nullableMap.is_null());
- nmoni.nullableMap.set_to_null();
- ASSERT_TRUE(nmoni.is_initialized());
- ASSERT_RPCTYPE_VALID(nmoni);
- ASSERT_TRUE(nmoni.nullableMap.is_null());
- const char* awaited_json = "{\"nullableMap\":null}\n";
- std::string result = writer.write(nmoni.ToJsonValue());
- ASSERT_EQ(awaited_json, result);
-}
-
-TEST_F(GeneratedInterfaceTests, TestNullingValueInStructWithNullableMapOfNullableInts) {
- StructWithNullableMapOfNullableInts nmoni;
- ASSERT_FALSE(nmoni.is_initialized());
- ASSERT_FALSE(nmoni.is_valid());
- ASSERT_FALSE(nmoni.nullableMap.is_null());
- nmoni.nullableMap["Hello"].set_to_null();
-
- ASSERT_TRUE(nmoni.is_initialized());
- ASSERT_RPCTYPE_VALID(nmoni);
- ASSERT_FALSE(nmoni.nullableMap.is_null());
- ASSERT_TRUE(nmoni.nullableMap["Hello"].is_null());
- const char* awaited_json = "{\"nullableMap\":{\"Hello\":null}}\n";
- std::string result = writer.write(nmoni.ToJsonValue());
- ASSERT_EQ(awaited_json, result);
-}
-
-TEST_F(GeneratedInterfaceTests, EmptyStructTests) {
- EmptyStruct e;
- ASSERT_TRUE(e.struct_empty());
- ASSERT_FALSE(e.is_valid());
- ASSERT_FALSE(e.is_initialized());
- e.mark_initialized();
- ASSERT_TRUE(e.struct_empty());
- ASSERT_RPCTYPE_VALID(e);
- ASSERT_TRUE(e.is_initialized());
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOptionalEmptyStructFieldTest) {
- StructWithOptionalEmptyStructField oe;
- ASSERT_FALSE(oe.is_valid());
- ASSERT_FALSE(oe.is_initialized());
- oe.emptyOne->mark_initialized();
- ASSERT_RPCTYPE_VALID(oe);
- ASSERT_TRUE(oe.is_initialized());
- ASSERT_FALSE(oe.struct_empty());
- ASSERT_TRUE(oe.emptyOne->struct_empty());
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithMandatoryEmptyStructFieldTest) {
- StructWithMandatoryEmptyStructField me;
- ASSERT_FALSE(me.is_valid());
- ASSERT_FALSE(me.is_initialized());
-}
-
-TEST_F(GeneratedInterfaceTests, EmptyStructJsonTests) {
- EmptyStruct e;
- ASSERT_FALSE(e.is_valid());
- ASSERT_FALSE(e.is_initialized());
- e.mark_initialized();
- ASSERT_RPCTYPE_VALID(e);
- ASSERT_TRUE(e.is_initialized());
- const char* expected_json = "{}\n";
- ASSERT_EQ(expected_json, writer.write(e.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOptionalEmptyStructFieldJsonTest) {
- StructWithOptionalEmptyStructField oe;
- ASSERT_FALSE(oe.is_valid());
- ASSERT_FALSE(oe.is_initialized());
- oe.mark_initialized();
- ASSERT_RPCTYPE_VALID(oe);
- ASSERT_TRUE(oe.is_initialized());
- const char* expected_json = "{}\n";
- ASSERT_EQ(expected_json, writer.write(oe.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithMandatoryEmptyStructFieldJsonTest) {
- StructWithMandatoryEmptyStructField me;
- ASSERT_FALSE(me.is_valid());
- ASSERT_FALSE(me.is_initialized());
- me.emptyOne.mark_initialized();
- ASSERT_RPCTYPE_VALID(me);
- ASSERT_TRUE(me.is_initialized());
- const char* expected_json = "{\"emptyOne\":{}}\n";
- ASSERT_EQ(expected_json, writer.write(me.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOneOptionalIntFieldTest) {
- StructWithOneOptionalIntField soo;
- ASSERT_FALSE(soo.is_valid());
- ASSERT_FALSE(soo.is_initialized());
- soo.mark_initialized();
- ASSERT_TRUE(soo.is_initialized());
- ASSERT_RPCTYPE_VALID(soo);
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOneOptionalInitializedIntFieldTest) {
- StructWithOneOptionalIntField soo;
- *soo.optionalInt = 13;
- ASSERT_RPCTYPE_VALID(soo);
- ASSERT_TRUE(soo.is_initialized());
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOneOptionalIntFieldJsonTest) {
- StructWithOneOptionalIntField soo;
- ASSERT_FALSE(soo.is_valid());
- ASSERT_FALSE(soo.is_initialized());
- soo.mark_initialized();
- const char* expected_json = "{}\n";
- ASSERT_EQ(expected_json, writer.write(soo.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOneInitializedOptionalIntFieldJsonTest) {
- const char* input_json = "{\"optionalInt\":11}\n";
- Json::Value json_value = JsonValue(input_json);
- StructWithOneOptionalIntField soo(&json_value);
- ASSERT_RPCTYPE_VALID(soo);
- ASSERT_TRUE(soo.is_initialized());
- ASSERT_EQ(11, *soo.optionalInt);
- ASSERT_EQ(input_json, writer.write(soo.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfStructThatMightBeEmptyTest) {
- StructWithFieldOfStructThatMightBeEmpty sfme;
- ASSERT_FALSE(sfme.is_valid());
- ASSERT_FALSE(sfme.is_initialized());
- ASSERT_TRUE(sfme.struct_empty());
- *sfme.fieldThatMightBeEmpty.optionalInt = 5;
- ASSERT_FALSE(sfme.struct_empty());
- ASSERT_RPCTYPE_VALID(sfme);
- ASSERT_TRUE(sfme.is_initialized());
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfStructThatMightBeEmptyJsonNoValueTest) {
- StructWithFieldOfStructThatMightBeEmpty sfme;
- ASSERT_TRUE(sfme.struct_empty());
- ASSERT_FALSE(sfme.is_valid());
- ASSERT_FALSE(sfme.is_initialized());
- sfme.fieldThatMightBeEmpty.mark_initialized();
- ASSERT_FALSE(sfme.struct_empty());
- ASSERT_RPCTYPE_VALID(sfme);
- ASSERT_TRUE(sfme.is_initialized());
- const char* expcected_json = "{\"fieldThatMightBeEmpty\":{}}\n";
- ASSERT_EQ(expcected_json, writer.write(sfme.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfStructThatMightBeEmptyJsonHasValueTest) {
- const char* input_json = "{\"fieldThatMightBeEmpty\":{\"optionalInt\":12}}\n";
- Json::Value json_value = JsonValue(input_json);
- StructWithFieldOfStructThatMightBeEmpty sfme(&json_value);
- ASSERT_RPCTYPE_VALID(sfme);
- ASSERT_TRUE(sfme.is_initialized());
- ASSERT_EQ(12, *sfme.fieldThatMightBeEmpty.optionalInt);
- ASSERT_EQ(input_json, writer.write(sfme.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfOptionalMapTest) {
- StructWithNullableOptionalMap snom;
- ASSERT_TRUE(snom.struct_empty());
- ASSERT_FALSE(snom.is_valid());
- ASSERT_FALSE(snom.is_initialized());
- (*snom.nullableOptionalIntMap)["a"] = 5;
- ASSERT_FALSE(snom.struct_empty());
- ASSERT_RPCTYPE_VALID(snom);
- ASSERT_TRUE(snom.is_initialized());
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfOptionalMapToJsonTest) {
- StructWithNullableOptionalMap snom;
- ASSERT_TRUE(snom.struct_empty());
- ASSERT_FALSE(snom.is_valid());
- ASSERT_FALSE(snom.is_initialized());
- snom.mark_initialized();
- ASSERT_TRUE(snom.struct_empty());
- ASSERT_RPCTYPE_VALID(snom);
- ASSERT_TRUE(snom.is_initialized());
- const char* expected_json = "{}\n";
- ASSERT_EQ(expected_json, writer.write(snom.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfOptionalMapNulledToJsonTest) {
- StructWithNullableOptionalMap snom;
- ASSERT_TRUE(snom.struct_empty());
- ASSERT_FALSE(snom.is_valid());
- ASSERT_FALSE(snom.is_initialized());
- snom.nullableOptionalIntMap->set_to_null();
- ASSERT_FALSE(snom.struct_empty());
- ASSERT_RPCTYPE_VALID(snom);
- ASSERT_TRUE(snom.is_initialized());
- const char* expected_json = "{\"nullableOptionalIntMap\":null}\n";
- ASSERT_EQ(expected_json, writer.write(snom.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfOptionalMapNulledInJsonTest) {
- const char* input_json = "{\"nullableOptionalIntMap\":null}\n";
- Json::Value json_value = JsonValue(input_json);
- StructWithNullableOptionalMap snom(&json_value);
- ASSERT_RPCTYPE_VALID(snom);
- ASSERT_TRUE(snom.is_initialized());
- ASSERT_TRUE(snom.nullableOptionalIntMap->is_null());
- ASSERT_EQ(input_json, writer.write(snom.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithFieldOfOptionalMapInitializedInJsonTest) {
- const char* input_json = "{\"nullableOptionalIntMap\":{\"Hello\":2}}\n";
- Json::Value json_value = JsonValue(input_json);
- StructWithNullableOptionalMap snom(&json_value);
- ASSERT_RPCTYPE_VALID(snom);
- ASSERT_TRUE(snom.is_initialized());
- ASSERT_FALSE(snom.nullableOptionalIntMap->is_null());
- ASSERT_EQ(input_json, writer.write(snom.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOptionalArrayTest) {
- const char* expected_json = "{}\n";
- StructWithOptionalIntArray soia;
- ASSERT_TRUE(soia.struct_empty());
- ASSERT_FALSE(soia.is_valid());
- ASSERT_FALSE(soia.is_initialized());
- soia.mark_initialized();
- ASSERT_EQ(expected_json, writer.write(soia.ToJsonValue()));
- (*soia.optionalIntArray).push_back(2);
- ASSERT_RPCTYPE_VALID(soia);
- ASSERT_TRUE(soia.is_initialized());
- const char* expected_json2 = "{\"optionalIntArray\":[2]}\n";
- ASSERT_EQ(expected_json2, writer.write(soia.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithMandatoryArrayTest) {
- const char* expected_json = "{\"mandatoryIntArray\":[]}\n";
- StructWithMandatoryIntArray smia;
- ASSERT_FALSE(smia.is_valid());
- ASSERT_FALSE(smia.is_initialized());
- smia.mandatoryIntArray.mark_initialized();
- ASSERT_RPCTYPE_VALID(smia);
- ASSERT_TRUE(smia.is_initialized());
- ASSERT_EQ(expected_json, writer.write(smia.ToJsonValue()));
-
- smia.mandatoryIntArray.push_back(3);
- ASSERT_RPCTYPE_VALID(smia);
- ASSERT_TRUE(smia.is_initialized());
- const char* expected_json2 = "{\"mandatoryIntArray\":[3]}\n";
- ASSERT_EQ(expected_json2, writer.write(smia.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithOptionalMapTest) {
- const char* expected_json = "{}\n";
- StructWithOptionalIntMap soim;
- ASSERT_TRUE(soim.struct_empty());
- ASSERT_FALSE(soim.is_valid());
- ASSERT_FALSE(soim.is_initialized());
- soim.mark_initialized();
- ASSERT_TRUE(soim.struct_empty());
- ASSERT_RPCTYPE_VALID(soim);
- ASSERT_TRUE(soim.is_initialized());
- ASSERT_EQ(expected_json, writer.write(soim.ToJsonValue()));
- (*soim.optionalIntMap)["Yay"] = 2;
- ASSERT_RPCTYPE_VALID(soim);
- ASSERT_TRUE(soim.is_initialized());
- const char* expected_json2 = "{\"optionalIntMap\":{\"Yay\":2}}\n";
- ASSERT_EQ(expected_json2, writer.write(soim.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithMandatoryMapTest) {
- const char* expected_json = "{\"mandatoryIntMap\":{}}\n";
- StructWithMandatoryIntMap smim;
- ASSERT_FALSE(smim.is_valid());
- ASSERT_FALSE(smim.is_initialized());
- smim.mandatoryIntMap.mark_initialized();
- ASSERT_RPCTYPE_VALID(smim);
- ASSERT_TRUE(smim.is_initialized());
- ASSERT_EQ(expected_json, writer.write(smim.ToJsonValue()));
- smim.mandatoryIntMap["Yay"] = 2;
- ASSERT_RPCTYPE_VALID(smim);
- ASSERT_TRUE(smim.is_initialized());
- const char* expected_json2 = "{\"mandatoryIntMap\":{\"Yay\":2}}\n";
- ASSERT_EQ(expected_json2, writer.write(smim.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, StructWithMandatoryMapInitFromWrongJsonTest) {
- const char* empty_json = "{}\n";
- Json::Value json_value = JsonValue(empty_json);
-
- StructWithMandatoryIntMap smim(&json_value);
-
- ASSERT_TRUE(smim.struct_empty());
- ASSERT_FALSE(smim.is_valid());
- ASSERT_TRUE(smim.is_initialized());
-
- smim.mandatoryIntMap["Yay"] = 2;
- ASSERT_FALSE(smim.struct_empty());
- ASSERT_RPCTYPE_VALID(smim);
- ASSERT_TRUE(smim.is_initialized());
- const char* expected_json = "{\"mandatoryIntMap\":{\"Yay\":2}}\n";
- ASSERT_EQ(expected_json, writer.write(smim.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, ReportIncorrectlyInitializedMap1) {
- StructWithMandatoryIntMap smim;
- smim.mark_initialized();
- ASSERT_FALSE(smim.is_valid());
- rpc::ValidationReport report("smim");
- smim.ReportErrors(&report);
- ASSERT_EQ("smim.mandatoryIntMap: object is not initialized\n", PrettyFormat(report));
-}
-
-TEST_F(GeneratedInterfaceTests, ReportIncorrectlyInitializedMap2) {
- Choice c;
- ASSERT_FALSE(c.is_valid());
- rpc::ValidationReport report("c");
- c.ReportErrors(&report);
- ASSERT_EQ("c: object is not initialized\n"
- "c.choiceID: value is not initialized\n"
- "c.menuName: value is not initialized\n"
- "c.vrCommands: object is not initialized\n", PrettyFormat(report));
-}
-
-TEST_F(GeneratedInterfaceTests, TestFrankenstructCreation) {
- FrankenstructOfEmptyStringWithMandatoryInt fbmi;
- ASSERT_FALSE(fbmi.is_valid());
- ASSERT_FALSE(fbmi.is_initialized());
- ASSERT_TRUE(fbmi.empty());
- ASSERT_TRUE(fbmi.struct_empty());
- fbmi.mandatoryInt = 5;
- ASSERT_FALSE(fbmi.struct_empty());
- ASSERT_TRUE(fbmi.empty());
- ASSERT_TRUE(fbmi.is_initialized());
-
- // Ok known bug: frankenstructs must be explicitly marked initialized
- // or has values in map
- ASSERT_FALSE(fbmi.is_valid());
- fbmi.mark_initialized();
- ASSERT_RPCTYPE_VALID(fbmi);
-
- ASSERT_TRUE(fbmi.is_initialized());
-
- rpc::ValidationReport report("fbmi");
- fbmi.ReportErrors(&report);
- ASSERT_EQ("", PrettyFormat(report));
-}
-
-TEST_F(GeneratedInterfaceTests, FrankenstructToJson) {
- const char* expected_json = "{\"hello\":\"str\",\"mandatoryInt\":2}\n";
- FrankenstructOfEmptyStringWithMandatoryInt fbmi;
- fbmi.mandatoryInt = 2;
- fbmi["hello"] = "str";
- ASSERT_TRUE(fbmi.is_initialized());
- ASSERT_RPCTYPE_VALID(fbmi);
- ASSERT_FALSE(fbmi.empty());
- ASSERT_FALSE(fbmi.struct_empty());
- ASSERT_EQ(expected_json,
- writer.write(fbmi.ToJsonValue()));
-}
-
-TEST_F(GeneratedInterfaceTests, FrankenstructFromJson) {
- const char* input_json = "{\"hello\":\"str\",\"mandatoryInt\":2}\n";
- Json::Value json_value = JsonValue(input_json);
- FrankenstructOfEmptyStringWithMandatoryInt fbmi(&json_value);
- ASSERT_TRUE(fbmi.is_initialized());
- ASSERT_RPCTYPE_VALID(fbmi);
- ASSERT_FALSE(fbmi.empty());
- ASSERT_FALSE(fbmi.struct_empty());
- ASSERT_EQ(1u, fbmi.size());
- ASSERT_EQ(2, fbmi.mandatoryInt);
- ASSERT_EQ("str", std::string(fbmi["hello"]));
-}
-
-TEST_F(GeneratedInterfaceTests, FrankenstructFromInvalidJson) {
- const char* input_json = "{\"hello\":true,\"mandatoryInt\":2}\n";
- Json::Value json_value = JsonValue(input_json);
- FrankenstructOfEmptyStringWithMandatoryInt fbmi(&json_value);
- ASSERT_TRUE(fbmi.is_initialized());
- ASSERT_FALSE(fbmi.is_valid());
- ASSERT_FALSE(fbmi.empty());
- ASSERT_FALSE(fbmi.struct_empty());
- ASSERT_EQ(1u, fbmi.size());
- ASSERT_EQ(2, fbmi.mandatoryInt);
- rpc::ValidationReport report("fbmi");
- fbmi.ReportErrors(&report);
- ASSERT_EQ("fbmi[\"hello\"]: value initialized incorrectly\n", PrettyFormat(report));
-}
-
-} // namespace test
diff --git a/test/tools/intergen/test_hmi_interafce.xml b/test/tools/intergen/test_hmi_interafce.xml
deleted file mode 100644
index 487eb4773..000000000
--- a/test/tools/intergen/test_hmi_interafce.xml
+++ /dev/null
@@ -1,3669 +0,0 @@
-<?xml version="1.0" standalone="yes"?>
-
-<!--
-* 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. -->
-
-
-<interfaces name="SmartDeviceLink HMI API">
-
-<interface name="Common" version="1.1" date="2013-10-02">
-
-<enum name="Result">
- <element name="SUCCESS" value="0"/>
- <element name="UNSUPPORTED_REQUEST" value="1"/>
- <element name="UNSUPPORTED_RESOURCE" value="2"/>
- <element name="DISALLOWED" value="3"/>
- <element name="REJECTED" value="4"/>
- <element name="ABORTED" value="5"/>
- <element name="IGNORED" value="6"/>
- <element name="RETRY" value="7"/>
- <element name="IN_USE" value="8"/>
- <element name="DATA_NOT_AVAILABLE" value="9"/>
- <element name="TIMED_OUT" value="10"/>
- <element name="INVALID_DATA" value="11"/>
- <element name="CHAR_LIMIT_EXCEEDED" value="12"/>
- <element name="INVALID_ID" value="13"/>
- <element name="DUPLICATE_NAME" value="14"/>
- <element name="APPLICATION_NOT_REGISTERED" value="15"/>
- <element name="WRONG_LANGUAGE" value="16"/>
- <element name="OUT_OF_MEMORY" value="17"/>
- <element name="TOO_MANY_PENDING_REQUESTS" value="18"/>
- <element name="NO_APPS_REGISTERED" value="19"/>
- <element name="NO_DEVICES_CONNECTED" value="20"/>
- <element name="WARNINGS" value="21"/>
- <element name="GENERIC_ERROR" value="22"/>
- <element name="USER_DISALLOWED" value="23"/>
-</enum>
-
-<enum name="ButtonName">
- <description>Defines the hard (physical) and soft (touchscreen) buttons available from SYNC</description>
- <element name="OK"/>
- <element name="SEEKLEFT"/>
- <element name="SEEKRIGHT"/>
- <element name="TUNEUP"/>
- <element name="TUNEDOWN"/>
- <element name="PRESET_0"/>
- <element name="PRESET_1"/>
- <element name="PRESET_2"/>
- <element name="PRESET_3"/>
- <element name="PRESET_4"/>
- <element name="PRESET_5"/>
- <element name="PRESET_6"/>
- <element name="PRESET_7"/>
- <element name="PRESET_8"/>
- <element name="PRESET_9"/>
- <element name="CUSTOM_BUTTON"/>
- <element name="SEARCH"/>
-</enum>
-
-<enum name="ButtonEventMode">
- <element name="BUTTONUP">
- <description>A button has been released up</description>
- </element>
- <element name="BUTTONDOWN">
- <description>A button has been pressed down</description>
- </element>
-</enum>
-
-<enum name="ButtonPressMode">
- <element name="LONG">
- <description>A button was released, after it was pressed for a long time. Actual timing is defined by head unit and may vary</description>
- </element>
- <element name="SHORT">
- <description>A button was released, after it was pressed for a short time. Actual timing is defined by head unit and may vary</description>
- </element>
-</enum>
-
- <enum name="Language">
- <element name="EN-US" internal_name="EN_US">
- <description>English - US</description>
- </element>
- <element name="ES-MX" internal_name="ES_MX">
- <description>Spanish - Mexico</description>
- </element>
- <element name="FR-CA" internal_name="FR_CA">
- <description>French - Canada</description>
- </element>
- <element name="DE-DE" internal_name="DE_DE">
- <description>German - Germany</description>
- </element>
- <element name="ES-ES" internal_name="ES_ES">
- <description>Spanish - Spain</description>
- </element>
- <element name="EN-GB" internal_name="EN_GB">
- <description>English - GB</description>
- </element>
- <element name="RU-RU" internal_name="RU_RU">
- <description>Russian - Russia</description>
- </element>
- <element name="TR-TR" internal_name="TR_TR">
- <description>Turkish - Turkey</description>
- </element>
- <element name="PL-PL" internal_name="PL_PL">
- <description>Polish - Poland</description>
- </element>
- <element name="FR-FR" internal_name="FR_FR">
- <description>French - France</description>
- </element>
- <element name="IT-IT" internal_name="IT_IT">
- <description>Italian - Italy</description>
- </element>
- <element name="SV-SE" internal_name="SV_SE">
- <description>Swedish - Sweden</description>
- </element>
- <element name="PT-PT" internal_name="PT_PT">
- <description>Portuguese - Portugal</description>
- </element>
- <element name="NL-NL" internal_name="NL_NL">
- <description>Dutch (Standard) - Netherlands</description>
- </element>
- <element name="EN-AU" internal_name="EN_AU">
- <description>English - Australia</description>
- </element>
- <element name="ZH-CN" internal_name="ZH_CN">
- <description>Mandarin - China</description>
- </element>
- <element name="ZH-TW" internal_name="ZH_TW">
- <description>Mandarin - Taiwan</description>
- </element>
- <element name="JA-JP" internal_name="JA_JP">
- <description>Japanese - Japan</description>
- </element>
- <element name="AR-SA" internal_name="AR_SA">
- <description>Arabic - Saudi Arabia</description>
- </element>
- <element name="KO-KR" internal_name="KO_KR">
- <description>Korean - South Korea</description>
- </element>
- <element name="PT-BR" internal_name="PT_BR">
- <description>Portuguese - Brazil</description>
- </element>
- <element name="CS-CZ" internal_name="CS_CZ">
- <description>Czech - Czech Republic</description>
- </element>
- <element name="DA-DK" internal_name="DA_DK">
- <description>Danish - Denmark</description>
- </element>
- <element name="NO-NO" internal_name="NO_NO">
- <description>Norwegian - Norway</description>
- </element>
-</enum>
-
-<enum name="SoftButtonType">
- <description>Contains information about the SoftButton capabilities.</description>
- <element name="TEXT" internal_name="SBT_TEXT"/>
- <element name="IMAGE" internal_name="SBT_IMAGE"/>
- <element name="BOTH" internal_name="SBT_BOTH"/>
-</enum>
-
-<enum name="SystemAction">
- <description>Enumeration that describes system actions that can be triggered.</description>
- <element name="DEFAULT_ACTION">
- <description>Default action occurs. Standard behavior (e.g. SoftButton clears overlay).</description>
- </element>
- <element name="STEAL_FOCUS">
- <description>The calling app's dialog or related event should clear and the app should be brought into HMI_FULL.</description>
- </element>
- <element name="KEEP_CONTEXT">
- <description>Current system context is maintained. An overlay is persisted even though a SoftButton has been pressed and the notification sent.</description>
- </element>
-</enum>
-
-<enum name="AppHMIType">
- <description>Enumeration listing possible app types.</description>
- <element name="DEFAULT" />
- <element name="COMMUNICATION" />
- <element name="MEDIA" />
- <element name="MESSAGING" />
- <element name="NAVIGATION" />
- <element name="INFORMATION" />
- <element name="SOCIAL" />
- <element name="BACKGROUND_PROCESS" />
- <element name="TESTING" />
- <element name="SYSTEM" />
-</enum>
-
-<enum name="LayoutMode">
- <description>For touchscreen interactions, the mode of how the choices are presented.</description>
- <element name="ICON_ONLY" />
- <description>This mode causes the interaction to display the previous set of choices as icons.</description>
- <element name="ICON_WITH_SEARCH" />
- <description>This mode causes the interaction to display the previous set of choices as icons along with a search field in the HMI.</description>
- <element name="LIST_ONLY" />
- <description>This mode causes the interaction to display the previous set of choices as a list.</description>
- <element name="LIST_WITH_SEARCH" />
- <description>This mode causes the interaction to display the previous set of choices as a list along with a search field in the HMI.</description>
- <element name="KEYBOARD" />
- <description>This mode causes the interaction to immediately display a keyboard entry through the HMI.</description>
-</enum>
-
-<enum name="DeactivateReason">
- <description>Specifies the functionality the User has switched to.</description>
- <element name="AUDIO">
- <description>Navigated to audio(radio, etc)</description>
- </element>
- <element name="PHONECALL">
- <description>Navigated to make a call.</description>
- </element>
- <element name="NAVIGATIONMAP">
- <description>Navigated to navigation screen.</description>
- </element>
- <element name="PHONEMENU">
- <description>Navigated to phone menu.</description>
- </element>
- <element name="SYNCSETTINGS">
- <description>Navigated to settings menu.</description>
- </element>
- <element name="GENERAL">
- <description>Other screens navigation apart from other mobile app.</description>
- </element>
-</enum>
-
-<enum name="ClockUpdateMode">
- <description>Describes how the media clock timer should behave on the platform</description>
- <element name="COUNTUP" />
- <description>Starts the media clock timer counting upwards, as in time elapsed.</description>
- <element name="COUNTDOWN" />
- <description>Starts the media clock timer counting downwards, as in time remaining.</description>
- <element name="PAUSE" />
- <description>Pauses the media clock timer</description>
- <element name="RESUME" />
- <description>Resume the media clock timer</description>
- <element name="CLEAR" />
- <description>Clears the media clock timer (previously done through Show->mediaClock)</description>
-</enum>
-
-<enum name="SystemContext">
- <description>Enumeration that describes possible contexts the application might be in on HU.</description>
- <description>Communicated to whichever app is in HMI FULL, except Alert.</description>
- <element name="MAIN" internal_name="SYSCTXT_MAIN">
- <description>The app's persistent display (whether media/non-media/navigation) is fully visible onscreen.</description>
- <description> There is currently no user interaction (user-initiated or app-initiated) with the head-unit</description>
- </element>
- <element name="VRSESSION" internal_name="SYSCTXT_VRSESSION">
- <description>The system is currently in a VR session (with whatever dedicated VR screen being overlaid onscreen).</description>
- </element>
- <element name="MENU" internal_name="SYSCTXT_MENU">
- <description>The system is currently displaying a system or in-App menu onscreen.</description>
- </element>
- <element name="HMI_OBSCURED" internal_name="SYSCTXT_HMI_OBSCURED">
- <description>The app's display HMI is currently obscuring with either a system or other app's overlay (except of Alert element).</description>
- </element>
- <element name="ALERT" internal_name="SYSCTXT_ALERT">
- <description>Broadcast only to whichever app has an alert currently being displayed.</description>
- </element>
-</enum>
-
-<enum name="HmiZoneCapabilities">
- <description>Contains information about the HMI zone capabilities.</description>
- <description>For future use.</description>
- <element name="FRONT" />
- <element name="BACK" />
-</enum>
-
-<enum name="SpeechCapabilities">
- <description>Contains information about the TTS capabilities.</description>
- <element name="TEXT" internal_name="SC_TEXT" />
- <element name="SAPI_PHONEMES" />
- <element name="LHPLUS_PHONEMES" />
- <element name="PRE_RECORDED" />
- <element name="SILENCE" />
-</enum>
-
-<enum name="VrCapabilities">
- <description>Contains information about the VR capabilities.</description>
- <element name="TEXT" internal_name="VR_TEXT" />
-</enum>
-
-<enum name="TBTState">
- <description>Enumeration that describes possible states of turn-by-turn client or SmartDeviceLink app.</description>
- <element name="ROUTE_UPDATE_REQUEST" />
- <element name="ROUTE_ACCEPTED" />
- <element name="ROUTE_REFUSED" />
- <element name="ROUTE_CANCELLED" />
- <element name="ETA_REQUEST" />
- <element name="NEXT_TURN_REQUEST" />
- <element name="ROUTE_STATUS_REQUEST" />
- <element name="ROUTE_SUMMARY_REQUEST" />
- <element name="TRIP_STATUS_REQUEST" />
- <element name="ROUTE_UPDATE_REQUEST_TIMEOUT" />
-</enum>
-
-<enum name="ApplicationsCloseReason">
- <description>Describes the reasons for exiting all of applications.</description>
- <element name="IGNITION_OFF" />
- <element name="MASTER_RESET" />
- <element name="FACTORY_DEFAULTS" />
-</enum>
-
-<enum name="DisplayType">
- <description>The possible types of HU display.</description>
- <element name="CID">
- <description> A 2-line x 20 character "dot matrix" display </description>
- </element>
- <element name="TYPE2">
- <description> 1 line older radio head unit.</description>
- </element>
- <element name="TYPE5">
- <description> Old radio head unit.</description>
- </element>
- <element name="NGN">
- <description> Next Generation Navigation display.</description>
- </element>
- <element name="GEN2_8_DMA">
- <description> GEN-2, 8 inch display.</description>
- </element>
- <element name="GEN2_6_DMA">
- <description> GEN-2, 6 inch display.</description>
- </element>
- <element name="MFD3">
- <description> 3 inch GEN1.1 display </description>
- </element>
- <element name="MFD4">
- <description> 4 inch GEN1.1 display </description>
- </element>
- <element name="MFD5">
- <description> 5 inch GEN1.1 display </description>
- </element>
- </enum>
-
-<enum name="ImageType">
- <description>Contains information about the type of image.</description>
- <element name="STATIC" />
- <element name="DYNAMIC" />
-</enum>
-
-<enum name="TextFieldName">
- <element name="mainField1">
- <description>The first line of first set of main fields of the persistent display; applies to "Show"</description>
- </element>
- <element name="mainField2">
- <description>The second line of first set of main fields of the persistent display; applies to "Show"</description>
- </element>
- <element name="mainField3">
- <description>The first line of second set of main fields of persistent display; applies to "Show"</description>
- </element>
- <element name="mainField4">
- <description>The second line of second set of main fields of the persistent display; applies to "Show"</description>
- </element>
- <element name="statusBar">
- <description>The status bar on NGN; applies to "Show"</description>
- </element>
- <element name="mediaClock">
- <description>Text value for MediaClock field; applies to "Show"</description>
- </element>
- <element name="mediaTrack">
- <description>The track field of NGN and GEN1.1 MFD displays. This field is only available for media applications; applies to "Show"</description>
- </element>
- <element name="alertText1">
- <description>The first line of the alert text field; applies to "Alert"</description>
- </element>
- <element name="alertText2">
- <description>The second line of the alert text field; applies to "Alert"</description>
- </element>
- <element name="alertText3">
- <description>The third line of the alert text field; applies to "Alert"</description>
- </element>
- <element name="scrollableMessageBody">
- <description>Long form body of text that can include newlines and tabs; applies to "ScrollableMessage"</description>
- </element>
- <element name="initialInteractionText">
- <description> First line suggestion for a user response (in the case of VR enabled interaction</description>
- </element>
- <element name="navigationText1">
- <description> First line of navigation text</description>
- </element>
- <element name="navigationText2">
- <description> Second line of navigation text</description>
- </element>
- <element name="ETA">
- <description> Estimated Time of Arrival time for navigation</description>
- </element>
- <element name="totalDistance">
- <description> Total distance to destination for navigation</description>
- </element>
- <element name="navigationText">
- <description>Navigation text for UpdateTurnList.</description>
- </element>
- <element name="audioPassThruDisplayText1">
- <description> First line of text for audio pass thru</description>
- </element>
- <element name="audioPassThruDisplayText2">
- <description> Second line of text for audio pass thru</description>
- </element>
- <element name="sliderHeader">
- <description> Header text for slider</description>
- </element>
- <element name="sliderFooter">
- <description> Footer text for slider</description>
- </element>
- <element name="notificationText">
- <description>Text of notification to be displayed on screen.</description>
- </element>
- <element name="menuName">
- <description> Primary text for Choice</description>
- </element>
- <element name="secondaryText">
- <description> Secondary text for Choice</description>
- </element>
- <element name="tertiaryText">
- <description> Tertiary text for Choice</description>
- </element>
- <element name="timeToDestination"/>
- <element name="turnText"/>
-</enum>
-
-<enum name="ImageFieldName">
- <element name="softButtonImage">
- <description>The image field for SoftButton</description>
- </element>
- <element name="choiceImage">
- <description>The first image field for Choice</description>
- </element>
- <element name="choiceSecondaryImage">
- <description>The secondary image field for Choice</description>
- </element>
- <element name="vrHelpItem">
- <description>The image field for vrHelpItem</description>
- </element>
- <element name="turnIcon">
- <description>The image field for Turn</description>
- </element>
- <element name="menuIcon">
- <description>The image field for the menu icon in SetGlobalProperties</description>
- </element>
- <element name="cmdIcon">
- <description>The image field for AddCommand</description>
- </element>
- <element name="graphic">
- <description>The image field for Show</description>
- </element>
- <element name="showConstantTBTIcon">
- <description>The primary image field for ShowConstantTBT</description>
- </element>
- <element name="showConstantTBTNextTurnIcon">
- <description>The secondary image field for ShowConstantTBT</description>
- </element>
- <element name="nextTurnIcon"/>
-</enum>
-
-<enum name="TextAlignment">
- <description>The list of possible alignments, left, right, or centered</description>
- <element name="LEFT_ALIGNED" />
- <element name="RIGHT_ALIGNED" />
- <element name="CENTERED" />
-</enum>
-
-<enum name="DriverDistractionState">
- <description>Enumeration that describes possible states of driver distraction.</description>
- <element name="DD_ON" />
- <element name="DD_OFF" />
-</enum>
-
-<enum name="MediaClockFormat">
- <element name="CLOCK1">
- <description>
- minutesFieldWidth = 2;minutesFieldMax = 19;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 19;maxMinutes = 59;maxSeconds = 59;
- Is used for Type II, NGN and CID head units.
- </description>
- </element>
- <element name="CLOCK2">
- <description>
- minutesFieldWidth = 3;minutesFieldMax = 199;secondsFieldWidth = 2;secondsFieldMax = 99;maxHours = 59;maxMinutes = 59;maxSeconds = 59;
- Is used for Type V head units.
- </description>
- </element>
- <element name="CLOCK3">
- <description>
- minutesFieldWidth = 2;minutesFieldMax = 59;secondsFieldWidth = 2;secondsFieldMax = 59;maxHours = 9;maxMinutes = 59;maxSeconds = 59;
- Is used for GEN1.1 (i.e. MFD3/4/5) head units.
- </description>
- </element>
- <element name="CLOCKTEXT1">
- <description>
- 5 characters possible
- Format: 1|sp c :|sp c c
- 1|sp : digit "1" or space
- c : character out of following character set: sp|0-9|[letters
- :|sp : colon or space
- Is used for Type II head unit
- </description>
- </element>
- <element name="CLOCKTEXT2">
- <description>
- 5 chars possible
- Format: 1|sp c :|sp c c
- 1|sp : digit "1" or space
- c : character out of following character set: sp|0-9|[letters
- :|sp : colon or space
- Is used for CID and NGN head unit
- </description>
- </element>
- <element name="CLOCKTEXT3">
- <description>
- 6 chars possible
- Format: 1|sp c c :|sp c c
- 1|sp : digit "1" or space
- c : character out of following character set: sp|0-9|[letters
- :|sp : colon or space
- Is used for Type V head unit
- </description>
- </element>
- <element name="CLOCKTEXT4">
- <description>
- 6 chars possible
- Format: c :|sp c c : c c
- :|sp : colon or space
- c : character out of following character set: sp|0-9|[letters].
- Is used for GEN1.1 (i.e. MFD3/4/5) head units
- </description>
- </element>
-</enum>
-
-<!--IVI part-->
-<enum name="ComponentVolumeStatus">
- <description>The volume status of a vehicle component.</description>
- <element name="UNKNOWN" internal_name="CVS_UNKNOWN">
- <description> The data is unknown.</description>
- </element>
- <element name="NORMAL" internal_name="CVS_NORMAL">
- <description> The volume is normal.</description>
- </element>
- <element name="LOW" internal_name="CVS_LOW">
- <description> The volume is low.</description>
- </element>
- <element name="FAULT" internal_name="CVS_FAULT">
- <description> The module/sensor is currently faulted. </description>
- </element>
- <element name="ALERT" internal_name="CVS_ALERT">
- <description> The component`s volume is in critical level.</description>
- </element>
- <element name="NOT_SUPPORTED" internal_name="CVS_NOT_SUPPORTED">
- <description> The data is not supported.</description>
- </element>
-</enum>
-
-<enum name="PRNDL">
- <description>The selected gear.</description>
- <element name="PARK">
- <description>Parking</description>
- </element>
- <element name="REVERSE">
- <description>Reverse gear</description>
- </element>
- <element name="NEUTRAL">
- <description>No gear</description>
- </element>
- <element name="DRIVE">
- </element>
- <element name="SPORT">
- <description>Drive Sport mode</description>
- </element>
- <element name="LOWGEAR">
- <description>1st gear hold</description>
- </element>
- <element name="FIRST">
- </element>
- <element name="SECOND">
- </element>
- <element name="THIRD">
- </element>
- <element name="FOURTH">
- </element>
- <element name="FIFTH">
- </element>
- <element name="SIXTH">
- </element>
- <element name="SEVENTH">
- </element>
- <element name="EIGHTH">
- </element>
-</enum>
-
-<enum name="VehicleDataEventStatus">
- <description>Reflects the status of a vehicle data event; e.g. a seat belt event status.</description>
- <element name="NO_EVENT" internal_name="VDES_NO_EVENT">
- <description> The system does not have the adequate information to send valid YES or NO states.</description>
- </element>
- <element name="NO" internal_name="VDES_NO">
- <description> The requested event is in NO state.</description>
- </element>
- <element name="YES" internal_name="VDES_YES">
- <description> The requested event is in YES state.</description>
- </element>
- <element name="NOT_SUPPORTED" internal_name="VDES_NOT_SUPPORTED">
- <description> The requested data is not supported </description>
- </element>
- <element name="FAULT" internal_name="VDES_FAULT">
- <description> The module/sensor is currently faulted.</description>
- </element>
-</enum>
-
-<enum name="VehicleDataStatus">
- <description>Reflects the status of a binary vehicle data item.</description>
- <element name="NO_DATA_EXISTS" internal_name="VDS_NO_DATA_EXISTS">
- </element>
- <element name="OFF" internal_name="VDS_OFF">
- </element>
- <element name="ON" internal_name="VDS_ON">
- </element>
-</enum>
-
-<enum name="IgnitionStableStatus">
- <description>Reflects the ignition switch stability.</description>
- <element name="IGNITION_SWITCH_NOT_STABLE">
- </element>
- <element name="IGNITION_SWITCH_STABLE">
- </element>
- <element name="MISSING_FROM_TRANSMITTER">
- <description> Either the data is not accessible or the sensor is broken.</description>
- </element>
-</enum>
-
-<enum name="IgnitionStatus">
- <description>Reflects the status of ignition.</description>
- <element name="UNKNOWN" internal_name="IS_UNKNOWN">
- <description> The information is not acceptable. </description>
- </element>
- <element name="OFF" internal_name="IS_OFF">
- <description> The ignition is off.</description>
- </element>
- <element name="ACCESSORY" internal_name="IS_ACCESSORY">
- <description> The accessories are active (power windows, audio, display, etc.).</description>
- </element>
- <element name="RUN" internal_name="IS_RUN">
- <description> Ignition is active.</description>
- </element>
- <element name="START" internal_name="IS_START">
- <description> Starter is switched.</description>
- </element>
- <element name="INVALID" internal_name="IS_INVALID">
- <description> The data is provided, but there is some sort of fault or problem.</description>
- </element>
-</enum>
-
-<enum name="DeviceLevelStatus">
- <description>Reflects the reported component status of the connected device, if reported.</description>
- <element name="ZERO_LEVEL_BARS">
- </element>
- <element name="ONE_LEVEL_BARS">
- </element>
- <element name="TWO_LEVEL_BARS">
- </element>
- <element name="THREE_LEVEL_BARS">
- </element>
- <element name="FOUR_LEVEL_BARS">
- </element>
- <element name="NOT_PROVIDED">
- </element>
-</enum>
-
-<enum name="PrimaryAudioSource">
- <description>Reflects the current primary audio source (if selected).</description>
- <element name="NO_SOURCE_SELECTED">
- </element>
- <element name="USB">
- </element>
- <element name="USB2">
- </element>
- <element name="BLUETOOTH_STEREO_BTST">
- </element>
- <element name="LINE_IN">
- </element>
- <element name="IPOD">
- </element>
- <element name="MOBILE_APP">
- </element>
-</enum>
-
-<enum name="CompassDirection">
- <description>The list of potential compass directions</description>
- <element name="NORTH">
- </element>
- <element name="NORTHWEST">
- </element>
- <element name="WEST">
- </element>
- <element name="SOUTHWEST">
- </element>
- <element name="SOUTH">
- </element>
- <element name="SOUTHEAST">
- </element>
- <element name="EAST">
- </element>
- <element name="NORTHEAST">
- </element>
-</enum>
-
-<enum name="Dimension">
- <description>The supported dimensions of the GPS</description>
- <element name="NO_FIX" internal_name="Dimension_NO_FIX">
- <description>No GPS at all</description>
- </element>
- <element name="2D" internal_name="Dimension_2D">
- <description>Longitude and lattitude</description>
- </element>
- <element name="3D" internal_name="Dimension_3D">
- <description>Longitude and lattitude and altitude</description>
- </element>
-</enum>
-
-<enum name="TouchType">
- <element name="BEGIN"/>
- <element name="MOVE"/>
- <element name="END"/>
-</enum>
-
-<enum name="WarningLightStatus">
- <description>Reflects the status of a cluster instrument warning light.</description>
- <element name="OFF" internal_name="WLS_OFF">
- </element>
- <element name="ON" internal_name="WLS_ON">
- </element>
- <element name="FLASH" internal_name="WLS_FLASH">
- </element>
-</enum>
-
-<enum name="VehicleDataResultCode">
- <description>Enumeration that describes possible result codes of a vehicle data entry request.</description>
- <element name="SUCCESS" internal_name="VDRC_SUCCESS"/>
- <element name="TRUNCATED_DATA" internal_name="VDRC_TRUNCATED_DATA"/>
- <element name="DISALLOWED" internal_name="VDRC_DISALLOWED"/>
- <element name="USER_DISALLOWED" internal_name="VDRC_USER_DISALLOWED"/>
- <element name="INVALID_ID" internal_name="VDRC_INVALID_ID"/>
- <element name="VEHICLE_DATA_NOT_AVAILABLE" internal_name="VDRC_DATA_NOT_AVAILABLE"/>
- <element name="DATA_ALREADY_SUBSCRIBED" internal_name="VDRC_DATA_ALREADY_SUBSCRIBED"/>
- <element name="DATA_NOT_SUBSCRIBED" internal_name="VDRC_DATA_NOT_SUBSCRIBED"/>
- <element name="IGNORED" internal_name="VDRC_IGNORED"/>
-</enum>
-
-<enum name="VehicleDataType">
- <description>Defines the data types that can be published and subscribed to.</description>
- <element name="VEHICLEDATA_GPS">
- <description>Notifies GPSData may be subscribed</description>
- </element>
- <element name="VEHICLEDATA_SPEED" />
- <element name="VEHICLEDATA_RPM" />
- <element name="VEHICLEDATA_FUELLEVEL" />
- <element name="VEHICLEDATA_FUELLEVEL_STATE" />
- <element name="VEHICLEDATA_FUELCONSUMPTION" />
- <element name="VEHICLEDATA_EXTERNTEMP" />
- <element name="VEHICLEDATA_VIN" />
- <element name="VEHICLEDATA_PRNDL" />
- <element name="VEHICLEDATA_TIREPRESSURE" />
- <element name="VEHICLEDATA_ODOMETER" />
- <element name="VEHICLEDATA_BELTSTATUS" />
- <element name="VEHICLEDATA_BODYINFO" />
- <element name="VEHICLEDATA_DEVICESTATUS" />
- <element name="VEHICLEDATA_ECALLINFO" />
- <element name="VEHICLEDATA_AIRBAGSTATUS" />
- <element name="VEHICLEDATA_EMERGENCYEVENT" />
- <element name="VEHICLEDATA_CLUSTERMODESTATUS" />
- <element name="VEHICLEDATA_MYKEY" />
- <element name="VEHICLEDATA_BRAKING" />
- <element name="VEHICLEDATA_WIPERSTATUS" />
- <element name="VEHICLEDATA_HEADLAMPSTATUS" />
- <element name="VEHICLEDATA_BATTVOLTAGE" />
- <element name="VEHICLEDATA_ENGINETORQUE" />
- <element name="VEHICLEDATA_ACCPEDAL" />
- <element name="VEHICLEDATA_STEERINGWHEEL" />
-</enum>
-
-<enum name="WiperStatus">
- <description>Reflects the status of the wipers.</description>
- <element name="OFF">
- <description> The wipers are off.</description>
- </element>
- <element name="AUTO_OFF">
- <description> The wipers are automatically off </description>
- </element>
- <element name="OFF_MOVING">
- <description> Means that though set to off, somehow the wipers have been engaged (physically moved enough to engage a wiping motion).</description>
- </element>
- <element name="MAN_INT_OFF">
- <description> The wipers are manually off after having been working.</description>
- </element>
- <element name="MAN_INT_ON">
- <description> The wipers are manually on.</description>
- </element>
- <element name="MAN_LOW">
- <description> The wipers are manually set to low speed.</description>
- </element>
- <element name="MAN_HIGH">
- <description> The wipers are manually set to high speed.</description>
- </element>
- <element name="MAN_FLICK">
- <description> The wipers are manually set for doing a flick.</description>
- </element>
- <element name="WASH">
- <description> The wipers are set to use the water from vehicle washer bottle for cleaning the windscreen.</description>
- </element>
- <element name="AUTO_LOW">
- <description> The wipers are automatically set to low speed.</description>
- </element>
- <element name="AUTO_HIGH">
- <description> The wipers are automatically set to high speed.</description>
- </element>
- <element name="COURTESYWIPE">
- <description> This is for when a user has just initiated a WASH and several seconds later a secondary wipe is automatically initiated to clear remaining fluid.</description>
- </element>
- <element name="AUTO_ADJUST">
- <description> This is set as the user moves between possible automatic wiper speeds.</description>
- </element>
- <element name="STALLED">
- <description> The wiper is stalled to its place. </description>
- </element>
- <element name="NO_DATA_EXISTS">
- <description> The sensor / module cannot provide any information for wiper.</description>
- </element>
-</enum>
-
-<enum name="SamplingRate">
- <description>Describes different sampling options for PerformAudioPassThru.</description>
- <element name="8KHZ" internal_name="RATE_8KHZ"/>
- <element name="16KHZ" internal_name="RATE_16KHZ"/>
- <element name="22KHZ" internal_name="RATE_22KHZ"/>
- <element name="44KHZ" internal_name="RATE_44KHZ"/>
-</enum>
-
-<enum name="BitsPerSample">
- <description>Describes different quality options for PerformAudioPassThru.</description>
- <element name="8_BIT" internal_name="RATE_8_BIT"/>
- <element name="16_BIT" internal_name="RATE_16_BIT"/>
-</enum>
-
-<enum name="AudioType">
- <description>Describes different audio type options for PerformAudioPassThru.</description>
- <element name="PCM" />
-</enum>
-
-<enum name="KeyboardLayout">
- <description>Enumeration listing possible keyboard layouts.</description>
- <element name="QWERTY" />
- <element name="QWERTZ" />
- <element name="AZERTY" />
-</enum>
-
-<enum name="KeyboardEvent">
- <description>Enumeration listing possible keyboard events.</description>
- <element name="KEYPRESS" />
- <element name="ENTRY_SUBMITTED" />
- <element name="ENTRY_CANCELLED" />
- <element name="ENTRY_ABORTED" />
-</enum>
-
-<enum name="KeypressMode">
- <description>Enumeration listing possible keyboard events.</description>
- <element name="SINGLE_KEYPRESS">
- <description>Each keypress is individually sent as the user presses the keyboard keys.</description>
- </element>
- <element name="QUEUE_KEYPRESSES">
- <description>The keypresses are queued and a string is eventually sent once the user chooses to submit their entry.</description>
- </element>
- <element name="RESEND_CURRENT_ENTRY">
- <description>The keypresses are queue and a string is sent each time the user presses a keyboard key; the string contains the entire current entry.</description>
- </element>
-</enum>
-
-<enum name="AmbientLightStatus">
- <description>Reflects the status of the ambient light sensor.</description>
- <element name="NIGHT" />
- <element name="TWILIGHT_1" />
- <element name="TWILIGHT_2" />
- <element name="TWILIGHT_3" />
- <element name="TWILIGHT_4" />
- <element name="DAY" />
- <element name="UNKNOWN" />
- <element name="INVALID" />
-</enum>
-
-<enum name="FileType">
- <description>Enumeration listing possible file types.</description>
- <element name="GRAPHIC_BMP" />
- <element name="GRAPHIC_JPEG" />
- <element name="GRAPHIC_PNG" />
- <element name="AUDIO_WAVE" />
- <element name="AUDIO_MP3" />
-</enum>
-
-<enum name="RequestType">
- <description>Enumeration listing possible asynchronous requests.</description>
- <element name="HTTP" />
- <element name="FILE_RESUME" />
- <element name="AUTH_REQUEST" />
- <element name="AUTH_CHALLENGE" />
- <element name="AUTH_ACK" />
- </enum>
-
-<enum name="ECallConfirmationStatus">
- <description>Reflects the status of the eCall Notification.</description>
- <element name="NORMAL" internal_name="ECCS_NORMAL">
- </element>
- <element name="CALL_IN_PROGRESS" internal_name="ECCS_CALL_IN_PROGRESS">
- </element>
- <element name="CALL_CANCELLED" internal_name="ECCS_CALL_CANCELLED">
- </element>
- <element name="CALL_COMPLETED">
- </element>
- <element name="CALL_UNSUCCESSFUL" internal_name="ECCS_CALL_UNSUCCESSFUL">
- </element>
- <element name="ECALL_CONFIGURED_OFF" internal_name="ECCS_ECALL_CONFIGURED_OFF">
- </element>
- <element name="CALL_COMPLETE_DTMF_TIMEOUT" internal_name="ECCS_CALL_COMPLETE_DTMF_TIMEOUT">
- </element>
-</enum>
-
-<enum name="VehicleDataNotificationStatus">
- <description>Reflects the status of a vehicle data notification.</description>
- <element name="NOT_SUPPORTED" internal_name="VDNS_NOT_SUPPORTED">
- </element>
- <element name="NORMAL" internal_name="VDNS_NORMAL">
- </element>
- <element name="ACTIVE" internal_name="VDNS_ACTIVE">
- </element>
-</enum>
-
-<enum name="EmergencyEventType">
- <description>Reflects the emergency event status of the vehicle.</description>
- <element name="NO_EVENT" internal_name="EET_NO_EVENT">
- </element>
- <element name="FRONTAL" internal_name="EET_FRONTAL">
- </element>
- <element name="SIDE" internal_name="EET_SIDE">
- </element>
- <element name="REAR" internal_name="EET_REAR">
- </element>
- <element name="ROLLOVER" internal_name="EET_ROLLOVER">
- </element>
- <element name="NOT_SUPPORTED" internal_name="EET_NOT_SUPPORTED">
- </element>
- <element name="FAULT" internal_name="EET_FAULT">
- </element>
-</enum>
-
-<enum name="FuelCutoffStatus">
- <description>Reflects the status of the RCM fuel cutoff.</description>
- <element name="TERMINATE_FUEL" internal_name="FCS_TERMINATE_FUEL">
- </element>
- <element name="NORMAL_OPERATION" internal_name="FCS_NORMAL_OPERATION">
- </element>
- <element name="FAULT" internal_name="FCS_FAULT">
- </element>
-</enum>
-
-<enum name="PowerModeQualificationStatus">
- <description>Reflects the status of the current power mode qualification.</description>
- <element name="POWER_MODE_UNDEFINED">
- </element>
- <element name="POWER_MODE_EVALUATION_IN_PROGRESS">
- </element>
- <element name="NOT_DEFINED">
- </element>
- <element name="POWER_MODE_OK">
- </element>
-</enum>
-
-<enum name="CarModeStatus">
- <description>Reflects the status of the current car mode.</description>
- <element name="NORMAL" internal_name="CMS_NORMAL">
- </element>
- <element name="FACTORY" internal_name="CMS_FACTORY">
- </element>
- <element name="TRANSPORT" internal_name="CMS_TRANSPORT">
- </element>
- <element name="CRASH" internal_name="CMS_CRASH">
- </element>
-</enum>
-
-<enum name="PowerModeStatus">
- <description>Reflects the status of the current power mode.</description>
- <element name="KEY_OUT">
- </element>
- <element name="KEY_RECENTLY_OUT">
- </element>
- <element name="KEY_APPROVED_0">
- </element>
- <element name="POST_ACCESORY_0">
- </element>
- <element name="ACCESORY_1">
- </element>
- <element name="POST_IGNITION_1">
- </element>
- <element name="IGNITION_ON_2">
- </element>
- <element name="RUNNING_2">
- </element>
- <element name="CRANK_3">
- </element>
-</enum>
-
-<!-- End of IVI part-->
-
-<struct name="ButtonCapabilities">
- <description>Contains the information about capabilities of a button.</description>
- <param name="name" type="Common.ButtonName" mandatory="true">
- <description>The name of the Button from the ButtonName enum</description>
- </param>
- <param name="shortPressAvailable" type="Boolean" mandatory="true">
- <description>The button supports a short press. Whenever the button is pressed short, onButtonPressed(SHORT) should be invoked.</description>
- </param>
- <param name="longPressAvailable" type="Boolean" mandatory="true">
- <description>The button supports a LONG press. Whenever the button is pressed long, onButtonPressed(LONG) should be invoked.</description>
- </param>
- <param name="upDownAvailable" type="Boolean" mandatory="true">
- <description>The button supports "button down" and "button up". Whenever the button is pressed, onButtonEvent(DOWN) should be invoked. Whenever the button is released, onButtonEvent(UP) should be invoked.</description>
- </param>
-</struct>
-
-<struct name="VehicleDataResult">
- <description>Individual published data request result</description>
- <param name="dataType" type="Common.VehicleDataType">
- <description>Defined published data element type.</description>
- </param>
- <param name="resultCode" type="Common.VehicleDataResultCode">
- <description>Published data result code.</description>
- </param>
-</struct>
-
-<struct name="TouchCoord">
- <param name="x" type="Integer" mandatory="true" minvalue="0" maxvalue="10000">
- <description>The x coordinate of the touch.</description>
- </param>
- <param name="y" type="Integer" mandatory="true" minvalue="0" maxvalue="10000">
- <description>The y coordinate of the touch.</description>
- </param>
-</struct>
-
-<struct name="TouchEvent">
- <param name="id" type="Integer" mandatory="true" minvalue="0" maxvalue="9">
- <description>
- A touch's unique identifier. The application can track the current touch events by id.
- If a touch event has type begin, the id should be added to the set of touches.
- If a touch event has type end, the id should be removed from the set of touches.
- </description>
- </param>
- <param name="ts" type="Integer" mandatory="true" array="true" minvalue="0" maxvalue="2147483647" minsize="1" maxsize="1000">
- <description>
- The time that the touch was recorded. This number can the time since the beginning of the session or something else as long as the units are in milliseconds.
- The timestamp is used to determined the rate of change of position of a touch.
- The application also uses the time to verify whether two touches, with different ids, are part of a single action by the user.
- If there is only a single timestamp in this array, it is the same for every coordinate in the coordinates array.
- </description>
- </param>
- <param name="c" type="Common.TouchCoord" mandatory="true" array="true" minsize="1" maxsize="1000">
- </param>
-</struct>
-
-<struct name="PresetBankCapabilities">
- <description>Contains information about on-screen preset capabilities (whether the HW preset buttons could be duplicated with onscreen buttons).</description>
- <param name="onScreenPresetsAvailable" type="Boolean" mandatory="true">
- <description>Must be true if onscreen custom presets are available.</description>
- </param>
-</struct>
-
-<struct name="Image">
- <param name="value" maxlength="65535" type="String" mandatory="true">
- <description>The path to the dynamic image stored on HU or the static binary image itself.</description>
- </param>
- <param name="imageType" type="Common.ImageType" mandatory="true">
- <description>Describes, whether it is a static or dynamic image.</description>
- </param>
-</struct>
-
-<struct name="SoftButton">
- <param name="type" type="Common.SoftButtonType" mandatory="true">
- <description>Describes, whether text, icon or both text and image should be displayed on the soft button. See softButtonType</description>
- </param>
- <param name="text" maxlength="500" type="String" mandatory="false">
- <description>Optional text to be displayed (if defined as TEXT or BOTH)</description>
- </param>
- <param name="image" type="Common.Image" mandatory="false">
- <description>Optional image struct for SoftButton (if defined as IMAGE or BOTH)</description>
- </param>
- <param name="isHighlighted" type="Boolean" mandatory="false">
- <description>If true, must be highlighted</description>
- <description>If false, must be not</description>
- </param>
- <param name="softButtonID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Value which must be returned via OnButtonPress / OnButtonEvent</description>
- </param>
- <param name="systemAction" type="Common.SystemAction" mandatory="false">
- <description>Parameter indicates whether clicking a SoftButton must call a specific system action. See SystemAction</description>
- </param>
- </struct>
-
-<struct name="TTSChunk">
- <description>A TTS chunk, that consists of the text/phonemes to be spoken</description>
- <param name="text" type="String" mandatory="true" maxlength="500">
- <description>The text or phonemes to be spoken.</description>
- </param>
- <param name="type" type="Common.SpeechCapabilities" mandatory="true">
- <description>Describes, whether it is text or a specific phoneme set. See SpeechCapabilities.</description>
- </param>
-</struct>
-
-<struct name="HMIApplication">
- <description>Data type containing information about application needed by HMI.</description>
- <param name="appName" type="String" maxlength="100" mandatory="true">
- <description>The mobile application name, e.g. "Ford Drive Green".</description>
- </param>
- <param name="ngnMediaScreenAppName" type="String" maxlength="100" mandatory="false">
- <description>Provides an abbreviated version of the app name (if needed), that may be displayed on the NGN media screen.</description>
- <description>If not provided, the appName should be used instead (and may be truncated if too long)</description>
- </param>
- <param name="icon" type="String" mandatory="false">
- <description>Path to application icon stored on HU.</description>
- </param>
- <param name="deviceName" type="String" mandatory="true">
- <description>The name of device which the provided application is running on.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>Unique (during ignition cycle) id of the application. To be used in all RPCs sent by both HU system and SDL</description>
- </param>
- <param name="hmiDisplayLanguageDesired" type="Common.Language" mandatory="true">
- <description>The language the application intends to use on HU </description>
- </param>
- <param name="isMediaApplication" type="Boolean" mandatory="true">
- <description>Indicates whether it is a media or a non-media application.</description>
- </param>
- <param name="appType" type="Common.AppHMIType" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>List of all applicable app types stating which classifications to be given to the app.</description>
- <description>e.g. for platforms like GEN2, this determines which "corner(s)" the app can populate.</description>
- </param>
-</struct>
-
-<struct name="MenuParams">
- <param name="parentID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
- <description>unique ID of the sub menu, the command must be added to.</description>
- <description>If not provided, the command must be added to the top level of the in application menu.</description>
- </param>
- <param name="position" type="Integer" minvalue="0" maxvalue="1000" mandatory="false">
- <description>Position within the items that are at the top level of the in application menu.</description>
- <description>0 should insert at the front.</description>
- <description>1 should insert at the second position.</description>
- <description>if position is greater than or equal to the number of items on the top level, the the sub menu/command should be appended to the end.</description>
- <description>If this param is omitted the entry should be added at the end.</description>
- </param>
- <param name="menuName" type="String" maxlength="500" mandatory="true">
- <description>The name of the sub menu/command.</description>
- </param>
-</struct>
-
-<struct name="Choice">
- <description>A choice is an option given to the user which can be selected either by menu, or through voice recognition system.</description>
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description> The unique within the concerned application identifier for this choice </description>
- </param>
- <param name="menuName" type="String" maxlength="500" mandatory="false">
- <description> The name of the choice </description>
- </param>
- <param name="image" type="Common.Image" mandatory="false">
- <description> The image for representing the choice </description>
- </param>
- <param name="secondaryText" maxlength="500" type="String" mandatory="false">
- <description>Optional secondary text to display; e.g. address of POI in a search result entry</description>
- </param>
- <param name="tertiaryText" maxlength="500" type="String" mandatory="false">
- <description>Optional tertiary text to display; e.g. distance to POI for a search result entry</description>
- </param>
- <param name="secondaryImage" type="Image" mandatory="false">
- <description>Optional secondary image struct for choice</description>
- </param>
-</struct>
-
-<struct name="VrHelpItem">
- <param name="text" maxlength="500" type="String" mandatory="true">
- <description>Text to display for VR Help item</description>
- </param>
- <param name="image" type="Common.Image" mandatory="false">
- <description>Image struct for VR Help item</description>
- </param>
- <param name="position" type="Integer" minvalue="1" maxvalue="8" mandatory="true">
- <description>Position to display item in VR Help list</description>
- </param>
-</struct>
-
-<struct name="TimeFormat">
- <param name="hours" type="Integer" minvalue="0" maxvalue="59" mandatory="true">
- <description>The hour of the media clock.</description>
- <description>Some units only support a max of 19 hours. If out of range, it should be rejected.</description>
- </param>
- <param name="minutes" type="Integer" minvalue="0" maxvalue="59" mandatory="true"/>
- <param name="seconds" type="Integer" minvalue="0" maxvalue="59" mandatory="true"/>
-</struct>
-
-<struct name="TouchEventCapabilities">
- <param name="pressAvailable" type="Boolean" mandatory="true">
- </param>
- <param name="multiTouchAvailable" type="Boolean" mandatory="true">
- </param>
- <param name="doublePressAvailable" type="Boolean" mandatory="true">
- </param>
-</struct>
-
-<struct name="ImageResolution">
- <param name="resolutionWidth" type="Integer" minvalue="1" maxvalue="10000" mandatory="true">
- <description>The image resolution width.</description>
- </param>
- <param name="resolutionHeight" type="Integer" minvalue="1" maxvalue="10000" mandatory="true">
- <description>The image resolution height.</description>
- </param>
-</struct>
-
-<struct name="ScreenParams">
- <param name="resolution" type="Common.ImageResolution" mandatory="true">
- <description>The resolution of the prescribed screen area.</description>
- </param>
- <param name="touchEventAvailable" type="Common.TouchEventCapabilities" mandatory="false">
- <description>Types of screen touch events available in screen area.</description>
- </param>
-</struct>
-
-<struct name="ImageField">
- <param name="name" type="Common.ImageFieldName" mandatory="true">
- <description>The name that identifies the field. See ImageFieldName.</description>
- </param>
- <param name="imageTypeSupported" type="Common.FileType" maxsize="100" array="true" mandatory="false" minsize="1">
- <description>The image types that are supported in this field. See FileType.</description>
- </param>
- <param name="imageResolution" type="Common.ImageResolution" mandatory="false">
- <description>The image resolution of this field.</description>
- </param>
-</struct>
-
-<struct name="DisplayCapabilities">
- <description>Contains information about the display capabilities.</description>
- <param name="displayType" type="Common.DisplayType" mandatory="true">
- <description>The type of the display. See DisplayType</description>
- </param>
- <param name="textFields" type="Common.TextFieldName" minsize="0" maxsize="100" array="true" mandatory="true">
- <description>A set of all fields for text displaying supported by HU. See TextFieldName.</description>
- <description>If there are no textfields supported, the empty array must be returned</description>
- </param>
- <param name="imageFields" type="Common.ImageField" minsize="1" maxsize="100" array="true">
- <description>A set of all fields that support images. See ImageField</description>
- </param>
- <param name="mediaClockFormats" type="Common.MediaClockFormat" minsize="1" maxsize="100" array="true" mandatory="true">
- <description>A set of all supported formats of the media clock. See MediaClockFormat</description>
- </param>
- <param name="imageCapabilities" type="Common.ImageType" array="true" minsize="0" maxsize="2" mandatory="false">
- </param>
- <param name="graphicSupported" type="Boolean" mandatory="true">
- <description>The display's persistent screen supports referencing a static or dynamic image.</description>
- </param>
-</struct>
-
-<struct name="SoftButtonCapabilities">
- <description>Contains information about a SoftButton's capabilities.</description>
- <param name="shortPressAvailable" type="Boolean" mandatory="true">
- <description>The button supports a short press.</description>
- <description>Whenever the button is pressed short, onButtonPressed( SHORT) must be invoked.</description>
- </param>
- <param name="longPressAvailable" type="Boolean" mandatory="true">
- <description>The button supports a LONG press.</description>
- <description>Whenever the button is pressed long, onButtonPressed( LONG) must be invoked.</description>
- </param>
- <param name="upDownAvailable" type="Boolean" mandatory="true">
- <description>The button supports "button down" and "button up".</description>
- <description>Whenever the button is pressed, onButtonEvent( DOWN) must be invoked.</description>
- <description>Whenever the button is released, onButtonEvent( UP) must be invoked.</description>
- </param>
- <param name="imageSupported" type="Boolean" mandatory="true">
- <description>Must be true if the button supports referencing a static or dynamic image.</description>
- </param>
-</struct>
-
-<struct name="AudioPassThruCapabilities">
- <description>
- Describes different audio type configurations for PerformAudioPassThru.
- e.g. 8kHz,8-bit,PCM
- </description>
- <param name="samplingRate" type="Common.SamplingRate" mandatory="true"/>
- <param name="bitsPerSample" type="Common.BitsPerSample" mandatory="true"/>
- <param name="audioType" type="Common.AudioType" mandatory="true"/>
-</struct>
-
-<struct name="Coordinate">
- <param name="xCoord" type="Integer" mandatory="true">
- </param>
- <param name="yCoord" type="Integer" mandatory="true">
- </param>
-</struct>
-
-<struct name="TouchArea">
- <param name="rotationAngle" type="Float" mandatory="false" minvalue="0" maxvalue="360">
- </param>
- <param name="radiusCoord" type="Common.Coordinate" mandatory="true">
- </param>
-</struct>
-
-<struct name="TextFieldStruct">
- <param name="fieldName" type="Common.TextFieldName" mandatory="true">
- <description>The name of the field for displaying the text.</description>
- </param>
- <param name="fieldText" type="String" maxlength="500" mandatory="true">
- <description>The text itself.</description>
- </param>
-</struct>
-
-<struct name="KeyboardProperties">
- <description>Configuration of on-screen keyboard (if available).</description>
- <param name="language" type="Common.Language" mandatory="false">
- <description>The keyboard language.</description>
- </param>
- <param name="keyboardLayout" type="Common.KeyboardLayout" mandatory="false" >
- <description>Desired keyboard layout.</description>
- </param>
- <param name="sendDynamicEntry" type="Boolean" mandatory="false">
- <description>In this mode, all keypresses will be sent as they occur.</description>
- <description>If disabled, entire string of text will be returned only once submitted by user.</description>
- <description>If omitted, this value will be set to FALSE.</description>
- </param>
- <param name="keypressMode" type="Common.KeypressMode" mandatory="false" >
- <description>
- Desired keypress mode.
- If omitted, this value will be set to RESEND_CURRENT_ENTRY.
- </description>
- </param>
- <param name="limitedCharacterList" type="String" maxlength="1" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Array of keyboard characters to enable.</description>
- <description>All omitted characters will be greyed out (disabled) on the keyboard.</description>
- <description>If omitted, the entire keyboard will be enabled.</description>
- </param>
- <param name="autoCompleteText" type="String" maxlength="1000" mandatory="false">
- <description>Allows an app to prepopulate the text field with a suggested or completed entry as the user types</description>
- </param>
-</struct>
-
-<struct name="Turn">
- <param name="navigationText" type="Common.TextFieldStruct" mandatory="false">
- <description>Uses navigationText from TextFieldStruct.</description>
- </param>
- <param name="turnIcon" type="Common.Image" mandatory="false">
- </param>
-</struct>
-
-<struct name="VehicleType">
- <param name="make" type="String" maxlength="500" mandatory="false">
- <description>Make of the vehicle</description>
- <description>e.g. Ford</description>
- </param>
- <param name="model" type="String" maxlength="500" mandatory="false">
- <description>Model of the vehicle</description>
- <description>e.g. Fiesta</description>
- </param>
- <param name="modelYear" type="String" maxlength="500" mandatory="false">
- <description>Model Year of the vehicle</description>
- <description>e.g. 2013</description>
- </param>
- <param name="trim" type="String" maxlength="500" mandatory="false">
- <description>Trim of the vehicle</description>
- <description>e.g. SE</description>
- </param>
-</struct>
-
-<struct name="DeviceInfo">
- <param name="name" type="String" mandatory="true">
- <description>The name of the device connected.</description>
- </param>
- <param name="id" type="Integer" mandatory="true">
- <description>The ID of the device connected</description>
- </param>
-</struct>
-
-<!--IVI part-->
-<struct name="GPSData">
- <description>Struct with the GPS data.</description>
- <param name="longitudeDegrees" type="Float" minvalue="-180" maxvalue="180" mandatory="false">
- </param>
- <param name="latitudeDegrees" type="Float" minvalue="-90" maxvalue="90" mandatory="false">
- </param>
- <param name="utcYear" type="Integer" minvalue="2010" maxvalue="2100" mandatory="false">
- <description>The current UTC year.</description>
- </param>
- <param name="utcMonth" type="Integer" minvalue="1" maxvalue="12" mandatory="false">
- <description>The current UTC month.</description>
- </param>
- <param name="utcDay" type="Integer" minvalue="1" maxvalue="31" mandatory="false">
- <description>The current UTC day.</description>
- </param>
- <param name="utcHours" type="Integer" minvalue="0" maxvalue="23" mandatory="false">
- <description>The current UTC hour.</description>
- </param>
- <param name="utcMinutes" type="Integer" minvalue="0" maxvalue="59" mandatory="false">
- <description>The current UTC minute.</description>
- </param>
- <param name="utcSeconds" type="Integer" minvalue="0" maxvalue="59" mandatory="false">
- <description>The current UTC second.</description>
- </param>
- <param name="compassDirection" type="Common.CompassDirection" mandatory="false">
- <description>See CompassDirection.</description>
- </param>
- <param name="pdop" type="Float" minvalue="0" maxvalue="10" mandatory="false">
- <description>PDOP.</description>
- </param>
- <param name="hdop" type="Float" minvalue="0" maxvalue="10" mandatory="false">
- <description>HDOP.</description>
- </param>
- <param name="vdop" type="Float" minvalue="0" maxvalue="10" mandatory="false">
- <description>VDOP.</description>
- </param>
- <param name="actual" type="Boolean" mandatory="false">
- <description>
- True, if actual.
- False, if infered.
- </description>
- </param>
- <param name="satellites" type="Integer" minvalue="0" maxvalue="31" mandatory="false">
- <description>Number of satellites in view</description>
- </param>
- <param name="dimension" type="Common.Dimension" mandatory="false">
- <description>See Dimension</description>
- </param>
- <param name="altitude" type="Float" minvalue="-10000" maxvalue="10000" mandatory="false">
- <description>Altitude in meters</description>
- </param>
- <param name="heading" type="Float" minvalue="0" maxvalue="359.99" mandatory="false">
- <description>The heading. North is 0. Resolution is 0.01</description>
- </param>
- <param name="speed" type="Float" minvalue="0" maxvalue="500" mandatory="false">
- <description>The speed in KPH</description>
- </param>
-</struct>
-
-<struct name="SingleTireStatus">
- <param name="status" type="Common.ComponentVolumeStatus" mandatory="true">
- <description>The status of component volume. See ComponentVolumeStatus.</description>
-</param>
-</struct>
-
-<struct name="DIDResult">
- <description>Individual requested DID result and data</description>
- <param name="resultCode" type="Common.VehicleDataResultCode" mandatory="true">
- <description>Individual DID result code.</description>
- </param>
- <param name="didLocation" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Location of raw data (the address from ReadDID request)</description>
- </param>
- <param name="data" type="String" maxlength="5000" mandatory="false">
- <description>Raw DID-based data returned for requested element.</description>
- </param>
-</struct>
-
-<struct name="HeadLampStatus">
- <param name="lowBeamsOn" type="Boolean" mandatory="true">
- <description>Status of the low beam lamps.</description>
- </param>
- <param name="highBeamsOn" type="Boolean" mandatory="true">
- <description>Status of the high beam lamps.</description>
- </param>
- <param name="ambientLightSensorStatus" type="Common.AmbientLightStatus" mandatory="true">
- <description>Status of the ambient light sensor.</description>
- </param>
-</struct>
-
-<struct name="TireStatus">
-<description>The status and pressure of the tires.</description>
-<param name="pressureTelltale" type="Common.WarningLightStatus" mandatory="false">
- <description>Status of the Tire Pressure Telltale. See WarningLightStatus.</description>
-</param>
- <param name="leftFront" type="Common.SingleTireStatus" mandatory="false">
- <description>The status of the left front tire.</description>
-</param>
- <param name="rightFront" type="Common.SingleTireStatus" mandatory="false">
- <description>The status of the right front tire.</description>
-</param>
- <param name="leftRear" type="Common.SingleTireStatus" mandatory="false">
- <description>The status of the left rear tire.</description>
-</param>
- <param name="rightRear" type="Common.SingleTireStatus" mandatory="false">
- <description>The status of the right rear tire.</description>
-</param>
- <param name="innerLeftRear" type="Common.SingleTireStatus" mandatory="false">
- <description>The status of the inner left rear.</description>
-</param>
- <param name="innerRightRear" type="Common.SingleTireStatus" mandatory="false">
- <description>The status of the inner right rear.</description>
-</param>
-</struct>
-
-<struct name="BeltStatus">
- <param name="driverBeltDeployed" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="passengerBeltDeployed" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="passengerBuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="driverBuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="leftRow2BuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="passengerChildDetected" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="rightRow2BuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="middleRow2BuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="middleRow3BuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="leftRow3BuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="rightRow3BuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="leftRearInflatableBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="rightRearInflatableBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="middleRow1BeltDeployed" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
- <param name="middleRow1BuckleBelted" type="Common.VehicleDataEventStatus" mandatory="false">
- <description>See VehicleDataEventStatus.</description>
-</param>
-</struct>
-
-<struct name="BodyInformation">
- <param name="parkBrakeActive" type="Boolean" mandatory="true">
- <description>Must be true if the park brake is active</description>
- </param>
- <param name="ignitionStableStatus" type="Common.IgnitionStableStatus" mandatory="true">
- <description>Information about the ignition switch. See IgnitionStableStatus.</description>
- </param>
- <param name="ignitionStatus" type="Common.IgnitionStatus" mandatory="true">
- <description>The status of the ignition. See IgnitionStatus.</description>
- </param>
-</struct>
-
-<struct name="DeviceStatus">
- <param name="voiceRecOn" type="Boolean" mandatory="false">
- <description>Must be true if the voice recording is on.</description>
- </param>
- <param name="btIconOn" type="Boolean" mandatory="false">
- <description>Must be true if Bluetooth icon is displayed.</description>
- </param>
- <param name="callActive" type="Boolean" mandatory="false">
- <description>Must be true if there is an active call..</description>
- </param>
- <param name="phoneRoaming" type="Boolean" mandatory="false">
- <description>Must be true if ther is a phone roaming.</description>
- </param>
- <param name="textMsgAvailable" type="Boolean" mandatory="false">
- <description>Must be true if the text message is available.</description>
- </param>
- <param name="battLevelStatus" type="Common.DeviceLevelStatus" mandatory="false">
- <description>Device battery level status. See DeviceLevelStatus.</description>
- </param>
- <param name="stereoAudioOutputMuted" type="Boolean" mandatory="false">
- <description>Must be true if stereo audio output is muted.</description>
- </param>
- <param name="monoAudioOutputMuted" type="Boolean" mandatory="false">
- <description>Must be true if mono audio output is muted.</description>
- </param>
- <param name="signalLevelStatus" type="Common.DeviceLevelStatus" mandatory="false">
- <description>Device signal level status. See DeviceLevelStatus.</description>
- </param>
- <param name="primaryAudioSource" type="Common.PrimaryAudioSource" mandatory="false">
- <description>See PrimaryAudioSource.</description>
- </param>
- <param name="eCallEventActive" type="Boolean" mandatory="false">
- <description>Must be true if emergency call event is active.</description>
- </param>
-</struct>
-
-<struct name="ECallInfo">
- <param name="eCallNotificationStatus" type="Common.VehicleDataNotificationStatus">
- <description>References signal "eCallNotification_4A". See VehicleDataNotificationStatus.</description>
- </param>
- <param name="auxECallNotificationStatus" type="Common.VehicleDataNotificationStatus">
- <description>References signal "eCallNotification". See VehicleDataNotificationStatus.</description>
- </param>
- <param name="eCallConfirmationStatus" type="Common.ECallConfirmationStatus">
- <description>References signal "eCallConfirmation". See ECallConfirmationStatus.</description>
- </param>
-</struct>
-
-<struct name="AirbagStatus">
- <param name="driverAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsDrvBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="driverSideAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsDrvSideBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="driverCurtainAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsDrvCrtnBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="passengerAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsPasBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="passengerCurtainAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsPasCrtnBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="driverKneeAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsKneeDrvBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="passengerSideAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsPasSideBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="passengerKneeAirbagDeployed" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsKneePasBag_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
-</struct>
-
-<struct name="EmergencyEvent">
- <param name="emergencyEventType" type="Common.EmergencyEventType">
- <description>References signal "VedsEvntType_D_Ltchd". See EmergencyEventType.</description>
- </param>
- <param name="fuelCutoffStatus" type="Common.FuelCutoffStatus">
- <description>References signal "RCM_FuelCutoff". See FuelCutoffStatus.</description>
- </param>
- <param name="rolloverEvent" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsEvntRoll_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="maximumChangeVelocity" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsMaxDeltaV_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
- <param name="multipleEvents" type="Common.VehicleDataEventStatus">
- <description>References signal "VedsMultiEvnt_D_Ltchd". See VehicleDataEventStatus.</description>
- </param>
-</struct>
-
-<struct name="ClusterModeStatus">
- <param name="powerModeActive" type="Boolean">
- <description>References signal "PowerMode_UB".</description>
- </param>
- <param name="powerModeQualificationStatus" type="Common.PowerModeQualificationStatus">
- <description>References signal "PowerModeQF". See PowerModeQualificationStatus.</description>
- </param>
- <param name="carModeStatus" type="Common.CarModeStatus">
- <description>References signal "CarMode". See CarMode.</description>
- </param>
- <param name="powerModeStatus" type="Common.PowerModeStatus">
- <description>References signal "PowerMode". See PowerMode.</description>
- </param>
-</struct>
-
-<struct name="MyKey">
- <param name="e911Override" type="Common.VehicleDataStatus" mandatory="true">
- <description>Indicates whether e911 override is on. See VehicleDataStatus.</description>
- </param>
-</struct>
-<!--end of IVI part-->
-
-</interface>
-
-<interface name="Buttons" version="1.0" date="2013-04-12">
- <function name="GetCapabilities" messagetype="request">
- <description>Method is invoked at system start-up. SDL requests the information about all supported hardware buttons and their capabilities</description>
- </function>
- <function name="GetCapabilities" messagetype="response">
- <param name="capabilities" type="Common.ButtonCapabilities" array="true" minsize="1" maxsize="100" mandatory="true">
- <description>Response must provide the names of available buttons and their capabilities.See ButtonCapabilities</description>
- </param>
- <param name="presetBankCapabilities" type="Common.PresetBankCapabilities" mandatory="false">
- <description>Must be returned if the platform supports custom on-screen Presets</description>
- </param>
- </function>
- <function name="OnButtonEvent" messagetype="notification">
- <description>HU system must notify about every UP/DOWN event for buttons</description>
- <param name="name" type="Common.ButtonName" mandatory="true"/>
- <param name="mode" type="Common.ButtonEventMode" mandatory="true">
- <description>Indicates whether this is an UP or DOWN event.</description>
- </param>
- <param name="customButtonID" type="Integer" mandatory="false" minvalue="0" maxvalue="65536">
- <description>Must be provided if ButtonName is CUSTOM_BUTTON, this references the integer ID passed by a custom button. (e.g. softButtonName)</description>
- </param>
- </function>
- <function name="OnButtonPress" messagetype="notification">
- <param name="name" type="Common.ButtonName" mandatory="true"/>
- <param name="mode" type="Common.ButtonPressMode" mandatory="true">
- <description>Indicates whether this is a LONG or SHORT button press event.</description>
- </param>
- <param name="customButtonID" type="Integer" mandatory="false" minvalue="0" maxvalue="65536">
- <description>Must be returned if ButtonName is CUSTOM_BUTTON, this references the string passed by a custom button. (e.g. softButtonName)</description>
- </param>
- </function>
-</interface>
-
-<interface name="BasicCommunication" version="1.0" date="2013-04-12">
- <function name="OnReady" messagetype="notification">
- <description>HMI must notify SDL about its readiness to start communication. In fact, this has to be the first message between SDL and HMI.</description>
- </function>
- <function name="OnStartDeviceDiscovery" messagetype="notification">
- <description>Initiated by HMI user for getting the list of connected devices.</description>
- </function>
- <function name="UpdateDeviceList" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to change device list.</description>
- <param name="deviceList" type="Common.DeviceInfo" mandatory="true" array="true" minsize="0" maxsize="100">
- <description>The array of names/IDs of connected devices</description>
- </param>
- </function>
- <function name="UpdateDeviceList" messagetype="response">
- </function>
- <function name="OnUpdateDeviceList" messagetype="notification">
- <description>Notification from HMI to SDL sent when HMI requires update of device list (i.e. when user clicks 'Change Device' button)</description>
- </function>
- <function name="AllowDeviceToConnect" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to get the permissions of new device connection.</description>
- <param name="device" type="Common.DeviceInfo" mandatory="true"/>
- </function>
- <function name="AllowDeviceToConnect" messagetype="response">
- <param name="allow" type="Boolean" mandatory="true"/>
- </function>
- <function name="OnDeviceChosen" messagetype="notification">
- <description>Notification must be initiated by HMI on user selecting device in the list of devices.</description>
- <param name="deviceInfo" type="Common.DeviceInfo" mandatory="true">
- <description>The name and ID of the device chosen</description>
- </param>
- </function>
- <function name="OnFindApplications" messagetype="notification">
- <description>This method must be invoked by HMI to get list of registered apps.</description>
- <param name="deviceInfo" type="Common.DeviceInfo" mandatory="false">
- <description>The name and ID of the device the list of registered applications is required for.</description>
- </param>
- </function>
- <function name="UpdateAppList" messagetype="request">
- <description>Issued by SDL to notify HMI about new applications registered.</description>
- <param name="applications" type="Common.HMIApplication" mandatory="true" array="true" minsize="1" maxsize="100"/>
- </function>
- <function name="UpdateAppList" messagetype="response">
- </function>
- <function name="ActivateApp" messagetype="request">
- <description>Request from SDL to HMI to bring specified application to front on UI e.g make it HMI status 'FULL'.</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of deactivated application.</description>
- </param>
- </function>
- <function name="ActivateApp" messagetype="response">
- </function>
- <function name="OnAppActivated" messagetype="notification">
- <description>Must be sent by HU system when the user clicks on app in the list of registered apps or on soft button with 'STEAL_FOCUS' action.</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of selected application.</description>
- </param>
- </function>
- <function name="OnAppDeactivated" messagetype="notification">
- <description>Must be sent by HU system when the user switches to any functionality which is not other mobile application.</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of deactivated application.</description>
- </param>
- <param name="reason" type="Common.DeactivateReason" mandatory="true">
- <description>Specifies the functionality the user has switched to.</description>
- </param>
- </function>
- <function name="OnAppRegistered" messagetype="notification">
- <description>Issued by SDL to notify HMI about new application registered.</description>
- <param name="application" type="Common.HMIApplication" mandatory="true">
- <description>The information about application registered. See HMIApplication. </description>
- </param>
- <param name="resume" type="Boolean" mandatory="false">
- <description>Flag to indicate if application may be resumed in future</description>
- </param>
- </function>
- <function name="OnAppUnregistered" messagetype="notification">
- <description>Issued by SDL to notify HMI about application unregistered. Application then to be removed from application list; all data connected with application has to be cleared up.</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of the application unregistered</description>
- </param>
- <param name="resume" type="Boolean" mandatory="false">
- <description>Flag to indicate if application may be resumed in future</description>
- </param>
- </function>
- <function name="GetResumeResult" messagetype="request">
- <description>Issued by SDL to request HMI resumption check.</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of the registered application that will be resumed</description>
- </param>
- </function>
- <function name="GetResumeResult" messagetype="response">
- <description>Issued by HMI to notify SDL about application resumption check.</description>
- <param name="result" type="Boolean" mandatory="true">
- <description>Flag to indicate if applications data check was successfull</description>
- </param>
- </function>
- <function name="OnExitApplication" messagetype="notification">
- <description>Must be sent by HMI when the User chooses to exit the application..</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of the application to be exited.</description>
- </param>
- </function>
- <function name="OnExitAllApplications" messagetype="notification">
- <description>Sent by HMI to SDL to close all registered applications.</description>
- <param name="reason" type="Common.ApplicationsCloseReason" mandatory="true">
- <description>Specifies reason for exiting all apllications.</description>
- </param>
- </function>
- <function name="MixingAudioSupported" messagetype="request">
- <description>Request from SDL to HMI to find out if the last one supports mixing audio (i.e. recording TTS command and playing audio).</description>
- </function>
- <function name="MixingAudioSupported" messagetype="response">
- <description>If no response received SDL supposes that mixing audio is not supported</description>
- <param name="attenuatedSupported" type="Boolean" mandatory="true">
- <description>Must be true if supported</description>
- </param>
- </function>
- <function name="PlayTone" messagetype="notification">
- <description>Sent by SDL to HMI to notify that the tone should be played.</description>
- </function>
- <!-- Policies -->
- <function name="AllowAllApps" messagetype="request">
- <description>Initiated by SDL. Results by user/HMI allowing SDL functionality or disallowing access to all mobile apps.</description>
- </function>
- <function name="AllowAllApps" messagetype="response">
- <param name="allowed" type="Boolean" mandatory="true">
- <description>Must be true if allowed</description>
- </param>
- </function>
- <function name="AllowApp" messagetype="request">
- <description>Initiated by SDL for requesting the allowance for the application</description>
- <param name="app" type="Common.HMIApplication" mandatory="true">
- <description>Information about the application. See HMIApplication. </description>
- </param>
- <param name="appPermissions" type="String" array="true" minsize="1" maxsize="100" mandatory="false">
- <description>List of permissions required by application.</description>
- </param>
- </function>
- <function name="AllowApp" messagetype="response">
- <param name="allowed" type="Boolean" mandatory="true">
- <description>Must be true if allowed</description>
- </param>
- </function>
-
- <function name="OnSystemRequest" messagetype="notification" >
- <description>
- An asynchronous request from the system for specific data from the device or the cloud or response to a request from the device or cloud
- Binary data can be included in hybrid part of message for some requests (such as Authentication request responses)
- </description>
- <param name="requestType" type="Common.RequestType" mandatory="true">
- <description>The type of system request.</description>
- </param>
- <param name="url" type="String" maxlength="1000" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Optional array of URL(s) for HTTP requests.</description>
- </param>
- <param name="fileType" type="Common.FileType" mandatory="false">
- <description>Optional file type (meant for HTTP file requests).</description>
- </param>
- <param name="offset" type="Integer" minvalue="0" maxvalue="100000000000" mandatory="false">
- <description>Optional offset in bytes for resuming partial data chunks</description>
- </param>
- <param name="length" type="Integer" minvalue="0" maxvalue="100000000000" mandatory="false">
- <description>Optional length in bytes for resuming partial data chunks</description>
- </param>
- </function>
-
-</interface>
-
-<interface name="VR" version="1.0" date="2013-04-17">
- <function name="IsReady" messagetype="request">
- <description>Method is invoked at system startup. Response provides information about presence of VR module and its readiness to cooperate with SDL.</description>
- </function>
- <function name="IsReady" messagetype="response">
- <param name="available" type="Boolean" mandatory="true">
- <description>Must be true if VR is present and ready to communicate with SDL.</description>
- </param>
- </function>
- <function name="Started" messagetype="notification">
- <description>Must be initiated by VR module to let SDL know that VR session has started.</description>
- </function>
- <function name="Stopped" messagetype="notification">
- <description>Must be initiated by VR module to let SDL know that VR session has stopped.</description>
- </function>
- <function name="AddCommand" messagetype="request">
- <description>Request from SDL to add a command(string with associated id) to VR.</description>
- <param name="cmdID" type="Integer" mandatory="true" minvalue="0">
- <description>ID of a command (further to be used in OnCommand notification).</description>
- </param>
- <param name="vrCommands" type="String" mandatory="true" maxlength="99" minsize="1" maxsize="100" array="true">
- <description>List of strings to be used as VR commands.</description>
- </param>
- <param name="appID" type="Integer" mandatory="false">
- <description>ID of application that requested this RPC.</description>
- </param>
- </function>
- <function name="AddCommand" messagetype="response">
- </function>
- <function name="DeleteCommand" messagetype="request">
- <description>Request from SDL to delete a command from VR.</description>
- <param name="cmdID" type="Integer" mandatory="true">
- <description>Id of a command (list of strings), previously sent by AddCommand.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that requested this RPC.</description>
- </param>
- </function>
- <function name="DeleteCommand" messagetype="response">
- </function>
- <function name="OnCommand" messagetype="notification">
- <description>Notifies SDL about command trigerred via VR</description>
- <param name="cmdID" type="Integer" mandatory="true">
- <description>ID of of the command (list of strings)</description>
- </param>
- <param name="appID" type="Integer" mandatory="false">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="ChangeRegistration" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to change language of VR.</description>
- <param name="language" type="Common.Language" mandatory="true">
- <description>The language application wants to switch to.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="ChangeRegistration" messagetype="response">
- </function>
- <function name="OnLanguageChange" messagetype="notification">
- <description>Notification from HMI to SmartDeviceLink about change of language.</description>
- <param name="language" type="Common.Language" mandatory="true">
- <description>Language VR has switched to.</description>
- </param>
- </function>
- <function name="GetSupportedLanguages" messagetype="request">
- <description>Method is invoked at system start-up. Response must provide the information about VR supported languages.</description>
- </function>
- <function name="GetSupportedLanguages" messagetype="response">
- <param name="languages" type="Common.Language" mandatory="true" array="true" minsize="1" maxsize="100">
- <description>List of languages supported in VR.</description>
- </param>
- </function>
- <function name="GetLanguage" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to get currently active VR language</description>
- </function>
- <function name="GetLanguage" messagetype="response">
- <param name="language" type="Common.Language" mandatory="true"/>
- </function>
- <function name="GetCapabilities" messagetype="request">
- <description>Method is invoked at system startup by SDL to request information about VR capabilities of HMI.</description>
- </function>
- <function name="GetCapabilities" messagetype="response">
- <param name="vrCapabilities" type="Common.VrCapabilities" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Types of input recognized by VR module.</description>
- </param>
- </function>
-</interface>
-
-<interface name="TTS" version="1.0" date="2013-04-18">
- <description>RPCs for communication between TTS and SDL.</description>
- <function name="GetCapabilities" messagetype="request">
- <description>Method is invoked at system start-up. SDL requests the information about all supported hardware and their capabilities</description>
- </function>
- <function name="GetCapabilities" messagetype="response">
- <param name="capabilities" type="Common.SpeechCapabilities" mandatory="true">
- </param>
- </function>
- <function name="Started" messagetype="notification">
- <description>Must be initiated by TTS module to let SDL know that TTS session has started.</description>
- </function>
- <function name="Stopped" messagetype="notification">
- <description>Must be initiated by TTS module to let SDL know that TTS session has stopped.</description>
- </function>
- <function name="IsReady" messagetype="request">
- <description>Method is invoked at system start-up. Response must provide the information about presence of TTS module and its readiness to cooperate with SDL.</description>
- </function>
- <function name="IsReady" messagetype="response">
- <param name="available" type="Boolean" mandatory="true">
- <description>Must be true if TTS is present and ready to communicate with SDL.</description>
- </param>
- </function>
- <function name="PerformInteraction" messagetype="request">
- <description>Sets some properties for the application initiated request.</description>
- <param name="helpPrompt" type="Common.TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>The help prompt. An array of text chunks of type TTSChunk. See TTSChunk. The array must have at least one item.</description>
- </param>
- <param name="initialPrompt" type="Common.TTSChunk" minsize="1" maxsize="100" array="true">
- <description>
- This is the intial prompt spoken to the user at the start of an interaction.
- An array of text chunks of type TTSChunk. See TTSChunk.
- The array must have at least one item.
- </description>
- </param>
- <param name="timeoutPrompt" type="Common.TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Help text for a wait timeout. An array of text chunks of type TTSChunk. See TTSChunk. The array must have at least one item.</description>
- </param>
- <param name="timeout" type="Integer" mandatory="true">
- <description>Timeout initiate timeoutPrompt</description>
- </param>
- </function>
- <function name="PerformInteraction" messagetype="response">
- </function>
- <function name="Speak" messagetype="request">
- <description>RPC from SDL to TTS for speaking the text.</description>
- <param name="ttsChunks" type="Common.TTSChunk" mandatory="true" array="true" minsize="1" maxsize="100">
- <description>List of strings to be spoken.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that requested this RPC.</description>
- </param>
- </function>
- <function name="Speak" messagetype="response">
- <description>Provides information about success of operation.</description>
- </function>
- <function name="StopSpeaking" messagetype="request">
- <description>Initiated by SDL to stop speaking the text.</description>
- </function>
- <function name="StopSpeaking" messagetype="response">
- </function>
- <function name="ChangeRegistration" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to change language of TTS.</description>
- <param name="language" type="Common.Language" mandatory="true">
- <description>The language application wants to switch to.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="ChangeRegistration" messagetype="response">
- </function>
- <function name="OnLanguageChange" messagetype="notification">
- <description>Notification from HMI to SmartDeviceLink about change of language.</description>
- <param name="language" type="Common.Language" mandatory="true">
- <description>Language TTS has switched to.</description>
- </param>
- </function>
- <function name="GetSupportedLanguages" messagetype="request">
- <description>Method is invoked at system start-up by SDL. Response must provide the information about TTS supported languages.</description>
- </function>
- <function name="GetSupportedLanguages" messagetype="response">
- <param name="languages" type="Common.Language" mandatory="true" array="true" minsize="1" maxsize="100">
- <description>List of languages supported in TTS.</description>
- </param>
- </function>
- <function name="GetLanguage" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to get currently active TTS language</description>
- </function>
- <function name="GetLanguage" messagetype="response">
- <param name="language" type="Common.Language" mandatory="true"/>
- </function>
- <function name="SetGlobalProperties" messagetype="request">
- <description>Sets some properties for the application initiated request.</description>
- <param name="helpPrompt" type="Common.TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false" >
- <description>
- The help prompt.
- An array of text chunks of type TTSChunk. See TTSChunk.
- The array must have at least one item.
- </description>
- </param>
- <param name="timeoutPrompt" type="Common.TTSChunk" minsize="1" maxsize="100" array="true" mandatory="false" >
- <description>
- Help text for a wait timeout.
- An array of text chunks of type TTSChunk. See TTSChunk.
- The array must have at least one item.
- </description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="SetGlobalProperties" messagetype="response">
- </function>
-</interface>
-
-<interface name="UI" version="1.0" date="2013-04-16">
- <function name="Alert" messagetype="request">
- <description>Request from SDL to show an alert message on the display.</description>
- <param name="alertStrings" type="Common.TextFieldStruct" mandatory="true" array="true" minsize="0" maxsize="3">
- <description>Array of lines of alert text fields. See TextFieldStruct. Uses alertText1, alertText2, alertText3.</description>
- </param>
- <param name="duration" type="Integer" mandatory="true" minvalue="3000" maxvalue="10000" defvalue="5000">
- <description>Timeout in milliseconds.</description>
- </param>
- <param name="softButtons" type="Common.SoftButton" mandatory="false" minsize="0" maxsize="4" array="true">
- <description>App defined SoftButtons</description>
- </param>
- <param name="progressIndicator" type="Boolean" mandatory="false">
- <description>If supported on the given platform, the alert GUI will include some sort of animation indicating that loading of a feature is progressing. e.g. a spinning wheel or hourglass, etc.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="Alert" messagetype="response">
- <param name="tryAgainTime" type="Integer" mandatory="false" minvalue="0" maxvalue="360000">
- <description>Amount of time (in milliseconds) that SDL must wait before resending an alert. Must be provided if another system event or overlay currently has a higher priority than this alert.</description>
- </param>
- </function>
- <function name="ShowNotification" messagetype="notification">
- <description>Initiated by SDL in order to notify user about some actions, i.e. while waiting for updates from server etc.</description>
- <param name="text" type="Common.TextFieldStruct" mandatory="true"/>
- <param name="icon" type="Common.Image" mandatory="false"/>
- <param name="timeout" type="Integer" mandatory="true">
- <description>Pop-up is expected to be shown before time specified with timeout is up and then closed by HMI or closed upon ClosePopUp request from SDL.</description>
- </param>
- </function>
- <function name="Show" messagetype="request">
- <param name="showStrings" type="Common.TextFieldStruct" mandatory="true" array="true" minsize="0" maxsize="7">
- <description>Array of lines of show text fields. See TextFieldStruct. Uses mainField1, mainField2, mainField3, mainField4. If some field is not set, the corresponding text should stay unchanged. If field's text is empty "", the field must be cleared.
- mainField1: The text that should be displayed in a single or upper display line.
- mainField2: The text that should be displayed on the second display line.
- mainField3: The text that should be displayed on the second "page" first display line.
- mainField4: The text that should be displayed on the second "page" second display line.
- statusBar: statusBar.
- mediaClock: Text value for MediaClock field.
- mediaTrack: The text that should be displayed in the track field. This field is only valid for media applications on NGN type ACMs.
- </description>
- </param>
- <param name="alignment" type="Common.TextAlignment" mandatory="false">
- <description>Specifies how mainField1 and mainField2 texts should be aligned on the display.</description>
- <description>If omitted, texts must be centered</description>
- </param>
- <param name="graphic" type="Common.Image" mandatory="false">
- <description>Path to optional dynamic image or the static binary image itself. See Image. If omitted, the displayed graphic should not change.</description>
- </param>
- <param name="secondaryGraphic" type="Common.Image" mandatory="false">
- <description>
- Image struct determining whether static or dynamic secondary image to display in app.
- If omitted on supported displays, the displayed secondary graphic shall not change.
- </description>
- </param>
- <param name="softButtons" type="Common.SoftButton" minsize="0" maxsize="8" array="true" mandatory="false">
- <description>App defined SoftButtons.</description>
- <description>If omitted, the currently displayed SoftButton values should not change.</description>
- </param>
- <param name="customPresets" type="String" maxlength="500" minsize="0" maxsize="6" array="true" mandatory="false">
- <description>App labeled on-screen presets (i.e. GEN3 media presets or dynamic search suggestions).</description>
- <description>If omitted on supported displays, the presets will be shown as not defined.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>Id of application related to this RPC.</description>
- </param>
- </function>
- <function name="Show" messagetype="response">
- </function>
- <function name="AddCommand" messagetype="request">
- <description>Request from SDL to add a command to the application menu.</description>
- <param name="cmdID" type="Integer" minvalue="0" mandatory="true">
- <description>ID of the command to be added.</description>
- </param>
- <param name="menuParams" type="Common.MenuParams" mandatory="false">
- <description>Optional sub value containing parameters of the command (position, name, etc.). See MenuParams. If omitted the command should be added to the end of the list of commands.</description>
- </param>
- <param name="cmdIcon" type="Common.Image" mandatory="false">
- <description>Image to be displayed for representing the command. See Image.</description>
- <description>If omitted, no (or the default if applicable) icon should be displayed.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="AddCommand" messagetype="response">
- </function>
- <function name="DeleteCommand" messagetype="request">
- <description>Request from SDL to delete a command from the in-application menu with the specified command id.</description>
- <param name="cmdID" type="Integer" mandatory="true" minvalue="0" maxvalue="2000000000">
- <description>cmdId previously sent via AddCommand request - id of the command to be deleted.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="DeleteCommand" messagetype="response">
- </function>
- <function name="AddSubMenu" messagetype="request">
- <description>Request from SDL to add a sub menu to the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
- <description>ID of the sub menu to be added. Unique for the application.</description>
- </param>
- <param name="menuParams" type="Common.MenuParams" mandatory="true">
- <description>Position and name of menu to be added. 'parent' field is omitted for this RPC. </description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that requested this RPC.</description>
- </param>
- </function>
- <function name="AddSubMenu" messagetype="response">
- </function>
- <function name="DeleteSubMenu" messagetype="request">
- <description>Request from SDL to delete a submenu from the in-application menu.</description>
- <param name="menuID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true" >
- <description>The "menuID" of the sub-menu to be deleted. (See addSubMenu.menuID)</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="DeleteSubMenu" messagetype="response">
- </function>
- <function name="PerformInteraction" messagetype="request">
- <description>Request from SDL for triggering an interaction (e.g. "Permit GPS?" - Yes, no, Always Allow).</description>
- <param name="initialText" type="Common.TextFieldStruct" mandatory="true">
- <description>Uses initialInteractionText. See TextFieldStruct.</description>
- </param>
- <param name="choiceSet" type="Common.Choice" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>The list of choices to be used for the interaction with the user</description>
- </param>
- <param name="vrHelpTitle" type="String" maxlength="500" mandatory="false">
- <description>VR Help Title text.</description>
- <description>If omitted on supported displays, the default HU system help title should be used.</description>
- </param>
- <param name="vrHelp" type="Common.VrHelpItem" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>VR Help Items. If omitted on supported displays, the default HU system generated help items should be used.</description>
- </param>
- <param name="timeout" type="Integer" minvalue="5000" maxvalue="100000" defvalue="10000" mandatory="true">
- <description>Timeout in milliseconds.</description>
- </param>
- <param name="interactionLayout" type="Common.LayoutMode" mandatory="false">
- <description>See LayoutMode.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="PerformInteraction" messagetype="response">
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false">
- <description>ID of the choice that was selected in response to PerformInteraction.</description>
- </param>
- <param name="manualTextEntry" type="String" maxlength="500" mandatory="false">
- <description>
- Manually entered text selection, e.g. through keyboard
- Can be returned in lieu of choiceID, depending on trigger source
- </description>
- </param>
- </function>
- <function name="SetMediaClockTimer" messagetype="request">
- <description>Sets the initial media clock value and automatic update method.</description>
- <param name="startTime" type="Common.TimeFormat" mandatory="false">
- <description>startTime should be ignored for "PAUSE", "RESUME", and "CLEAR"</description>
- </param>
- <param name="endTime" type="Common.TimeFormat" mandatory="false">
- <description>
- See TimeFormat.
- endTime can be provided for "COUNTUP" and "COUNTDOWN"; to be used to calculate any visual progress bar (if not provided, this feature is ignored)
- If endTime is greater then startTime for COUNTDOWN or less than startTime for COUNTUP, then the request will return an INVALID_DATA.
- endTime will be ignored for "PAUSE", "RESUME", and "CLEAR"
- </description>
- </param>
- <param name="updateMode" type="Common.ClockUpdateMode" mandatory="true">
- <description>The update method of the media clock.</description>
- <description>In case of pause, resume, or clear, the start time value is ignored and shall be left out. For resume, the time continues with the same value as it was when paused.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that requested this RPC.</description>
- </param>
- </function>
- <function name="SetMediaClockTimer" messagetype="response">
- </function>
- <function name="SetGlobalProperties" messagetype="request">
- <description>Request from SDL to set some properties for VR help.</description>
- <param name="vrHelpTitle" type="String" maxlength="500" mandatory="false">
- <description>VR Help Title text.</description>
- <description>If omitted on supported displays, the default HU system help title should be used.</description>
- </param>
- <param name="vrHelp" type="Common.VrHelpItem" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>VR Help Items. If omitted on supported displays, the default HU system generated help items should be used.</description>
- </param>
- <param name="menuTitle" maxlength="500" type="String" mandatory="false">
- <description>Optional text to label an app menu button (for certain touchscreen platforms).</description>
- </param>
- <param name="menuIcon" type="Common.Image" mandatory="false">
- <description>>Optional icon to draw on an app menu button (for certain touchscreen platforms).</description>
- </param>
- <param name="keyboardProperties" type="Common.KeyboardProperties" mandatory="false">
- <description>On-screen keybaord configuration (if available).</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="SetGlobalProperties" messagetype="response">
- </function>
- <function name="OnCommand" messagetype="notification">
- <description>Notification must be initiated by HMI on user choosing menu item.</description>
- <param name="cmdID" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true">
- <description>Command ID, which is related to a specific menu entry (previously sent with AddCommand).</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that is related to this RPC.</description>
- </param>
- </function>
- <function name="OnSystemContext" messagetype="notification">
- <description>Notification must be initiated by HMI when the user changes the context of application: goes to menu (in-application menu or system menu); switches to VR; pop-up appears on screen etc.</description>
- <param name="systemContext" type="Common.SystemContext" mandatory="true">
- <description>The context the application is brought into.</description>
- </param>
- </function>
- <function name="GetCapabilities" messagetype="request">
- <description>Method is invoked at system startup by SDL to request information about UI capabilities of HMI.</description>
- </function>
- <function name="GetCapabilities" messagetype="response">
- <param name="displayCapabilities" type="Common.DisplayCapabilities" mandatory="true">
- <description>Information about the capabilities of the display: its type, text field supported, etc. See DisplayCapabilities. </description>
- </param>
- <param name="audioPassThruCapabilities" type="Common.AudioPassThruCapabilities" mandatory="true"/>
- <param name="hmiZoneCapabilities" type="Common.HmiZoneCapabilities" mandatory="true"/>
- <param name="softButtonCapabilities" type="Common.SoftButtonCapabilities" mandatory="false">
- <description>Must be returned if the platform supports on-screen SoftButtons.</description>
- </param>
- </function>
- <function name="ChangeRegistration" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to change language for app.</description>
- <param name="language" type="Common.Language" mandatory="true">
- <description>The language application wants to switch to.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="ChangeRegistration" messagetype="response">
- </function>
- <function name="OnLanguageChange" messagetype="notification">
- <description>Notification from HMI to SmartDeviceLink about change of language.</description>
- <param name="language" type="Common.Language" mandatory="true">
- <description>Language UI has switched to.</description>
- </param>
- </function>
- <function name="GetSupportedLanguages" messagetype="request">
- <description>Method should be invoked at system startup. Response provides information about UI supported languages.</description>
- </function>
- <function name="GetSupportedLanguages" messagetype="response">
- <param name="languages" type="Common.Language" mandatory="true" array="true" minsize="1" maxsize="100">
- <description>List of languages supported in UI.</description>
- </param>
- </function>
- <function name="GetLanguage" messagetype="request">
- <description>Request from SmartDeviceLink to HMI to get currently active UI language</description>
- </function>
- <function name="GetLanguage" messagetype="response">
- <param name="language" type="Common.Language" mandatory="true"/>
- </function>
- <function name="OnDriverDistraction" messagetype="notification">
- <description>Notification must be sent from HMI to SDL when driver distraction state is changed. Driver distraction rules are defined by the platform.</description>
- <param name="state" type="Common.DriverDistractionState" mandatory="true">
- <description>See DriverDistractionState. </description>
- </param>
- </function>
- <function name="SetAppIcon" messagetype="request">
- <description>Used to set existing local file on SYNC as the app's icon.</description>
- <param name="syncFileName" type="Common.Image" mandatory="true">
- <description>Either the path to the dynamic image stored on HY or the static binary image itself. See Image</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="SetAppIcon" messagetype="response">
- </function>
- <function name="ShowCustomForm" messagetype="request">
- <description>Used to show a custom form; it can be a parent or child screen. If no parent screen is designated, it is set as a parent screen.</description>
- <param name="customFormID" type="String" maxlength="500" mandatory="true">
- <description>
- Predefined or dynamically created screen layout.
- Currently only predefined forms are defined.
- Predefined layouts include:
- "DEFAULT" - Default media / non-media screen
- "ONSCREEN_PRESETS" - Custom root media screen containing app-defined onscreen presets.
- "KEYBOARD_SEARCH" - Custom template containing app-configured on-screen keyboard with active search updating; user also can trigger voice search.
- "NAV_FULLSCREEN_MAP" - Custom root template screen containing full screen map with navigation controls.
- "NAV_POI_MENU" - Custom template containing app-defined POI options.
- "NAV_SEARCH_RESULTS" - Custom template containing a list of app-defined search results
- "NAV_POI_INFO" - Custom template containing app-defined POI information (and potentially map data).
- </description>
- </param>
- <param name="parentFormID" type="String" maxlength="500" mandatory="false">
- <description>
- Parent screen of predefined form to display.
- Currently only predefined forms are defined.
- If not provided, then set to "DEFAULT".
- Predefined layouts include:
- "DEFAULT" - Default media / non-media screen
- "ONSCREEN_PRESETS" - Custom root media screen containing app-defined onscreen presets.
- "NAV_FULLSCREEN_MAP" - Custom template containing full screen map with navigation controls.
- </description>
- </param>
- </function>
- <function name="ShowCustomForm" messagetype="response">
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="ShowKeyboard" messagetype="request">
- <description>Configures and populates on-screen keyboard.</description>
- <param name="language" type="Common.Language" mandatory="true">
- <description>The keyboard language.</description>
- </param>
- <param name="keyboardLayout" type="Common.KeyboardLayout" mandatory="true" >
- <description>Desired keyboard layout.</description>
- </param>
- <param name="sendDynamicEntry" type="Boolean" mandatory="false">
- <description>In this mode, all keypresses will be sent as they occur.</description>
- <description>If disabled, entire string of text will be returned only once submitted by user.</description>
- <description>If omitted, this value will be set to FALSE.</description>
- </param>
- <param name="limitedCharacterList" type="String" maxlength="1" minsize="1" maxsize="100" array="true" mandatory="false">
- <description>Array of keyboard characters to enable.</description>
- <description>All omitted characters will be greyed out (disabled) on the keyboard.</description>
- <description>If omitted, the entire keyboard will be enabled.</description>
- </param>
- <param name="autoCompleteText" type="String" maxlength="1000" mandatory="false">
- <description>Allows an app to prepopulate the text field with a suggested or completed entry as the user types</description>
- </param>
- </function>
- <function name="ShowKeyboard" messagetype="response">
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
- <function name="OnKeyboardInput" messagetype="notification">
- <description>On-screen keyboard event.</description>
- <description>Can be full string or individual keypresses depending on keyboard mode.</description>
- <param name="event" type="Common.KeyboardEvent" mandatory="true">
- <description>On-screen keyboard input data.</description>
- </param>
- <param name="data" type="String" maxlength="500" mandatory="false">
- <description>On-screen keyboard input data.</description>
- <description>For dynamic keypress events, this will be the current compounded string of entry text.</description>
- <description>For entry submission events, this will be the full text entry (this will always return regardless of the mode).</description>
- <description>For entry cancelled and entry aborted events, this data param will be omitted.</description>
- </param>
- </function>
- <function name="OnTouchEvent" messagetype="notification">
- <description>Notifies about touch events on the screen's prescribed area</description>
- <param name="type" type="Common.TouchType" mandatory="true">
- <description>The type of touch event.</description>
- </param>
- <param name="event" type="Common.TouchEvent" mandatory="true" minsize="1" maxsize="10" array="true">
- <description>List of all individual touches involved in this event.</description>
- </param>
- </function>
- <function name="Slider" messagetype="request">
- <description>Creates a full screen or pop-up overlay (depending on platform) with a single user controlled slider.</description>
- <param name="numTicks" type="Integer" minvalue="2" maxvalue="26" mandatory="true">
- <description>Number of selectable items on a horizontal axis</description>
- </param>
- <param name="position" type="Integer" minvalue="1" maxvalue="26" mandatory="true">
- <description>Initial position of slider control (cannot exceed numTicks)</description>
- </param>
- <param name="sliderHeader" type="String" maxlength="500" mandatory="true">
- <description>Text header to be displayed.</description>
- </param>
- <param name="sliderFooter" type="String" maxlength="500" minsize="1" maxsize="26" array="true" mandatory="false">
- <description>Text footer to be displayed (meant to display min/max threshold descriptors).</description>
- <description>For a static text footer, only one footer string shall be provided in the array.</description>
- <description>For a dynamic text footer, the number of footer text string in the array must match the numTicks value.</description>
- <description>For a dynamic text footer, text array string should correlate with potential slider position index.</description>
- <description>If omitted on supported displays, no footer text shall be displayed.</description>
- </param>
- <param name="timeout" type="Integer" minvalue="1000" maxvalue="65535" mandatory="true">
- <description>Timeout. The slider should be displayed until the defined amount of time has elapsed. </description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that concerns this RPC.</description>
- </param>
- </function>
- <function name="Slider" messagetype="response">
- <param name="sliderPosition" type="Integer" minvalue="1" maxvalue="26" mandatory="false">
- <description>Current slider position. Must be returned when the user has clicked the ‘Save’ or ‘Canceled’ button or by the timeout </description>
- </param>
- </function>
- <function name="ScrollableMessage" messagetype="request">
- <description>Creates a full screen overlay containing a large block of formatted text that can be scrolled with up to 8 SoftButtons defined</description>
- <param name="messageText" type="Common.TextFieldStruct" mandatory="true">
- <description>Body of text that can include newlines and tabs. Uses scrollableMessageBody.</description>
- </param>
- <param name="timeout" type="Integer" minvalue="0" maxvalue="65535" defvalue="30000" mandatory="true">
- <description>Timeout in milliseconds. The message should be displayed until the time defined is up.</description>
- </param>
- <param name="softButtons" type="Common.SoftButton" minsize="0" maxsize="8" array="true" mandatory="false">
- <description>App defined SoftButtons.</description>
- <description>If omitted on supported displays, only the system defined "Close" SoftButton should be displayed.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="ScrollableMessage" messagetype="response">
- </function>
- <function name="PerformAudioPassThru" messagetype="request">
- <param name="audioPassThruDisplayTexts" type="Common.TextFieldStruct" mandatory="true" minsize="0" maxsize="2" array="true">
- <description>Uses
- audioPassThruDisplayText1: First line of text displayed during audio capture.
- audioPassThruDisplayText2: Second line of text displayed during audio capture.</description>
- </param>
- <param name="maxDuration" type="Integer" minvalue="1" maxvalue="1000000" mandatory="true">
- <description>The maximum duration of audio recording in milliseconds. If not provided, the recording should be performed until EndAudioPassThru arrives.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="PerformAudioPassThru" messagetype="response">
- </function>
- <function name="EndAudioPassThru" messagetype="request">
- <description>Request is sent by SDL to stop the audio capturing.</description>
- </function>
- <function name="EndAudioPassThru" messagetype="response">
- </function>
- <function name="IsReady" messagetype="request">
- <description>Method is invoked at system startup. Response provides information about presence of UI module and its readiness to cooperate with SDL.</description>
- </function>
- <function name="IsReady" messagetype="response">
- <param name="available" type="Boolean" mandatory="true">
- <description>Must be true if UI is present and ready to communicate with SDL.</description>
- </param>
- </function>
- <function name="ClosePopUp" messagetype="request">
- <description>Initiated by SDL to close currently active pop-up on HMI.</description>
- <param name="methodName" type="String" mandatory="false">
- <description>Method to be closed</description>
- </param>
- </function>
- <function name="ClosePopUp" messagetype="response">
- <description>Provides the result of operation.</description>
- </function>
- <function name="OnResetTimeout" messagetype="notification">
- <description>HMI must provide SDL with notifications specific to the current Turn-By-Turn client status on the module</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>Id of application that invoked notifcation.</description>
- </param>
- <param name="methodName" type="String" mandatory="true">
- <description>Currently used method name on which was triggered action</description>
- </param>
- </function>
-</interface>
-
-<interface name="Navigation" version="1.0" date="2013-05-22">
- <function name="IsReady" messagetype="request">
- <description>Method is invoked at system startup. Response must provide the information about presence of UI Navigation module and its readiness to cooperate with SDL.</description>
- </function>
- <function name="IsReady" messagetype="response">
- <param name="available" type="Boolean" mandatory="true">
- <description>Must be true if Navigation is present and ready to communicate with SDL.</description>
- </param>
- </function>
- <function name="ShowConstantTBT" messagetype="request">
- <description>Request from SmartDeviceLinkCore to HMI to show info about navigation.</description>
- <param name="navigationTexts" type="Common.TextFieldStruct" mandatory="true" array="true" minsize="0" maxsize="5">
- <description>See TextFieldStruct. Uses:
- navigationText1
- navigationText2
- ETA
- totalDistance.
- </description>
- </param>
- <param name="turnIcon" type="Common.Image" mandatory="false">
- </param>
- <param name="nextTurnIcon" type="Common.Image" mandatory="false">
- </param>
- <param name="distanceToManeuver" type="Float" minvalue="0" maxvalue="1000000000" mandatory="true">
- <description>Fraction of distance till next maneuver (from previous maneuver).</description>
- <description>May be used to calculate progress bar.</description>
- </param>
- <param name="distanceToManeuverScale" type="Float" minvalue="0" maxvalue="1000000000" mandatory="true">
- <description>Fraction of distance till next maneuver (starting from when AlertManeuver is triggered).</description>
- <description>May be used to calculate progress bar.</description>
- </param>
- <param name="maneuverComplete" type="Boolean" mandatory="false">
- <description>If and when a maneuver has completed while an AlertManeuver is active, SDL will send this value set to TRUE in order to clear the AlertManeuver overlay.</description>
- <description>If omitted the value should be assumed as FALSE.</description>
- </param>
- <param name="softButtons" type="Common.SoftButton" minsize="0" maxsize="3" array="true" mandatory="false">
- <description>Three dynamic SoftButtons available</description>
- <description>If omitted on supported displays, the currently displayed SoftButton values will not change.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="ShowConstantTBT" messagetype="response">
- </function>
- <function name="AlertManeuver" messagetype="request">
- <description>Request from SmartDeviceLinkCore to HMI to announce navigation maneuver</description>
- <param name="softButtons" type="Common.SoftButton" minsize="0" maxsize="3" array="true" mandatory="false">
- <description>If omitted, only the system defined "Close" SoftButton should be displayed.</description>
- </param>
- </function>
- <function name="AlertManeuver" messagetype="response">
- </function>
- <function name="UpdateTurnList" messagetype="request">
- <description>Request from SmartDeviceLinkCore to HMI to update turn list.</description>
- <param name="turnList" type="Common.Turn" minsize="1" maxsize="100" array="true" mandatory="true">
- </param>
- <param name="softButtons" type="Common.SoftButton" minsize="0" maxsize="1" array="true" mandatory="false">
- <description>If omitted, app-defined SoftButton should be left blank.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="UpdateTurnList" messagetype="response">
- </function>
- <function name="OnTBTClientState" messagetype="notification">
- <description>HMI must provide SDL with notifications specific to the current Turn-By-Turn client status on the module</description>
- <param name="state" type="Common.TBTState" mandatory="true">
- <description>Current State of TBT client</description>
- </param>
- </function>
- <function name="StartStream" messagetype="request">
- <description>Notification from SmartDeviceLinkCore to HMI to start playing video streaming.</description>
- <param name="url" type="String" minlength="21" maxlength="500" mandatory="true">
- <description>URL that HMI start playing.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="StartStream" messagetype="response">
- </function>
- <function name="StopStream" messagetype="request">
- <description>Notification from SmartDeviceLinkCore to HMI to start playing video streaming.</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="StopStream" messagetype="response">
- </function>
-
- <function name="StartAudioStream" messagetype="request">
- <description>Notification from SmartDeviceLinkCore to HMI to start playing audio streaming.</description>
- <param name="url" type="String" minlength="21" maxlength="500" mandatory="true">
- <description>URL that HMI start playing.</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="StartAudioStream" messagetype="response">
- </function>
- <function name="StopAudioStream" messagetype="request">
- <description>Notification from SmartDeviceLinkCore to HMI to start playing audio streaming.</description>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="StopAudioStream" messagetype="response">
- </function>
-
-</interface>
-
-<interface name="VehicleInfo" version="1.0" date="2013-04-21">
- <function name="IsReady" messagetype="request">
- <description>Method is invoked at system startup. Response should provide information about presence of any of vehicle information modules (ECU, GPS, etc) and their readiness to cooperate with SDL.</description>
- </function>
- <function name="IsReady" messagetype="response">
- <param name="available" type="Boolean" mandatory="true">
- <description>Must be true if vehicle data modules are present and ready to communicate with SDL.</description>
- </param>
- </function>
- <function name="GetVehicleType" messagetype="request">
- <description>Request from SmartDeviceLinkCore to HMI to get info about the vehicle (type, model, etc.).</description>
- </function>
- <function name="GetVehicleType" messagetype="response">
- <param name="vehicleType" type="Common.VehicleType" mandatory="true"/>
- </function>
- <function name="ReadDID" messagetype="request">
- <description>Request from SDL for vehicle data reading.</description>
- <param name="ecuName" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Name of ECU.</description>
- </param>
- <param name="didLocation" type="Integer" minvalue="0" maxvalue="65535" minsize="1" maxsize="1000" array="true" mandatory="true">
- <description>Get raw data from vehicle data DID location(s).</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application related to this RPC.</description>
- </param>
- </function>
- <function name="ReadDID" messagetype="response">
- <param name="didResult" type="Common.DIDResult" minsize="0" maxsize="1000" array="true" mandatory="false">
- <description>Array of requested DID results (with data if available).</description>
- </param>
- </function>
- <function name="GetDTCs" messagetype="request">
- <description>Vehicle module diagnostic trouble code request.</description>
- <param name="ecuName" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Name of ECU.</description>
- </param>
- <param name="dtcMask" type="Integer" minvalue="0" maxvalue="255" mandatory="false">
- <description>DTC Mask Byte to be sent in diagnostic request to module .</description>
- </param>
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application that requested this RPC.</description>
- </param>
- </function>
- <function name="GetDTCs" messagetype="response">
- <param name="ecuHeader" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>2 byte ECU Header for DTC response (as defined in VHR_Layout_Specification_DTCs.pdf)</description>
- </param>
- <param name="dtc" type="String" mandatory="false" minsize="1" maxsize="15" maxlength="10" array="true">
- <description>
- Array of all reported DTCs on module. Each DTC is represented with 4 bytes:
- 3 bytes for data
- 1 byte for status
- </description>
- </param>
- </function>
-
-<!--Qt HMI version of GetVehicleData-->
- <function name="GetGpsData" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetGpsData" messagetype="response">
- <param name="gps" type="Common.GPSData" mandatory="true">
- <description>See GPSData</description>
- </param>
- </function>
-
- <function name="GetSpeed" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetSpeed" messagetype="response">
- <param name="speed" type="Float" minvalue="0" maxvalue="700" mandatory="true">
- <description>The vehicle speed in kilometers per hour</description>
- </param>
- </function>
-
- <function name="GetRpm" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetRpm" messagetype="response">
- <param name="rpm" type="Integer" minvalue="0" maxvalue="20000" mandatory="true">
- <description>The number of revolutions per minute of the engine</description>
- </param>
- </function>
-
- <function name="GetFuelLevel" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetFuelLevel" messagetype="response">
- <param name="fuelLevel" type="Float" minvalue="-6" maxvalue="106" mandatory="true">
- <description>The fuel level in the tank (percentage)</description>
- </param>
- </function>
-
- <function name="GetFuelLevelState" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetFuelLevelState" messagetype="response">
- <param name="fuelLevel_State" type="Common.ComponentVolumeStatus" mandatory="true">
- <description>The fuel level state</description>
- </param>
- </function>
-
- <function name="GetInstantFuelConsumption" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetInstantFuelConsumption" messagetype="response">
- <param name="instantFuelConsumption" type="Float" minvalue="0" maxvalue="25575" mandatory="true">
- <description>The instantaneous fuel consumption in microlitres</description>
- </param>
- </function>
-
- <function name="GetExternalTemperature" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetExternalTemperature" messagetype="response">
- <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="true">
- <description>The external temperature in degrees celsius</description>
- </param>
- </function>
-
- <function name="GetVin" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetVin" messagetype="response">
- <param name="vin" type="String" maxlength="17" mandatory="true">
- <description>Vehicle identification number</description>
- </param>
- </function>
-
- <function name="GetPrndl" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetPrndl" messagetype="response">
- <param name="prndl" type="Common.PRNDL" mandatory="true">
- <description>See PRNDL</description>
- </param>
- </function>
-
- <function name="GetTirePressure" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetTirePressure" messagetype="response">
- <param name="tirePressure" type="Common.TireStatus" mandatory="true">
- <description>See TireStatus</description>
- </param>
- </function>
-
- <function name="GetOdometer" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetOdometer" messagetype="response">
- <param name="odometer" type="Integer" minvalue="0" maxvalue="17000000" mandatory="true">
- <description>Odometer in km</description>
- </param>
- </function>
-
- <function name="GetBeltStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetBeltStatus" messagetype="response">
- <param name="beltStatus" type="Common.BeltStatus" mandatory="true">
- <description>The status of the seat belts</description>
- </param>
- </function>
-
- <function name="GetBodyInformation" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetBodyInformation" messagetype="response">
- <param name="bodyInformation" type="Common.BodyInformation" mandatory="true">
- <description>The body information including power modes</description>
- </param>
- </function>
-
- <function name="GetDeviceStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetDeviceStatus" messagetype="response">
- <param name="deviceStatus" type="Common.DeviceStatus" mandatory="true">
- <description>The device status including signal and battery strength</description>
- </param>
- </function>
-
- <function name="GetDriverBraking" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetDriverBraking" messagetype="response">
- <param name="driverBraking" type="Common.VehicleDataEventStatus" mandatory="true">
- <description>The status of the brake pedal</description>
- </param>
- </function>
-
- <function name="GetWiperStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetWiperStatus" messagetype="response">
- <param name="wiperStatus" type="Common.WiperStatus" mandatory="true">
- <description>The status of the wipers</description>
- </param>
- </function>
-
- <function name="GetHeadLampStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetHeadLampStatus" messagetype="response">
- <param name="headLampStatus" type="Common.HeadLampStatus" mandatory="true">
- <description>Status of the head lamps</description>
- </param>
- </function>
-
- <function name="GetEngineTorque" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetEngineTorque" messagetype="response">
- <param name="engineTorque" type="Float" minvalue="-1000" maxvalue="2000" mandatory="true">
- <description>Torque value for engine (in Nm) on non-diesel variants</description>
- </param>
- </function>
-
- <function name="GetAccPedalPosition" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetAccPedalPosition" messagetype="response">
- <param name="accPedalPosition" type="Float" minvalue="0" maxvalue="100" mandatory="true">
- <description>Accelerator pedal position (percentage depressed)</description>
- </param>
- </function>
-
- <function name="GetSteeringWheelAngle" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetSteeringWheelAngle" messagetype="response">
- <param name="steeringWheelAngle" type="Float" minvalue="-2000" maxvalue="2000" mandatory="true">
- <description>Current angle of the steering wheel (in deg)</description>
- </param>
- </function>
-
- <function name="GetECallInfo" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetECallInfo" messagetype="response">
- <param name="eCallInfo" type="Common.ECallInfo" mandatory="true">
- <description>Emergency Call notification and confirmation data</description>
- </param>
- </function>
-
- <function name="GetAirbagStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetAirbagStatus" messagetype="response">
- <param name="airbagStatus" type="Common.AirbagStatus" mandatory="true">
- <description>The status of the air bags</description>
- </param>
- </function>
-
- <function name="GetEmergencyEvent" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetEmergencyEvent" messagetype="response">
- <param name="emergencyEvent" type="Common.EmergencyEvent" mandatory="true">
- <description>Information related to an emergency event (and if it occurred)</description>
- </param>
- </function>
-
- <function name="GetClusterModeStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetClusterModeStatus" messagetype="response">
- <param name="clusterModeStatus" type="Common.ClusterModeStatus" mandatory="true">
- <description>The status modes of the cluster</description>
- </param>
- </function>
-
- <function name="GetMyKey" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="GetMyKey" messagetype="response">
- <param name="myKey" type="Common.MyKey" mandatory="true">
- <description>Information related to the MyKey feature</description>
- </param>
- </function>
-<!--end Qt HMI version of GetVehicleData-->
-
-<!--Qt HMI version of OnVehicleData-->
- <function name="OnGpsData" messagetype="notification">
- <param name="gps" type="Common.GPSData" mandatory="true">
- <description>See GPSData</description>
- </param>
- </function>
-
- <function name="OnSpeed" messagetype="notification">
- <param name="speed" type="Float" minvalue="0" maxvalue="700" mandatory="true">
- <description>The vehicle speed in kilometers per hour</description>
- </param>
- </function>
-
- <function name="OnRpm" messagetype="notification">
- <param name="rpm" type="Integer" minvalue="0" maxvalue="20000" mandatory="true">
- <description>The number of revolutions per minute of the engine</description>
- </param>
- </function>
-
- <function name="OnFuelLevel" messagetype="notification">
- <param name="fuelLevel" type="Float" minvalue="-6" maxvalue="106" mandatory="true">
- <description>The fuel level in the tank (percentage)</description>
- </param>
- </function>
-
- <function name="OnFuelLevelState" messagetype="notification">
- <param name="fuelLevel_State" type="Common.ComponentVolumeStatus" mandatory="true">
- <description>The fuel level state</description>
- </param>
- </function>
-
- <function name="OnInstantFuelConsumption" messagetype="notification">
- <param name="instantFuelConsumption" type="Float" minvalue="0" maxvalue="25575" mandatory="true">
- <description>The instantaneous fuel consumption in microlitres</description>
- </param>
- </function>
-
- <function name="OnExternalTemperature" messagetype="notification">
- <param name="externalTemperature" type="Float" minvalue="-40" maxvalue="100" mandatory="true">
- <description>The external temperature in degrees celsius</description>
- </param>
- </function>
-
- <function name="OnVin" messagetype="notification">
- <param name="vin" type="String" maxlength="17" mandatory="true">
- <description>Vehicle identification number.</description>
- </param>
- </function>
-
- <function name="OnPrndl" messagetype="notification">
- <param name="prndl" type="Common.PRNDL" mandatory="true">
- <description>See PRNDL</description>
- </param>
- </function>
-
- <function name="OnTirePressure" messagetype="notification">
- <param name="tirePressure" type="Common.TireStatus" mandatory="true">
- <description>See TireStatus</description>
- </param>
- </function>
-
- <function name="OnOdometer" messagetype="notification">
- <param name="odometer" type="Integer" minvalue="0" maxvalue="2000000" mandatory="true">
- <description>Odometer in km</description>
- </param>
- </function>
-
- <function name="OnBeltStatus" messagetype="notification">
- <param name="beltStatus" type="Common.BeltStatus" mandatory="true">
- <description>The status of the seat belts</description>
- </param>
- </function>
-
- <function name="OnBodyInformation" messagetype="notification">
- <param name="bodyInformation" type="Common.BodyInformation" mandatory="true">
- <description>The body information including power modes</description>
- </param>
- </function>
-
- <function name="OnDeviceStatus" messagetype="notification">
- <param name="deviceStatus" type="Common.DeviceStatus" mandatory="true">
- <description>The device status including signal and battery strength</description>
- </param>
- </function>
-
- <function name="OnDriverBraking" messagetype="notification">
- <param name="driverBraking" type="Common.VehicleDataEventStatus" mandatory="true">
- <description>The status of the brake pedal</description>
- </param>
- </function>
-
- <function name="OnWiperStatus" messagetype="notification">
- <param name="wiperStatus" type="Common.WiperStatus" mandatory="true">
- <description>The status of the wipers</description>
- </param>
- </function>
-
- <function name="OnHeadLampStatus" messagetype="notification">
- <param name="headLampStatus" type="Common.HeadLampStatus" mandatory="true">
- <description>Status of the head lamps</description>
- </param>
- </function>
-
- <function name="OnEngineTorque" messagetype="notification">
- <param name="engineTorque" type="Float" minvalue="-1000" maxvalue="2000" mandatory="true">
- <description>Torque value for engine (in Nm) on non-diesel variants</description>
- </param>
- </function>
-
- <function name="OnAccPedalPosition" messagetype="notification">
- <param name="accPedalPosition" type="Float" minvalue="0" maxvalue="100" mandatory="true">
- <description>Accelerator pedal position (percentage depressed)</description>
- </param>
- </function>
-
- <function name="OnSteeringWheelAngle" messagetype="notification">
- <param name="steeringWheelAngle" type="Float" minvalue="-2000" maxvalue="2000" mandatory="true">
- <description>Current angle of the steering wheel (in deg)</description>
- </param>
- </function>
-
- <function name="OnMyKey" messagetype="notification">
- <param name="myKey" type="Common.MyKey" mandatory="true">
- <description>Information related to the MyKey feature</description>
- </param>
- </function>
-<!--end Qt HMI version of OnVehicleData-->
-
-<!--Qt HMI version of SubscribeVehicleData/UnsubscribeVehicleData-->
- <function name="SubscribeGps" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeGps" messagetype="response">
- <param name="gps" type="Common.VehicleDataResult" mandatory="true">
- <description>See GPSData</description>
- </param>
- </function>
- <function name="UnsubscribeGps" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeGps" messagetype="response">
- <param name="gps" type="Common.VehicleDataResult" mandatory="true">
- <description>See GPSData</description>
- </param>
- </function>
-
- <function name="SubscribeSpeed" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeSpeed" messagetype="response">
- <param name="speed" type="Common.VehicleDataResult" mandatory="true">
- <description>The vehicle speed in kilometers per hour</description>
- </param>
- </function>
- <function name="UnsubscribeSpeed" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeSpeed" messagetype="response">
- <param name="speed" type="Common.VehicleDataResult" mandatory="true">
- <description>The vehicle speed in kilometers per hour</description>
- </param>
- </function>
-
- <function name="SubscribeRpm" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeRpm" messagetype="response">
- <param name="rpm" type="Common.VehicleDataResult" mandatory="true">
- <description>The number of revolutions per minute of the engine</description>
- </param>
- </function>
- <function name="UnsubscribeRpm" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeRpm" messagetype="response">
- <param name="rpm" type="Common.VehicleDataResult" mandatory="true">
- <description>The number of revolutions per minute of the engine</description>
- </param>
- </function>
-
- <function name="SubscribeFuelLevel" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeFuelLevel" messagetype="response">
- <param name="fuelLevel" type="Common.VehicleDataResult" mandatory="true">
- <description>The fuel level in the tank (percentage)</description>
- </param>
- </function>
- <function name="UnsubscribeFuelLevel" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeFuelLevel" messagetype="response">
- <param name="fuelLevel" type="Common.VehicleDataResult" mandatory="true">
- <description>The fuel level in the tank (percentage)</description>
- </param>
- </function>
-
- <function name="SubscribeFuelLevel_State" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeFuelLevel_State" messagetype="response">
- <param name="fuelLevel_State" type="Common.VehicleDataResult" mandatory="true">
- <description>The fuel level state</description>
- </param>
- </function>
- <function name="UnsubscribeFuelLevel_State" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeFuelLevel_State" messagetype="response">
- <param name="fuelLevel_State" type="Common.VehicleDataResult" mandatory="true">
- <description>The fuel level state</description>
- </param>
- </function>
-
- <function name="SubscribeInstantFuelConsumption" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeInstantFuelConsumption" messagetype="response">
- <param name="instantFuelConsumption" type="Common.VehicleDataResult" mandatory="true">
- <description>The instantaneous fuel consumption in microlitres</description>
- </param>
- </function>
- <function name="UnsubscribeInstantFuelConsumption" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeInstantFuelConsumption" messagetype="response">
- <param name="instantFuelConsumption" type="Common.VehicleDataResult" mandatory="true">
- <description>The instantaneous fuel consumption in microlitres</description>
- </param>
- </function>
-
- <function name="SubscribeExternalTemperature" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeExternalTemperature" messagetype="response">
- <param name="externalTemperature" type="Common.VehicleDataResult" mandatory="true">
- <description>The external temperature in degrees celsius</description>
- </param>
- </function>
- <function name="UnsubscribeExternalTemperature" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeExternalTemperature" messagetype="response">
- <param name="externalTemperature" type="Common.VehicleDataResult" mandatory="true">
- <description>The external temperature in degrees celsius</description>
- </param>
- </function>
-
- <function name="SubscribePrndl" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribePrndl" messagetype="response">
- <param name="prndl" type="Common.VehicleDataResult" mandatory="true">
- <description>See PRNDL</description>
- </param>
- </function>
- <function name="UnsubscribePrndl" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribePrndl" messagetype="response">
- <param name="prndl" type="Common.VehicleDataResult" mandatory="true">
- <description>See PRNDL</description>
- </param>
- </function>
-
- <function name="SubscribeVin" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeVin" messagetype="response">
- <param name="vin" type="String" maxlength="17" mandatory="true">
- <description>Vehicle identification number</description>
- </param>
- </function>
- <function name="UnsubscribeVin" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeVin" messagetype="response">
- <param name="vin" type="String" maxlength="17" mandatory="true">
- <description>Vehicle identification number</description>
- </param>
- </function>
-
- <function name="SubscribeTirePressure" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeTirePressure" messagetype="response">
- <param name="tirePressure" type="Common.VehicleDataResult" mandatory="true">
- <description>See TireStatus</description>
- </param>
- </function>
- <function name="UnsubscribeTirePressure" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeTirePressure" messagetype="response">
- <param name="tirePressure" type="Common.VehicleDataResult" mandatory="true">
- <description>See TireStatus</description>
- </param>
- </function>
-
- <function name="SubscribeOdometer" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeOdometer" messagetype="response">
- <param name="odometer" type="Common.VehicleDataResult" mandatory="true">
- <description>Odometer in km</description>
- </param>
- </function>
- <function name="UnsubscribeOdometer" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeOdometer" messagetype="response">
- <param name="odometer" type="Common.VehicleDataResult" mandatory="true">
- <description>Odometer in km</description>
- </param>
- </function>
-
- <function name="SubscribeBeltStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeBeltStatus" messagetype="response">
- <param name="beltStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the seat belts</description>
- </param>
- </function>
- <function name="UnsubscribeBeltStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeBeltStatus" messagetype="response">
- <param name="beltStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the seat belts</description>
- </param>
- </function>
-
- <function name="SubscribeBodyInformation" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeBodyInformation" messagetype="response">
- <param name="bodyInformation" type="Common.VehicleDataResult" mandatory="true">
- <description>The body information including power modes</description>
- </param>
- </function>
- <function name="UnsubscribeBodyInformation" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeBodyInformation" messagetype="response">
- <param name="bodyInformation" type="Common.VehicleDataResult" mandatory="true">
- <description>The body information including power modes</description>
- </param>
- </function>
-
- <function name="SubscribeDeviceStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeDeviceStatus" messagetype="response">
- <param name="deviceStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The device status including signal and battery strength</description>
- </param>
- </function>
- <function name="UnsubscribeDeviceStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeDeviceStatus" messagetype="response">
- <param name="deviceStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The device status including signal and battery strength</description>
- </param>
- </function>
-
- <function name="SubscribeDriverBraking" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeDriverBraking" messagetype="response">
- <param name="driverBraking" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the brake pedal</description>
- </param>
- </function>
- <function name="UnsubscribeDriverBraking" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeDriverBraking" messagetype="response">
- <param name="driverBraking" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the brake pedal</description>
- </param>
- </function>
-
- <function name="SubscribeWiperStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeWiperStatus" messagetype="response">
- <param name="wiperStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the wipers</description>
- </param>
- </function>
- <function name="UnsubscribeWiperStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeWiperStatus" messagetype="response">
- <param name="wiperStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the wipers</description>
- </param>
- </function>
-
- <function name="SubscribeHeadLampStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeHeadLampStatus" messagetype="response">
- <param name="headLampStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>Status of the head lamps</description>
- </param>
- </function>
- <function name="UnsubscribeHeadLampStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeHeadLampStatus" messagetype="response">
- <param name="headLampStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>Status of the head lamps</description>
- </param>
- </function>
-
- <function name="SubscribeEngineTorque" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeEngineTorque" messagetype="response">
- <param name="engineTorque" type="Common.VehicleDataResult" mandatory="true">
- <description>Torque value for engine (in Nm) on non-diesel variants</description>
- </param>
- </function>
- <function name="UnsubscribeEngineTorque" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeEngineTorque" messagetype="response">
- <param name="engineTorque" type="Common.VehicleDataResult" mandatory="true">
- <description>Torque value for engine (in Nm) on non-diesel variants</description>
- </param>
- </function>
-
- <function name="SubscribeAccPedalPosition" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeAccPedalPosition" messagetype="response">
- <param name="accPedalPosition" type="Common.VehicleDataResult" mandatory="true">
- <description>Accelerator pedal position (percentage depressed)</description>
- </param>
- </function>
- <function name="UnsubscribeAccPedalPosition" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeAccPedalPosition" messagetype="response">
- <param name="accPedalPosition" type="Common.VehicleDataResult" mandatory="true">
- <description>Accelerator pedal position (percentage depressed)</description>
- </param>
- </function>
-
- <function name="SubscribeSteeringWheelAngle" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeSteeringWheelAngle" messagetype="response">
- <param name="steeringWheelAngle" type="Common.VehicleDataResult" mandatory="true">
- <description>Current angle of the steering wheel (in deg)</description>
- </param>
- </function>
- <function name="UnsubscribeSteeringWheelAngle" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeSteeringWheelAngle" messagetype="response">
- <param name="steeringWheelAngle" type="Common.VehicleDataResult" mandatory="true">
- <description>Current angle of the steering wheel (in deg)</description>
- </param>
- </function>
-
- <function name="SubscribeECallInfo" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeECallInfo" messagetype="response">
- <param name="eCallInfo" type="Common.VehicleDataResult" mandatory="true">
- <description>Emergency Call notification and confirmation data</description>
- </param>
- </function>
- <function name="UnsubscribeECallInfo" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeECallInfo" messagetype="response">
- <param name="eCallInfo" type="Common.VehicleDataResult" mandatory="true">
- <description>Emergency Call notification and confirmation data</description>
- </param>
- </function>
-
- <function name="SubscribeAirbagStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeAirbagStatus" messagetype="response">
- <param name="airbagStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the air bags</description>
- </param>
- </function>
- <function name="UnsubscribeAirbagStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeAirbagStatus" messagetype="response">
- <param name="airbagStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status of the air bags</description>
- </param>
- </function>
-
- <function name="SubscribeEmergencyEvent" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeEmergencyEvent" messagetype="response">
- <param name="emergencyEvent" type="Common.VehicleDataResult" mandatory="true">
- <description>Information related to an emergency event (and if it occurred)</description>
- </param>
- </function>
- <function name="UnsubscribeEmergencyEvent" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeEmergencyEvent" messagetype="response">
- <param name="emergencyEvent" type="Common.VehicleDataResult" mandatory="true">
- <description>Information related to an emergency event (and if it occurred)</description>
- </param>
- </function>
-
- <function name="SubscribeClusterModeStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeClusterModeStatus" messagetype="response">
- <param name="clusterModeStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status modes of the cluster</description>
- </param>
- </function>
- <function name="UnsubscribeClusterModeStatus" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeClusterModeStatus" messagetype="response">
- <param name="clusterModeStatus" type="Common.VehicleDataResult" mandatory="true">
- <description>The status modes of the cluster</description>
- </param>
- </function>
-
- <function name="SubscribeMyKey" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="SubscribeMyKey" messagetype="response">
- <param name="myKey" type="Common.VehicleDataResult" mandatory="true">
- <description>Information related to the MyKey feature</description>
- </param>
- </function>
- <function name="UnsubscribeMyKey" messagetype="request">
- <param name="appID" type="Integer" mandatory="true">
- <description>ID of application requested this RPC.</description>
- </param>
- </function>
- <function name="UnsubscribeMyKey" messagetype="response">
- <param name="myKey" type="Common.VehicleDataResult" mandatory="true">
- <description>Information related to the MyKey feature</description>
- </param>
- </function>
-<!--end Qt HMI version of SubscribeVehicleData/UnsubscribeVehicleData-->
-
-</interface>
-</interfaces>
diff --git a/test/tools/intergen/test_interface.xml b/test/tools/intergen/test_interface.xml
deleted file mode 100644
index 78ed9aa20..000000000
--- a/test/tools/intergen/test_interface.xml
+++ /dev/null
@@ -1,426 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<?xml-stylesheet type="text/xml" href="protocol2html.xsl"?>
-
-<interface name="test rpc interface" version="42" >
-
- <enum name="Result" internal_scope="base">
- <element name="SUCCESS">
- <description>The request succeeded</description>
- </element>
- <element name="INVALID_DATA">
- <description>
- The data sent is invalid. For example:
- Invalid Json syntax
- Parameters out of bounds (number or enum range)
- Mandatory parameters not provided
- Parameter provided with wrong type
- Invalid characters
- Empty string
- </description>
- </element>
- <element name="UNSUPPORTED_REQUEST">
- <description>The request is not supported by Sync</description>
- </element>
- <element name="OUT_OF_MEMORY">
- <description>The system could not process the request because the necessary memory couldn't be allocated</description>
- </element>
- <element name="TOO_MANY_PENDING_REQUESTS">
- <description>There are too many requests pending (means, that the response has not been delivered, yet).</description>
- <designdescription>There may be a maximum of 1000 pending requests at a time.</designdescription>
- </element>
- <element name="INVALID_ID">
- <description>
- One of the provided IDs is not valid. For example
- This applies to CorrelationID, SubscriptionID, CommandID, MenuID, etc.
- </description>
- </element>
- <element name="DUPLICATE_NAME">
- <description>There was a conflict with an registered name (application or menu item) or vr command</description>
- </element>
- <element name="TOO_MANY_APPLICATIONS">
- <description>There are already too many registered applications</description>
- </element>
- <element name="APPLICATION_REGISTERED_ALREADY">
- <description>RegisterApplication has been called again, after a RegisterApplication was successful before.</description>
- </element>
- <element name="UNSUPPORTED_VERSION">
- <description>Sync doesn't support the protocol that is requested by the mobile application</description>
- </element>
- <element name="WRONG_LANGUAGE">
- <description>
- The requested language is currently not supported.
- Might be because of a mismatch of the currently active language on Sync and the requested language
- </description>
- </element>
- <element name="APPLICATION_NOT_REGISTERED">
- <description>An command can not be executed because no application has been registered with RegisterApplication.</description>
- </element>
- <element name="IN_USE">
- <description>
- The data may not be changed, because it is currently in use.
- For example when trying to delete a command set that is currently involved in an interaction.
- </description>
- </element>
- <element name="VEHICLE_DATA_NOT_ALLOWED">
- <description>The user has turned off access to vehicle data, and it is globally unavailable to mobile applications.</description>
- </element>
- <element name="VEHICLE_DATA_NOT_AVAILABLE">
- <description>The requested vehicle data is not available on this vehicle or is not published.</description>
- </element>
- <element name="REJECTED">
- <description>
- The requested command was rejected, e.g. because mobile app is in background and cannot perform any HMI commands.
- Or an HMI command (e.g. Speak) is rejected because a higher priority HMI command (e.g. Alert) is playing.
- </description>
- </element>
- <element name="ABORTED">
- <description>
- A command was aborted, for example due to user interaction (e.g. user pressed button).
- Or an HMI command (e.g. Speak) is aborted because a higher priority HMI command (e.g. Alert) was requested.
- </description>
- </element>
- <element name="IGNORED">
- <description>
- A command was ignored, because the intended result is already in effect.
- For example, SetMediaClockTimer was used to pause the media clock although the clock is paused already.
- NOTE: potentially replaces SUBSCRIBED_ALREADY
- </description>
- </element>
- <element name="UNSUPPORTED_RESOURCE">
- <description>
- A button that was requested for subscription is not supported under the current system.
- NOTE: could become a more generic UNSUPPORTED_RESOURCE by merging with VEHICLE_DATA_NOT_AVAILABLE.
- </description>
- </element>
- <element name="FILE_NOT_FOUND">
- <description>A specified file could not be found on Sync.</description>
- </element>
- <element name="GENERIC_ERROR">
- <description>Provided data is valid but something went wrong in the lower layers.</description>
- </element>
- <element name="DISALLOWED">
- <description>RPC is not authorized in local policy table.</description>
- </element>
- <element name="USER_DISALLOWED">
- <description>RPC is included in a functional group explicitly blocked by the user.</description>
- </element>
- <element name="TIMED_OUT">
- <description>Overlay reached the maximum timeout and closed.</description>
- </element>
- <element name="CANCEL_ROUTE">
- <description>User selected to Cancel Route.</description>
- </element>
- <element name="TRUNCATED_DATA">
- <description>The RPC (e.g. ReadDID) executed successfully but the data exceeded the platform maximum threshold and thus, only part of the data is available.</description>
- </element>
- <element name="RETRY">
- <description>The user interrupted the RPC (e.g. PerformAudioPassThru) and indicated to start over. Note, the app must issue the new RPC.</description>
- </element>
- <element name="WARNINGS">
- <description>The RPC (e.g. SubscribeVehicleData) executed successfully but one or more items have a warning or failure.</description>
- </element>
- </enum>
-
- <enum name="AppInterfaceUnregisteredReason">
- <description>Error code, which comes from sync side.</description>
-<!-- Deprecate
- <element name="USER_EXIT" />
--->
- <element name="IGNITION_OFF" />
- <element name="BLUETOOTH_OFF" />
- <element name="USB_DISCONNECTED" />
- <element name="REQUEST_WHILE_IN_NONE_HMI_LEVEL" />
- <element name="TOO_MANY_REQUESTS" />
- <element name="DRIVER_DISTRACTION_VIOLATION" />
- <element name="LANGUAGE_CHANGE" />
- <element name="MASTER_RESET" />
- <element name="FACTORY_DEFAULTS" />
- <element name="APP_UNAUTHORIZED" />
- </enum>
-
- <enum name="TBTState">
- <description>Enumeration that describes possible states of turn-by-turn client or AppLink app.</description>
- <element name="ROUTE_UPDATE_REQUEST" />
- <element name="ROUTE_ACCEPTED" />
- <element name="ROUTE_REFUSED" />
- <element name="ROUTE_CANCELLED" />
- <element name="ETA_REQUEST" />
- <element name="NEXT_TURN_REQUEST" />
- <element name="ROUTE_STATUS_REQUEST" />
- <element name="ROUTE_SUMMARY_REQUEST" />
- <element name="TRIP_STATUS_REQUEST" />
- <element name="ROUTE_UPDATE_REQUEST_TIMEOUT" />
- </enum>
-
- <enum name="ImageType">
- <description>Contains information about the type of image.</description>
- <element name="STATIC" />
- <element name="DYNAMIC" />
- </enum>
-
- <struct name="Image">
- <param name="value" maxlength="65535" type="String">
- <description>Either the static hex icon value or the binary image file name identifier (sent by PutFile).</description>
- </param>
- <param name="imageType" type="ImageType">
- <description>Describes, whether it is a static or dynamic image.</description>
- </param>
- </struct>
-
- <struct name="Choice">
- <description>A choice is an option given to the user, which can be selected either by menu, or through voice recognition system.</description>
- <param name="choiceID" type="Integer" minvalue="0" maxvalue="65535" />
- <param name="menuName" type="String" maxlength="500" />
- <param name="vrCommands" type="String" minsize="1" maxsize="100" maxlength="99" map="true" />
- <param name="image" type="Image" mandatory="false"/>
- <param name="secondaryText" maxlength="500" type="String" mandatory="false" scope="partner">
- <description>Optional secondary text to display; e.g. address of POI in a search result entry</description>
- </param>
- <param name="tertiaryText" maxlength="500" type="String" mandatory="false" scope="partner">
- <description>Optional tertiary text to display; e.g. distance to POI for a search result entry</description>
- </param>
- <param name="secondaryImage" type="Image" mandatory="false" scope="partner">
- <description>Optional secondary image struct for choice</description>
- </param>
- </struct>
-
- <struct name="TestStructWithNullableParam">
- <param name="nullableInt" nullable="true" type="Integer" minavlue="0" maxvalue="42" />
- </struct>
-
- <struct name="TestStructWithNullableStructParam">
- <param name="nullableEnum" nullable="true" type="ImageType"/>
- <param name="nonNullableEnum" nullable="true" type="ImageType"/>
- </struct>
-
- <enum name="FunctionID" internal_scope="base">
- <description>Enumeration linking function names with function IDs in AppLink protocol.</description>
- <description>Assumes enumeration starts at value 0.</description>
- <element name="RESERVED" value="0" />
- <element name="AddSubMenuID" value="7" hexvalue="7" />
- <element name="DiagnosticMessageID" value="37" hexvalue="25" />
- <element name="OnAppInterfaceUnregisteredID" value="32769" hexvalue="8001" />
- <element name="OnTBTClientStateID" value="32774" hexvalue="8006" />
- <element name="OnAudioPassThruID" value="32777" hexvalue="8009" />
- <element name="DummyNotificationID" value="42" />
- </enum>
-
- <enum name="messageType">
- <description>
- Enumeration linking message types with function types in WiPro protocol.
- Assumes enumeration starts at value 0.
- </description>
- <element name="request" value="0" />
- <element name="response" value="1" />
- <element name="notification" value="2" />
- </enum>
-
- <!-- Requests/Responses -->
-
- <function name="AddSubMenu" functionID="AddSubMenuID" messagetype="request">
- <description>Adds a sub menu to the in-application menu.</description>
-
- <param name="menuID" type="Integer" minvalue="1" maxvalue="2000000000">
- <description>unique ID of the sub menu to add.</description>
- </param>
-
- <param name="position" type="Integer" minvalue="0" maxvalue="1000" defvalue="1000" mandatory="false">
- <description>
- Position within the items that are are at top level of the in application menu.
- 0 will insert at the front.
- 1 will insert at the second position.
- If position is greater or equal than the number of items on top level, the sub menu will be appended to the end.
- Position of any submenu will always be located before the return and exit options
- If this param was omitted the entry will be added at the end.
- </description>
- </param>
-
- <param name="menuName" maxlength="500" type="String">
- <description>Text to show in the menu for this sub menu.</description>
- </param>
- </function>
-
- <function name="AddSubMenu" functionID="AddSubMenuID" messagetype="response">
- <param name="success" type="Boolean" platform="documentation">
- <description> true if successful; false, if failed </description>
- </param>
-
- <param name="resultCode" type="Result" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="INVALID_ID"/>
- <element name="DUPLICATE_NAME"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
- </function>
-
-
- <function name="DiagnosticMessage" functionID="DiagnosticMessageID" messagetype="request" scope="internal">
- <description>Non periodic vehicle diagnostic request</description>
-
- <param name="targetID" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Name of target ECU.</description>
- </param>
-
- <param name="messageLength" type="Integer" minvalue="0" maxvalue="65535" mandatory="true">
- <description>Length of message (in bytes).</description>
- </param>
-
- <param name="messageData" type="Integer" minvalue="0" maxvalue="255" minsize="1" maxsize="65535" array="true" mandatory="true">
- <description>
- Array of bytes comprising CAN message.
- </description>
- </param>
- </function>
-
- <function name="DiagnosticMessage" functionID="DiagnosticMessageID" messagetype="response" scope="internal">
-
- <param name="success" type="Boolean" platform="documentation">
- <description> true, if successful; false, if failed </description>
- </param>
-
- <param name="resultCode" type="Result" array="true" platform="documentation">
- <description>See Result</description>
- <element name="SUCCESS"/>
- <element name="INVALID_DATA"/>
- <element name="OUT_OF_MEMORY"/>
- <element name="TOO_MANY_PENDING_REQUESTS"/>
- <element name="APPLICATION_NOT_REGISTERED"/>
- <element name="GENERIC_ERROR"/>
- <element name="REJECTED"/>
- <element name="DISALLOWED"/>
- <element name="USER_DISALLOWED"/>
- <element name="TRUNCATED_DATA"/>
- </param>
-
- <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation">
- <description>Provides additional human readable info regarding the result.</description>
- </param>
-
- <param name="messageDataResult" type="Integer" minvalue="0" maxvalue="255" minsize="1" maxsize="65535" array="true" mandatory="true">
- <description>
- Array of bytes comprising CAN message result.
- </description>
- </param>
-
- </function>
-
- <function name="OnAppInterfaceUnregistered" functionID="OnAppInterfaceUnregisteredID" messagetype="notification">
- <param name="reason" type="AppInterfaceUnregisteredReason">
- <description>See AppInterfaceUnregisteredReason</description>
- </param>
- </function>
-
- <function name="OnTBTClientState" functionID="OnTBTClientStateID" messagetype="notification" >
- <description>Provides applications with notifications specific to the current TBT client status on the module</description>
- <param name="state" type="TBTState">
- <description>Current State of TBT client</description>
- </param>
- </function>
-
- <function name="OnAudioPassThru" functionID="OnAudioPassThruID" messagetype="notification">
- <description>Binary data is in binary part of hybrid msg</description>
- </function>
-
- <typedef name="TdResult" type="Result">
- <description>
- Test typedef over enum
- </description>
- </typedef>
-
- <struct name="EmptyStruct">
- <description>
- Completely empty structure
- </description>
- </struct>
-
- <struct name="StructWithOptionalEmptyStructField">
- <param name="emptyOne" type="EmptyStruct" mandatory="false" />
- </struct>
-
- <struct name="StructWithMandatoryEmptyStructField">
- <param name="emptyOne" type="EmptyStruct" />
- </struct>
-
- <struct name="StructWithNullableTypedef">
- <description>
- Test struct having nullable typedef as a param
- </description>
- <param name="nullableTdResult" type="TdResult" nullable="true"/>
- </struct>
-
- <struct name="StructWithOneOptionalIntField" nullable="true" >
- <param name="optionalInt" type="Integer" minvalue="1" maxvalue="42" mandatory="false" />
- </struct>
-
- <struct name="StructWithFieldOfStructThatMightBeEmpty">
- <param name="fieldThatMightBeEmpty" type="StructWithOneOptionalIntField" mandatory="true" />
- </struct>
-
- <struct name="StructWithNullableOptionalMap">
- <param name="nullableOptionalIntMap" type="Integer" map="true" nullable="true" mandatory="false" minsize="0" maxsize="5" minvalue="2" maxvalue="10" />
- </struct>
-
- <struct name="StructWithNullableMapOfNullableInts">
- <param name="nullableMap" type="Integer" minvalue="0" maxvalue="42" map="true" minsize="1" maxsize="5" nullable="true" null_values_allowed="true" />
- </struct>
-
- <struct name="StructWithOptionalIntArray">
- <param name="optionalIntArray" type="Integer" minvalue="0" maxvalue="42" array="true" minsize="0" maxsize="5" mandatory="false" />
- </struct>
-
- <struct name="StructWithMandatoryIntArray">
- <param name="mandatoryIntArray" type="Integer" minvalue="0" maxvalue="42" array="true" minsize="0" maxsize="5" />
- </struct>
-
- <struct name="StructWithOptionalIntMap">
- <param name="optionalIntMap" type="Integer" minvalue="0" maxvalue="42" map="true" minsize="0" maxsize="5" mandatory="false" />
- </struct>
-
- <struct name="StructWithMandatoryIntMap">
- <param name="mandatoryIntMap" type="Integer" minvalue="0" maxvalue="42" map="true" minsize="0" maxsize="5" />
- </struct>
-
- <struct name="FrankenstructOfEmptyStringWithMandatoryInt" type="String" maxlength="15" minsize="0" maxsize="3">
- <param name="mandatoryInt" type="Integer" minvalue="0" maxvalue="42" />
- </struct>
-
- <typedef name="TdResultArray" type="TdResult" array="true" minsize="1" maxsize="10">
- <description>
- Test typedef over array
- </description>
- </typedef>
- <typedef name="TdResultArrayMap" type="TdResultArray" map="true" minsize="1" maxsize="5">
- <description>
- Test typedef over map of arrays
- </description>
- </typedef>
-
- <struct name="TdStruct" >
- <description>
- Test struct containing typedef field
- </description>
- <param name="resArrMap" type="TdResultArrayMap" mandatory="true" />
- <param name="optionalResArrMap" type="TdResultArrayMap" mandatory="false" />
- </struct>
-
- <typedef name="TdStructBasedTdef" type="TdStruct" array="true" minsize="1" maxsize="10">
- <description>
- Test typedef over struct
- </description>
- </typedef>
-
- <function name="DummyNotification" functionID="DummyNotificationID" messagetype="notification">
- <param name="tds" type="TdStructBasedTdef" />
- </function>
-
- </interface>
diff --git a/test/tools/policy_table_validator/CMakeLists.txt b/test/tools/policy_table_validator/CMakeLists.txt
deleted file mode 100644
index 2a372d7ff..000000000
--- a/test/tools/policy_table_validator/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-#set( CMAKE_VERBOSE_MAKEFILE on )
-
-include_directories(
- ${CMAKE_SOURCE_DIR}/src/components/policy/src/policy/
- ${CMAKE_SOURCE_DIR}/src/components/rpc_base/include/
- ${CMAKE_SOURCE_DIR}/src/components/utils/include/
- ${JSONCPP_INCLUDE_DIRECTORY}
-)
-
-
-link_directories (
- ${CMAKE_BINARY_DIR}/src/components/policy/src/policy/policy_table/table_struct/
- ${CMAKE_BINARY_DIR}/src/components/rpc_base/
-)
-
-
-set(LIBRARIES
- policy_struct
- rpc_base
-)
-
-set (SOURCES
- main.cpp
-)
-
-add_executable(policyValidator ${SOURCES})
-target_link_libraries(policyValidator ${LIBRARIES})
diff --git a/test/tools/policy_table_validator/main.cpp b/test/tools/policy_table_validator/main.cpp
deleted file mode 100644
index 16454ca12..000000000
--- a/test/tools/policy_table_validator/main.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <iostream>
-#include <cstdlib>
-#include "policy_table/table_struct/types.h"
-
-#include "json/reader.h"
-#include "utils/file_system.h"
-
-namespace policy_table = rpc::policy_table_interface_base;
-
-enum ResultCode {
- SUCCES = 0,
- MISSED_FILE_NAME,
- READ_ERROR,
- PARSE_ERROR,
- PT_TYPE_ERROR
-};
-
-rpc::policy_table_interface_base::PolicyTableType StringToPolicyTableType(const std::string& str_pt_type) {
- if (str_pt_type == "PT_PRELOADED") {
- return rpc::policy_table_interface_base::PT_PRELOADED;
- }
- if (str_pt_type == "PT_SNAPSHOT") {
- return rpc::policy_table_interface_base::PT_SNAPSHOT;
- }
- if (str_pt_type == "PT_UPDATE") {
- return rpc::policy_table_interface_base::PT_UPDATE;
- }
- return rpc::policy_table_interface_base::INVALID_PT_TYPE;
-}
-
-void help() {
- std::cout << "Usage:" << std::endl <<
- "./policy_validator {Policy table type} {file_name}" << std::endl;
- std::cout << "Policy table types:"
- "\t PT_PRELOADED , PT_UPDATE , PT_SNAPSHOT" <<std::endl;
-}
-
-int main(int argc, char** argv) {
- if (argc != 3) {
- // TODO(AKutsan): No filename
- help();
- exit(MISSED_FILE_NAME);
- }
- std::string pt_type_str = argv[1];
- std::string file_name = argv[2];
- std::string json_string;
- rpc::policy_table_interface_base::PolicyTableType pt_type;
- pt_type = StringToPolicyTableType(pt_type_str);
- if (rpc::policy_table_interface_base::PolicyTableType::INVALID_PT_TYPE
- == pt_type) {
- std::cout << "Invalid policy table type: " << pt_type_str << std::endl;
- exit(PT_TYPE_ERROR);
- }
- bool read_result = file_system::ReadFile(file_name, json_string);
- if (false == read_result) {
- std::cout << "Read file error: " << file_name << std::endl;
- exit(READ_ERROR);
- }
-
- Json::Reader reader;
- Json::Value value;
-
- bool parce_result = reader.parse(json_string, value);
- if (false == parce_result) {
- std::cout << "Json parce fails" << std::endl;
- exit(PARSE_ERROR);
- }
- std::cout << "DEFAULT_POLICY" << std::endl;
- policy_table::Table table(&value);
- table.SetPolicyTableType(pt_type);
- bool is_valid = table.is_valid();
- if (true == is_valid ) {
- std::cout << "Table is valid" << std::endl;
- exit(SUCCES);
- }
-
- std::cout << "Table is not valid" << std::endl;
- rpc::ValidationReport report("policy_table");
- table.ReportErrors(&report);
- std::cout << "Errors: " << std::endl << rpc::PrettyFormat(report) << std::endl;
-
- return SUCCES;
-}