diff options
author | Ira Lytvynenko <ILytvynenko@luxoft.com> | 2018-02-18 18:32:17 +0200 |
---|---|---|
committer | Ira Lytvynenko (GitHub) <ILytvynenko@luxoft.com> | 2018-06-26 12:01:46 +0300 |
commit | 4453774c786f847c3a533a73f58439dc8ca64a55 (patch) | |
tree | 6fbbbeb58529d6d001bb4d5d9d2b81fe785782b2 /src/components/application_manager/rpc_plugins | |
parent | 89c1db3101b3f6f6f324b1c9f4a4abaa4a281398 (diff) | |
download | sdl_core-4453774c786f847c3a533a73f58439dc8ca64a55.tar.gz |
UTS for ButtonPress
Fix UT of the rc commands
-Get interior vehicle data request test
Fix UTs
Fixed application_manager_mock_hmi_test (SEGFAULT)
Added mock_rpc_plugin.h & mock_rpc_plugin_manager.h
Changed application_manager_impl.h, application_manager.h &
mock_application_manager.h
Fixed application_manager_impl.cc, rpc_plugin_manager.h
application_manager_impl_mock_hmi_test.cc
Diffstat (limited to 'src/components/application_manager/rpc_plugins')
9 files changed, 89 insertions, 78 deletions
diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index d67f8973e4..69a05c430c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -29,6 +29,8 @@ RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification( policy_handle) , resource_allocation_manager_(resource_allocation_manager) {} +RCOnRemoteControlSettingsNotification::~RCOnRemoteControlSettingsNotification() {} + hmi_apis::Common_RCAccessMode::eType AccessModeFromString( const std::string& access_mode) { std::map<std::string, hmi_apis::Common_RCAccessMode::eType>::const_iterator @@ -118,8 +120,5 @@ void RCOnRemoteControlSettingsNotification::Run() { } } -RCOnRemoteControlSettingsNotification:: - ~RCOnRemoteControlSettingsNotification() {} - } // namespace commands } // namespace rc_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc index 4cfe955bbf..88e4ebaa3c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/button_press_request.cc @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2018, 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 "rc_rpc_plugin/commands/mobile/button_press_request.h" #include "rc_rpc_plugin/rc_module_constants.h" #include "smart_objects/enum_schema_item.h" @@ -166,7 +198,7 @@ void ButtonPressRequest::Execute() { } const smart_objects::SmartObject* rc_capabilities = - application_manager_.hmi_capabilities().rc_capability(); + hmi_capabilities_.rc_capability(); const bool button_name_matches_module_type = CheckButtonName(module_type, button_name, rc_capabilities); const bool button_id_exist_in_caps = diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc index 7fa5c43279..edf6ca9d55 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/get_interior_vehicle_data_request.cc @@ -48,7 +48,7 @@ void GetInteriorVehicleDataRequest::Execute() { LOG4CXX_AUTO_TRACE(logger_); const smart_objects::SmartObject* rc_capabilities = - application_manager_.hmi_capabilities().rc_capability(); + hmi_capabilities_.rc_capability(); const std::string module_type = ModuleType(); if (rc_capabilities && !CheckIfModuleTypeExistInCapabilities(*rc_capabilities, module_type)) { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 081289ee00..deff3b786c 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -159,7 +159,7 @@ void SetInteriorVehicleDataRequest::Execute() { if (module_type_and_data_match) { const smart_objects::SmartObject* rc_capabilities = - application_manager_.hmi_capabilities().rc_capability(); + hmi_capabilities_.rc_capability(); if (rc_capabilities && !CheckIfModuleDataExistInCapabilities(*rc_capabilities, module_data)) { LOG4CXX_WARN(logger_, "Accessing not supported module data"); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc index 62c1cd4005..a6c1dd02b3 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc @@ -100,8 +100,7 @@ bool RCCommandRequest::CheckDriverConsent() { rc_rpc_plugin::TypeAccess RCCommandRequest::CheckModule( const std::string& module_type, application_manager::ApplicationSharedPtr app) { - return application_manager_.GetPolicyHandler().CheckModule( - app->policy_app_id(), module_type) + return policy_handler_.CheckModule(app->policy_app_id(), module_type) ? rc_rpc_plugin::TypeAccess::kAllowed : rc_rpc_plugin::TypeAccess::kDisallowed; } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt index d50ee4f0c5..7c5455fdec 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/CMakeLists.txt @@ -1,12 +1,47 @@ +# 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(${CMAKE_SOURCE_DIR}/tools/cmake/helpers/sources.cmake) + include_directories ( ${GMOCK_INCLUDE_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR}/include ${COMPONENTS_DIR}/application_manager/test/include + ${COMPONENTS_DIR}/application_manager/rpc_plugins/rc_rpc_plugin/test/include/ ${COMPONENTS_DIR}/include/test/application_manager/ + ${COMPONENTS_DIR}/rc_rpc_plugin/test/include ) set (RC_TEST_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc +${CMAKE_CURRENT_SOURCE_DIR}/resource_allocation_manager_impl_test.cc +) + +set(RC_COMMANDS_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/commands) + +file(GLOB SOURCES + ${COMPONENTS_DIR}/application_manager/test/mock_message_helper.cc + ${RC_COMMANDS_TEST_DIR}/* ) set(LIBRARIES @@ -29,6 +64,6 @@ if(ENABLE_LOG) list(APPEND LIBRARIES expat -L${EXPAT_LIBS_DIRECTORY}) endif() - -create_test("resourse_allocaiton_manager_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") +create_test("rc_commands_test" "${SOURCES}" "${LIBRARIES}" ) +create_test("resourse_allocation_manager_test" "${RC_TEST_SOURCES}" "${LIBRARIES}") diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_remote_control_plugin.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_remote_control_plugin.h deleted file mode 100644 index a8143f448c..0000000000 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_remote_control_plugin.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_REMOTE_CONTROL_PLUGIN_H_ -#define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_REMOTE_CONTROL_PLUGIN_H_ - -#include <stdint.h> -#include "remote_control/remote_plugin_interface.h" -#include "remote_control/resource_allocation_manager.h" -#include "application_manager/message.h" -#include "mock_application.h" - -namespace test { -namespace components { -namespace remote_control_test { - -class RCAppExtension; -typedef utils::SharedPtr<RCAppExtension> RCAppExtensionPtr; - -class MockRemotePluginInterface : public remote_control::RemotePluginInterface { - public: - MOCK_CONST_METHOD0(GetPluginInfo, functional_modules::PluginInfo()); - MOCK_METHOD1( - ProcessMessage, - functional_modules::ProcessResult(application_manager::MessagePtr msg)); - MOCK_METHOD1( - ProcessHMIMessage, - functional_modules::ProcessResult(application_manager::MessagePtr msg)); - MOCK_METHOD1(SendResponseToMobile, void(application_manager::MessagePtr msg)); - MOCK_METHOD1(SendTimeoutResponseToMobile, - void(application_manager::MessagePtr msg)); - MOCK_METHOD1(RemoveAppExtension, void(uint32_t app_id)); - MOCK_METHOD1(IsAppForPlugin, - bool(application_manager::ApplicationSharedPtr app)); - MOCK_METHOD2(OnAppHMILevelChanged, - void(application_manager::ApplicationSharedPtr app, - mobile_apis::HMILevel::eType old_level)); - MOCK_METHOD1(OnUnregisterApplication, void(const uint32_t app_id)); - MOCK_METHOD1(SendHmiStatusNotification, - void(application_manager::ApplicationSharedPtr app)); - MOCK_METHOD0(event_dispatcher, RCPluginEventDispatcher&()); - MOCK_METHOD0(RemoveAppExtensions, void()); - MOCK_METHOD0(service, application_manager::ServicePtr()); - MOCK_CONST_METHOD0(GetModuleID, functional_modules::ModuleID()); - MOCK_METHOD0(resource_allocation_manager, - remote_control::ResourceAllocationManager&()); - MOCK_METHOD2(OnApplicationEvent, - void(functional_modules::ApplicationEvent event, - application_manager::ApplicationSharedPtr application)); - MOCK_METHOD1(OnPolicyEvent, void(functional_modules::PolicyEvent event)); -}; - -} // namespace remote_control_test -} // namespace components -} // namespace test - -#endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_REMOTE_CONTROL_PLUGIN_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h index 6337d8a32a..eae4effc1d 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/include/rc_rpc_plugin/mock/mock_resource_allocation_manager.h @@ -2,39 +2,37 @@ #define SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ #include "gmock/gmock.h" -#include "remote_control/resource_allocation_manager.h" +#include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/resource_allocation_manager.h" -namespace test { -namespace components { -namespace remote_control_test { +namespace rc_rpc_plugin_test{ class MockResourceAllocationManager - : public remote_control::ResourceAllocationManager { + : public rc_rpc_plugin::ResourceAllocationManager { public: MOCK_METHOD2(AcquireResource, - remote_control::AcquireResult::eType( - const std::string& module_type, const uint32_t app_id)); + rc_rpc_plugin::AcquireResult::eType + (const std::string& module_type, const uint32_t app_id)); MOCK_METHOD2(ForceAcquireResource, void(const std::string& module_type, const uint32_t app_id)); MOCK_METHOD2(OnDriverDisallowed, void(const std::string& module_type, const uint32_t app_id)); MOCK_METHOD2(OnApplicationEvent, - void(functional_modules::ApplicationEvent event, + void(application_manager::plugin_manager::ApplicationEvent event, application_manager::ApplicationSharedPtr application)); - MOCK_METHOD1(OnPolicyEvent, void(functional_modules::PolicyEvent event)); + MOCK_METHOD1(OnPolicyEvent, void(application_manager::plugin_manager::PolicyEvent event)); MOCK_METHOD1(SetAccessMode, void(const hmi_apis::Common_RCAccessMode::eType access_mode)); MOCK_CONST_METHOD0(GetAccessMode, hmi_apis::Common_RCAccessMode::eType()); MOCK_METHOD3(SetResourceState, void(const std::string& module_type, const uint32_t app_id, - const remote_control::ResourceState::eType state)); + const rc_rpc_plugin::ResourceState::eType state)); MOCK_CONST_METHOD1(IsResourceFree, bool(const std::string& module_type)); + MOCK_METHOD1(GetApplicationExtention, + rc_rpc_plugin::RCAppExtensionPtr(application_manager::ApplicationSharedPtr application)); MOCK_METHOD0(ResetAllAllocations, void()); }; -} // namespace remote_control_test -} // namespace components -} // namespace test +} // namespace rc_rpc_plugin_test #endif // SRC_COMPONENTS_REMOTE_CONTROL_TEST_INCLUDE_MOCK_RESOURCE_ALLOCATION_MANAGER_H_ diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc index 664dce1b1c..5bd891d3a2 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/resource_allocation_manager_impl_test.cc @@ -411,6 +411,7 @@ TEST_F(RAManagerTest, AppsDisallowed_ReleaseAllResources) { ra_manager.AcquireResource(kModuleType1, kAppId2)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, ra_manager.AcquireResource(kModuleType2, kAppId2)); + Mock::VerifyAndClearExpectations(&mock_app_mngr_); } TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { @@ -467,6 +468,7 @@ TEST_F(RAManagerTest, AppGotRevokedModulesWithPTU_ReleaseRevokedResource) { ra_manager.AcquireResource(kModuleType1, kAppId2)); EXPECT_EQ(rc_rpc_plugin::AcquireResult::ALLOWED, ra_manager.AcquireResource(kModuleType2, kAppId2)); + Mock::VerifyAndClearExpectations(&mock_app_mngr_); } TEST_F(RAManagerTest, GetAccessMode_ExpectedSameAsHadSet) { |