summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi
diff options
context:
space:
mode:
authorOleksandr Lohvinenko (GitHub) <OLohvinenko@luxoft.com>2018-05-25 19:29:45 +0300
committerIra Lytvynenko (GitHub) <ILytvynenko@luxoft.com>2018-06-26 12:01:47 +0300
commit9e86dafadf845bcfcbf8fabf2c928bc357d01431 (patch)
tree9359ca627b168ef2e051a0e965d18efda4d7f120 /src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi
parent0ad2d550bd3d3a0a6d2f7be5d4de6ab53c7190d4 (diff)
downloadsdl_core-9e86dafadf845bcfcbf8fabf2c928bc357d01431.tar.gz
Migrated unit tests.
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc35
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc16
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc12
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc153
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_is_ready_request_test.cc169
5 files changed, 3 insertions, 382 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
index 62e9243ec2..b5a33784b8 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/dummy_hmi_commands_test.cc
@@ -154,25 +154,10 @@
#include "hmi/tts_get_capabilities_response.h"
#include "hmi/vr_perform_interaction_request.h"
#include "hmi/vr_perform_interaction_response.h"
-#include "hmi/vi_is_ready_request.h"
-#include "hmi/vi_is_ready_response.h"
-#include "hmi/vi_read_did_request.h"
-#include "hmi/vi_read_did_response.h"
#include "hmi/sdl_activate_app_request.h"
#include "hmi/sdl_activate_app_response.h"
#include "hmi/on_app_permission_changed_notification.h"
#include "hmi/on_event_changed_notification.h"
-#include "hmi/vi_get_vehicle_data_request.h"
-#include "hmi/vi_get_vehicle_data_response.h"
-#include "hmi/on_vi_vehicle_data_notification.h"
-#include "hmi/vi_subscribe_vehicle_data_request.h"
-#include "hmi/vi_subscribe_vehicle_data_response.h"
-#include "hmi/vi_unsubscribe_vehicle_data_request.h"
-#include "hmi/vi_unsubscribe_vehicle_data_response.h"
-#include "hmi/vi_get_dtcs_request.h"
-#include "hmi/vi_get_dtcs_response.h"
-#include "hmi/vi_diagnostic_message_request.h"
-#include "hmi/vi_diagnostic_message_response.h"
#include "hmi/vi_get_vehicle_type_request.h"
#include "hmi/vi_get_vehicle_type_response.h"
#include "hmi/navi_is_ready_request.h"
@@ -211,7 +196,6 @@
#include "hmi/on_button_event_notification.h"
#include "hmi/on_button_press_notification.h"
#include "hmi/on_button_subscription_notification.h"
-#include "hmi/on_vi_vehicle_data_notification.h"
#include "hmi/on_ui_keyboard_input_notification.h"
#include "hmi/on_ui_touch_event_notification.h"
#include "hmi/on_ui_reset_timeout_notification.h"
@@ -447,19 +431,9 @@ typedef Types<commands::UIChangeRegistrationRequest,
commands::ClosePopupResponse,
commands::ClosePopupRequest,
commands::UIIsReadyResponse,
- commands::UIIsReadyRequest,
- commands::VIIsReadyResponse> HMICommandsListSecond;
+ commands::UIIsReadyRequest> HMICommandsListSecond;
-typedef Types<commands::VIIsReadyRequest,
- commands::VIReadDIDResponse,
- commands::VIReadDIDRequest,
- commands::VIGetVehicleDataResponse,
- commands::VIGetVehicleDataRequest,
- commands::VIGetDTCsResponse,
- commands::VIGetDTCsRequest,
- commands::VIDiagnosticMessageResponse,
- commands::VIDiagnosticMessageRequest,
- commands::VIGetVehicleTypeResponse,
+typedef Types<commands::VIGetVehicleTypeResponse,
commands::VIGetVehicleTypeRequest,
commands::NaviIsReadyResponse,
commands::NaviIsReadyRequest,
@@ -502,11 +476,6 @@ typedef Types<commands::VIIsReadyRequest,
typedef Types<commands::hmi::OnButtonEventNotification,
commands::hmi::OnButtonPressNotification,
commands::hmi::OnButtonSubscriptionNotification,
- commands::VISubscribeVehicleDataResponse,
- commands::VISubscribeVehicleDataRequest,
- commands::VIUnsubscribeVehicleDataResponse,
- commands::VIUnsubscribeVehicleDataRequest,
- commands::OnVIVehicleDataNotification,
commands::OnNaviTBTClientStateNotification,
commands::hmi::OnUIKeyBoardInputNotification,
commands::hmi::OnUITouchEventNotification,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc
index 5929d8acb1..b313fc2363 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_requests_to_hmi_test.cc
@@ -60,9 +60,6 @@
#include "sdl_rpc_plugin/commands/hmi/ui_set_global_properties_request.h"
#include "application_manager/commands/request_to_hmi.h"
#include "sdl_rpc_plugin/commands/hmi/vi_get_vehicle_type_request.h"
-#include "sdl_rpc_plugin/commands/hmi/vi_is_ready_request.h"
-#include "sdl_rpc_plugin/commands/hmi/vi_read_did_request.h"
-#include "sdl_rpc_plugin/commands/hmi/vi_subscribe_vehicle_data_request.h"
#include "sdl_rpc_plugin/commands/hmi/dial_number_request.h"
#include "sdl_rpc_plugin/commands/hmi/tts_is_ready_request.h"
#include "sdl_rpc_plugin/commands/hmi/tts_set_global_properties_request.h"
@@ -86,13 +83,9 @@
#include "sdl_rpc_plugin/commands/hmi/ui_is_ready_request.h"
#include "sdl_rpc_plugin/commands/hmi/ui_perform_audio_pass_thru_request.h"
#include "sdl_rpc_plugin/commands/hmi/ui_perform_interaction_request.h"
-#include "sdl_rpc_plugin/commands/hmi/vi_diagnostic_message_request.h"
-#include "sdl_rpc_plugin/commands/hmi/vi_get_dtcs_request.h"
-#include "sdl_rpc_plugin/commands/hmi/vi_get_vehicle_data_request.h"
#include "sdl_rpc_plugin/commands/hmi/ui_set_media_clock_timer_request.h"
#include "sdl_rpc_plugin/commands/hmi/ui_show_request.h"
#include "sdl_rpc_plugin/commands/hmi/ui_slider_request.h"
-#include "sdl_rpc_plugin/commands/hmi/vi_unsubscribe_vehicle_data_request.h"
#include "sdl_rpc_plugin/commands/hmi/vr_add_command_request.h"
#include "sdl_rpc_plugin/commands/hmi/vr_change_registration_request.h"
#include "sdl_rpc_plugin/commands/hmi/vr_delete_command_request.h"
@@ -172,8 +165,6 @@ class RequestToHMICommandsTest3
};
typedef Types<sdl_rpc_plugin::commands::VIGetVehicleTypeRequest,
- sdl_rpc_plugin::commands::VIReadDIDRequest,
- sdl_rpc_plugin::commands::VISubscribeVehicleDataRequest,
sdl_rpc_plugin::commands::hmi::DialNumberRequest,
sdl_rpc_plugin::commands::ClosePopupRequest,
sdl_rpc_plugin::commands::TTSSetGlobalPropertiesRequest,
@@ -192,12 +183,8 @@ typedef Types<sdl_rpc_plugin::commands::VIGetVehicleTypeRequest,
sdl_rpc_plugin::commands::UIGetSupportedLanguagesRequest,
sdl_rpc_plugin::commands::UIPerformAudioPassThruRequest,
sdl_rpc_plugin::commands::UIPerformInteractionRequest,
- sdl_rpc_plugin::commands::VIDiagnosticMessageRequest,
- sdl_rpc_plugin::commands::VIGetDTCsRequest,
- sdl_rpc_plugin::commands::VIGetVehicleDataRequest,
sdl_rpc_plugin::commands::UISetMediaClockTimerRequest,
sdl_rpc_plugin::commands::UIShowRequest,
- sdl_rpc_plugin::commands::VIUnsubscribeVehicleDataRequest,
sdl_rpc_plugin::commands::VRAddCommandRequest,
sdl_rpc_plugin::commands::VRChangeRegistrationRequest,
sdl_rpc_plugin::commands::VRDeleteCommandRequest,
@@ -238,8 +225,7 @@ typedef Types<sdl_rpc_plugin::commands::UIScrollableMessageRequest,
sdl_rpc_plugin::commands::hmi::DialNumberRequest>
RequestCommandsList2;
-typedef Types<sdl_rpc_plugin::commands::VIIsReadyRequest,
- sdl_rpc_plugin::commands::TTSIsReadyRequest,
+typedef Types<sdl_rpc_plugin::commands::TTSIsReadyRequest,
sdl_rpc_plugin::commands::UIIsReadyRequest,
sdl_rpc_plugin::commands::NaviIsReadyRequest,
sdl_rpc_plugin::commands::VRIsReadyRequest> RequestCommandsList3;
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc
index 1f89e4aefa..a7c07f8b1e 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/simple_response_from_hmi_test.cc
@@ -59,10 +59,7 @@
#include "application_manager/mock_event_dispatcher.h"
#include "application_manager/mock_hmi_capabilities.h"
#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "hmi/vi_read_did_response.h"
-#include "hmi/vi_subscribe_vehicle_data_response.h"
#include "hmi/vi_get_vehicle_type_response.h"
-#include "hmi/vi_is_ready_response.h"
#include "hmi/dial_number_response.h"
#include "hmi/close_popup_response.h"
#include "hmi/tts_set_global_properties_response.h"
@@ -78,12 +75,9 @@
#include "hmi/ui_end_audio_pass_thru_response.h"
#include "hmi/ui_perform_audio_pass_thru_response.h"
#include "hmi/ui_perform_interaction_response.h"
-#include "hmi/vi_diagnostic_message_response.h"
-#include "hmi/vi_get_dtcs_response.h"
#include "hmi/ui_set_media_clock_timer_response.h"
#include "hmi/ui_show_response.h"
#include "hmi/ui_slider_response.h"
-#include "hmi/vi_unsubscribe_vehicle_data_response.h"
#include "hmi/vr_add_command_response.h"
#include "hmi/vr_change_registration_response.h"
#include "hmi/vr_delete_command_response.h"
@@ -183,16 +177,10 @@ typedef Types<
hmi_apis::FunctionID::UI_DeleteSubMenu>,
CommandData<sdl_rpc_plugin::commands::UIEndAudioPassThruResponse,
hmi_apis::FunctionID::UI_EndAudioPassThru>,
- CommandData<sdl_rpc_plugin::commands::VIDiagnosticMessageResponse,
- hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage>,
- CommandData<sdl_rpc_plugin::commands::VIGetDTCsResponse,
- hmi_apis::FunctionID::VehicleInfo_GetDTCs>,
CommandData<sdl_rpc_plugin::commands::UISetMediaClockTimerResponse,
hmi_apis::FunctionID::UI_SetMediaClockTimer>,
CommandData<sdl_rpc_plugin::commands::UIShowResponse,
hmi_apis::FunctionID::UI_Show>,
- CommandData<sdl_rpc_plugin::commands::VIUnsubscribeVehicleDataResponse,
- hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData>,
CommandData<sdl_rpc_plugin::commands::VRAddCommandResponse,
hmi_apis::FunctionID::VR_AddCommand>,
CommandData<sdl_rpc_plugin::commands::VRChangeRegistrationResponse,
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc
deleted file mode 100644
index 3c52b348c3..0000000000
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_get_vehicle_data_response_test.cc
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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 <stdint.h>
-#include <string>
-#include <vector>
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "smart_objects/smart_object.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/commands/commands_test.h"
-#include "application_manager/application.h"
-#include "application_manager/message_helper.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/event_engine/event.h"
-#include "application_manager/mock_event_dispatcher.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "hmi/vi_get_vehicle_data_response.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace hmi_commands_test {
-namespace vi_get_vehicle_data_response {
-
-using ::testing::_;
-using ::testing::Return;
-using ::testing::ReturnRef;
-namespace am = ::application_manager;
-namespace strings = ::application_manager::strings;
-namespace hmi_response = am::hmi_response;
-using am::commands::MessageSharedPtr;
-using sdl_rpc_plugin::commands::VIGetVehicleDataResponse;
-using am::event_engine::Event;
-using test::components::event_engine_test::MockEventDispatcher;
-
-typedef SharedPtr<VIGetVehicleDataResponse> VIGetVehicleDataResponsePtr;
-
-namespace {
-const uint32_t kConnectionKey = 2u;
-const uint32_t kCorrelationId = 1u;
-const std::string kStrNumber = "123";
-} // namespace
-
-class VIGetVehicleDataResponseTest
- : public CommandsTest<CommandsTestMocks::kIsNice> {};
-
-TEST_F(VIGetVehicleDataResponseTest, RUN_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[strings::msg_params][strings::number] = kStrNumber;
- (*command_msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*command_msg)[strings::params][strings::message_type] =
- hmi_apis::messageType::response;
-
- VIGetVehicleDataResponsePtr command(
- CreateCommand<VIGetVehicleDataResponse>(command_msg));
-
- am::event_engine::Event event(
- hmi_apis::FunctionID::VehicleInfo_GetVehicleData);
- event.set_smart_object(*command_msg);
-
- EXPECT_CALL(mock_policy_handler_, OnVehicleDataUpdated(*command_msg));
-
- MockEventDispatcher mock_event_dispatcher;
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher));
- EXPECT_CALL(mock_event_dispatcher, raise_event(_));
-
- command->Run();
-}
-
-TEST_F(VIGetVehicleDataResponseTest, ErrorResponse_SUCCESS) {
- MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
- (*command_msg)[strings::msg_params][strings::number] = kStrNumber;
- (*command_msg)[strings::params][strings::connection_key] = kConnectionKey;
- (*command_msg)[strings::params][strings::message_type] =
- hmi_apis::messageType::error_response;
- (*command_msg)[strings::params][strings::data][strings::slider_position] = 1;
- (*command_msg)[strings::params][hmi_response::code] =
- hmi_apis::Common_Result::SUCCESS;
- (*command_msg)[strings::params][strings::correlation_id] = kCorrelationId;
- (*command_msg)[am::strings::params][am::strings::error_msg] = "test_error";
- (*command_msg)[am::strings::params][am::strings::protocol_type] =
- am::commands::CommandImpl::hmi_protocol_type_;
- (*command_msg)[strings::params][strings::protocol_version] =
- am::commands::CommandImpl::protocol_version_;
-
- smart_objects::SmartObject result(smart_objects::SmartType_Map);
- result[strings::msg_params] = (*command_msg)[strings::params][strings::data];
- result[strings::params][hmi_response::code] =
- (*command_msg)[strings::params][hmi_response::code];
- result[strings::params][strings::correlation_id] =
- (*command_msg)[strings::params][strings::correlation_id];
- result[strings::params][strings::error_msg] =
- (*command_msg)[strings::params][strings::error_msg];
- result[strings::params][strings::message_type] =
- (*command_msg)[strings::params][strings::message_type];
- result[strings::params][strings::protocol_type] =
- (*command_msg)[strings::params][strings::protocol_type];
- result[strings::params][strings::protocol_version] =
- (*command_msg)[strings::params][strings::protocol_version];
-
- VIGetVehicleDataResponsePtr command(
- CreateCommand<VIGetVehicleDataResponse>(command_msg));
-
- am::event_engine::Event event(
- hmi_apis::FunctionID::VehicleInfo_GetVehicleData);
- event.set_smart_object(result);
-
- MockEventDispatcher mock_event_dispatcher;
- EXPECT_CALL(app_mngr_, event_dispatcher())
- .WillOnce(ReturnRef(mock_event_dispatcher));
- EXPECT_CALL(mock_event_dispatcher, raise_event(_));
-
- command->Run();
-}
-
-} // namespace vi_get_vehicle_data_response
-} // namespace hmi_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_is_ready_request_test.cc
deleted file mode 100644
index f09ff72856..0000000000
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/vi_is_ready_request_test.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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 "hmi/vi_is_ready_request.h"
-
-#include "gtest/gtest.h"
-#include "utils/shared_ptr.h"
-#include "smart_objects/smart_object.h"
-#include "application_manager/smart_object_keys.h"
-#include "application_manager/commands/command_request_test.h"
-#include "application_manager/mock_application_manager.h"
-#include "application_manager/hmi_interfaces.h"
-#include "application_manager/mock_hmi_interface.h"
-#include "application_manager/mock_hmi_capabilities.h"
-#include "application_manager/policies/mock_policy_handler_interface.h"
-#include "application_manager/mock_message_helper.h"
-#include "application_manager/event_engine/event.h"
-
-namespace test {
-namespace components {
-namespace commands_test {
-namespace hmi_commands_test {
-namespace vi_is_ready_request {
-
-using ::testing::_;
-using ::testing::ReturnRef;
-using ::testing::Return;
-namespace am = ::application_manager;
-using am::commands::MessageSharedPtr;
-using sdl_rpc_plugin::commands::VIIsReadyRequest;
-using am::event_engine::Event;
-
-typedef SharedPtr<VIIsReadyRequest> VIIsReadyRequestPtr;
-
-class VIIsReadyRequestTest
- : public CommandRequestTest<CommandsTestMocks::kIsNice> {
- public:
- VIIsReadyRequestTest() : command_(CreateCommand<VIIsReadyRequest>()) {}
-
- void SetUpExpectations(bool is_vi_cooperating_available,
- bool is_send_message_to_hmi,
- bool is_message_contain_param,
- am::HmiInterfaces::InterfaceState state) {
- EXPECT_CALL(mock_hmi_capabilities_,
- set_is_ivi_cooperating(is_vi_cooperating_available));
-
- if (is_message_contain_param) {
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillRepeatedly(ReturnRef(mock_hmi_interfaces_));
- EXPECT_CALL(mock_hmi_interfaces_,
- SetInterfaceState(
- am::HmiInterfaces::HMI_INTERFACE_VehicleInfo, state));
- } else {
- EXPECT_CALL(app_mngr_, hmi_interfaces())
- .WillOnce(ReturnRef(mock_hmi_interfaces_));
- EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0);
- }
- EXPECT_CALL(mock_policy_handler_, OnVIIsReady());
-
- EXPECT_CALL(mock_hmi_interfaces_,
- GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VehicleInfo))
- .WillOnce(Return(state));
-
- if (is_send_message_to_hmi) {
- ExpectSendMessagesToHMI();
- }
- }
-
- void ExpectSendMessagesToHMI() {
- smart_objects::SmartObjectSPtr ivi_type;
- EXPECT_CALL(
- mock_message_helper_,
- CreateModuleInfoSO(hmi_apis::FunctionID::VehicleInfo_GetVehicleType, _))
- .WillOnce(Return(ivi_type));
- EXPECT_CALL(mock_rpc_service_, ManageHMICommand(ivi_type));
- }
-
- void PrepareEvent(bool is_message_contain_param,
- Event& event,
- bool is_vi_cooperating_available = false) {
- MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map);
- if (is_message_contain_param) {
- (*msg)[am::strings::msg_params][am::strings::available] =
- is_vi_cooperating_available;
- }
- event.set_smart_object(*msg);
- }
-
- VIIsReadyRequestPtr command_;
-};
-
-TEST_F(VIIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) {
- const bool is_vi_cooperating_available = false;
- const bool is_send_message_to_hmi = true;
- const bool is_message_contain_param = false;
- Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
- PrepareEvent(is_message_contain_param, event);
- SetUpExpectations(is_vi_cooperating_available,
- is_send_message_to_hmi,
- is_message_contain_param,
- am::HmiInterfaces::STATE_NOT_RESPONSE);
- command_->on_event(event);
-}
-
-TEST_F(VIIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) {
- const bool is_vi_cooperating_available = false;
- const bool is_send_message_to_hmi = false;
- const bool is_message_contain_param = true;
- Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
- PrepareEvent(is_message_contain_param, event);
- SetUpExpectations(is_vi_cooperating_available,
- is_send_message_to_hmi,
- is_message_contain_param,
- am::HmiInterfaces::STATE_NOT_AVAILABLE);
- command_->on_event(event);
-}
-
-TEST_F(VIIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) {
- const bool is_vi_cooperating_available = true;
- const bool is_send_message_to_hmi = true;
- const bool is_message_contain_param = true;
- Event event(hmi_apis::FunctionID::VehicleInfo_IsReady);
- PrepareEvent(is_message_contain_param, event, is_vi_cooperating_available);
- SetUpExpectations(is_vi_cooperating_available,
- is_send_message_to_hmi,
- is_message_contain_param,
- am::HmiInterfaces::STATE_AVAILABLE);
- command_->on_event(event);
-}
-
-TEST_F(VIIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) {
- ExpectSendMessagesToHMI();
- command_->onTimeOut();
-}
-
-} // namespace vi_is_ready_request
-} // namespace hmi_commands_test
-} // namespace commands_test
-} // namespace components
-} // namespace test