file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/hmi_capabilities.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/wp1_policy_table.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
-if (BUILD_TESTS_WITH_HMI)
+if (BUILD_TESTS)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/wp1_policy_table.json DESTINATION ${CMAKE_BINARY_DIR}/test/)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/log4cxx.properties DESTINATION ${CMAKE_BINARY_DIR}/test/)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/smartDeviceLink.ini DESTINATION ${CMAKE_BINARY_DIR}/test/)
}
class CommandNotificationImpl;
+#ifdef TESTS_WITH_HMI
+namespace test {
+ class ApplicationManagerImplTest;
+}
+#endif
+
namespace application_manager {
namespace mobile_api = mobile_apis;
DISALLOW_COPY_AND_ASSIGN(ApplicationManagerImpl);
FRIEND_BASE_SINGLETON_CLASS(ApplicationManagerImpl);
+#ifdef TESTS_WITH_HMI
+ friend class test::ApplicationManagerImplTest;
+#endif
};
const std::set<ApplicationSharedPtr>& ApplicationManagerImpl::applications() const {
# ${GLIB_glib_2_INCLUDE_DIR}
)
-if (BUILD_TESTS_WITH_HMI)
- set(LIBRARIES
- test_App_Manager
- ApplicationManager
- MediaManager
- gtest
- gtest_main
- gmock
- gmock_main
- formatters
- HMI_API
- v4_protocol_v1_2_no_extra
- SmartObjects
- RequestWatchdog
- policies
- 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
- bluetooth
- pthread
- avahi-client
- avahi-common
- ${LibXML2_LIBRARIES} -lxml2
- # rt
- # ${GSTREAMER_gstreamer_LIBRARY}
- Resumption
- )
-else(BUILD_TESTS_WITH_HMI)
set(LIBRARIES
- MediaManager
- ApplicationManager
- gtest
- gtest_main
- gmock
- gmock_main
- formatters
- HMI_API
- v4_protocol_v1_2_no_extra
- SmartObjects
- RequestWatchdog
- policies
- 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
- bluetooth
- pthread
- avahi-client
- avahi-common
- ${LibXML2_LIBRARIES} -lxml2
- # rt
- # ${GSTREAMER_gstreamer_LIBRARY}
- Resumption
+ MediaManager
+ ApplicationManager
+ gtest
+ gtest_main
+ gmock
+ gmock_main
+ formatters
+ HMI_API
+ v4_protocol_v1_2_no_extra
+ SmartObjects
+ RequestWatchdog
+ policies
+ 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
+ connectionHandler
+ MOBILE_API
+ jsoncpp
+ TransportManager
+ HMIMessageHandler
+ MessageBroker
+ MessageBrokerClient
+ MessageBrokerServer
+ encryption
+ bluetooth
+ pthread
+ avahi-client
+ avahi-common
+ ${LibXML2_LIBRARIES} -lxml2
+ # rt
+ # ${GSTREAMER_gstreamer_LIBRARY}
+ Resumption
)
-endif(BUILD_TESTS_WITH_HMI)
-
if (BUILD_USB_SUPPORT)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
add_executable("test_suit" "./test_suit.cc")
-target_link_libraries("test_suit" ${LIBRARIES})
+if (BUILD_TESTS_WITH_HMI)
+ target_link_libraries("test_suit" test_App_Manager ${LIBRARIES})
+else (BUILD_TESTS_WITH_HMI)
+ target_link_libraries("test_suit" ${LIBRARIES})
+endif (BUILD_TESTS_WITH_HMI)
# vim: set ts=2 sw=2 et:
"./src/smoke_test_exp_media.cc"
"./src/protocol_handler_mockup.cc"
"./src/init_start_data.cc"
- "./src/test_hmi.cc")
+ "./src/test_hmi.cc"
+ "./src/application_manager_impl_test.cc")
--- /dev/null
+/**
+ * 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_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_TEST_H_
+#define TEST_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_TEST_H_
+
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+#include <cstdint>
+#include <string>
+#include <list>
+#include <vector>
+#include <map>
+#include <set>
+#include "application_manager/hmi_command_factory.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/hmi_capabilities.h"
+#include "application_manager/message.h"
+#include "application_manager/policies_manager/policies_manager.h"
+#include "application_manager/request_controller.h"
+#include "application_manager/resume_ctrl.h"
+#include "protocol_handler/protocol_observer.h"
+#include "hmi_message_handler/hmi_message_observer.h"
+
+#include "media_manager/media_manager_impl.h"
+
+#include "connection_handler/connection_handler_observer.h"
+#include "connection_handler/device.h"
+
+#include "formatters/CSmartFactory.hpp"
+
+#include "interfaces/HMI_API.h"
+#include "interfaces/HMI_API_schema.h"
+#include "interfaces/MOBILE_API_schema.h"
+
+#include "interfaces/v4_protocol_v1_2_no_extra.h"
+#include "interfaces/v4_protocol_v1_2_no_extra_schema.h"
+
+#include "protocol_handler/service_type.h"
+
+#include "utils/macro.h"
+#include "utils/logger.h"
+#include "utils/shared_ptr.h"
+#include "utils/message_queue.h"
+#include "utils/prioritized_queue.h"
+#include "utils/threads/thread.h"
+#include "utils/threads/message_loop_thread.h"
+#include "utils/lock.h"
+#include "utils/singleton.h"
+
+#include "application_manager/application_manager_impl.h"
+#include "formatters/CFormatterJsonSDLRPCv2.hpp"
+#include "application_manager/mobile_message_handler.h"
+#include "connection_handler/connection_handler_impl.h"
+
+namespace application_manager {
+class ApplicationManagerImpl;
+}
+
+namespace am = application_manager;
+namespace smart = NsSmartDeviceLink::NsSmartObjects;
+namespace jsn = NsSmartDeviceLink::NsJSONHandler::strings;
+
+namespace test {
+
+ class ApplicationManagerImplTest {
+ public:
+ ApplicationManagerImplTest();
+
+ ~ApplicationManagerImplTest();
+
+ const std::map<int32_t, am::ApplicationSharedPtr>& GetApplications();
+
+ const std::set<am::ApplicationSharedPtr>& GetApplicationList();
+
+ const std::list<am::CommandSharedPtr>& GetNotificationList();
+
+ const std::map<const int32_t, const uint32_t>& GetAppIDList();
+
+ bool GetAudioPassThruActive();
+
+ bool GetIsDistractingDriver();
+
+ bool GetIsVrSessionStrated();
+
+ bool GetHMICooperating();
+
+ bool GetIsAllAppsAllowed();
+
+ const media_manager::MediaManager* GetMediaManager();
+
+ const hmi_message_handler::HMIMessageHandler* GetHmiHandler();
+
+ const connection_handler::ConnectionHandler* GetConnectionHandler();
+
+ const protocol_handler::ProtocolHandler* GetProtocolHandler();
+
+ const policies::PolicyManager* GetPolicyManager();
+
+ const am::HMICapabilities& GetHmiCapabilities();
+
+ const am::policies_manager::PoliciesManager& GetPoliciesManager();
+
+ const hmi_apis::HMI_API* GetHmiSoFactory();
+
+ const mobile_apis::MOBILE_API* GetMobileSoFactory();
+
+ //uint32_t GetCorelationId();
+
+ //uint32_t GetMaxCorelationId();
+
+ am::mobile_api::AppInterfaceUnregisteredReason::eType
+ GetUnregisterReason();
+
+ const am::impl::FromMobileQueue& GetMessagesFromMobile();
+
+ const am::impl::ToMobileQueue& GetMessagesToMobile();
+
+ const am::impl::FromHmiQueue& GetMessagesFromHmi();
+
+ const am::impl::ToHmiQueue& GetMessagesToHmi();
+
+ /*
+ const std::map<int32_t, am::ApplicationSharedPtr>& GetApplications() {
+ return applications_;
+ }
+
+ const std::set<am::ApplicationSharedPtr>& GetApplicationList() {
+ return application_list_;
+ }
+
+ const std::list<am::CommandSharedPtr>& GetNotificationList() {
+ return notification_list_;
+ }
+
+ const std::map<const int32_t, const uint32_t>& GetAppIDList() {
+ return appID_list_;
+ }
+
+ bool GetAudioPassThruActive() {
+ return audio_pass_thru_active_;
+ }
+
+ bool GetIsDistractingDriver() {
+ return is_distracting_driver_;
+ }
+
+ bool GetIsVrSessionStrated() {
+ return is_vr_session_strated_;
+ }
+
+ bool GetHMICooperating() {
+ return hmi_cooperating_;
+ }
+
+ bool GetIsAllAppsAllowed() {
+ return is_all_apps_allowed_;
+ }
+
+ const media_manager::MediaManager* GetMediaManager() {
+ return media_manager_;
+ }
+
+ const hmi_message_handler::HMIMessageHandler* GetHmiHandler() {
+ return hmi_handler_;
+ }
+
+ const connection_handler::ConnectionHandler* GetConnectionHandler() {
+ return connection_handler_;
+ }
+
+ const protocol_handler::ProtocolHandler* GetProtocolHandler() {
+ return protocol_handler_;
+ }
+
+ const policies::PolicyManager* GetPolicyManager() {
+ return policy_manager_;
+ }
+
+ const am::HMICapabilities& GetHmiCapabilities() {
+ return hmi_capabilities_;
+ }
+
+ const am::policies_manager::PoliciesManager& GetPoliciesManager() {
+ return policies_manager_;
+ }
+
+ const hmi_apis::HMI_API* GetHmiSoFactory() {
+ return hmi_so_factory_;
+ }
+
+ const mobile_apis::MOBILE_API* GetMobileSoFactory() {
+ return mobile_so_factory_;
+ }
+
+ const uint32_t& GetCorelationId() {
+ return corelation_id_;
+ }
+
+ const uint32_t& GetMaxCorelationId() {
+ return max_corelation_id_;
+ }
+
+ am::mobile_api::AppInterfaceUnregisteredReason::eType
+ GetUnregisterReason() {
+ return unregister_reason_;
+ }
+
+ const am::impl::FromMobileQueue& GetMessagesFromMobile() {
+ return messages_from_mobile_;
+ }
+
+ const am::impl::ToMobileQueue& GetMessagesToMobile() {
+ return messages_to_mobile_;
+ }
+
+ const am::impl::FromHmiQueue& GetMessagesFromHmi() {
+ return messages_from_hmi_;
+ }
+
+ const am::impl::ToHmiQueue& GetMessagesToHmi() {
+ return messages_to_hmi_;
+ }
+ */
+ private:
+ am::ApplicationManagerImpl* app_;
+ };
+
+ void RegistrSO(utils::SharedPtr<smart::SmartObject> AppRegRequest);
+
+ utils::SharedPtr<protocol_handler::RawMessage>
+ ConvertSOToRawMess(utils::SharedPtr<smart::SmartObject> so);
+
+ void AddDevice(uint32_t);
+
+} // namespace test
+
+#endif // TEST_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_APPLICATION_MANAGER_IMPL_TEST_H_
--- /dev/null
+/**
+ * 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_RPC_INCLUDE_RPC_TEST_APP_MANAGER_H_
+#define TEST_COMPONENTS_APPLICATION_MANAGER_RPC_INCLUDE_RPC_TEST_APP_MANAGER_H_
+
+#include <string>
+
+#include "rpc/application_manager_impl_test.h"
+#include "rpc/init_hmi.h"
+
+#include "application_manager/application_manager_impl.h"
+#include "connection_handler/connection_handler_impl.h"
+#include "formatters/CFormatterJsonSDLRPCv2.hpp"
+#include "application_manager/mobile_message_handler.h"
+
+#include "life_cycle.h"
+
+namespace am = application_manager;
+namespace smart = NsSmartDeviceLink::NsSmartObjects;
+namespace jsn = NsSmartDeviceLink::NsJSONHandler::strings;
+
+// void RegistrSO(utils::SharedPtr<smart::SmartObject> AppRegRequest);
+
+// utils::SharedPtr<protocol_handler::RawMessage>
+// ConvertSOToRawMess(utils::SharedPtr<smart::SmartObject> so);
+
+namespace test {
+
+TEST(TestApplicationManager, RegApp) {
+ /****************************************************************************/
+ /**
+ * Test without ConnectionHandle Device
+ */
+ utils::SharedPtr<smart::SmartObject> so_reg(new smart::SmartObject);
+ utils::SharedPtr<protocol_handler::RawMessage> raw_mes;
+ am::ApplicationSharedPtr sh_app;
+ am::ApplicationSharedPtr temp_sh_app;
+ test::ApplicationManagerImplTest app_manager_test;
+
+ am::ApplicationManagerImpl* app_manager =
+ am::ApplicationManagerImpl::instance();
+
+ RegistrSO(so_reg);
+
+ raw_mes = ConvertSOToRawMess(so_reg);
+
+ app_manager->OnMessageReceived(raw_mes);
+ sleep(3);
+ sh_app = app_manager->application(65546);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Valid add app
+ */
+ AddDevice(10);
+
+ app_manager->OnMessageReceived(raw_mes);
+
+ sleep(3);
+ sh_app = app_manager->application(65546);
+
+ EXPECT_TRUE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test app_name is DUPLICATE_NAME
+ */
+ utils::SharedPtr<smart::SmartObject> so_reg2(new smart::SmartObject);
+ utils::SharedPtr<protocol_handler::RawMessage> raw_mes2;
+
+ RegistrSO(so_reg2);
+
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::app_id] = "65547";
+ (*so_reg2)[jsn::S_PARAMS][am::strings::connection_key] = 65547;
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::app_name] = "SyncProxyTester";
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::vr_synonyms][0] =
+ "VR SyncProxyTester2";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ AddDevice(11);
+ sleep(1);
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test app_name is INVALID_DATA - Failed to parse string to smart object
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::app_name] = "";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test app_name is INVALID_DATA - Param names restrictions check failed
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::app_name] = "\n";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test tts_name is INVALID_DATA -Failed to parse string to smart object
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::app_name] = "SyncProxyTester2";
+
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][0]["text"] = "";
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][0]["type"] = "TEXT";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test tts_name is INVALID_DATA - Param names restrictions check failed
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][0]["text"] = "\n";
+
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test tts_name is INVALID_DATA -Failed to parse string to smart object
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][0]["text"] =
+ "SyncProxyTesterTTS2";
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][1]["text"] = "";
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][1]["type"] = "TEXT";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test tts_name is INVALID_DATA - Param names restrictions check failed
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][1]["text"] =
+ "\n";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test vr_synonyms is DUPLICATE_NAME - Some VR synonyms are known already
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::tts_name][1]["text"] =
+ "TTSName";
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::vr_synonyms][0] =
+ "VR SyncProxyTester";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Test app_id is INVALID_DATA - duplicate
+ */
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::vr_synonyms][0] =
+ "VR SyncProxyTester2";
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::app_id] = "65537";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_FALSE(sh_app.valid());
+
+ /****************************************************************************/
+ /**
+ * Valid add app
+ */
+
+ (*so_reg2)[jsn::S_MSG_PARAMS][am::strings::app_id] = "65547";
+
+ raw_mes2 = ConvertSOToRawMess(so_reg2);
+
+ app_manager->OnMessageReceived(raw_mes2);
+
+ sleep(3);
+ sh_app = app_manager->application(65547);
+
+ EXPECT_TRUE(sh_app.valid());
+
+}
+} // namespace test
+
+#endif // TEST_COMPONENTS_APPLICATION_MANAGER_RPC_INCLUDE_RPC_TEST_APP_MANAGER_H_
--- /dev/null
+/**
+ * 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 "rpc/application_manager_impl_test.h"
+#include "application_manager/application_manager_impl.h"
+
+namespace test {
+
+ApplicationManagerImplTest::ApplicationManagerImplTest()
+ : app_(NULL) {
+ app_ = am::ApplicationManagerImpl::instance();
+ //app_ = new application_manager::ApplicationManagerImpl;
+ app_->application_list_;
+}
+
+ApplicationManagerImplTest::~ApplicationManagerImplTest() {
+}
+
+const std::map<int32_t, am::ApplicationSharedPtr>&
+ApplicationManagerImplTest::GetApplications() {
+ return app_->applications_;
+}
+
+const std::set<am::ApplicationSharedPtr>&
+ApplicationManagerImplTest::GetApplicationList() {
+ return app_->application_list_;
+}
+
+const std::list<am::CommandSharedPtr>&
+ApplicationManagerImplTest::GetNotificationList() {
+ return app_->notification_list_;
+}
+
+const std::map<const int32_t, const uint32_t>&
+ApplicationManagerImplTest::GetAppIDList() {
+ return app_->appID_list_;
+}
+
+bool ApplicationManagerImplTest::GetAudioPassThruActive() {
+ return app_->audio_pass_thru_active_;
+}
+
+bool ApplicationManagerImplTest::GetIsDistractingDriver() {
+ return app_->is_distracting_driver_;
+}
+
+bool ApplicationManagerImplTest::GetIsVrSessionStrated() {
+ return app_->is_vr_session_strated_;
+}
+
+bool ApplicationManagerImplTest::GetHMICooperating() {
+ return app_->hmi_cooperating_;
+}
+
+bool ApplicationManagerImplTest::GetIsAllAppsAllowed() {
+ return app_->is_all_apps_allowed_;
+}
+
+const media_manager::MediaManager*
+ApplicationManagerImplTest::GetMediaManager() {
+ return app_->media_manager_;
+}
+
+const hmi_message_handler::HMIMessageHandler*
+ApplicationManagerImplTest::GetHmiHandler() {
+ return app_->hmi_handler_;
+}
+
+const connection_handler::ConnectionHandler*
+ApplicationManagerImplTest::GetConnectionHandler() {
+ return app_->connection_handler_;
+}
+
+const protocol_handler::ProtocolHandler*
+ApplicationManagerImplTest::GetProtocolHandler() {
+ return app_->protocol_handler_;
+}
+
+const policies::PolicyManager* ApplicationManagerImplTest::GetPolicyManager() {
+ return app_->policy_manager_;
+}
+
+const am::HMICapabilities& ApplicationManagerImplTest::GetHmiCapabilities() {
+ return app_->hmi_capabilities_;
+}
+
+const am::policies_manager::PoliciesManager&
+ApplicationManagerImplTest::GetPoliciesManager() {
+ return app_->policies_manager_;
+}
+
+const hmi_apis::HMI_API* ApplicationManagerImplTest::GetHmiSoFactory() {
+ return app_->hmi_so_factory_;
+}
+
+const mobile_apis::MOBILE_API*
+ApplicationManagerImplTest::GetMobileSoFactory() {
+ return app_->mobile_so_factory_;
+}
+/*
+uint32_t ApplicationManagerImplTest::GetCorelationId() {
+ return app_->corelation_id_;
+}
+
+uint32_t ApplicationManagerImplTest::GetMaxCorelationId() {
+ return app_->max_corelation_id_;
+}
+*/
+am::mobile_api::AppInterfaceUnregisteredReason::eType
+ApplicationManagerImplTest::GetUnregisterReason() {
+ return app_->unregister_reason_;
+}
+
+const am::impl::FromMobileQueue&
+ApplicationManagerImplTest::GetMessagesFromMobile() {
+ return app_->messages_from_mobile_;
+}
+
+const am::impl::ToMobileQueue&
+ApplicationManagerImplTest::GetMessagesToMobile() {
+ return app_->messages_to_mobile_;
+}
+
+const am::impl::FromHmiQueue& ApplicationManagerImplTest::GetMessagesFromHmi() {
+ return app_->messages_from_hmi_;
+}
+
+const am::impl::ToHmiQueue& ApplicationManagerImplTest::GetMessagesToHmi() {
+ return app_->messages_to_hmi_;
+}
+
+void RegistrSO(utils::SharedPtr<smart::SmartObject> AppRegRequest) {
+ (*AppRegRequest)[jsn::S_PARAMS][am::strings::function_id] =
+ mobile_apis::FunctionID::RegisterAppInterfaceID;
+ (*AppRegRequest)[jsn::S_PARAMS][am::strings::message_type] =
+ mobile_apis::messageType::request;
+
+ (*AppRegRequest)[jsn::S_PARAMS][am::strings::connection_key] = 65546;
+
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::app_name] =
+ "SyncProxyTester";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::available] = true;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::language_desired] =
+ hmi_apis::Common_Language::EN_US;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::hmi_display_language_desired] =
+ hmi_apis::Common_Language::EN_US;
+
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::app_id] = "65537";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::sync_msg_version]["majorVersion"] = 2;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::sync_msg_version]["minorVersion"] = 2;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::is_media_application] = true;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::app_hmi_type][0] = "NAVIGATION";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::ngn_media_screen_app_name] = "SyncP";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::vr_synonyms][0] = "VR SyncProxyTester";
+}
+
+utils::SharedPtr<protocol_handler::RawMessage> ConvertSOToRawMess(
+ utils::SharedPtr<smart::SmartObject> so) {
+ application_manager::Message* mes = new application_manager::Message(
+ protocol_handler::MessagePriority::kDefault);
+
+ utils::SharedPtr<application_manager::Message> message_to_app(mes);
+ std::string str;
+
+ (*message_to_app).set_correlation_id(
+ (*so)[jsn::S_PARAMS][am::strings::correlation_id].asInt());
+ (*message_to_app).set_function_id(
+ (*so)[jsn::S_PARAMS][am::strings::function_id].asInt());
+ (*message_to_app).set_connection_key(
+ (*so)[jsn::S_PARAMS][am::strings::connection_key].asInt());
+ (*message_to_app).set_message_type(application_manager::kRequest);
+
+ NsSmartDeviceLink::NsJSONHandler::Formatters::CFormatterJsonSDLRPCv2::
+ toString((*so), str);
+
+ (*message_to_app).set_json_message(str);
+
+ utils::SharedPtr<protocol_handler::RawMessage> raw_mes(
+ am::MobileMessageHandler::HandleOutgoingMessageProtocolV2(
+ message_to_app));
+
+ return raw_mes;
+}
+
+void AddDevice(uint32_t value) {
+ connection_handler::ConnectionHandlerImpl* connection_handle =
+ connection_handler::ConnectionHandlerImpl::instance();
+
+ transport_manager::DeviceHandle device_handler_test = value;
+ std::string mac_address_test = "255.255.255.0";
+ std::string name_test = "test_DeviceInfo";
+
+ transport_manager::ConnectionUID connection_id_test = value;
+
+ transport_manager::DeviceInfo device_info_test(
+ device_handler_test,
+ mac_address_test,
+ name_test);
+
+ connection_handle->OnDeviceAdded(device_info_test);
+
+ connection_handle->OnConnectionEstablished(
+ device_info_test,
+ connection_id_test);
+}
+
+/*
+ am::ApplicationSharedPtr RegistrApp() {
+ connection_handler::ConnectionHandlerImpl* connection_handler_ =
+ connection_handler::ConnectionHandlerImpl::instance();
+
+ application_manager::ApplicationManagerImpl* app_manager_ =
+ &app_mngr_impl_test_;
+
+ app_manager_->set_connection_handler(connection_handler_);
+ connection_handler_->set_connection_handler_observer(app_manager_);
+
+ utils::SharedPtr<am::Application> appl(app_manager_->application(65537));
+
+ if (appl.valid()) {
+ return;
+ }
+
+ printf("\n\n\n Registration Application \n\n\n");
+
+ transport_manager::DeviceHandle device_handler_test = 1;
+ std::string mac_address_test = "255.255.255.0";
+ std::string name_test = "test_DeviceInfo";
+
+ transport_manager::ConnectionUID connection_id_test = 1;
+
+ transport_manager::DeviceInfo device_info_test(
+ device_handler_test,
+ mac_address_test,
+ name_test);
+
+ // std::vector<transport_manager::DeviceInfo> device_list_test;
+ // device_list_test.push_back(device_info_test);
+ // connection_handler_->OnDeviceListUpdated(device_list_test);
+ connection_handler_->OnDeviceAdded(device_info_test);
+
+ connection_handler_->OnConnectionEstablished(
+ device_info_test,
+ connection_id_test);
+ sleep(5);
+
+ utils::SharedPtr<smart::SmartObject> AppRegRequest(new smart::SmartObject);
+
+ // -------------------------------------------------------------------------
+ (*AppRegRequest)[jsn::S_PARAMS][am::strings::function_id] =
+ mobile_apis::FunctionID::RegisterAppInterfaceID;
+ (*AppRegRequest)[jsn::S_PARAMS][am::strings::message_type] =
+ mobile_apis::messageType::request;
+
+ (*AppRegRequest)[jsn::S_PARAMS][am::strings::connection_key] = 65537;
+
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::app_name] =
+ "SyncProxyTester";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::available] = true;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::language_desired] =
+ hmi_apis::Common_Language::EN_US;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::hmi_display_language_desired]
+ = hmi_apis::Common_Language::EN_US;
+
+ (*AppRegRequest)[jsn::S_MSG_PARAMS][am::strings::app_id] = "65537";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::sync_msg_version]["majorVersion"] = 2;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::sync_msg_version]["minorVersion"] = 2;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::is_media_application] = true;
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::app_hmi_type][0] = "NAVIGATION";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::ngn_media_screen_app_name] = "SyncP";
+ (*AppRegRequest)[jsn::S_MSG_PARAMS]
+ [am::strings::vr_synonyms][0] = "VR SyncProxyTester";
+
+ app_manager_->ManageMobileCommand(AppRegRequest);
+
+ }
+ */
+
+} // namespace test
#include "rpc/admin_app_test.h"
#include "utils/threads/thread.h"
#include "utils/threads/thread_options.h"
+#include "rpc/test_app_manager.h"
#endif
-
// #define QT_HMI
#ifdef __cplusplus
int main(int argc, char **argv) {
::testing::InitGoogleMock(&argc, argv);
- #ifdef TESTS_WITH_HMI
- profile::Profile::instance()->config_file_name("smartDeviceLink.ini");
- log4cxx::PropertyConfigurator::configure("log4cxx.properties");
- test::AdminAppTest app;
+ profile::Profile::instance()->config_file_name("log4cxx.properties");
+ log4cxx::PropertyConfigurator::configure("log4cxx.properties");
+
+
+#ifdef TESTS_WITH_HMI
+ test::AdminAppTest app;
- app.Run();
- sleep(5);
- #endif
+ app.Run();
+ sleep(5);
+#endif
int result = RUN_ALL_TESTS();
- #ifdef __cplusplus
- __gcov_flush();
- #endif
+#ifdef __cplusplus
+ __gcov_flush();
+#endif
sleep(2);
return result;
}
-