diff options
Diffstat (limited to 'src/components/application_manager/test/commands/hmi')
55 files changed, 0 insertions, 10200 deletions
diff --git a/src/components/application_manager/test/commands/hmi/activate_app_request_test.cc b/src/components/application_manager/test/commands/hmi/activate_app_request_test.cc deleted file mode 100644 index 7f7911a01d..0000000000 --- a/src/components/application_manager/test/commands/hmi/activate_app_request_test.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/activate_app_request.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/commands/command_impl.h" -#include "commands/commands_test.h" -#include "application_manager/mock_application.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace activate_app_request { - -using ::testing::_; -using ::utils::SharedPtr; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::MessageSharedPtr; -using am::commands::ActivateAppRequest; -using am::commands::CommandImpl; - -using ::test::components::application_manager_test::MockApplication; - -typedef SharedPtr<MockApplication> MockAppPtr; -typedef ::utils::SharedPtr<ActivateAppRequest> ActivateAppRequestPtr; - -MATCHER_P(CheckMessage, level, "") { - return level == - static_cast<mobile_apis::HMILevel::eType>( - (*arg)[strings::msg_params][strings::activate_app_hmi_level] - .asInt()); -} - -namespace { -const uint32_t kAppId = 1u; -const uint32_t kCorrelationId = 2u; -} // namespace - -class ActivateAppRequestTest : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr CreateMsgParams() { - MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params[strings::app_id] = kAppId; - msg_params[strings::correlation_id] = kCorrelationId; - (*msg)[strings::msg_params] = msg_params; - (*msg)[strings::params][strings::app_id] = kAppId; - (*msg)[strings::params][strings::correlation_id] = kCorrelationId; - (*msg)[strings::app_id] = kAppId; - return msg; - } -}; - -TEST_F(ActivateAppRequestTest, Run_SUCCESS) { - MessageSharedPtr msg = CreateMsgParams(); - MockAppPtr app = CreateMockApp(); - - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app)); - - ON_CALL(*app, hmi_app_id()).WillByDefault(Return(kAppId)); - -// TODO(OKozlov) Investigate and fix issue with using log -#ifdef ENABLE_LOG - (*msg)[strings::msg_params][strings::activate_app_hmi_level] = - mobile_apis::HMILevel::HMI_FULL; -#endif - ActivateAppRequestPtr command(CreateCommand<ActivateAppRequest>(msg)); - - EXPECT_CALL(app_mngr_, set_application_id(kCorrelationId, kAppId)); -#ifdef ENABLE_LOG - EXPECT_CALL(app_mngr_, - SendMessageToHMI(CheckMessage(mobile_apis::HMILevel::HMI_FULL))); -#else - EXPECT_CALL(app_mngr_, - SendMessageToHMI(msg))); -#endif - command->Run(); - -#ifndef ENABLE_LOG - EXPECT_EQ(CommandImpl::hmi_protocol_type_, - (*msg)[strings::params][strings::protocol_type].asInt()); - EXPECT_EQ(CommandImpl::protocol_version_, - (*msg)[strings::params][strings::protocol_version].asInt()); -#endif -} - -} // namespace activate_app_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/add_statistics_info_notification_test.cc b/src/components/application_manager/test/commands/hmi/add_statistics_info_notification_test.cc deleted file mode 100644 index 88efc61816..0000000000 --- a/src/components/application_manager/test/commands/hmi/add_statistics_info_notification_test.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/add_statistics_info_notification.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/mock_application.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/policies/mock_policy_handler_interface.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace add_statistics_info_notification { - -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_notification = ::application_manager::hmi_notification; -using am::commands::MessageSharedPtr; -using am::commands::AddStatisticsInfoNotification; -using am::commands::CommandImpl; -using policy::PolicyHandler; -using policy_test::MockPolicyHandlerInterface; -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; - -typedef ::utils::SharedPtr<AddStatisticsInfoNotification> NotificationPtr; - -namespace { -const uint32_t kStatisticType = 1u; -} // namespace - -class AddStatisticsInfoNotificationTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - protected: - MockPolicyHandlerInterface policy_handler_; -}; - -TEST_F(AddStatisticsInfoNotificationTest, Run_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[am::strings::msg_params][am::hmi_notification::statistic_type] = - kStatisticType; - NotificationPtr command(CreateCommand<AddStatisticsInfoNotification>(msg)); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler_)); - EXPECT_CALL(policy_handler_, AddStatisticsInfo(kStatisticType)); - - command->Run(); -} - -} // namespace add_statistics_info_notification -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/allow_all_apps_response_test.cc b/src/components/application_manager/test/commands/hmi/allow_all_apps_response_test.cc deleted file mode 100644 index 60eced4830..0000000000 --- a/src/components/application_manager/test/commands/hmi/allow_all_apps_response_test.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/allow_all_apps_response.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/mock_application.h" -#include "application_manager/commands/command_impl.h" -#include "commands/commands_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace allow_all_apps_response { - -using application_manager::commands::MessageSharedPtr; -using application_manager::commands::AllowAllAppsResponse; - -namespace strings = ::application_manager::strings; -namespace hmi_response = ::application_manager::hmi_response; - -typedef ::utils::SharedPtr<AllowAllAppsResponse> ResponsePtr; - -namespace { -const bool kResponseIsAllowed = true; -} // - -class AllowAllAppsResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(AllowAllAppsResponseTest, Run_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::allowed] = kResponseIsAllowed; - - ResponsePtr command(CreateCommand<AllowAllAppsResponse>(msg)); - - EXPECT_CALL(app_mngr_, SetAllAppsAllowed(kResponseIsAllowed)); - - command->Run(); -} - -} // namespace allow_all_apps_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/allow_app_response_test.cc b/src/components/application_manager/test/commands/hmi/allow_app_response_test.cc deleted file mode 100644 index 69b4abe39d..0000000000 --- a/src/components/application_manager/test/commands/hmi/allow_app_response_test.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/allow_app_response.h" -#include "utils/shared_ptr.h" -#include "application_manager/mock_application.h" -#include "commands/commands_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace allow_app_response { - -using application_manager::commands::MessageSharedPtr; -using application_manager::commands::AllowAppResponse; -using ::testing::_; -using ::testing::Return; - -namespace strings = ::application_manager::strings; -namespace hmi_response = ::application_manager::hmi_response; - -namespace { -const uint32_t kConnectionKey = 1u; -const bool kIsResponseAllowed = true; -} - -typedef ::utils::SharedPtr<AllowAppResponse> ResponsePtr; - -class AllowAppResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(AllowAppResponseTest, Run_AppCreated_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][hmi_response::allowed] = kIsResponseAllowed; - - ResponsePtr command(CreateCommand<AllowAppResponse>(msg)); - - MockAppPtr mock_app = CreateMockApp(); - EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, set_app_allowed(kIsResponseAllowed)); - - command->Run(); -} - -TEST_F(AllowAppResponseTest, Run_AppNotCreated_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][hmi_response::allowed] = kIsResponseAllowed; - - ResponsePtr command(CreateCommand<AllowAppResponse>(msg)); - - MockAppPtr mock_app; - EXPECT_CALL(app_mngr_, application(kConnectionKey)) - .WillOnce(Return(MockAppPtr())); - - command->Run(); -} - -} // namespace allow_app_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/button_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/button_get_capabilities_response_test.cc deleted file mode 100644 index b2a8f0858a..0000000000 --- a/src/components/application_manager/test/commands/hmi/button_get_capabilities_response_test.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/button_get_capabilities_response.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "commands/commands_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace button_get_capabilities_response { - -using application_manager::commands::MessageSharedPtr; -using application_manager::commands::ButtonGetCapabilitiesResponse; -using ::testing::ReturnRef; -using ::testing::NiceMock; - -namespace strings = ::application_manager::strings; -namespace hmi_response = ::application_manager::hmi_response; - -typedef ::utils::SharedPtr<ButtonGetCapabilitiesResponse> ResponsePtr; - -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -class ButtonGetCapabilitiesResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr CreateMsgParams() { - capabilities_[strings::name] = hmi_apis::Common_ButtonName::OK; - preset_bank_capabilities_ = true; - - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::capabilities] = (capabilities_); - (*msg)[strings::msg_params][hmi_response::preset_bank_capabilities] = - (preset_bank_capabilities_); - - return msg; - } - - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; - SmartObject preset_bank_capabilities_; -}; - -TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeSuccess_SUCCESS) { - MessageSharedPtr msg = CreateMsgParams(); - (*msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - - ResponsePtr command(CreateCommand<ButtonGetCapabilitiesResponse>(msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(mock_hmi_capabilities_, set_button_capabilities(capabilities_)); - EXPECT_CALL(mock_hmi_capabilities_, - set_preset_bank_capabilities(preset_bank_capabilities_)); - - command->Run(); -} - -TEST_F(ButtonGetCapabilitiesResponseTest, Run_CodeAborted_SUCCESS) { - MessageSharedPtr msg = CreateMsgParams(); - (*msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::ABORTED; - - ResponsePtr command(CreateCommand<ButtonGetCapabilitiesResponse>(msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()).Times(0); - EXPECT_CALL(mock_hmi_capabilities_, set_button_capabilities(capabilities_)) - .Times(0); - EXPECT_CALL(mock_hmi_capabilities_, - set_preset_bank_capabilities(preset_bank_capabilities_)).Times(0); - - command->Run(); -} - -} // namespace button_get_capabilities_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/close_popup_response_test.cc b/src/components/application_manager/test/commands/hmi/close_popup_response_test.cc deleted file mode 100644 index b4a6ea272a..0000000000 --- a/src/components/application_manager/test/commands/hmi/close_popup_response_test.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2016, 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 "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.h" -#include "commands/commands_test.h" -#include "application_manager/commands/hmi/response_from_hmi.h" -#include "application_manager/commands/hmi/close_popup_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace close_popup_response { - -using ::utils::SharedPtr; -namespace am = ::application_manager; -using am::commands::ResponseFromHMI; -using am::commands::ClosePopupResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; - -class ClosePopupResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { -}; - -TEST_F(ClosePopupResponseTest, RUN_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - ResponseFromHMIPtr command(CreateCommand<ClosePopupResponse>(command_msg)); - - command->Run(); -} - -} // namespace close_popup_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/dummy_hmi_commands_test.cc b/src/components/application_manager/test/commands/hmi/dummy_hmi_commands_test.cc deleted file mode 100644 index 7c95a4ca2f..0000000000 --- a/src/components/application_manager/test/commands/hmi/dummy_hmi_commands_test.cc +++ /dev/null @@ -1,617 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/command_request_test.h" - -#include <stdint.h> -#include <string> -#include <vector> -#include "gtest/gtest.h" - -#include "application_manager/commands/hmi/allow_all_apps_request.h" -#include "application_manager/commands/hmi/allow_all_apps_response.h" -#include "application_manager/commands/hmi/allow_app_request.h" -#include "application_manager/commands/hmi/allow_app_response.h" -#include "application_manager/commands/hmi/navi_audio_start_stream_request.h" -#include "application_manager/commands/hmi/navi_audio_start_stream_response.h" -#include "application_manager/commands/hmi/navi_audio_stop_stream_request.h" -#include "application_manager/commands/hmi/navi_audio_stop_stream_response.h" -#include "application_manager/commands/hmi/update_device_list_request.h" -#include "application_manager/commands/hmi/update_device_list_response.h" -#include "application_manager/commands/hmi/on_update_device_list.h" -#include "application_manager/commands/hmi/on_start_device_discovery.h" -#include "application_manager/commands/hmi/update_app_list_request.h" -#include "application_manager/commands/hmi/update_app_list_response.h" -#include "application_manager/commands/hmi/on_find_applications.h" -#include "application_manager/commands/hmi/sdl_get_list_of_permissions_request.h" -#include "application_manager/commands/hmi/sdl_get_list_of_permissions_response.h" -#include "application_manager/commands/hmi/sdl_get_user_friendly_message_request.h" -#include "application_manager/commands/hmi/sdl_get_user_friendly_message_response.h" -#include "application_manager/commands/hmi/sdl_get_status_update_request.h" -#include "application_manager/commands/hmi/sdl_get_status_update_response.h" -#include "application_manager/commands/hmi/on_status_update_notification.h" -#include "application_manager/commands/hmi/update_sdl_request.h" -#include "application_manager/commands/hmi/update_sdl_response.h" -#include "application_manager/commands/hmi/activate_app_request.h" -#include "application_manager/commands/hmi/activate_app_response.h" -#include "application_manager/commands/hmi/mixing_audio_supported_request.h" -#include "application_manager/commands/hmi/mixing_audio_supported_response.h" -#include "application_manager/commands/hmi/on_allow_sdl_functionality_notification.h" -#include "application_manager/commands/hmi/on_app_permission_changed_notification.h" -#include "application_manager/commands/hmi/on_app_permission_consent_notification.h" -#include "application_manager/commands/hmi/on_app_activated_notification.h" -#include "application_manager/commands/hmi/on_audio_data_streaming_notification.h" -#include "application_manager/commands/hmi/on_video_data_streaming_notification.h" -#include "application_manager/commands/hmi/on_sdl_consent_needed_notification.h" -#include "application_manager/commands/hmi/on_exit_all_applications_notification.h" -#include "application_manager/commands/hmi/on_exit_application_notification.h" -#include "application_manager/commands/hmi/on_put_file_notification.h" -#include "application_manager/commands/hmi/on_resume_audio_source_notification.h" -#include "application_manager/commands/hmi/on_ignition_cycle_over_notification.h" -#include "application_manager/commands/hmi/on_system_info_changed_notification.h" -#include "application_manager/commands/hmi/get_system_info_request.h" -#include "application_manager/commands/hmi/get_system_info_response.h" -#include "application_manager/commands/hmi/close_popup_request.h" -#include "application_manager/commands/hmi/close_popup_response.h" -#include "application_manager/commands/hmi/button_get_capabilities_request.h" -#include "application_manager/commands/hmi/button_get_capabilities_response.h" -#include "application_manager/commands/hmi/ui_add_command_request.h" -#include "application_manager/commands/hmi/ui_add_command_response.h" -#include "application_manager/commands/hmi/ui_delete_command_request.h" -#include "application_manager/commands/hmi/ui_delete_command_response.h" -#include "application_manager/commands/hmi/ui_add_submenu_request.h" -#include "application_manager/commands/hmi/ui_add_submenu_response.h" -#include "application_manager/commands/hmi/ui_delete_submenu_request.h" -#include "application_manager/commands/hmi/ui_delete_submenu_response.h" -#include "application_manager/commands/hmi/ui_get_supported_languages_request.h" -#include "application_manager/commands/hmi/ui_get_supported_languages_response.h" -#include "application_manager/commands/hmi/ui_get_language_request.h" -#include "application_manager/commands/hmi/ui_get_language_response.h" -#include "application_manager/commands/hmi/ui_get_capabilities_request.h" -#include "application_manager/commands/hmi/ui_get_capabilities_response.h" -#include "application_manager/commands/hmi/ui_change_registration_request.h" -#include "application_manager/commands/hmi/ui_change_registration_response.h" -#include "application_manager/commands/hmi/ui_show_request.h" -#include "application_manager/commands/hmi/ui_show_response.h" -#include "application_manager/commands/hmi/ui_alert_request.h" -#include "application_manager/commands/hmi/ui_alert_response.h" -#include "application_manager/commands/hmi/ui_is_ready_request.h" -#include "application_manager/commands/hmi/ui_is_ready_response.h" -#include "application_manager/commands/hmi/ui_slider_request.h" -#include "application_manager/commands/hmi/ui_slider_response.h" -#include "application_manager/commands/hmi/ui_set_media_clock_timer_request.h" -#include "application_manager/commands/hmi/ui_set_media_clock_timer_response.h" -#include "application_manager/commands/hmi/ui_set_global_properties_request.h" -#include "application_manager/commands/hmi/ui_set_global_properties_response.h" -#include "application_manager/commands/hmi/ui_scrollable_message_request.h" -#include "application_manager/commands/hmi/ui_scrollable_message_response.h" -#include "application_manager/commands/hmi/ui_set_app_icon_request.h" -#include "application_manager/commands/hmi/ui_set_app_icon_response.h" -#include "application_manager/commands/hmi/ui_perform_audio_pass_thru_response.h" -#include "application_manager/commands/hmi/ui_perform_audio_pass_thru_request.h" -#include "application_manager/commands/hmi/ui_end_audio_pass_thru_request.h" -#include "application_manager/commands/hmi/ui_end_audio_pass_thru_response.h" -#include "application_manager/commands/hmi/ui_perform_interaction_request.h" -#include "application_manager/commands/hmi/ui_perform_interaction_response.h" -#include "application_manager/commands/hmi/vr_is_ready_request.h" -#include "application_manager/commands/hmi/vr_is_ready_response.h" -#include "application_manager/commands/hmi/vr_add_command_request.h" -#include "application_manager/commands/hmi/vr_add_command_response.h" -#include "application_manager/commands/hmi/vr_delete_command_request.h" -#include "application_manager/commands/hmi/vr_delete_command_response.h" -#include "application_manager/commands/hmi/vr_change_registration_request.h" -#include "application_manager/commands/hmi/vr_change_registration_response.h" -#include "application_manager/commands/hmi/vr_get_supported_languages_request.h" -#include "application_manager/commands/hmi/vr_get_supported_languages_response.h" -#include "application_manager/commands/hmi/vr_get_language_request.h" -#include "application_manager/commands/hmi/vr_get_language_response.h" -#include "application_manager/commands/hmi/vr_get_capabilities_request.h" -#include "application_manager/commands/hmi/vr_get_capabilities_response.h" -#include "application_manager/commands/hmi/tts_is_ready_request.h" -#include "application_manager/commands/hmi/tts_is_ready_response.h" -#include "application_manager/commands/hmi/tts_change_registration_request.h" -#include "application_manager/commands/hmi/tts_change_registration_response.h" -#include "application_manager/commands/hmi/tts_get_supported_languages_request.h" -#include "application_manager/commands/hmi/tts_get_supported_languages_response.h" -#include "application_manager/commands/hmi/tts_get_language_request.h" -#include "application_manager/commands/hmi/tts_get_language_response.h" -#include "application_manager/commands/hmi/tts_stop_speaking_request.h" -#include "application_manager/commands/hmi/tts_stop_speaking_response.h" -#include "application_manager/commands/hmi/tts_speak_request.h" -#include "application_manager/commands/hmi/tts_speak_response.h" -#include "application_manager/commands/hmi/tts_set_global_properties_request.h" -#include "application_manager/commands/hmi/tts_set_global_properties_response.h" -#include "application_manager/commands/hmi/tts_get_capabilities_request.h" -#include "application_manager/commands/hmi/tts_get_capabilities_response.h" -#include "application_manager/commands/hmi/vr_perform_interaction_request.h" -#include "application_manager/commands/hmi/vr_perform_interaction_response.h" -#include "application_manager/commands/hmi/vi_is_ready_request.h" -#include "application_manager/commands/hmi/vi_is_ready_response.h" -#include "application_manager/commands/hmi/vi_read_did_request.h" -#include "application_manager/commands/hmi/vi_read_did_response.h" -#include "application_manager/commands/hmi/sdl_activate_app_request.h" -#include "application_manager/commands/hmi/sdl_activate_app_response.h" -#include "application_manager/commands/hmi/on_app_permission_changed_notification.h" -#include "application_manager/commands/hmi/on_event_changed_notification.h" -#include "application_manager/commands/hmi/vi_get_vehicle_data_request.h" -#include "application_manager/commands/hmi/vi_get_vehicle_data_response.h" -#include "application_manager/commands/hmi/on_vi_vehicle_data_notification.h" -#include "application_manager/commands/hmi/vi_subscribe_vehicle_data_request.h" -#include "application_manager/commands/hmi/vi_subscribe_vehicle_data_response.h" -#include "application_manager/commands/hmi/vi_unsubscribe_vehicle_data_request.h" -#include "application_manager/commands/hmi/vi_unsubscribe_vehicle_data_response.h" -#include "application_manager/commands/hmi/vi_get_dtcs_request.h" -#include "application_manager/commands/hmi/vi_get_dtcs_response.h" -#include "application_manager/commands/hmi/vi_diagnostic_message_request.h" -#include "application_manager/commands/hmi/vi_diagnostic_message_response.h" -#include "application_manager/commands/hmi/vi_get_vehicle_type_request.h" -#include "application_manager/commands/hmi/vi_get_vehicle_type_response.h" -#include "application_manager/commands/hmi/navi_is_ready_request.h" -#include "application_manager/commands/hmi/navi_show_constant_tbt_request.h" -#include "application_manager/commands/hmi/navi_show_constant_tbt_response.h" -#include "application_manager/commands/hmi/navi_is_ready_response.h" -#include "application_manager/commands/hmi/navi_alert_maneuver_request.h" -#include "application_manager/commands/hmi/navi_alert_maneuver_response.h" -#include "application_manager/commands/hmi/navi_update_turn_list_request.h" -#include "application_manager/commands/hmi/navi_update_turn_list_response.h" -#include "application_manager/commands/hmi/navi_subscribe_way_points_request.h" -#include "application_manager/commands/hmi/navi_subscribe_way_points_response.h" -#include "application_manager/commands/hmi/navi_unsubscribe_way_points_request.h" -#include "application_manager/commands/hmi/navi_unsubscribe_way_points_response.h" -#include "application_manager/commands/hmi/navi_get_way_points_request.h" -#include "application_manager/commands/hmi/navi_get_way_points_response.h" -#include "application_manager/commands/hmi/on_ready_notification.h" -#include "application_manager/commands/hmi/on_device_chosen_notification.h" -#include "application_manager/commands/hmi/on_file_removed_notification.h" -#include "application_manager/commands/hmi/on_system_context_notification.h" -#include "application_manager/commands/hmi/on_app_registered_notification.h" -#include "application_manager/commands/hmi/on_app_unregistered_notification.h" -#include "application_manager/commands/hmi/on_driver_distraction_notification.h" -#include "application_manager/commands/hmi/on_tts_started_notification.h" -#include "application_manager/commands/hmi/on_tts_stopped_notification.h" -#include "application_manager/commands/hmi/on_vr_started_notification.h" -#include "application_manager/commands/hmi/on_vr_stopped_notification.h" -#include "application_manager/commands/hmi/on_vr_command_notification.h" -#include "application_manager/commands/hmi/on_ui_command_notification.h" -#include "application_manager/commands/hmi/on_app_deactivated_notification.h" -#include "application_manager/commands/hmi/on_ui_language_change_notification.h" -#include "application_manager/commands/hmi/on_vr_language_change_notification.h" -#include "application_manager/commands/hmi/on_tts_language_change_notification.h" -#include "application_manager/commands/hmi/on_navi_tbt_client_state_notification.h" -#include "application_manager/commands/hmi/on_navi_way_point_change_notification.h" -#include "application_manager/commands/hmi/on_button_event_notification.h" -#include "application_manager/commands/hmi/on_button_press_notification.h" -#include "application_manager/commands/hmi/on_button_subscription_notification.h" -#include "application_manager/commands/hmi/on_vi_vehicle_data_notification.h" -#include "application_manager/commands/hmi/on_ui_keyboard_input_notification.h" -#include "application_manager/commands/hmi/on_ui_touch_event_notification.h" -#include "application_manager/commands/hmi/on_ui_reset_timeout_notification.h" -#include "application_manager/commands/hmi/navi_start_stream_request.h" -#include "application_manager/commands/hmi/navi_start_stream_response.h" -#include "application_manager/commands/hmi/navi_stop_stream_request.h" -#include "application_manager/commands/hmi/navi_stop_stream_response.h" -#include "application_manager/commands/hmi/on_system_request_notification.h" -#include "application_manager/commands/hmi/ui_set_display_layout_request.h" -#include "application_manager/commands/hmi/ui_set_display_layout_response.h" -#include "application_manager/commands/hmi/on_sdl_close_notification.h" -#include "application_manager/commands/hmi/on_sdl_persistence_complete_notification.h" -#include "application_manager/commands/hmi/on_record_start_notification.h" -#include "application_manager/commands/hmi/add_statistics_info_notification.h" -#include "application_manager/commands/hmi/on_system_error_notification.h" -#include "application_manager/commands/hmi/basic_communication_system_request.h" -#include "application_manager/commands/hmi/basic_communication_system_response.h" -#include "application_manager/commands/hmi/sdl_policy_update.h" -#include "application_manager/commands/hmi/sdl_policy_update_response.h" -#include "application_manager/commands/hmi/on_received_policy_update.h" -#include "application_manager/commands/hmi/on_policy_update.h" -#include "application_manager/commands/hmi/get_urls.h" -#include "application_manager/commands/hmi/get_urls_response.h" -#include "application_manager/commands/hmi/on_device_state_changed_notification.h" -#include "application_manager/commands/hmi/navi_send_location_request.h" -#include "application_manager/commands/hmi/navi_send_location_response.h" -#include "application_manager/commands/hmi/on_tts_reset_timeout_notification.h" -#include "application_manager/commands/hmi/dial_number_request.h" -#include "application_manager/commands/hmi/dial_number_response.h" -#include "application_manager/commands/hmi/on_vi_gps_data_notification.h" -#include "application_manager/commands/hmi/on_vi_speed_notification.h" -#include "application_manager/commands/hmi/on_vi_rpm_notification.h" -#include "application_manager/commands/hmi/on_vi_fuel_level_notification.h" -#include "application_manager/commands/hmi/on_vi_fuel_level_state_notification.h" -#include "application_manager/commands/hmi/on_vi_instant_fuel_consumption_notification.h" -#include "application_manager/commands/hmi/on_vi_external_temperature_notification.h" -#include "application_manager/commands/hmi/on_vi_vin_notification.h" -#include "application_manager/commands/hmi/on_vi_prndl_notification.h" -#include "application_manager/commands/hmi/on_vi_tire_pressure_notification.h" -#include "application_manager/commands/hmi/on_vi_odometer_notification.h" -#include "application_manager/commands/hmi/on_vi_belt_status_notification.h" -#include "application_manager/commands/hmi/on_vi_body_information_notification.h" -#include "application_manager/commands/hmi/on_vi_device_status_notification.h" -#include "application_manager/commands/hmi/on_vi_driver_braking_notification.h" -#include "application_manager/commands/hmi/on_vi_wiper_status_notification.h" -#include "application_manager/commands/hmi/on_vi_head_lamp_status_notification.h" -#include "application_manager/commands/hmi/on_vi_engine_torque_notification.h" -#include "application_manager/commands/hmi/on_vi_acc_pedal_position_notification.h" -#include "application_manager/commands/hmi/on_vi_steering_wheel_angle_notification.h" -#include "application_manager/commands/hmi/on_vi_my_key_notification.h" -#include "application_manager/commands/hmi/ui_set_icon_request.h" - -#include "application_manager/mock_application.h" -#include "application_manager/mock_application_manager.h" -#include "test/application_manager/mock_application_manager_settings.h" -#include "application_manager/mock_event_dispatcher.h" - -namespace am = application_manager; - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace dummy_hmi_commands_test { - -namespace commands = ::application_manager::commands; - -using ::testing::_; -using ::testing::NotNull; -using ::testing::Types; -using commands::MessageSharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; -using ::test::components::application_manager_test::MockApplicationManager; -using ::test::components::application_manager_test:: - MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; - -template <class Command> -class HMICommandsTest : public components::commands_test::CommandRequestTest< - CommandsTestMocks::kIsNice> { - public: - typedef Command CommandType; - - void InitCommand(const uint32_t& timeout) OVERRIDE { - stream_retry_.first = 0; - stream_retry_.second = 0; - EXPECT_CALL(app_mngr_settings_, default_timeout()) - .WillOnce(ReturnRef(timeout)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(event_dispatcher_)); - ON_CALL(app_mngr_, get_settings()) - .WillByDefault(ReturnRef(app_mngr_settings_)); - ON_CALL(app_mngr_settings_, start_stream_retry_amount()) - .WillByDefault(ReturnRef(stream_retry_)); - } - - protected: - std::pair<uint32_t, int32_t> stream_retry_; -}; - -template <class Command> -class HMICommandsTestFirst : public HMICommandsTest<Command> { - public: - using typename HMICommandsTest<Command>::CommandType; -}; - -template <class Command> -class HMICommandsTestSecond : public HMICommandsTest<Command> { - public: - using typename HMICommandsTest<Command>::CommandType; -}; - -template <class Command> -class HMICommandsTestThird : public HMICommandsTest<Command> { - public: - using typename HMICommandsTest<Command>::CommandType; -}; - -template <class Command> -class HMICommandsTestFourth : public HMICommandsTest<Command> { - public: - using typename HMICommandsTest<Command>::CommandType; -}; - -template <class Command> -class HMICommandsTestFifth : public HMICommandsTest<Command> { - public: - using typename HMICommandsTest<Command>::CommandType; -}; - -/* macro TYPED_TEST_CASE takes max 50 args. That is why there are few - * TYPED_TEST_CASE for HMI and mobile commands - */ - -typedef Types<commands::OnStartDeviceDiscovery, - commands::UpdateDeviceListResponse, - commands::UpdateDeviceListRequest, - commands::ActivateAppResponse, - commands::ActivateAppRequest, - commands::GetSystemInfoResponse, - commands::GetSystemInfoRequest, - commands::SDLActivateAppResponse, - commands::SDLActivateAppRequest, - commands::SDLPolicyUpdateResponse, - commands::SDLPolicyUpdate, - commands::GetUrlsResponse, - commands::GetUrls, - commands::OnAppPermissionChangedNotification, - commands::SDLGetListOfPermissionsResponse, - commands::SDLGetListOfPermissionsRequest, - commands::SDLGetUserFriendlyMessageResponse, - commands::SDLGetUserFriendlyMessageRequest, - commands::SDLGetStatusUpdateResponse, - commands::SDLGetStatusUpdateRequest, - commands::OnStatusUpdateNotification, - commands::OnAppPermissionConsentNotification, - commands::MixingAudioSupportedResponse, - commands::MixingAudioSupportedRequest, - commands::OnExitAllApplicationsNotification, - commands::UIAddCommandResponse, - commands::UIAddCommandRequest, - commands::UIDeleteCommandResponse, - commands::UIDeleteCommandRequest, - commands::UIAddSubmenuResponse, - commands::UIAddSubmenuRequest, - commands::UIDeleteSubmenuResponse, - commands::UIDeleteSubmenuRequest, - commands::UISetMediaClockTimerResponse, - commands::UISetMediaClockTimerRequest, - commands::UIPerformInteractionResponse, - commands::UIPerformInteractionRequest, - commands::UISetGlobalPropertiesResponse, - commands::UISetGlobalPropertiesRequest, - commands::UIScrollableMessageResponse, - commands::UIScrollableMessageRequest, - commands::UISetAppIconResponse, - commands::UISetAppIconRequest, - commands::UIGetSupportedLanguagesResponse, - commands::UIGetSupportedLanguagesRequest, - commands::UIGetLanguageResponse, - commands::UIGetLanguageRequest, - commands::UIGetCapabilitiesResponse, - commands::UIGetCapabilitiesRequest, - commands::UIChangeRegistratioResponse> HMICommandsListFirst; - -typedef Types<commands::UIChangeRegistrationRequest, - commands::UIPerformAudioPassThruResponse, - commands::UIPerformAudioPassThruRequest, - commands::UIEndAudioPassThruResponse, - commands::UIEndAudioPassThruRequest, - commands::UIAlertResponse, - commands::UIAlertRequest, - commands::VRIsReadyResponse, - commands::VRIsReadyRequest, - commands::VRAddCommandResponse, - commands::VRAddCommandRequest, - commands::VRDeleteCommandResponse, - commands::VRDeleteCommandRequest, - commands::VRChangeRegistrationResponse, - commands::VRChangeRegistrationRequest, - commands::VRGetSupportedLanguagesResponse, - commands::VRGetSupportedLanguagesRequest, - commands::VRGetLanguageResponse, - commands::VRGetLanguageRequest, - commands::VRGetCapabilitiesResponse, - commands::VRGetCapabilitiesRequest, - commands::TTSIsReadyResponse, - commands::TTSIsReadyRequest, - commands::TTSChangeRegistratioResponse, - commands::TTSChangeRegistrationRequest, - commands::TTSGetSupportedLanguagesResponse, - commands::TTSGetSupportedLanguagesRequest, - commands::TTSStopSpeakingResponse, - commands::TTSStopSpeakingRequest, - commands::TTSGetLanguageResponse, - commands::TTSGetLanguageRequest, - commands::TTSSpeakResponse, - commands::TTSSpeakRequest, - commands::TTSSetGlobalPropertiesResponse, - commands::TTSSetGlobalPropertiesRequest, - commands::TTSGetCapabilitiesResponse, - commands::TTSGetCapabilitiesRequest, - commands::OnTTSStartedNotification, - commands::OnTTSStoppedNotification, - commands::OnAppActivatedNotification, - commands::OnExitApplicationNotification, - commands::UIShowResponse, - commands::UIShowRequest, - commands::UISliderResponse, - commands::UISliderRequest, - commands::ClosePopupResponse, - commands::ClosePopupRequest, - commands::UIIsReadyResponse, - commands::UIIsReadyRequest, - commands::VIIsReadyResponse> HMICommandsListSecond; - -typedef Types<commands::VIIsReadyRequest, - commands::VIReadDIDResponse, - commands::VIReadDIDRequest, - commands::VIGetVehicleDataResponse, - commands::VIGetVehicleDataRequest, - commands::VIGetDTCsResponse, - commands::VIGetDTCsRequest, - commands::VIDiagnosticMessageResponse, - commands::VIDiagnosticMessageRequest, - commands::VIGetVehicleTypeResponse, - commands::VIGetVehicleTypeRequest, - commands::NaviIsReadyResponse, - commands::NaviIsReadyRequest, - commands::NaviAlertManeuverResponse, - commands::NaviAlertManeuverRequest, - commands::NaviGetWayPointsResponse, - commands::NaviGetWayPointsRequest, - commands::NaviUpdateTurnListResponse, - commands::NaviUpdateTurnListRequest, - commands::NaviShowConstantTBTResponse, - commands::NaviShowConstantTBTRequest, - commands::NaviSubscribeWayPointsResponse, - commands::NaviSubscribeWayPointsRequest, - commands::NaviUnsubscribeWayPointsResponse, - commands::NaviUnSubscribeWayPointsRequest, - commands::ButtonGetCapabilitiesResponse, - commands::ButtonGetCapabilitiesRequest, - commands::OnAllowSDLFunctionalityNotification, - commands::OnSDLConsentNeededNotification, - commands::UpdateSDLResponse, - commands::UpdateSDLRequest, - commands::OnIgnitionCycleOverNotification, - commands::OnSystemInfoChangedNotification, - commands::OnReadyNotification, - commands::OnDeviceChosenNotification, - commands::OnSystemContextNotification, - commands::hmi::OnDriverDistractionNotification, - commands::OnUpdateDeviceList, - commands::OnAppRegisteredNotification, - commands::OnAppUnregisteredNotification, - commands::OnFindApplications, - commands::UpdateAppListResponse, - commands::UpdateAppListRequest, - commands::OnVRStartedNotification, - commands::OnVRStoppedNotification, - commands::OnVRCommandNotification, - commands::OnUICommandNotification, - commands::OnAppDeactivatedNotification> HMICommandsListThird; - -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, - commands::hmi::OnUIResetTimeoutNotification, - commands::NaviStartStreamResponse, - commands::NaviStartStreamRequest, - commands::NaviStopStreamResponse, - commands::NaviStopStreamRequest, - commands::AudioStartStreamResponse, - commands::AudioStartStreamRequest, - commands::AudioStopStreamResponse, - commands::AudioStopStreamRequest, - commands::OnAudioDataStreamingNotification, - commands::OnVideoDataStreamingNotification, - commands::VRPerformInteractionResponse, - commands::VRPerformInteractionRequest, - commands::OnSystemRequestNotification, - commands::OnPutFileNotification, - commands::OnResumeAudioSourceNotification, - commands::UiSetDisplayLayoutResponse, - commands::UiSetDisplayLayoutRequest, - commands::OnSDLCloseNotification, - commands::OnSDLPersistenceCompleteNotification, - commands::OnFileRemovedNotification, - commands::OnRecordStartdNotification, - commands::BasicCommunicationSystemResponse, - commands::BasicCommunicationSystemRequest, - commands::NaviSendLocationResponse, - commands::NaviSendLocationRequest, - commands::AddStatisticsInfoNotification, - commands::OnSystemErrorNotification, - commands::OnReceivedPolicyUpdate, - commands::OnPolicyUpdate, - commands::OnDeviceStateChangedNotification, - commands::hmi::OnTTSResetTimeoutNotification, - commands::hmi::DialNumberResponse, - commands::hmi::DialNumberRequest, - commands::OnEventChangedNotification, - commands::OnNaviWayPointChangeNotification, - commands::OnUILanguageChangeNotification, - commands::OnVRLanguageChangeNotification, - commands::OnTTSLanguageChangeNotification> HMICommandsListFourth; - -typedef Types<commands::OnVIGpsDataNotification, - commands::OnVISpeedNotification, - commands::OnVIRpmNotification, - commands::OnVIFuelLevelNotification, - commands::OnVIFuelLevelStateNotification, - commands::OnVIInstantFuelConsumptionNotification, - commands::OnVIExternalTemperatureNotification, - commands::OnVIVinNotification, - commands::OnVIPrndlNotification, - commands::OnVITirePressureNotification, - commands::OnVIOdometerNotification, - commands::OnVIBeltStatusNotification, - commands::OnVIBodyInformationNotification, - commands::OnVIDeviceStatusNotification, - commands::OnVIDriverBrakingNotification, - commands::OnVIWiperStatusNotification, - commands::OnVIHeadLampStatusNotification, - commands::OnVIEngineTorqueNotification, - commands::OnVIAccPedalPositionNotification, - commands::OnVISteeringWheelAngleNotification, - commands::OnVIMyKeyNotification, - commands::AllowAllAppsRequest, - commands::AllowAllAppsResponse, - commands::AllowAppRequest, - commands::AllowAppResponse> HMICommandsListFifth; - -TYPED_TEST_CASE(HMICommandsTestFirst, HMICommandsListFirst); -TYPED_TEST_CASE(HMICommandsTestSecond, HMICommandsListSecond); -TYPED_TEST_CASE(HMICommandsTestThird, HMICommandsListThird); -TYPED_TEST_CASE(HMICommandsTestFourth, HMICommandsListFourth); -TYPED_TEST_CASE(HMICommandsTestFifth, HMICommandsListFifth); - -TYPED_TEST(HMICommandsTestFirst, CtorAndDtorCall) { - utils::SharedPtr<typename TestFixture::CommandType> command = - this->template CreateCommand<typename TestFixture::CommandType>(); - UNUSED(command); -} - -TYPED_TEST(HMICommandsTestSecond, CtorAndDtorCall) { - utils::SharedPtr<typename TestFixture::CommandType> command = - this->template CreateCommand<typename TestFixture::CommandType>(); - UNUSED(command); -} -TYPED_TEST(HMICommandsTestThird, CtorAndDtorCall) { - utils::SharedPtr<typename TestFixture::CommandType> command = - this->template CreateCommand<typename TestFixture::CommandType>(); - UNUSED(command); -} - -TYPED_TEST(HMICommandsTestFourth, CtorAndDtorCall) { - utils::SharedPtr<typename TestFixture::CommandType> command = - this->template CreateCommand<typename TestFixture::CommandType>(); - UNUSED(command); -} - -TYPED_TEST(HMICommandsTestFifth, CtorAndDtorCall) { - utils::SharedPtr<typename TestFixture::CommandType> command = - this->template CreateCommand<typename TestFixture::CommandType>(); - UNUSED(command); -} - -} // namespace dummy_hmi_commands_test -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/get_system_info_request_test.cc b/src/components/application_manager/test/commands/hmi/get_system_info_request_test.cc deleted file mode 100644 index e8c88256c3..0000000000 --- a/src/components/application_manager/test/commands/hmi/get_system_info_request_test.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/hmi/request_to_hmi.h" -#include "application_manager/commands/hmi/get_system_info_request.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace get_system_info_request { - -using ::utils::SharedPtr; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::RequestToHMI; -using am::commands::GetSystemInfoRequest; -using am::commands::CommandImpl; - -typedef SharedPtr<RequestToHMI> RequestToHMIPtr; - -namespace { -const uint32_t kConnectionKey = 2u; -const uint32_t kCorrelationId = 1u; -} // namespace - -class GetSystemInfoRequestTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(GetSystemInfoRequestTest, RUN_SendRequest_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][strings::correlation_id] = kCorrelationId; - - RequestToHMIPtr command(CreateCommand<GetSystemInfoRequest>(command_msg)); - - const uint32_t kAppId = command->application_id(); - - EXPECT_CALL(app_mngr_, set_application_id(kCorrelationId, kAppId)); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(command_msg)); - - command->Run(); - - EXPECT_EQ((*command_msg)[strings::msg_params][strings::app_id].asUInt(), - kAppId); - EXPECT_EQ((*command_msg)[strings::params][strings::correlation_id].asUInt(), - kCorrelationId); - - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); -} - -} // namespace get_system_info_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/get_system_info_response_test.cc b/src/components/application_manager/test/commands/hmi/get_system_info_response_test.cc deleted file mode 100644 index 980b6e0e9d..0000000000 --- a/src/components/application_manager/test/commands/hmi/get_system_info_response_test.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/hmi/response_from_hmi.h" -#include "application_manager/commands/hmi/get_system_info_response.h" -#include "application_manager/policies/mock_policy_handler_interface.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace get_system_info_response { - -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::ResponseFromHMI; -using am::commands::GetSystemInfoResponse; -using am::commands::CommandImpl; -using am::commands::SystemInfo; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -const std::string ccpu_version("4.1.3.B_EB355B"); -const std::string wers_country_code("WAEGB"); -const uint32_t lang_code = 0u; -const std::string kLanguage = ""; -} // namespace - -class GetSystemInfoResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr CreateCommandMsg() { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::msg_params]["ccpu_version"] = ccpu_version; - (*command_msg)[strings::msg_params]["wersCountryCode"] = wers_country_code; - (*command_msg)[strings::msg_params]["language"] = lang_code; - - return command_msg; - } - - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(GetSystemInfoResponseTest, GetSystemInfo_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - - ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg)); - policy_test::MockPolicyHandlerInterface policy_handler; - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - std::string language; - EXPECT_CALL(mock_message_helper_, - CommonLanguageToString( - static_cast<hmi_apis::Common_Language::eType>(lang_code))) - .WillOnce(Return(language)); - EXPECT_EQ(kLanguage, language); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler)); - EXPECT_CALL(policy_handler, - OnGetSystemInfo(ccpu_version, wers_country_code, kLanguage)); - - command->Run(); -} - -TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::WRONG_LANGUAGE; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - - ResponseFromHMIPtr command(CreateCommand<GetSystemInfoResponse>(command_msg)); - policy_test::MockPolicyHandlerInterface policy_handler; - - EXPECT_CALL(app_mngr_, hmi_capabilities()).Times(0); - - EXPECT_CALL(mock_message_helper_, - CommonLanguageToString( - static_cast<hmi_apis::Common_Language::eType>(lang_code))) - .Times(0); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler)); - EXPECT_CALL(policy_handler, OnGetSystemInfo("", "", "")); - - command->Run(); -} - -} // namespace get_system_info_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/get_urls_response_test.cc b/src/components/application_manager/test/commands/hmi/get_urls_response_test.cc deleted file mode 100644 index 5a41cae7ce..0000000000 --- a/src/components/application_manager/test/commands/hmi/get_urls_response_test.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2016, 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 "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.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/hmi/response_to_hmi.h" -#include "application_manager/commands/hmi/get_urls_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace get_urls_response { - -using ::testing::_; -using ::testing::Return; -using ::utils::SharedPtr; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::ResponseToHMI; -using am::commands::GetUrlsResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<ResponseToHMI> ResponseToHMIPtr; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class GetUrlResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(GetUrlResponseTest, RUN_SendRequest_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - - ResponseToHMIPtr command(CreateCommand<GetUrlsResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(command_msg)); - - command->Run(); - - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); -} - -} // namespace get_urls_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/get_urls_test.cc b/src/components/application_manager/test/commands/hmi/get_urls_test.cc deleted file mode 100644 index 9430dc045c..0000000000 --- a/src/components/application_manager/test/commands/hmi/get_urls_test.cc +++ /dev/null @@ -1,331 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "application_manager/message.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_application_manager.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/command.h" -#include "application_manager/commands/hmi/get_urls.h" -#include "application_manager/policies/policy_handler.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "commands/commands_test.h" -#include "commands/command_request_test.h" -#include "hmi/request_from_hmi.h" -#include "policy/mock_policy_manager.h" -#include "application_manager/event_engine/event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace get_urls { - -using namespace hmi_apis; -using namespace policy; -using ::utils::SharedPtr; -using ::testing::NiceMock; -using ::testing::SetArgReferee; -using ::test::components::application_manager_test::MockApplication; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::RequestFromHMI; -using am::commands::GetUrls; -using am::commands::CommandImpl; -using policy::PolicyHandler; -using policy_test::MockPolicyHandlerInterface; - -typedef SharedPtr<RequestFromHMI> RequestFromHMIPtr; - -namespace { -const uint32_t kInvalidAppId_ = 0u; -const uint32_t kAppIdForSending = 1u; -const uint32_t kConnectionKey = 2u; -const uint32_t kServiceType = 0u; -const std::string kInitialService = "0x0"; -const std::string kPolicyService = "7"; -const std::string kDefaultUrl = "URL is not found"; -const std::string kDefaultId = "default"; -const std::string kPolicyAppId = "policy_app_id"; -} // namespace - -class GetUrlsTest : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - policy_test::MockPolicyHandlerInterface mock_policy_handler_; - MessageSharedPtr command_msg_; - RequestFromHMIPtr request_command_; - - GetUrlsTest() { - command_msg_ = - CreateMessage(NsSmartDeviceLink::NsSmartObjects::SmartType_Map); - (*command_msg_)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kInitialService; - - request_command_ = CreateCommand<GetUrls>(command_msg_); - - ON_CALL(app_mngr_, GetPolicyHandler()) - .WillByDefault(ReturnRef(mock_policy_handler_)); - } -}; - -TEST_F(GetUrlsTest, RUN_SUCCESS) { - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - request_command_->Run(); -} - -TEST_F(GetUrlsTest, RUN_PolicyNotEnabled_UNSUCCESS) { - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(false)); - - EXPECT_CALL(app_mngr_, ManageHMICommand(command_msg_)).WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -TEST_F(GetUrlsTest, RUN_EmptyEndpoints_UNSUCCESS) { - EndpointUrls endpoints_; - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - EXPECT_CALL(app_mngr_, ManageHMICommand(command_msg_)).WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -#ifdef EXTENDED_POLICY -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr mock_app = CreateMockApp(); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppIdForSending)); - EXPECT_CALL(app_mngr_, ManageHMICommand(command_msg_)).WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::SUCCESS, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); - - EXPECT_EQ(kAppIdForSending, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [strings::app_id].asInt()); - EXPECT_EQ(kDefaultUrl, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [strings::url].asString()); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_IncorrectIdForSending_UNSUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kInvalidAppId_)); - - EXPECT_CALL(app_mngr_, ManageHMICommand(command_msg_)).WillOnce(Return(true)); - - EXPECT_CALL(app_mngr_, application(kInvalidAppId_)).Times(0); - - request_command_->Run(); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_ApplicationIsNotValid_UNSUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr invalid_mock_app; - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(invalid_mock_app)); - - EXPECT_CALL(app_mngr_, ManageHMICommand(command_msg_)).WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::DATA_NOT_AVAILABLE, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} - -TEST_F(GetUrlsTest, ProcessPolicyServiceURLs_FoundURLForApplication_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_request::service] = - kPolicyService; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - data.app_id = kPolicyAppId; - endpoints_.push_back(data); - - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kPolicyService, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - MockAppPtr mock_app = CreateMockApp(); - - EXPECT_CALL(mock_policy_handler_, GetAppIdForSending()) - .WillOnce(Return(kAppIdForSending)); - - EXPECT_CALL(app_mngr_, application(kAppIdForSending)) - .WillOnce(Return(mock_app)); - - EXPECT_CALL(*mock_app, policy_app_id()).WillOnce(Return(kPolicyAppId)); - - EXPECT_CALL(app_mngr_, ManageHMICommand(command_msg_)).WillOnce(Return(true)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - - EXPECT_EQ(am::MessageType::kResponse, - (*command_msg_)[strings::params][strings::message_type].asInt()); - EXPECT_EQ(Common_Result::SUCCESS, - (*command_msg_)[strings::params][am::hmi_response::code].asInt()); -} -#endif - -TEST_F(GetUrlsTest, DISABLED_ProcessServiceURLs_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = - kDefaultUrl; - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id] = "1"; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - data.app_id = "1"; - endpoints_.push_back(data); - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - EXPECT_EQ(kDefaultUrl, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::strings::url].asString()); - EXPECT_EQ(endpoints_[0].app_id, - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id].asString()); -} - -TEST_F(GetUrlsTest, ProcessServiceURLs_PolicyDefaultId_SUCCESS) { - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] = - kDefaultUrl; - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - [am::hmi_response::policy_app_id] = kDefaultId; - - EXPECT_CALL(mock_policy_handler_, PolicyEnabled()).WillOnce(Return(true)); - EndpointUrls endpoints_; - EndpointData data(kDefaultUrl); - endpoints_.push_back(data); - EXPECT_CALL(mock_policy_handler_, GetUpdateUrls(kServiceType, _)) - .WillOnce(SetArgReferee<1>(endpoints_)); - MockAppPtr mock_app = CreateMockApp(); - EXPECT_CALL(app_mngr_, application_by_policy_id(_)) - .WillOnce(Return(mock_app)); - request_command_->Run(); - - EXPECT_FALSE((*command_msg_)[am::strings::msg_params].keyExists( - am::hmi_request::service)); - EXPECT_TRUE( - (*command_msg_)[am::strings::msg_params][am::hmi_response::urls][0] - .keyExists(am::hmi_response::policy_app_id)); -} - -} // namespace get_urls -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc deleted file mode 100644 index ffedf1b4f6..0000000000 --- a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc +++ /dev/null @@ -1,1980 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/commands_test.h" - -#include "application_manager/commands/hmi/on_button_event_notification.h" -#include "application_manager/commands/hmi/on_navi_tbt_client_state_notification.h" -#include "application_manager/commands/hmi/on_navi_way_point_change_notification.h" -#include "application_manager/commands/hmi/on_ui_command_notification.h" -#include "application_manager/commands/hmi/on_ui_keyboard_input_notification.h" -#include "application_manager/commands/hmi/on_ui_touch_event_notification.h" -#include "application_manager/commands/hmi/on_vi_acc_pedal_position_notification.h" -#include "application_manager/commands/hmi/on_vi_belt_status_notification.h" -#include "application_manager/commands/hmi/on_vi_body_information_notification.h" -#include "application_manager/commands/hmi/on_vi_device_status_notification.h" -#include "application_manager/commands/hmi/on_vi_driver_braking_notification.h" -#include "application_manager/commands/hmi/on_vi_engine_torque_notification.h" -#include "application_manager/commands/hmi/on_vi_external_temperature_notification.h" -#include "application_manager/commands/hmi/on_vi_fuel_level_notification.h" -#include "application_manager/commands/hmi/on_vi_fuel_level_state_notification.h" -#include "application_manager/commands/hmi/on_vi_gps_data_notification.h" -#include "application_manager/commands/hmi/on_vi_head_lamp_status_notification.h" -#include "application_manager/commands/hmi/on_vi_instant_fuel_consumption_notification.h" -#include "application_manager/commands/hmi/on_vi_my_key_notification.h" -#include "application_manager/commands/hmi/on_vi_odometer_notification.h" -#include "application_manager/commands/hmi/on_vi_prndl_notification.h" -#include "application_manager/commands/hmi/on_vi_rpm_notification.h" -#include "application_manager/commands/hmi/on_vi_speed_notification.h" -#include "application_manager/commands/hmi/on_vi_steering_wheel_angle_notification.h" -#include "application_manager/commands/hmi/on_vi_tire_pressure_notification.h" -#include "application_manager/commands/hmi/on_vi_vehicle_data_notification.h" -#include "application_manager/commands/hmi/on_vi_vin_notification.h" -#include "application_manager/commands/hmi/on_vi_wiper_status_notification.h" -#include "application_manager/commands/hmi/on_app_permission_changed_notification.h" -#include "application_manager/commands/hmi/on_app_registered_notification.h" -#include "application_manager/commands/hmi/on_audio_data_streaming_notification.h" -#include "application_manager/commands/hmi/on_button_subscription_notification.h" -#include "application_manager/commands/hmi/on_file_removed_notification.h" -#include "application_manager/commands/hmi/on_put_file_notification.h" -#include "application_manager/commands/hmi/on_resume_audio_source_notification.h" -#include "application_manager/commands/hmi/on_sdl_close_notification.h" -#include "application_manager/commands/hmi/on_sdl_consent_needed_notification.h" -#include "application_manager/commands/hmi/on_sdl_persistence_complete_notification.h" -#include "application_manager/commands/hmi/on_status_update_notification.h" -#include "application_manager/commands/hmi/on_video_data_streaming_notification.h" -#include "application_manager/commands/hmi/on_record_start_notification.h" -#include "application_manager/commands/hmi/on_app_activated_notification.h" -#include "application_manager/commands/hmi/on_app_deactivated_notification.h" -#include "application_manager/commands/hmi/on_app_unregistered_notification.h" -#include "application_manager/commands/hmi/on_button_press_notification.h" -#include "application_manager/commands/hmi/on_event_changed_notification.h" -#include "application_manager/commands/hmi/on_ready_notification.h" -#include "application_manager/commands/hmi/on_tts_reset_timeout_notification.h" -#include "application_manager/commands/hmi/on_tts_started_notification.h" -#include "application_manager/commands/hmi/on_tts_stopped_notification.h" -#include "application_manager/commands/hmi/on_ui_reset_timeout_notification.h" -#include "application_manager/commands/hmi/on_vr_started_notification.h" -#include "application_manager/commands/hmi/on_vr_stopped_notification.h" -#include "application_manager/commands/hmi/on_app_permission_consent_notification.h" -#include "application_manager/commands/hmi/on_ignition_cycle_over_notification.h" -#include "application_manager/commands/hmi/on_policy_update.h" -#include "application_manager/commands/hmi/on_received_policy_update.h" -#include "application_manager/commands/hmi/on_system_error_notification.h" -#include "application_manager/commands/hmi/on_system_info_changed_notification.h" -#include "application_manager/commands/hmi/on_allow_sdl_functionality_notification.h" -#include "application_manager/commands/hmi/on_device_state_changed_notification.h" -#include "application_manager/commands/hmi/on_exit_all_applications_notification.h" -#include "application_manager/commands/hmi/on_exit_application_notification.h" -#include "application_manager/commands/hmi/on_vr_command_notification.h" -#include "application_manager/commands/hmi/on_vr_language_change_notification.h" -#include "application_manager/commands/hmi/on_start_device_discovery.h" -#include "application_manager/commands/hmi/on_device_chosen_notification.h" -#include "application_manager/commands/hmi/on_system_context_notification.h" -#include "application_manager/commands/hmi/on_system_request_notification.h" -#include "application_manager/commands/hmi/on_tts_language_change_notification.h" -#include "application_manager/commands/hmi/on_ui_language_change_notification.h" -#include "application_manager/commands/hmi/on_driver_distraction_notification.h" - -#include "utils/lock.h" -#include "utils/data_accessor.h" -#include "utils/signals.h" -#include "utils/shared_ptr.h" -#include "utils/make_shared.h" -#include "utils/file_system.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_state_controller.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/hmi_capabilities_impl.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "transport_manager/mock_transport_manager.h" -#include "connection_handler/mock_connection_handler.h" -#include "connection_handler/mock_connection_handler_settings.h" -#include "test/application_manager/mock_application_manager_settings.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" -#include "protocol_handler/mock_session_observer.h" -#include "application_manager/mock_resume_ctrl.h" - -#ifdef SDL_REMOTE_CONTROL -#include "functional_module/plugin_manager.h" -#endif // SDL_REMOTE_CONTROL - -namespace am = application_manager; - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace hmi_notifications_test { - -using ::testing::_; -using ::testing::Test; -using ::testing::Types; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::testing::InSequence; -using ::utils::SharedPtr; -using ::smart_objects::SmartObject; -using ::application_manager::commands::MessageSharedPtr; -using ::test::components::application_manager_test::MockApplicationManager; -using ::test::components::application_manager_test:: - MockApplicationManagerSettings; -using ::application_manager::ApplicationSharedPtr; -using ::test::components::application_manager_test::MockApplication; -using ::test::components::event_engine_test::MockEventDispatcher; -using ::application_manager::MockMessageHelper; - -using namespace am::commands; - -typedef SharedPtr<MockApplication> MockAppPtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -#define MEDIA true -#define NOT_MEDIA false -#define VC true -#define NOT_VC false -#define NAVI true -#define NOT_NAVI false - -ACTION_P(GetEventId, event_id) { - *event_id = arg0.id(); -} -ACTION_P(GetArg, arg) { - *arg = arg0; -} - -ACTION_P(GetArg3, result) { - arg3 = *result; -} - -ACTION_P2(GetConnectIdPermissionConsent, connect_id, consent) { - *connect_id = arg0; - std::vector<policy::FunctionalGroupPermission>::const_iterator it = - arg1.group_permissions.begin(); - for (; it != arg1.group_permissions.end(); ++it) { - consent->group_permissions.push_back(*it); - } - consent->consent_source = arg1.consent_source; -} -ACTION_P2(GetBoolValueAndString, value, str) { - *value = arg0; - *str = arg1; -} -ACTION_P(GetMessage, message) { - (*message)[am::strings::params][am::strings::function_id] = - (*arg0)[am::strings::params][am::strings::function_id].asInt(); - (*message)[am::strings::params][am::strings::message_type] = - (*arg0)[am::strings::params][am::strings::message_type].asInt(); - (*message)[am::strings::params][am::strings::correlation_id] = - (*arg0)[am::strings::params][am::strings::correlation_id].asInt(); - (*message)[am::strings::params][am::strings::connection_key] = - (*arg0)[am::strings::params][am::strings::connection_key].asInt(); - return (*message)[am::strings::params][am::strings::correlation_id].asInt(); -} - -namespace { -const uint32_t kCountCommandsManageMobile_ = 22u; -const uint32_t kCountCommandsToHmi_ = 12u; -const int32_t kHmiProtocolType_ = 1; -const int32_t kMobileProtocolType_ = 0; -const int32_t kProtocolVersion_ = 3; -const uint32_t kCorrelationId_ = 1939u; -const uint32_t kAppId_ = 2014u; -} // namespace - -class HMICommandsNotificationsTest - : public components::commands_test::CommandsTest< - CommandsTestMocks::kIsNice> { - public: - HMICommandsNotificationsTest() - : applications_(application_set_, applications_lock_), app_ptr_(NULL) {} - - ~HMICommandsNotificationsTest() { - // Fix DataAccessor release and WinQt crash - Mock::VerifyAndClearExpectations(&app_mngr_); - } - typedef Command CommandType; - - protected: - am::ApplicationSet application_set_; - sync_primitives::Lock applications_lock_; - DataAccessor<am::ApplicationSet> applications_; - MockHMICapabilities mock_hmi_capabilities_; - - NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; - NiceMock<policy_test::MockPolicyHandlerInterface> policy_interface_; - - application_manager_test::MockStateController mock_state_controller_; - - am::ApplicationSharedPtr app_; - NiceMock<MockApplication>* app_ptr_; - - typedef IsNiceMock<connection_handler_test::MockConnectionHandler, - kMocksAreNice>::Result MockConnectionHandler; - - typedef IsNiceMock<protocol_handler_test::MockSessionObserver, - kMocksAreNice>::Result MockSessionObserver; - - MockConnectionHandler mock_connection_handler_; - MockSessionObserver mock_session_observer_; - - void InitCommand(const uint32_t& default_timeout) OVERRIDE { - app_ = ConfigureApp(&app_ptr_, kAppId_, NOT_MEDIA, NOT_NAVI, NOT_VC); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - EXPECT_CALL(app_mngr_settings_, default_timeout()) - .WillOnce(ReturnRef(default_timeout)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(mock_event_dispatcher_)); - ON_CALL(app_mngr_, GetPolicyHandler()) - .WillByDefault(ReturnRef(policy_interface_)); - ON_CALL(app_mngr_, application_by_hmi_app(_)).WillByDefault(Return(app_)); - ON_CALL(*app_ptr_, app_id()).WillByDefault(Return(kAppId_)); - } - - am::ApplicationSharedPtr ConfigureApp(NiceMock<MockApplication>** app_mock, - uint32_t app_id, - bool media, - bool navi, - bool vc) { - *app_mock = new NiceMock<MockApplication>; - - Mock::AllowLeak(*app_mock); // WorkAround for gogletest bug - am::ApplicationSharedPtr app(*app_mock); - - ON_CALL(**app_mock, app_id()).WillByDefault(Return(app_id)); - ON_CALL(**app_mock, is_media_application()).WillByDefault(Return(media)); - ON_CALL(**app_mock, is_navi()).WillByDefault(Return(navi)); - ON_CALL(**app_mock, is_voice_communication_supported()) - .WillByDefault(Return(vc)); - ON_CALL(**app_mock, IsAudioApplication()) - .WillByDefault(Return(media || navi || vc)); - return app; - } -#if defined(OS_POSIX) - void SubscribeForSignal() { - sigset_t signal_set; - sigemptyset(&signal_set); - sigaddset(&signal_set, SIGINT); - sigaddset(&signal_set, SIGTERM); - pthread_sigmask(SIG_BLOCK, &signal_set, NULL); - } -#endif -}; - -namespace { -void sig_handler(int sig) { - switch (sig) { - case SIGINT: - break; - case SIGTERM: - break; - case SIGSEGV: - abort(); - default: - exit(EXIT_FAILURE); - } -} -} // namespace - -template <class Command> -class HMIOnViNotifications : public commands_test::CommandsTest<kIsNice> { - public: - typedef Command CommandType; -}; - -template <class Command> -class HMIOnNotificationsListToHMI - : public commands_test::CommandsTest<kIsNice> { - public: - typedef Command CommandType; -}; - -template <class CommandT, hmi_apis::FunctionID::eType kCommandId> -struct CommandPair { - typedef CommandT CommandType; - enum { kHMICommandId = kCommandId }; -}; - -template <class Command> -class HMIOnNotificationsEventDispatcher - : public commands_test::CommandsTest<kIsNice> { - public: - typedef Command CommandType; - NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; -}; - -typedef Types<OnVIAccPedalPositionNotification, - OnVIBeltStatusNotification, - OnVIBodyInformationNotification, - OnVIDeviceStatusNotification, - OnVIDriverBrakingNotification, - OnVIEngineTorqueNotification, - OnVIExternalTemperatureNotification, - OnVIFuelLevelNotification, - OnVIFuelLevelStateNotification, - OnVIGpsDataNotification, - OnVIHeadLampStatusNotification, - OnVIInstantFuelConsumptionNotification, - OnVIMyKeyNotification, - OnVIOdometerNotification, - OnVIPrndlNotification, - OnVIRpmNotification, - OnVISpeedNotification, - OnVISteeringWheelAngleNotification, - OnVITirePressureNotification, - OnVIVehicleDataNotification, - OnVIVinNotification, - OnVIWiperStatusNotification> HMIOnViNotificationsTypes; - -typedef Types<OnAppPermissionChangedNotification, - OnAudioDataStreamingNotification, - hmi::OnButtonSubscriptionNotification, - OnFileRemovedNotification, - OnPutFileNotification, - OnResumeAudioSourceNotification, - OnSDLCloseNotification, - OnSDLConsentNeededNotification, - OnSDLPersistenceCompleteNotification, - OnStatusUpdateNotification, - OnVideoDataStreamingNotification, - OnRecordStartdNotification> HMIOnNotificationsListToHMITypes; - -typedef Types< - CommandPair<OnAppActivatedNotification, - hmi_apis::FunctionID::BasicCommunication_OnAppActivated>, - CommandPair<OnAppDeactivatedNotification, - hmi_apis::FunctionID::BasicCommunication_OnAppDeactivated>, - CommandPair<OnEventChangedNotification, - hmi_apis::FunctionID::BasicCommunication_OnEventChanged>, - CommandPair<hmi::OnTTSResetTimeoutNotification, - hmi_apis::FunctionID::TTS_OnResetTimeout>, - CommandPair<OnTTSStartedNotification, hmi_apis::FunctionID::TTS_Started>, - CommandPair<OnTTSStoppedNotification, hmi_apis::FunctionID::TTS_Stopped>, - CommandPair<hmi::OnUIResetTimeoutNotification, - hmi_apis::FunctionID::UI_OnResetTimeout>, - CommandPair<OnVRStartedNotification, hmi_apis::FunctionID::VR_Started>, - CommandPair<OnVRStoppedNotification, hmi_apis::FunctionID::VR_Stopped> > - HMIOnNotificationsEventDispatcherTypes; - -TYPED_TEST_CASE(HMIOnViNotifications, HMIOnViNotificationsTypes); -TYPED_TEST_CASE(HMIOnNotificationsListToHMI, HMIOnNotificationsListToHMITypes); -TYPED_TEST_CASE(HMIOnNotificationsEventDispatcher, - HMIOnNotificationsEventDispatcherTypes); - -TYPED_TEST(HMIOnViNotifications, CommandsSendNotificationToMobile) { - MessageSharedPtr message = - commands_test::CommandsTest<kIsNice>::CreateMessage(); - utils::SharedPtr<typename TestFixture::CommandType> command = - this->template CreateCommand<typename TestFixture::CommandType>(message); - EXPECT_CALL(commands_test::CommandsTest<kIsNice>::app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ( - static_cast<int32_t>(mobile_apis::FunctionID::eType::OnVehicleDataID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TYPED_TEST(HMIOnNotificationsListToHMI, CommandsSendNotificationToHmi) { - MessageSharedPtr message = - commands_test::CommandsTest<kIsNice>::CreateMessage(); - utils::SharedPtr<typename TestFixture::CommandType> command = - this->template CreateCommand<typename TestFixture::CommandType>(message); - EXPECT_CALL(commands_test::CommandsTest<kIsNice>::app_mngr_, - SendMessageToHMI(_)); - command->Run(); - EXPECT_EQ( - static_cast<int32_t>(kHmiProtocolType_), - (*message)[am::strings::params][am::strings::protocol_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kProtocolVersion_), - (*message)[am::strings::params][am::strings::protocol_version].asInt()); -} - -TYPED_TEST(HMIOnNotificationsEventDispatcher, - CommandsNotificationEventDispatcher) { - int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr message = - commands_test::CommandsTest<kIsNice>::CreateMessage(); - utils::SharedPtr<typename TestFixture::CommandType::CommandType> command = - this->template CreateCommand< - typename TestFixture::CommandType::CommandType>(message); - EXPECT_CALL(commands_test::CommandsTest<kIsNice>::app_mngr_, - event_dispatcher()) - .WillOnce(ReturnRef(this->mock_event_dispatcher_)); - EXPECT_CALL(this->mock_event_dispatcher_, raise_event(_)) - .WillOnce(GetEventId(&event_id)); - command->Run(); - EXPECT_EQ(TestFixture::CommandType::kHMICommandId, event_id); -} - -// notifications(SendNotificationToMobile) -TEST_F(HMICommandsNotificationsTest, OnButtonEventSendNotificationToMobile) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<hmi::OnButtonEventNotification>(message); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnButtonEventID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnNaviTBTClientSendNotificationToMobile) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnNaviTBTClientStateNotification>(message); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnTBTClientStateID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnNaviWayPointChangeSendNotificationToMobile) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnNaviWayPointChangeNotification>(message); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnWayPointChangeID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnUICommandSendNotificationToMobile) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnUICommandNotification>(message); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(mobile_apis::TriggerSource::TS_MENU), - (*message)[am::strings::msg_params][am::strings::trigger_source].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnUIKeyBoardInputSendNotificationToMobile) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<hmi::OnUIKeyBoardInputNotification>(message); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnKeyboardInputID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnUITouchEventSendNotificationToMobile) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<hmi::OnUITouchEventNotification>(message); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnTouchEventID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnAppRegisteredNotificationSendNotificationToHmi) { - int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnAppRegisteredNotification>(message); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(_)); - EXPECT_CALL(app_mngr_, event_dispatcher()); - EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) - .WillOnce(GetEventId(&event_id)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>( - hmi_apis::FunctionID::BasicCommunication_OnAppRegistered), - event_id); - EXPECT_EQ( - kHmiProtocolType_, - (*message)[am::strings::params][am::strings::protocol_type].asInt()); - EXPECT_EQ( - kProtocolVersion_, - (*message)[am::strings::params][am::strings::protocol_version].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnAppUnregisteredNotificationEventDispatcher) { - int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnAppUnregisteredNotification>(message); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(_)); - EXPECT_CALL(app_mngr_, event_dispatcher()); - EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) - .WillOnce(GetEventId(&event_id)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>( - hmi_apis::FunctionID::BasicCommunication_OnAppUnregistered), - event_id); - EXPECT_EQ( - kHmiProtocolType_, - (*message)[am::strings::params][am::strings::protocol_type].asInt()); - EXPECT_EQ( - kProtocolVersion_, - (*message)[am::strings::params][am::strings::protocol_version].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnButtonPressNotificationEventDispatcher) { - int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<hmi::OnButtonPressNotification>(message); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - EXPECT_CALL(app_mngr_, event_dispatcher()); - EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) - .WillOnce(GetEventId(&event_id)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(hmi_apis::FunctionID::Buttons_OnButtonPress), - event_id); - EXPECT_EQ(static_cast<int>(mobile_apis::FunctionID::eType::OnButtonPressID), - (*message)[am::strings::params][am::strings::function_id].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnReadyNotificationEventDispatcher) { - int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnReadyNotification>(message); - - EXPECT_CALL(app_mngr_, OnHMIStartedCooperation()); - EXPECT_CALL(app_mngr_, event_dispatcher()); - EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) - .WillOnce(GetEventId(&event_id)); - command->Run(); - EXPECT_EQ(hmi_apis::FunctionID::BasicCommunication_OnReady, event_id); -} - -// policy handler -TEST_F(HMICommandsNotificationsTest, - OnIgnitionCycleOverNotificationPolicyHandler) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnIgnitionCycleOverNotification>(message); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, OnIgnitionCycleOver()); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, OnPolicyUpdateNotificationPolicyHandler) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = CreateCommand<OnPolicyUpdate>(message); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, OnPTExchangeNeeded()); - command->Run(); -} - -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) -TEST_F(HMICommandsNotificationsTest, - OnReceivePolicyUpdateNotification_SUCCESS) { - const std::string kFile = "./test_file.txt"; - EXPECT_TRUE(file_system::CreateFile(kFile)); - uint8_t tmp[] = {1u, 2u, 3u, 4u}; - std::vector<uint8_t> data(tmp, tmp + 4); - EXPECT_TRUE(file_system::WriteBinaryFile(kFile, data)); - - MessageSharedPtr message = CreateMessage(smart_objects::SmartType_String); - (*message)[am::strings::msg_params][am::hmi_notification::policyfile] = kFile; - utils::SharedPtr<Command> command = - CreateCommand<OnReceivedPolicyUpdate>(message); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, ReceiveMessageFromSDK(kFile, data)); - command->Run(); - EXPECT_TRUE(file_system::DeleteFile(kFile)); -} -#endif - -TEST_F(HMICommandsNotificationsTest, - OnReceivePolicyUpdateNotification_UNSUCCESS) { - MessageSharedPtr message = CreateMessage(smart_objects::SmartType_String); - utils::SharedPtr<Command> command = - CreateCommand<OnReceivedPolicyUpdate>(message); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(0); - EXPECT_CALL(policy_interface_, ReceiveMessageFromSDK(_, _)).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnAppPermissionConsentNotificationPolicyHandlerNoAppId) { - MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); - (*message)[am::strings::msg_params]["consentedFunctions"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - SmartObject& applications = - (*message)[am::strings::msg_params]["consentedFunctions"]; - - smart_objects::SmartObject hmi_application_temp(smart_objects::SmartType_Map); - applications[0] = hmi_application_temp; - - utils::SharedPtr<Command> command = - CreateCommand<OnAppPermissionConsentNotification>(message); - - int32_t connection_id = -1; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); -#ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _, _)) -#else - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _)) -#endif - .WillOnce(GetArg(&connection_id)); - command->Run(); - EXPECT_EQ(0, connection_id); -} - -TEST_F(HMICommandsNotificationsTest, - OnAppPermissionConsentNotificationPolicyHandlerWithAppId) { - MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - (*message)[am::strings::msg_params]["consentedFunctions"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - smart_objects::SmartObjectSPtr consented_function = - utils::MakeShared<smart_objects::SmartObject>(); - (*message)[am::strings::msg_params]["consentedFunctions"][0] = - *consented_function; - - utils::SharedPtr<Command> command = - CreateCommand<OnAppPermissionConsentNotification>(message); - - int32_t connection_id = -1; - policy::PermissionConsent permission_consent; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); -#ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _, _)) -#else - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _)) -#endif - .WillOnce( - GetConnectIdPermissionConsent(&connection_id, &permission_consent)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(kAppId_), connection_id); - std::vector<policy::FunctionalGroupPermission>::const_iterator it = - permission_consent.group_permissions.begin(); - for (; it != permission_consent.group_permissions.end(); ++it) { - EXPECT_EQ(policy::kGroupUndefined, (*it).state); - } -} - -TEST_F(HMICommandsNotificationsTest, - OnAppPermissionConsentNotificationPolicyHandlerAppIdAllowTrue) { - MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); - (*message)[am::strings::msg_params]["consentedFunctions"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - (*message)[am::strings::msg_params]["source"] = "test_content_source"; - - smart_objects::SmartObjectSPtr consented_function = - utils::MakeShared<smart_objects::SmartObject>(); - (*consented_function)["allowed"] = true; - (*consented_function)[am::strings::id] = 999; - (*consented_function)[am::strings::name] = "test_group_alias"; - (*message)[am::strings::msg_params]["consentedFunctions"][0] = - *consented_function; - - utils::SharedPtr<Command> command = - CreateCommand<OnAppPermissionConsentNotification>(message); - - int32_t connection_id = -1; - policy::PermissionConsent permission_consent; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); -#ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _, _)) -#else - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _)) -#endif - .WillOnce( - GetConnectIdPermissionConsent(&connection_id, &permission_consent)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(kAppId_), connection_id); - - std::vector<policy::FunctionalGroupPermission>::const_iterator it = - permission_consent.group_permissions.begin(); - for (; it != permission_consent.group_permissions.end(); ++it) { - EXPECT_EQ(999, (*it).group_id); - EXPECT_EQ("test_group_alias", (*it).group_alias); - EXPECT_EQ(policy::kGroupAllowed, (*it).state); - } - EXPECT_EQ("test_content_source", permission_consent.consent_source); -} - -TEST_F(HMICommandsNotificationsTest, - OnAppPermissionConsentNotificationPolicyHandlerAppIdAllowFalse) { - MessageSharedPtr message = CreateMessage(smart_objects::SmartType_Map); - (*message)[am::strings::msg_params]["consentedFunctions"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - (*message)[am::strings::msg_params]["source"] = "test_content_source"; - - smart_objects::SmartObjectSPtr consented_function = - utils::MakeShared<smart_objects::SmartObject>(); - (*consented_function)["allowed"] = false; - (*consented_function)[am::strings::id] = 999; - (*consented_function)[am::strings::name] = "test_group_alias"; - (*message)[am::strings::msg_params]["consentedFunctions"][0] = - *consented_function; - - utils::SharedPtr<Command> command = - CreateCommand<OnAppPermissionConsentNotification>(message); - - int32_t connection_id = -1; - policy::PermissionConsent permission_consent; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); -#ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _, _)) -#else - EXPECT_CALL(policy_interface_, OnAppPermissionConsent(_, _)) -#endif - .WillOnce( - GetConnectIdPermissionConsent(&connection_id, &permission_consent)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(kAppId_), connection_id); - - std::vector<policy::FunctionalGroupPermission>::const_iterator it = - permission_consent.group_permissions.begin(); - for (; it != permission_consent.group_permissions.end(); ++it) { - EXPECT_EQ(999, (*it).group_id); - EXPECT_EQ("test_group_alias", (*it).group_alias); - EXPECT_EQ(policy::kGroupDisallowed, (*it).state); - } - EXPECT_EQ("test_content_source", permission_consent.consent_source); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemErrorNotificationOnSystemErrorCode) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_notification::error] = - hmi_apis::Common_SystemError::SYNC_REBOOTED; - - utils::SharedPtr<Command> command = - CreateCommand<OnSystemErrorNotification>(message); - - int32_t code = hmi_apis::Common_SystemError::INVALID_ENUM; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, OnSystemError(_)).WillOnce(GetArg(&code)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(hmi_apis::Common_SystemError::SYNC_REBOOTED), - code); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemInfoChangedNotificationCheckLanguage) { - const uint32_t kLangCode = 5u; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = kLangCode; - - utils::SharedPtr<Command> command = - CreateCommand<OnSystemInfoChangedNotification>(message); - - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(_)); - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, OnSystemInfoChanged(_)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnAllowSDLFunctionalityNotificationDeviceKeyNotExist) { - const std::string kDeviceId = ""; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_response::allowed] = true; - utils::SharedPtr<Command> command = - CreateCommand<OnAllowSDLFunctionalityNotification>(message); - - bool value = false; - std::string str; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, OnAllowSDLFunctionalityNotification(_, _)) - .WillOnce(GetBoolValueAndString(&value, &str)); - command->Run(); - EXPECT_EQ(true, value); - EXPECT_EQ(kDeviceId, str); -} - -TEST_F(HMICommandsNotificationsTest, - OnAllowSDLFunctionalityNotificationDeviceKeyExist) { - const std::string kDeviceId = "device_id"; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_response::allowed] = true; - (*message)[am::strings::msg_params]["device"]["id"] = kDeviceId; - utils::SharedPtr<Command> command = - CreateCommand<OnAllowSDLFunctionalityNotification>(message); - - bool value; - std::string str; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, OnAllowSDLFunctionalityNotification(_, _)) - .WillOnce(GetBoolValueAndString(&value, &str)); - command->Run(); - EXPECT_EQ(true, value); - EXPECT_EQ(kDeviceId, str); -} - -TEST_F(HMICommandsNotificationsTest, - OnDeviceStateChangedNotificationDeviceStateNotUnpaired) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params]["deviceState"] = - hmi_apis::Common_DeviceState::INVALID_ENUM; - utils::SharedPtr<Command> command = - CreateCommand<OnDeviceStateChangedNotification>(message); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(0); - EXPECT_CALL(policy_interface_, RemoveDevice(_)).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnDeviceStateChangedNotificationDeviceStateUnpaired) { - // Random MAC adress for test. It must contain 12 symbols. - const std::string device_id = "AA15F2204D6B"; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params]["deviceState"] = - hmi_apis::Common_DeviceState::UNPAIRED; - (*message)[am::strings::msg_params]["deviceInternalId"] = device_id; - - utils::SharedPtr<Command> command = - CreateCommand<OnDeviceStateChangedNotification>(message); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, RemoveDevice(_)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnDeviceStateChangedNotificationDeviceStateEmptyDeviceId) { - const std::string empty_device_id = ""; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params]["deviceState"] = - hmi_apis::Common_DeviceState::UNPAIRED; - (*message)[am::strings::msg_params]["deviceInternalId"] = empty_device_id; - - utils::SharedPtr<Command> command = - CreateCommand<OnDeviceStateChangedNotification>(message); - - std::string device_id = "default_id"; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, RemoveDevice(_)).WillOnce(GetArg(&device_id)); - command->Run(); - EXPECT_EQ(empty_device_id, device_id); -} - -TEST_F(HMICommandsNotificationsTest, - OnDeviceStateChangedNotificationDeviceStateDeviceIdFromId) { - const std::string empty_device_id = ""; - const std::string id = "id_string"; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params]["deviceState"] = - hmi_apis::Common_DeviceState::UNPAIRED; - (*message)[am::strings::msg_params]["deviceInternalId"] = empty_device_id; - (*message)[am::strings::msg_params]["deviceId"]["id"] = id; - - utils::SharedPtr<Command> command = - CreateCommand<OnDeviceStateChangedNotification>(message); - - std::string device_id = "default_id"; - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, RemoveDevice(_)).WillOnce(GetArg(&device_id)); - command->Run(); - EXPECT_EQ(id, device_id); -} - -//~policy_handler -TEST_F(HMICommandsNotificationsTest, - OnExitAllApplicationsNotificationReasonIgnitionOff) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_request::reason] = - hmi_apis::Common_ApplicationsCloseReason::IGNITION_OFF; - - utils::SharedPtr<Command> command = - CreateCommand<OnExitAllApplicationsNotification>(message); -#if defined(OS_POSIX) - am::mobile_api::AppInterfaceUnregisteredReason::eType mob_reason; - - EXPECT_CALL(app_mngr_, SetUnregisterAllApplicationsReason(_)) - .WillOnce(GetArg(&mob_reason)); - EXPECT_CALL(app_mngr_, HeadUnitReset(_)).Times(0); - - SubscribeForSignal(); - command->Run(); - utils::WaitTerminationSignals(sig_handler); - - EXPECT_EQ(am::mobile_api::AppInterfaceUnregisteredReason::IGNITION_OFF, - mob_reason); -#endif -} - -TEST_F(HMICommandsNotificationsTest, - OnExitAllApplicationsNotificationReasonMasterResetAndFactoryDefaults) { - MessageSharedPtr message = CreateMessage(); - - std::vector<hmi_apis::Common_ApplicationsCloseReason::eType> reason_list; - reason_list.push_back(hmi_apis::Common_ApplicationsCloseReason::MASTER_RESET); - reason_list.push_back( - hmi_apis::Common_ApplicationsCloseReason::FACTORY_DEFAULTS); - - std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType> - mob_reason_list; - mob_reason_list.push_back( - mobile_apis::AppInterfaceUnregisteredReason::MASTER_RESET); - mob_reason_list.push_back( - mobile_apis::AppInterfaceUnregisteredReason::FACTORY_DEFAULTS); - - std::vector<hmi_apis::Common_ApplicationsCloseReason::eType>::iterator - it_reason = reason_list.begin(); - std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType>::iterator - it_mob_reason = mob_reason_list.begin(); - - for (; it_reason != reason_list.end(); ++it_reason, ++it_mob_reason) { - (*message)[am::strings::msg_params][am::hmi_request::reason] = *it_reason; - - utils::SharedPtr<Command> command = - CreateCommand<OnExitAllApplicationsNotification>(message); -#if defined(OS_POSIX) - am::mobile_api::AppInterfaceUnregisteredReason::eType mob_reason = - *it_mob_reason; - - EXPECT_CALL(app_mngr_, SetUnregisterAllApplicationsReason(mob_reason)); - EXPECT_CALL(app_mngr_, HeadUnitReset(mob_reason)); - - SubscribeForSignal(); - command->Run(); - utils::WaitTerminationSignals(sig_handler); -#endif - } -} - -TEST_F(HMICommandsNotificationsTest, - OnExitAllApplicationsNotificationReasonSuspend) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_request::reason] = - hmi_apis::Common_ApplicationsCloseReason::SUSPEND; - - utils::SharedPtr<Command> command = - CreateCommand<OnExitAllApplicationsNotification>(message); - - MessageSharedPtr ethalon_message = - CreateMessage(smart_objects::SmartType_Map); - (*ethalon_message)[am::strings::params][am::strings::function_id] = - hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete; - (*ethalon_message)[am::strings::params][am::strings::message_type] = - am::MessageType::kNotification; - (*ethalon_message)[am::strings::params][am::strings::correlation_id] = - kCorrelationId_; - MessageSharedPtr temp_message = CreateMessage(); - - resumprion_test::MockResumeCtrl mock_resume_ctrl; - EXPECT_CALL(app_mngr_, resume_controller()) - .WillOnce(ReturnRef(mock_resume_ctrl)); - EXPECT_CALL(mock_resume_ctrl, OnSuspend()); - - EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) - .WillOnce(Return(kCorrelationId_)); - EXPECT_CALL(app_mngr_, ManageHMICommand(_)) - .WillOnce(GetMessage(temp_message)); - - command->Run(); - EXPECT_EQ( - static_cast<uint32_t>( - hmi_apis::FunctionID::BasicCommunication_OnSDLPersistenceComplete), - (*temp_message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<uint32_t>(am::MessageType::kNotification), - (*temp_message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ(static_cast<uint32_t>(kCorrelationId_), - (*temp_message)[am::strings::params][am::strings::correlation_id] - .asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnExitAllApplicationsNotificationReasonInvalidEnum) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_request::reason] = - hmi_apis::Common_ApplicationsCloseReason::INVALID_ENUM; - - utils::SharedPtr<Command> command = - CreateCommand<OnExitAllApplicationsNotification>(message); - - EXPECT_CALL(app_mngr_, SetUnregisterAllApplicationsReason(_)).Times(0); - EXPECT_CALL(app_mngr_, HeadUnitReset(_)).Times(0); - EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()).Times(0); - EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnExitApplicationNotificationManageMobileCommand) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - smart_objects::SmartObjectSPtr notification = - utils::MakeShared<smart_objects::SmartObject>(); - (*notification)[am::strings::params][am::strings::function_id] = - static_cast<int32_t>( - mobile_apis::FunctionID::OnAppInterfaceUnregisteredID); - (*notification)[am::strings::params][am::strings::message_type] = - static_cast<int32_t>(am::MessageType::kNotification); - (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; - - std::vector<hmi_apis::Common_ApplicationExitReason::eType> reason_list; - reason_list.push_back(hmi_apis::Common_ApplicationExitReason:: - UNAUTHORIZED_TRANSPORT_REGISTRATION); - reason_list.push_back( - hmi_apis::Common_ApplicationExitReason::UNSUPPORTED_HMI_RESOURCE); - - std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType> - mobile_reason_list; - mobile_reason_list.push_back( - mobile_apis::AppInterfaceUnregisteredReason::APP_UNAUTHORIZED); - mobile_reason_list.push_back( - mobile_apis::AppInterfaceUnregisteredReason::UNSUPPORTED_HMI_RESOURCE); - - std::vector<mobile_apis::AppInterfaceUnregisteredReason::eType>::iterator - it_mobile_reason = mobile_reason_list.begin(); - std::vector<hmi_apis::Common_ApplicationExitReason::eType>::iterator - it_reason = reason_list.begin(); - - for (; it_reason != reason_list.end(); ++it_reason, ++it_mobile_reason) { - (*message)[am::strings::msg_params][am::strings::reason] = *it_reason; - utils::SharedPtr<Command> command = - CreateCommand<OnExitApplicationNotification>(message); - - (*notification)[am::strings::msg_params][am::strings::reason] = - static_cast<int32_t>(*it_mobile_reason); - -#ifdef SDL_REMOTE_CONTROL - functional_modules::PluginManager plugin_mng; - EXPECT_CALL(app_mngr_, GetPluginManager()) - .WillRepeatedly(ReturnRef(plugin_mng)); -#endif // SDL_REMOTE_CONTROL - - EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_)); - EXPECT_CALL(mock_message_helper_, - GetOnAppInterfaceUnregisteredNotificationToMobile( - kAppId_, *it_mobile_reason)).WillOnce(Return(notification)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(notification, Command::ORIGIN_SDL)); - EXPECT_CALL(app_mngr_, - UnregisterApplication( - kAppId_, mobile_apis::Result::SUCCESS, false, false)); - command->Run(); - } -} - -TEST_F(HMICommandsNotificationsTest, - OnExitApplicationNotificationUnhandledReason) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - - (*message)[am::strings::msg_params][am::strings::reason] = - hmi_apis::Common_ApplicationExitReason::INVALID_ENUM; - - utils::SharedPtr<Command> command = - CreateCommand<OnExitApplicationNotification>(message); - -#ifdef SDL_REMOTE_CONTROL - functional_modules::PluginManager plugin_mng; - EXPECT_CALL(app_mngr_, GetPluginManager()) - .WillRepeatedly(ReturnRef(plugin_mng)); -#endif // SDL_REMOTE_CONTROL - - EXPECT_CALL(app_mngr_, application(_)).Times(0); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0); - EXPECT_CALL(app_mngr_, state_controller()).Times(0); - EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(app_)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, OnExitApplicationNotificationInvalidApp) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - - utils::SharedPtr<Command> command = - CreateCommand<OnExitApplicationNotification>(message); - - am::ApplicationSharedPtr invalid_app; - EXPECT_CALL(app_mngr_, application(_)).Times(0); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0); - EXPECT_CALL(app_mngr_, state_controller()).Times(0); - EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(invalid_app)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - DISABLED_OnExitApplicationNotificationDriverDistractionValidApp) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - (*message)[am::strings::msg_params][am::strings::reason] = - hmi_apis::Common_ApplicationExitReason::DRIVER_DISTRACTION_VIOLATION; - utils::SharedPtr<Command> command = - CreateCommand<OnExitApplicationNotification>(message); - - EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_)); - - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - SetRegularState(app_, - mobile_apis::HMILevel::HMI_NONE, - mobile_apis::AudioStreamingState::NOT_AUDIBLE, - false)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnExitApplicationNotificationrUserExitValidApp) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - (*message)[am::strings::msg_params][am::strings::reason] = - hmi_apis::Common_ApplicationExitReason::USER_EXIT; - utils::SharedPtr<Command> command = - CreateCommand<OnExitApplicationNotification>(message); - -#ifdef SDL_REMOTE_CONTROL - functional_modules::PluginManager plugin_mng; - EXPECT_CALL(app_mngr_, GetPluginManager()) - .WillRepeatedly(ReturnRef(plugin_mng)); -#endif // SDL_REMOTE_CONTROL - - EXPECT_CALL(app_mngr_, application(kAppId_)).WillRepeatedly(Return(app_)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(app_mngr_, UnregisterApplication(_, _, _, _)).Times(0); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - SetRegularState(app_, - mobile_apis::HMILevel::HMI_NONE, - mobile_apis::AudioStreamingState::NOT_AUDIBLE, - false)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRCommandNotificationSwitchedAndValidApp) { - const uint32_t cmd_id = 12u; - const uint32_t max_cmd_id = 10u; - - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::cmd_id] = cmd_id; - utils::SharedPtr<Command> command = - CreateCommand<OnVRCommandNotification>(message); - - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(app_)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - SetRegularState(_, mobile_apis::HMILevel::HMI_FULL, true)); - - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(max_cmd_id)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRCommandNotificationSwitchedAndInvalidApp) { - const uint32_t kCmdId = 12u; - const uint32_t kMaxCmdId = 10u; - - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; - utils::SharedPtr<Command> command = - CreateCommand<OnVRCommandNotification>(message); - - am::ApplicationSharedPtr invalid_app; - EXPECT_CALL(app_mngr_, application(_)).WillRepeatedly(Return(invalid_app)); - EXPECT_CALL(app_mngr_, state_controller()).Times(0); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRCommandNotificationCmdIdEqualToMaxCmdId) { - const uint32_t kCmdId = 11u; - const uint32_t kMaxCmdId = 10u; - - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; - utils::SharedPtr<Command> command = - CreateCommand<OnVRCommandNotification>(message); - - EXPECT_CALL(app_mngr_, application(_)).Times(0); - EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRCommandNotificationCmdIdLessMaxCmdIsInvalidApp) { - const uint32_t kCmdId = 8u; - const uint32_t kMaxCmdId = 10u; - - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; - utils::SharedPtr<Command> command = - CreateCommand<OnVRCommandNotification>(message); - - am::ApplicationSharedPtr invalid_app; - EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(invalid_app)); - EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - EXPECT_CALL(app_mngr_, event_dispatcher()).Times(0); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRCommandNotificationActivePerformIteraction) { - const uint32_t kCmdId = 8u; - const uint32_t kMaxCmdId = 10u; - const uint32_t kIsPerformInteractionActive = 1u; - int32_t event_id = hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; - utils::SharedPtr<Command> command = - CreateCommand<OnVRCommandNotification>(message); - - EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); - EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - EXPECT_CALL(*app_ptr_, is_perform_interaction_active()) - .WillOnce(Return(kIsPerformInteractionActive)); - EXPECT_CALL(app_mngr_, event_dispatcher()); - EXPECT_CALL(mock_event_dispatcher_, raise_event(_)) - .WillOnce(GetEventId(&event_id)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - command->Run(); - EXPECT_EQ(hmi_apis::FunctionID::VR_OnCommand, event_id); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRCommandNotificationNotActivePerformIteraction) { - const uint32_t kCmdId = 8u; - const uint32_t kMaxCmdId = 10u; - const uint32_t kIsPerformInteractionActive = 0u; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::cmd_id] = kCmdId; - (*message)[am::strings::msg_params][am::strings::function_id] = - mobile_apis::FunctionID::eType::OnCommandID; - utils::SharedPtr<Command> command = - CreateCommand<OnVRCommandNotification>(message); - - EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); - EXPECT_CALL(app_mngr_settings_, max_cmd_id()).WillOnce(ReturnRef(kMaxCmdId)); - EXPECT_CALL(app_mngr_, get_settings()) - .WillOnce(ReturnRef(app_mngr_settings_)); - EXPECT_CALL(*app_ptr_, is_perform_interaction_active()) - .WillOnce(Return(kIsPerformInteractionActive)); - - EXPECT_CALL(app_mngr_, event_dispatcher()).Times(0); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::eType::OnCommandID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(mobile_apis::TriggerSource::TS_VR), - (*message)[am::strings::msg_params][am::strings::trigger_source].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnVRLanguageChangeNotificationEmptyData) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = kLang; - utils::SharedPtr<Command> command = - CreateCommand<OnVRLanguageChangeNotification>(message); - - EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(*app_ptr_, app_id()).Times(0); - EXPECT_CALL(*app_ptr_, language()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRLanguageChangeNotificationAppLangEqualMessageLang) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = kLang; - utils::SharedPtr<Command> command = - CreateCommand<OnVRLanguageChangeNotification>(message); - - application_set_.insert(app_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); - EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); - - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), - (*message)[am::strings::msg_params][am::strings::hmi_display_language] - .asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnVRLanguageChangeNotificationAppLangNotEqualMessageLang) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = - mobile_apis::Language::EN_US; - utils::SharedPtr<Command> command = - CreateCommand<OnVRLanguageChangeNotification>(message); - - application_set_.insert(app_); - smart_objects::SmartObjectSPtr notification = - utils::MakeShared<smart_objects::SmartObject>(); - (*notification)[am::strings::params][am::strings::function_id] = - static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); - (*notification)[am::strings::params][am::strings::message_type] = - static_cast<int32_t>(am::MessageType::kNotification); - (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; - (*notification)[am::strings::msg_params][am::strings::reason] = - static_cast<int32_t>( - mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); - - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); - EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, false)); - EXPECT_CALL(mock_message_helper_, - GetOnAppInterfaceUnregisteredNotificationToMobile( - kAppId_, - mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE)) - .WillOnce(Return(notification)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(notification, Command::ORIGIN_SDL)); - EXPECT_CALL(app_mngr_, - UnregisterApplication( - kAppId_, mobile_apis::Result::SUCCESS, false, false)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), - (*message)[am::strings::msg_params][am::strings::hmi_display_language] - .asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnStartDeviceDiscoveryRun) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnStartDeviceDiscovery>(message); - EXPECT_CALL(app_mngr_, StartDevicesDiscovery()); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnDeviceChosenNotificationDeviceInfoExists) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::device_info] - [am::strings::id] = "2014"; - utils::SharedPtr<Command> command = - CreateCommand<OnDeviceChosenNotification>(message); - EXPECT_CALL(app_mngr_, - ConnectToDevice( - (*message)[am::strings::msg_params][am::strings::device_info] - [am::strings::id].asString())); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnDeviceChosenNotificationDeviceInfoNotExists) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnDeviceChosenNotification>(message); - EXPECT_CALL(app_mngr_, ConnectToDevice(_)).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemContextNotificationValidActiveApplication) { - MessageSharedPtr message = CreateMessage(); - std::vector<am::mobile_api::SystemContext::eType> system_context_list; - system_context_list.push_back( - am::mobile_api::SystemContext::SYSCTXT_VRSESSION); - system_context_list.push_back(am::mobile_api::SystemContext::SYSCTXT_MENU); - system_context_list.push_back( - am::mobile_api::SystemContext::SYSCTXT_HMI_OBSCURED); - - std::vector<am::mobile_api::SystemContext::eType>::iterator it = - system_context_list.begin(); - for (; it != system_context_list.end(); ++it) { - (*message)[am::strings::msg_params][am::hmi_notification::system_context] = - *it; - utils::SharedPtr<Command> command = - CreateCommand<OnSystemContextNotification>(message); - EXPECT_CALL(app_mngr_, active_application()).WillOnce(Return(app_)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); - command->Run(); - } -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemContextNotificationInvalidActiveApplication) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_notification::system_context] = - am::mobile_api::SystemContext::SYSCTXT_VRSESSION; - utils::SharedPtr<Command> command = - CreateCommand<OnSystemContextNotification>(message); - ApplicationSharedPtr invalid_app; - EXPECT_CALL(app_mngr_, active_application()).WillOnce(Return(invalid_app)); - EXPECT_CALL(app_mngr_, state_controller()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemContextNotificationInvalidSystemContext) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_notification::system_context] = - am::mobile_api::SystemContext::INVALID_ENUM; - utils::SharedPtr<Command> command = - CreateCommand<OnSystemContextNotification>(message); - EXPECT_CALL(app_mngr_, active_application()).Times(0); - EXPECT_CALL(app_mngr_, application(_)).Times(0); - EXPECT_CALL(app_mngr_, state_controller()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemContextNotificationValidApplication) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - std::vector<am::mobile_api::SystemContext::eType> system_context_list; - system_context_list.push_back(am::mobile_api::SystemContext::SYSCTXT_ALERT); - system_context_list.push_back(am::mobile_api::SystemContext::SYSCTXT_MAIN); - - std::vector<am::mobile_api::SystemContext::eType>::iterator it = - system_context_list.begin(); - for (; it != system_context_list.end(); ++it) { - (*message)[am::strings::msg_params][am::hmi_notification::system_context] = - *it; - utils::SharedPtr<Command> command = - CreateCommand<OnSystemContextNotification>(message); - EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, SetRegularState(app_, *it)); - command->Run(); - } -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemContextNotificationAppIdDoesntExists) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_notification::system_context] = - am::mobile_api::SystemContext::SYSCTXT_ALERT; - utils::SharedPtr<Command> command = - CreateCommand<OnSystemContextNotification>(message); - EXPECT_CALL(app_mngr_, application(_)).Times(0); - EXPECT_CALL(app_mngr_, state_controller()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemRequestNotificationAppIdExistsAndValidApp) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - utils::SharedPtr<Command> command = - CreateCommand<OnSystemRequestNotification>(message); - - EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(app_)); - ON_CALL(app_mngr_, connection_handler()) - .WillByDefault(ReturnRef(mock_connection_handler_)); - ON_CALL(mock_connection_handler_, get_session_observer()) - .WillByDefault(ReturnRef(mock_session_observer_)); - const int32_t device_id = 1; - ON_CALL( - mock_session_observer_, - GetDataOnDeviceID( - testing::An<transport_manager::DeviceHandle>(), NULL, NULL, _, NULL)) - .WillByDefault(Return(device_id)); - - EXPECT_CALL(policy_interface_, GetUserConsentForDevice(_)) - .WillOnce(Return(policy::kDeviceAllowed)); - - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemRequestNotificationAppIdExistsAndInvalidApp) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::app_id] = kAppId_; - utils::SharedPtr<Command> command = - CreateCommand<OnSystemRequestNotification>(message); - ApplicationSharedPtr invalid_app; - EXPECT_CALL(app_mngr_, application(kAppId_)).WillOnce(Return(invalid_app)); - EXPECT_CALL(*app_ptr_, app_id()).Times(0); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - command->Run(); - EXPECT_EQ( - static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID), - (*message)[am::strings::params][am::strings::function_id].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemRequestNotificationAppIdDoesntExistsAndValidApp) { - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnSystemRequestNotification>(message); - ON_CALL(app_mngr_, GetPolicyHandler()) - .WillByDefault(ReturnRef(policy_interface_)); - EXPECT_CALL(policy_interface_, GetAppIdForSending()) - .WillOnce(Return(kAppId_)); - EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app_)); - ON_CALL(app_mngr_, connection_handler()) - .WillByDefault(ReturnRef(mock_connection_handler_)); - ON_CALL(mock_connection_handler_, get_session_observer()) - .WillByDefault(ReturnRef(mock_session_observer_)); - const int32_t device_id = 1; - ON_CALL( - mock_session_observer_, - GetDataOnDeviceID( - testing::An<transport_manager::DeviceHandle>(), NULL, NULL, _, NULL)) - .WillByDefault(Return(device_id)); - - EXPECT_CALL(policy_interface_, GetUserConsentForDevice(_)) - .WillOnce(Return(policy::kDeviceAllowed)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(mobile_apis::FunctionID::eType::OnSystemRequestID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnSystemRequestNotificationAppIdDoesntExistsAndNullAppId) { - const uint32_t kNullApppId = 0u; - MessageSharedPtr message = CreateMessage(); - utils::SharedPtr<Command> command = - CreateCommand<OnSystemRequestNotification>(message); - EXPECT_CALL(app_mngr_, GetPolicyHandler()); - EXPECT_CALL(policy_interface_, GetAppIdForSending()) - .WillOnce(Return(kNullApppId)); - EXPECT_CALL(app_mngr_, application(_)).Times(0); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, OnTTSLanguageChangeNotificationEmptyData) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = kLang; - utils::SharedPtr<Command> command = - CreateCommand<OnTTSLanguageChangeNotification>(message); - - EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); - EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(*app_ptr_, app_id()).Times(0); - EXPECT_CALL(*app_ptr_, language()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnTTSLanguageChangeNotificationAppLangEqualMessageLang) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = kLang; - utils::SharedPtr<Command> command = - CreateCommand<OnTTSLanguageChangeNotification>(message); - - application_set_.insert(app_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); - EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); - - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), - (*message)[am::strings::msg_params][am::strings::hmi_display_language] - .asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnTTSLanguageChangeNotificationAppLangNotEqualMessageLang) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = - mobile_apis::Language::EN_US; - utils::SharedPtr<Command> command = - CreateCommand<OnTTSLanguageChangeNotification>(message); - - application_set_.insert(app_); - smart_objects::SmartObjectSPtr notification = - utils::MakeShared<smart_objects::SmartObject>(); - (*notification)[am::strings::params][am::strings::function_id] = - static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); - (*notification)[am::strings::params][am::strings::message_type] = - static_cast<int32_t>(am::MessageType::kNotification); - (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; - (*notification)[am::strings::msg_params][am::strings::reason] = - static_cast<int32_t>( - mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); - - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(mock_hmi_capabilities_, active_ui_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_vr_language(_)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_tts_language(_)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); - EXPECT_CALL(*app_ptr_, language()).WillRepeatedly(ReturnRef(kLang)); - EXPECT_CALL(mock_message_helper_, - GetOnAppInterfaceUnregisteredNotificationToMobile( - kAppId_, - mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE)) - .WillOnce(Return(notification)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(notification, Command::ORIGIN_SDL)); - EXPECT_CALL(app_mngr_, - UnregisterApplication( - kAppId_, mobile_apis::Result::SUCCESS, false, false)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(hmi_apis::Common_Language::EN_AU), - (*message)[am::strings::msg_params][am::strings::hmi_display_language] - .asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnUILanguageChangeNotificationEmptyData) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = kLang; - utils::SharedPtr<Command> command = - CreateCommand<OnUILanguageChangeNotification>(message); - - EXPECT_CALL(mock_hmi_capabilities_, set_active_ui_language(_)); - EXPECT_CALL(mock_hmi_capabilities_, active_vr_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(*app_ptr_, app_id()).Times(0); - EXPECT_CALL(*app_ptr_, ui_language()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnUILanguageChangeNotificationAppLangEqualMessageLang) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = kLang; - utils::SharedPtr<Command> command = - CreateCommand<OnUILanguageChangeNotification>(message); - - application_set_.insert(app_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(mock_hmi_capabilities_, active_vr_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_ui_language(_)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - EXPECT_CALL(*app_ptr_, app_id()).WillOnce(Return(kAppId_)); - EXPECT_CALL(*app_ptr_, ui_language()).WillRepeatedly(ReturnRef(kLang)); - - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kLang), - (*message)[am::strings::msg_params][am::strings::hmi_display_language] - .asInt()); -} - -TEST_F(HMICommandsNotificationsTest, - OnUILanguageChangeNotificationAppLangNotEqualMessageLang) { - const mobile_apis::Language::eType& kLang = mobile_apis::Language::EN_GB; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::language] = - mobile_apis::Language::EN_US; - utils::SharedPtr<Command> command = - CreateCommand<OnUILanguageChangeNotification>(message); - - application_set_.insert(app_); - smart_objects::SmartObjectSPtr notification = - utils::MakeShared<smart_objects::SmartObject>(); - (*notification)[am::strings::params][am::strings::function_id] = - static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID); - (*notification)[am::strings::params][am::strings::message_type] = - static_cast<int32_t>(am::MessageType::kNotification); - (*notification)[am::strings::params][am::strings::connection_key] = kAppId_; - (*notification)[am::strings::msg_params][am::strings::reason] = - static_cast<int32_t>( - mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE); - - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - EXPECT_CALL(mock_hmi_capabilities_, active_vr_language()) - .WillOnce(Return(hmi_apis::Common_Language::EN_AU)); - EXPECT_CALL(mock_hmi_capabilities_, set_active_ui_language(_)); - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)); - EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); - EXPECT_CALL(*app_ptr_, ui_language()).WillRepeatedly(ReturnRef(kLang)); - EXPECT_CALL(mock_message_helper_, - GetOnAppInterfaceUnregisteredNotificationToMobile( - kAppId_, - mobile_apis::AppInterfaceUnregisteredReason::LANGUAGE_CHANGE)) - .WillOnce(Return(notification)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(notification, Command::ORIGIN_SDL)); - EXPECT_CALL(app_mngr_, - UnregisterApplication( - kAppId_, mobile_apis::Result::SUCCESS, false, false)); - command->Run(); - EXPECT_EQ(static_cast<int32_t>(mobile_apis::FunctionID::OnLanguageChangeID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); - EXPECT_EQ( - static_cast<int32_t>(mobile_apis::Language::EN_US), - (*message)[am::strings::msg_params][am::strings::hmi_display_language] - .asInt()); -} - -TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationEmptyData) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_notification::state] = state; - utils::SharedPtr<Command> command = - CreateCommand<hmi::OnDriverDistractionNotification>(message); - - EXPECT_CALL(app_mngr_, set_driver_distraction_state(state)); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(*app_ptr_, app_id()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, - OnDriverDistractionNotificationInvalidApp) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::hmi_notification::state] = state; - utils::SharedPtr<Command> command = - CreateCommand<hmi::OnDriverDistractionNotification>(message); - - ApplicationSharedPtr invalid_app; - application_set_.insert(invalid_app); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - - EXPECT_CALL(app_mngr_, ManageMobileCommand(_, _)).Times(0); - EXPECT_CALL(*app_ptr_, app_id()).Times(0); - command->Run(); -} - -TEST_F(HMICommandsNotificationsTest, OnDriverDistractionNotificationValidApp) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::mobile_notification::state] = state; - utils::SharedPtr<Command> command = - CreateCommand<hmi::OnDriverDistractionNotification>(message); - - application_set_.insert(app_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(applications_)); - policy::CheckPermissionResult result; - result.hmi_level_permitted = policy::kRpcAllowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_interface_)); - EXPECT_CALL(policy_interface_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand(_, Command::CommandOrigin::ORIGIN_SDL)) - .WillOnce(GetMessage(message)); - EXPECT_CALL(*app_ptr_, app_id()).WillRepeatedly(Return(kAppId_)); - - command->Run(); - EXPECT_EQ( - static_cast<int32_t>(am::mobile_api::FunctionID::OnDriverDistractionID), - (*message)[am::strings::params][am::strings::function_id].asInt()); - EXPECT_EQ( - static_cast<int32_t>(kAppId_), - (*message)[am::strings::params][am::strings::connection_key].asInt()); - EXPECT_EQ(static_cast<int32_t>(am::MessageType::kNotification), - (*message)[am::strings::params][am::strings::message_type].asInt()); -} - -} // namespace hmi_notifications_test -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/mixing_audio_supported_request_test.cc b/src/components/application_manager/test/commands/hmi/mixing_audio_supported_request_test.cc deleted file mode 100644 index 322f7dd398..0000000000 --- a/src/components/application_manager/test/commands/hmi/mixing_audio_supported_request_test.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "commands/command_request_test.h" -#include "hmi/request_to_hmi.h" -#include "application_manager/commands/hmi/mixing_audio_supported_request.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace mixing_audio_supported_request { - -using ::testing::_; -using ::testing::Return; -using ::utils::SharedPtr; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::RequestToHMI; -using am::commands::MixingAudioSupportedRequest; -using am::commands::CommandImpl; - -typedef SharedPtr<RequestToHMI> RequestToHMIPtr; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class MixingAudioSupportedRequestTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(MixingAudioSupportedRequestTest, RUN_SendRequest_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[am::strings::msg_params][am::strings::number] = "123"; - (*command_msg)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - - RequestToHMIPtr command( - CreateCommand<MixingAudioSupportedRequest>(command_msg)); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(command_msg)); - - command->Run(); - - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); -} - -} // namespace mixing_audio_supported_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/mixing_audio_supported_response_test.cc b/src/components/application_manager/test/commands/hmi/mixing_audio_supported_response_test.cc deleted file mode 100644 index 89ba6c8bdb..0000000000 --- a/src/components/application_manager/test/commands/hmi/mixing_audio_supported_response_test.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2016, 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 "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.h" -#include "commands/commands_test.h" -#include "commands/command_request_test.h" -#include "application_manager/commands/hmi/response_from_hmi.h" -#include "interfaces/HMI_API.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/commands/hmi/mixing_audio_supported_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace mixing_audio_supported_response { - -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::NiceMock; -using ::utils::SharedPtr; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::ResponseFromHMI; -using am::commands::MixingAudioSupportedResponse; -using am::commands::CommandImpl; -using am::HMICapabilities; -namespace hmi_response = ::application_manager::hmi_response; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class MixingAudioSupportedResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(MixingAudioSupportedResponseTest, RUN_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[am::strings::msg_params][am::strings::number] = "123"; - (*command_msg)[am::strings::params][am::strings::connection_key] = - kConnectionKey; - - ResponseFromHMIPtr command( - CreateCommand<MixingAudioSupportedResponse>(command_msg)); - MockHMICapabilities mock_hmi_capabilities; - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - - const bool hmiResponse = - (*command_msg)[strings::msg_params][hmi_response::attenuated_supported] - .asBool(); - - EXPECT_CALL(mock_hmi_capabilities, set_attenuated_supported(hmiResponse)); - - command->Run(); -} - -} // namespace mixing_audio_supported_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc deleted file mode 100644 index c187cc75d9..0000000000 --- a/src/components/application_manager/test/commands/hmi/navi_audio_start_stream_request_test.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2016, 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 <utility> - -#include "application_manager/commands/hmi/navi_audio_start_stream_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" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace navi_audio_start_stream_request { - -using ::testing::_; -using ::testing::ReturnRef; -namespace am = ::application_manager; -namespace commands = am::commands; -using commands::MessageSharedPtr; -using commands::AudioStartStreamRequest; -using am::event_engine::Event; - -namespace { -const uint32_t kHmiAppId = 13u; -const am::HmiInterfaces::InterfaceID kHmiInterface = - am::HmiInterfaces::HMI_INTERFACE_Navigation; -} // namespace - -class AudioStartStreamRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - AudioStartStreamRequestTest() { - ON_CALL(app_mngr_settings_, start_stream_retry_amount()) - .WillByDefault(ReturnRef(start_stream_retry_amount_)); - msg_ = CreateMessage(); - command_ = CreateCommand<AudioStartStreamRequest>(msg_); - } - - std::pair<uint32_t, int32_t> start_stream_retry_amount_; - MessageSharedPtr msg_; - SharedPtr<AudioStartStreamRequest> command_; -}; - -TEST_F(AudioStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) { - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0); - - command_->Run(); -} - -TEST_F(AudioStartStreamRequestTest, - Run_HmiInterfaceAvailableButNoApp_NoRequest) { - (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); - - EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) - .WillOnce(Return(ApplicationSharedPtr())); - EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0); - - command_->Run(); -} - -TEST_F(AudioStartStreamRequestTest, Run_HmiInterfaceAvailable_SentRequest) { - (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); - - MockAppPtr mock_app = CreateMockApp(); - EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) - .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, set_audio_streaming_allowed(true)); - EXPECT_CALL(app_mngr_, SendMessageToHMI(msg_)); - - command_->Run(); -} - -} // namespace navi_audio_start_stream_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc deleted file mode 100644 index 825cca9185..0000000000 --- a/src/components/application_manager/test/commands/hmi/navi_is_ready_request_test.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/navi_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/event_engine/event.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace navi_is_ready_request { - -using ::testing::_; -using ::testing::ReturnRef; -namespace am = ::application_manager; -using am::commands::MessageSharedPtr; -using am::commands::NaviIsReadyRequest; -using am::event_engine::Event; - -namespace { -const hmi_apis::FunctionID::eType kEventID = - hmi_apis::FunctionID::Navigation_IsReady; -} // namespace - -typedef SharedPtr<NaviIsReadyRequest> NaviIsReadyRequestPtr; - -class NaviIsReadyRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - NaviIsReadyRequestTest() : command_(CreateCommand<NaviIsReadyRequest>()) { - ON_CALL(app_mngr_, hmi_capabilities()) - .WillByDefault(ReturnRef(mock_hmi_capabilities_)); - } - - NaviIsReadyRequestPtr command_; - MOCK(application_manager_test::MockHMICapabilities) mock_hmi_capabilities_; -}; - -TEST_F(NaviIsReadyRequestTest, - OnEvent_HmiInterfaceIsAvailable_NaviCooperatingIsAvailable) { - const bool is_hmi_interface_available = true; - - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[am::strings::msg_params][am::strings::available] = - is_hmi_interface_available; - - Event event(kEventID); - event.set_smart_object(*event_msg); - - EXPECT_CALL(mock_hmi_interfaces_, - SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation, - am::HmiInterfaces::STATE_AVAILABLE)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_is_navi_cooperating(is_hmi_interface_available)); - - command_->on_event(event); -} - -TEST_F(NaviIsReadyRequestTest, - OnEvent_HmiInterfaceIsNotAvailable_NaviCooperatingIsNotAvailable) { - const bool is_hmi_interface_available = false; - - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[am::strings::msg_params][am::strings::available] = - is_hmi_interface_available; - - Event event(kEventID); - event.set_smart_object(*event_msg); - - EXPECT_CALL(mock_hmi_interfaces_, - SetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_Navigation, - am::HmiInterfaces::STATE_NOT_AVAILABLE)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_is_navi_cooperating(is_hmi_interface_available)); - - command_->on_event(event); -} - -TEST_F(NaviIsReadyRequestTest, - OnEvent_AvailabilityFieldMissing_NaviCooperatingIsNotAvailable) { - const bool is_hmi_interface_available = false; - - MessageSharedPtr event_msg = CreateMessage(); - Event event(kEventID); - event.set_smart_object(*event_msg); - - EXPECT_CALL(mock_hmi_capabilities_, - set_is_navi_cooperating(is_hmi_interface_available)); - - command_->on_event(event); -} - -} // namespace navi_is_ready_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/navi_is_ready_response_test.cc b/src/components/application_manager/test/commands/hmi/navi_is_ready_response_test.cc deleted file mode 100644 index 7185a5f7ed..0000000000 --- a/src/components/application_manager/test/commands/hmi/navi_is_ready_response_test.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_request_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/commands/hmi/navi_is_ready_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace navi_is_ready_responce { - -namespace am = ::application_manager; -namespace commands = am::commands; - -using ::testing::ReturnRef; -using ::utils::SharedPtr; -using commands::ResponseFromHMI; -using test::components::event_engine_test::MockEventDispatcher; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; - -class NaviIsReadyResponseTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(NaviIsReadyResponseTest, NaviIsReadyResponse_Run_SUCCESS) { - ResponseFromHMIPtr command(CreateCommand<commands::NaviIsReadyResponse>()); - 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 navi_is_ready_responce -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/navi_set_video_config_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_set_video_config_request_test.cc deleted file mode 100644 index 7c04aa724c..0000000000 --- a/src/components/application_manager/test/commands/hmi/navi_set_video_config_request_test.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (c) 2017 Xevo Inc. - * 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 names of the copyright holders 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 <algorithm> - -#include "application_manager/commands/hmi/navi_set_video_config_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/event_engine/event.h" -#include "application_manager/mock_event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace navi_set_video_config_request { - -using ::testing::_; -using ::testing::ReturnRef; -namespace am = ::application_manager; -using am::commands::MessageSharedPtr; -using am::commands::NaviSetVideoConfigRequest; -using am::event_engine::Event; - -namespace { -const uint32_t kAppId = 1u; -const uint32_t kHmiAppId = 13u; -const hmi_apis::FunctionID::eType kEventID = - hmi_apis::FunctionID::Navigation_SetVideoConfig; -} // namespace - -typedef SharedPtr<NaviSetVideoConfigRequest> NaviSetVideoConfigRequestPtr; - -class NaviSetVideoConfigRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - NaviSetVideoConfigRequestTest() { - mock_app_ptr_ = CreateMockApp(); - ON_CALL(app_mngr_, hmi_interfaces()) - .WillByDefault(ReturnRef(mock_hmi_interfaces_)); - ON_CALL(app_mngr_, application(_)).WillByDefault(Return(mock_app_ptr_)); - ON_CALL(app_mngr_, application_by_hmi_app(_)) - .WillByDefault(Return(mock_app_ptr_)); - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(mock_event_dispatcher_)); - ON_CALL(*mock_app_ptr_, app_id()).WillByDefault(Return(kAppId)); - ON_CALL(*mock_app_ptr_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); - } - - MOCK(am::MockHmiInterfaces) mock_hmi_interfaces_; - MockAppPtr mock_app_ptr_; - MockEventDispatcher mock_event_dispatcher_; -}; - -TEST_F(NaviSetVideoConfigRequestTest, OnEventWithSuccessResponse) { - MessageSharedPtr request_msg = CreateMessage(); - (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; - - NaviSetVideoConfigRequestPtr command = - CreateCommand<NaviSetVideoConfigRequest>(request_msg); - - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[am::strings::params][am::hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - Event event(kEventID); - event.set_smart_object(*event_msg); - - std::vector<std::string> empty; - EXPECT_CALL( - app_mngr_, - OnStreamingConfigured( - kAppId, protocol_handler::ServiceType::kMobileNav, true, empty)) - .Times(1); - - command->on_event(event); -} - -static bool ValidateList(std::vector<std::string>& expected, - std::vector<std::string>& actual) { - std::sort(expected.begin(), expected.end()); - std::sort(actual.begin(), actual.end()); - return std::equal(expected.begin(), expected.end(), actual.begin()); -} - -TEST_F(NaviSetVideoConfigRequestTest, OnEventWithRejectedResponse) { - MessageSharedPtr request_msg = CreateMessage(); - (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; - (*request_msg)[am::strings::msg_params][am::strings::config] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - (*request_msg)[am::strings::msg_params][am::strings::config] - [am::strings::protocol] = - hmi_apis::Common_VideoStreamingProtocol::RTP; - (*request_msg)[am::strings::msg_params][am::strings::config] - [am::strings::codec] = - hmi_apis::Common_VideoStreamingCodec::H265; - (*request_msg)[am::strings::msg_params][am::strings::config] - [am::strings::height] = 640; - (*request_msg)[am::strings::msg_params][am::strings::config] - [am::strings::width] = 480; - - NaviSetVideoConfigRequestPtr command = - CreateCommand<NaviSetVideoConfigRequest>(request_msg); - - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[am::strings::params][am::hmi_response::code] = - hmi_apis::Common_Result::REJECTED; - - (*event_msg)[am::strings::msg_params][am::strings::rejected_params] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - (*event_msg)[am::strings::msg_params][am::strings::rejected_params][0] = - "codec"; - (*event_msg)[am::strings::msg_params][am::strings::rejected_params][1] = - "protocol"; - Event event(kEventID); - event.set_smart_object(*event_msg); - - std::vector<std::string> rejected_params; - EXPECT_CALL(app_mngr_, - OnStreamingConfigured( - kAppId, protocol_handler::ServiceType::kMobileNav, false, _)) - .WillOnce(SaveArg<3>(&rejected_params)); - - command->on_event(event); - - ASSERT_EQ(2u, rejected_params.size()); - std::vector<std::string> expected_list; - expected_list.push_back(std::string("protocol")); - expected_list.push_back(std::string("codec")); - ASSERT_TRUE(ValidateList(expected_list, rejected_params)); -} - -TEST_F(NaviSetVideoConfigRequestTest, - OnEventWithRejectedResponseWithoutParams) { - MessageSharedPtr request_msg = CreateMessage(); - (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; - - NaviSetVideoConfigRequestPtr command = - CreateCommand<NaviSetVideoConfigRequest>(request_msg); - - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[am::strings::params][am::hmi_response::code] = - hmi_apis::Common_Result::REJECTED; - - Event event(kEventID); - event.set_smart_object(*event_msg); - - std::vector<std::string> empty; - EXPECT_CALL( - app_mngr_, - OnStreamingConfigured( - kAppId, protocol_handler::ServiceType::kMobileNav, false, empty)) - .WillOnce(Return()); - - command->on_event(event); -} - -TEST_F(NaviSetVideoConfigRequestTest, OnTimeout) { - MessageSharedPtr request_msg = CreateMessage(); - (*request_msg)[am::strings::msg_params][am::strings::app_id] = kAppId; - - NaviSetVideoConfigRequestPtr command = - CreateCommand<NaviSetVideoConfigRequest>(request_msg); - - std::vector<std::string> empty; - EXPECT_CALL( - app_mngr_, - OnStreamingConfigured( - kAppId, protocol_handler::ServiceType::kMobileNav, false, empty)) - .WillOnce(Return()); - - EXPECT_CALL(app_mngr_, TerminateRequest(_, _, _)).Times(1); - - command->onTimeOut(); -} - -} // namespace navi_set_video_config_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/navi_set_video_config_response_test.cc b/src/components/application_manager/test/commands/hmi/navi_set_video_config_response_test.cc deleted file mode 100644 index 753c2a9179..0000000000 --- a/src/components/application_manager/test/commands/hmi/navi_set_video_config_response_test.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2017 Xevo Inc. - * 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 names of the copyright holders 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 "application_manager/commands/commands_test.h" -#include "application_manager/commands/hmi/navi_set_video_config_response.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/smart_object_keys.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace navi_set_video_config_response { - -using utils::SharedPtr; -using application_manager::commands::NaviSetVideoConfigResponse; -using test::components::event_engine_test::MockEventDispatcher; -using testing::_; -using testing::ReturnRef; -using ::testing::NiceMock; - -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -class NaviSetVideoConfigResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(NaviSetVideoConfigResponseTest, RUN_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - - SharedPtr<NaviSetVideoConfigResponse> command( - CreateCommand<NaviSetVideoConfigResponse>(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(); -} - -} // namespace navi_set_video_config_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc b/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc deleted file mode 100644 index 1327ff6dd6..0000000000 --- a/src/components/application_manager/test/commands/hmi/navi_start_stream_request_test.cc +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2016, 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 <utility> - -#include "application_manager/commands/hmi/navi_start_stream_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" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace navi_start_stream_request { - -using ::testing::_; -using ::testing::ReturnRef; -namespace am = ::application_manager; -namespace commands = am::commands; -using commands::MessageSharedPtr; -using commands::NaviStartStreamRequest; -using am::event_engine::Event; - -namespace { -const uint32_t kHmiAppId = 13u; -const am::HmiInterfaces::InterfaceID kHmiInterface = - am::HmiInterfaces::HMI_INTERFACE_Navigation; -} // namespace - -class NaviStartStreamRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - NaviStartStreamRequestTest() { - ON_CALL(app_mngr_settings_, start_stream_retry_amount()) - .WillByDefault(ReturnRef(start_stream_retry_amount_)); - msg_ = CreateMessage(); - command_ = CreateCommand<NaviStartStreamRequest>(msg_); - } - - std::pair<uint32_t, int32_t> start_stream_retry_amount_; - MessageSharedPtr msg_; - SharedPtr<NaviStartStreamRequest> command_; -}; - -TEST_F(NaviStartStreamRequestTest, Run_HmiInterfaceNotAvailable_NoRequest) { - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0); - - command_->Run(); -} - -TEST_F(NaviStartStreamRequestTest, - Run_HmiInterfaceAvailableButNoApp_NoRequest) { - (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); - - EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) - .WillOnce(Return(ApplicationSharedPtr())); - EXPECT_CALL(app_mngr_, SendMessageToHMI(_)).Times(0); - - command_->Run(); -} - -TEST_F(NaviStartStreamRequestTest, Run_HmiInterfaceAvailable_SentRequest) { - (*msg_)[am::strings::msg_params][am::strings::app_id] = kHmiAppId; - EXPECT_CALL(mock_hmi_interfaces_, GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); - - MockAppPtr mock_app = CreateMockApp(); - EXPECT_CALL(app_mngr_, application_by_hmi_app(kHmiAppId)) - .WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, set_video_streaming_allowed(true)); - EXPECT_CALL(app_mngr_, SendMessageToHMI(msg_)); - - command_->Run(); -} - -} // namespace navi_start_stream_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc b/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc deleted file mode 100644 index 18f82cd645..0000000000 --- a/src/components/application_manager/test/commands/hmi/navi_stop_stream_requests_test.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/navi_stop_stream_request.h" -#include "application_manager/commands/hmi/navi_audio_stop_stream_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" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace navi_stop_stream_requests { - -using ::testing::_; -using ::testing::ReturnRef; -namespace am = ::application_manager; -namespace commands = am::commands; -using commands::MessageSharedPtr; -using am::event_engine::Event; - -namespace { -const am::HmiInterfaces::InterfaceID kHmiInterface = - am::HmiInterfaces::HMI_INTERFACE_Navigation; -} // namespace - -template <typename Command> -class NaviStopStreamRequestsTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - NaviStopStreamRequestsTest() { - ON_CALL(this->app_mngr_, hmi_interfaces()) - .WillByDefault(ReturnRef(mock_hmi_interfaces_)); - msg_ = CreateMessage(); - command_ = CreateCommand<Command>(msg_); - } - - MessageSharedPtr msg_; - SharedPtr<Command> command_; -}; - -typedef testing::Types<commands::AudioStopStreamRequest, - commands::NaviStopStreamRequest> RequestCommandsList; -TYPED_TEST_CASE(NaviStopStreamRequestsTest, RequestCommandsList); - -TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceNotAvailable_NoRequest) { - EXPECT_CALL(TestFixture::mock_hmi_interfaces_, - GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_NOT_AVAILABLE)); - EXPECT_CALL(TestFixture::app_mngr_, SendMessageToHMI(_)).Times(0); - - TestFixture::command_->Run(); -} - -TYPED_TEST(NaviStopStreamRequestsTest, Run_HmiInterfaceAvailable_SentRequest) { - EXPECT_CALL(TestFixture::mock_hmi_interfaces_, - GetInterfaceState(kHmiInterface)) - .WillOnce(Return(am::HmiInterfaces::STATE_AVAILABLE)); - EXPECT_CALL(TestFixture::app_mngr_, SendMessageToHMI(TestFixture::msg_)); - - TestFixture::command_->Run(); -} - -} // namespace navi_stop_stream_requests -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/on_driver_distraction_notification_test.cc b/src/components/application_manager/test/commands/hmi/on_driver_distraction_notification_test.cc deleted file mode 100644 index b8a8c68ece..0000000000 --- a/src/components/application_manager/test/commands/hmi/on_driver_distraction_notification_test.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "utils/shared_ptr.h" -#include "utils/lock.h" -#include "utils/make_shared.h" -#include "utils/data_accessor.h" -#include "commands/commands_test.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "hmi/on_driver_distraction_notification.h" -#include "interfaces/MOBILE_API.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace on_driver_distraction_notification { - -using ::testing::_; -using ::testing::Return; -using ::testing::Eq; -using ::utils::SharedPtr; - -namespace am = ::application_manager; -using am::commands::MessageSharedPtr; -using am::commands::hmi::OnDriverDistractionNotification; -using namespace am::commands; - -typedef ::utils::SharedPtr<OnDriverDistractionNotification> NotificationPtr; - -class HMIOnDriverDistractionNotificationTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - ::sync_primitives::Lock app_set_lock_; - policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_; -}; - -MATCHER_P2(CheckNotificationParams, function_id, state, "") { - bool is_function_id_matched = - function_id == - static_cast<am::mobile_api::FunctionID::eType>( - (*arg)[am::strings::params][am::strings::function_id].asInt()); - bool is_state_matched = - state == - static_cast<hmi_apis::Common_DriverDistractionState::eType>( - (*arg)[am::strings::msg_params][am::mobile_notification::state] - .asInt()); - return is_function_id_matched && is_state_matched; -} - -ACTION_P(GetArg3, result) { - arg3 = *result; -} - -TEST_F(HMIOnDriverDistractionNotificationTest, Run_PushMobileMessage_SUCCESS) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; - MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); - (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; - - NotificationPtr command( - CreateCommand<OnDriverDistractionNotification>(commands_msg)); - - EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); - - MockAppPtr mock_app = CreateMockApp(); - am::ApplicationSet app_set; - app_set.insert(mock_app); - - DataAccessor<am::ApplicationSet> accessor(app_set, app_set_lock_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); - policy::CheckPermissionResult result; - result.hmi_level_permitted = policy::kRpcDisallowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_interface_)); - EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); - - EXPECT_CALL(*mock_app, - PushMobileMessage(CheckNotificationParams( - am::mobile_api::FunctionID::OnDriverDistractionID, state))); - - command->Run(); -} - -TEST_F(HMIOnDriverDistractionNotificationTest, - Run_SendNotificationToMobile_SUCCESS) { - const hmi_apis::Common_DriverDistractionState::eType state = - hmi_apis::Common_DriverDistractionState::DD_ON; - MessageSharedPtr commands_msg(CreateMessage(smart_objects::SmartType_Map)); - (*commands_msg)[am::strings::msg_params][am::hmi_notification::state] = state; - - NotificationPtr command( - CreateCommand<OnDriverDistractionNotification>(commands_msg)); - - EXPECT_CALL(app_mngr_, set_driver_distraction_state(Eq(state))); - - MockAppPtr mock_app = CreateMockApp(); - am::ApplicationSet app_set; - app_set.insert(mock_app); - - DataAccessor<am::ApplicationSet> accessor(app_set, app_set_lock_); - EXPECT_CALL(app_mngr_, applications()).WillOnce(Return(accessor)); - - policy::CheckPermissionResult result; - result.hmi_level_permitted = policy::kRpcAllowed; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_interface_)); - EXPECT_CALL(mock_policy_handler_interface_, CheckPermissions(_, _, _, _)) - .WillOnce(GetArg3(&result)); - EXPECT_CALL(app_mngr_, - ManageMobileCommand( - CheckNotificationParams( - am::mobile_api::FunctionID::OnDriverDistractionID, state), - Command::CommandOrigin::ORIGIN_SDL)); - - command->Run(); -} - -} // on_driver_distraction_notification -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/rc_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/rc_get_capabilities_response_test.cc deleted file mode 100644 index 90be018e74..0000000000 --- a/src/components/application_manager/test/commands/hmi/rc_get_capabilities_response_test.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" -#include "application_manager/commands/hmi/rc_get_capabilities_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace rc_get_capabilities_response { - -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = am::strings; -namespace hmi_response = am::hmi_response; -using am::commands::RCGetCapabilitiesResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<RCGetCapabilitiesResponse> RCGetCapabilitiesResponsePtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class RCGetCapabilitiesResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr CreateCommandMsg() { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - (*command_msg)[strings::msg_params][strings::rc_capability] = - (capabilities_); - - return command_msg; - } - - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(RCGetCapabilitiesResponseTest, RUN_SUCCESSS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - - (*command_msg)[strings::msg_params][strings::system_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::rc_capability] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject& remote_control_capability = - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::rc_capability]; - - remote_control_capability["climateControlCapabilities"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - remote_control_capability["climateControlCapabilities"][0] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - smart_objects::SmartObject& climate_control_capability = - remote_control_capability["climateControlCapabilities"][0]; - - climate_control_capability["moduleName"] = "Climate"; - climate_control_capability["fanSpeedAvailable"] = true; - climate_control_capability["desiredTemperatureAvailable"] = true; - climate_control_capability["acEnableAvailable"] = true; - climate_control_capability["acMaxEnableAvailable"] = true; - climate_control_capability["circulateAirEnableAvailable"] = true; - climate_control_capability["autoModeEnableAvailable"] = true; - climate_control_capability["dualModeEnableAvailable"] = true; - - climate_control_capability["defrostZoneAvailable"] = true; - climate_control_capability["defrostZone"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - climate_control_capability["defrostZone"][0] = "ALL"; - - climate_control_capability["ventilationModeAvailable"] = true; - climate_control_capability["ventilationMode"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - climate_control_capability["ventilationMode"][0] = "BOTH"; - - remote_control_capability["radioControlCapabilities"] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - remote_control_capability["radioControlCapabilities"][0] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - smart_objects::SmartObject& radio_control_capability = - remote_control_capability["radioControlCapabilities"][0]; - - radio_control_capability["moduleName"] = "Radio"; - radio_control_capability["radioEnableAvailable"] = true; - radio_control_capability["radioBandAvailable"] = true; - radio_control_capability["radioFrequencyAvailable"] = true; - radio_control_capability["hdChannelAvailable"] = true; - radio_control_capability["rdsDataAvailable"] = true; - radio_control_capability["availableHDsAvailable"] = true; - radio_control_capability["stateAvailable"] = true; - radio_control_capability["signalStrengthAvailable"] = true; - radio_control_capability["signalChangeThresholdAvailable"] = true; - - remote_control_capability[hmi_response::button_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - remote_control_capability[hmi_response::button_capabilities][0] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - smart_objects::SmartObject& button_capability = - remote_control_capability[hmi_response::button_capabilities][0]; - - button_capability[strings::button_name] = "OK"; - button_capability["shortPressAvailable"] = true; - button_capability["longPressAvailable"] = true; - button_capability["upDownAvailable"] = true; - - RCGetCapabilitiesResponsePtr command( - CreateCommand<RCGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject rc_capability_so = - (*command_msg)[strings::msg_params][strings::rc_capability]; - - EXPECT_CALL(mock_hmi_capabilities_, set_rc_capability(rc_capability_so)); - EXPECT_CALL(mock_hmi_capabilities_, set_rc_supported(true)); - - command->Run(); -} - -} // namespace rc_get_capabilities_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/rc_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/rc_is_ready_request_test.cc deleted file mode 100644 index 73a43342f1..0000000000 --- a/src/components/application_manager/test/commands/hmi/rc_is_ready_request_test.cc +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/rc_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/mock_message_helper.h" -#include "application_manager/event_engine/event.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace rc_is_ready_request { - -using ::testing::_; -using ::testing::ReturnRef; -namespace am = ::application_manager; -using am::commands::MessageSharedPtr; -using am::commands::RCIsReadyRequest; -using am::event_engine::Event; - -typedef SharedPtr<RCIsReadyRequest> RCIsReadyRequestPtr; - -class RCIsReadyRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - RCIsReadyRequestTest() : command_(CreateCommand<RCIsReadyRequest>()) {} - - void SetUpExpectations(bool is_rc_cooperating_available, - bool is_send_message_to_hmi, - bool is_message_contain_param, - am::HmiInterfaces::InterfaceState state) { - if (is_send_message_to_hmi) { - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillRepeatedly(ReturnRef(mock_hmi_capabilities_)); - ExpectSendMessagesToHMI(); - } else { - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - } - EXPECT_CALL(mock_hmi_capabilities_, - set_is_rc_cooperating(is_rc_cooperating_available)); - if (!is_rc_cooperating_available) { - EXPECT_CALL(mock_hmi_capabilities_, set_rc_supported(false)); - } - - 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_RC, state)); - } else { - EXPECT_CALL(app_mngr_, hmi_interfaces()) - .WillOnce(ReturnRef(mock_hmi_interfaces_)); - EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0); - } - EXPECT_CALL(mock_hmi_interfaces_, - GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_RC)) - .WillOnce(Return(state)); - } - - void ExpectSendMessagesToHMI() { - smart_objects::SmartObjectSPtr capabilities( - new smart_objects::SmartObject(smart_objects::SmartType_Map)); - EXPECT_CALL(mock_message_helper_, - CreateModuleInfoSO(hmi_apis::FunctionID::RC_GetCapabilities, _)) - .WillOnce(Return(capabilities)); - EXPECT_CALL(app_mngr_, ManageHMICommand(capabilities)); - } - - void PrepareEvent(bool is_message_contain_param, - Event& event, - bool is_rc_cooperating_available = false) { - MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); - if (is_message_contain_param) { - (*msg)[am::strings::msg_params][am::strings::available] = - is_rc_cooperating_available; - } - event.set_smart_object(*msg); - } - - RCIsReadyRequestPtr command_; - am::MockHmiInterfaces mock_hmi_interfaces_; - application_manager_test::MockHMICapabilities mock_hmi_capabilities_; -}; - -TEST_F(RCIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) { - const bool is_rc_cooperating_available = false; - const bool is_send_message_to_hmi = true; - const bool is_message_contain_param = false; - Event event(hmi_apis::FunctionID::RC_IsReady); - PrepareEvent(is_message_contain_param, event); - SetUpExpectations(is_rc_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_NOT_RESPONSE); - command_->on_event(event); -} - -TEST_F(RCIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) { - const bool is_rc_cooperating_available = false; - const bool is_send_message_to_hmi = false; - const bool is_message_contain_param = true; - Event event(hmi_apis::FunctionID::RC_IsReady); - PrepareEvent(is_message_contain_param, event); - SetUpExpectations(is_rc_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_NOT_AVAILABLE); - command_->on_event(event); -} - -TEST_F(RCIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) { - const bool is_rc_cooperating_available = true; - const bool is_send_message_to_hmi = true; - const bool is_message_contain_param = true; - Event event(hmi_apis::FunctionID::RC_IsReady); - PrepareEvent(is_message_contain_param, event, is_rc_cooperating_available); - SetUpExpectations(is_rc_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_AVAILABLE); - command_->on_event(event); -} - -TEST_F(RCIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) { - ExpectSendMessagesToHMI(); - command_->onTimeOut(); -} - -} // namespace rc_is_ready_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/rc_is_ready_response_test.cc b/src/components/application_manager/test/commands/hmi/rc_is_ready_response_test.cc deleted file mode 100644 index 157dff6216..0000000000 --- a/src/components/application_manager/test/commands/hmi/rc_is_ready_response_test.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/commands/hmi/rc_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace rc_is_ready_response { - -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::RCIsReadyResponse; -using test::components::event_engine_test::MockEventDispatcher; - -typedef SharedPtr<RCIsReadyResponse> RCIsReadyResponsePtr; - -class RCIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { -}; - -TEST_F(RCIsReadyResponseTest, RUN_SUCCESS) { - RCIsReadyResponsePtr command(CreateCommand<RCIsReadyResponse>()); - - 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 rc_is_ready_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/response_from_hmi_test.cc b/src/components/application_manager/test/commands/hmi/response_from_hmi_test.cc deleted file mode 100644 index 8ee86f098d..0000000000 --- a/src/components/application_manager/test/commands/hmi/response_from_hmi_test.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2016, 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 "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/commands/command.h" -#include "application_manager/mock_event_dispatcher.h" -#include "hmi/response_from_hmi.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace response_from_hmi { - -using ::testing::_; -using ::testing::Return; -using ::testing::SaveArg; -using ::testing::DoAll; - -using ::utils::SharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; - -namespace am = ::application_manager; - -using am::commands::ResponseFromHMI; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; - -class ResponseFromHMITest : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(ResponseFromHMITest, BasicMethodsOverloads_SUCCESS) { - ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); - - // Current implementation always return `true` - EXPECT_TRUE(command->Init()); - EXPECT_NO_THROW(command->Run()); - EXPECT_TRUE(command->CleanUp()); -} - -TEST_F(ResponseFromHMITest, SendResponseToMobile_SUCCESS) { - ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); - - MessageSharedPtr msg(CreateMessage(smart_objects::SmartType_Map)); - - EXPECT_CALL(app_mngr_, ManageMobileCommand(msg, _)); - - command->SendResponseToMobile(msg, app_mngr_); - - const application_manager::MessageType received_message_tipe = - static_cast<application_manager::MessageType>( - (*msg)[am::strings::params][am::strings::message_type].asInt()); - - EXPECT_EQ(application_manager::MessageType::kResponse, received_message_tipe); -} - -TEST_F(ResponseFromHMITest, CreateHMIRequest_SUCCESS) { - ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); - - MessageSharedPtr result_msg; - EXPECT_CALL(app_mngr_, ManageHMICommand(_)) - .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(true))); - - const hmi_apis::FunctionID::eType posted_function_id = - hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr dummy_msg_params = CreateMessage(); - command->CreateHMIRequest(posted_function_id, *dummy_msg_params); - - ASSERT_TRUE(result_msg); - - const application_manager::MessageType received_message_tipe = - static_cast<application_manager::MessageType>( - (*result_msg)[am::strings::params][am::strings::message_type] - .asInt()); - - EXPECT_EQ(am::MessageType::kRequest, received_message_tipe); - - const hmi_apis::FunctionID::eType received_function_id = - static_cast<hmi_apis::FunctionID::eType>( - (*result_msg)[am::strings::params][am::strings::function_id].asInt()); - - EXPECT_EQ(posted_function_id, received_function_id); -} - -TEST_F(ResponseFromHMITest, CreateHMIRequest_CantManageCommand_Covering) { - ResponseFromHMIPtr command(CreateCommand<ResponseFromHMI>()); - - MessageSharedPtr result_msg; - ON_CALL(app_mngr_, GetNextHMICorrelationID()).WillByDefault(Return(1u)); - EXPECT_CALL(app_mngr_, ManageHMICommand(_)) - .WillOnce(DoAll(SaveArg<0>(&result_msg), Return(false))); - - const hmi_apis::FunctionID::eType posted_function_id = - hmi_apis::FunctionID::INVALID_ENUM; - MessageSharedPtr dummy_msg_params = CreateMessage(); - command->CreateHMIRequest(posted_function_id, *dummy_msg_params); -} - -} // namespace response_from_hmi -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc b/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc deleted file mode 100644 index d36b55ee25..0000000000 --- a/src/components/application_manager/test/commands/hmi/sdl_activate_app_request_test.cc +++ /dev/null @@ -1,503 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/lock.h" -#include "utils/helpers.h" -#include "application_manager/commands/hmi/sdl_activate_app_request.h" -#include "application_manager/mock_application.h" -#include "application_manager/application_manager.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "commands/command_request_test.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_state_controller.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace sdl_activate_app_request { - -namespace am = ::application_manager; -namespace strings = am::strings; -namespace hmi_response = am::hmi_response; -using am::commands::MessageSharedPtr; -using am::commands::SDLActivateAppRequest; -using am::ApplicationSet; -using testing::Mock; -using testing::Return; -using testing::ReturnRef; -using testing::Mock; -using ::testing::NiceMock; -using policy_test::MockPolicyHandlerInterface; -using am::event_engine::Event; - -namespace { -const uint32_t kCorrelationID = 1u; -const uint32_t kAppID = 2u; -const uint32_t kAppIDFirst = 1u; -const connection_handler::DeviceHandle kHandle = 2u; -} // namespace - -MATCHER_P2(CheckMsgParams, result, corr_id, "") { - const bool is_func_id_valid = - hmi_apis::FunctionID::SDL_ActivateApp == - static_cast<int32_t>( - (*arg)[am::strings::params][am::strings::function_id].asInt()); - - const bool is_result_code_valid = - hmi_apis::Common_Result::APPLICATION_NOT_REGISTERED == - static_cast<int32_t>( - (*arg)[am::strings::msg_params][am::strings::result_code].asInt()); - - const bool is_result_valid = - result == (*arg)[am::strings::msg_params][am::strings::success].asBool(); - - const bool is_corr_id_valid = - corr_id == - ((*arg)[am::strings::params][am::strings::correlation_id].asUInt()); - - using namespace helpers; - return Compare<bool, EQ, ALL>(true, - is_func_id_valid, - is_result_code_valid, - is_result_valid, - is_corr_id_valid); -} - -class SDLActivateAppRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - protected: - ~SDLActivateAppRequestTest() { - // Fix DataAccessor release and WinQt crash - Mock::VerifyAndClearExpectations(&app_mngr_); - } - - void InitCommand(const uint32_t& timeout) OVERRIDE { - MockAppPtr mock_app = CreateMockApp(); - CommandRequestTest<CommandsTestMocks::kIsNice>::InitCommand(timeout); - ON_CALL((*mock_app), app_id()).WillByDefault(Return(kAppID)); - ON_CALL(app_mngr_, application_by_hmi_app(kAppID)) - .WillByDefault(Return(mock_app)); - } - void SetCorrelationAndAppID(MessageSharedPtr msg) { - (*msg)[am::strings::params][strings::correlation_id] = kCorrelationID; - (*msg)[am::strings::msg_params][strings::app_id] = kAppID; - } - - ApplicationSet app_list_; - ::sync_primitives::Lock lock_; - policy_test::MockPolicyHandlerInterface policy_handler_; - application_manager_test::MockStateController mock_state_controller_; - NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; -}; - -#ifdef EXTERNAL_PROPRIETARY_MODE - -TEST_F(SDLActivateAppRequestTest, Run_ActivateApp_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler_)); - EXPECT_CALL(policy_handler_, OnActivateApp(kAppID, kCorrelationID)); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, DISABLED_Run_DactivateApp_REJECTED) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - (*msg)[am::strings::msg_params][strings::function_id] = - hmi_apis::FunctionID::SDL_ActivateApp; - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(true)); - - EXPECT_CALL( - app_mngr_, - ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::SDL_ActivateApp))) - .WillOnce(Return(true)); - - command->Run(); -} -#else - -TEST_F(SDLActivateAppRequestTest, FindAppToRegister_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MockAppPtr mock_app(CreateMockApp()); - EXPECT_CALL(app_mngr_, application(kAppID)).WillOnce(Return(mock_app)); - - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); - ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); - - MockAppPtr mock_app_first(CreateMockApp()); - ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); - ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); - - app_list_.insert(mock_app_first); - DataAccessor<ApplicationSet> accessor(app_list_, lock_); - EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - - ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); - EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(false)); - ON_CALL(*mock_app_first, protocol_version()) - .WillByDefault( - Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); - ON_CALL(*mock_app, protocol_version()) - .WillByDefault( - Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); - - const std::string url = "url"; - ON_CALL(*mock_app_first, SchemaUrl()).WillByDefault(Return(url)); - const std::string package = "package"; - ON_CALL(*mock_app_first, PackageName()).WillByDefault(Return(package)); - - EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, AppIdNotFound_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - EXPECT_CALL(app_mngr_, application(kAppID)) - .WillOnce(Return(ApplicationSharedPtr())); - EXPECT_CALL(app_mngr_, WaitingApplicationByID(kAppID)) - .WillOnce(Return(ApplicationSharedPtr())); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, DevicesAppsEmpty_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MockAppPtr mock_app(CreateMockApp()); - ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); - - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); - ON_CALL(*mock_app, device()).WillByDefault(Return(kHandle)); - - DataAccessor<ApplicationSet> accessor(app_list_, lock_); - EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - app_list_ = accessor.GetData(); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, FirstAppActive_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MockAppPtr mock_app(CreateMockApp()); - ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); - - DataAccessor<ApplicationSet> accessor(app_list_, lock_); - EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - - app_list_ = accessor.GetData(); - - MockAppPtr mock_app_first(CreateMockApp()); - ON_CALL(app_mngr_, application(kAppIDFirst)) - .WillByDefault(Return(mock_app_first)); - - app_list_.insert(mock_app_first); - ON_CALL(*mock_app_first, protocol_version()) - .WillByDefault( - Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); - - ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); - EXPECT_CALL(*mock_app_first, is_foreground()).WillRepeatedly(Return(true)); - - EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, FirstAppNotActive_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MockAppPtr mock_app(CreateMockApp()); - ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(true)); - - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler_)); - EXPECT_CALL(policy_handler_, OnActivateApp(kAppID, kCorrelationID)); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, FirstAppIsForeground_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MockAppPtr mock_app(CreateMockApp()); - - const std::string schema("schema"); - mock_app->SetShemaUrl(schema); - const std::string package_name("package_name"); - mock_app->SetPackageName(package_name); - - ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); - - EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); - EXPECT_CALL(*mock_app, IsRegistered()).WillOnce(Return(false)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - MockAppPtr mock_app_first(CreateMockApp()); - ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); - - app_list_.insert(mock_app_first); - DataAccessor<ApplicationSet> accessor(app_list_, lock_); - EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - ON_CALL(*mock_app_first, protocol_version()) - .WillByDefault( - Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); - ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); - EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(true)); - - EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, schema, package_name, _)); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, FirstAppNotRegisteredAndEmpty_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MockAppPtr mock_app(CreateMockApp()); - ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); - EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - - MockAppPtr mock_app_first(CreateMockApp()); - ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); - ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); - - app_list_.insert(mock_app_first); - DataAccessor<ApplicationSet> accessor(app_list_, lock_); - EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - ON_CALL(*mock_app_first, protocol_version()) - .WillByDefault( - Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); - EXPECT_CALL(*mock_app_first, is_foreground()).WillOnce(Return(false)); - - EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); - - command->Run(); -} - -TEST_F(SDLActivateAppRequestTest, FirstAppNotRegistered_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MockAppPtr mock_app(CreateMockApp()); - ON_CALL(app_mngr_, application(kAppID)).WillByDefault(Return(mock_app)); - EXPECT_CALL(*mock_app, device()).WillOnce(Return(kHandle)); - EXPECT_CALL(app_mngr_, state_controller()) - .WillOnce(ReturnRef(mock_state_controller_)); - EXPECT_CALL(mock_state_controller_, - IsStateActive(am::HmiState::StateID::STATE_ID_DEACTIVATE_HMI)) - .WillOnce(Return(false)); - DataAccessor<ApplicationSet> accessor(app_list_, lock_); - EXPECT_CALL(app_mngr_, applications()).WillRepeatedly(Return(accessor)); - - app_list_ = accessor.GetData(); - - MockAppPtr mock_app_first(CreateMockApp()); - ON_CALL(*mock_app_first, device()).WillByDefault(Return(kHandle)); - ON_CALL(*mock_app_first, is_foreground()).WillByDefault(Return(false)); - - app_list_.insert(mock_app_first); - ON_CALL(*mock_app_first, protocol_version()) - .WillByDefault( - Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_5)); - EXPECT_CALL(*mock_app_first, is_foreground()).WillRepeatedly(Return(true)); - - EXPECT_CALL(mock_message_helper_, SendLaunchApp(_, _, _, _)); - - command->Run(); -} -#endif - -TEST_F(SDLActivateAppRequestTest, OnTimeout_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - SetCorrelationAndAppID(msg); - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - ON_CALL(mock_event_dispatcher_, remove_observer(_, _)); - EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true)); - - command->onTimeOut(); -} - -TEST_F(SDLActivateAppRequestTest, OnEvent_InvalidEventId_UNSUCCESS) { - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[am::strings::params][strings::correlation_id] = kCorrelationID; - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>()); - - Event event(hmi_apis::FunctionID::INVALID_ENUM); - event.set_smart_object(*event_msg); - EXPECT_CALL(app_mngr_, application_by_hmi_app(_)).Times(0); - - command->on_event(event); -} - -TEST_F(SDLActivateAppRequestTest, OnEvent_InvalidAppId_UNSUCCESS) { - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[strings::msg_params][strings::application][strings::app_id] = - kAppID; - - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>()); - - Event event(hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); - event.set_smart_object(*event_msg); - - MockAppPtr invalid_mock_app; - EXPECT_CALL(app_mngr_, application_by_hmi_app(_)) - .WillOnce(Return(invalid_mock_app)); - EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(0); - - command->on_event(event); -} - -TEST_F(SDLActivateAppRequestTest, OnEvent_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::correlation_id] = kCorrelationID; - SharedPtr<SDLActivateAppRequest> command( - CreateCommand<SDLActivateAppRequest>(msg)); - - MessageSharedPtr event_msg = CreateMessage(); - (*event_msg)[strings::msg_params][strings::application][strings::app_id] = - kAppID; - - Event event(hmi_apis::FunctionID::BasicCommunication_OnAppRegistered); - event.set_smart_object(*event_msg); - - MockAppPtr mock_app(CreateMockApp()); - EXPECT_CALL(app_mngr_, application_by_hmi_app(_)).WillOnce(Return(mock_app)); - EXPECT_CALL(*mock_app, app_id()).WillOnce(Return(kAppID)); - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler_)); - EXPECT_CALL(policy_handler_, OnActivateApp(kAppID, kCorrelationID)); - - command->on_event(event); -} - -} // namespace sdl_activate_app_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/sdl_activate_app_response_test.cc b/src/components/application_manager/test/commands/hmi/sdl_activate_app_response_test.cc deleted file mode 100644 index 5dff55f7c3..0000000000 --- a/src/components/application_manager/test/commands/hmi/sdl_activate_app_response_test.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "application_manager/commands/hmi/sdl_activate_app_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace sdl_activate_app_response { - -using ::utils::SharedPtr; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::SDLActivateAppResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<SDLActivateAppResponse> SDLActivateAppResponsePtr; - -namespace { -const uint32_t kConnectionKey = 2u; -const std::string kStrNumber = "123"; -} // namespace - -class SDLActivateAppResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(SDLActivateAppResponseTest, RUN_SendRequest_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; - - SDLActivateAppResponsePtr command( - CreateCommand<SDLActivateAppResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(command_msg)); - - command->Run(); - - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); -} - -} // namespace sdl_activate_app_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc b/src/components/application_manager/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc deleted file mode 100644 index 1bcdaebb35..0000000000 --- a/src/components/application_manager/test/commands/hmi/sdl_get_list_of_permisssions_request_test.cc +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "application_manager/commands/hmi/sdl_get_list_of_permissions_request.h" -#include "application_manager/mock_application.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "commands/command_request_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace sdl_get_list_of_permissions_request { - -using application_manager::commands::MessageSharedPtr; -using application_manager::commands::SDLGetListOfPermissionsRequest; -using test::components::policy_test::MockPolicyHandlerInterface; -using smart_objects::SmartObject; -using testing::Return; -using testing::ReturnRef; - -namespace { -const uint32_t kCorrelationID = 1u; -const uint32_t kAppID = 2u; -const uint32_t kConnectionKey = 0u; -} // namespace - -namespace strings = ::application_manager::strings; -namespace hmi_response = ::application_manager::hmi_response; - -class SDLGetListOfPermissionsRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - protected: - void SetUp() OVERRIDE { - mock_app_ = CreateMockApp(); - } - - void InitCommand(const uint32_t& timeout) OVERRIDE { - CommandRequestTest<CommandsTestMocks::kIsNice>::InitCommand(timeout); - ON_CALL((*mock_app_), app_id()).WillByDefault(Return(kAppID)); - } - MockAppPtr mock_app_; -}; - -TEST_F(SDLGetListOfPermissionsRequestTest, Run_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::correlation_id] = kCorrelationID; - (*msg)[strings::msg_params][strings::app_id] = kAppID; - - EXPECT_CALL(app_mngr_, application_by_hmi_app(kAppID)) - .WillOnce(Return(mock_app_)); - - SharedPtr<SDLGetListOfPermissionsRequest> command( - CreateCommand<SDLGetListOfPermissionsRequest>(msg)); - - MockPolicyHandlerInterface policy_handler; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler)); - EXPECT_CALL(policy_handler, OnGetListOfPermissions(kAppID, kCorrelationID)); - - command->Run(); -} - -TEST_F(SDLGetListOfPermissionsRequestTest, Run_KeyDoesntExist_SUCCESS) { - MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Binary); - (*msg)[strings::params][strings::correlation_id] = kCorrelationID; - - SharedPtr<SDLGetListOfPermissionsRequest> command( - CreateCommand<SDLGetListOfPermissionsRequest>(msg)); - - MockPolicyHandlerInterface policy_handler; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler)); - EXPECT_CALL(policy_handler, - OnGetListOfPermissions(kConnectionKey, kCorrelationID)); - - command->Run(); -} - -} // namespace sdl_get_list_of_permissions_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/sdl_get_status_update_request_test.cc b/src/components/application_manager/test/commands/hmi/sdl_get_status_update_request_test.cc deleted file mode 100644 index 988cdd18c7..0000000000 --- a/src/components/application_manager/test/commands/hmi/sdl_get_status_update_request_test.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "application_manager/commands/hmi/sdl_get_status_update_request.h" -#include "application_manager/mock_application.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "commands/command_request_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace sdl_get_status_update_request { - -using application_manager::commands::MessageSharedPtr; -using application_manager::commands::SDLGetStatusUpdateRequest; -using test::components::policy_test::MockPolicyHandlerInterface; -using testing::Return; -using testing::ReturnRef; - -namespace { -const uint32_t kCorrelationID = 1u; -} // namespace - -namespace strings = ::application_manager::strings; -namespace hmi_response = ::application_manager::hmi_response; - -class SDLGetStatusUpdateRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(SDLGetStatusUpdateRequestTest, Run_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::correlation_id] = kCorrelationID; - - SharedPtr<SDLGetStatusUpdateRequest> command( - CreateCommand<SDLGetStatusUpdateRequest>(msg)); - - MockPolicyHandlerInterface mock_policy_handler; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler)); - EXPECT_CALL(mock_policy_handler, OnGetStatusUpdate(kCorrelationID)); - - command->Run(); -} - -} // namespace sdl_get_status_update_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc b/src/components/application_manager/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc deleted file mode 100644 index 66fedda3ca..0000000000 --- a/src/components/application_manager/test/commands/hmi/sdl_get_user_friendly_message_request_test.cc +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/sdl_get_user_friendly_message_request.h" -#include "application_manager/mock_application.h" -#include "application_manager/mock_state_controller.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "smart_objects/smart_object.h" -#include "commands/command_request_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace sdl_get_user_friendly_message_request { - -using application_manager::commands::MessageSharedPtr; -using application_manager::commands::SDLGetUserFriendlyMessageRequest; -using application_manager::MockMessageHelper; -using test::components::policy_test::MockPolicyHandlerInterface; -using test::components::application_manager_test::MockHMICapabilities; -using testing::_; -using testing::Return; -using testing::ReturnRef; - -namespace { -const uint32_t kCorrelationID = 1u; -const uint32_t kAppID = 2u; -const std::string kLanguageDe = "de-de"; -const std::string kLanguageEn = "en-gb"; -const std::string kMessageCodes = "messageCodes"; -const hmi_apis::Common_Language::eType kLanguage = - hmi_apis::Common_Language::EN_GB; -} // namespace - -namespace strings = ::application_manager::strings; - -class SDLGetUserFriendlyMessageRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - protected: - void SetUp() OVERRIDE { - mock_app_ = CreateMockApp(); - } - - void InitCommand(const uint32_t& timeout) OVERRIDE { - CommandRequestTest<CommandsTestMocks::kIsNice>::InitCommand(timeout); - ON_CALL((*mock_app_), app_id()).WillByDefault(Return(kAppID)); - EXPECT_CALL(app_mngr_, application_by_hmi_app(kAppID)) - .WillOnce(Return(mock_app_)); - } - MockAppPtr mock_app_; - MockPolicyHandlerInterface mock_policy_handler_; -}; - -TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_LanguageSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::correlation_id] = kCorrelationID; - (*msg)[strings::msg_params][strings::app_id] = kAppID; - - (*msg)[strings::msg_params][kMessageCodes] = - SmartObject(smart_objects::SmartType_Array); - (*msg)[strings::msg_params][kMessageCodes][0] = SmartObject(kLanguageDe); - (*msg)[strings::msg_params][kMessageCodes][1] = SmartObject(kLanguageEn); - - (*msg)[strings::msg_params][strings::language] = kLanguage; - - SharedPtr<SDLGetUserFriendlyMessageRequest> command( - CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); - - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(kLanguage)) - .WillOnce(Return(kLanguageEn)); - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_)); - std::vector<std::string> msg_codes; - msg_codes.push_back(kLanguageDe); - msg_codes.push_back(kLanguageEn); - EXPECT_CALL(mock_policy_handler_, - OnGetUserFriendlyMessage(msg_codes, kLanguageEn, kCorrelationID)); - - command->Run(); -} - -TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_LanguageNotSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::correlation_id] = kCorrelationID; - (*msg)[strings::msg_params][strings::app_id] = kAppID; - - (*msg)[strings::msg_params][kMessageCodes] = - SmartObject(smart_objects::SmartType_Array); - (*msg)[strings::msg_params][kMessageCodes][0] = SmartObject(kLanguageDe); - (*msg)[strings::msg_params][kMessageCodes][1] = SmartObject(kLanguageEn); - - SharedPtr<SDLGetUserFriendlyMessageRequest> command( - CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); - - MockHMICapabilities mock_hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_hmi_capabilities, active_ui_language()) - .WillOnce(Return(kLanguage)); - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(kLanguage)) - .WillOnce(Return(kLanguageEn)); - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_)); - std::vector<std::string> msg_codes; - msg_codes.push_back(kLanguageDe); - msg_codes.push_back(kLanguageEn); - EXPECT_CALL(mock_policy_handler_, - OnGetUserFriendlyMessage(msg_codes, kLanguageEn, kCorrelationID)); - - command->Run(); -} - -TEST_F(SDLGetUserFriendlyMessageRequestTest, Run_NoMsgCodes_Canceled) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::params][strings::correlation_id] = kCorrelationID; - (*msg)[strings::msg_params][strings::app_id] = kAppID; - - SharedPtr<SDLGetUserFriendlyMessageRequest> command( - CreateCommand<SDLGetUserFriendlyMessageRequest>(msg)); - - EXPECT_CALL(mock_message_helper_, CommonLanguageToString(_)).Times(0); - EXPECT_CALL(app_mngr_, GetPolicyHandler()).Times(0); - EXPECT_CALL(mock_policy_handler_, OnGetUserFriendlyMessage(_, _, _)).Times(0); - - command->Run(); -} - -} // namespace sdl_get_user_friendly_message_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/simple_notifications_test.cc b/src/components/application_manager/test/commands/hmi/simple_notifications_test.cc deleted file mode 100644 index 9d7441fef7..0000000000 --- a/src/components/application_manager/test/commands/hmi/simple_notifications_test.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016, 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 "commands/commands_test.h" - -#include "hmi/notification_to_hmi.h" -#include "application_manager/commands/command_notification_impl.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace simple_notifications_test { - -using namespace application_manager; - -using ::testing::Types; - -template <typename Command> -class SimpleNotificationsTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - typedef Command CommandType; -}; - -typedef Types<commands::CommandNotificationImpl, commands::NotificationToHMI> - CommandsList; - -TYPED_TEST_CASE(SimpleNotificationsTest, CommandsList); - -TYPED_TEST(SimpleNotificationsTest, Run_SendMessageToHMI_SUCCESS) { - typedef typename TestFixture::CommandType CommandType; - - SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); - - // Current implementation always return `true` - EXPECT_TRUE(command->Init()); - EXPECT_NO_THROW(command->Run()); - EXPECT_TRUE(command->CleanUp()); -} - -} // namespace simple_notifications_test -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/simple_request_from_hmi_test.cc b/src/components/application_manager/test/commands/hmi/simple_request_from_hmi_test.cc deleted file mode 100644 index 4f7a7a9f72..0000000000 --- a/src/components/application_manager/test/commands/hmi/simple_request_from_hmi_test.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2016, 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 "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/commands/command.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/mock_event_dispatcher.h" -#include "hmi/request_from_hmi.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace simple_requests_from_hmi_test { - -using ::testing::_; -using ::testing::Types; -using ::testing::NotNull; -using ::testing::NiceMock; - -using ::utils::SharedPtr; -namespace commands = ::application_manager::commands; -using commands::MessageSharedPtr; -using ::application_manager::event_engine::EventObserver; -using ::test::components::event_engine_test::MockEventDispatcher; - -class RequestFromHMITest : public CommandsTest<CommandsTestMocks::kIsNice> { - protected: - void SetUp() OVERRIDE { - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - } - NiceMock<event_engine_test::MockEventDispatcher> mock_event_dispatcher_; -}; - -TEST_F(RequestFromHMITest, BasicMethodsOverloads_SUCCESS) { - SharedPtr<commands::RequestFromHMI> command( - CreateCommand<commands::RequestFromHMI>()); - application_manager::event_engine::Event event( - hmi_apis::FunctionID::BasicCommunication_ActivateApp); - // Current implementation always return `true` - EXPECT_TRUE(command->Init()); - EXPECT_TRUE(command->CleanUp()); - EXPECT_NO_THROW(command->Run()); - EXPECT_NO_THROW(command->on_event(event)); -} - -TEST_F(RequestFromHMITest, SendResponse_SUCCESS) { - SharedPtr<commands::RequestFromHMI> command( - CreateCommand<commands::RequestFromHMI>()); - - const bool success = false; - const uint32_t correlation_id = 1u; - EXPECT_CALL(app_mngr_, ManageHMICommand(NotNull())); - - command->SendResponse(success, - correlation_id, - hmi_apis::FunctionID::BasicCommunication_ActivateApp, - hmi_apis::Common_Result::SUCCESS); -} - -} // namespace simple_requests_to_hmi_test -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc b/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc deleted file mode 100644 index 3fa3aaef3a..0000000000 --- a/src/components/application_manager/test/commands/hmi/simple_requests_to_hmi_test.cc +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) 2016, Ford Motor Company - * All rights reserved. - * - * Copyright (c) 2017 Xevo Inc. - * 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 copyright holders nor the names of their 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 "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/commands/command_request_test.h" -#include "application_manager/commands/command.h" -#include "application_manager/commands/hmi/allow_app_request.h" -#include "application_manager/commands/hmi/allow_all_apps_request.h" -#include "application_manager/commands/hmi/basic_communication_system_request.h" -#include "application_manager/commands/hmi/button_get_capabilities_request.h" -#include "application_manager/commands/hmi/navi_alert_maneuver_request.h" -#include "application_manager/commands/hmi/navi_audio_stop_stream_request.h" -#include "application_manager/commands/hmi/navi_get_way_points_request.h" -#include "application_manager/commands/hmi/navi_is_ready_request.h" -#include "application_manager/commands/hmi/navi_send_location_request.h" -#include "application_manager/commands/hmi/navi_show_constant_tbt_request.h" -#include "application_manager/commands/hmi/navi_stop_stream_request.h" -#include "application_manager/commands/hmi/navi_subscribe_way_points_request.h" -#include "application_manager/commands/hmi/navi_unsubscribe_way_points_request.h" -#include "application_manager/commands/hmi/navi_update_turn_list_request.h" -#include "application_manager/commands/hmi/sdl_activate_app_response.h" -#include "application_manager/commands/hmi/sdl_get_list_of_permissions_response.h" -#include "application_manager/commands/hmi/sdl_get_status_update_response.h" -#include "application_manager/commands/hmi/ui_scrollable_message_request.h" -#include "application_manager/commands/hmi/ui_set_app_icon_request.h" -#include "application_manager/commands/hmi/ui_set_display_layout_request.h" -#include "application_manager/commands/hmi/ui_set_global_properties_request.h" -#include "application_manager/commands/hmi/request_to_hmi.h" -#include "application_manager/commands/hmi/vi_get_vehicle_type_request.h" -#include "application_manager/commands/hmi/vi_is_ready_request.h" -#include "application_manager/commands/hmi/vi_read_did_request.h" -#include "application_manager/commands/hmi/vi_subscribe_vehicle_data_request.h" -#include "application_manager/commands/hmi/dial_number_request.h" -#include "application_manager/commands/hmi/tts_is_ready_request.h" -#include "application_manager/commands/hmi/tts_set_global_properties_request.h" -#include "application_manager/commands/hmi/tts_speak_request.h" -#include "application_manager/commands/hmi/tts_stop_speaking_request.h" -#include "application_manager/commands/hmi/tts_get_supported_languages_request.h" -#include "application_manager/commands/hmi/tts_change_registration_request.h" -#include "application_manager/commands/hmi/tts_get_capabilities_request.h" -#include "application_manager/commands/hmi/tts_get_language_request.h" -#include "application_manager/commands/hmi/close_popup_request.h" -#include "application_manager/commands/hmi/ui_add_command_request.h" -#include "application_manager/commands/hmi/ui_add_submenu_request.h" -#include "application_manager/commands/hmi/ui_alert_request.h" -#include "application_manager/commands/hmi/ui_change_registration_request.h" -#include "application_manager/commands/hmi/ui_delete_command_request.h" -#include "application_manager/commands/hmi/ui_delete_submenu_request.h" -#include "application_manager/commands/hmi/ui_end_audio_pass_thru_request.h" -#include "application_manager/commands/hmi/ui_get_capabilities_request.h" -#include "application_manager/commands/hmi/ui_get_language_request.h" -#include "application_manager/commands/hmi/ui_get_supported_languages_request.h" -#include "application_manager/commands/hmi/ui_is_ready_request.h" -#include "application_manager/commands/hmi/ui_perform_audio_pass_thru_request.h" -#include "application_manager/commands/hmi/ui_perform_interaction_request.h" -#include "application_manager/commands/hmi/vi_diagnostic_message_request.h" -#include "application_manager/commands/hmi/vi_get_dtcs_request.h" -#include "application_manager/commands/hmi/vi_get_vehicle_data_request.h" -#include "application_manager/commands/hmi/ui_set_media_clock_timer_request.h" -#include "application_manager/commands/hmi/ui_show_request.h" -#include "application_manager/commands/hmi/ui_slider_request.h" -#include "application_manager/commands/hmi/vi_unsubscribe_vehicle_data_request.h" -#include "application_manager/commands/hmi/vr_add_command_request.h" -#include "application_manager/commands/hmi/vr_change_registration_request.h" -#include "application_manager/commands/hmi/vr_delete_command_request.h" -#include "application_manager/commands/hmi/vr_get_capabilities_request.h" -#include "application_manager/commands/hmi/vr_get_supported_languages_request.h" -#include "application_manager/commands/hmi/vr_get_language_request.h" -#include "application_manager/commands/hmi/vr_is_ready_request.h" -#include "application_manager/commands/hmi/vr_perform_interaction_request.h" -#include "application_manager/commands/hmi/allow_all_apps_request.h" -#include "application_manager/commands/hmi/basic_communication_system_request.h" -#include "application_manager/commands/hmi/button_get_capabilities_request.h" -#include "application_manager/commands/hmi/allow_app_request.h" -#include "application_manager/commands/hmi/navi_send_location_request.h" -#include "application_manager/commands/hmi/navi_unsubscribe_way_points_request.h" -#include "application_manager/commands/hmi/navi_update_turn_list_request.h" -#include "application_manager/commands/hmi/navi_show_constant_tbt_request.h" -#include "application_manager/commands/hmi/navi_stop_stream_request.h" -#include "application_manager/commands/hmi/navi_subscribe_way_points_request.h" -#include "application_manager/commands/hmi/sdl_policy_update.h" -#include "application_manager/commands/hmi/ui_set_icon_request.h" -#include "application_manager/commands/hmi/dial_number_request.h" -#include "application_manager/commands/hmi/ui_send_haptic_data_request.h" - -#include "application_manager/test/include/application_manager/mock_event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace simple_requests_to_hmi_test { - -using ::testing::_; -using ::testing::Types; -using ::testing::NotNull; - -using ::utils::SharedPtr; - -namespace am_commands = application_manager::commands; -using am_commands::MessageSharedPtr; -using event_engine_test::MockEventDispatcher; - -class RequestToHMITest : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(RequestToHMITest, BasicMethodsOverloads_SUCCESS) { - SharedPtr<am_commands::RequestToHMI> command( - CreateCommand<am_commands::RequestToHMI>()); - - // Current implementation always return `true` - EXPECT_TRUE(command->Init()); - EXPECT_NO_THROW(command->Run()); - EXPECT_TRUE(command->CleanUp()); -} - -TEST_F(RequestToHMITest, SendRequest_SUCCESS) { - SharedPtr<am_commands::RequestToHMI> command( - CreateCommand<am_commands::RequestToHMI>()); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(NotNull())); - - command->SendRequest(); -} - -template <typename Command> -class RequestToHMICommandsTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - typedef Command CommandType; -}; - -template <typename Command> -class RequestToHMICommandsTest2 : public RequestToHMICommandsTest<Command> {}; - -template <typename Command> -class RequestToHMICommandsTest3 - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - typedef Command CommandType; -}; - -typedef Types<am_commands::VIGetVehicleTypeRequest, - am_commands::VIReadDIDRequest, - am_commands::VISubscribeVehicleDataRequest, - am_commands::hmi::DialNumberRequest, - am_commands::ClosePopupRequest, - am_commands::TTSSetGlobalPropertiesRequest, - am_commands::TTSSpeakRequest, - am_commands::TTSStopSpeakingRequest, - am_commands::TTSGetSupportedLanguagesRequest, - am_commands::UIAddCommandRequest, - am_commands::UIAddSubmenuRequest, - am_commands::UIAlertRequest, - am_commands::UIChangeRegistrationRequest, - am_commands::UIDeleteCommandRequest, - am_commands::UIDeleteSubmenuRequest, - am_commands::UIEndAudioPassThruRequest, - am_commands::UIGetCapabilitiesRequest, - am_commands::UIGetLanguageRequest, - am_commands::UIGetSupportedLanguagesRequest, - am_commands::UIPerformAudioPassThruRequest, - am_commands::UIPerformInteractionRequest, - am_commands::VIDiagnosticMessageRequest, - am_commands::VIGetDTCsRequest, - am_commands::VIGetVehicleDataRequest, - am_commands::UISetMediaClockTimerRequest, - am_commands::UIShowRequest, - am_commands::VIUnsubscribeVehicleDataRequest, - am_commands::VRAddCommandRequest, - am_commands::VRChangeRegistrationRequest, - am_commands::VRDeleteCommandRequest, - am_commands::UISliderRequest, - am_commands::TTSChangeRegistrationRequest, - am_commands::TTSGetCapabilitiesRequest, - am_commands::TTSGetLanguageRequest, - am_commands::AllowAllAppsRequest, - am_commands::BasicCommunicationSystemRequest, - am_commands::ButtonGetCapabilitiesRequest, - am_commands::NaviSendLocationRequest, - am_commands::NaviUnSubscribeWayPointsRequest, - am_commands::NaviUpdateTurnListRequest, - am_commands::NaviShowConstantTBTRequest, - am_commands::NaviStopStreamRequest, - am_commands::NaviSubscribeWayPointsRequest, - am_commands::NaviAlertManeuverRequest, - am_commands::AudioStopStreamRequest, - am_commands::NaviGetWayPointsRequest, - am_commands::UISetGlobalPropertiesRequest, - am_commands::UISendHapticDataRequest> RequestCommandsList; - -typedef Types<am_commands::UIScrollableMessageRequest, - am_commands::VRGetCapabilitiesRequest, - am_commands::UISetAppIconRequest, - am_commands::UiSetDisplayLayoutRequest, - am_commands::VRGetSupportedLanguagesRequest, - am_commands::VRGetLanguageRequest, - am_commands::VRPerformInteractionRequest, - am_commands::AllowAppRequest, -// TODO (OKozlov). Need to clarify why UT fails -// for UISetIconRequest -// am_commands::UISetIconRequest, -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) - am_commands::SDLPolicyUpdate, -#endif - am_commands::hmi::DialNumberRequest> RequestCommandsList2; - -typedef Types<am_commands::VIIsReadyRequest, - am_commands::TTSIsReadyRequest, - am_commands::UIIsReadyRequest, - am_commands::NaviIsReadyRequest, - am_commands::VRIsReadyRequest> RequestCommandsList3; - -TYPED_TEST_CASE(RequestToHMICommandsTest, RequestCommandsList); -TYPED_TEST_CASE(RequestToHMICommandsTest2, RequestCommandsList2); -TYPED_TEST_CASE(RequestToHMICommandsTest3, RequestCommandsList3); - -TYPED_TEST(RequestToHMICommandsTest, Run_SendMessageToHMI_SUCCESS) { - typedef typename TestFixture::CommandType CommandType; - - SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); - EXPECT_CALL(this->app_mngr_, SendMessageToHMI(NotNull())); - - command->Run(); -} - -TYPED_TEST(RequestToHMICommandsTest2, Run_SendMessageToHMI_SUCCESS) { - typedef typename TestFixture::CommandType CommandType; - - SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); - EXPECT_CALL(this->app_mngr_, SendMessageToHMI(NotNull())); - - command->Run(); -} - -TYPED_TEST(RequestToHMICommandsTest3, Run_SendMessageToHMI_SUCCESS) { - typedef typename TestFixture::CommandType CommandType; - - SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); - - EXPECT_CALL(this->app_mngr_, SendMessageToHMI(NotNull())); - - command->Run(); -} - -} // namespace simple_requests_to_hmi_test -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc b/src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc deleted file mode 100644 index f55b2e5835..0000000000 --- a/src/components/application_manager/test/commands/hmi/simple_response_from_hmi_test.cc +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (c) 2016, Ford Motor Company - * All rights reserved. - * - * Copyright (c) 2017 Xevo Inc. - * 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 copyright holders nor the names of their 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 "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/commands/command.h" -#include "hmi/activate_app_response.h" -#include "hmi/basic_communication_system_response.h" -#include "hmi/navi_alert_maneuver_response.h" -#include "hmi/navi_audio_start_stream_response.h" -#include "hmi/navi_audio_stop_stream_response.h" -#include "hmi/navi_get_way_points_response.h" -#include "hmi/navi_send_location_response.h" -#include "hmi/navi_show_constant_tbt_response.h" -#include "hmi/navi_start_stream_response.h" -#include "hmi/navi_stop_stream_response.h" -#include "hmi/navi_subscribe_way_points_response.h" -#include "hmi/navi_unsubscribe_way_points_response.h" -#include "hmi/navi_update_turn_list_response.h" -#include "hmi/tts_change_registration_response.h" -#include "hmi/ui_set_app_icon_response.h" -#include "hmi/ui_set_display_layout_response.h" -#include "hmi/ui_set_global_properties_response.h" -#include "hmi/ui_scrollable_message_response.h" -#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" -#include "hmi/tts_speak_response.h" -#include "hmi/tts_stop_speaking_response.h" -#include "hmi/tts_change_registration_response.h" -#include "hmi/ui_add_command_response.h" -#include "hmi/ui_add_submenu_response.h" -#include "hmi/ui_alert_response.h" -#include "hmi/ui_change_registration_response.h" -#include "hmi/ui_delete_command_response.h" -#include "hmi/ui_delete_submenu_response.h" -#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" -#include "hmi/vr_perform_interaction_response.h" -#include "hmi/activate_app_response.h" -#include "hmi/basic_communication_system_response.h" -#include "hmi/navi_unsubscribe_way_points_response.h" -#include "hmi/navi_update_turn_list_response.h" -#include "hmi/navi_send_location_response.h" -#include "hmi/navi_show_constant_tbt_response.h" -#include "hmi/navi_start_stream_response.h" -#include "hmi/navi_subscribe_way_points_response.h" -#include "hmi/on_find_applications.h" -#include "hmi/on_update_device_list.h" -#include "hmi/sdl_policy_update_response.h" -#include "hmi/update_app_list_response.h" -#include "hmi/update_device_list_response.h" -#include "hmi/notification_from_hmi.h" -#include "hmi/ui_send_haptic_data_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace simple_response_from_hmi_test { - -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; -using ::testing::Types; -using ::testing::Eq; - -using ::utils::SharedPtr; -using ::test::components::event_engine_test::MockEventDispatcher; - -namespace am = ::application_manager; -namespace commands = am::commands; -using commands::MessageSharedPtr; - -template <class CommandD> -class ResponseFromHMICommandsTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - typedef CommandD CommandData; - MockEventDispatcher event_dispatcher_; - - ResponseFromHMICommandsTest() { - ON_CALL(app_mngr_, event_dispatcher()) - .WillByDefault(ReturnRef(event_dispatcher_)); - } -}; - -template <class Command> -class EmptyResponseFromHMICommandsTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - typedef Command CommandType; -}; - -template <class Command, hmi_apis::FunctionID::eType kExpectedEventId> -struct CommandData { - typedef Command CommandType; - enum { kEventId = kExpectedEventId }; -}; - -typedef Types< - CommandData<commands::VIReadDIDResponse, - hmi_apis::FunctionID::VehicleInfo_ReadDID>, - CommandData<commands::TTSSpeakResponse, hmi_apis::FunctionID::TTS_Speak>, - CommandData<commands::VISubscribeVehicleDataResponse, - hmi_apis::FunctionID::VehicleInfo_SubscribeVehicleData>, - CommandData<commands::hmi::DialNumberResponse, - hmi_apis::FunctionID::BasicCommunication_DialNumber>, - CommandData<commands::UIDeleteSubmenuResponse, - hmi_apis::FunctionID::UI_DeleteSubMenu>, - CommandData<commands::UIEndAudioPassThruResponse, - hmi_apis::FunctionID::UI_EndAudioPassThru>, - CommandData<commands::TTSSetGlobalPropertiesResponse, - hmi_apis::FunctionID::TTS_SetGlobalProperties>, - CommandData<commands::TTSStopSpeakingResponse, - hmi_apis::FunctionID::TTS_StopSpeaking>, - CommandData<commands::UIAddCommandResponse, - hmi_apis::FunctionID::UI_AddCommand>, - CommandData<commands::UIAddSubmenuResponse, - hmi_apis::FunctionID::UI_AddSubMenu>, - CommandData<commands::UIAlertResponse, hmi_apis::FunctionID::UI_Alert>, - CommandData<commands::UIChangeRegistratioResponse, - hmi_apis::FunctionID::UI_ChangeRegistration>, - CommandData<commands::UIDeleteCommandResponse, - hmi_apis::FunctionID::UI_DeleteCommand>, - CommandData<commands::UIPerformAudioPassThruResponse, - hmi_apis::FunctionID::UI_PerformAudioPassThru>, - CommandData<commands::UIPerformInteractionResponse, - hmi_apis::FunctionID::UI_PerformInteraction>, - CommandData<commands::UIDeleteSubmenuResponse, - hmi_apis::FunctionID::UI_DeleteSubMenu>, - CommandData<commands::UIEndAudioPassThruResponse, - hmi_apis::FunctionID::UI_EndAudioPassThru>, - CommandData<commands::VIDiagnosticMessageResponse, - hmi_apis::FunctionID::VehicleInfo_DiagnosticMessage>, - CommandData<commands::VIGetDTCsResponse, - hmi_apis::FunctionID::VehicleInfo_GetDTCs>, - CommandData<commands::UISetMediaClockTimerResponse, - hmi_apis::FunctionID::UI_SetMediaClockTimer>, - CommandData<commands::UIShowResponse, hmi_apis::FunctionID::UI_Show>, - CommandData<commands::VIUnsubscribeVehicleDataResponse, - hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData>, - CommandData<commands::VRAddCommandResponse, - hmi_apis::FunctionID::VR_AddCommand>, - CommandData<commands::VRChangeRegistrationResponse, - hmi_apis::FunctionID::VR_ChangeRegistration>, - CommandData<commands::VRDeleteCommandResponse, - hmi_apis::FunctionID::VR_DeleteCommand>, - CommandData<commands::UISliderResponse, hmi_apis::FunctionID::UI_Slider>, - CommandData<commands::TTSChangeRegistratioResponse, - hmi_apis::FunctionID::TTS_ChangeRegistration>, - CommandData<commands::ActivateAppResponse, - hmi_apis::FunctionID::BasicCommunication_ActivateApp>, - CommandData<commands::BasicCommunicationSystemResponse, - hmi_apis::FunctionID::BasicCommunication_SystemRequest>, - CommandData<commands::NaviAlertManeuverResponse, - hmi_apis::FunctionID::Navigation_AlertManeuver>, - CommandData<commands::AudioStartStreamResponse, - hmi_apis::FunctionID::Navigation_StartAudioStream>, - CommandData<commands::NaviGetWayPointsResponse, - hmi_apis::FunctionID::Navigation_GetWayPoints>, - CommandData<commands::NaviSendLocationResponse, - hmi_apis::FunctionID::Navigation_SendLocation>, - CommandData<commands::NaviShowConstantTBTResponse, - hmi_apis::FunctionID::Navigation_ShowConstantTBT>, - CommandData<commands::NaviStartStreamResponse, - hmi_apis::FunctionID::Navigation_StartStream>, - CommandData<commands::NaviSubscribeWayPointsResponse, - hmi_apis::FunctionID::Navigation_SubscribeWayPoints>, - CommandData<commands::NaviUnsubscribeWayPointsResponse, - hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints>, - CommandData<commands::NaviUpdateTurnListResponse, - hmi_apis::FunctionID::Navigation_UpdateTurnList>, - CommandData<commands::UISetAppIconResponse, - hmi_apis::FunctionID::UI_SetAppIcon>, - CommandData<commands::UiSetDisplayLayoutResponse, - hmi_apis::FunctionID::UI_SetDisplayLayout>, - CommandData<commands::UISetGlobalPropertiesResponse, - hmi_apis::FunctionID::UI_SetGlobalProperties>, - CommandData<commands::UISetGlobalPropertiesResponse, - hmi_apis::FunctionID::UI_SetGlobalProperties>, - CommandData<commands::VRPerformInteractionResponse, - hmi_apis::FunctionID::VR_PerformInteraction>, - CommandData<commands::UIScrollableMessageResponse, - hmi_apis::FunctionID::UI_ScrollableMessage>, - CommandData<commands::UISendHapticDataResponse, - hmi_apis::FunctionID::UI_SendHapticData> > ResponseCommandsList; - -typedef Types<commands::AudioStopStreamResponse, - commands::NaviStopStreamResponse, - commands::OnFindApplications, - commands::OnUpdateDeviceList, - commands::SDLPolicyUpdateResponse, - commands::UpdateAppListResponse, - commands::UpdateDeviceListResponse> EmptyResponseCommandsList; - -TYPED_TEST_CASE(ResponseFromHMICommandsTest, ResponseCommandsList); - -TYPED_TEST_CASE(EmptyResponseFromHMICommandsTest, EmptyResponseCommandsList); - -MATCHER_P(EventIdIsEqualTo, function_id, "") { - return static_cast<hmi_apis::FunctionID::eType>(function_id) == arg.id(); -} - -TYPED_TEST(ResponseFromHMICommandsTest, Run_SendMessageToHMI_SUCCESS) { - typedef typename TestFixture::CommandData CommandData; - typedef typename CommandData::CommandType CommandType; - - SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); - - EXPECT_CALL(this->event_dispatcher_, - raise_event(EventIdIsEqualTo(CommandData::kEventId))); - - command->Run(); -} - -TYPED_TEST(EmptyResponseFromHMICommandsTest, Run_SUCCESS) { - typedef typename TestFixture::CommandType CommandType; - - SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); - - command->Run(); -} - -class OtherResponseFromHMICommandsTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -MATCHER_P(VehicleTypeIsEqualTo, vehicle_type, "") { - return (*vehicle_type) == arg.asString(); -} - -TEST_F(OtherResponseFromHMICommandsTest, VIGetVehicleTypeResponse_Run_SUCCESS) { - const std::string kVehicleType = "Test"; - - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[am::strings::msg_params][am::hmi_response::vehicle_type] = - kVehicleType; - - SharedPtr<commands::VIGetVehicleTypeResponse> command( - CreateCommand<commands::VIGetVehicleTypeResponse>(command_msg)); - - application_manager_test::MockHMICapabilities hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(hmi_capabilities)); - - EXPECT_CALL(hmi_capabilities, - set_vehicle_type(VehicleTypeIsEqualTo(&kVehicleType))); - - command->Run(); -} - -TEST_F(OtherResponseFromHMICommandsTest, VIIsReadyResponse_Run_SUCCESS) { - SharedPtr<commands::VIIsReadyResponse> command( - CreateCommand<commands::VIIsReadyResponse>()); - - MockEventDispatcher mock_event_dispatcher; - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher)); - EXPECT_CALL(mock_event_dispatcher, raise_event(_)); - - command->Run(); -} - -MATCHER_P(CheckMsgType, msg_type, "") { - return msg_type == - static_cast<int32_t>( - (*arg)[am::strings::params][am::strings::message_type].asInt()); -} - -class NotificationFromHMITest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(NotificationFromHMITest, BasicMethodsOverloads_SUCCESS) { - SharedPtr<commands::NotificationFromHMI> command( - CreateCommand<commands::NotificationFromHMI>()); - // Current implementation always return `true` - EXPECT_TRUE(command->Init()); - EXPECT_TRUE(command->CleanUp()); - EXPECT_NO_THROW(command->Run()); -} - -TEST_F(NotificationFromHMITest, SendNotificationToMobile_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[am::strings::params][am::strings::message_type] = - static_cast<int32_t>(am::MessageType::kNotification); - - SharedPtr<commands::NotificationFromHMI> command( - CreateCommand<commands::NotificationFromHMI>()); - - EXPECT_CALL( - app_mngr_, - ManageMobileCommand(CheckMsgType(am::MessageType::kNotification), - am::commands::Command::CommandOrigin::ORIGIN_SDL)); - - command->SendNotificationToMobile(command_msg); -} - -TEST_F(NotificationFromHMITest, CreateHMIRequest_UNSUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[am::strings::msg_params] = 0; - SharedPtr<commands::NotificationFromHMI> command( - CreateCommand<commands::NotificationFromHMI>(command_msg)); - - const uint32_t correlation_id = 1u; - EXPECT_CALL(app_mngr_, GetNextHMICorrelationID()) - .WillOnce(Return(correlation_id)); - EXPECT_CALL(app_mngr_, - ManageHMICommand(CheckMsgType(am::MessageType::kRequest))) - .WillOnce(Return(false)); - - command->CreateHMIRequest(hmi_apis::FunctionID::INVALID_ENUM, - (*command_msg)[am::strings::msg_params]); -} - -} // namespace simple_response_from_hmi_test -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/simple_response_to_hmi_test.cc b/src/components/application_manager/test/commands/hmi/simple_response_to_hmi_test.cc deleted file mode 100644 index 3948d2bfe3..0000000000 --- a/src/components/application_manager/test/commands/hmi/simple_response_to_hmi_test.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2016, 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 "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/commands/command.h" -#include "application_manager/commands/hmi/sdl_activate_app_response.h" -#include "application_manager/commands/hmi/sdl_get_list_of_permissions_response.h" -#include "application_manager/commands/hmi/sdl_get_status_update_response.h" -#include "application_manager/commands/hmi/sdl_get_user_friendly_message_response.h" -#include "application_manager/commands/hmi/response_to_hmi.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace simple_response_to_hmi_test { - -using ::testing::_; -using ::testing::Types; -using ::testing::NotNull; -using ::utils::SharedPtr; - -namespace commands = ::application_manager::commands; -using commands::MessageSharedPtr; - -template <class Command> -class ResponseToHMICommandsTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - typedef Command CommandType; -}; - -typedef Types<commands::SDLActivateAppResponse, - commands::SDLGetListOfPermissionsResponse, - commands::SDLGetStatusUpdateResponse, - commands::SDLGetUserFriendlyMessageResponse> ResponseCommandsList; - -TYPED_TEST_CASE(ResponseToHMICommandsTest, ResponseCommandsList); - -TYPED_TEST(ResponseToHMICommandsTest, Run_SendMessageToHMI_SUCCESS) { - typedef typename TestFixture::CommandType CommandType; - - SharedPtr<CommandType> command = this->template CreateCommand<CommandType>(); - - EXPECT_CALL(this->app_mngr_, SendMessageToHMI(NotNull())); - - command->Run(); -} - -class ResponseToHMITest : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(ResponseToHMITest, BasicMethodsOverloads_SUCCESS) { - SharedPtr<commands::ResponseToHMI> command( - CreateCommand<commands::ResponseToHMI>()); - - // Current implementation always return `true` - EXPECT_TRUE(command->Init()); - EXPECT_TRUE(command->CleanUp()); -} - -TEST_F(ResponseToHMITest, Run_SUCCESS) { - SharedPtr<commands::ResponseToHMI> command( - CreateCommand<commands::ResponseToHMI>()); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(NotNull())); - - command->Run(); -} - -} // namespace simple_response_to_hmi_test -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/tts_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/tts_get_capabilities_response_test.cc deleted file mode 100644 index c7b5c76b40..0000000000 --- a/src/components/application_manager/test/commands/hmi/tts_get_capabilities_response_test.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/tts_get_capabilities_response.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "smart_objects/smart_object.h" -#include "commands/commands_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace tts_get_capabilities_response { - -using application_manager::commands::MessageSharedPtr; -using application_manager::commands::TTSGetCapabilitiesResponse; -using test::components::application_manager_test::MockHMICapabilities; -using utils::SharedPtr; -using testing::_; - -namespace strings = ::application_manager::strings; -namespace hmi_response = ::application_manager::hmi_response; - -namespace { -const std::string kText = "TEXT"; -} - -class TTSGetCapabilitiesResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MockHMICapabilities mock_hmi_capabilities_; -}; - -TEST_F(TTSGetCapabilitiesResponseTest, Run_BothExist_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::speech_capabilities] = kText; - (*msg)[strings::msg_params][hmi_response::prerecorded_speech_capabilities] = - kText; - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(mock_hmi_capabilities_, - set_speech_capabilities(SmartObject(kText))); - EXPECT_CALL(mock_hmi_capabilities_, - set_prerecorded_speech(SmartObject(kText))); - - SharedPtr<TTSGetCapabilitiesResponse> command( - CreateCommand<TTSGetCapabilitiesResponse>(msg)); - - command->Run(); -} - -TEST_F(TTSGetCapabilitiesResponseTest, Run_OnlySpeech_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::speech_capabilities] = kText; - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(mock_hmi_capabilities_, - set_speech_capabilities(SmartObject(kText))); - EXPECT_CALL(mock_hmi_capabilities_, set_prerecorded_speech(_)).Times(0); - - SharedPtr<TTSGetCapabilitiesResponse> command( - CreateCommand<TTSGetCapabilitiesResponse>(msg)); - - command->Run(); -} - -TEST_F(TTSGetCapabilitiesResponseTest, Run_OnlyPrerecorded_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::prerecorded_speech_capabilities] = - kText; - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(mock_hmi_capabilities_, set_speech_capabilities(_)).Times(0); - EXPECT_CALL(mock_hmi_capabilities_, - set_prerecorded_speech(SmartObject(kText))); - - SharedPtr<TTSGetCapabilitiesResponse> command( - CreateCommand<TTSGetCapabilitiesResponse>(msg)); - - command->Run(); -} - -TEST_F(TTSGetCapabilitiesResponseTest, Run_Nothing_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - EXPECT_CALL(mock_hmi_capabilities_, set_speech_capabilities(_)).Times(0); - EXPECT_CALL(mock_hmi_capabilities_, set_prerecorded_speech(_)).Times(0); - - SharedPtr<TTSGetCapabilitiesResponse> command( - CreateCommand<TTSGetCapabilitiesResponse>(msg)); - - command->Run(); -} - -} // namespace tts_get_capabilities_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/tts_get_language_response_test.cc b/src/components/application_manager/test/commands/hmi/tts_get_language_response_test.cc deleted file mode 100644 index e0b2fad5b9..0000000000 --- a/src/components/application_manager/test/commands/hmi/tts_get_language_response_test.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/tts_get_language_response.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_event_dispatcher.h" -#include "commands/commands_test.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace tts_get_language_response { - -using utils::SharedPtr; -using application_manager::commands::TTSGetLanguageResponse; -using test::components::application_manager_test::MockHMICapabilities; -using test::components::event_engine_test::MockEventDispatcher; -using testing::_; -using testing::ReturnRef; - -namespace strings = application_manager::strings; -namespace hmi_response = application_manager::hmi_response; -using namespace hmi_apis; - -namespace { -const Common_Language::eType kLanguage = Common_Language::EN_GB; -} // namespace - -class TTSGetLanguageResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(TTSGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::language] = kLanguage; - - SharedPtr<TTSGetLanguageResponse> command( - CreateCommand<TTSGetLanguageResponse>(msg)); - - MockHMICapabilities mock_hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_hmi_capabilities, set_active_tts_language(kLanguage)); - - 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(TTSGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - - SharedPtr<TTSGetLanguageResponse> command( - CreateCommand<TTSGetLanguageResponse>(msg)); - - MockHMICapabilities mock_hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_hmi_capabilities, - set_active_tts_language(Common_Language::INVALID_ENUM)); - - 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 tts_get_language_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/tts_get_supported_languages_response_test.cc b/src/components/application_manager/test/commands/hmi/tts_get_supported_languages_response_test.cc deleted file mode 100644 index 547fc02481..0000000000 --- a/src/components/application_manager/test/commands/hmi/tts_get_supported_languages_response_test.cc +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/hmi/response_from_hmi.h" -#include "application_manager/commands/hmi/tts_get_supported_languages_response.h" -#include "application_manager/policies/mock_policy_handler_interface.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace tts_get_supported_languages_response { - -using ::testing::_; -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::ResponseFromHMI; -using am::commands::TTSGetSupportedLanguagesResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class TTSGetSupportedLanguageResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(TTSGetSupportedLanguageResponseTest, RUN_SUCCESS) { - smart_objects::SmartObject supported_languages("EN_US"); - - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - (*command_msg)[strings::msg_params][hmi_response::languages] = - supported_languages; - - ResponseFromHMIPtr command( - CreateCommand<TTSGetSupportedLanguagesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_tts_supported_languages(( - *command_msg)[strings::msg_params][hmi_response::languages])); - - command->Run(); -} -TEST_F(TTSGetSupportedLanguageResponseTest, RUN_UNSUCCESS) { - smart_objects::SmartObject supported_languages("EN_US"); - - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::WRONG_LANGUAGE; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - - ResponseFromHMIPtr command( - CreateCommand<TTSGetSupportedLanguagesResponse>(command_msg)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_tts_supported_languages(supported_languages)).Times(0); - - command->Run(); - - EXPECT_FALSE((*command_msg)[am::strings::msg_params].keyExists( - am::hmi_response::languages)); -} - -} // namespace tts_get_supported_languages_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/tts_is_ready_response_test.cc b/src/components/application_manager/test/commands/hmi/tts_is_ready_response_test.cc deleted file mode 100644 index 52c66ff877..0000000000 --- a/src/components/application_manager/test/commands/hmi/tts_is_ready_response_test.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_message_helper.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/hmi/response_from_hmi.h" -#include "application_manager/commands/hmi/tts_is_ready_response.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/mock_event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace tts_is_ready_response { - -using ::testing::_; -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::ResponseFromHMI; -using am::commands::TTSIsReadyResponse; -using am::commands::CommandImpl; -using test::components::event_engine_test::MockEventDispatcher; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -const bool kIsAvailable = true; -const bool kIsNotAvailable = false; -} // namespace - -class TTSIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(TTSIsReadyResponseTest, RUN_SUCCESS) { - ResponseFromHMIPtr command(CreateCommand<TTSIsReadyResponse>()); - 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 tts_is_ready_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc deleted file mode 100644 index b02c9851ee..0000000000 --- a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 2016, Ford Motor Company - * All rights reserved. - * - * Copyright (c) 2017 Xevo Inc. - * 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 copyright holders nor the names of their 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "utils/make_shared.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" -#include "application_manager/commands/hmi/ui_get_capabilities_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace ui_get_capabilities_response { - -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = am::strings; -namespace hmi_response = am::hmi_response; -using am::commands::ResponseFromHMI; -using am::commands::UIGetCapabilitiesResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<ResponseFromHMI> ResponseFromHMIPtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class UIGetCapabilitiesResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr CreateCommandMsg() { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - - return command_msg; - } - - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(UIGetCapabilitiesResponseTest, RUN_SetDisplay_SUCCESSS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][hmi_response::display_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - (*command_msg)[strings::msg_params][hmi_response::display_capabilities] - [hmi_response::display_type] = "GEN2_8_DMA"; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject display_capabilities_so = - (*command_msg)[strings::msg_params][hmi_response::display_capabilities]; - - EXPECT_CALL(mock_hmi_capabilities_, - set_display_capabilities(display_capabilities_so)); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetSoftButton_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][hmi_response::soft_button_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - (*command_msg)[strings::msg_params][hmi_response::soft_button_capabilities] - [hmi_response::image_supported] = true; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject soft_button_capabilities_so = (*command_msg) - [strings::msg_params][hmi_response::soft_button_capabilities]; - - EXPECT_CALL(mock_hmi_capabilities_, - set_soft_button_capabilities(soft_button_capabilities_so)); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetHmiZone_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][hmi_response::hmi_zone_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - (*command_msg)[strings::msg_params][hmi_response::hmi_zone_capabilities][0] = - "FRONT"; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject hmi_zone_capabilities_so = - (*command_msg)[strings::msg_params][hmi_response::hmi_zone_capabilities]; - - EXPECT_CALL(mock_hmi_capabilities_, - set_hmi_zone_capabilities(hmi_zone_capabilities_so)); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetAudioPassThru_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::audio_pass_thru_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject audio_pass_thru_capabilities_so = (*command_msg) - [strings::msg_params][strings::audio_pass_thru_capabilities]; - EXPECT_CALL( - mock_hmi_capabilities_, - set_audio_pass_thru_capabilities(audio_pass_thru_capabilities_so)); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetNavigation_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::hmi_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - (*command_msg)[strings::msg_params][strings::hmi_capabilities] - [strings::navigation] = true; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject hmi_capabilities_so = - (*command_msg)[strings::msg_params][strings::hmi_capabilities]; - EXPECT_CALL(mock_hmi_capabilities_, - set_navigation_supported( - hmi_capabilities_so[strings::navigation].asBool())); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetPhoneCall_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::hmi_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - (*command_msg)[strings::msg_params][strings::hmi_capabilities] - [strings::phone_call] = true; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject hmi_capabilities_so = - (*command_msg)[strings::msg_params][strings::hmi_capabilities]; - EXPECT_CALL(mock_hmi_capabilities_, - set_phone_call_supported( - hmi_capabilities_so[strings::phone_call].asBool())); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreaming_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::hmi_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - (*command_msg)[strings::msg_params][strings::hmi_capabilities] - [strings::video_streaming] = true; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject hmi_capabilities_so = - (*command_msg)[strings::msg_params][strings::hmi_capabilities]; - EXPECT_CALL(mock_hmi_capabilities_, - set_video_streaming_supported( - hmi_capabilities_so[strings::video_streaming].asBool())); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetNavigationCapability_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::system_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::navigation_capability]["sendLocationEnabled"] = true; - - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::navigation_capability]["getWayPointsEnabled"] = true; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject navigation_capability_so = - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::navigation_capability]; - - EXPECT_CALL(mock_hmi_capabilities_, - set_navigation_capability(navigation_capability_so)); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetPhonenCapability_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::system_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::phone_capability]["dialNumberEnabled"] = true; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject phone_capability_so = - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::phone_capability]; - - EXPECT_CALL(mock_hmi_capabilities_, - set_phone_capability(phone_capability_so)); - - command->Run(); -} - -TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::system_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::video_streaming_capability] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - smart_objects::SmartObject& video_streaming_capability = - (*command_msg)[strings::msg_params][strings::system_capabilities] - [strings::video_streaming_capability]; - - video_streaming_capability[strings::preferred_resolution] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - video_streaming_capability[strings::preferred_resolution] - [strings::resolution_width] = 800; - video_streaming_capability[strings::preferred_resolution] - [strings::resolution_height] = 350; - - video_streaming_capability[strings::max_bitrate] = 10000; - - video_streaming_capability[strings::supported_formats] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - - video_streaming_capability[strings::supported_formats][0] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - - video_streaming_capability[strings::supported_formats][0][strings::protocol] = - hmi_apis::Common_VideoStreamingProtocol::RAW; - - video_streaming_capability[strings::supported_formats][0][strings::codec] = - hmi_apis::Common_VideoStreamingCodec::H264; - - video_streaming_capability[strings::haptic_spatial_data_supported] = true; - - ResponseFromHMIPtr command( - CreateCommand<UIGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_video_streaming_capability(video_streaming_capability)); - - command->Run(); -} - -} // namespace ui_get_capabilities_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/ui_get_language_response_test.cc b/src/components/application_manager/test/commands/hmi/ui_get_language_response_test.cc deleted file mode 100644 index e45e4583e5..0000000000 --- a/src/components/application_manager/test/commands/hmi/ui_get_language_response_test.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/ui_get_language_response.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_application_manager.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace ui_get_language_response { - -using utils::SharedPtr; -using application_manager::commands::UIGetLanguageResponse; -using test::components::event_engine_test::MockEventDispatcher; -using testing::_; -using testing::ReturnRef; -using ::testing::NiceMock; - -namespace strings = application_manager::strings; -namespace hmi_response = application_manager::hmi_response; -using namespace hmi_apis; - -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const hmi_apis::Common_Language::eType kLanguage = Common_Language::EN_GB; -} // namespace - -class UIGetLanguageResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(UIGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::language] = kLanguage; - - SharedPtr<UIGetLanguageResponse> command( - CreateCommand<UIGetLanguageResponse>(msg)); - - MockHMICapabilities mock_hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_hmi_capabilities, set_active_ui_language(kLanguage)); - - 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(UIGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - - SharedPtr<UIGetLanguageResponse> command( - CreateCommand<UIGetLanguageResponse>(msg)); - - MockHMICapabilities mock_hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_hmi_capabilities, - set_active_ui_language(Common_Language::INVALID_ENUM)); - - 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 ui_get_language_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/ui_get_supported_languages_response_test.cc b/src/components/application_manager/test/commands/hmi/ui_get_supported_languages_response_test.cc deleted file mode 100644 index 690c863ccb..0000000000 --- a/src/components/application_manager/test/commands/hmi/ui_get_supported_languages_response_test.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/application.h" -#include "commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/hmi/ui_get_supported_languages_response.h" -#include "application_manager/policies/mock_policy_handler_interface.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace ui_get_supported_languages_response { - -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::UIGetSupportedLanguagesResponse; - -typedef SharedPtr<UIGetSupportedLanguagesResponse> - UIGetSupportedLanguagesResponsePtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -const std::string kStringNum = "123"; -const std::string kLanguage = "EN_US"; -const smart_objects::SmartObject supported_languages(kLanguage); -} // namespace - -class UIGetSupportedLanguagesResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(UIGetSupportedLanguagesResponseTest, RUN_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = kStringNum; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - (*command_msg)[strings::msg_params][hmi_response::languages] = - supported_languages; - - UIGetSupportedLanguagesResponsePtr command( - CreateCommand<UIGetSupportedLanguagesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_ui_supported_languages((supported_languages))); - - command->Run(); -} -TEST_F(UIGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = kStringNum; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::WRONG_LANGUAGE; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - - UIGetSupportedLanguagesResponsePtr command( - CreateCommand<UIGetSupportedLanguagesResponse>(command_msg)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_ui_supported_languages(supported_languages)).Times(0); - - command->Run(); - - EXPECT_FALSE((*command_msg)[am::strings::msg_params].keyExists( - am::hmi_response::languages)); -} - -} // namespace ui_get_supported_languages_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc deleted file mode 100644 index 66b1317870..0000000000 --- a/src/components/application_manager/test/commands/hmi/ui_is_ready_request_test.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/ui_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 ui_is_ready_request { - -namespace am = ::application_manager; - -using ::testing::_; -using ::testing::Return; -using ::testing::ReturnRef; -using am::commands::MessageSharedPtr; -using am::commands::UIIsReadyRequest; -using am::event_engine::Event; - -typedef SharedPtr<UIIsReadyRequest> UIIsReadyRequestPtr; - -class UIIsReadyRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - UIIsReadyRequestTest() : command_(CreateCommand<UIIsReadyRequest>()) {} - - void SetUp() OVERRIDE { - ON_CALL(app_mngr_, hmi_capabilities()) - .WillByDefault(ReturnRef(mock_hmi_capabilities_)); - } - void SetUpExpectations(bool is_ui_cooperating_available, - bool is_send_message_to_hmi, - bool is_message_contain_param, - am::HmiInterfaces::InterfaceState state) { - EXPECT_CALL(mock_hmi_capabilities_, - set_is_ui_cooperating(is_ui_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_UI, state)); - } else { - EXPECT_CALL(app_mngr_, hmi_interfaces()) - .WillOnce(ReturnRef(mock_hmi_interfaces_)); - EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0); - } - - EXPECT_CALL(mock_hmi_interfaces_, - GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) - .WillOnce(Return(state)); - - if (is_send_message_to_hmi) { - ExpectSendMessagesToHMI(); - } - } - - void ExpectSendMessagesToHMI() { - smart_objects::SmartObjectSPtr get_language(CreateMessage()); - (*get_language)[am::strings::params][am::strings::message_type] = - static_cast<int>(am::MessageType::kRequest); - (*get_language)[am::strings::msg_params] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - EXPECT_CALL(mock_message_helper_, - CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetLanguage, _)) - .WillOnce(Return(get_language)); - - smart_objects::SmartObjectSPtr get_all_language(CreateMessage()); - (*get_all_language)[am::strings::params][am::strings::message_type] = - static_cast<int>(am::MessageType::kRequest); - (*get_all_language)[am::strings::msg_params] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - EXPECT_CALL( - mock_message_helper_, - CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetSupportedLanguages, _)) - .WillOnce(Return(get_all_language)); - - smart_objects::SmartObjectSPtr get_capabilities(CreateMessage()); - (*get_capabilities)[am::strings::params][am::strings::message_type] = - static_cast<int>(am::MessageType::kRequest); - (*get_capabilities)[am::strings::msg_params] = - smart_objects::SmartObject(smart_objects::SmartType_Map); - EXPECT_CALL(mock_message_helper_, - CreateModuleInfoSO(hmi_apis::FunctionID::UI_GetCapabilities, _)) - .WillOnce(Return(get_capabilities)); - - EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*get_language)); - EXPECT_CALL(app_mngr_, ManageHMICommand(get_language)); - EXPECT_CALL(app_mngr_, ManageHMICommand(get_all_language)); - EXPECT_CALL(app_mngr_, ManageHMICommand(get_capabilities)); - } - - void PrepareEvent(bool is_message_contain_param, - Event& event, - bool is_ui_cooperating_available = false) { - MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); - if (is_message_contain_param) { - (*msg)[am::strings::msg_params][am::strings::available] = - is_ui_cooperating_available; - } - event.set_smart_object(*msg); - } - - UIIsReadyRequestPtr command_; - application_manager_test::MockHMICapabilities mock_hmi_capabilities_; - policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_; -}; - -TEST_F(UIIsReadyRequestTest, - OnEvent_NoKeyAvailableInMessage_HmiInterfacesIgnored) { - const bool is_ui_cooperating_available = false; - const bool is_send_message_to_hmi = true; - const bool is_message_contain_param = false; - Event event(hmi_apis::FunctionID::UI_IsReady); - PrepareEvent(is_message_contain_param, event); - SetUpExpectations(is_ui_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_NOT_RESPONSE); - - command_->on_event(event); -} - -TEST_F(UIIsReadyRequestTest, - OnEvent_KeyAvailableEqualToFalse_StateNotAvailable) { - const bool is_ui_cooperating_available = false; - const bool is_send_message_to_hmi = false; - const bool is_message_contain_param = true; - Event event(hmi_apis::FunctionID::UI_IsReady); - PrepareEvent(is_message_contain_param, event); - SetUpExpectations(is_ui_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_NOT_AVAILABLE); - command_->on_event(event); -} - -TEST_F(UIIsReadyRequestTest, OnEvent_KeyAvailableEqualToTrue_StateAvailable) { - const bool is_ui_cooperating_available = true; - const bool is_send_message_to_hmi = true; - const bool is_message_contain_param = true; - Event event(hmi_apis::FunctionID::UI_IsReady); - PrepareEvent(is_message_contain_param, event, is_ui_cooperating_available); - SetUpExpectations(is_ui_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_AVAILABLE); - command_->on_event(event); -} - -TEST_F(UIIsReadyRequestTest, OnTimeout_SUCCESS) { - ExpectSendMessagesToHMI(); - command_->onTimeOut(); -} - -} // namespace ui_is_ready_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/ui_is_ready_response_test.cc b/src/components/application_manager/test/commands/hmi/ui_is_ready_response_test.cc deleted file mode 100644 index d69ec0528e..0000000000 --- a/src/components/application_manager/test/commands/hmi/ui_is_ready_response_test.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/commands/hmi/ui_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace ui_is_ready_response { - -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::UIIsReadyResponse; -using test::components::event_engine_test::MockEventDispatcher; - -typedef SharedPtr<UIIsReadyResponse> UIIsReadyResponsePtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -const std::string kStringNum = "123"; -const bool kIsAvailable = true; -const bool kIsNotAvailable = false; -} // namespace - -class UIIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(UIIsReadyResponseTest, RUN_SUCCESS) { - UIIsReadyResponsePtr command(CreateCommand<UIIsReadyResponse>()); - - 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 ui_is_ready_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/update_device_list_request_test.cc b/src/components/application_manager/test/commands/hmi/update_device_list_request_test.cc deleted file mode 100644 index 99eed48f71..0000000000 --- a/src/components/application_manager/test/commands/hmi/update_device_list_request_test.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "interfaces/HMI_API.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" -#include "application_manager/application_manager.h" -#include "application_manager/application_manager_impl.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_application.h" -#include "application_manager/event_engine/event.h" -#include "application_manager/request_controller_settings.h" -#include "application_manager/mock_application_manager_settings.h" -#include "application_manager/commands/hmi/update_device_list_request.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace update_device_list_request { - -using ::utils::SharedPtr; -using testing::_; -using testing::ReturnRef; -using testing::Return; -using test::components::event_engine_test::MockEventDispatcher; -using ::test::components::application_manager_test:: - MockApplicationManagerSettings; -namespace am = ::application_manager; -namespace strings = am::strings; -namespace hmi_response = am::hmi_response; -using am::event_engine::Event; -using am::commands::UpdateDeviceListRequest; -using am::commands::CommandImpl; - -typedef SharedPtr<UpdateDeviceListRequest> UpdateDeviceListRequestPtr; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class UpdateDeviceListRequestTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr CreateCommandMsg() { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - - return command_msg; - } - - MockApplicationManagerSettings settings_; - MockEventDispatcher mock_event_dispatcher_; -}; - -TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) { - MessageSharedPtr command_msg = CreateCommandMsg(); - - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); - - UpdateDeviceListRequestPtr command( - CreateCommand<UpdateDeviceListRequest>(command_msg)); - - EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings_)); - - EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(false)); - - EXPECT_CALL(app_mngr_, IsHMICooperating()).Times(0); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(command_msg)); - - command->Run(); - - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); -} - -TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); - - UpdateDeviceListRequestPtr command( - CreateCommand<UpdateDeviceListRequest>(command_msg)); - - EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings_)); - - EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true)); - - EXPECT_CALL(app_mngr_, IsHMICooperating()).WillOnce(Return(true)); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(command_msg)); - - command->Run(); - - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); -} - -TEST_F(UpdateDeviceListRequestTest, OnEvent_WrongEventId_UNSUCCESS) { - Event event(Event::EventID::INVALID_ENUM); - - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); - - UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>()); - - command->on_event(event); -} - -TEST_F(UpdateDeviceListRequestTest, OnEvent_SUCCESS) { - Event event(Event::EventID::BasicCommunication_OnReady); - - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_, _)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); - - UpdateDeviceListRequestPtr command(CreateCommand<UpdateDeviceListRequest>()); - - command->on_event(event); -} - -} // namespace update_device_list_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/update_sdl_request_test.cc b/src/components/application_manager/test/commands/hmi/update_sdl_request_test.cc deleted file mode 100644 index e9bf402aa7..0000000000 --- a/src/components/application_manager/test/commands/hmi/update_sdl_request_test.cc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "application_manager/policies/mock_policy_handler_interface.h" -#include "application_manager/commands/hmi/update_sdl_request.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace update_sdl_request { - -using ::utils::SharedPtr; -using ::testing::ReturnRef; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::UpdateSDLRequest; - -typedef SharedPtr<UpdateSDLRequest> UpdateSDLRequestPtr; - -namespace { -const uint32_t kConnectionKey = 2u; -const uint32_t kCorrelationId = 1u; -const std::string kStrNumber = "123"; -} // namespace - -class UpdateSDLRequestTest : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(UpdateSDLRequestTest, 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::correlation_id] = kCorrelationId; - - UpdateSDLRequestPtr command(CreateCommand<UpdateSDLRequest>(command_msg)); - policy_test::MockPolicyHandlerInterface policy_handler; - - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler)); - EXPECT_CALL(policy_handler, PTExchangeAtUserRequest(kCorrelationId)); - - command->Run(); - - EXPECT_EQ(kCorrelationId, - (*command_msg)[strings::params][strings::correlation_id].asUInt()); -} - -} // namespace update_sdl_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/update_sdl_response_test.cc b/src/components/application_manager/test/commands/hmi/update_sdl_response_test.cc deleted file mode 100644 index e612f438cc..0000000000 --- a/src/components/application_manager/test/commands/hmi/update_sdl_response_test.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "commands/commands_test.h" -#include "application_manager/application.h" -#include "hmi/update_sdl_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace update_sdl_response { - -using ::utils::SharedPtr; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -using am::commands::UpdateSDLResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<UpdateSDLResponse> UpdateSDLResponsePtr; - -namespace { -const uint32_t kConnectionKey = 2u; -const std::string kStrNumber = "123"; -} // namespace - -class UpdateSDLResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { -}; - -TEST_F(UpdateSDLResponseTest, RUN_SendRequest_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; - - UpdateSDLResponsePtr command(CreateCommand<UpdateSDLResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, SendMessageToHMI(command_msg)); - - command->Run(); - - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_type].asInt(), - CommandImpl::hmi_protocol_type_); - EXPECT_EQ((*command_msg)[strings::params][strings::protocol_version].asInt(), - CommandImpl::protocol_version_); -} - -} // namespace update_sdl_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/vi_get_vehicle_data_response_test.cc b/src/components/application_manager/test/commands/hmi/vi_get_vehicle_data_response_test.cc deleted file mode 100644 index e61f90a2fa..0000000000 --- a/src/components/application_manager/test/commands/hmi/vi_get_vehicle_data_response_test.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2016, 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 "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 am::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); - - policy_test::MockPolicyHandlerInterface policy_handler; - EXPECT_CALL(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(policy_handler)); - EXPECT_CALL(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/test/commands/hmi/vi_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc deleted file mode 100644 index 557afa98d0..0000000000 --- a/src/components/application_manager/test/commands/hmi/vi_is_ready_request_test.cc +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/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 am::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(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - 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(app_mngr_, GetPolicyHandler()) - .WillOnce(ReturnRef(mock_policy_handler_interface_)); - EXPECT_CALL(mock_policy_handler_interface_, 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(app_mngr_, 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_; - application_manager_test::MockHMICapabilities mock_hmi_capabilities_; - policy_test::MockPolicyHandlerInterface mock_policy_handler_interface_; -}; - -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 diff --git a/src/components/application_manager/test/commands/hmi/vr_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/vr_get_capabilities_response_test.cc deleted file mode 100644 index 907a013972..0000000000 --- a/src/components/application_manager/test/commands/hmi/vr_get_capabilities_response_test.cc +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "interfaces/MOBILE_API.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/commands/command_impl.h" -#include "application_manager/commands/hmi/vr_get_capabilities_response.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace vr_get_capabilities_response { - -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = am::strings; -namespace hmi_response = am::hmi_response; -using am::commands::VRGetCapabilitiesResponse; -using am::commands::CommandImpl; - -typedef SharedPtr<VRGetCapabilitiesResponse> VRGetCapabilitiesResponsePtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -} // namespace - -class VRGetCapabilitiesResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MessageSharedPtr CreateCommandMsg() { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = "123"; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - - return command_msg; - } - - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(VRGetCapabilitiesResponseTest, RUN_SUCCESSS) { - MessageSharedPtr command_msg = CreateCommandMsg(); - (*command_msg)[strings::msg_params][strings::vr_capabilities] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - (*command_msg)[strings::msg_params][strings::vr_capabilities][0] = - "vrCapabilities"; - - VRGetCapabilitiesResponsePtr command( - CreateCommand<VRGetCapabilitiesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - smart_objects::SmartObject vr_capabilities_so = - (*command_msg)[strings::msg_params][strings::vr_capabilities]; - - EXPECT_CALL(mock_hmi_capabilities_, set_vr_capabilities(vr_capabilities_so)); - - command->Run(); -} - -} // namespace vr_get_capabilities_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/vr_get_language_response_test.cc b/src/components/application_manager/test/commands/hmi/vr_get_language_response_test.cc deleted file mode 100644 index 7d42e39548..0000000000 --- a/src/components/application_manager/test/commands/hmi/vr_get_language_response_test.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/vr_get_language_response.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_event_dispatcher.h" -#include "application_manager/mock_application_manager.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace vr_get_language_response { - -using utils::SharedPtr; -using application_manager::commands::VRGetLanguageResponse; -using test::components::event_engine_test::MockEventDispatcher; -using testing::_; -using testing::ReturnRef; -using ::testing::NiceMock; - -namespace strings = application_manager::strings; -namespace hmi_response = application_manager::hmi_response; -using namespace hmi_apis; - -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const hmi_apis::Common_Language::eType kLanguage = Common_Language::EN_GB; -} // namespace - -class VRGetLanguageResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; - -TEST_F(VRGetLanguageResponseTest, Run_LanguageSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - (*msg)[strings::msg_params][hmi_response::language] = kLanguage; - - SharedPtr<VRGetLanguageResponse> command( - CreateCommand<VRGetLanguageResponse>(msg)); - - MockHMICapabilities mock_hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_hmi_capabilities, set_active_vr_language(kLanguage)); - - 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(VRGetLanguageResponseTest, Run_LanguageNotSet_SUCCESS) { - MessageSharedPtr msg = CreateMessage(); - - SharedPtr<VRGetLanguageResponse> command( - CreateCommand<VRGetLanguageResponse>(msg)); - - MockHMICapabilities mock_hmi_capabilities; - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities)); - EXPECT_CALL(mock_hmi_capabilities, - set_active_vr_language(Common_Language::INVALID_ENUM)); - - 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 vr_get_language_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/vr_get_supported_languages_response_test.cc b/src/components/application_manager/test/commands/hmi/vr_get_supported_languages_response_test.cc deleted file mode 100644 index 27be9e0f0f..0000000000 --- a/src/components/application_manager/test/commands/hmi/vr_get_supported_languages_response_test.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "application_manager/smart_object_keys.h" -#include "application_manager/application.h" -#include "commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/mock_application_manager.h" -#include "application_manager/commands/hmi/vr_get_supported_languages_response.h" -#include "application_manager/policies/mock_policy_handler_interface.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace vr_get_supported_languages_response { - -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::VRGetSupportedLanguagesResponse; - -typedef SharedPtr<VRGetSupportedLanguagesResponse> - VRGetSupportedLanguagesResponsePtr; -typedef NiceMock< - ::test::components::application_manager_test::MockHMICapabilities> - MockHMICapabilities; - -namespace { -const uint32_t kConnectionKey = 2u; -const std::string kStringNum = "123"; -const std::string kLanguage = "EN_US"; -const smart_objects::SmartObject supported_languages(kLanguage); -} // namespace - -class VRGetSupportedLanguagesResponseTest - : public CommandsTest<CommandsTestMocks::kIsNice> { - public: - MockHMICapabilities mock_hmi_capabilities_; - SmartObject capabilities_; -}; - -TEST_F(VRGetSupportedLanguagesResponseTest, RUN_SUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = kStringNum; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::SUCCESS; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - (*command_msg)[strings::msg_params][hmi_response::languages] = - supported_languages; - - VRGetSupportedLanguagesResponsePtr command( - CreateCommand<VRGetSupportedLanguagesResponse>(command_msg)); - - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_vr_supported_languages((supported_languages))); - - command->Run(); -} -TEST_F(VRGetSupportedLanguagesResponseTest, RUN_UNSUCCESS) { - MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map)); - (*command_msg)[strings::msg_params][strings::number] = kStringNum; - (*command_msg)[strings::params][strings::connection_key] = kConnectionKey; - (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::WRONG_LANGUAGE; - (*command_msg)[strings::msg_params][hmi_response::capabilities] = - (capabilities_); - - VRGetSupportedLanguagesResponsePtr command( - CreateCommand<VRGetSupportedLanguagesResponse>(command_msg)); - - EXPECT_CALL(mock_hmi_capabilities_, - set_vr_supported_languages(supported_languages)).Times(0); - - command->Run(); - - EXPECT_FALSE((*command_msg)[am::strings::msg_params].keyExists( - am::hmi_response::languages)); -} - -} // namespace vr_get_supported_languages_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc b/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc deleted file mode 100644 index c9403b2f0e..0000000000 --- a/src/components/application_manager/test/commands/hmi/vr_is_ready_request_test.cc +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2016, 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 "application_manager/commands/hmi/vr_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/mock_message_helper.h" -#include "application_manager/event_engine/event.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace vr_is_ready_request { - -using ::testing::_; -using ::testing::ReturnRef; -namespace am = ::application_manager; -using am::commands::MessageSharedPtr; -using am::commands::VRIsReadyRequest; -using am::event_engine::Event; - -typedef SharedPtr<VRIsReadyRequest> VRIsReadyRequestPtr; - -class VRIsReadyRequestTest - : public CommandRequestTest<CommandsTestMocks::kIsNice> { - public: - VRIsReadyRequestTest() : command_(CreateCommand<VRIsReadyRequest>()) {} - - void SetUpExpectations(bool is_vr_cooperating_available, - bool is_send_message_to_hmi, - bool is_message_contain_param, - am::HmiInterfaces::InterfaceState state) { - const bool is_send_message_by_timeout = false; - if (is_send_message_to_hmi) { - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillRepeatedly(ReturnRef(mock_hmi_capabilities_)); - ExpectSendMessagesToHMI(is_send_message_by_timeout); - } else { - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - } - EXPECT_CALL(mock_hmi_capabilities_, - set_is_vr_cooperating(is_vr_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_VR, state)); - } else { - EXPECT_CALL(app_mngr_, hmi_interfaces()) - .WillOnce(ReturnRef(mock_hmi_interfaces_)); - EXPECT_CALL(mock_hmi_interfaces_, SetInterfaceState(_, _)).Times(0); - } - EXPECT_CALL(mock_hmi_interfaces_, - GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_VR)) - .WillOnce(Return(state)); - } - - void ExpectSendMessagesToHMI(bool is_send_message_by_timeout) { - if (is_send_message_by_timeout) { - EXPECT_CALL(app_mngr_, hmi_capabilities()) - .WillOnce(ReturnRef(mock_hmi_capabilities_)); - } - - smart_objects::SmartObjectSPtr language( - new smart_objects::SmartObject(smart_objects::SmartType_Map)); - EXPECT_CALL(mock_message_helper_, - CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetLanguage, _)) - .WillOnce(Return(language)); - EXPECT_CALL(mock_hmi_capabilities_, set_handle_response_for(*language)); - EXPECT_CALL(app_mngr_, ManageHMICommand(language)); - - smart_objects::SmartObjectSPtr support_language( - new smart_objects::SmartObject(smart_objects::SmartType_Map)); - EXPECT_CALL( - mock_message_helper_, - CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetSupportedLanguages, _)) - .WillOnce(Return(support_language)); - EXPECT_CALL(app_mngr_, ManageHMICommand(support_language)); - - smart_objects::SmartObjectSPtr capabilities( - new smart_objects::SmartObject(smart_objects::SmartType_Map)); - EXPECT_CALL(mock_message_helper_, - CreateModuleInfoSO(hmi_apis::FunctionID::VR_GetCapabilities, _)) - .WillOnce(Return(capabilities)); - EXPECT_CALL(app_mngr_, ManageHMICommand(capabilities)); - } - - void PrepareEvent(bool is_message_contain_param, - Event& event, - bool is_vr_cooperating_available = false) { - MessageSharedPtr msg = CreateMessage(smart_objects::SmartType_Map); - if (is_message_contain_param) { - (*msg)[am::strings::msg_params][am::strings::available] = - is_vr_cooperating_available; - } - event.set_smart_object(*msg); - } - - VRIsReadyRequestPtr command_; - application_manager_test::MockHMICapabilities mock_hmi_capabilities_; -}; - -TEST_F(VRIsReadyRequestTest, Run_NoKeyAvailableInMessage_HmiInterfacesIgnored) { - const bool is_vr_cooperating_available = false; - const bool is_send_message_to_hmi = true; - const bool is_message_contain_param = false; - Event event(hmi_apis::FunctionID::VR_IsReady); - PrepareEvent(is_message_contain_param, event); - SetUpExpectations(is_vr_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_NOT_RESPONSE); - command_->on_event(event); -} - -TEST_F(VRIsReadyRequestTest, Run_KeyAvailableEqualToFalse_StateNotAvailable) { - const bool is_vr_cooperating_available = false; - const bool is_send_message_to_hmi = false; - const bool is_message_contain_param = true; - Event event(hmi_apis::FunctionID::VR_IsReady); - PrepareEvent(is_message_contain_param, event); - SetUpExpectations(is_vr_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_NOT_AVAILABLE); - command_->on_event(event); -} - -TEST_F(VRIsReadyRequestTest, Run_KeyAvailableEqualToTrue_StateAvailable) { - const bool is_vr_cooperating_available = true; - const bool is_send_message_to_hmi = true; - const bool is_message_contain_param = true; - Event event(hmi_apis::FunctionID::VR_IsReady); - PrepareEvent(is_message_contain_param, event, is_vr_cooperating_available); - SetUpExpectations(is_vr_cooperating_available, - is_send_message_to_hmi, - is_message_contain_param, - am::HmiInterfaces::STATE_AVAILABLE); - command_->on_event(event); -} - -TEST_F(VRIsReadyRequestTest, Run_HMIDoestRespond_SendMessageToHMIByTimeout) { - const bool is_send_message_by_timeout = true; - ExpectSendMessagesToHMI(is_send_message_by_timeout); - command_->onTimeOut(); -} - -} // namespace vr_is_ready_request -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test diff --git a/src/components/application_manager/test/commands/hmi/vr_is_ready_response_test.cc b/src/components/application_manager/test/commands/hmi/vr_is_ready_response_test.cc deleted file mode 100644 index 37e945bc11..0000000000 --- a/src/components/application_manager/test/commands/hmi/vr_is_ready_response_test.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2016, 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 "gtest/gtest.h" -#include "utils/shared_ptr.h" -#include "smart_objects/smart_object.h" -#include "commands/commands_test.h" -#include "application_manager/mock_hmi_capabilities.h" -#include "application_manager/commands/hmi/vr_is_ready_response.h" -#include "application_manager/mock_event_dispatcher.h" - -namespace test { -namespace components { -namespace commands_test { -namespace hmi_commands_test { -namespace vr_is_ready_response { - -using ::testing::Return; -using ::utils::SharedPtr; -using ::testing::NiceMock; -namespace am = ::application_manager; -namespace strings = ::application_manager::strings; -namespace hmi_response = am::hmi_response; -using am::commands::VRIsReadyResponse; -using test::components::event_engine_test::MockEventDispatcher; - -typedef SharedPtr<VRIsReadyResponse> VRIsReadyResponsePtr; - -class VRIsReadyResponseTest : public CommandsTest<CommandsTestMocks::kIsNice> { -}; - -TEST_F(VRIsReadyResponseTest, RUN_SUCCESS) { - VRIsReadyResponsePtr command(CreateCommand<VRIsReadyResponse>()); - - 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 vr_is_ready_response -} // namespace hmi_commands_test -} // namespace commands_test -} // namespace components -} // namespace test |